Example #1
0
    def makedirs(self, path):
        """Create directory entries for a path

        Raise OSError if the path already exists.

        """
        path = self.abspath(path)
        entry = self._direntry(path)
        if entry is not None:
            raise _OSError(errno.EEXIST, path)

        new_entries = util.build_nested_dir_dict(path)
        util.merge_dicts(new_entries, self._entries)
Example #2
0
File: mfs.py Project: Gerg/mockfs
    def makedirs(self, path):
        """Create directory entries for a path

        Raise OSError if the path already exists.

        """
        path = self.abspath(path)
        entry = self._direntry(path)
        if entry is not None:
            raise _OSError(errno.EEXIST, path)

        new_entries = util.build_nested_dir_dict(path)
        util.merge_dicts(new_entries, self._entries)
Example #3
0
File: mfs.py Project: ogsy/mockfs
 def add_entries(self, entries):
     """Add new entries to mockfs."""
     new_entries = util.build_nested_dict(entries)
     util.merge_dicts(new_entries, self._entries)
Example #4
0
File: mfs.py Project: ogsy/mockfs
 def makedirs(self, path):
     """Create directory entries for a path"""
     path = self.abspath(path)
     new_entries = util.build_nested_dir_dict(path)
     util.merge_dicts(new_entries, self._entries)
Example #5
0
    def test_merge_conflict_dicts(self):
        src = {"a": {"b": "src"}}
        dst = {"a": {"b": "dst"}}

        util.merge_dicts(src, dst)
        self.assertEqual(dst["a"]["b"], "src")
Example #6
0
 def test_merge_no_overlap(self):
     a = {"a": 1}
     b = {"b": 2}
     util.merge_dicts(a, b)
     self.assertEqual(b["a"], 1)
     self.assertEqual(b["b"], 2)
Example #7
0
 def test_merge_overrides(self):
     a = {"a": 1}
     b = {"a": 2}
     util.merge_dicts(a, b)
     self.assertEqual(b["a"], 1)
Example #8
0
 def test_merge_extends_lists(self):
     a = {"a": [1, 2]}
     b = {"a": [3, 4]}
     util.merge_dicts(a, b)
     self.assertEqual(b["a"], [3, 4, 1, 2])
Example #9
0
 def test_merge_no_overlap(self):
     a = {'a': 1}
     b = {'b': 2}
     util.merge_dicts(a, b)
     self.assertEqual(b['a'], 1)
     self.assertEqual(b['b'], 2)
Example #10
0
 def test_merge_overrides(self):
     a = {'a': 1}
     b = {'a': 2}
     util.merge_dicts(a, b)
     self.assertEqual(b['a'], 1)
Example #11
0
    def test_merge_conflict_dicts(self):
        src = {'a': {'b': 'src'}}
        dst = {'a': {'b': 'dst'}}

        util.merge_dicts(src, dst)
        self.assertEqual(dst['a']['b'], 'src')
Example #12
0
 def test_merge_no_overlap(self):
     a = {'a': 1}
     b = {'b': 2}
     util.merge_dicts(a, b)
     self.assertEqual(b['a'], 1)
     self.assertEqual(b['b'], 2)
Example #13
0
 def test_merge_overrides(self):
     a = {'a': 1}
     b = {'a': 2}
     util.merge_dicts(a, b)
     self.assertEqual(b['a'], 1)
Example #14
0
 def test_merge_extends_lists(self):
     a = {'a': [1, 2]}
     b = {'a': [3, 4]}
     util.merge_dicts(a, b)
     self.assertEqual(b['a'], [3, 4, 1, 2])
Example #15
0
 def add_entries(self, entries):
     """Add new entries to mockfs."""
     new_entries = util.build_nested_dict(entries)
     util.merge_dicts(new_entries, self._entries)