diff options
-rw-r--r-- | templates/python/context.py | 3 | ||||
-rw-r--r-- | templates/python/context_tests.py | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/templates/python/context.py b/templates/python/context.py index 9bb8056..df86b02 100644 --- a/templates/python/context.py +++ b/templates/python/context.py @@ -21,3 +21,6 @@ class Context: def __contains__(self, key): return key in self._vars + + def __delitem__(self, key): + del self._vars[key] diff --git a/templates/python/context_tests.py b/templates/python/context_tests.py index 9db6bd0..24d8f51 100644 --- a/templates/python/context_tests.py +++ b/templates/python/context_tests.py @@ -17,6 +17,12 @@ class ContextTests(unittest.TestCase): ctx = Context() self.assertFalse("foo" in ctx) + def test_no_longer_contains_item(self): + ctx = Context() + ctx["foo"] = "bar" + del ctx["foo"] + self.assertFalse("foo" in ctx) + def test_contains_item(self): ctx = Context() ctx["foo"] = "bar" |