summaryrefslogtreecommitdiff
path: root/tests/test_functional.py
diff options
context:
space:
mode:
authorMarc Mueller <30130371+cdce8p@users.noreply.github.com>2022-10-23 19:13:01 +0200
committerGitHub <noreply@github.com>2022-10-23 19:13:01 +0200
commit40c243bd166164b4c484cf2c90d5b2543a5938c1 (patch)
tree32d95f62e553a5f81075b5046ce30aa215148699 /tests/test_functional.py
parent43e8171f0d13a150e951ef833d98d9567d4a3088 (diff)
downloadpylint-git-40c243bd166164b4c484cf2c90d5b2543a5938c1.tar.gz
Fix showing DeprecationWarnings for functional tests (#7665)
Diffstat (limited to 'tests/test_functional.py')
-rw-r--r--tests/test_functional.py31
1 files changed, 12 insertions, 19 deletions
diff --git a/tests/test_functional.py b/tests/test_functional.py
index 74b541bcf..77cdbc58f 100644
--- a/tests/test_functional.py
+++ b/tests/test_functional.py
@@ -11,7 +11,6 @@ from pathlib import Path
import pytest
from _pytest.config import Config
-from _pytest.recwarn import WarningsRecorder
from pylint import testutils
from pylint.testutils import UPDATE_FILE, UPDATE_OPTION
@@ -33,34 +32,28 @@ TESTS = [
]
TESTS_NAMES = [t.base for t in TESTS]
TEST_WITH_EXPECTED_DEPRECATION = [
+ "anomalous_backslash_escape",
+ "anomalous_unicode_escape",
+ "excess_escapes",
"future_unicode_literals",
- "anomalous_unicode_escape_py3",
]
@pytest.mark.parametrize("test_file", TESTS, ids=TESTS_NAMES)
-def test_functional(
- test_file: FunctionalTestFile, recwarn: WarningsRecorder, pytestconfig: Config
-) -> None:
+def test_functional(test_file: FunctionalTestFile, pytestconfig: Config) -> None:
__tracebackhide__ = True # pylint: disable=unused-variable
+ lint_test: LintModuleOutputUpdate | testutils.LintModuleTest
if UPDATE_FILE.exists():
- lint_test: (
- LintModuleOutputUpdate | testutils.LintModuleTest
- ) = LintModuleOutputUpdate(test_file, pytestconfig)
+ lint_test = LintModuleOutputUpdate(test_file, pytestconfig)
else:
lint_test = testutils.LintModuleTest(test_file, pytestconfig)
lint_test.setUp()
- lint_test.runTest()
- if recwarn.list:
- if (
- test_file.base in TEST_WITH_EXPECTED_DEPRECATION
- and sys.version_info.minor > 5
- ):
- assert any(
- "invalid escape sequence" in str(i.message)
- for i in recwarn.list
- if issubclass(i.category, DeprecationWarning)
- )
+
+ if test_file.base in TEST_WITH_EXPECTED_DEPRECATION:
+ with pytest.warns(DeprecationWarning, match="invalid escape sequence"):
+ lint_test.runTest()
+ else:
+ lint_test.runTest()
if __name__ == "__main__":