Commit 51e31f57 by Chris Jerdonek

Removed search_dirs from the SpecLoader constructor.

parent 81c6a9c4
...@@ -122,8 +122,8 @@ class View(TemplateSpec): ...@@ -122,8 +122,8 @@ class View(TemplateSpec):
return renderer.render(template, self.context) return renderer.render(template, self.context)
# TODO: get this class fully working with test cases, and then refactor # TODO: add test cases for this class, and then refactor while replacing the
# and replace the View class. # View class.
class SpecLoader(object): class SpecLoader(object):
""" """
...@@ -131,15 +131,11 @@ class SpecLoader(object): ...@@ -131,15 +131,11 @@ class SpecLoader(object):
""" """
def __init__(self, search_dirs=None, loader=None): def __init__(self, loader=None):
if loader is None: if loader is None:
loader = Loader() loader = Loader()
if search_dirs is None:
search_dirs = []
self.loader = loader self.loader = loader
self.search_dirs = search_dirs
def _find_relative(self, spec): def _find_relative(self, spec):
""" """
...@@ -175,7 +171,7 @@ class SpecLoader(object): ...@@ -175,7 +171,7 @@ class SpecLoader(object):
if dir_path is None: if dir_path is None:
# Then we need to search for the path. # Then we need to search for the path.
path = locator.find_object(spec, self.search_dirs, file_name=file_name) path = locator.find_object(spec, self.loader.search_dirs, file_name=file_name)
else: else:
obj_dir = locator.get_object_directory(spec) obj_dir = locator.get_object_directory(spec)
path = os.path.join(obj_dir, dir_path, file_name) path = os.path.join(obj_dir, dir_path, file_name)
......
...@@ -150,20 +150,12 @@ class SpecLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin): ...@@ -150,20 +150,12 @@ class SpecLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
loader = custom.loader loader = custom.loader
self.assertEquals(loader.extension, 'mustache') self.assertEquals(loader.extension, 'mustache')
self.assertEquals(loader.file_encoding, sys.getdefaultencoding()) self.assertEquals(loader.file_encoding, sys.getdefaultencoding())
# TODO: finish testing the other Loader attributes.
to_unicode = loader.to_unicode to_unicode = loader.to_unicode
# Check search_dirs.
self.assertEquals(custom.search_dirs, [])
def test_init__search_dirs(self):
search_dirs = ['a', 'b']
loader = SpecLoader(search_dirs)
self.assertEquals(loader.search_dirs, ['a', 'b'])
def test_init__loader(self): def test_init__loader(self):
loader = Loader() loader = Loader()
custom = SpecLoader([], loader=loader) custom = SpecLoader(loader=loader)
self.assertIs(custom.loader, loader) self.assertIs(custom.loader, loader)
...@@ -260,8 +252,7 @@ class TemplateSpecTests(unittest.TestCase): ...@@ -260,8 +252,7 @@ class TemplateSpecTests(unittest.TestCase):
# TODO: rename this method to _make_loader(). # TODO: rename this method to _make_loader().
def _make_locator(self): def _make_locator(self):
locator = SpecLoader(search_dirs=[DATA_DIR]) return SpecLoader()
return locator
def _assert_template_location(self, view, expected): def _assert_template_location(self, view, expected):
locator = self._make_locator() locator = self._make_locator()
......
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