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)
def add_entries(self, entries): """Add new entries to mockfs.""" new_entries = util.build_nested_dict(entries) util.merge_dicts(new_entries, self._entries)
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)
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")
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)
def test_merge_overrides(self): a = {"a": 1} b = {"a": 2} util.merge_dicts(a, b) self.assertEqual(b["a"], 1)
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])
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)
def test_merge_overrides(self): a = {'a': 1} b = {'a': 2} util.merge_dicts(a, b) self.assertEqual(b['a'], 1)
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')
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])