mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-06 12:54:29 +08:00
Fix line endings support at various locations
This commit is contained in:
@@ -15,6 +15,8 @@ def test_eof_newline():
|
||||
assert issue.code == 292
|
||||
|
||||
assert not issues('asdf = 1\n')
|
||||
assert not issues('asdf = 1\r\n')
|
||||
assert not issues('asdf = 1\r')
|
||||
assert_issue('asdf = 1')
|
||||
assert_issue('asdf = 1\n# foo')
|
||||
assert_issue('# foobar')
|
||||
|
||||
@@ -19,6 +19,7 @@ unicode_bom = BOM_UTF8.decode('utf-8')
|
||||
(' \f ', ['\f', ' ']),
|
||||
(' \f ', ['\f', ' ']),
|
||||
(' \r\n', ['\r\n', '']),
|
||||
(' \r', ['\r', '']),
|
||||
('\\\n', ['\\\n', '']),
|
||||
('\\\r\n', ['\\\r\n', '']),
|
||||
('\t\t\n\t', ['\n', '\t']),
|
||||
@@ -34,7 +35,7 @@ def test_simple_prefix_splitting(string, tokens):
|
||||
assert pt.value == expected
|
||||
|
||||
# Calculate the estimated end_pos
|
||||
if expected.endswith('\n'):
|
||||
if expected.endswith('\n') or expected.endswith('\r'):
|
||||
end_pos = start_pos[0] + 1, 0
|
||||
else:
|
||||
end_pos = start_pos[0], start_pos[1] + len(expected) + len(pt.spacing)
|
||||
|
||||
@@ -74,6 +74,10 @@ def test_utf8_bom():
|
||||
('code', 'errors'), [
|
||||
(b'# coding: wtf-12\nfoo', 'strict'),
|
||||
(b'# coding: wtf-12\nfoo', 'replace'),
|
||||
(b'# coding: wtf-12\r\nfoo', 'strict'),
|
||||
(b'# coding: wtf-12\r\nfoo', 'replace'),
|
||||
(b'# coding: wtf-12\rfoo', 'strict'),
|
||||
(b'# coding: wtf-12\rfoo', 'replace'),
|
||||
]
|
||||
)
|
||||
def test_bytes_to_unicode_failing_encoding(code, errors):
|
||||
|
||||
Reference in New Issue
Block a user