|
6 | 6 | import os.path
|
7 | 7 | import re
|
8 | 8 | import textwrap
|
| 9 | +import warnings |
9 | 10 |
|
10 | 11 | import pytest
|
11 | 12 |
|
@@ -95,18 +96,20 @@ def test_tokenize_real_file(self):
|
95 | 96 | real_file = os.path.join(TESTS_DIR, "test_coverage.py")
|
96 | 97 | self.check_file_tokenization(real_file)
|
97 | 98 |
|
98 |
| - def test_stress(self): |
99 |
| - # Check the tokenization of a stress-test file. |
| 99 | + @pytest.mark.parametrize("fname", [ |
| 100 | + "stress_phystoken.tok", |
| 101 | + "stress_phystoken_dos.tok", |
| 102 | + ]) |
| 103 | + def test_stress(self, fname): |
| 104 | + # Check the tokenization of the stress-test files. |
100 | 105 | # And check that those files haven't been incorrectly "fixed".
|
101 |
| - stress = os.path.join(TESTS_DIR, "stress_phystoken.tok") |
102 |
| - self.check_file_tokenization(stress) |
103 |
| - with open(stress) as fstress: |
104 |
| - assert re.search(r"\s$", fstress.read()), f"{stress} needs a trailing space." |
105 |
| - stress = os.path.join(TESTS_DIR, "stress_phystoken_dos.tok") |
106 |
| - self.check_file_tokenization(stress) |
107 |
| - with open(stress) as fstress: |
108 |
| - assert re.search(r"\s$", fstress.read()), f"{stress} needs a trailing space." |
| 106 | + with warnings.catch_warnings(): |
| 107 | + warnings.filterwarnings("ignore", message=r".*invalid escape sequence",) |
109 | 108 |
|
| 109 | + stress = os.path.join(TESTS_DIR, fname) |
| 110 | + self.check_file_tokenization(stress) |
| 111 | + with open(stress) as fstress: |
| 112 | + assert re.search(r"(?m) $", fstress.read()), f"{stress} needs a trailing space." |
110 | 113 |
|
111 | 114 | @pytest.mark.skipif(not env.PYBEHAVIOR.soft_keywords, reason="Soft keywords are new in Python 3.10")
|
112 | 115 | class SoftKeywordTest(CoverageTest):
|
|
0 commit comments