1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Allowed Context.push to behave as a context mananger.

Thanks Loic Bistuer for the review.
This commit is contained in:
Curtis Maloney
2013-07-16 21:11:32 +10:00
committed by Tim Graham
parent 828359e52d
commit a3e7d73ed7
7 changed files with 145 additions and 98 deletions

View File

@@ -16,3 +16,12 @@ class ContextTests(TestCase):
self.assertEqual(c.pop(), {"a": 2})
self.assertEqual(c["a"], 1)
self.assertEqual(c.get("foo", 42), 42)
with c.push():
c['a'] = 2
self.assertEqual(c['a'], 2)
self.assertEqual(c['a'], 1)
with c.push(a=3):
self.assertEqual(c['a'], 3)
self.assertEqual(c['a'], 1)