2022-12-13 16:56:33 +01:00
|
|
|
import os
|
2022-02-10 10:58:59 +01:00
|
|
|
import shutil
|
|
|
|
|
|
|
|
import pytest
|
2024-10-22 17:35:13 +02:00
|
|
|
from utils import FIXTURES_DIR, TOX4, modify_config, drop_unsupported_pythons
|
2022-02-10 10:58:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
2022-12-13 16:56:33 +01:00
|
|
|
def projdir(tmp_path, monkeypatch, worker_id):
|
2022-02-10 10:58:59 +01:00
|
|
|
pwd = tmp_path / "projdir"
|
|
|
|
pwd.mkdir()
|
2024-10-22 16:15:48 +02:00
|
|
|
for fname in "tox.ini", "setup.py", "pyproject.toml":
|
2022-02-10 10:58:59 +01:00
|
|
|
shutil.copy(FIXTURES_DIR / fname, pwd)
|
2024-10-22 17:35:13 +02:00
|
|
|
if TOX4:
|
|
|
|
with modify_config(pwd / "tox.ini") as config:
|
|
|
|
config["tox"]["envlist"] = drop_unsupported_pythons(config["tox"]["envlist"])
|
2022-02-10 10:58:59 +01:00
|
|
|
monkeypatch.chdir(pwd)
|
2022-12-13 16:56:33 +01:00
|
|
|
# https://github.com/pypa/pip/issues/5345#issuecomment-386424455
|
|
|
|
monkeypatch.setenv("XDG_CACHE_HOME",
|
|
|
|
os.path.expanduser(f"~/.cache/pytest-xdist-{worker_id}"))
|
2022-02-10 10:58:59 +01:00
|
|
|
return pwd
|
|
|
|
|
|
|
|
|
|
|
|
if TOX4:
|
|
|
|
available_options = ("--print-deps-to-file=-", "--print-deps-to=-")
|
|
|
|
else:
|
|
|
|
available_options = (
|
|
|
|
"--print-deps-only",
|
|
|
|
"--print-deps-to-file=-",
|
|
|
|
"--print-deps-to=-",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(params=available_options)
|
|
|
|
def print_deps_stdout_arg(request):
|
|
|
|
"""Argument for printing deps to stdout"""
|
|
|
|
return request.param
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(params=("--print-extras-to-file=-", "--print-extras-to=-"))
|
|
|
|
def print_extras_stdout_arg(request):
|
|
|
|
"""Argument for printing extras to stdout"""
|
|
|
|
return request.param
|