| 1 |
[tox] |
| 2 |
envlist = py{39,310,311,312,313,314,py310,py311} |
| 3 |
labels = |
| 4 |
check = typing, gen_exports, type_completeness, pip_compile |
| 5 |
cython = py39-cython2,py39-cython,py311-cython2,py313-cython |
| 6 |
|
| 7 |
# TODO: |
| 8 |
# * environment to check coverage |
| 9 |
# * replace ci.sh |
| 10 |
# * --verbose --durations=10 |
| 11 |
# * -p _trio_check_attrs_aliases |
| 12 |
# * mypy cache |
| 13 |
# * LSP |
| 14 |
# * use tox in CI |
| 15 |
# * switch to nox? |
| 16 |
# * move to pyproject.toml? |
| 17 |
# * this means conditional deps need to be replaced |
| 18 |
|
| 19 |
# protip: install tox-uv for faster venv generation |
| 20 |
|
| 21 |
[testenv] |
| 22 |
description = "Base environment for running tests depending on python version." |
| 23 |
# use wheels instead of sdist, significantly faster install |
| 24 |
package = wheel |
| 25 |
wheel_build_env = .pkg |
| 26 |
deps = |
| 27 |
hypothesis: hypothesis |
| 28 |
-r test-requirements.txt |
| 29 |
set_env = |
| 30 |
slow: TOX_RUN_SLOW = '--run-slow' |
| 31 |
commands = |
| 32 |
pytest {env:TOX_RUN_SLOW:} {posargs} |
| 33 |
|
| 34 |
[testenv:no_test_requirements] |
| 35 |
description = "Run tests without optional test-requirements, to see we don't accidentally depend on a library not specified in depends." |
| 36 |
deps = |
| 37 |
pytest |
| 38 |
commands = |
| 39 |
pytest --skip-optional-imports {posargs} |
| 40 |
|
| 41 |
[testenv:docs] |
| 42 |
description = "Build documentation into docs/build." |
| 43 |
deps = |
| 44 |
-r docs-requirements.txt |
| 45 |
# base_python synced with .readthedocs.yml |
| 46 |
# To avoid syncing we can make RTD call the tox environment |
| 47 |
base_python = 3.11 |
| 48 |
commands = |
| 49 |
sphinx-build {posargs:--fresh-env} docs/source docs/build |
| 50 |
|
| 51 |
[testenv:py39-cython2,py39-cython,py311-cython2,py313-cython] |
| 52 |
description = "Run cython tests." |
| 53 |
deps = |
| 54 |
# cython 3.1.0 broke stuff https://github.com/cython/cython/issues/6865 |
| 55 |
cython: cython |
| 56 |
cython2: cython<3 |
| 57 |
setuptools ; python_version >= '3.12' |
| 58 |
commands_pre = |
| 59 |
python --version |
| 60 |
cython --version |
| 61 |
cythonize --inplace -X linetrace=True tests/cython/test_cython.pyx |
| 62 |
commands = |
| 63 |
python -m tests.cython.run_test_cython |
| 64 |
|
| 65 |
[testenv:cov-cython] |
| 66 |
deps = |
| 67 |
setuptools |
| 68 |
cython |
| 69 |
set_env = |
| 70 |
CFLAGS= -DCYTHON_TRACE_NOGIL=1 |
| 71 |
allowlist_externals = |
| 72 |
sed |
| 73 |
cp |
| 74 |
commands_pre = |
| 75 |
python --version |
| 76 |
cython --version |
| 77 |
cp pyproject.toml {temp_dir}/ |
| 78 |
sed -i "s/plugins\ =\ \\[\\]/plugins = [\"Cython.Coverage\"]/" {temp_dir}/pyproject.toml |
| 79 |
cythonize --inplace -X linetrace=True tests/cython/test_cython.pyx |
| 80 |
commands = |
| 81 |
coverage run -m tests.cython.run_test_cython --rcfile={temp_dir}/pyproject.toml |
| 82 |
coverage combine |
| 83 |
coverage report |
| 84 |
|
| 85 |
[testenv:gen_exports] |
| 86 |
description = "Run gen_exports.py, regenerating code for public API wrappers." |
| 87 |
deps = |
| 88 |
-r test-requirements.txt |
| 89 |
base_python = 3.13 |
| 90 |
commands = |
| 91 |
python ./src/trio/_tools/gen_exports.py --test |
| 92 |
|
| 93 |
[testenv:pip_compile] |
| 94 |
description = "Run pre-commit job pip-compile" |
| 95 |
base_python = 3.13 |
| 96 |
commands = |
| 97 |
pre-commit run pip-compile --all-files |
| 98 |
|
| 99 |
[testenv:typing] |
| 100 |
description = "Run type checks: mypy on all platforms, and pyright on `src/trio[/_core]/_tests/type_tests/`." |
| 101 |
deps = |
| 102 |
-r test-requirements.txt |
| 103 |
exceptiongroup |
| 104 |
base_python = 3.10 |
| 105 |
set_env = |
| 106 |
PYRIGHT_PYTHON_IGNORE_WARNINGS=1 |
| 107 |
commands = |
| 108 |
# use mypy_annotate if running in CI? if not, should remove it |
| 109 |
mypy --platform linux |
| 110 |
mypy --platform darwin |
| 111 |
mypy --platform win32 |
| 112 |
|
| 113 |
pyright src/trio/_tests/type_tests |
| 114 |
pyright src/trio/_core/_tests/type_tests |
| 115 |
|
| 116 |
[testenv:type_completeness] |
| 117 |
description = "Check type completeness, using our wrapper around pyright --verifytypes." |
| 118 |
deps = |
| 119 |
-r test-requirements.txt |
| 120 |
exceptiongroup |
| 121 |
base_python = 3.13 |
| 122 |
set_env = |
| 123 |
PYRIGHT_PYTHON_IGNORE_WARNINGS=1 |
| 124 |
commands = |
| 125 |
python src/trio/_tests/check_type_completeness.py |