Merge branch 'main' into teardown_fixture_order
This commit is contained in:
commit
fa9607e2a3
|
@ -72,6 +72,12 @@ jobs:
|
|||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Download Package
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: Packages
|
||||
path: dist
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
|
|
1
AUTHORS
1
AUTHORS
|
@ -141,6 +141,7 @@ Evgeny Seliverstov
|
|||
Fabian Sturm
|
||||
Fabien Zarifian
|
||||
Fabio Zadrozny
|
||||
faph
|
||||
Felix Hofstätter
|
||||
Felix Nieuwenhuizen
|
||||
Feng Ma
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
Improvements to how ``-r`` for xfailures and xpasses:
|
||||
|
||||
* Report tracebacks for xfailures when ``-rx`` is set.
|
||||
* Report captured output for xpasses when ``-rX`` is set.
|
||||
* For xpasses, add ``-`` in summary between test name and reason, to match how xfail is displayed.
|
|
@ -1 +0,0 @@
|
|||
Fix reporting of teardown errors in higher-scoped fixtures when using `--maxfail` or `--stepwise`.
|
|
@ -1,2 +0,0 @@
|
|||
Fixed ``IndexError: string index out of range`` crash in ``if highlighted[-1] == "\n" and source[-1] != "\n"``.
|
||||
This bug was introduced in pytest 8.0.0rc1.
|
|
@ -0,0 +1 @@
|
|||
Documented the retention of temporary directories created using the ``tmp_path`` fixture in more detail.
|
|
@ -1 +0,0 @@
|
|||
The :hook:`pytest_plugin_registered` hook has a new ``plugin_name`` parameter containing the name by which ``plugin`` is registered.
|
|
@ -1,3 +0,0 @@
|
|||
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.
|
||||
|
||||
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*.
|
|
@ -6,6 +6,7 @@ Release announcements
|
|||
:maxdepth: 2
|
||||
|
||||
|
||||
release-8.0.0rc2
|
||||
release-8.0.0rc1
|
||||
release-7.4.4
|
||||
release-7.4.3
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
pytest-8.0.0rc2
|
||||
=======================================
|
||||
|
||||
The pytest team is proud to announce the 8.0.0rc2 prerelease!
|
||||
|
||||
This is a prerelease, not intended for production use, but to test the upcoming features and improvements
|
||||
in order to catch any major problems before the final version is released to the major public.
|
||||
|
||||
We appreciate your help testing this out before the final release, making sure to report any
|
||||
regressions to our issue tracker:
|
||||
|
||||
https://github.com/pytest-dev/pytest/issues
|
||||
|
||||
When doing so, please include the string ``[prerelease]`` in the title.
|
||||
|
||||
You can upgrade from PyPI via:
|
||||
|
||||
pip install pytest==8.0.0rc2
|
||||
|
||||
Users are encouraged to take a look at the CHANGELOG carefully:
|
||||
|
||||
https://docs.pytest.org/en/release-8.0.0rc2/changelog.html
|
||||
|
||||
Thanks to all the contributors to this release:
|
||||
|
||||
* Ben Brown
|
||||
* Bruno Oliveira
|
||||
* Ran Benita
|
||||
|
||||
|
||||
Happy testing,
|
||||
The pytest Development Team
|
|
@ -28,6 +28,37 @@ with advance notice in the **Deprecations** section of releases.
|
|||
|
||||
.. towncrier release notes start
|
||||
|
||||
pytest 8.0.0rc2 (2024-01-17)
|
||||
============================
|
||||
|
||||
|
||||
Improvements
|
||||
------------
|
||||
|
||||
- `#11233 <https://github.com/pytest-dev/pytest/issues/11233>`_: Improvements to ``-r`` for xfailures and xpasses:
|
||||
|
||||
* Report tracebacks for xfailures when ``-rx`` is set.
|
||||
* Report captured output for xpasses when ``-rX`` is set.
|
||||
* For xpasses, add ``-`` in summary between test name and reason, to match how xfail is displayed.
|
||||
|
||||
- `#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.
|
||||
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#11706 <https://github.com/pytest-dev/pytest/issues/11706>`_: Fix reporting of teardown errors in higher-scoped fixtures when using `--maxfail` or `--stepwise`.
|
||||
|
||||
|
||||
- `#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"``.
|
||||
This bug was introduced in pytest 8.0.0rc1.
|
||||
|
||||
|
||||
- `#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.
|
||||
|
||||
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*.
|
||||
|
||||
|
||||
pytest 8.0.0rc1 (2023-12-30)
|
||||
============================
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ objects, they are still using the default pytest representation:
|
|||
rootdir: /home/sweet/project
|
||||
collected 8 items
|
||||
|
||||
<Dir parametrize.rst-189>
|
||||
<Dir parametrize.rst-192>
|
||||
<Module test_time.py>
|
||||
<Function test_timedistance_v0[a0-b0-expected0]>
|
||||
<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
|
|||
rootdir: /home/sweet/project
|
||||
collected 4 items
|
||||
|
||||
<Dir parametrize.rst-189>
|
||||
<Dir parametrize.rst-192>
|
||||
<Module test_scenarios.py>
|
||||
<Class TestSampleWithScenarios>
|
||||
<Function test_demo1[basic]>
|
||||
|
@ -318,7 +318,7 @@ Let's first see how it looks like at collection time:
|
|||
rootdir: /home/sweet/project
|
||||
collected 2 items
|
||||
|
||||
<Dir parametrize.rst-189>
|
||||
<Dir parametrize.rst-192>
|
||||
<Module test_backends.py>
|
||||
<Function test_db_initialized[d1]>
|
||||
<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
|
|||
.. code-block:: pytest
|
||||
|
||||
. $ pytest -rs -q multipython.py
|
||||
ssssssssssss...ssssssssssss [100%]
|
||||
ssssssssssssssssssssssss... [100%]
|
||||
========================= short test summary info ==========================
|
||||
SKIPPED [12] multipython.py:68: 'python3.9' not found
|
||||
SKIPPED [12] multipython.py:68: 'python3.11' not found
|
||||
SKIPPED [12] multipython.py:68: 'python3.10' not found
|
||||
3 passed, 24 skipped in 0.12s
|
||||
|
||||
Parametrization of optional implementations/imports
|
||||
|
|
|
@ -152,7 +152,7 @@ The test collection would look like this:
|
|||
configfile: pytest.ini
|
||||
collected 2 items
|
||||
|
||||
<Dir pythoncollection.rst-190>
|
||||
<Dir pythoncollection.rst-193>
|
||||
<Module check_myapp.py>
|
||||
<Class CheckMyApp>
|
||||
<Function simple_check>
|
||||
|
@ -215,7 +215,7 @@ You can always peek at the collection tree without running tests like this:
|
|||
configfile: pytest.ini
|
||||
collected 3 items
|
||||
|
||||
<Dir pythoncollection.rst-190>
|
||||
<Dir pythoncollection.rst-193>
|
||||
<Dir CWD>
|
||||
<Module pythoncollection.py>
|
||||
<Function test_function>
|
||||
|
|
|
@ -660,6 +660,31 @@ If we run this:
|
|||
E assert 0
|
||||
|
||||
test_step.py:11: AssertionError
|
||||
================================ XFAILURES =================================
|
||||
______________________ TestUserHandling.test_deletion ______________________
|
||||
|
||||
item = <Function test_deletion>
|
||||
|
||||
def pytest_runtest_setup(item):
|
||||
if "incremental" in item.keywords:
|
||||
# retrieve the class name of the test
|
||||
cls_name = str(item.cls)
|
||||
# check if a previous test has failed for this class
|
||||
if cls_name in _test_failed_incremental:
|
||||
# retrieve the index of the test (if parametrize is used in combination with incremental)
|
||||
parametrize_index = (
|
||||
tuple(item.callspec.indices.values())
|
||||
if hasattr(item, "callspec")
|
||||
else ()
|
||||
)
|
||||
# retrieve the name of the first test function to fail for this class name and index
|
||||
test_name = _test_failed_incremental[cls_name].get(parametrize_index, None)
|
||||
# if name found, test has failed for the combination of class name & test name
|
||||
if test_name is not None:
|
||||
> pytest.xfail(f"previous test failed ({test_name})")
|
||||
E _pytest.outcomes.XFailed: previous test failed (test_modification)
|
||||
|
||||
conftest.py:47: XFailed
|
||||
========================= short test summary info ==========================
|
||||
XFAIL test_step.py::TestUserHandling::test_deletion - reason: previous test failed (test_modification)
|
||||
================== 1 failed, 2 passed, 1 xfailed in 0.12s ==================
|
||||
|
|
|
@ -22,7 +22,7 @@ Install ``pytest``
|
|||
.. code-block:: bash
|
||||
|
||||
$ pytest --version
|
||||
pytest 8.0.0rc1
|
||||
pytest 8.0.0rc2
|
||||
|
||||
.. _`simpletest`:
|
||||
|
||||
|
|
|
@ -1418,7 +1418,7 @@ Running the above tests results in the following test IDs being used:
|
|||
rootdir: /home/sweet/project
|
||||
collected 12 items
|
||||
|
||||
<Dir fixtures.rst-208>
|
||||
<Dir fixtures.rst-211>
|
||||
<Module test_anothersmtp.py>
|
||||
<Function test_showhelo[smtp.gmail.com]>
|
||||
<Function test_showhelo[mail.python.org]>
|
||||
|
|
|
@ -404,10 +404,19 @@ Example:
|
|||
E assert 0
|
||||
|
||||
test_example.py:14: AssertionError
|
||||
================================ XFAILURES =================================
|
||||
________________________________ test_xfail ________________________________
|
||||
|
||||
def test_xfail():
|
||||
> pytest.xfail("xfailing this test")
|
||||
E _pytest.outcomes.XFailed: xfailing this test
|
||||
|
||||
test_example.py:26: XFailed
|
||||
================================= XPASSES ==================================
|
||||
========================= short test summary info ==========================
|
||||
SKIPPED [1] test_example.py:22: skipping this test
|
||||
XFAIL test_example.py::test_xfail - reason: xfailing this test
|
||||
XPASS test_example.py::test_xpass always xfail
|
||||
XPASS test_example.py::test_xpass - always xfail
|
||||
ERROR test_example.py::test_error - assert 0
|
||||
FAILED test_example.py::test_fail - assert 0
|
||||
== 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12s ===
|
||||
|
|
|
@ -8,9 +8,8 @@ How to use temporary directories and files in tests
|
|||
The ``tmp_path`` fixture
|
||||
------------------------
|
||||
|
||||
You can use the ``tmp_path`` fixture which will
|
||||
provide a temporary directory unique to the current test,
|
||||
created in the `base temporary directory`_.
|
||||
You can use the ``tmp_path`` fixture which will provide a temporary directory
|
||||
unique to each test function.
|
||||
|
||||
``tmp_path`` is a :class:`pathlib.Path` object. Here is an example test usage:
|
||||
|
||||
|
@ -62,6 +61,11 @@ Running this would result in a passed test except for the last
|
|||
FAILED test_tmp_path.py::test_create_file - assert 0
|
||||
============================ 1 failed in 0.12s =============================
|
||||
|
||||
By default, ``pytest`` retains the temporary directory for the last 3 ``pytest``
|
||||
invocations. Concurrent invocations of the same test function are supported by
|
||||
configuring the base temporary directory to be unique for each concurrent
|
||||
run. See `temporary directory location and retention`_ for details.
|
||||
|
||||
.. _`tmp_path_factory example`:
|
||||
|
||||
The ``tmp_path_factory`` fixture
|
||||
|
@ -100,7 +104,7 @@ See :ref:`tmp_path_factory API <tmp_path_factory factory api>` for details.
|
|||
.. _tmpdir:
|
||||
|
||||
The ``tmpdir`` and ``tmpdir_factory`` fixtures
|
||||
---------------------------------------------------
|
||||
----------------------------------------------
|
||||
|
||||
The ``tmpdir`` and ``tmpdir_factory`` fixtures are similar to ``tmp_path``
|
||||
and ``tmp_path_factory``, but use/return legacy `py.path.local`_ objects
|
||||
|
@ -124,10 +128,10 @@ See :fixture:`tmpdir <tmpdir>` :fixture:`tmpdir_factory <tmpdir_factory>`
|
|||
API for details.
|
||||
|
||||
|
||||
.. _`base temporary directory`:
|
||||
.. _`temporary directory location and retention`:
|
||||
|
||||
The default base temporary directory
|
||||
-----------------------------------------------
|
||||
Temporary directory location and retention
|
||||
------------------------------------------
|
||||
|
||||
Temporary directories are by default created as sub-directories of
|
||||
the system temporary directory. The base name will be ``pytest-NUM`` where
|
||||
|
@ -152,7 +156,7 @@ You can override the default temporary directory setting like this:
|
|||
for that purpose only.
|
||||
|
||||
When distributing tests on the local machine using ``pytest-xdist``, care is taken to
|
||||
automatically configure a basetemp directory for the sub processes such that all temporary
|
||||
data lands below a single per-test run basetemp directory.
|
||||
automatically configure a `basetemp` directory for the sub processes such that all temporary
|
||||
data lands below a single per-test run temporary directory.
|
||||
|
||||
.. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html
|
||||
|
|
|
@ -326,8 +326,8 @@ class LegacyTmpdirPlugin:
|
|||
|
||||
By default, a new base temporary directory is created each test session,
|
||||
and old bases are removed after 3 sessions, to aid in debugging. If
|
||||
``--basetemp`` is used then it is cleared each session. See :ref:`base
|
||||
temporary directory`.
|
||||
``--basetemp`` is used then it is cleared each session. See
|
||||
:ref:`temporary directory location and retention`.
|
||||
|
||||
The returned object is a `legacy_path`_ object.
|
||||
|
||||
|
|
|
@ -262,8 +262,8 @@ def tmp_path(
|
|||
and old bases are removed after 3 sessions, to aid in debugging.
|
||||
This behavior can be configured with :confval:`tmp_path_retention_count` and
|
||||
:confval:`tmp_path_retention_policy`.
|
||||
If ``--basetemp`` is used then it is cleared each session. See :ref:`base
|
||||
temporary directory`.
|
||||
If ``--basetemp`` is used then it is cleared each session. See
|
||||
:ref:`temporary directory location and retention`.
|
||||
|
||||
The returned object is a :class:`pathlib.Path` object.
|
||||
"""
|
||||
|
|
|
@ -13,9 +13,6 @@ from typing import Sequence
|
|||
from typing import Tuple
|
||||
from typing import Union
|
||||
|
||||
import hypothesis
|
||||
from hypothesis import strategies
|
||||
|
||||
import pytest
|
||||
from _pytest import fixtures
|
||||
from _pytest import python
|
||||
|
@ -27,6 +24,9 @@ from _pytest.python import Function
|
|||
from _pytest.python import IdMaker
|
||||
from _pytest.scope import Scope
|
||||
|
||||
# import hypothesis
|
||||
# from hypothesis import strategies
|
||||
|
||||
|
||||
class TestMetafunc:
|
||||
def Metafunc(self, func, config=None) -> python.Metafunc:
|
||||
|
@ -292,14 +292,15 @@ class TestMetafunc:
|
|||
assert metafunc._calls[2].id == "x1-a"
|
||||
assert metafunc._calls[3].id == "x1-b"
|
||||
|
||||
@hypothesis.given(strategies.text() | strategies.binary())
|
||||
@hypothesis.settings(
|
||||
deadline=400.0
|
||||
) # very close to std deadline and CI boxes are not reliable in CPU power
|
||||
def test_idval_hypothesis(self, value) -> None:
|
||||
escaped = IdMaker([], [], None, None, None, None, None)._idval(value, "a", 6)
|
||||
assert isinstance(escaped, str)
|
||||
escaped.encode("ascii")
|
||||
# TODO: Uncomment - https://github.com/HypothesisWorks/hypothesis/pull/3849
|
||||
# @hypothesis.given(strategies.text() | strategies.binary())
|
||||
# @hypothesis.settings(
|
||||
# deadline=400.0
|
||||
# ) # very close to std deadline and CI boxes are not reliable in CPU power
|
||||
# def test_idval_hypothesis(self, value) -> None:
|
||||
# escaped = IdMaker([], [], None, None, None, None, None)._idval(value, "a", 6)
|
||||
# assert isinstance(escaped, str)
|
||||
# escaped.encode("ascii")
|
||||
|
||||
def test_unicode_idval(self) -> None:
|
||||
"""Test that Unicode strings outside the ASCII character set get
|
||||
|
|
Loading…
Reference in New Issue