|
11 | 11 |
|
12 | 12 | import pytest
|
13 | 13 | from _pytest.config import Config
|
14 |
| -from _pytest.recwarn import WarningsRecorder |
15 | 14 |
|
16 | 15 | from pylint import testutils
|
17 | 16 | from pylint.testutils import UPDATE_FILE, UPDATE_OPTION
|
|
33 | 32 | ]
|
34 | 33 | TESTS_NAMES = [t.base for t in TESTS]
|
35 | 34 | TEST_WITH_EXPECTED_DEPRECATION = [
|
| 35 | + "anomalous_backslash_escape", |
| 36 | + "anomalous_unicode_escape", |
| 37 | + "excess_escapes", |
36 | 38 | "future_unicode_literals",
|
37 |
| - "anomalous_unicode_escape_py3", |
38 | 39 | ]
|
39 | 40 |
|
40 | 41 |
|
41 | 42 | @pytest.mark.parametrize("test_file", TESTS, ids=TESTS_NAMES)
|
42 |
| -def test_functional( |
43 |
| - test_file: FunctionalTestFile, recwarn: WarningsRecorder, pytestconfig: Config |
44 |
| -) -> None: |
| 43 | +def test_functional(test_file: FunctionalTestFile, pytestconfig: Config) -> None: |
45 | 44 | __tracebackhide__ = True # pylint: disable=unused-variable
|
| 45 | + lint_test: LintModuleOutputUpdate | testutils.LintModuleTest |
46 | 46 | if UPDATE_FILE.exists():
|
47 |
| - lint_test: ( |
48 |
| - LintModuleOutputUpdate | testutils.LintModuleTest |
49 |
| - ) = LintModuleOutputUpdate(test_file, pytestconfig) |
| 47 | + lint_test = LintModuleOutputUpdate(test_file, pytestconfig) |
50 | 48 | else:
|
51 | 49 | lint_test = testutils.LintModuleTest(test_file, pytestconfig)
|
52 | 50 | 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 |
| - ) |
| 51 | + |
| 52 | + if test_file.base in TEST_WITH_EXPECTED_DEPRECATION: |
| 53 | + with pytest.warns(DeprecationWarning, match="invalid escape sequence"): |
| 54 | + lint_test.runTest() |
| 55 | + else: |
| 56 | + lint_test.runTest() |
64 | 57 |
|
65 | 58 |
|
66 | 59 | if __name__ == "__main__":
|
|
0 commit comments