diff options
| author | Tim Graham <timograham@gmail.com> | 2013-08-12 12:41:39 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-08-15 10:22:56 -0400 |
| commit | ccff25b1431bd1bb9d633b1ca1d3aff79acc33d9 (patch) | |
| tree | 64d0e626816e828cd1b19a2e595abef67b90ff5c /tests | |
| parent | d2419bb2b85003ba9a35feac8814c9b698ef557c (diff) | |
[1.6.x] 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.
Backport of 71b5617c24 from master.
Diffstat (limited to 'tests')
| -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 05c1dd57b9..778f4051e8 100644 --- a/tests/template_tests/test_context.py +++ b/tests/template_tests/test_context.py @@ -1,5 +1,5 @@ # coding: utf-8 -from django.template import Context +from django.template import Context, Variable, VariableDoesNotExist from django.utils.unittest import TestCase @@ -14,3 +14,12 @@ class ContextTests(TestCase): self.assertEqual(c.pop(), {"a": 2}) self.assertEqual(c["a"], 1) self.assertEqual(c.get("foo", 42), 42) + + 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') |
