Ticket #17778: 17778-testcase.patch

File 17778-testcase.patch, 1.0 KB (added by Aymeric Augustin, 13 years ago)
  • tests/regressiontests/templates/context.py

     
    11# coding: utf-8
    2 from django.template import Context
     2from django.template import Context, Variable, VariableDoesNotExist
    33from django.utils.unittest import TestCase
    44
    55
    66class ContextTests(TestCase):
     7
    78    def test_context(self):
    89        c = Context({"a": 1, "b": "xyzzy"})
    910        self.assertEqual(c["a"], 1)
     
    1415        self.assertEqual(c.pop(), {"a": 2})
    1516        self.assertEqual(c["a"], 1)
    1617        self.assertEqual(c.get("foo", 42), 42)
     18
     19    def test_resolve_on_context_method(self):
     20        # Regression test for #17778
     21        empty_context = Context()
     22        self.assertRaises(VariableDoesNotExist,
     23                Variable('no_such_variable').resolve, empty_context)
     24        self.assertRaises(VariableDoesNotExist,
     25                Variable('new').resolve, empty_context)
     26
Back to Top