mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 12:54:29 +08:00
Fix utf-8 bom positions.
This commit is contained in:
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user