File: conftest.py

package info (click to toggle)
tox-current-env 0.0.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 296 kB
  • sloc: python: 1,672; sh: 8; makefile: 6
file content (56 lines) | stat: -rw-r--r-- 1,780 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
import shutil

import pytest
from utils import FIXTURES_DIR, TOX_VERSION, TOX4, modify_config, drop_unsupported_pythons


@pytest.fixture(autouse=True)
def projdir(tmp_path, monkeypatch, worker_id):
    pwd = tmp_path / "projdir"
    pwd.mkdir()
    for fname in "tox.ini", "setup.py", "pyproject.toml":
        shutil.copy(FIXTURES_DIR / fname, pwd)
    if TOX4:
        with modify_config(pwd / "tox.ini") as config:
            config["tox"]["envlist"] = drop_unsupported_pythons(config["tox"]["envlist"])
    monkeypatch.chdir(pwd)
    # https://github.com/pypa/pip/issues/5345#issuecomment-386424455
    monkeypatch.setenv("XDG_CACHE_HOME",
                       os.path.expanduser(f"~/.cache/pytest-xdist-{worker_id}"))
    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


@pytest.fixture
def dependency_groups_support():
    """Support for dependency groups"""
    if (TOX_VERSION.major, TOX_VERSION.minor) < (4, 22):
        raise pytest.skip(reason="requires tox 4.22 or higher")


@pytest.fixture(params=("--print-dependency-groups-to-file=-", "--print-dependency-groups-to=-"))
def print_dependency_groups_stdout_arg(request, dependency_groups_support):
    """Argument for printing dependency groups to stdout"""
    return request.param