From a415af33dbc390525fa3019d8fbbad03b4079b02 Mon Sep 17 00:00:00 2001 From: Chris Jerdonek Date: Sat, 20 Oct 2012 14:30:48 -0700 Subject: Tweak merged patch. --- pystache/tests/test_defaults.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/pystache/tests/test_defaults.py b/pystache/tests/test_defaults.py index 903867a..c78ea7c 100644 --- a/pystache/tests/test_defaults.py +++ b/pystache/tests/test_defaults.py @@ -1,19 +1,28 @@ +# coding: utf-8 + +""" +Unit tests for defaults.py. + +""" + import unittest import pystache -import pystache.defaults from pystache.tests.common import AssertStringMixin -class TestDefaults(unittest.TestCase, AssertStringMixin): - """Set of tests to ensure that the user can override defaults.""" +# TODO: make sure each default has at least one test. +class DefaultsConfigurableTestCase(unittest.TestCase, AssertStringMixin): + """Tests that the user can change the defaults at runtime.""" + + # TODO: switch to using a context manager after 2.4 is deprecated. def setUp(self): - """save all the defaults.""" + """Save the defaults.""" defaults = [ 'DECODE_ERRORS', 'DELIMITERS', - 'FILE_ENCODING', 'MISSING_TAGS', + 'FILE_ENCODING', 'MISSING_TAGS', 'SEARCH_DIRS', 'STRING_ENCODING', 'TAG_ESCAPE', 'TEMPLATE_EXTENSION' ] @@ -26,7 +35,7 @@ class TestDefaults(unittest.TestCase, AssertStringMixin): setattr(pystache.defaults, key, value) def test_tag_escape(self): - """Test that TAG_ESCAPE default takes effect.""" + """Test that changes to defaults.TAG_ESCAPE take effect.""" template = u"{{foo}}" context = {'foo': '<'} actual = pystache.render(template, context) @@ -37,7 +46,7 @@ class TestDefaults(unittest.TestCase, AssertStringMixin): self.assertString(actual, u"<") def test_delimiters(self): - """Test that DELIMITERS default takes effect.""" + """Test that changes to defaults.DELIMITERS take effect.""" template = u"[[foo]]{{foo}}" context = {'foo': 'FOO'} actual = pystache.render(template, context) @@ -48,13 +57,12 @@ class TestDefaults(unittest.TestCase, AssertStringMixin): self.assertString(actual, u"FOO{{foo}}") def test_missing_tags(self): - """Test that MISSING_TAGS default take effect.""" + """Test that changes to defaults.MISSING_TAGS take effect.""" template = u"{{foo}}" context = {} actual = pystache.render(template, context) self.assertString(actual, u"") pystache.defaults.MISSING_TAGS = 'strict' - self.assertRaises(pystache.context.KeyNotFoundError, pystache.render, template, context) -- cgit v1.2.1