]> Devi Nivas Git - chevron.git/commitdiff
fix line numbers in errors
authorSamuel Colvin <s@muelcolvin.com>
Mon, 3 Jul 2017 14:53:12 +0000 (15:53 +0100)
committerSamuel Colvin <s@muelcolvin.com>
Mon, 3 Jul 2017 14:53:12 +0000 (15:53 +0100)
.gitignore
chevron/tokenizer.py
test_spec.py

index e86540c701e93ad02c4a81d5d96f56beb0999539..4707f0acf716524f51e6342195188bd4706ee328 100644 (file)
@@ -28,3 +28,4 @@ pip-log.txt
 
 # Mr Developer
 .mr.developer.cfg
+.idea/
index ed5799ef0ce606976b22670294ef73bc49c2e2e8..4362eabda6a513c53371ebb72cc52f8cb154f0c2 100644 (file)
@@ -160,6 +160,9 @@ def tokenize(template, def_ldel='{{', def_rdel='}}'):
     the literal itself.
     """
 
+    global _CURRENT_LINE, _LAST_TAG_LINE
+    _CURRENT_LINE = 1
+    _LAST_TAG_LINE = None
     # If the template is a file-like object then read it
     try:
         template = template.read()
index 5b3481152700af9a6ff2dc1f5296db7a1d957be4..a02819eb13b26df10092de491adbb42911b2bbfe 100755 (executable)
@@ -202,6 +202,22 @@ class ExpandedCoverage(unittest.TestCase):
 
         self.assertRaises(chevron.ChevronError, chevron.render, **args)
 
+    def test_current_line_rest(self):
+        args = {
+            'template': 'first line\nsecond line\n {{ foo } bar',
+            'data': {'foo': 'xx'}
+        }
+
+        self.assertRaisesRegexp(chevron.ChevronError,
+                                'unclosed tag at line 3',
+                                chevron.render, **args)
+        self.assertRaisesRegexp(chevron.ChevronError,
+                                'unclosed tag at line 3',
+                                chevron.render, **args)
+        self.assertRaisesRegexp(chevron.ChevronError,
+                                'unclosed tag at line 3',
+                                chevron.render, **args)
+
 
 # Run unit tests from command line
 if __name__ == "__main__":