Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ pip-log.txt

# Mr Developer
.mr.developer.cfg
.idea/
3 changes: 3 additions & 0 deletions chevron/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
23 changes: 22 additions & 1 deletion test_spec.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

import unittest
import os
import json

import chevron

import sys
if sys.version_info < (2, 7):
import unittest2 as unittest
else:
import unittest

SPECS_PATH = os.path.join('spec', 'specs')
SPECS = [path for path in os.listdir(SPECS_PATH) if path.endswith('.json')]
STACHE = chevron.render
Expand Down Expand Up @@ -202,6 +207,22 @@ def test_closing_tag_only(self):

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__":
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
envlist = py26, py27, py32, py33, py34, py35, pypy, flake8

[testenv]
deps = coverage
deps = coverage,unitest2
commands =
coverage run --source={toxinidir}/chevron {toxinidir}/test_spec.py
coverage report -m
Expand All @@ -12,4 +12,4 @@ commands = python {toxinidir}/test_spec.py

[testenv:flake8]
deps = flake8
commands = flake8
commands = flake8