diff options
| author | Tim Graham <timograham@gmail.com> | 2013-08-12 12:41:39 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-08-12 12:41:39 -0400 |
| commit | 71b5617c24bb997db294480f07611233069e3359 (patch) | |
| tree | ec1ed7cdba18a6a3d3e011ad5ccc28b97eef786c /tests/template_tests/test_context.py | |
| parent | 6bdb3b1135d1bd7b2dc24131b9d26ac19ebdba67 (diff) | |
Fixed #17778 -- Prevented class attributes on context from resolving as template variables.
Thanks KyleMac for the report, regebro for the patch, and Aymeric for the test.
Diffstat (limited to 'tests/template_tests/test_context.py')
| -rw-r--r-- | tests/template_tests/test_context.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/template_tests/test_context.py b/tests/template_tests/test_context.py index ca167a73f3..7bcfb7f9f2 100644 --- a/tests/template_tests/test_context.py +++ b/tests/template_tests/test_context.py @@ -2,7 +2,7 @@ from unittest import TestCase -from django.template import Context +from django.template import Context, Variable, VariableDoesNotExist class ContextTests(TestCase): @@ -25,3 +25,12 @@ class ContextTests(TestCase): with c.push(a=3): self.assertEqual(c['a'], 3) self.assertEqual(c['a'], 1) + + def test_resolve_on_context_method(self): + # Regression test for #17778 + empty_context = Context() + self.assertRaises(VariableDoesNotExist, + Variable('no_such_variable').resolve, empty_context) + self.assertRaises(VariableDoesNotExist, + Variable('new').resolve, empty_context) + self.assertEqual(Variable('new').resolve(Context({'new': 'foo'})), 'foo') |
