Skip to content

Commit 269b674

Browse files
committed
Merge branch 'main' into feature/issue-10865
# Conflicts: # testing/test_recwarn.py
2 parents 7ec6e4a + 8853a57 commit 269b674

File tree

184 files changed

+2588
-1803
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+2588
-1803
lines changed

.github/workflows/deploy.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
persist-credentials: false
2727

2828
- name: Build and Check Package
29-
uses: hynek/build-and-inspect-python-package@v1.5.4
29+
uses: hynek/build-and-inspect-python-package@v2.0.0
3030

3131
deploy:
3232
if: github.repository == 'pytest-dev/pytest'
@@ -41,7 +41,7 @@ jobs:
4141
- uses: actions/checkout@v4
4242

4343
- name: Download Package
44-
uses: actions/download-artifact@v3
44+
uses: actions/download-artifact@v4
4545
with:
4646
name: Packages
4747
path: dist
@@ -72,6 +72,12 @@ jobs:
7272
fetch-depth: 0
7373
persist-credentials: false
7474

75+
- name: Download Package
76+
uses: actions/download-artifact@v4
77+
with:
78+
name: Packages
79+
path: dist
80+
7581
- name: Set up Python
7682
uses: actions/setup-python@v5
7783
with:

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
fetch-depth: 0
3636
persist-credentials: false
3737
- name: Build and Check Package
38-
uses: hynek/build-and-inspect-python-package@v1.5.4
38+
uses: hynek/build-and-inspect-python-package@v2.0.0
3939

4040
build:
4141
needs: [package]
@@ -173,7 +173,7 @@ jobs:
173173
persist-credentials: false
174174

175175
- name: Download Package
176-
uses: actions/download-artifact@v3
176+
uses: actions/download-artifact@v4
177177
with:
178178
name: Packages
179179
path: dist

.github/workflows/update-plugin-list.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
python-version: "3.11"
3131
cache: pip
3232
- name: requests-cache
33-
uses: actions/cache@v3
33+
uses: actions/cache@v4
3434
with:
3535
path: ~/.cache/pytest-plugin-list/
3636
key: plugins-http-cache-${{ github.run_id }} # Can use time based key as well

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ repos:
6464
additional_dependencies:
6565
- iniconfig>=1.1.0
6666
- attrs>=19.2.0
67+
- pluggy>=1.4.0
6768
- packaging
6869
- tomli
6970
- types-pkg_resources

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ Evgeny Seliverstov
141141
Fabian Sturm
142142
Fabien Zarifian
143143
Fabio Zadrozny
144+
faph
144145
Felix Hofstätter
145146
Felix Nieuwenhuizen
146147
Feng Ma

changelog/11233.feature.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.

changelog/11706.bugfix.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog/11758.bugfix.rst

Lines changed: 0 additions & 2 deletions
This file was deleted.

changelog/11790.doc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Documented the retention of temporary directories created using the ``tmp_path`` fixture in more detail.

changelog/11801.improvement.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Added the :func:`iter_parents() <_pytest.nodes.Node.iter_parents>` helper method on nodes.
2+
It is similar to :func:`listchain <_pytest.nodes.Node.listchain>`, but goes from bottom to top, and returns an iterator, not a list.

doc/en/announce/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Release announcements
66
:maxdepth: 2
77

88

9+
release-8.0.0
10+
release-8.0.0rc2
911
release-8.0.0rc1
1012
release-7.4.4
1113
release-7.4.3

doc/en/announce/release-8.0.0.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
pytest-8.0.0
2+
=======================================
3+
4+
The pytest team is proud to announce the 8.0.0 release!
5+
6+
This release contains new features, improvements, bug fixes, and breaking changes, so users
7+
are encouraged to take a look at the CHANGELOG carefully:
8+
9+
https://docs.pytest.org/en/stable/changelog.html
10+
11+
For complete documentation, please visit:
12+
13+
https://docs.pytest.org/en/stable/
14+
15+
As usual, you can upgrade from PyPI via:
16+
17+
pip install -U pytest
18+
19+
Thanks to all of the contributors to this release:
20+
21+
* Bruno Oliveira
22+
* Ran Benita
23+
24+
25+
Happy testing,
26+
The pytest Development Team

