diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-06-08 14:27:37 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-06-08 14:27:37 -0400 |
commit | a2f80404e7051de1c9f6e07aef052d3c725bb71e (patch) | |
tree | 28ffad163202681c22cf5a8beace22aa12d52417 /test/test_template.py | |
parent | 25287e3f8a0e339449211e2424f7cc35508d4333 (diff) | |
download | mako-a2f80404e7051de1c9f6e07aef052d3c725bb71e.tar.gz |
- correct some misconceptions in how the new lineno thing was built;
record all linenos fully and track printed line numbers accurately
wrt buffered lines and such.
Diffstat (limited to 'test/test_template.py')
-rw-r--r-- | test/test_template.py | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/test/test_template.py b/test/test_template.py index 3dd42be..c4ab99a 100644 --- a/test/test_template.py +++ b/test/test_template.py @@ -1251,15 +1251,44 @@ Text eq_( ModuleInfo.get_module_source_metadata(t.code, full_line_map=True), { + 'full_line_map': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 1, 4, 5, 5, 5, 7, 8, + 8, 8, 8, 8, 8, 8], 'source_encoding': 'ascii', - 'uri': '/some/template', 'filename': None, - 'boilerplate_lines': [1, 21], - 'full_line_map': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 4, 5, 5, 5, 7, 8, 8, - 8, 8, 8, 8, 8], - 'line_map': {34: 8, 21: 1, 22: 4, 23: 5, 26: 7, 27: 8} + 'line_map': {34: 28, 14: 0, 21: 1, 22: 4, 23: 5, 24: 5, + 25: 5, 26: 7, 27: 8, 28: 8}, + 'uri': '/some/template' } + + ) + + def test_metadata_two(self): + t = Template(""" +Text +Text +% if bar: + ${expression} +% endif + + <%block name="foo"> + hi block + </%block> + + +""", uri="/some/template") + eq_( + ModuleInfo.get_module_source_metadata(t.code, full_line_map=True), + { + 'full_line_map': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 4, 5, 5, 5, 7, 7, 7, + 7, 7, 10, 10, 10, 10, 10, 10, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8], + 'source_encoding': 'ascii', + 'filename': None, + 'line_map': {33: 10, 39: 8, 45: 8, 14: 0, 51: 45, 23: 1, + 24: 4, 25: 5, 26: 5, 27: 5, 28: 7}, + 'uri': '/some/template'} ) class PreprocessTest(TemplateTest): |