From 990945320feecf1c5352382c1de2ec86bf6993b2 Mon Sep 17 00:00:00 2001 From: Gustavo Niemeyer Date: Sun, 11 Nov 2007 14:20:17 -0500 Subject: Implemented delitem action kind. --- test.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test.py') diff --git a/test.py b/test.py index 2d9475a..19b132b 100755 --- a/test.py +++ b/test.py @@ -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 -- cgit v1.2.1