Skip to content

Commit 1439658

Browse files
committed
Include tox-extra and tox-uv when testing
1 parent 25143c7 commit 1439658

File tree

4 files changed

+42
-22
lines changed

4 files changed

+42
-22
lines changed

.config/constraints.txt

+12-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ astroid==3.3.8 # via pylint
55
attrs==25.1.0 # via jsonschema, referencing
66
babel==2.16.0 # via mkdocs-material
77
beautifulsoup4==4.12.3 # via linkchecker, mkdocs-htmlproofer-plugin
8+
bindep==2.12.0 # via tox-extra
89
black==25.1.0 # via tox-ansible (pyproject.toml)
910
cachetools==5.5.1 # via tox
1011
cairocffi==1.7.1 # via cairosvg
@@ -23,12 +24,15 @@ cssselect2==0.7.0 # via cairosvg
2324
defusedxml==0.7.1 # via cairosvg
2425
dill==0.3.9 # via pylint
2526
distlib==0.3.9 # via virtualenv
27+
distro==1.9.0 # via bindep
2628
dnspython==2.7.0 # via linkchecker
2729
docstring-parser-fork==0.0.12 # via pydoclint
2830
exceptiongroup==1.2.2 # via pytest
2931
execnet==2.1.1 # via pytest-xdist
3032
filelock==3.17.0 # via tox, virtualenv
3133
ghp-import==2.1.0 # via mkdocs
34+
gitdb==4.0.12 # via gitpython
35+
gitpython==3.1.44 # via tox-extra
3236
griffe==1.5.5 # via mkdocstrings-python
3337
hjson==3.1.0 # via mkdocs-macros-plugin, super-collections
3438
htmlmin2==0.1.13 # via mkdocs-minify-plugin
@@ -63,9 +67,11 @@ mkdocstrings-python==1.13.0 # via mkdocs-ansible
6367
mypy==1.14.1 # via tox-ansible (pyproject.toml)
6468
mypy-extensions==1.0.0 # via black, mypy
6569
nodeenv==1.9.1 # via pre-commit
66-
packaging==24.2 # via ansible-compat, ansible-core, black, mkdocs, mkdocs-macros-plugin, pyproject-api, pytest, pytest-ansible, tox
70+
packaging==24.2 # via ansible-compat, ansible-core, bindep, black, mkdocs, mkdocs-macros-plugin, pyproject-api, pytest, pytest-ansible, tox, tox-extra, tox-uv
6771
paginate==0.5.7 # via mkdocs-material
72+
parsley==1.3 # via bindep
6873
pathspec==0.12.1 # via black, mkdocs, mkdocs-macros-plugin
74+
pbr==6.1.0 # via bindep
6975
pillow==11.1.0 # via cairosvg, mkdocs-ansible
7076
platformdirs==4.3.6 # via black, mkdocs-get-deps, mkdocstrings, pylint, tox, virtualenv
7177
pluggy==1.5.0 # via pytest, tox
@@ -89,6 +95,7 @@ requests==2.32.3 # via linkchecker, mkdocs-htmlproofer-plugin, mkdocs-m
8995
rpds-py==0.22.3 # via jsonschema, referencing
9096
ruff==0.9.3 # via tox-ansible (pyproject.toml)
9197
six==1.17.0 # via python-dateutil
98+
smmap==5.0.2 # via gitdb
9299
soupsieve==2.6 # via beautifulsoup4
93100
subprocess-tee==0.4.2 # via ansible-compat
94101
super-collections==0.5.3 # via mkdocs-macros-plugin
@@ -98,7 +105,9 @@ tinycss2==1.4.0 # via cairosvg, cssselect2
98105
toml-sort==0.24.2 # via tox-ansible (pyproject.toml)
99106
tomli==2.2.1 # via black, coverage, mypy, pydoclint, pylint, pyproject-api, pytest, tox
100107
tomlkit==0.13.2 # via pylint, toml-sort
101-
tox==4.24.1 # via tox-ansible (pyproject.toml)
108+
tox==4.24.1 # via tox-extra, tox-uv, tox-ansible (pyproject.toml)
109+
tox-extra==2.1.0 # via tox-ansible (pyproject.toml)
110+
tox-uv==1.20.2 # via tox-extra, tox-ansible (pyproject.toml)
102111
types-pyyaml==6.0.12.20241230 # via tox-ansible (pyproject.toml)
103112
urllib3==2.3.0 # via requests
104113
virtualenv==20.29.1 # via pre-commit, tox
@@ -109,3 +118,4 @@ webencodings==0.5.1 # via cssselect2, tinycss2
109118
# ansible-core
110119
# resolvelib
111120
# typing-extensions
121+
# uv

.config/requirements-test.in

+2
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ pytest-xdist
1010
ruff
1111
toml-sort
1212
tox
13+
tox-extra
14+
tox-uv
1315
types-PyYAML

tests/conftest.py

