Skip to content

Commit 52d8e68

Browse files
authored
Merge pull request #13889 from bluetech/regendoc-restore
Regendoc fixes
2 parents 5ae9e47 + d6d3e4a commit 52d8e68

File tree

8 files changed

+52
-157
lines changed

8 files changed

+52
-157
lines changed

doc/en/example/markers.rst

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -239,21 +239,11 @@ Registering markers
239239
240240
Registering markers for your test suite is simple:
241241

242-
.. tab:: toml
242+
.. code-block:: toml
243243
244-
.. code-block:: toml
245-
246-
[pytest]
247-
markers = ["webtest: mark a test as a webtest.", "slow: mark test as slow."]
248-
249-
.. tab:: ini
250-
251-
.. code-block:: ini
252-
253-
[pytest]
254-
markers =
255-
webtest: mark a test as a webtest.
256-
slow: mark test as slow.
244+
# content of pytest.toml
245+
[pytest]
246+
markers = ["webtest: mark a test as a webtest.", "slow: mark test as slow."]
257247
258248
Multiple custom markers can be registered, by defining each one in its own line, as shown in above example.
259249

doc/en/example/pythoncollection.rst

Lines changed: 24 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,11 @@ Changing directory recursion
9090

9191
You can set the :confval:`norecursedirs` option in a configuration file:
9292

93-
.. tab:: toml
93+
.. code-block:: toml
9494
95-
.. code-block:: toml
96-
97-
[pytest]
98-
norecursedirs = [".svn", "_build", "tmp*"]
99-
100-
.. tab:: ini
101-
102-
.. code-block:: ini
103-
104-
[pytest]
105-
norecursedirs = .svn _build tmp*
95+
# content of pytest.toml
96+
[pytest]
97+
norecursedirs = [".svn", "_build", "tmp*"]
10698
10799
This would tell ``pytest`` to not recurse into typical subversion or sphinx-build directories or into any ``tmp`` prefixed directory.
108100

@@ -116,25 +108,14 @@ the :confval:`python_files`, :confval:`python_classes` and
116108
:confval:`python_functions` in your :ref:`configuration file <config file formats>`.
117109
Here is an example:
118110

119-
.. tab:: toml
120-
121-
.. code-block:: toml
111+
.. code-block:: toml
122112
123-
# Example 1: have pytest look for "check" instead of "test"
124-
[pytest]
125-
python_files = ["check_*.py"]
126-
python_classes = ["Check"]
127-
python_functions = ["*_check"]
128-
129-
.. tab:: ini
130-
131-
.. code-block:: ini
132-
133-
# Example 1: have pytest look for "check" instead of "test"
134-
[pytest]
135-
python_files = check_*.py
136-
python_classes = Check
137-
python_functions = *_check
113+
# content of pytest.toml
114+
# Example 1: have pytest look for "check" instead of "test"
115+
[pytest]
116+
python_files = ["check_*.py"]
117+
python_classes = ["Check"]
118+
python_functions = ["*_check"]
138119
139120
This would make ``pytest`` look for tests in files that match the ``check_*
140121
.py`` glob-pattern, ``Check`` prefixes in classes, and functions and methods
@@ -171,21 +152,12 @@ The test collection would look like this:
171152
172153
You can check for multiple glob patterns by adding a space between the patterns:
173154

174-
.. tab:: toml
175-
176-
.. code-block:: toml
177-
178-
# Example 2: have pytest look for files with "test" and "example"
179-
[pytest]
180-
python_files = ["test_*.py", "example_*.py"]
155+
.. code-block:: toml
181156
182-
.. tab:: ini
183-
184-
.. code-block:: ini
185-
186-
# Example 2: have pytest look for files with "test" and "example"
187-
[pytest]
188-
python_files = test_*.py example_*.py
157+
# content of pytest.toml
158+
# Example 2: have pytest look for files with "test" and "example"
159+
[pytest]
160+
python_files = ["test_*.py", "example_*.py"]
189161
190162
.. note::
191163

@@ -209,19 +181,11 @@ which would run the respective test module. Like with
209181
other options, through a configuration file and the :confval:`addopts` option you
210182
can make this change more permanently:
211183

212-
.. tab:: toml
213-
214-
.. code-block:: toml
215-
216-
[pytest]
217-
addopts = ["--pyargs"]
218-
219-
.. tab:: ini
184+
.. code-block:: toml
220185
221-
.. code-block:: ini
222-
223-
[pytest]
224-
addopts = --pyargs
186+
# content of pytest.toml
187+
[pytest]
188+
addopts = ["--pyargs"]
225189
226190
Now a simple invocation of ``pytest NAME`` will check
227191
if NAME exists as an importable package/module and otherwise
@@ -260,19 +224,11 @@ Customizing test collection
260224
261225
You can easily instruct ``pytest`` to discover tests from every Python file:
262226

