forked from orbit-oss/flask
use tmp_path instead of tmpdir
This commit is contained in:
parent
1d7281fe07
commit
0a00e1b608
4 changed files with 59 additions and 64 deletions
|
|
@ -128,28 +128,27 @@ def limit_loader(request, monkeypatch):
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def modules_tmpdir(tmpdir, monkeypatch):
|
||||
"""A tmpdir added to sys.path."""
|
||||
rv = tmpdir.mkdir("modules_tmpdir")
|
||||
monkeypatch.syspath_prepend(str(rv))
|
||||
def modules_tmp_path(tmp_path, monkeypatch):
|
||||
"""A temporary directory added to sys.path."""
|
||||
rv = tmp_path / "modules_tmp"
|
||||
rv.mkdir()
|
||||
monkeypatch.syspath_prepend(os.fspath(rv))
|
||||
return rv
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def modules_tmpdir_prefix(modules_tmpdir, monkeypatch):
|
||||
monkeypatch.setattr(sys, "prefix", str(modules_tmpdir))
|
||||
return modules_tmpdir
|
||||
def modules_tmp_path_prefix(modules_tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(sys, "prefix", os.fspath(modules_tmp_path))
|
||||
return modules_tmp_path
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def site_packages(modules_tmpdir, monkeypatch):
|
||||
def site_packages(modules_tmp_path, monkeypatch):
|
||||
"""Create a fake site-packages."""
|
||||
rv = (
|
||||
modules_tmpdir.mkdir("lib")
|
||||
.mkdir(f"python{sys.version_info.major}.{sys.version_info.minor}")
|
||||
.mkdir("site-packages")
|
||||
)
|
||||
monkeypatch.syspath_prepend(str(rv))
|
||||
py_dir = f"python{sys.version_info.major}.{sys.version_info.minor}"
|
||||
rv = modules_tmp_path / "lib" / py_dir / "site-packages"
|
||||
rv.mkdir(parents=True)
|
||||
monkeypatch.syspath_prepend(os.fspath(rv))
|
||||
return rv
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue