Commit c689ce93 by Chris Jerdonek

Bug fix: View(context=context, **kwargs) could modify the passed context.

Also added a test case.
parent a68ddb39
......@@ -50,6 +50,9 @@ class View(object):
Construct a View instance.
"""
if context is None:
context = {}
if load_template is not None:
self._load_template = load_template
......
......@@ -25,6 +25,15 @@ class ViewTestCase(unittest.TestCase):
view = TestView()
self.assertEquals(view.template, "foo")
def test_init__kwargs_does_not_modify_context(self):
"""
Test that passing **kwargs does not modify the passed context.
"""
context = {"foo": "bar"}
view = View(context=context, fuzz="buzz")
self.assertEquals(context, {"foo": "bar"})
def test_basic(self):
view = Simple("Hi {{thing}}!", { 'thing': 'world' })
self.assertEquals(view.render(), "Hi world!")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment