]> Devi Nivas Git - chevron.git/commitdiff
Updated unittests to deal with partials.
authornoah morrison <noah@morrison.ph>
Thu, 6 Nov 2014 22:16:10 +0000 (17:16 -0500)
committernoah morrison <noah@morrison.ph>
Thu, 6 Nov 2014 22:16:10 +0000 (17:16 -0500)
test_spec.py

index f5967882eca1c41e5a4d27ba840599eded07122d..901f5ea8e30bd1dbbe3bd04ad39192b89cad249e 100755 (executable)
@@ -11,21 +11,30 @@ STACHE = render
 
 
 def _test_case_from_path(json_path):
+
     class MustacheTestCase(unittest.TestCase):
         """A simple yaml based test case"""
+
         def _test_from_object(obj):
             """Generate a unit test from a test object"""
+
             def test_case(self):
-                self.assertEqual(STACHE(obj['template'], obj['data']),
-                                 obj['expected'])
+                result = STACHE(obj['template'], obj['data'],
+                                partials_dict=obj.get('partials', {}))
+
+                self.assertEqual(result, obj['expected'])
+
             test_case.__doc__ = 'suite: {}    desc: {}'.format(spec,
                                                                obj['desc'])
             return test_case
+
         with open(json_path, 'r') as f:
             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)
+
     # Return the built class
     return MustacheTestCase