diff options
-rw-r--r-- | tests/test_parser.py | 7 | ||||
-rw-r--r-- | tests/test_phystokens.py | 23 |
2 files changed, 18 insertions, 12 deletions
diff --git a/tests/test_parser.py b/tests/test_parser.py index 48963358..d5f43197 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -5,6 +5,7 @@ import os.path import textwrap +import warnings import pytest @@ -492,8 +493,10 @@ def test_ast_dump(): with open(fname) as f: source = f.read() num_lines = len(source.splitlines()) - print(f"file {fname} has {num_lines} lines") - ast_root = ast_parse(source) + with warnings.catch_warnings(): + # stress_phystoken.tok has deprecation warnings, suppress them. + warnings.filterwarnings("ignore", message=r".*invalid escape sequence",) + ast_root = ast_parse(source) result = [] ast_dump(ast_root, print=result.append) if num_lines < 100: diff --git a/tests/test_phystokens.py b/tests/test_phystokens.py index f3985437..9950e655 100644 --- a/tests/test_phystokens.py +++ b/tests/test_phystokens.py @@ -6,6 +6,7 @@ import os.path import re import textwrap +import warnings import pytest @@ -95,18 +96,20 @@ class PhysTokensTest(CoverageTest): real_file = os.path.join(TESTS_DIR, "test_coverage.py") self.check_file_tokenization(real_file) - def test_stress(self): - # Check the tokenization of a stress-test file. + @pytest.mark.parametrize("fname", [ + "stress_phystoken.tok", + "stress_phystoken_dos.tok", + ]) + def test_stress(self, fname): + # Check the tokenization of the stress-test files. # And check that those files haven't been incorrectly "fixed". - stress = os.path.join(TESTS_DIR, "stress_phystoken.tok") - self.check_file_tokenization(stress) - with open(stress) as fstress: - assert re.search(r"\s$", fstress.read()), f"{stress} needs a trailing space." - stress = os.path.join(TESTS_DIR, "stress_phystoken_dos.tok") - self.check_file_tokenization(stress) - with open(stress) as fstress: - assert re.search(r"\s$", fstress.read()), f"{stress} needs a trailing space." + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", message=r".*invalid escape sequence",) + stress = os.path.join(TESTS_DIR, fname) + self.check_file_tokenization(stress) + with open(stress) as fstress: + assert re.search(r"(?m) $", fstress.read()), f"{stress} needs a trailing space." @pytest.mark.skipif(not env.PYBEHAVIOR.soft_keywords, reason="Soft keywords are new in Python 3.10") class SoftKeywordTest(CoverageTest): |