Skip to content

Commit bdd1453

Browse files
authored
docs: Add prelude section on testenvs to config guide (#1573)
1 parent 7d8cfc3 commit bdd1453

File tree

5 files changed

+57
-21
lines changed

5 files changed

+57
-21
lines changed

.pre-commit-config.yaml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
default_language_version:
3+
# force all unspecified python hooks to run python3
4+
python: python3
15
repos:
26
- repo: https://github.com/psf/black
37
rev: 19.10b0
@@ -6,13 +10,13 @@ repos:
610
args: [--safe]
711
language_version: python3.8
812
- repo: https://github.com/asottile/blacken-docs
9-
rev: v1.3.0
13+
rev: v1.6.0
1014
hooks:
1115
- id: blacken-docs
12-
additional_dependencies: [black==19.3b0]
16+
additional_dependencies: [black==19.10b0]
1317
language_version: python3.8
1418
- repo: https://github.com/asottile/seed-isort-config
15-
rev: v1.9.3
19+
rev: v2.1.1
1620
hooks:
1721
- id: seed-isort-config
1822
args: [--application-directories, "src:."]
@@ -21,21 +25,21 @@ repos:
2125
hooks:
2226
- id: isort
2327
- repo: https://github.com/pre-commit/pre-commit-hooks
24-
rev: v2.4.0
28+
rev: v2.5.0
2529
hooks:
2630
- id: trailing-whitespace
2731
- id: end-of-file-fixer
2832
- id: check-yaml
2933
- id: debug-statements
3034
- id: flake8
31-
additional_dependencies: ["flake8-bugbear == 19.8.0"]
35+
additional_dependencies: ["flake8-bugbear == 20.1.4"]
3236
language_version: python3.8
3337
- repo: https://github.com/asottile/pyupgrade
34-
rev: v1.25.1
38+
rev: v2.3.0
3539
hooks:
3640
- id: pyupgrade
3741
- repo: https://github.com/pre-commit/pygrep-hooks
38-
rev: v1.4.2
42+
rev: v1.5.1
3943
hooks:
4044
- id: rst-backticks
4145
- repo: local

docs/changelog/1423.bugfix.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Respect attempts to change `PATH` via `setenv`. - by :user:`aklajnert`
1+
Respect attempts to change ``PATH`` via ``setenv`` - by :user:`aklajnert`.

docs/changelog/1573.doc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve documentation about config by adding tox environment description at start - by :user:`stephenfin`.

docs/config.rst

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -189,23 +189,50 @@ by using the ``tox:jenkins`` section:
189189
commands = ... # override settings for the jenkins context
190190
191191
192-
tox environment settings
193-
------------------------
192+
tox environments
193+
----------------
194194

195-
Test environments are defined by a:
195+
Test environments are defined under the ``testenv`` section and individual
196+
``testenv:NAME`` sections, where ``NAME`` is the name of a specific
197+
environment.
196198

197199
.. code-block:: ini
198200
201+
[testenv]
202+
commands = ...
203+
199204
[testenv:NAME]
200205
commands = ...
201206
202-
section. The ``NAME`` will be the name of the virtual environment.
203-
Defaults for each setting in this section are looked up in the::
207+
Settings defined in the top-level ``testenv`` section are automatically
208+
inherited by individual environments unless overridden. Test environment names
209+
can consist of alphanumeric characters and dashes; for example:
210+
``py38-django30``. The name will be split on dashes into multiple factors,
211+
meaning ``py38-django30`` will be split into two factors: ``py38`` and
212+
``django30``. *tox* defines a number of default factors, which correspond to
213+
various versions and implementations of Python and provide default values for
214+
:conf:`basepython`:
215+
216+
- ``pyNM``: configures ``basepython = pythonN.M``
217+
- ``pyN``: configures ``basepython = pythonN``
218+
- ``py``: configures ``basepython = python``
219+
- ``pypyN``: configures ``basepython = pypyN``
220+
- ``pypy``: configures ``basepython = pypy``
221+
- ``jythonN``: configures ``basepython = jythonN``
222+
- ``jython``: configures ``basepython = jython``
223+
224+
It is also possible to define what's know as *generative names*, where an
225+
individual section maps to multiple environments; for example:
226+
``py{37,38}-django{30,31}``, which would generate four environments, each
227+
consisting of two factors a piece: ``py37-django30`` (``py37``, ``django30``),
228+
``py37-django31`` (``py37``, ``django31``), ``py38-django30`` (``py38``,
229+
``django30``), and ``py38-django31`` (``py38``, ``django31``). Combined, these
230+
features provide the ability to write very concise ``tox.ini`` files and is
231+
discussed further `below <generating-environments>`__.
204232

205-
[testenv]
206-
commands = ...
207233

208-
``testenv`` default section.
234+
tox environment settings
235+
------------------------
209236

210237
Complete list of settings that you can put into ``testenv*`` sections:
211238

@@ -755,6 +782,8 @@ You can put default values in one section and reference them in others to avoid
755782
{[base]deps}
756783
757784
785+
.. _generating-environments:
786+
758787
Generating environments, conditional settings
759788
---------------------------------------------
760789

@@ -793,7 +822,7 @@ Let's go through this step by step.
793822
.. _generative-envlist:
794823

795824
Generative envlist
796-
+++++++++++++++++++++++
825+
++++++++++++++++++
797826

798827
::
799828

@@ -856,9 +885,10 @@ but still want to take advantage of factor-conditional settings.
856885
Factors and factor-conditional settings
857886
++++++++++++++++++++++++++++++++++++++++
858887

859-
Parts of an environment name delimited by hyphens are called factors and can
860-
be used to set values conditionally. In list settings such as ``deps`` or
861-
``commands`` you can freely intermix optional lines with unconditional ones:
888+
As discussed previously, parts of an environment name delimited by hyphens are
889+
called factors and can be used to set values conditionally. In list settings
890+
such as ``deps`` or ``commands`` you can freely intermix optional lines with
891+
unconditional ones:
862892

863893
.. code-block:: ini
864894
@@ -908,6 +938,7 @@ special case for a combination of factors. Here is how you do it:
908938
py{27,36}-sqlite: mock # mocking sqlite in python 2.x & 3.6
909939
!py34-sqlite: mock # mocking sqlite, except in python 3.4
910940
sqlite-!py34: mock # (same as the line above)
941+
!py34,!py36: enum34 # use if neither py34 nor py36 are in the env name
911942
912943
Take a look at the first ``deps`` line. It shows how you can special case
913944
something for a combination of factors, by just hyphenating the combining

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ passenv =
7272
PROGRAMDATA
7373
PRE_COMMIT_HOME
7474
extras = lint
75-
deps = pre-commit >= 1.14.4, < 2
75+
deps = pre-commit>=2, <3
7676
skip_install = True
7777
commands = pre-commit run --all-files --show-diff-on-failure {posargs}
7878
python -c 'import pathlib; print("hint: run \{\} install to add checks as pre-commit hook".format(pathlib.Path(r"{envdir}") / "bin" / "pre-commit"))'

0 commit comments

Comments
 (0)