Commit 51e31f57 by Chris Jerdonek

Removed search_dirs from the SpecLoader constructor.

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