]> Devi Nivas Git - chevron.git/commitdiff
Make unittests easier to deal with.
authorDaniel Morrison <dan@morrison.ph>
Mon, 10 Nov 2014 03:48:01 +0000 (22:48 -0500)
committernoah morrison <noah@morrison.ph>
Mon, 10 Nov 2014 23:21:54 +0000 (18:21 -0500)
- Test everything

    ./test_spec.py

- Test suite

    ./test_spec.py inverted

- Test unit

    ./test_spec.py inverted.test_7

test_spec.py

index 901f5ea8e30bd1dbbe3bd04ad39192b89cad249e..d45fd87723e764ac5aad38b78fbec5a00bf841cf 100755 (executable)
@@ -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