doc/en/announce/release-8.0.0rc2.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
pytest-8.0.0rc2
2+
=======================================
3+
4+
The pytest team is proud to announce the 8.0.0rc2 prerelease!
5+
6+
This is a prerelease, not intended for production use, but to test the upcoming features and improvements
7+
in order to catch any major problems before the final version is released to the major public.
8+
9+
We appreciate your help testing this out before the final release, making sure to report any
10+
regressions to our issue tracker:
11+
12+
https://github.com/pytest-dev/pytest/issues
13+
14+
When doing so, please include the string ``[prerelease]`` in the title.
15+
16+
You can upgrade from PyPI via:
17+
18+
pip install pytest==8.0.0rc2
19+
20+
Users are encouraged to take a look at the CHANGELOG carefully:
21+
22+
https://docs.pytest.org/en/release-8.0.0rc2/changelog.html
23+
24+
Thanks to all the contributors to this release:
25+
26+
* Ben Brown
27+
* Bruno Oliveira
28+
* Ran Benita
29+
30+
31+
Happy testing,
32+
The pytest Development Team

doc/en/builtin.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
129129
if pytestconfig.getoption("verbose") > 0:
130130
...
131131
132-
record_property -- .../_pytest/junitxml.py:282
132+
record_property -- .../_pytest/junitxml.py:284
133133
Add extra properties to the calling test.
134134
135135
User properties become part of the test report and are available to the
@@ -143,13 +143,13 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
143143
def test_function(record_property):
144144
record_property("example_key", 1)
145145
146-
record_xml_attribute -- .../_pytest/junitxml.py:305
146+
record_xml_attribute -- .../_pytest/junitxml.py:307
147147
Add extra xml attributes to the tag for the calling test.
148148
149149
The fixture is callable with ``name, value``. The value is
150150
automatically XML-encoded.
151151
152-
record_testsuite_property [session scope] -- .../_pytest/junitxml.py:343
152+
record_testsuite_property [session scope] -- .../_pytest/junitxml.py:345
153153
Record a new ``<property>`` tag as child of the root ``<testsuite>``.
154154
155155
This is suitable to writing global information regarding the entire test
@@ -196,7 +196,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
196196
197197
.. _legacy_path: https://py.readthedocs.io/en/latest/path.html
198198
199-
caplog -- .../_pytest/logging.py:593
199+
caplog -- .../_pytest/logging.py:594
200200
Access and control log capturing.
201201
202202
Captured logs are available through the following properties/methods::

doc/en/changelog.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,49 @@ with advance notice in the **Deprecations** section of releases.
2828

2929
.. towncrier release notes start
3030
31+
pytest 8.0.0 (2024-01-27)
32+
=========================
33+
34+
Bug Fixes
35+
---------
36+
37+
- `#11842 <https://github.com/pytest-dev/pytest/issues/11842>`_: Properly escape the ``reason`` of a :ref:`skip <pytest.mark.skip ref>` mark when writing JUnit XML files.
38+
39+
40+
- `#11861 <https://github.com/pytest-dev/pytest/issues/11861>`_: Avoid microsecond exceeds ``1_000_000`` when using ``log-date-format`` with ``%f`` specifier, which might cause the test suite to crash.
41+
42+
43+
pytest 8.0.0rc2 (2024-01-17)
44+
============================
45+
46+
47+
Improvements
48+
------------
49+
50+
- `#11233 <https://github.com/pytest-dev/pytest/issues/11233>`_: Improvements to ``-r`` for xfailures and xpasses:
51+
52+
* Report tracebacks for xfailures when ``-rx`` is set.
53+
* Report captured output for xpasses when ``-rX`` is set.
54+
* For xpasses, add ``-`` in summary between test name and reason, to match how xfail is displayed.
55+
56+
- `#11825 <https://github.com/pytest-dev/pytest/issues/11825>`_: The :hook:`pytest_plugin_registered` hook has a new ``plugin_name`` parameter containing the name by which ``plugin`` is registered.
57+
58+
59+
Bug Fixes
60+
---------
61+
62+
- `#11706 <https://github.com/pytest-dev/pytest/issues/11706>`_: Fix reporting of teardown errors in higher-scoped fixtures when using `--maxfail` or `--stepwise`.
63+
64+
65+
- `#11758 <https://github.com/pytest-dev/pytest/issues/11758>`_: Fixed ``IndexError: string index out of range`` crash in ``if highlighted[-1] == "\n" and source[-1] != "\n"``.
66+
This bug was introduced in pytest 8.0.0rc1.
67+
68+
69+
- `#9765 <https://github.com/pytest-dev/pytest/issues/9765>`_, `#11816 <https://github.com/pytest-dev/pytest/issues/11816>`_: Fixed a frustrating bug that afflicted some users with the only error being ``assert mod not in mods``. The issue was caused by the fact that ``str(Path(mod))`` and ``mod.__file__`` don't necessarily produce the same string, and was being erroneously used interchangably in some places in the code.
70+
71+
This fix also broke the internal API of ``PytestPluginManager.consider_conftest`` by introducing a new parameter -- we mention this in case it is being used by external code, even if marked as *private*.
72+
73+
3174
pytest 8.0.0rc1 (2023-12-30)
3275
============================
3376

