diff options
author | Gustavo Niemeyer <gustavo@niemeyer.net> | 2007-11-11 14:20:17 -0500 |
---|---|---|
committer | Gustavo Niemeyer <gustavo@niemeyer.net> | 2007-11-11 14:20:17 -0500 |
commit | 990945320feecf1c5352382c1de2ec86bf6993b2 (patch) | |
tree | 4da3ae2546670c78070eb95990b16385798a8279 /test.py | |
parent | 1749238fbb54eec370a3bec91c4a64cf369798ab (diff) | |
download | mocker-990945320feecf1c5352382c1de2ec86bf6993b2.tar.gz |
Implemented delitem action kind.
Diffstat (limited to 'test.py')
-rwxr-xr-x | test.py | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -1264,6 +1264,12 @@ class ActionTest(unittest.TestCase): action.execute(obj) self.assertEquals(obj, {"a": 1}) + def test_execute_delitem(self): + obj = {"a": 1, "b": 2} + action = Action("delitem", ("a",), {}) + action.execute(obj) + self.assertEquals(obj, {"b": 2}) + def test_execute_len(self): obj = [1, 2, 3] action = Action("len", (), {}) @@ -1540,6 +1546,10 @@ class PathTest(unittest.TestCase): path = Path(self.mock, None, [Action("setitem", ("key", "value"), {})]) self.assertEquals(str(path), "obj['key'] = 'value'") + def test_str_delitem(self): + path = Path(self.mock, None, [Action("delitem", ("key",), {})]) + self.assertEquals(str(path), "del obj['key']") + def test_str_len(self): path = Path(self.mock, None, [Action("len", (), {})]) self.assertEquals(str(path), "len(obj)") @@ -1869,6 +1879,14 @@ class MockTest(unittest.TestCase): self.assertEquals(path, self.mock.__mocker_path__ + Action("setitem", ("key", "value"), {})) + def test_delitem(self): + del self.mock["key"] + (path,) = self.paths + self.assertEquals(type(path), Path) + self.assertTrue(path.parent_path is self.mock.__mocker_path__) + self.assertEquals(path, self.mock.__mocker_path__ + + Action("delitem", ("key",), {})) + def test_len(self): self.assertEquals(len(self.mock), 42) (path,) = self.paths |