Commit c2a31361 by Chris Jerdonek

More progress on LoaderTests: template attribute.

parent 830eaa7b
...@@ -123,7 +123,7 @@ class View(CustomizedTemplate): ...@@ -123,7 +123,7 @@ class View(CustomizedTemplate):
class Loader(object): class Loader(object):
""" """
Supports loading the template of a CustomizedTemplate instance. Supports loading a custom-specified template.
""" """
......
...@@ -139,7 +139,7 @@ class ViewTestCase(unittest.TestCase): ...@@ -139,7 +139,7 @@ class ViewTestCase(unittest.TestCase):
class LoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin): class LoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
""" """
Tests the custom_template.Loader class. Tests custom_template.Loader.
""" """
...@@ -176,16 +176,51 @@ class LoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin): ...@@ -176,16 +176,51 @@ class LoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
self.assertIs(loader.locator, locator) self.assertIs(loader.locator, locator)
def test_load__template__basic(self): def _assert_template(self, loader, custom, expected):
self.assertString(loader.load(custom), expected)
def test_load__template__type_str(self):
""" """
Test the template attribute. Test the template attribute: str string.
""" """
template = Template() custom = Template()
template.template = "abc" custom.template = "abc"
loader = Loader() self._assert_template(Loader(), custom, u"abc")
self.assertString(loader.load(template), u"abc")
def test_load__template__type_unicode(self):
"""
Test the template attribute: unicode string.
"""
custom = Template()
custom.template = u"abc"
self._assert_template(Loader(), custom, u"abc")
def test_load__template__unicode_non_ascii(self):
"""
Test the template attribute: non-ascii unicode string.
"""
custom = Template()
custom.template = u"é"
self._assert_template(Loader(), custom, u"é")
def test_load__template__with_template_encoding(self):
"""
Test the template attribute: with template encoding attribute.
"""
custom = Template()
custom.template = u'é'.encode('utf-8')
self.assertRaises(UnicodeDecodeError, self._assert_template, Loader(), custom, u'é')
custom.template_encoding = 'utf-8'
self._assert_template(Loader(), custom, u'é')
# TODO: migrate these tests into the LoaderTests class. # TODO: migrate these tests into the LoaderTests class.
......
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