doc/en/deprecations.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,13 @@ Will also need to be ported to a supported pytest style. One way to do it is usi
387387
.. _`with-setup-nose`: https://nose.readthedocs.io/en/latest/testing_tools.html?highlight=with_setup#nose.tools.with_setup
388388

389389

390+
The ``compat_co_firstlineno`` attribute
391+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
392+
393+
Nose inspects this attribute on function objects to allow overriding the function's inferred line number.
394+
Pytest no longer respects this attribute.
395+
396+
390397

391398
Passing ``msg=`` to ``pytest.skip``, ``pytest.fail`` or ``pytest.exit``
392399
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

doc/en/example/parametrize.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ objects, they are still using the default pytest representation:
162162
rootdir: /home/sweet/project
163163
collected 8 items
164164
165-
<Dir parametrize.rst-189>
165+
<Dir parametrize.rst-193>
166166
<Module test_time.py>
167167
<Function test_timedistance_v0[a0-b0-expected0]>
168168
<Function test_timedistance_v0[a1-b1-expected1]>
@@ -239,7 +239,7 @@ If you just collect tests you'll also nicely see 'advanced' and 'basic' as varia
239239
rootdir: /home/sweet/project
240240
collected 4 items
241241
242-
<Dir parametrize.rst-189>
242+
<Dir parametrize.rst-193>
243243
<Module test_scenarios.py>
244244
<Class TestSampleWithScenarios>
245245
<Function test_demo1[basic]>
@@ -318,7 +318,7 @@ Let's first see how it looks like at collection time:
318318
rootdir: /home/sweet/project
319319
collected 2 items
320320
321-
<Dir parametrize.rst-189>
321+
<Dir parametrize.rst-193>
322322
<Module test_backends.py>
323323
<Function test_db_initialized[d1]>
324324
<Function test_db_initialized[d2]>
@@ -503,10 +503,10 @@ Running it results in some skips if we don't have all the python interpreters in
503503
.. code-block:: pytest
504504
505505
. $ pytest -rs -q multipython.py
506-
ssssssssssss...ssssssssssss [100%]
506+
ssssssssssssssssssssssss... [100%]
507507
========================= short test summary info ==========================
508508
SKIPPED [12] multipython.py:68: 'python3.9' not found
509-
SKIPPED [12] multipython.py:68: 'python3.11' not found
509+
SKIPPED [12] multipython.py:68: 'python3.10' not found
510510
3 passed, 24 skipped in 0.12s
511511
512512
Parametrization of optional implementations/imports

