]> Devi Nivas Git - chevron.git/commitdiff
Add a unittest for an edge-case recursion error.
authornoah morrison <noah@morrison.ph>
Fri, 16 Jan 2015 15:51:20 +0000 (10:51 -0500)
committernoah morrison <noah@morrison.ph>
Fri, 16 Jan 2015 15:51:20 +0000 (10:51 -0500)
Currently this makes chevron run in an infinite loop
(Until recursion depth limit happens)

test_spec.py

index 778762582e763ec2fef68a5a27c15b07d663ea59..7b9bbe8f39faa1def82b509eff52659372fb87b7 100755 (executable)
@@ -115,6 +115,20 @@ class ExpandedCoverage(unittest.TestCase):
 
         self.assertEqual(result, expected)
 
+    def test_recursion(self):
+        args = {
+            'template': '{{# 1.2 }}{{# data }}{{.}}{{/ data }}{{/ 1.2 }}',
+            'data': {'1': {'2': [{'data': ["1", "2", "3"]}]}}
+        }
+
+        try:
+            result = chevron.render(**args)
+        except RuntimeError:
+            result = 'recursion'
+        expected = '123'
+
+        self.assertEqual(result, expected)
+
 
 # Run unit tests from command line
 if __name__ == "__main__":