summaryrefslogtreecommitdiff
path: root/pyflakes/test
diff options
context:
space:
mode:
Diffstat (limited to 'pyflakes/test')
-rw-r--r--pyflakes/test/test_api.py29
-rw-r--r--pyflakes/test/test_doctests.py13
-rw-r--r--pyflakes/test/test_other.py46
-rw-r--r--pyflakes/test/test_type_annotations.py3
4 files changed, 10 insertions, 81 deletions
diff --git a/pyflakes/test/test_api.py b/pyflakes/test/test_api.py
index 535e701..5c1879c 100644
--- a/pyflakes/test/test_api.py
+++ b/pyflakes/test/test_api.py
@@ -233,9 +233,7 @@ class TestReporter(TestCase):
"""
err = io.StringIO()
reporter = Reporter(None, err)
- reporter.syntaxError('foo.py', 'a problem', 3,
- 8 if sys.version_info >= (3, 8) else 7,
- 'bad line of source')
+ reporter.syntaxError('foo.py', 'a problem', 3, 8, 'bad line of source')
self.assertEqual(
("foo.py:3:8: a problem\n"
"bad line of source\n"
@@ -281,11 +279,10 @@ class TestReporter(TestCase):
reporter = Reporter(None, err)
reporter.syntaxError('foo.py', 'a problem', 3, len(lines[0]) + 7,
'\n'.join(lines))
- column = 25 if sys.version_info >= (3, 8) else 7
self.assertEqual(
- ("foo.py:3:%d: a problem\n" % column +
+ ("foo.py:3:25: a problem\n" +
lines[-1] + "\n" +
- " " * (column - 1) + "^\n"),
+ " " * 24 + "^\n"),
err.getvalue())
def test_unexpectedError(self):
@@ -417,10 +414,8 @@ def baz():
if PYPY or sys.version_info >= (3, 10):
column = 12
- elif sys.version_info >= (3, 8):
- column = 8
else:
- column = 11
+ column = 8
self.assertHasErrors(
sourcePath,
["""\
@@ -487,10 +482,8 @@ def foo(bar=baz, bax):
column = 18
elif sys.version_info >= (3, 9):
column = 21
- elif sys.version_info >= (3, 8):
- column = 9
else:
- column = 8
+ column = 9
last_line = ' ' * (column - 1) + '^\n'
columnstr = '%d:' % column
self.assertHasErrors(
@@ -512,7 +505,7 @@ foo(bar=baz, bax)
with self.makeTempFile(source) as sourcePath:
if sys.version_info >= (3, 9):
column = 17
- elif not PYPY and sys.version_info >= (3, 8):
+ elif not PYPY:
column = 14
else:
column = 13
@@ -679,18 +672,10 @@ x = "%s"
"max(1 for i in range(10), key=lambda x: x+1)",
" ^",
]
- elif sys.version_info >= (3, 8):
+ else:
expected_error = [
"<stdin>:1:5: Generator expression must be parenthesized",
]
- elif sys.version_info >= (3, 7):
- expected_error = [
- "<stdin>:1:4: Generator expression must be parenthesized",
- ]
- elif sys.version_info >= (3, 6):
- expected_error = [
- "<stdin>:1:4: Generator expression must be parenthesized if not sole argument", # noqa: E501
- ]
self.assertEqual(errlines, expected_error)
diff --git a/pyflakes/test/test_doctests.py b/pyflakes/test/test_doctests.py
index 6c8e69e..63cea4d 100644
--- a/pyflakes/test/test_doctests.py
+++ b/pyflakes/test/test_doctests.py
@@ -1,4 +1,3 @@
-import sys
import textwrap
from pyflakes import messages as m
@@ -323,7 +322,7 @@ class Test(TestCase):
m.DoctestSyntaxError).messages
exc = exceptions[0]
self.assertEqual(exc.lineno, 4)
- if not PYPY and sys.version_info >= (3, 8):
+ if not PYPY:
self.assertEqual(exc.col, 18)
else:
self.assertEqual(exc.col, 26)
@@ -339,10 +338,7 @@ class Test(TestCase):
self.assertEqual(exc.col, 16)
exc = exceptions[2]
self.assertEqual(exc.lineno, 6)
- if PYPY or sys.version_info >= (3, 8):
- self.assertEqual(exc.col, 13)
- else:
- self.assertEqual(exc.col, 18)
+ self.assertEqual(exc.col, 13)
def test_indentationErrorInDoctest(self):
exc = self.flakes('''
@@ -353,10 +349,7 @@ class Test(TestCase):
"""
''', m.DoctestSyntaxError).messages[0]
self.assertEqual(exc.lineno, 5)
- if PYPY or sys.version_info >= (3, 8):
- self.assertEqual(exc.col, 13)
- else:
- self.assertEqual(exc.col, 16)
+ self.assertEqual(exc.col, 13)
def test_offsetWithMultiLineArgs(self):
(exc1, exc2) = self.flakes(
diff --git a/pyflakes/test/test_other.py b/pyflakes/test/test_other.py
index ce742a5..42e99ae 100644
--- a/pyflakes/test/test_other.py
+++ b/pyflakes/test/test_other.py
@@ -445,36 +445,6 @@ class Test(TestCase):
continue
''')
- @skipIf(version_info > (3, 8), "Python <= 3.8 only")
- def test_continueInFinally(self):
- # 'continue' inside 'finally' is a special syntax error
- # that is removed in 3.8
- self.flakes('''
- while True:
- try:
- pass
- finally:
- continue
- ''', m.ContinueInFinally)
-
- self.flakes('''
- while True:
- try:
- pass
- finally:
- if 1:
- if 2:
- continue
- ''', m.ContinueInFinally)
-
- # Even when not in a loop, this is the error Python gives
- self.flakes('''
- try:
- pass
- finally:
- continue
- ''', m.ContinueInFinally)
-
def test_breakOutsideLoop(self):
self.flakes('''
break
@@ -1716,7 +1686,6 @@ class TestUnusedAssignment(TestCase):
print(f'\x7b4*baz\N{RIGHT CURLY BRACKET}')
''')
- @skipIf(version_info < (3, 8), 'new in Python 3.8')
def test_assign_expr(self):
"""Test PEP 572 assignment expressions are treated as usage / write."""
self.flakes('''
@@ -1725,7 +1694,6 @@ class TestUnusedAssignment(TestCase):
print(x)
''')
- @skipIf(version_info < (3, 8), 'new in Python 3.8')
def test_assign_expr_generator_scope(self):
"""Test assignment expressions in generator expressions."""
self.flakes('''
@@ -1733,7 +1701,6 @@ class TestUnusedAssignment(TestCase):
print(y)
''')
- @skipIf(version_info < (3, 8), 'new in Python 3.8')
def test_assign_expr_nested(self):
"""Test assignment expressions in nested expressions."""
self.flakes('''
@@ -1972,19 +1939,6 @@ class TestAsyncStatements(TestCase):
return output
''', m.BreakOutsideLoop)
- @skipIf(version_info > (3, 8), "Python <= 3.8 only")
- def test_continueInAsyncForFinally(self):
- self.flakes('''
- async def read_data(db):
- output = []
- async for row in db.cursor():
- try:
- output.append(row)
- finally:
- continue
- return output
- ''', m.ContinueInFinally)
-
def test_asyncWith(self):
self.flakes('''
async def commit(session, data):
diff --git a/pyflakes/test/test_type_annotations.py b/pyflakes/test/test_type_annotations.py
index 885302c..2f27b06 100644
--- a/pyflakes/test/test_type_annotations.py
+++ b/pyflakes/test/test_type_annotations.py
@@ -379,7 +379,6 @@ class TestTypeAnnotations(TestCase):
async def func(c: c) -> None: pass
''')
- @skipIf(version_info < (3, 7), 'new in Python 3.7')
def test_postponed_annotations(self):
self.flakes('''
from __future__ import annotations
@@ -434,7 +433,6 @@ class TestTypeAnnotations(TestCase):
return Y
""", m.UndefinedName)
- @skipIf(version_info < (3, 8), 'new in Python 3.8')
def test_positional_only_argument_annotations(self):
self.flakes("""
from x import C
@@ -584,7 +582,6 @@ class TestTypeAnnotations(TestCase):
return None
""")
- @skipIf(version_info < (3, 7), 'new in Python 3.7')
def test_partial_string_annotations_with_future_annotations(self):
self.flakes("""
from __future__ import annotations