Skip to content

Commit 4faed28

Browse files
committed
testing: convert some tmpdir to tmp_path
The tmpdir fixture (and its factory variant) is soft-deprecated in favor of the tmp_path fixture.
1 parent a218413 commit 4faed28

File tree

2 files changed

+124
-95
lines changed

2 files changed

+124
-95
lines changed

testing/test_cacheprovider.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from _pytest.config import ExitCode
99
from _pytest.monkeypatch import MonkeyPatch
1010
from _pytest.pytester import Pytester
11+
from _pytest.tmpdir import TempPathFactory
1112

1213
pytest_plugins = ("pytester",)
1314

@@ -139,9 +140,11 @@ def test_custom_rel_cache_dir(self, pytester: Pytester) -> None:
139140
pytester.runpytest()
140141
assert pytester.path.joinpath(rel_cache_dir).is_dir()
141142

142-
def test_custom_abs_cache_dir(self, pytester: Pytester, tmpdir_factory) -> None:
143-
tmp = str(tmpdir_factory.mktemp("tmp"))
144-
abs_cache_dir = os.path.join(tmp, "custom_cache_dir")
143+
def test_custom_abs_cache_dir(
144+
self, pytester: Pytester, tmp_path_factory: TempPathFactory
145+
) -> None:
146+
tmp = tmp_path_factory.mktemp("tmp")
147+
abs_cache_dir = tmp / "custom_cache_dir"
145148
pytester.makeini(
146149
"""
147150
[pytest]
@@ -152,7 +155,7 @@ def test_custom_abs_cache_dir(self, pytester: Pytester, tmpdir_factory) -> None:
152155
)
153156
pytester.makepyfile(test_errored="def test_error():\n assert False")
154157
pytester.runpytest()
155-
assert Path(abs_cache_dir).is_dir()
158+
assert abs_cache_dir.is_dir()
156159

157160
def test_custom_cache_dir_with_env_var(
158161
self, pytester: Pytester, monkeypatch: MonkeyPatch
@@ -185,9 +188,9 @@ def test_cache_reportheader(env, pytester: Pytester, monkeypatch: MonkeyPatch) -
185188

186189

187190
def test_cache_reportheader_external_abspath(
188-
pytester: Pytester, tmpdir_factory
191+
pytester: Pytester, tmp_path_factory: TempPathFactory
189192
) -> None:
190-
external_cache = tmpdir_factory.mktemp(
193+
external_cache = tmp_path_factory.mktemp(
191194
"test_cache_reportheader_external_abspath_abs"
192195
)
193196

0 commit comments

Comments
 (0)