diff options
author | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-04-14 10:26:21 -0700 |
---|---|---|
committer | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-04-14 10:26:21 -0700 |
commit | 0db070487943ad43bed2122ab57283f8a479799d (patch) | |
tree | 8143cdeb43af8d4b718a2586b1f60f557d473a2c /pystache | |
parent | eacbdb3b6dacfbd86be9c07f18cedb2e3611a071 (diff) | |
download | pystache-0db070487943ad43bed2122ab57283f8a479799d.tar.gz |
Stubbed out a stand-alone script command.
The eventual goal is to have a test script that behaves well with tox.
Using a stand-alone test script that we control instead of an
out-of-the-box command-line script like nosetests or Distribute's test
should give us more flexibility in dealing with any idiosyncracies
that occur with tox.
Diffstat (limited to 'pystache')
-rw-r--r-- | pystache/commands/test.py | 24 | ||||
-rw-r--r-- | pystache/tests/test_locator.py | 15 | ||||
-rw-r--r-- | pystache/tests/test_specloader.py | 21 |
3 files changed, 48 insertions, 12 deletions
diff --git a/pystache/commands/test.py b/pystache/commands/test.py new file mode 100644 index 0000000..f8afb96 --- /dev/null +++ b/pystache/commands/test.py @@ -0,0 +1,24 @@ +# coding: utf-8 + +""" +This module provides a command to test pystache (unit tests, doctests, etc). + +""" + +import sys + +# TODO: make nose unnecessary. +import nose + +import pystache + + +def main(sys_argv): + # This does not work with the --with-doctest flag yet because of the + # following issue: + # https://github.com/nose-devs/nose/issues/383 + nose.main(module=pystache) + + +if __name__=='__main__': + main(sys.argv) diff --git a/pystache/tests/test_locator.py b/pystache/tests/test_locator.py index ddebef8..d11c192 100644 --- a/pystache/tests/test_locator.py +++ b/pystache/tests/test_locator.py @@ -34,13 +34,20 @@ class LocatorTests(unittest.TestCase): locator = Locator(extension=False) self.assertTrue(locator.template_extension is False) + def _assert_paths(self, actual, expected): + """ + Assert that two paths are the same. + + """ + self.assertEqual(actual, expected) + def test_get_object_directory(self): locator = Locator() obj = SayHello() actual = locator.get_object_directory(obj) - self.assertEqual(actual, os.path.abspath(DATA_DIR)) + self._assert_paths(actual, DATA_DIR) def test_get_object_directory__not_hasattr_module(self): locator = Locator() @@ -111,9 +118,9 @@ class LocatorTests(unittest.TestCase): obj = SayHello() actual = locator.find_object(search_dirs=[], obj=obj, file_name='sample_view.mustache') - expected = os.path.abspath(os.path.join(DATA_DIR, 'sample_view.mustache')) + expected = os.path.join(DATA_DIR, 'sample_view.mustache') - self.assertEqual(actual, expected) + self._assert_paths(actual, expected) def test_find_object__none_file_name(self): locator = Locator() @@ -121,7 +128,7 @@ class LocatorTests(unittest.TestCase): obj = SayHello() actual = locator.find_object(search_dirs=[], obj=obj) - expected = os.path.abspath(os.path.join(DATA_DIR, 'say_hello.mustache')) + expected = os.path.join(DATA_DIR, 'say_hello.mustache') self.assertEqual(actual, expected) diff --git a/pystache/tests/test_specloader.py b/pystache/tests/test_specloader.py index ac32dd6..6fc2256 100644 --- a/pystache/tests/test_specloader.py +++ b/pystache/tests/test_specloader.py @@ -19,10 +19,8 @@ from pystache import TemplateSpec from pystache.locator import Locator from pystache.loader import Loader from pystache.specloader import SpecLoader -from pystache.tests.common import DATA_DIR -from pystache.tests.common import EXAMPLES_DIR -from pystache.tests.common import AssertIsMixin -from pystache.tests.common import AssertStringMixin +from pystache.tests.common import DATA_DIR, EXAMPLES_DIR +from pystache.tests.common import AssertIsMixin, AssertStringMixin from pystache.tests.data.views import SampleView from pystache.tests.data.views import NonAscii @@ -358,6 +356,13 @@ class TemplateSpecTests(unittest.TestCase): view.template_extension = 'txt' self._assert_template_location(view, (None, 'sample_view.txt')) + def _assert_paths(self, actual, expected): + """ + Assert that two paths are the same. + + """ + self.assertEqual(actual, expected) + def test_find__with_directory(self): """ Test _find() with a view that has a directory specified. @@ -370,9 +375,9 @@ class TemplateSpecTests(unittest.TestCase): self.assertTrue(loader._find_relative(view)[0] is not None) actual = loader._find(view) - expected = os.path.abspath(os.path.join(DATA_DIR, 'foo/bar.txt')) + expected = os.path.join(DATA_DIR, 'foo/bar.txt') - self.assertEqual(actual, expected) + self._assert_paths(actual, expected) def test_find__without_directory(self): """ @@ -385,9 +390,9 @@ class TemplateSpecTests(unittest.TestCase): self.assertTrue(loader._find_relative(view)[0] is None) actual = loader._find(view) - expected = os.path.abspath(os.path.join(DATA_DIR, 'sample_view.mustache')) + expected = os.path.join(DATA_DIR, 'sample_view.mustache') - self.assertEqual(actual, expected) + self._assert_paths(actual, expected) def _assert_get_template(self, custom, expected): loader = self._make_loader() |