+18-7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
Tracing '/**/src/<package>/__init__.py'
1717
"""
1818

19+
# cspell:ignore collectonly,sessionstart
20+
1921
from __future__ import annotations
2022

2123
import configparser
@@ -46,7 +48,7 @@ def run(
4648
cwd: Path,
4749
check: bool = False,
4850
shell: bool = True,
49-
env: subprocess._ENV | None = None,
51+
env: os._Environ[str] | None = None,
5052
) -> subprocess.CompletedProcess[str]:
5153
"""Utility function to run a command.
5254
@@ -60,14 +62,16 @@ def run(
6062
Returns:
6163
A CompletedProcess with the result of the command
6264
"""
65+
env_ = {**os.environ, **(env if env is not None else {})}
66+
env_["NO_COLOR"] = "1"
6367
return subprocess.run(
6468
args=args,
6569
capture_output=True,
6670
check=check,
6771
cwd=str(cwd),
6872
shell=shell,
6973
text=True,
70-
env=env,
74+
env=env_,
7175
)
7276

7377

@@ -140,16 +144,23 @@ def pytest_generate_tests(metafunc: Metafunc) -> None:
140144
if "basic_environment" in metafunc.fixturenames:
141145
cwd = Path(__file__).parent
142146
basic_dir = cwd / "fixtures" / "integration" / "test_basic"
147+
env = os.environ
148+
env.pop("TOX_ENV_DIR", None)
149+
env.pop("TOX_ENV_NAME", None)
150+
env.pop("TOX_WORK_DIR", None)
151+
152+
# trick to make 'tox config' output parsable due to known bug which can
153+
# mangle stdout when it does bootstrap itself
154+
run(f"{sys.executable} -m tox --version",
155+
check=True,
156+
cwd=basic_dir,
157+
env=env,
158+
)
143159
try:
144160
cmd = (
145161
f"{sys.executable} -m tox config --ansible "
146162
f"--root {basic_dir} --conf tox-ansible.ini"
147163
)
148-
env = os.environ
149-
env.pop("TOX_ENV_DIR", None)
150-
env.pop("TOX_ENV_NAME", None)
151-
env.pop("TOX_WORK_DIR", None)
152-
153164
proc = run(
154165
args=cmd,
155166
check=True,

tox.ini

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[tox]
22
requires =
3-
tox>=4.11.3
4-
tox-uv
3+
tox>=4.24.1
4+
tox-extra>=2.1
5+
tox-uv>=1.20.2
56
env_list =
67
py
78
deps
@@ -27,13 +28,16 @@ pass_env =
2728
TERM
2829
USER
2930
set_env =
30-
!milestone: PIP_CONSTRAINT = {toxinidir}/.config/constraints.txt
3131
COVERAGE_COMBINED = {envdir}/.coverage
3232
COVERAGE_FILE = {env:COVERAGE_FILE:{envdir}/.coverage.{envname}}
3333
COVERAGE_PROCESS_START = {toxinidir}/pyproject.toml
3434
FORCE_COLOR = 1
35+
PIP_CONSTRAINT = {toxinidir}/.config/constraints.txt
3536
PRE_COMMIT_COLOR = always
3637
TERM = xterm-256color
38+
UV_CONSTRAINT = {toxinidir}/.config/constraints.txt
39+
deps, lint, milestone: PIP_CONSTRAINT = /dev/null
40+
deps, lint, milestone: UV_CONSTRAINT = /dev/null
3741
commands_pre =
3842
sh -c "rm -f {envdir}/.coverage* 2>/dev/null || true"
3943
commands =
@@ -54,13 +58,11 @@ skip_install = true
5458
deps =
5559
{[testenv:lint]deps}
5660
extras =
57-
set_env =
58-
PIP_CONSTRAINT = /dev/null
5961
commands_pre =
6062
commands =
61-
-pre-commit run --all-files --show-diff-on-failure --hook-stage manual up
62-
-pre-commit autoupdate
63-
git diff --exit-code
63+
pre-commit run --all-files --show-diff-on-failure --hook-stage manual up
64+
pre-commit autoupdate
65+
tox -e lint
6466
env_dir = {toxworkdir}/lint
6567

6668
[testenv:docs]
@@ -81,8 +83,6 @@ skip_install = true
8183
deps =
8284
pre-commit
8385
pre-commit-uv
84-
set_env =
85-
PIP_CONSTRAINT = /dev/null
8686
commands =
8787
pre-commit run --show-diff-on-failure --all-files
8888

@@ -91,9 +91,6 @@ description =
9191
Run tests with ansible-core milestone branch and without dependencies constraints
9292
deps =
9393
ansible-core@ https://github.com/ansible/ansible/archive/milestone.tar.gz
94-
set_env =
95-
{[testenv]set_env}
96-
PIP_CONSTRAINT = /dev/null
9794

9895
[testenv:pkg]
9996
description =

0 commit comments

Comments
 (0)