You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -14,15 +14,102 @@ configurations files by using the general help option:
14
14
This will display command line and configuration file settings
15
15
which were registered by installed plugins.
16
16
17
+
.. _`config file formats`:
18
+
19
+
Configuration file formats
20
+
--------------------------
21
+
22
+
Many :ref:`pytest settings <ini options ref>` can be set in a *configuration file*, which
23
+
by convention resides on the root of your repository or in your
24
+
tests folder.
25
+
26
+
A quick example of the configuration files supported by pytest:
27
+
28
+
pytest.ini
29
+
~~~~~~~~~~
30
+
31
+
``pytest.ini`` files take precedence over other files, even when empty.
32
+
33
+
.. code-block:: ini
34
+
35
+
# pytest.ini
36
+
[pytest]
37
+
minversion = 6.0
38
+
addopts = -ra -q
39
+
testpaths =
40
+
tests
41
+
integration
42
+
43
+
44
+
pyproject.toml
45
+
~~~~~~~~~~~~~~
46
+
47
+
.. versionadded:: 6.0
48
+
49
+
``pyproject.toml`` are considered for configuration when they contain a ``tool.pytest.ini_options`` table.
50
+
51
+
.. code-block:: toml
52
+
53
+
# pyproject.toml
54
+
[tool.pytest.ini_options]
55
+
minversion = "6.0"
56
+
addopts = "-ra -q"
57
+
testpaths = [
58
+
"tests",
59
+
"integration",
60
+
]
61
+
62
+
tox.ini
63
+
~~~~~~~
64
+
65
+
``tox.ini`` files are the configuration files of the `tox <https://tox.readthedocs.io>`__ project,
66
+
and can also be used to hold pytest configuration if they have a ``[pytest]`` section.
67
+
68
+
.. code-block:: ini
69
+
70
+
# tox.ini
71
+
[pytest]
72
+
minversion = 6.0
73
+
addopts = -ra -q
74
+
testpaths =
75
+
tests
76
+
integration
77
+
78
+
79
+
setup.cfg
80
+
~~~~~~~~~
81
+
82
+
``setup.cfg`` files are general purpose configuration files, used originally by `distutils <https://docs.python.org/3/distutils/configfile.html>`__, and can also be used to hold pytest configuration
83
+
if they have a ``[tool:pytest]`` section.
84
+
85
+
.. code-block:: ini
86
+
87
+
# setup.cfg
88
+
[tool:pytest]
89
+
minversion = 6.0
90
+
addopts = -ra -q
91
+
testpaths =
92
+
tests
93
+
integration
94
+
95
+
.. warning::
96
+
97
+
Usage of ``setup.cfg`` is not recommended unless for very simple use cases. ``.cfg``
98
+
files use a different parser than ``pytest.ini`` and ``tox.ini`` which might cause hard to track
99
+
down problems.
100
+
When possible, it is recommended to use the latter files, or ``pyproject.toml``, to hold your
101
+
pytest configuration.
102
+
103
+
17
104
.. _rootdir:
18
-
.. _inifiles:
105
+
.. _configfiles:
19
106
20
-
Initialization: determining rootdir and inifile
21
-
-----------------------------------------------
107
+
Initialization: determining rootdir and configfile
0 commit comments