@@ -10,7 +10,7 @@ tool can be:
10
10
- a test runner (such as :pypi: `pytest `),
11
11
- a linter (e.g., :pypi: `flake8 `),
12
12
- a formatter (for example :pypi: `black ` or :pypi: `isort `),
13
- - a documentation generator (e.g., :pypi: `sphinx `),
13
+ - a documentation generator (e.g., :pypi: `Sphinx `),
14
14
- library builder and publisher (e.g., :pypi: `build ` with :pypi: `twine `),
15
15
- or anything else you may need to execute.
16
16
@@ -176,10 +176,10 @@ Related projects
176
176
tox has influenced several other projects in the Python test automation space. If tox doesn't quite fit your needs or
177
177
you want to do more research, we recommend taking a look at these projects:
178
178
179
- - `nox <https://nox.thea.codes >`__ is a project similar in spirit to tox but different in approach. The primary key
180
- difference is that it uses Python scripts instead of a configuration file. It might be useful if you find tox
181
- configuration too limiting but aren't looking to move to something as general-purpose as ``Invoke `` or `` make ``.
182
- Please note that tox will support defining configuration in a Python file soon, too.
179
+ - `nox <https://nox.thea.codes/en/stable/ >`__ is a project similar in spirit to tox but different in approach. The
180
+ primary key difference is that it uses Python scripts instead of a configuration file. It might be useful if you
181
+ find tox configuration too limiting but aren't looking to move to something as general-purpose as ``Invoke `` or
182
+ `` make ``. Please note that tox will support defining configuration in a Python file soon, too.
183
183
- `Invoke <https://www.pyinvoke.org/ >`__ is a general-purpose task execution library, similar to Make. Invoke is far
184
184
more general-purpose than tox but it does not contain the Python testing-specific features that tox specializes in.
185
185
@@ -364,4 +364,74 @@ tox supports these features that 90 percent of the time you'll not need, but are
364
364
Generative environments
365
365
~~~~~~~~~~~~~~~~~~~~~~~
366
366
367
- Django.
367
+ Generative environment list
368
+ +++++++++++++++++++++++++++
369
+
370
+ If you have a large matrix of dependencies, python versions and/or environments you can use a generative
371
+ :ref: `env_list ` and conditional settings to express that in a concise form:
372
+
373
+ .. code-block :: ini
374
+
375
+ [tox]
376
+ env_list = py{311,310,39}-django{41,40}-{sqlite,mysql}
377
+
378
+ [testenv]
379
+ deps =
380
+ django41: Django>=4.1,<4.2
381
+ django40: Django>=4.0,<4.1
382
+ # use PyMySQL if factors "py311" and "mysql" are present in env name
383
+ py311-mysql: PyMySQL
384
+ # use urllib3 if any of "py311" or "py310" are present in env name
385
+ py311,py310: urllib3
386
+ # mocking sqlite on 3.11 and 3.10 if factor "sqlite" is present
387
+ py{311,310}-sqlite: mock
388
+
389
+ This will generate the following tox environments:
390
+
391
+ .. code-block :: shell
392
+
393
+ > tox l
394
+ default environments:
395
+ py311-django41-sqlite -> [no description]
396
+ py311-django41-mysql -> [no description]
397
+ py311-django40-sqlite -> [no description]
398
+ py311-django40-mysql -> [no description]
399
+ py310-django41-sqlite -> [no description]
400
+ py310-django41-mysql -> [no description]
401
+ py310-django40-sqlite -> [no description]
402
+ py310-django40-mysql -> [no description]
403
+ py39-django41-sqlite -> [no description]
404
+ py39-django41-mysql -> [no description]
405
+ py39-django40-sqlite -> [no description]
406
+ py39-django40-mysql -> [no description]
407
+
408
+ Generative section names
409
+ ++++++++++++++++++++++++
410
+
411
+ Suppose you have some binary packages, and need to run tests both in 32 and 64 bits. You also want an environment to
412
+ create your virtual env for the developers.
413
+
414
+ .. code-block :: ini
415
+
416
+ [testenv]
417
+ base_python =
418
+ py311-x86: python3.11-32
419
+ py311-x64: python3.11-64
420
+ commands = pytest
421
+
422
+ [testenv:py311-{x86,x64}-venv]
423
+ envdir =
424
+ x86: .venv-x86
425
+ x64: .venv-x64
426
+
427
+ .. code-block :: shell
428
+
429
+ > tox l
430
+ default environments:
431
+ py -> [no description]
432
+
433
+ additional environments:
434
+ py310-black -> [no description]
435
+ py310-lint -> [no description]
436
+ py311-black -> [no description]
437
+ py311-lint -> [no description]
0 commit comments