summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2020-11-14 23:34:27 +0100
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2020-11-28 16:09:53 +0100
commite37bf8c5d64ef5ce6becf631663b7880d8ee5a67 (patch)
tree723e80f938f19a03fadaeec9e645ab3d29696b6b
parent637597c96fc82e41850cf9f73d12c8556e52ec93 (diff)
downloadpylint-git-e37bf8c5d64ef5ce6becf631663b7880d8ee5a67.tar.gz
Fix python 3.6 pipeline without deprecation warning (?)
And better comment following review, see https://github.com/PyCQA/pylint/pull/3943#discussion_r530981553
-rw-r--r--tests/test_func.py17
-rw-r--r--tests/test_functional.py22
2 files changed, 28 insertions, 11 deletions
diff --git a/tests/test_func.py b/tests/test_func.py
index b8903a4d8..735030d5d 100644
--- a/tests/test_func.py
+++ b/tests/test_func.py
@@ -135,12 +135,19 @@ TEST_WITH_EXPECTED_DEPRECATION = ["func_excess_escapes.py"]
gen_tests(FILTER_RGX),
ids=[o[0] for o in gen_tests(FILTER_RGX)],
)
-def test_functionality(module_file, messages_file, dependencies):
- if module_file in TEST_WITH_EXPECTED_DEPRECATION and sys.version_info.minor > 5:
- # Remove <unknown>:x: DeprecationWarning: invalid escape sequence
- with pytest.deprecated_call():
- __test_functionality(module_file, messages_file, dependencies)
+def test_functionality(module_file, messages_file, dependencies, recwarn):
__test_functionality(module_file, messages_file, dependencies)
+ warning = None
+ try:
+ # Catch <unknown>:x: DeprecationWarning: invalid escape sequence
+ # so it's not shown during tests
+ warning = recwarn.pop()
+ except AssertionError:
+ pass
+ if warning is not None:
+ if module_file in TEST_WITH_EXPECTED_DEPRECATION and sys.version_info.minor > 5:
+ assert issubclass(warning.category, DeprecationWarning)
+ assert "invalid escape sequence" in str(warning.message)
def __test_functionality(module_file, messages_file, dependencies):
diff --git a/tests/test_functional.py b/tests/test_functional.py
index 331babdbe..70d553921 100644
--- a/tests/test_functional.py
+++ b/tests/test_functional.py
@@ -105,18 +105,28 @@ TEST_WITH_EXPECTED_DEPRECATION = [
@pytest.mark.parametrize("test_file", TESTS, ids=TESTS_NAMES)
-def test_functional(test_file):
+def test_functional(test_file, recwarn):
LintTest = (
LintModuleOutputUpdate(test_file)
if UPDATE.exists()
else testutils.LintModuleTest(test_file)
)
LintTest.setUp()
- if test_file.base in TEST_WITH_EXPECTED_DEPRECATION and sys.version_info.minor > 5:
- with pytest.deprecated_call():
- LintTest._runTest()
- else:
- LintTest._runTest()
+ LintTest._runTest()
+ warning = None
+ try:
+ # Catch <unknown>:x: DeprecationWarning: invalid escape sequence
+ # so it's not shown during tests
+ warning = recwarn.pop()
+ except AssertionError:
+ pass
+ if warning is not None:
+ if (
+ test_file.base in TEST_WITH_EXPECTED_DEPRECATION
+ and sys.version_info.minor > 5
+ ):
+ assert issubclass(warning.category, DeprecationWarning)
+ assert "invalid escape sequence" in str(warning.message)
if __name__ == "__main__":