@@ -4,7 +4,9 @@ Doctest integration for modules and test files
4
4
5
5
By default all files matching the ``test*.txt `` pattern will
6
6
be run through the python standard ``doctest `` module. You
7
- can change the pattern by issuing::
7
+ can change the pattern by issuing:
8
+
9
+ .. code-block :: bash
8
10
9
11
pytest --doctest-glob=' *.rst'
10
12
@@ -26,7 +28,9 @@ can be given multiple times in the command-line.
26
28
27
29
You can also trigger running of doctests
28
30
from docstrings in all python modules (including regular
29
- python test modules)::
31
+ python test modules):
32
+
33
+ .. code-block :: bash
30
34
31
35
pytest --doctest-modules
32
36
@@ -39,7 +43,9 @@ putting them into a pytest.ini file like this:
39
43
[pytest]
40
44
addopts = --doctest-modules
41
45
42
- If you then have a text file like this::
46
+ If you then have a text file like this:
47
+
48
+ .. code-block :: text
43
49
44
50
# content of example.rst
45
51
@@ -73,7 +79,9 @@ then you can just invoke ``pytest`` without command line options:
73
79
74
80
========================= 1 passed in 0.12 seconds =========================
75
81
76
- It is possible to use fixtures using the ``getfixture `` helper::
82
+ It is possible to use fixtures using the ``getfixture `` helper:
83
+
84
+ .. code-block :: text
77
85
78
86
# content of example.rst
79
87
>>> tmp = getfixture('tmpdir')
@@ -112,14 +120,18 @@ the ``doctest_optionflags`` ini option:
112
120
113
121
114
122
Alternatively, it can be enabled by an inline comment in the doc test
115
- itself::
123
+ itself:
124
+
125
+ .. code-block :: rst
116
126
117
127
# content of example.rst
118
128
>>> get_unicode_greeting() # doctest: +ALLOW_UNICODE
119
129
'Hello'
120
130
121
131
By default, pytest would report only the first failure for a given doctest. If
122
- you want to continue the test even when you have failures, do::
132
+ you want to continue the test even when you have failures, do:
133
+
134
+ .. code-block :: bash
123
135
124
136
pytest --doctest-modules --doctest-continue-on-failure
125
137
@@ -167,7 +179,9 @@ Output format
167
179
You can change the diff output format on failure for your doctests
168
180
by using one of standard doctest modules format in options
169
181
(see :data: `python:doctest.REPORT_UDIFF `, :data: `python:doctest.REPORT_CDIFF `,
170
- :data: `python:doctest.REPORT_NDIFF `, :data: `python:doctest.REPORT_ONLY_FIRST_FAILURE `)::
182
+ :data: `python:doctest.REPORT_NDIFF `, :data: `python:doctest.REPORT_ONLY_FIRST_FAILURE `):
183
+
184
+ .. code-block :: bash
171
185
172
186
pytest --doctest-modules --doctest-report none
173
187
pytest --doctest-modules --doctest-report udiff
0 commit comments