@@ -127,16 +127,16 @@ def test_foo():
127127
128128class TestCollectFS :
129129 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" ):
140140 x .write_text ("def test_hello(): pass" , "utf-8" )
141141
142142 result = pytester .runpytest ("--collect-only" )
@@ -226,10 +226,12 @@ def test_custom_norecursedirs(self, pytester: Pytester) -> None:
226226 norecursedirs = mydir xyz*
227227 """
228228 )
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" )
233235 rec = pytester .inline_run ()
234236 rec .assertoutcome (passed = 1 )
235237 rec = pytester .inline_run ("xyz123/test_2.py" )
@@ -242,10 +244,10 @@ def test_testpaths_ini(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> No
242244 testpaths = gui uts
243245 """
244246 )
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" )
249251
250252 # executing from rootdir only tests from `testpaths` directories
251253 # are collected
@@ -255,7 +257,7 @@ def test_testpaths_ini(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> No
255257 # check that explicitly passing directories in the command-line
256258 # collects the tests
257259 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 ))
259261 assert [x .name for x in items ] == ["test_%s" % dirname ]
260262
261263 # changing cwd to each subdirectory and running pytest without
@@ -628,10 +630,9 @@ def test_method(self):
628630
629631class Test_getinitialnodes :
630632 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 )
635636 col = pytester .getnode (config , x )
636637 assert isinstance (col , pytest .Module )
637638 assert col .name == "x.py"
@@ -645,8 +646,8 @@ def test_pkgfile(self, pytester: Pytester) -> None:
645646 The parent chain should match: Module<x.py> -> Package<subdir> -> Session.
646647 Session's parent should always be None.
647648 """
648- tmpdir = pytester .path
649- subdir = tmpdir .joinpath ("subdir" )
649+ tmp_path = pytester .path
650+ subdir = tmp_path .joinpath ("subdir" )
650651 x = ensure_file (subdir / "x.py" )
651652 ensure_file (subdir / "__init__.py" )
652653 with subdir .cwd ():
0 commit comments