Skip to content

Commit 9ed01b7

Browse files
authored
maintain: Convert tox conf to native TOML (#459)
1 parent ca9be60 commit 9ed01b7

File tree

1 file changed

+81
-68
lines changed

1 file changed

+81
-68
lines changed

pyproject.toml

Lines changed: 81 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -60,77 +60,90 @@ xfail_strict = true
6060

6161

6262
[tool.tox]
63-
legacy_tox_ini = '''
64-
[tox]
63+
requires = ["tox>=4.21.1"]
6564
# Only run pytest envs when no args given to tox
66-
envlist = py{39,310,311,312,313}
67-
isolated_build = True
68-
69-
[testenv:py{39,310,311,312,313}]
70-
description = run tests
71-
deps =
72-
-r tests/requirements.txt
73-
commands =
74-
pytest {posargs:--cov}
75-
76-
[testenv:profile]
77-
description = run profiler (use e.g. `firefox .tox/prof/combined.svg` to open)
78-
deps =
79-
-r tests/requirements.txt
80-
pytest-profiling
81-
commands =
82-
pytest tests/test_for_profiler.py --profile-svg --pstats-dir "{toxworkdir}/prof"
83-
python -c 'import pathlib; print("profiler svg output under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "prof" / "combined.svg"))'
84-
85-
[testenv:pre-commit]
86-
description = run linters (except mypy)
87-
skip_install = True
88-
deps = pre-commit
89-
commands = pre-commit run {posargs:--all}
90-
91-
[testenv:mypy]
92-
description = run mypy
93-
basepython = python3.11
94-
deps =
95-
-r tests/requirements.txt
96-
mypy==1.11.2
97-
commands =
98-
mypy {posargs:src/ tests/}
99-
100-
[testenv:hook]
101-
description = test mdformat's own pre-commit hook against the README file
102-
skip_install = True
103-
deps = pre-commit
104-
commands =
105-
pre-commit try-repo . mdformat --files README.md
106-
107-
[testenv:cli]
108-
description = run mdformat's own CLI
109-
commands = mdformat {posargs}
110-
111-
[testenv:docs]
112-
description = invoke sphinx-build to build the HTML docs
113-
skip_install = True
114-
deps =
115-
-r docs/requirements.txt
116-
commands =
117-
sphinx-build -d "{toxworkdir}/docs_doctree" docs/ "{toxworkdir}/docs_out" -W -b html {posargs}
118-
python -c 'import pathlib; print("documentation available under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "docs_out" / "index.html"))'
119-
120-
[testenv:fuzz]
121-
description = run the fuzzer (needs "apt install clang")
122-
deps =
123-
-r fuzzer/requirements.txt
124-
allowlist_externals =
125-
mkdir
126-
cp
127-
commands =
65+
env_list = ["3.9", "3.10", "3.11", "3.12", "3.13"]
66+
67+
[tool.tox.env_run_base]
68+
description = "run tests under {base_python}"
69+
deps = [
70+
"-r tests/requirements.txt",
71+
]
72+
commands = [
73+
["pytest", { replace = "posargs", default = ["--cov"], extend = true }],
74+
]
75+
76+
[tool.tox.env."profile"]
77+
description = "run profiler (use e.g. `firefox .tox/prof/combined.svg` to open)"
78+
deps = [
79+
"-r tests/requirements.txt",
80+
"pytest-profiling",
81+
]
82+
commands = [
83+
["pytest", "tests/test_for_profiler.py", "--profile-svg", "--pstats-dir", "{toxworkdir}/prof"],
84+
["python", "-c", 'import pathlib; print("profiler svg output under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "prof" / "combined.svg"))'],
85+
]
86+
87+
[tool.tox.env."pre-commit"]
88+
description = "run linters (except mypy)"
89+
skip_install = true
90+
deps = ["pre-commit"]
91+
commands = [
92+
["pre-commit", "run", { replace = "posargs", default = ["--all"], extend = true }],
93+
]
94+
95+
[tool.tox.env."mypy"]
96+
description = "run mypy"
97+
basepython = ["python3.11"]
98+
deps = [
99+
"-r tests/requirements.txt",
100+
"mypy==1.11.2",
101+
]
102+
commands = [
103+
["mypy", { replace = "posargs", default = ["src/", "tests/"], extend = true }],
104+
]
105+
106+
[tool.tox.env."hook"]
107+
description = "test mdformat's own pre-commit hook against the README file"
108+
skip_install = true
109+
deps = ["pre-commit"]
110+
commands = [
111+
["pre-commit", "try-repo", ".", "mdformat", "--files", "README.md"],
112+
]
113+
114+
[tool.tox.env."cli"]
115+
description = "run mdformat's own CLI"
116+
commands = [
117+
["mdformat", { replace = "posargs", extend = true }],
118+
]
119+
120+
[tool.tox.env."docs"]
121+
description = "invoke sphinx-build to build the HTML docs"
122+
skip_install = true
123+
deps = [
124+
"-r docs/requirements.txt",
125+
]
126+
commands = [
127+
["sphinx-build", "-d", "{toxworkdir}/docs_doctree", "docs/", "{toxworkdir}/docs_out", "-W", "-b", "html", { replace = "posargs", extend = true }],
128+
["python", "-c", 'import pathlib; print("documentation available under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "docs_out" / "index.html"))'],
129+
]
130+
131+
[tool.tox.env."fuzz"]
132+
description = 'run the fuzzer (needs "apt install clang")'
133+
deps = [
134+
"-r fuzzer/requirements.txt",
135+
]
136+
allowlist_externals = [
137+
"mkdir",
138+
"cp",
139+
]
140+
commands = [
128141
# Create a folder for persistent corpus and use README.md as initial seed
129-
mkdir -p {toxworkdir}/fuzzer-corpus
130-
cp -n README.md {toxworkdir}/fuzzer-corpus/README.md
142+
["mkdir", "-p", "{toxworkdir}/fuzzer-corpus"],
143+
["cp", "-n", "README.md", "{toxworkdir}/fuzzer-corpus/README.md"],
131144
# Run fuzzer
132-
python fuzzer/fuzz.py {toxworkdir}/fuzzer-corpus {posargs:-len_control=10000}
133-
'''
145+
["python", "fuzzer/fuzz.py", "{toxworkdir}/fuzzer-corpus", { replace = "posargs", default = ["-len_control=10000"], extend = true }],
146+
]
134147

135148

136149
[tool.coverage.run]

0 commit comments

Comments
 (0)