diff options
author | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-04-21 11:03:09 -0700 |
---|---|---|
committer | Chris Jerdonek <chris.jerdonek@gmail.com> | 2012-04-21 11:03:09 -0700 |
commit | 150d4c45563015b60afe79f6b011c0b21f6594b7 (patch) | |
tree | f54ce10dc5a930587694168d795a70a10ccd1545 | |
parent | ae755339578bebdf1134f1b8abf77dd8dceaabc9 (diff) | |
download | pystache-150d4c45563015b60afe79f6b011c0b21f6594b7.tar.gz |
The pystache-tests script now accepts a spec test directory argument.
-rw-r--r-- | pystache/tests/main.py | 11 | ||||
-rw-r--r-- | pystache/tests/test_mustachespec.py | 10 | ||||
-rw-r--r-- | tox.ini | 4 |
3 files changed, 19 insertions, 6 deletions
diff --git a/pystache/tests/main.py b/pystache/tests/main.py index 7cfcfeb..5b08471 100644 --- a/pystache/tests/main.py +++ b/pystache/tests/main.py @@ -32,10 +32,17 @@ def run_tests(sys_argv): try: # TODO: use optparse command options instead. project_dir = sys_argv[1] - sys_argv.pop() + sys_argv.pop(1) except IndexError: project_dir = PROJECT_DIR + try: + # TODO: use optparse command options instead. + spec_test_dir = sys_argv[1] + sys_argv.pop(1) + except IndexError: + spec_test_dir = SPEC_TEST_DIR + if len(sys_argv) <= 1 or sys_argv[-1].startswith("-"): # Then no explicit module or test names were provided, so # auto-detect all unit tests. @@ -43,7 +50,7 @@ def run_tests(sys_argv): sys_argv.extend(module_names) _PystacheTestProgram._text_doctest_dir = project_dir - _PystacheTestProgram._spec_test_dir = SPEC_TEST_DIR + _PystacheTestProgram._spec_test_dir = spec_test_dir # We pass None for the module because we do not want the unittest # module to resolve module names relative to a given module. diff --git a/pystache/tests/test_mustachespec.py b/pystache/tests/test_mustachespec.py index 273beed..453c5ea 100644 --- a/pystache/tests/test_mustachespec.py +++ b/pystache/tests/test_mustachespec.py @@ -77,14 +77,18 @@ def get_spec_tests(spec_test_dir): case = _deserialize_spec_test(data, path) cases.append(case) + # Store this as a value so that CheckSpecTestsFound is not checking + # a reference to cases that contains itself. + spec_test_count = len(cases) + # This test case lets us alert the user that spec tests are missing. class CheckSpecTestsFound(unittest.TestCase): def runTest(self): - if len(cases) > 0: + if spec_test_count > 0: return - raise Exception("Spec tests not found in: %s\n " - "Consult the README file on how to add the Mustache spec tests." % repr(spec_test_dir)) + raise Exception("Spec tests not found--\n in %s\n" + " Consult the README file on how to add the Mustache spec tests." % repr(spec_test_dir)) case = CheckSpecTestsFound() cases.append(case) @@ -6,7 +6,9 @@ envlist = py24,py25,py26,py27,py31,py32 [testenv] +# Change the working directory so that we don't import the pystache located +# in the original location. changedir = {envbindir} commands = - pystache-test {toxinidir} + pystache-test {toxinidir} {toxinidir}/ext/spec/specs |