Skip to content

Commit 028eb6f

Browse files
Merge pull request #9115 from RonnyPfannschmidt/fix-regendoc
fix #8818 - run regendoc without tox cachedir
2 parents dced00e + c21ef7b commit 028eb6f

25 files changed

+298
-369
lines changed

changelog/8818.trivial.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Ensure ``regendoc`` opts out of ``TOX_ENV`` cachedir selection to ensure independent example test runs.

doc/en/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ REGENDOC_ARGS := \
3434

3535
regen: REGENDOC_FILES:=*.rst */*.rst
3636
regen:
37-
PYTHONDONTWRITEBYTECODE=1 PYTEST_ADDOPTS="-pno:hypothesis -Wignore::pytest.PytestUnknownMarkWarning" COLUMNS=76 regendoc --update ${REGENDOC_FILES} ${REGENDOC_ARGS}
37+
# need to reset cachedir to the non-tox default
38+
PYTHONDONTWRITEBYTECODE=1 \
39+
PYTEST_ADDOPTS="-pno:hypothesis -p no:hypothesispytest -Wignore::pytest.PytestUnknownMarkWarning -o cache_dir=.pytest_cache" \
40+
COLUMNS=76 \
41+
regendoc --update ${REGENDOC_FILES} ${REGENDOC_ARGS}
3842

3943
.PHONY: regen

doc/en/builtin.rst

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
1616

1717
.. code-block:: pytest
1818
19-
$ pytest -q --fixtures
20-
cache
19+
$ pytest --fixtures -v
20+
=========================== test session starts ============================
21+
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
22+
cachedir: .pytest_cache
23+
rootdir: /home/sweet/project
24+
collected 0 items
25+
cache -- ../../../..$PYTHON_SITE/_pytest/cacheprovider.py:520
2126
Return a cache object that can persist state between testing sessions.
2227
2328
cache.get(key, default)
@@ -28,48 +33,49 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
2833
2934
Values can be any object handled by the json stdlib module.
3035
31-
capsys
36+
capsys -- ../../../..$PYTHON_SITE/_pytest/capture.py:903
3237
Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.
3338
3439
The captured output is made available via ``capsys.readouterr()`` method
3540
calls, which return a ``(out, err)`` namedtuple.
3641
``out`` and ``err`` will be ``text`` objects.
3742
38-
capsysbinary
43+
capsysbinary -- ../../../..$PYTHON_SITE/_pytest/capture.py:920
3944
Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.
4045
4146
The captured output is made available via ``capsysbinary.readouterr()``
4247
method calls, which return a ``(out, err)`` namedtuple.
4348
``out`` and ``err`` will be ``bytes`` objects.
4449
45-
capfd
50+
capfd -- ../../../..$PYTHON_SITE/_pytest/capture.py:937
4651
Enable text capturing of writes to file descriptors ``1`` and ``2``.
4752
4853
The captured output is made available via ``capfd.readouterr()`` method
4954
calls, which return a ``(out, err)`` namedtuple.
5055
``out`` and ``err`` will be ``text`` objects.
5156
52-
capfdbinary
57+
capfdbinary -- ../../../..$PYTHON_SITE/_pytest/capture.py:954
5358
Enable bytes capturing of writes to file descriptors ``1`` and ``2``.
5459
5560
The captured output is made available via ``capfd.readouterr()`` method
5661
calls, which return a ``(out, err)`` namedtuple.
5762
``out`` and ``err`` will be ``byte`` objects.
5863
59-
doctest_namespace [session scope]
64+
doctest_namespace [session scope] -- ../../../..$PYTHON_SITE/_pytest/doctest.py:728
6065
Fixture that returns a :py:class:`dict` that will be injected into the
6166
namespace of doctests.
6267
63-
pytestconfig [session scope]
64-
Session-scoped fixture that returns the :class:`pytest.Config` object.
68+
pytestconfig [session scope] -- ../../../..$PYTHON_SITE/_pytest/fixtures.py:1372
69+
Session-scoped fixture that returns the session's :class:`pytest.Config`
70+
object.
6571
6672
Example::
6773
6874
def test_foo(pytestconfig):
6975
if pytestconfig.getoption("verbose") > 0:
7076
...
7177
72-
record_property
78+
record_property -- ../../../..$PYTHON_SITE/_pytest/junitxml.py:282
7379
Add extra properties to the calling test.
7480
7581
User properties become part of the test report and are available to the
@@ -83,13 +89,13 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
8389
def test_function(record_property):
8490
record_property("example_key", 1)
8591
86-
record_xml_attribute
92+
record_xml_attribute -- ../../../..$PYTHON_SITE/_pytest/junitxml.py:305
8793
Add extra xml attributes to the tag for the calling test.
8894
8995
The fixture is callable with ``name, value``. The value is
9096
automatically XML-encoded.
9197
92-
record_testsuite_property [session scope]
98+
record_testsuite_property [session scope] -- ../../../..$PYTHON_SITE/_pytest/junitxml.py:343
9399
Record a new ``<property>`` tag as child of the root ``<testsuite>``.
94100
95101
This is suitable to writing global information regarding the entire test
@@ -111,7 +117,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
111117
`pytest-xdist <https://github.com/pytest-dev/pytest-xdist>`__ plugin. See issue
112118
`#7767 <https://github.com/pytest-dev/pytest/issues/7767>`__ for details.
113119
114-
caplog
120+
caplog -- ../../../..$PYTHON_SITE/_pytest/logging.py:491
115121
Access and control log capturing.
116122
117123
Captured logs are available through the following properties/methods::
@@ -122,7 +128,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
122128
* caplog.record_tuples -> list of (logger_name, level, message) tuples
123129
* caplog.clear() -> clear captured records and formatted log output string
124130
125-
monkeypatch
131+
monkeypatch -- ../../../..$PYTHON_SITE/_pytest/monkeypatch.py:29
126132
A convenient fixture for monkey-patching.
127133
128134
The fixture provides these methods to modify objects, dictionaries or
@@ -141,19 +147,19 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
141147
fixture has finished. The ``raising`` parameter determines if a KeyError
142148
or AttributeError will be raised if the set/deletion operation has no target.
143149
144-
recwarn
150+
recwarn -- ../../../..$PYTHON_SITE/_pytest/recwarn.py:29
145151
Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.
146152
147153
See https://docs.python.org/library/how-to/capture-warnings.html for information
148154
on warning categories.
149155
150-
tmpdir_factory [session scope]
156+
tmpdir_factory [session scope] -- ../../../..$PYTHON_SITE/_pytest/tmpdir.py:210
151157
Return a :class:`pytest.TempdirFactory` instance for the test session.
152158
153-
tmp_path_factory [session scope]
159+
tmp_path_factory [session scope] -- ../../../..$PYTHON_SITE/_pytest/tmpdir.py:217
154160
Return a :class:`pytest.TempPathFactory` instance for the test session.
155161
156-
tmpdir
162+
tmpdir -- ../../../..$PYTHON_SITE/_pytest/tmpdir.py:232
157163
Return a temporary directory path object which is unique to each test
158164
function invocation, created as a sub directory of the base temporary
159165
directory.
@@ -163,11 +169,11 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
163169
``--basetemp`` is used then it is cleared each session. See :ref:`base
164170
temporary directory`.
165171
166-
The returned object is a `py.path.local`_ path object.
172+
The returned object is a `legacy_path`_ object.
167173
168-
.. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html
174+
.. _legacy_path: https://py.readthedocs.io/en/latest/path.html
169175
170-
tmp_path
176+
tmp_path -- ../../../..$PYTHON_SITE/_pytest/tmpdir.py:250
171177
Return a temporary directory path object which is unique to each test
172178
function invocation, created as a sub directory of the base temporary
173179
directory.
@@ -180,7 +186,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
180186
The returned object is a :class:`pathlib.Path` object.
181187
182188
183-
no tests ran in 0.12s
189+
========================== no tests ran in 0.12s ===========================
184190
185191
You can also interactively ask for help, e.g. by typing on the Python interactive prompt something like:
186192

doc/en/example/markers.rst

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ You can then restrict a test run to only run tests marked with ``webtest``:
4646
$ pytest -v -m webtest
4747
=========================== test session starts ============================
4848
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
49-
cachedir: $PYTHON_PREFIX/.pytest_cache
50-
rootdir: $REGENDOC_TMPDIR
49+
cachedir: .pytest_cache
50+
rootdir: /home/sweet/project
5151
collecting ... collected 4 items / 3 deselected / 1 selected
5252
5353
test_server.py::test_send_http PASSED [100%]
@@ -61,8 +61,8 @@ Or the inverse, running all tests except the webtest ones:
6161
$ pytest -v -m "not webtest"
6262
=========================== test session starts ============================
6363
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
64-
cachedir: $PYTHON_PREFIX/.pytest_cache
65-
rootdir: $REGENDOC_TMPDIR
64+
cachedir: .pytest_cache
65+
rootdir: /home/sweet/project
6666
collecting ... collected 4 items / 1 deselected / 3 selected
6767
6868
test_server.py::test_something_quick PASSED [ 33%]
@@ -83,8 +83,8 @@ tests based on their module, class, method, or function name:
8383
$ pytest -v test_server.py::TestClass::test_method
8484
=========================== test session starts ============================
8585
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
86-
cachedir: $PYTHON_PREFIX/.pytest_cache
87-
rootdir: $REGENDOC_TMPDIR
86+
cachedir: .pytest_cache
87+
rootdir: /home/sweet/project
8888
collecting ... collected 1 item
8989
9090
test_server.py::TestClass::test_method PASSED [100%]
@@ -98,8 +98,8 @@ You can also select on the class:
9898
$ pytest -v test_server.py::TestClass
9999
=========================== test session starts ============================
100100
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
101-
cachedir: $PYTHON_PREFIX/.pytest_cache
102-
rootdir: $REGENDOC_TMPDIR
101+
cachedir: .pytest_cache
102+
rootdir: /home/sweet/project
103103
collecting ... collected 1 item
104104
105105
test_server.py::TestClass::test_method PASSED [100%]
@@ -113,8 +113,8 @@ Or select multiple nodes:
113113
$ pytest -v test_server.py::TestClass test_server.py::test_send_http
114114
=========================== test session starts ============================
115115
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
116-
cachedir: $PYTHON_PREFIX/.pytest_cache
117-
rootdir: $REGENDOC_TMPDIR
116+
cachedir: .pytest_cache
117+
rootdir: /home/sweet/project
118118
collecting ... collected 2 items
119119
120120
test_server.py::TestClass::test_method PASSED [ 50%]
@@ -157,8 +157,8 @@ The expression matching is now case-insensitive.
157157
$ pytest -v -k http # running with the above defined example module
158158
=========================== test session starts ============================
159159
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
160-
cachedir: $PYTHON_PREFIX/.pytest_cache
161-
rootdir: $REGENDOC_TMPDIR
160+
cachedir: .pytest_cache
161+
rootdir: /home/sweet/project
162162
collecting ... collected 4 items / 3 deselected / 1 selected
163163
164164
test_server.py::test_send_http PASSED [100%]
@@ -172,8 +172,8 @@ And you can also run all tests except the ones that match the keyword:
172172
$ pytest -k "not send_http" -v
173173
=========================== test session starts ============================
174174
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
175-
cachedir: $PYTHON_PREFIX/.pytest_cache
176-
rootdir: $REGENDOC_TMPDIR
175+
cachedir: .pytest_cache
176+
rootdir: /home/sweet/project
177177
collecting ... collected 4 items / 1 deselected / 3 selected
178178
179179
test_server.py::test_something_quick PASSED [ 33%]
@@ -189,8 +189,8 @@ Or to select "http" and "quick" tests:
189189
$ pytest -k "http or quick" -v
190190
=========================== test session starts ============================
191191
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
192-
cachedir: $PYTHON_PREFIX/.pytest_cache
193-
rootdir: $REGENDOC_TMPDIR
192+
cachedir: .pytest_cache
193+
rootdir: /home/sweet/project
194194
collecting ... collected 4 items / 2 deselected / 2 selected
195195
196196
test_server.py::test_send_http PASSED [ 50%]
@@ -244,7 +244,7 @@ You can ask which markers exist for your test suite - the list includes our just
244244
245245
@pytest.mark.parametrize(argnames, argvalues): call a test function multiple times passing in different arguments in turn. argvalues generally needs to be a list of values if argnames specifies only one name or a list of tuples of values if argnames specifies multiple names. Example: @parametrize('arg1', [1,2]) would lead to two calls of the decorated test function, one with arg1=1 and another with arg1=2.see https://docs.pytest.org/en/stable/how-to/parametrize.html for more info and examples.
246246
247-
@pytest.mark.usefixtures(fixturename1, fixturename2, ...): mark tests as needing all of the specified fixtures. see https://docs.pytest.org/en/stable/how-to/fixtures.html#usefixtures
247+
@pytest.mark.usefixtures(fixturename1, fixturename2, ...): mark tests as needing all of the specified fixtures. see https://docs.pytest.org/en/stable/explanation/fixtures.html#usefixtures
248248
249249
@pytest.mark.tryfirst: mark a hook implementation function such that the plugin machinery will try to call it first/as early as possible.
250250
@@ -398,8 +398,8 @@ the test needs:
398398
$ pytest -E stage2
399399
=========================== test session starts ============================
400400
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y
401-
cachedir: $PYTHON_PREFIX/.pytest_cache
402-
rootdir: $REGENDOC_TMPDIR
401+
cachedir: .pytest_cache
402+
rootdir: /home/sweet/project
403403
collected 1 item
404404
405405
test_someenv.py s [100%]
@@ -413,8 +413,8 @@ and here is one that specifies exactly the environment needed:
413413
$ pytest -E stage1
414414
=========================== test session starts ============================
415415
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y
416-
cachedir: $PYTHON_PREFIX/.pytest_cache
417-
rootdir: $REGENDOC_TMPDIR
416+
cachedir: .pytest_cache
417+
rootdir: /home/sweet/project
418418
collected 1 item
419419
420420
test_someenv.py . [100%]
@@ -488,7 +488,7 @@ The output is as follows:
488488
.. code-block:: pytest
489489
490490
$ pytest -q -s
491-
Mark(name='my_marker', args=(<function hello_world at 0xdeadbeef>,), kwargs={})
491+
Mark(name='my_marker', args=(<function hello_world at 0xdeadbeef0001>,), kwargs={})
492492
.
493493
1 passed in 0.12s
494494
@@ -606,8 +606,8 @@ then you will see two tests skipped and two executed tests as expected:
606606
$ pytest -rs # this option reports skip reasons
607607
=========================== test session starts ============================
608608
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y
609-
cachedir: $PYTHON_PREFIX/.pytest_cache
610-
rootdir: $REGENDOC_TMPDIR
609+
cachedir: .pytest_cache
610+
rootdir: /home/sweet/project
611611
collected 4 items
612612
613613
test_plat.py s.s. [100%]
@@ -623,8 +623,8 @@ Note that if you specify a platform via the marker-command line option like this
623623
$ pytest -m linux
624624
=========================== test session starts ============================
625625
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y
626-
cachedir: $PYTHON_PREFIX/.pytest_cache
627-
rootdir: $REGENDOC_TMPDIR
626+
cachedir: .pytest_cache
627+
rootdir: /home/sweet/project
628628
collected 4 items / 3 deselected / 1 selected
629629
630630
test_plat.py . [100%]
@@ -687,8 +687,8 @@ We can now use the ``-m option`` to select one set:
687687
$ pytest -m interface --tb=short
688688
=========================== test session starts ============================
689689
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y
690-
cachedir: $PYTHON_PREFIX/.pytest_cache
691-
rootdir: $REGENDOC_TMPDIR
690+
cachedir: .pytest_cache
691+
rootdir: /home/sweet/project
692692
collected 4 items / 2 deselected / 2 selected
693693
694694
test_module.py FF [100%]
@@ -714,8 +714,8 @@ or to select both "event" and "interface" tests:
714714
$ pytest -m "interface or event" --tb=short
715715
=========================== test session starts ============================
716716
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y
717-
cachedir: $PYTHON_PREFIX/.pytest_cache
718-
rootdir: $REGENDOC_TMPDIR
717+
cachedir: .pytest_cache
718+
rootdir: /home/sweet/project
719719
collected 4 items / 1 deselected / 3 selected
720720
721721
test_module.py FFF [100%]

doc/en/example/nonpython.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ now execute the test specification:
3030
nonpython $ pytest test_simple.yaml
3131
=========================== test session starts ============================
3232
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y
33-
cachedir: $PYTHON_PREFIX/.pytest_cache
34-
rootdir: $REGENDOC_TMPDIR/nonpython
33+
cachedir: .pytest_cache
34+
rootdir: /home/sweet/project/nonpython
3535
collected 2 items
3636
3737
test_simple.yaml F. [100%]
@@ -67,8 +67,8 @@ consulted when reporting in ``verbose`` mode:
6767
nonpython $ pytest -v
6868
=========================== test session starts ============================
6969
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
70-
cachedir: $PYTHON_PREFIX/.pytest_cache
71-
rootdir: $REGENDOC_TMPDIR/nonpython
70+
cachedir: .pytest_cache
71+
rootdir: /home/sweet/project/nonpython
7272
collecting ... collected 2 items
7373
7474
test_simple.yaml::hello FAILED [ 50%]
@@ -93,8 +93,8 @@ interesting to just look at the collection tree:
9393
nonpython $ pytest --collect-only
9494
=========================== test session starts ============================
9595
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-1.x.y
96-
cachedir: $PYTHON_PREFIX/.pytest_cache
97-
rootdir: $REGENDOC_TMPDIR/nonpython
96+
cachedir: .pytest_cache
97+
rootdir: /home/sweet/project/nonpython
9898
collected 2 items
9999
100100
<Package nonpython>

0 commit comments

Comments
 (0)