doc/en/example/pythoncollection.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ The test collection would look like this:
152152
configfile: pytest.ini
153153
collected 2 items
154154
155-
<Dir pythoncollection.rst-190>
155+
<Dir pythoncollection.rst-194>
156156
<Module check_myapp.py>
157157
<Class CheckMyApp>
158158
<Function simple_check>
@@ -215,7 +215,7 @@ You can always peek at the collection tree without running tests like this:
215215
configfile: pytest.ini
216216
collected 3 items
217217
218-
<Dir pythoncollection.rst-190>
218+
<Dir pythoncollection.rst-194>
219219
<Dir CWD>
220220
<Module pythoncollection.py>
221221
<Function test_function>

doc/en/example/simple.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,31 @@ If we run this:
660660
E assert 0
661661
662662
test_step.py:11: AssertionError
663+
================================ XFAILURES =================================
664+
______________________ TestUserHandling.test_deletion ______________________
665+
666+
item = <Function test_deletion>
667+
668+
def pytest_runtest_setup(item):
669+
if "incremental" in item.keywords:
670+
# retrieve the class name of the test
671+
cls_name = str(item.cls)
672+
# check if a previous test has failed for this class
673+
if cls_name in _test_failed_incremental:
674+
# retrieve the index of the test (if parametrize is used in combination with incremental)
675+
parametrize_index = (
676+
tuple(item.callspec.indices.values())
677+
if hasattr(item, "callspec")
678+
else ()
679+
)
680+
# retrieve the name of the first test function to fail for this class name and index
681+
test_name = _test_failed_incremental[cls_name].get(parametrize_index, None)
682+
# if name found, test has failed for the combination of class name & test name
683+
if test_name is not None:
684+
> pytest.xfail(f"previous test failed ({test_name})")
685+
E _pytest.outcomes.XFailed: previous test failed (test_modification)
686+
687+
conftest.py:47: XFailed
663688
========================= short test summary info ==========================
664689
XFAIL test_step.py::TestUserHandling::test_deletion - reason: previous test failed (test_modification)
665690
================== 1 failed, 2 passed, 1 xfailed in 0.12s ==================

doc/en/getting-started.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Install ``pytest``
2222
.. code-block:: bash
2323
2424
$ pytest --version
25-
pytest 8.0.0rc1
25+
pytest 8.0.0
2626
2727
.. _`simpletest`:
2828

doc/en/how-to/fixtures.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ Fixtures are created when first requested by a test, and are destroyed based on
494494
* ``function``: the default scope, the fixture is destroyed at the end of the test.
495495
* ``class``: the fixture is destroyed during teardown of the last test in the class.
496496
* ``module``: the fixture is destroyed during teardown of the last test in the module.
497-
* ``package``: the fixture is destroyed during teardown of the last test in the package.
497+
* ``package``: the fixture is destroyed during teardown of the last test in the package where the fixture is defined, including sub-packages and sub-directories within it.
498498
* ``session``: the fixture is destroyed at the end of the test session.
499499

500500
.. note::
@@ -1418,7 +1418,7 @@ Running the above tests results in the following test IDs being used:
14181418
rootdir: /home/sweet/project
14191419
collected 12 items
14201420
1421-
<Dir fixtures.rst-208>
1421+
<Dir fixtures.rst-212>
14221422
<Module test_anothersmtp.py>
14231423
<Function test_showhelo[smtp.gmail.com]>
14241424
<Function test_showhelo[mail.python.org]>

doc/en/how-to/output.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,19 @@ Example:
404404
E assert 0
405405
406406
test_example.py:14: AssertionError
407+
================================ XFAILURES =================================
408+
________________________________ test_xfail ________________________________
409+
410+
def test_xfail():
411+
> pytest.xfail("xfailing this test")
412+
E _pytest.outcomes.XFailed: xfailing this test
413+
414+
test_example.py:26: XFailed
415+
================================= XPASSES ==================================
407416
========================= short test summary info ==========================
408417
SKIPPED [1] test_example.py:22: skipping this test
409418
XFAIL test_example.py::test_xfail - reason: xfailing this test
410-
XPASS test_example.py::test_xpass always xfail
419+
XPASS test_example.py::test_xpass - always xfail
411420
ERROR test_example.py::test_error - assert 0
412421
FAILED test_example.py::test_fail - assert 0
413422
== 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12s ===

0 commit comments

Comments
 (0)