Skip to content

Commit

Permalink
Add escaped-newline test for future implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
myint committed Apr 15, 2017
1 parent ea18464 commit 3f71764
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test_autoflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import contextlib
import io
import os
import re
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -462,6 +463,25 @@ def test_fix_code_with_empty_string(self):
'',
autoflake.fix_code(''))

def test_fix_code_with_from_and_as_and_escaped_newline(self):
"""Make sure stuff after escaped newline is not lost."""
result = autoflake.fix_code("""\
from collections import defaultdict, namedtuple \\
as xyz
xyz
""")
# We currently leave lines with escaped newlines as is. But in the
# future this we may parse them and remove unused import accordingly.
# For now, we'll work around it here.
result = re.sub(r' *\\\n *as ', ' as ', result)

self.assertEqual(
"""\
from collections import namedtuple as xyz
xyz
""",
autoflake.fix_code(result))

def test_fix_code_with_unused_variables(self):
self.assertEqual(
"""\
Expand Down

0 comments on commit 3f71764

Please sign in to comment.