Skip to content

Commit

Permalink
testing: convert some tmpdir to tmp_path
Browse files Browse the repository at this point in the history
The tmpdir fixture (and its factory variant) is soft-deprecated in favor
of the tmp_path fixture.
  • Loading branch information
bluetech committed Dec 19, 2020
1 parent 92a7b06 commit 429544b
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 95 deletions.
15 changes: 9 additions & 6 deletions testing/test_cacheprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from _pytest.config import ExitCode
from _pytest.monkeypatch import MonkeyPatch
from _pytest.pytester import Pytester
from _pytest.tmpdir import TempPathFactory

pytest_plugins = ("pytester",)

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

def test_custom_abs_cache_dir(self, pytester: Pytester, tmpdir_factory) -> None:
tmp = str(tmpdir_factory.mktemp("tmp"))
abs_cache_dir = os.path.join(tmp, "custom_cache_dir")
def test_custom_abs_cache_dir(
self, pytester: Pytester, tmp_path_factory: TempPathFactory
) -> None:
tmp = tmp_path_factory.mktemp("tmp")
abs_cache_dir = tmp / "custom_cache_dir"
pytester.makeini(
"""
[pytest]
Expand All @@ -152,7 +155,7 @@ def test_custom_abs_cache_dir(self, pytester: Pytester, tmpdir_factory) -> None:
)
pytester.makepyfile(test_errored="def test_error():\n assert False")
pytester.runpytest()
assert Path(abs_cache_dir).is_dir()
assert abs_cache_dir.is_dir()

def test_custom_cache_dir_with_env_var(
self, pytester: Pytester, monkeypatch: MonkeyPatch
Expand Down Expand Up @@ -185,9 +188,9 @@ def test_cache_reportheader(env, pytester: Pytester, monkeypatch: MonkeyPatch) -


def test_cache_reportheader_external_abspath(
pytester: Pytester, tmpdir_factory
pytester: Pytester, tmp_path_factory: TempPathFactory
) -> None:
external_cache = tmpdir_factory.mktemp(
external_cache = tmp_path_factory.mktemp(
"test_cache_reportheader_external_abspath_abs"
)

Expand Down

0 comments on commit 429544b

Please sign in to comment.