Skip to content

Commit 8c4c299

Browse files
committed
Fix showing DeprecationWarnings for functional tests
1 parent 36756fa commit 8c4c299

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

tests/test_functional.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import pytest
1313
from _pytest.config import Config
14-
from _pytest.recwarn import WarningsRecorder
1514

1615
from pylint import testutils
1716
from pylint.testutils import UPDATE_FILE, UPDATE_OPTION
@@ -34,33 +33,25 @@
3433
TESTS_NAMES = [t.base for t in TESTS]
3534
TEST_WITH_EXPECTED_DEPRECATION = [
3635
"future_unicode_literals",
37-
"anomalous_unicode_escape_py3",
36+
"anomalous_unicode_escape",
3837
]
3938

4039

4140
@pytest.mark.parametrize("test_file", TESTS, ids=TESTS_NAMES)
42-
def test_functional(
43-
test_file: FunctionalTestFile, recwarn: WarningsRecorder, pytestconfig: Config
44-
) -> None:
41+
def test_functional(test_file: FunctionalTestFile, pytestconfig: Config) -> None:
4542
__tracebackhide__ = True # pylint: disable=unused-variable
43+
lint_test: LintModuleOutputUpdate | testutils.LintModuleTest
4644
if UPDATE_FILE.exists():
47-
lint_test: (
48-
LintModuleOutputUpdate | testutils.LintModuleTest
49-
) = LintModuleOutputUpdate(test_file, pytestconfig)
45+
lint_test = LintModuleOutputUpdate(test_file, pytestconfig)
5046
else:
5147
lint_test = testutils.LintModuleTest(test_file, pytestconfig)
5248
lint_test.setUp()
53-
lint_test.runTest()
54-
if recwarn.list:
55-
if (
56-
test_file.base in TEST_WITH_EXPECTED_DEPRECATION
57-
and sys.version_info.minor > 5
58-
):
59-
assert any(
60-
"invalid escape sequence" in str(i.message)
61-
for i in recwarn.list
62-
if issubclass(i.category, DeprecationWarning)
63-
)
49+
50+
if test_file.base in TEST_WITH_EXPECTED_DEPRECATION:
51+
with pytest.warns(DeprecationWarning, match="invalid escape sequence"):
52+
lint_test.runTest()
53+
else:
54+
lint_test.runTest()
6455

6556

6657
if __name__ == "__main__":

0 commit comments

Comments
 (0)