diff options
author | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-07-23 07:07:12 -0700 |
---|---|---|
committer | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-07-23 07:07:12 -0700 |
commit | afe2ab59e14ca71454fd4a88f853fe77f9d087a9 (patch) | |
tree | 365520f6881af165c4e9c7314e9fa29e9255959a /pystache | |
parent | 440064b0bec6ce4afe5874f22f345c583793cc5d (diff) | |
download | pystache-afe2ab59e14ca71454fd4a88f853fe77f9d087a9.tar.gz |
Add a unit test for Locator.find_file().
Diffstat (limited to 'pystache')
-rw-r--r-- | pystache/tests/data/locator/template.txt | 1 | ||||
-rw-r--r-- | pystache/tests/test_locator.py | 12 |
2 files changed, 12 insertions, 1 deletions
diff --git a/pystache/tests/data/locator/template.txt b/pystache/tests/data/locator/template.txt new file mode 100644 index 0000000..bef8160 --- /dev/null +++ b/pystache/tests/data/locator/template.txt @@ -0,0 +1 @@ +Test template file diff --git a/pystache/tests/test_locator.py b/pystache/tests/test_locator.py index 8d4ec9b..ee1c2ff 100644 --- a/pystache/tests/test_locator.py +++ b/pystache/tests/test_locator.py @@ -19,6 +19,9 @@ from pystache.tests.common import DATA_DIR, EXAMPLES_DIR, AssertExceptionMixin from pystache.tests.data.views import SayHello +LOCATOR_DATA_DIR = os.path.join(DATA_DIR, 'locator') + + class LocatorTests(unittest.TestCase, AssertExceptionMixin): def _locator(self): @@ -87,6 +90,13 @@ class LocatorTests(unittest.TestCase, AssertExceptionMixin): self.assertEqual(locator.make_file_name('foo', template_extension='bar'), 'foo.bar') + def test_find_file(self): + locator = Locator() + path = locator.find_file('template.txt', [LOCATOR_DATA_DIR]) + + expected_path = os.path.join(LOCATOR_DATA_DIR, 'template.txt') + self.assertEqual(path, expected_path) + def test_find_name(self): locator = Locator() path = locator.find_name(search_dirs=[EXAMPLES_DIR], template_name='simple') @@ -107,7 +117,7 @@ class LocatorTests(unittest.TestCase, AssertExceptionMixin): locator = Locator() dir1 = DATA_DIR - dir2 = os.path.join(DATA_DIR, 'locator') + dir2 = LOCATOR_DATA_DIR self.assertTrue(locator.find_name(search_dirs=[dir1], template_name='duplicate')) self.assertTrue(locator.find_name(search_dirs=[dir2], template_name='duplicate')) |