mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-06 13:06:53 +00:00
parent
d25cc10e38
commit
85c2be3b52
2 changed files with 39 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
|||
"""Integration tests for the checker submodule."""
|
||||
import sys
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
|
@ -336,3 +337,26 @@ def test_acquire_when_multiprocessing_pool_can_not_initialize():
|
|||
|
||||
pool.assert_called_once_with(2, checker._pool_init)
|
||||
assert result is None
|
||||
|
||||
|
||||
def test_handling_syntaxerrors_across_pythons():
|
||||
"""Verify we properly handle exception argument tuples.
|
||||
|
||||
Python 3.10 added more information to the SyntaxError parse token tuple.
|
||||
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)
|
||||
file_checker = checker.FileChecker("-", {}, mock.MagicMock())
|
||||
actual = file_checker._extract_syntax_information(err)
|
||||
assert actual == expected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue