diff options
author | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-03-24 14:51:01 -0700 |
---|---|---|
committer | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-03-24 14:51:01 -0700 |
commit | 9b60fe6beb5053de7bfdc2e67451f151c71c361a (patch) | |
tree | a1960eb29b080324f1b8f8ac6cda7fc62ea49473 | |
parent | 2a786f00edf11689114672ff6996f036a31dc119 (diff) | |
download | pystache-9b60fe6beb5053de7bfdc2e67451f151c71c361a.tar.gz |
Added a final LoaderTests unit test for the template attribute case.
-rw-r--r-- | tests/test_custom_template.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test_custom_template.py b/tests/test_custom_template.py index 12dabd2..d67b5fc 100644 --- a/tests/test_custom_template.py +++ b/tests/test_custom_template.py @@ -222,6 +222,36 @@ class LoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin): custom.template_encoding = 'utf-8' self._assert_template(Loader(), custom, u'é') + def test_load__template__correct_reader(self): + """ + Test that reader.unicode() is called with the correct arguments. + + This test is a catch-all for the template attribute in addition to + the other test cases. + + """ + class TestReader(Reader): + + def __init__(self): + self.s = None + self.encoding = None + + def unicode(self, s, encoding=None): + self.s = s + self.encoding = encoding + return u"foo" + + reader = TestReader() + loader = Loader(reader=reader) + + custom = Template() + custom.template = "template-foo" + custom.template_encoding = "encoding-foo" + + self._assert_template(loader, custom, u'foo') + self.assertEquals(reader.s, "template-foo") + self.assertEquals(reader.encoding, "encoding-foo") + # TODO: migrate these tests into the LoaderTests class. # TODO: rename the get_template() tests to test load(). |