mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-10 06:44:18 +00:00
py310+
This commit is contained in:
parent
d45bdc05ce
commit
567cafc15a
9 changed files with 25 additions and 74 deletions
|
|
@ -2,7 +2,6 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import importlib.metadata
|
||||
import sys
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
|
@ -322,17 +321,10 @@ def test_handling_syntaxerrors_across_pythons():
|
|||
We need to handle that correctly to avoid crashing.
|
||||
https://github.com/PyCQA/flake8/issues/1372
|
||||
"""
|
||||
if sys.version_info < (3, 10): # pragma: no cover (<3.10)
|
||||
# Python 3.9 or older
|
||||
err = SyntaxError(
|
||||
"invalid syntax", ("<unknown>", 2, 5, "bad python:\n"),
|
||||
)
|
||||
expected = (2, 4)
|
||||
else: # pragma: no cover (3.10+)
|
||||
err = SyntaxError(
|
||||
"invalid syntax", ("<unknown>", 2, 1, "bad python:\n", 2, 11),
|
||||
)
|
||||
expected = (2, 1)
|
||||
err = SyntaxError(
|
||||
"invalid syntax", ("<unknown>", 2, 1, "bad python:\n", 2, 11),
|
||||
)
|
||||
expected = (2, 1)
|
||||
file_checker = checker.FileChecker(
|
||||
filename="-",
|
||||
plugins=finder.Checkers([], [], []),
|
||||
|
|
|
|||
|
|
@ -168,10 +168,8 @@ def test_tokenization_error_but_not_syntax_error(tmpdir, capsys):
|
|||
tmpdir.join("t.py").write("b'foo' \\\n")
|
||||
assert cli.main(["t.py"]) == 1
|
||||
|
||||
if hasattr(sys, "pypy_version_info"): # pragma: no cover (pypy)
|
||||
expected = "t.py:2:1: E999 SyntaxError: end of file (EOF) in multi-line statement\n" # noqa: E501
|
||||
elif sys.version_info < (3, 10): # pragma: no cover (cp38+)
|
||||
expected = "t.py:1:8: E999 SyntaxError: unexpected EOF while parsing\n"
|
||||
if sys.implementation.name == "pypy": # pragma: no cover (pypy)
|
||||
expected = "t.py:1:9: E999 SyntaxError: unexpected end of file (EOF) in multi-line statement\n" # noqa: E501
|
||||
else: # pragma: no cover (cp310+)
|
||||
expected = "t.py:1:10: E999 SyntaxError: unexpected EOF while parsing\n" # noqa: E501
|
||||
|
||||
|
|
@ -186,10 +184,8 @@ def test_tokenization_error_is_a_syntax_error(tmpdir, capsys):
|
|||
tmpdir.join("t.py").write("if True:\n pass\n pass\n")
|
||||
assert cli.main(["t.py"]) == 1
|
||||
|
||||
if hasattr(sys, "pypy_version_info"): # pragma: no cover (pypy)
|
||||
expected = "t.py:3:2: E999 IndentationError: unindent does not match any outer indentation level\n" # noqa: E501
|
||||
elif sys.version_info < (3, 10): # pragma: no cover (<cp310)
|
||||
expected = "t.py:3:5: E999 IndentationError: unindent does not match any outer indentation level\n" # noqa: E501
|
||||
if sys.implementation.name == "pypy": # pragma: no cover (pypy)
|
||||
expected = "t.py:3:3: E999 IndentationError: unindent does not match any outer indentation level\n" # noqa: E501
|
||||
else: # pragma: no cover (cp310+)
|
||||
expected = "t.py:3:7: E999 IndentationError: unindent does not match any outer indentation level\n" # noqa: E501
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue