Fix utf-8 bom positions.

This commit is contained in:
Dave Halter
2017-07-10 23:38:44 +02:00
parent 859c48170e
commit ff949d1061
2 changed files with 22 additions and 3 deletions

View File

@@ -59,3 +59,16 @@ def test_prefix_splitting_types(string, types):
assert leaf.type == 'endmarker'
parsed_tokens = list(leaf._split_prefix())
assert [t.type for t in parsed_tokens] == types
def test_utf8_bom():
tree = parso.parse(unicode_bom + 'a = 1')
expr_stmt = tree.children[0]
assert expr_stmt.start_pos == (1, 0)
tree = parso.parse(unicode_bom + '\n')
endmarker = tree.children[0]
parts = list(endmarker._split_prefix())
assert [p.type for p in parts] == ['bom', 'newline', 'spacing']
assert [p.start_pos for p in parts] == [(1, 0), (1, 0), (2, 0)]
assert [p.end_pos for p in parts] == [(1, 0), (2, 0), (2, 0)]