@@ -127,16 +127,16 @@ def test_foo():
127
127
128
128
class TestCollectFS :
129
129
def test_ignored_certain_directories (self , pytester : Pytester ) -> None :
130
- tmpdir = pytester .path
131
- ensure_file (tmpdir / "build" / "test_notfound.py" )
132
- ensure_file (tmpdir / "dist" / "test_notfound.py" )
133
- ensure_file (tmpdir / "_darcs" / "test_notfound.py" )
134
- ensure_file (tmpdir / "CVS" / "test_notfound.py" )
135
- ensure_file (tmpdir / "{arch}" / "test_notfound.py" )
136
- ensure_file (tmpdir / ".whatever" / "test_notfound.py" )
137
- ensure_file (tmpdir / ".bzr" / "test_notfound.py" )
138
- ensure_file (tmpdir / "normal" / "test_found.py" )
139
- for x in Path ( str ( tmpdir )) .rglob ("test_*.py" ):
130
+ tmp_path = pytester .path
131
+ ensure_file (tmp_path / "build" / "test_notfound.py" )
132
+ ensure_file (tmp_path / "dist" / "test_notfound.py" )
133
+ ensure_file (tmp_path / "_darcs" / "test_notfound.py" )
134
+ ensure_file (tmp_path / "CVS" / "test_notfound.py" )
135
+ ensure_file (tmp_path / "{arch}" / "test_notfound.py" )
136
+ ensure_file (tmp_path / ".whatever" / "test_notfound.py" )
137
+ ensure_file (tmp_path / ".bzr" / "test_notfound.py" )
138
+ ensure_file (tmp_path / "normal" / "test_found.py" )
139
+ for x in tmp_path .rglob ("test_*.py" ):
140
140
x .write_text ("def test_hello(): pass" , "utf-8" )
141
141
142
142
result = pytester .runpytest ("--collect-only" )
@@ -226,10 +226,12 @@ def test_custom_norecursedirs(self, pytester: Pytester) -> None:
226
226
norecursedirs = mydir xyz*
227
227
"""
228
228
)
229
- tmpdir = pytester .path
230
- ensure_file (tmpdir / "mydir" / "test_hello.py" ).write_text ("def test_1(): pass" )
231
- ensure_file (tmpdir / "xyz123" / "test_2.py" ).write_text ("def test_2(): 0/0" )
232
- ensure_file (tmpdir / "xy" / "test_ok.py" ).write_text ("def test_3(): pass" )
229
+ tmp_path = pytester .path
230
+ ensure_file (tmp_path / "mydir" / "test_hello.py" ).write_text (
231
+ "def test_1(): pass"
232
+ )
233
+ ensure_file (tmp_path / "xyz123" / "test_2.py" ).write_text ("def test_2(): 0/0" )
234
+ ensure_file (tmp_path / "xy" / "test_ok.py" ).write_text ("def test_3(): pass" )
233
235
rec = pytester .inline_run ()
234
236
rec .assertoutcome (passed = 1 )
235
237
rec = pytester .inline_run ("xyz123/test_2.py" )
@@ -242,10 +244,10 @@ def test_testpaths_ini(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> No
242
244
testpaths = gui uts
243
245
"""
244
246
)
245
- tmpdir = pytester .path
246
- ensure_file (tmpdir / "env" / "test_1.py" ).write_text ("def test_env(): pass" )
247
- ensure_file (tmpdir / "gui" / "test_2.py" ).write_text ("def test_gui(): pass" )
248
- ensure_file (tmpdir / "uts" / "test_3.py" ).write_text ("def test_uts(): pass" )
247
+ tmp_path = pytester .path
248
+ ensure_file (tmp_path / "env" / "test_1.py" ).write_text ("def test_env(): pass" )
249
+ ensure_file (tmp_path / "gui" / "test_2.py" ).write_text ("def test_gui(): pass" )
250
+ ensure_file (tmp_path / "uts" / "test_3.py" ).write_text ("def test_uts(): pass" )
249
251
250
252
# executing from rootdir only tests from `testpaths` directories
251
253
# are collected
@@ -255,7 +257,7 @@ def test_testpaths_ini(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> No
255
257
# check that explicitly passing directories in the command-line
256
258
# collects the tests
257
259
for dirname in ("env" , "gui" , "uts" ):
258
- items , reprec = pytester .inline_genitems (tmpdir .joinpath (dirname ))
260
+ items , reprec = pytester .inline_genitems (tmp_path .joinpath (dirname ))
259
261
assert [x .name for x in items ] == ["test_%s" % dirname ]
260
262
261
263
# changing cwd to each subdirectory and running pytest without
@@ -628,10 +630,9 @@ def test_method(self):
628
630
629
631
class Test_getinitialnodes :
630
632
def test_global_file (self , pytester : Pytester ) -> None :
631
- tmpdir = pytester .path
632
- x = ensure_file (tmpdir / "x.py" )
633
- with tmpdir .cwd ():
634
- config = pytester .parseconfigure (x )
633
+ tmp_path = pytester .path
634
+ x = ensure_file (tmp_path / "x.py" )
635
+ config = pytester .parseconfigure (x )
635
636
col = pytester .getnode (config , x )
636
637
assert isinstance (col , pytest .Module )
637
638
assert col .name == "x.py"
@@ -645,8 +646,8 @@ def test_pkgfile(self, pytester: Pytester) -> None:
645
646
The parent chain should match: Module<x.py> -> Package<subdir> -> Session.
646
647
Session's parent should always be None.
647
648
"""
648
- tmpdir = pytester .path
649
- subdir = tmpdir .joinpath ("subdir" )
649
+ tmp_path = pytester .path
650
+ subdir = tmp_path .joinpath ("subdir" )
650
651
x = ensure_file (subdir / "x.py" )
651
652
ensure_file (subdir / "__init__.py" )
652
653
with subdir .cwd ():
0 commit comments