From: Daniel Morrison Date: Mon, 10 Nov 2014 03:48:01 +0000 (-0500) Subject: Make unittests easier to deal with. X-Git-Url: https://git.devinivas.org/?a=commitdiff_plain;h=c5279db4e24499d6ee49f1b444087be50f74ed90;p=chevron.git 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 --- 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