12
12
from xdist .looponfail import StatRecorder
13
13
14
14
15
- PYTEST_GTE_7 = hasattr (pytest , "version_tuple" ) and pytest .version_tuple >= (7 , 0 ) # type: ignore[attr-defined]
16
-
17
-
18
15
class TestStatRecorder :
19
16
def test_filechange (self , tmp_path : Path ) -> None :
20
17
tmp = tmp_path
@@ -128,9 +125,8 @@ def test_failures_somewhere(self, pytester: pytest.Pytester) -> None:
128
125
failures = control .runsession ()
129
126
assert failures
130
127
control .setup ()
131
- item_path = item .path if PYTEST_GTE_7 else Path (str (item .fspath )) # type: ignore[attr-defined]
132
- item_path .write_text ("def test_func():\n assert 1\n " )
133
- removepyc (item_path )
128
+ item .path .write_text ("def test_func():\n assert 1\n " )
129
+ removepyc (item .path )
134
130
topdir , failures = control .runsession ()[:2 ]
135
131
assert not failures
136
132
@@ -146,10 +142,7 @@ def test_func():
146
142
control = RemoteControl (modcol .config )
147
143
control .loop_once ()
148
144
assert control .failures
149
- if PYTEST_GTE_7 :
150
- modcol_path = modcol .path # type:ignore[attr-defined]
151
- else :
152
- modcol_path = Path (str (modcol .fspath ))
145
+ modcol_path = modcol .path # type:ignore[attr-defined]
153
146
154
147
modcol_path .write_text (
155
148
textwrap .dedent (
@@ -179,10 +172,7 @@ def test_func():
179
172
"""
180
173
)
181
174
)
182
- if PYTEST_GTE_7 :
183
- parent = modcol .path .parent .parent # type: ignore[attr-defined]
184
- else :
185
- parent = Path (modcol .fspath .dirpath ().dirpath ())
175
+ parent = modcol .path .parent .parent # type: ignore[attr-defined]
186
176
monkeypatch .chdir (parent )
187
177
modcol .config .args = [
188
178
str (Path (x ).relative_to (parent )) for x in modcol .config .args
@@ -248,8 +238,7 @@ def test_two():
248
238
remotecontrol .loop_once ()
249
239
assert len (remotecontrol .failures ) == 1
250
240
251
- modcol_path = modcol .path if PYTEST_GTE_7 else Path (modcol .fspath )
252
- modcol_path .write_text (
241
+ modcol .path .write_text (
253
242
textwrap .dedent (
254
243
"""
255
244
def test_one():
@@ -259,7 +248,7 @@ def test_two():
259
248
"""
260
249
)
261
250
)
262
- removepyc (modcol_path )
251
+ removepyc (modcol . path )
263
252
remotecontrol .loop_once ()
264
253
assert not remotecontrol .failures
265
254
@@ -277,8 +266,7 @@ def test_one():
277
266
assert len (remotecontrol .failures ) == 1
278
267
assert "test_one" in remotecontrol .failures [0 ]
279
268
280
- modcol_path = modcol .path if PYTEST_GTE_7 else Path (modcol .fspath )
281
- modcol_path .write_text (
269
+ modcol .path .write_text (
282
270
textwrap .dedent (
283
271
"""
284
272
def test_one():
@@ -288,7 +276,7 @@ def test_two():
288
276
"""
289
277
)
290
278
)
291
- removepyc (modcol_path )
279
+ removepyc (modcol . path )
292
280
remotecontrol .loop_once ()
293
281
assert len (remotecontrol .failures ) == 0
294
282
remotecontrol .loop_once ()
0 commit comments