Kaydet (Commit) acf12e77 authored tarafından Anthony Sottile's avatar Anthony Sottile
üst a662c5d4
......@@ -76,7 +76,7 @@ class FindCalls(ast.NodeVisitor):
offset = _to_offset(argnode)
# multiline strings have invalid position, ignore them
if offset.utf8_byte_offset != -1:
if offset.utf8_byte_offset != -1: # pragma: no branch (cpy bug)
if offset.line > orig:
is_multiline = True
arg_offsets.add(offset)
......
......@@ -2,6 +2,7 @@
from __future__ import absolute_import
from __future__ import unicode_literals
import ast
import sys
import pytest
......@@ -38,11 +39,6 @@ from add_trailing_comma import main
'x((\n'
' 1,\n'
'))',
# Can't handle multi line strings
'x(\n'
' """\n'
' """\n'
')',
),
)
def test_fix_calls_noops(src):
......@@ -50,6 +46,22 @@ def test_fix_calls_noops(src):
assert ret == src
def _has_16806_bug():
# See https://bugs.python.org/issue16806
return ast.parse('"""\n"""').body[0].value.col_offset == -1
@pytest.mark.xfail(not _has_16806_bug(), reason='multiline string parse bug')
def test_ignores_invalid_ast_node():
src = (
'x(\n'
' """\n'
' """\n'
')'
)
assert _fix_calls(src, py35_plus=False) == src
def test_py35_plus_rewrite():
src = (
'x(\n'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment