summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2012-03-31 10:05:00 -0700
committerChris Jerdonek <chris.jerdonek@gmail.com>2012-03-31 10:05:00 -0700
commit4d8d41bb50286c90788a324b8e9bc3e1bee3a710 (patch)
tree51c7c65fa579e4f7e18f7fa01fbb31cfc7dc4770
parent1542217e351fd9c45d25178e0fc92a91a5449cee (diff)
downloadpystache-4d8d41bb50286c90788a324b8e9bc3e1bee3a710.tar.gz
Renamed CustomLoader to SpecLoader.
-rw-r--r--pystache/template_spec.py3
-rw-r--r--tests/test_template_spec.py30
2 files changed, 16 insertions, 17 deletions
diff --git a/pystache/template_spec.py b/pystache/template_spec.py
index 1fd54a9..faab918 100644
--- a/pystache/template_spec.py
+++ b/pystache/template_spec.py
@@ -119,10 +119,9 @@ class View(TemplateSpec):
return renderer.render(template, self.context)
-# TODO: finalize this class's name.
# TODO: get this class fully working with test cases, and then refactor
# and replace the View class.
-class CustomLoader(object):
+class SpecLoader(object):
"""
Supports loading a custom-specified template.
diff --git a/tests/test_template_spec.py b/tests/test_template_spec.py
index 7947de9..510e117 100644
--- a/tests/test_template_spec.py
+++ b/tests/test_template_spec.py
@@ -16,7 +16,7 @@ from examples.inverted import Inverted, InvertedLists
from pystache import TemplateSpec as Template
from pystache import Renderer
from pystache import View
-from pystache.template_spec import CustomLoader
+from pystache.template_spec import SpecLoader
from pystache.locator import Locator
from pystache.loader import Loader
from .common import AssertIsMixin
@@ -136,15 +136,15 @@ class ViewTestCase(unittest.TestCase):
self.assertEquals(view.render(), """one, two, three, empty list""")
-class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
+class SpecLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
"""
- Tests template_spec.CustomLoader.
+ Tests template_spec.SpecLoader.
"""
def test_init__defaults(self):
- custom = CustomLoader()
+ custom = SpecLoader()
# Check the loader attribute.
loader = custom.loader
@@ -157,13 +157,13 @@ class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
def test_init__search_dirs(self):
search_dirs = ['a', 'b']
- loader = CustomLoader(search_dirs)
+ loader = SpecLoader(search_dirs)
self.assertEquals(loader.search_dirs, ['a', 'b'])
def test_init__loader(self):
loader = Loader()
- custom = CustomLoader([], loader=loader)
+ custom = SpecLoader([], loader=loader)
self.assertIs(custom.loader, loader)
@@ -179,7 +179,7 @@ class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
custom = Template()
custom.template = "abc"
- self._assert_template(CustomLoader(), custom, u"abc")
+ self._assert_template(SpecLoader(), custom, u"abc")
def test_load__template__type_unicode(self):
"""
@@ -189,7 +189,7 @@ class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
custom = Template()
custom.template = u"abc"
- self._assert_template(CustomLoader(), custom, u"abc")
+ self._assert_template(SpecLoader(), custom, u"abc")
def test_load__template__unicode_non_ascii(self):
"""
@@ -199,7 +199,7 @@ class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
custom = Template()
custom.template = u"é"
- self._assert_template(CustomLoader(), custom, u"é")
+ self._assert_template(SpecLoader(), custom, u"é")
def test_load__template__with_template_encoding(self):
"""
@@ -209,10 +209,10 @@ class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
custom = Template()
custom.template = u'é'.encode('utf-8')
- self.assertRaises(UnicodeDecodeError, self._assert_template, CustomLoader(), custom, u'é')
+ self.assertRaises(UnicodeDecodeError, self._assert_template, SpecLoader(), custom, u'é')
custom.template_encoding = 'utf-8'
- self._assert_template(CustomLoader(), custom, u'é')
+ self._assert_template(SpecLoader(), custom, u'é')
# TODO: make this test complete.
def test_load__template__correct_loader(self):
@@ -221,7 +221,7 @@ class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
This test tests that the correct reader is called with the correct
arguments. This is a catch-all test to supplement the other
- test cases. It tests CustomLoader.load() independent of reader.unicode()
+ test cases. It tests SpecLoader.load() independent of reader.unicode()
being implemented correctly (and tested).
"""
@@ -238,7 +238,7 @@ class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
return u"foo"
loader = MockLoader()
- custom_loader = CustomLoader()
+ custom_loader = SpecLoader()
custom_loader.loader = loader
view = Template()
@@ -251,7 +251,7 @@ class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
self.assertEquals(loader.encoding, "encoding-foo")
-# TODO: migrate these tests into the CustomLoaderTests class.
+# TODO: migrate these tests into the SpecLoaderTests class.
# TODO: rename the get_template() tests to test load().
# TODO: condense, reorganize, and rename the tests so that it is
# clear whether we have full test coverage (e.g. organized by
@@ -260,7 +260,7 @@ class TemplateSpecTests(unittest.TestCase):
# TODO: rename this method to _make_loader().
def _make_locator(self):
- locator = CustomLoader(search_dirs=[DATA_DIR])
+ locator = SpecLoader(search_dirs=[DATA_DIR])
return locator
def _assert_template_location(self, view, expected):