test: two tests for #1828 · nedbat/coveragepy@dc819ff (original) (raw)
`@@ -98,6 +98,24 @@ def test_tokenize_real_file(self) -> None:
`
98
98
`real_file = os.path.join(TESTS_DIR, "test_coverage.py")
`
99
99
`self.check_file_tokenization(real_file)
`
100
100
``
``
101
`+
def test_1828(self) -> None:
`
``
102
`+
https://github.com/nedbat/coveragepy/pull/1828
`
``
103
`+
tokens = list(source_token_lines(textwrap.dedent("""
`
``
104
`+
x = \
`
``
105
`+
1
`
``
106
`+
a = ["aaa",\
`
``
107
`+
"bbb \
`
``
108
`+
ccc"]
`
``
109
`+
""")))
`
``
110
`+
assert tokens == [
`
``
111
`+
[],
`
``
112
`+
[('nam', 'x'), ('ws', ' '), ('op', '='), ('ws', ' '), ('num', '1')],
`
``
113
`+
[('nam', 'a'), ('ws', ' '), ('op', '='), ('ws', ' '),
`
``
114
`+
('op', '['), ('str', '"aaa"'), ('op', ','), ('xx', '\')],
`
``
115
`+
[('ws', ' '), ('str', '"bbb \')],
`
``
116
`+
[('str', ' ccc"'), ('op', ']')],
`
``
117
`+
]
`
``
118
+
101
119
`@pytest.mark.parametrize("fname", [
`
102
120
`"stress_phystoken.tok",
`
103
121
`"stress_phystoken_dos.tok",
`
`@@ -113,6 +131,7 @@ def test_stress(self, fname: str) -> None:
`
113
131
`with open(stress) as fstress:
`
114
132
`assert re.search(r"(?m) $", fstress.read()), f"{stress} needs a trailing space."
`
115
133
``
``
134
+
116
135
`@pytest.mark.skipif(not env.PYBEHAVIOR.soft_keywords, reason="Soft keywords are new in Python 3.10")
`
117
136
`class SoftKeywordTest(CoverageTest):
`
118
137
`"""Tests the tokenizer handling soft keywords."""
`