263-
.. tab:: toml
264-
265-
.. code-block:: toml
266-
267-
[pytest]
268-
python_files = ["*.py"]
269-
270-
.. tab:: ini
271-
272-
.. code-block:: ini
227+
.. code-block:: toml
273228
274-
[pytest]
275-
python_files = *.py
229+
# content of pytest.toml
230+
[pytest]
231+
python_files = ["*.py"]
276232
277233
However, many projects will have a ``setup.py`` which they don't want to be
278234
imported. Moreover, there may files only importable by a specific python

doc/en/example/simple.rst

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,11 @@ every time you use ``pytest``. For example, if you always want to see
1111
detailed info on skipped and xfailed tests, as well as have terser "dot"
1212
progress output, you can write it into a configuration file:
1313

14-
.. tab:: toml
15-
16-
.. code-block:: toml
17-
18-
[pytest]
19-
addopts = ["-ra", "-q"]
20-
21-
.. tab:: ini
22-
23-
.. code-block:: ini
24-
25-
[pytest]
26-
addopts = -ra -q
14+
.. code-block:: toml
2715
16+
# content of pytest.toml
17+
[pytest]
18+
addopts = ["-ra", "-q"]
2819
2920
Alternatively, you can set a ``PYTEST_ADDOPTS`` environment variable to add command
3021
line options while the environment is in use:

doc/en/explanation/goodpractices.rst

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,11 @@ For new projects, we recommend to use ``importlib`` :ref:`import mode <import-mo
9696
(see which-import-mode_ for a detailed explanation).
9797
To this end, add the following to your configuration file:
9898

99-
.. tab:: toml
100-
101-
.. code-block:: toml
102-
103-
[pytest]
104-
addopts = ["--import-mode=importlib"]
105-
106-
.. tab:: ini
107-
108-
.. code-block:: ini
99+
.. code-block:: toml
109100
110-
[pytest]
111-
addopts = --import-mode=importlib
101+
# content of pytest.toml
102+
[pytest]
103+
addopts = ["--import-mode=importlib"]
112104
113105
.. _src-layout:
114106

doc/en/how-to/doctest.rst

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,11 @@ and functions, including from test modules:
7070
You can make these changes permanent in your project by
7171
putting them into a configuration file like this:
7272

73-
.. tab:: toml
74-
75-
.. code-block:: toml
76-
77-
[pytest]
78-
addopts = ["--doctest-modules"]
79-
80-
.. tab:: ini
81-
82-
.. code-block:: ini
83-
84-
[pytest]
85-
addopts = --doctest-modules
73+
.. code-block:: toml
8674
75+
# content of pytest.toml
76+
[pytest]
77+
addopts = ["--doctest-modules"]
8778
8879
Encoding
8980
--------

doc/en/how-to/fixtures.rst

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,20 +1738,11 @@ and you may specify fixture usage at the test module level using :globalvar:`pyt
17381738
It is also possible to put fixtures required by all tests in your project
17391739
into a configuration file:
17401740

1741-
.. tab:: toml
1742-
1743-
.. code-block:: toml
1744-
1745-
[pytest]
1746-
usefixtures = ["cleandir"]
1747-
1748-
.. tab:: ini
1749-
1750-
.. code-block:: ini
1751-
1752-
[pytest]
1753-
usefixtures = cleandir
1741+
.. code-block:: toml
17541742
1743+
# content of pytest.toml
1744+
[pytest]
1745+
usefixtures = ["cleandir"]
17551746
17561747
.. warning::
17571748

doc/en/how-to/writing_plugins.rst

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -422,19 +422,11 @@ which is especially useful for longer tests and/or longer ``conftest.py`` files.
422422
Note that for ``pytester.copy_example`` to work we need to set `pytester_example_dir`
423423
in our configuration file to tell pytest where to look for example files.
424424

425-
.. tab:: toml
425+
.. code-block:: toml
426426
427-
.. code-block:: toml
428-
429-
[pytest]
430-
pytester_example_dir = "."
431-
432-
.. tab:: ini
433-
434-
.. code-block:: ini
435-
436-
[pytest]
437-
pytester_example_dir = .
427+
# content of pytest.toml
428+
[pytest]
429+
pytester_example_dir = "."
438430
439431
440432
.. code-block:: python

doc/en/reference/reference.rst

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,19 +1333,11 @@ passed multiple times. The expected format is ``name=value``. For example::
13331333
Add the specified ``OPTS`` to the set of command line arguments as if they
13341334
had been specified by the user. Example: if you have this configuration file content:
13351335

1336-
.. tab:: toml
1337-
1338-
.. code-block:: toml
1339-
1340-
[pytest]
1341-
addopts = ["--maxfail=2", "-rf"] # exit after 2 failures, report fail info
1336+
.. code-block:: toml
13421337
1343-
.. tab:: ini
1344-
1345-
.. code-block:: ini
1346-
1347-
[pytest]
1348-
addopts = --maxfail=2 -rf # exit after 2 failures, report fail info
1338+
# content of pytest.toml
1339+
[pytest]
1340+
addopts = ["--maxfail=2", "-rf"] # exit after 2 failures, report fail info
13491341
13501342
issuing ``pytest test_hello.py`` actually means:
13511343

0 commit comments

Comments
 (0)