From c5279db4e24499d6ee49f1b444087be50f74ed90 Mon Sep 17 00:00:00 2001 From: Daniel Morrison Date: Sun, 9 Nov 2014 22:48:01 -0500 Subject: [PATCH] Make unittests easier to deal with. - Test everything ./test_spec.py - Test suite ./test_spec.py inverted - Test unit ./test_spec.py inverted.test_7 --- test_spec.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test_spec.py b/test_spec.py index 901f5ea..d45fd87 100755 --- a/test_spec.py +++ b/test_spec.py @@ -11,6 +11,7 @@ STACHE = render def _test_case_from_path(json_path): + json_path = '%s.json' % json_path class MustacheTestCase(unittest.TestCase): """A simple yaml based test case""" @@ -32,8 +33,8 @@ def _test_case_from_path(json_path): yaml = json.load(f) # Generates a unit test for each test object - for test in yaml['tests']: - vars()['test_'+test['name']] = _test_from_object(test) + for i, test in enumerate(yaml['tests']): + vars()['test_%s' % i] = _test_from_object(test) # Return the built class return MustacheTestCase @@ -42,6 +43,7 @@ def _test_case_from_path(json_path): for spec in SPECS: # Ignore optional tests if spec[0] is not '~': + spec = spec.split('.')[0] globals()[spec] = _test_case_from_path(os.path.join(SPECS_PATH, spec)) # Run unit tests from command line -- 2.47.3