From 388e79e9fcbf689d5708134534e55d176cfbcee3 Mon Sep 17 00:00:00 2001 From: Preston Timmons Date: Wed, 11 Mar 2015 11:00:17 -0500 Subject: Fixed #24493 -- Added BaseContext.setdefault() --- tests/template_tests/test_context.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/template_tests/test_context.py b/tests/template_tests/test_context.py index 8331904f64..9c23a38af2 100644 --- a/tests/template_tests/test_context.py +++ b/tests/template_tests/test_context.py @@ -30,6 +30,17 @@ class ContextTests(SimpleTestCase): self.assertEqual(c['a'], 3) self.assertEqual(c['a'], 1) + def test_setdefault(self): + c = Context() + + x = c.setdefault('x', 42) + self.assertEqual(x, 42) + self.assertEqual(c['x'], 42) + + x = c.setdefault('x', 100) + self.assertEqual(x, 42) + self.assertEqual(c['x'], 42) + def test_resolve_on_context_method(self): """ #17778 -- Variable shouldn't resolve RequestContext methods -- cgit v1.3