summaryrefslogtreecommitdiff
path: root/pyflakes/test/test_imports.py
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2022-06-12 17:07:21 -0400
committerGitHub <noreply@github.com>2022-06-12 17:07:21 -0400
commit2246217295dc8cb30ef4a7b9d8dc449ce32e603a (patch)
tree11a8fb153af9229c058f55bb10d0d454f86a2bee /pyflakes/test/test_imports.py
parentbecbab65bae84e3e19fc388a42dfabcff0c323c8 (diff)
downloadpyflakes-2246217295dc8cb30ef4a7b9d8dc449ce32e603a.tar.gz
burn the bridges with python 2.x (#707)
* pyupgrade --py36-plus * remove handling of PY2 * remove handling of PY35_PLUS * remove handling of PY36_PLUS * remove obsolete version_info checks in pyflakes/ * adjust skips in tests for 3.6+ * is_py3_func -> has_annotations (specifically for lambda) * remove references to py 2 * remove references to unichr * clean up version-specific getattrs * remove unused ReturnWithArgsInsideGenerator * remove unused ast handlers * remove unused RedefinedInListComp
Diffstat (limited to 'pyflakes/test/test_imports.py')
-rw-r--r--pyflakes/test/test_imports.py37
1 files changed, 4 insertions, 33 deletions
diff --git a/pyflakes/test/test_imports.py b/pyflakes/test/test_imports.py
index 07504d9..fb5d2fd 100644
--- a/pyflakes/test/test_imports.py
+++ b/pyflakes/test/test_imports.py
@@ -1,5 +1,3 @@
-from sys import version_info
-
from pyflakes import messages as m
from pyflakes.checker import (
FutureImportation,
@@ -8,7 +6,7 @@ from pyflakes.checker import (
StarImportation,
SubmoduleImportation,
)
-from pyflakes.test.harness import TestCase, skip, skipIf
+from pyflakes.test.harness import TestCase, skip
class TestImportationObject(TestCase):
@@ -577,9 +575,8 @@ class Test(TestCase):
def test_redefinedByExcept(self):
expected = [m.RedefinedWhileUnused]
- if version_info >= (3,):
- # The exc variable is unused inside the exception handler.
- expected.append(m.UnusedVariable)
+ # The exc variable is unused inside the exception handler.
+ expected.append(m.UnusedVariable)
self.flakes('''
import fu
try: pass
@@ -624,12 +621,6 @@ class Test(TestCase):
self.flakes('import fu; [fu for _ in range(1)]')
self.flakes('import fu; [1 for _ in range(1) if fu]')
- @skipIf(version_info >= (3,),
- 'in Python 3 list comprehensions execute in a separate scope')
- def test_redefinedByListComp(self):
- self.flakes('import fu; [1 for fu in range(1)]',
- m.RedefinedInListComp)
-
def test_usedInTryFinally(self):
self.flakes('''
import fu
@@ -686,15 +677,8 @@ class Test(TestCase):
def g(): foo.is_used()
''')
- @skipIf(version_info >= (3,), 'deprecated syntax')
- def test_usedInBackquote(self):
- self.flakes('import fu; `fu`')
-
def test_usedInExec(self):
- if version_info < (3,):
- exec_stmt = 'exec "print 1" in fu.bar'
- else:
- exec_stmt = 'exec("print(1)", fu.bar)'
+ exec_stmt = 'exec("print(1)", fu.bar)'
self.flakes('import fu; %s' % exec_stmt)
def test_usedInLambda(self):
@@ -793,8 +777,6 @@ class Test(TestCase):
assert error.message == '%r imported but unused'
assert error.message_args == ('from .. import *', )
- @skipIf(version_info < (3,),
- 'import * below module level is a warning on Python 2')
def test_localImportStar(self):
"""import * is only allowed at module level."""
self.flakes('''
@@ -814,17 +796,6 @@ class Test(TestCase):
assert error.message == "'from %s import *' only allowed at module level"
assert error.message_args == ('..', )
- @skipIf(version_info > (3,),
- 'import * below module level is an error on Python 3')
- def test_importStarNested(self):
- """All star imports are marked as used by an undefined variable."""
- self.flakes('''
- from fu import *
- def f():
- from bar import *
- x
- ''', m.ImportStarUsed, m.ImportStarUsed, m.ImportStarUsage)
-
def test_packageImport(self):
"""
If a dotted name is imported and used, no warning is reported.