Skip to content

Commit 4941983

Browse files
authored
Differentiate between venv and tox setups in CONTRIBUTING.md (#16067)
1 parent 8b73cc2 commit 4941983

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed

CONTRIBUTING.md

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,6 @@ like this:
6262
python3 runtests.py
6363
```
6464

65-
You can also use `tox` to run tests (`tox` handles setting up the test environment for you):
66-
67-
```bash
68-
tox run -e py
69-
70-
# Or some specific python version:
71-
tox run -e py39
72-
73-
# Or some specific command:
74-
tox run -e lint
75-
```
76-
7765
Some useful commands for running specific tests include:
7866

7967
```bash
@@ -95,6 +83,36 @@ python runtests.py lint
9583
For an in-depth guide on running and writing tests,
9684
see [the README in the test-data directory](test-data/unit/README.md).
9785

86+
#### Using `tox`
87+
88+
You can also use [`tox`](https://tox.wiki/en/latest/) to run tests and other commands.
89+
`tox` handles setting up test environments for you.
90+
91+
```bash
92+
# Run tests
93+
tox run -e py
94+
95+
# Run tests using some specific Python version
96+
tox run -e py311
97+
98+
# Run a specific command
99+
tox run -e lint
100+
101+
# Run a single test from the test suite
102+
tox run -e py -- -n0 -k 'test_name'
103+
104+
# Run all test cases in the "test-data/unit/check-dataclasses.test" file using
105+
# Python 3.11 specifically
106+
tox run -e py311 -- mypy/test/testcheck.py::TypeCheckSuite::check-dataclasses.test
107+
108+
# Set up a development environment with all the project libraries and run a command
109+
tox -e dev -- mypy --verbose test_case.py
110+
tox -e dev --override testenv:dev.allowlist_externals+=env -- env # inspect the environment
111+
```
112+
113+
If you don't already have `tox` installed, you can use a virtual environment as
114+
described above to install `tox` via `pip` (e.g., ``python3 -m pip install tox``).
115+
98116
## First time contributors
99117

100118
If you're looking for things to help with, browse our [issue tracker](https://github.com/python/mypy/issues)!

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ deps =
3030
commands =
3131
python -m pip list --format=columns
3232
python -c 'import sys; print(sys.executable)'
33+
{posargs}
3334

3435
[testenv:docs]
3536
description = invoke sphinx-build to build the HTML docs

0 commit comments

Comments
 (0)