From 807c01451867cb107900a5a9ce0d07f261770d99 Mon Sep 17 00:00:00 2001 From: polkapolka <7219835+polkapolka@users.noreply.github.com> Date: Mon, 20 May 2024 22:14:51 +0000 Subject: [PATCH 001/445] changed warning raised by async def to error --- src/_pytest/config/exceptions.py | 4 ---- src/_pytest/python.py | 16 ++++++++++++++-- src/_pytest/warning_types.py | 2 +- testing/acceptance_test.py | 31 +++++++++++-------------------- testing/test_unittest.py | 2 +- 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/_pytest/config/exceptions.py b/src/_pytest/config/exceptions.py index 4031ea732f3..95c412734be 100644 --- a/src/_pytest/config/exceptions.py +++ b/src/_pytest/config/exceptions.py @@ -1,7 +1,3 @@ -from typing import final - - -@final class UsageError(Exception): """Error in pytest usage or invocation.""" diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 4887614de3b..bf20ca31d13 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -54,6 +54,7 @@ from _pytest.config import Config from _pytest.config import hookimpl from _pytest.config.argparsing import Parser +from _pytest.config.exceptions import UsageError from _pytest.deprecated import check_ispytest from _pytest.fixtures import FixtureDef from _pytest.fixtures import FixtureRequest @@ -77,7 +78,6 @@ from _pytest.stash import StashKey from _pytest.warning_types import PytestCollectionWarning from _pytest.warning_types import PytestReturnNotNoneWarning -from _pytest.warning_types import PytestUnhandledCoroutineWarning if TYPE_CHECKING: @@ -138,6 +138,16 @@ def pytest_configure(config: Config) -> None: ) +@final +class PytestUnhandledCoroutineError(UsageError): + """An unraisable exception resulted in an error. + + Unraisable exceptions are exceptions raised in :meth:`__del__ ` + implementations and similar situations when the exception cannot be raised + as normal. + """ + + def async_warn_and_skip(nodeid: str) -> None: msg = "async def functions are not natively supported and have been skipped.\n" msg += ( @@ -148,7 +158,9 @@ def async_warn_and_skip(nodeid: str) -> None: msg += " - pytest-tornasync\n" msg += " - pytest-trio\n" msg += " - pytest-twisted" - warnings.warn(PytestUnhandledCoroutineWarning(msg.format(nodeid))) + raise PytestUnhandledCoroutineError( + msg.format(nodeid) + ) # TODO: This is the warning to look at skip(reason="async def function and no async plugin installed (see warnings)") diff --git a/src/_pytest/warning_types.py b/src/_pytest/warning_types.py index a5884f29582..d2e542651fe 100644 --- a/src/_pytest/warning_types.py +++ b/src/_pytest/warning_types.py @@ -77,7 +77,7 @@ def simple(cls, apiname: str) -> "PytestExperimentalApiWarning": @final -class PytestUnhandledCoroutineWarning(PytestReturnNotNoneWarning): +class PytestUnhandledCoroutineWarning(PytestReturnNotNoneWarning): # TODO: look at this """Warning emitted for an unhandled coroutine. A coroutine was encountered when collecting test functions, but was not diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index ac7fab3d27a..12c8a50dd98 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1233,7 +1233,7 @@ def test_usage_error_code(pytester: Pytester) -> None: assert result.ret == ExitCode.USAGE_ERROR -def test_warn_on_async_function(pytester: Pytester) -> None: +def test_error_on_async_function(pytester: Pytester) -> None: # TODO: Change this # In the below we .close() the coroutine only to avoid # "RuntimeWarning: coroutine 'test_2' was never awaited" # which messes with other tests. @@ -1249,23 +1249,19 @@ def test_3(): return coro """ ) - result = pytester.runpytest("-Wdefault") + result = pytester.runpytest() result.stdout.fnmatch_lines( [ - "test_async.py::test_1", - "test_async.py::test_2", - "test_async.py::test_3", + "*test_async.py::test_1*", + "*test_async.py::test_2*", + "*test_async.py::test_3*", "*async def functions are not natively supported*", - "*3 skipped, 3 warnings in*", ] ) - # ensure our warning message appears only once - assert ( - result.stdout.str().count("async def functions are not natively supported") == 1 - ) + result.assert_outcomes(failed=3) -def test_warn_on_async_gen_function(pytester: Pytester) -> None: +def test_error_on_async_gen_function(pytester: Pytester) -> None: # TODO: Change this pytester.makepyfile( test_async=""" async def test_1(): @@ -1276,20 +1272,15 @@ def test_3(): return test_2() """ ) - result = pytester.runpytest("-Wdefault") + result = pytester.runpytest() result.stdout.fnmatch_lines( [ - "test_async.py::test_1", - "test_async.py::test_2", - "test_async.py::test_3", + "*test_async.py::test_1*", + "*test_async.py::test_2*", + "*test_async.py::test_3*", "*async def functions are not natively supported*", - "*3 skipped, 3 warnings in*", ] ) - # ensure our warning message appears only once - assert ( - result.stdout.str().count("async def functions are not natively supported") == 1 - ) def test_pdb_can_be_rewritten(pytester: Pytester) -> None: diff --git a/testing/test_unittest.py b/testing/test_unittest.py index 003a74d3849..e2a2904a3ba 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -1309,7 +1309,7 @@ def test_1(self): assert tracked == [] -def test_async_support(pytester: Pytester) -> None: +def test_async_support(pytester: Pytester) -> None: # TODO: Change this pytest.importorskip("unittest.async_case") pytester.copy_example("unittest/test_unittest_asyncio.py") From 04bac8deaf1abd49e198cfd5cb66d8001b1de1ea Mon Sep 17 00:00:00 2001 From: pytest bot Date: Sat, 20 Jul 2024 15:20:56 +0000 Subject: [PATCH 002/445] Cherry-pick 8.3.0, 8.3.1 release notes --- changelog/11706.bugfix.rst | 4 - changelog/11771.contrib.rst | 5 - changelog/11797.bugfix.rst | 1 - changelog/12153.doc.rst | 1 - changelog/12204.bugfix.rst | 11 -- changelog/12231.feature.rst | 11 -- changelog/12264.bugfix.rst | 1 - changelog/12275.bugfix.rst | 1 - changelog/12281.feature.rst | 8 - changelog/12328.bugfix.rst | 1 - changelog/12424.bugfix.rst | 1 - changelog/12467.improvement.rst | 3 - changelog/12469.doc.rst | 6 - changelog/12469.improvement.rst | 4 - changelog/12472.bugfix.rst | 1 - changelog/12493.contrib.rst | 13 -- changelog/12498.contrib.rst | 5 - changelog/12501.contrib.rst | 11 -- changelog/12502.contrib.rst | 7 - changelog/12505.bugfix.rst | 1 - changelog/12522.contrib.rst | 4 - changelog/12531.contrib.rst | 6 - changelog/12533.contrib.rst | 7 - changelog/12544.improvement.rst | 3 - changelog/12545.improvement.rst | 1 - changelog/12557.contrib.rst | 1 - changelog/12562.contrib.rst | 2 - changelog/12567.feature.rst | 7 - changelog/12577.doc.rst | 3 - changelog/12580.bugfix.rst | 1 - changelog/2871.improvement.rst | 1 - changelog/389.improvement.rst | 38 ---- changelog/6962.bugfix.rst | 2 - changelog/7166.bugfix.rst | 1 - changelog/7662.improvement.rst | 1 - doc/en/announce/index.rst | 2 + doc/en/announce/release-8.3.0.rst | 60 +++++++ doc/en/announce/release-8.3.1.rst | 19 ++ doc/en/builtin.rst | 34 ++-- doc/en/changelog.rst | 263 ++++++++++++++++++++++++++++ doc/en/example/parametrize.rst | 10 +- doc/en/example/pythoncollection.rst | 4 +- doc/en/example/reportingdemo.rst | 96 +++++----- doc/en/example/simple.rst | 25 --- doc/en/getting-started.rst | 2 +- doc/en/how-to/fixtures.rst | 2 +- doc/en/how-to/output.rst | 8 - doc/en/reference/reference.rst | 199 ++++++++++----------- 48 files changed, 521 insertions(+), 377 deletions(-) delete mode 100644 changelog/11706.bugfix.rst delete mode 100644 changelog/11771.contrib.rst delete mode 100644 changelog/11797.bugfix.rst delete mode 100644 changelog/12153.doc.rst delete mode 100644 changelog/12204.bugfix.rst delete mode 100644 changelog/12231.feature.rst delete mode 120000 changelog/12264.bugfix.rst delete mode 100644 changelog/12275.bugfix.rst delete mode 100644 changelog/12281.feature.rst delete mode 100644 changelog/12328.bugfix.rst delete mode 100644 changelog/12424.bugfix.rst delete mode 100644 changelog/12467.improvement.rst delete mode 100644 changelog/12469.doc.rst delete mode 100644 changelog/12469.improvement.rst delete mode 100644 changelog/12472.bugfix.rst delete mode 100644 changelog/12493.contrib.rst delete mode 100644 changelog/12498.contrib.rst delete mode 100644 changelog/12501.contrib.rst delete mode 100644 changelog/12502.contrib.rst delete mode 100644 changelog/12505.bugfix.rst delete mode 100644 changelog/12522.contrib.rst delete mode 100644 changelog/12531.contrib.rst delete mode 100644 changelog/12533.contrib.rst delete mode 100644 changelog/12544.improvement.rst delete mode 120000 changelog/12545.improvement.rst delete mode 120000 changelog/12557.contrib.rst delete mode 100644 changelog/12562.contrib.rst delete mode 100644 changelog/12567.feature.rst delete mode 100644 changelog/12577.doc.rst delete mode 100644 changelog/12580.bugfix.rst delete mode 100644 changelog/2871.improvement.rst delete mode 100644 changelog/389.improvement.rst delete mode 100644 changelog/6962.bugfix.rst delete mode 100644 changelog/7166.bugfix.rst delete mode 100644 changelog/7662.improvement.rst create mode 100644 doc/en/announce/release-8.3.0.rst create mode 100644 doc/en/announce/release-8.3.1.rst diff --git a/changelog/11706.bugfix.rst b/changelog/11706.bugfix.rst deleted file mode 100644 index a86db5ef66a..00000000000 --- a/changelog/11706.bugfix.rst +++ /dev/null @@ -1,4 +0,0 @@ -Fix reporting of teardown errors in higher-scoped fixtures when using `--maxfail` or `--stepwise`. - -Originally added in pytest 8.0.0, but reverted in 8.0.2 due to a regression in pytest-xdist. -This regression was fixed in pytest-xdist 3.6.1. diff --git a/changelog/11771.contrib.rst b/changelog/11771.contrib.rst deleted file mode 100644 index a3c1ed1099e..00000000000 --- a/changelog/11771.contrib.rst +++ /dev/null @@ -1,5 +0,0 @@ -The PyPy runtime version has been updated to 3.9 from 3.8 that introduced -a flaky bug at the garbage collector which was not expected to fix there -as the V3.8 is EoL. - --- by :user:`x612skm` diff --git a/changelog/11797.bugfix.rst b/changelog/11797.bugfix.rst deleted file mode 100644 index 94b72da00fd..00000000000 --- a/changelog/11797.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -:func:`pytest.approx` now correctly handles :class:`Sequence `-like objects. diff --git a/changelog/12153.doc.rst b/changelog/12153.doc.rst deleted file mode 100644 index ac36becf9a7..00000000000 --- a/changelog/12153.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Documented using :envvar:`PYTEST_VERSION` to detect if code is running from within a pytest run. diff --git a/changelog/12204.bugfix.rst b/changelog/12204.bugfix.rst deleted file mode 100644 index 099ad70610a..00000000000 --- a/changelog/12204.bugfix.rst +++ /dev/null @@ -1,11 +0,0 @@ -Fixed a regression in pytest 8.0 where tracebacks get longer and longer when multiple -tests fail due to a shared higher-scope fixture which raised -- by :user:`bluetech`. - -Also fixed a similar regression in pytest 5.4 for collectors which raise during setup. - -The fix necessitated internal changes which may affect some plugins: - -* ``FixtureDef.cached_result[2]`` is now a tuple ``(exc, tb)`` - instead of ``exc``. -* ``SetupState.stack`` failures are now a tuple ``(exc, tb)`` - instead of ``exc``. diff --git a/changelog/12231.feature.rst b/changelog/12231.feature.rst deleted file mode 100644 index dad04bc20c1..00000000000 --- a/changelog/12231.feature.rst +++ /dev/null @@ -1,11 +0,0 @@ -Added `--xfail-tb` flag, which turns on traceback output for XFAIL results. - -* If the `--xfail-tb` flag is not sent, tracebacks for XFAIL results are NOT shown. -* The style of traceback for XFAIL is set with `--tb`, and can be `auto|long|short|line|native|no`. -* Note: Even if you have `--xfail-tb` set, you won't see them if `--tb=no`. - -Some history: - -With pytest 8.0, `-rx` or `-ra` would not only turn on summary reports for xfail, but also report the tracebacks for xfail results. This caused issues with some projects that utilize xfail, but don't want to see all of the xfail tracebacks. - -This change detaches xfail tracebacks from `-rx`, and now we turn on xfail tracebacks with `--xfail-tb`. With this, the default `-rx`/ `-ra` behavior is identical to pre-8.0 with respect to xfail tracebacks. While this is a behavior change, it brings default behavior back to pre-8.0.0 behavior, which ultimately was considered the better course of action. diff --git a/changelog/12264.bugfix.rst b/changelog/12264.bugfix.rst deleted file mode 120000 index e5704e6e819..00000000000 --- a/changelog/12264.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -12204.bugfix.rst \ No newline at end of file diff --git a/changelog/12275.bugfix.rst b/changelog/12275.bugfix.rst deleted file mode 100644 index 2d040a3a063..00000000000 --- a/changelog/12275.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix collection error upon encountering an :mod:`abstract ` class, including abstract `unittest.TestCase` subclasses. diff --git a/changelog/12281.feature.rst b/changelog/12281.feature.rst deleted file mode 100644 index c6e8e3b3098..00000000000 --- a/changelog/12281.feature.rst +++ /dev/null @@ -1,8 +0,0 @@ -Added support for keyword matching in marker expressions. - -Now tests can be selected by marker keyword arguments. -Supported values are :class:`int`, (unescaped) :class:`str`, :class:`bool` & :data:`None`. - -See :ref:`marker examples ` for more information. - --- by :user:`lovetheguitar` diff --git a/changelog/12328.bugfix.rst b/changelog/12328.bugfix.rst deleted file mode 100644 index f334425850b..00000000000 --- a/changelog/12328.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix a regression in pytest 8.0.0 where package-scoped parameterized items were not correctly reordered to minimize setups/teardowns in some cases. diff --git a/changelog/12424.bugfix.rst b/changelog/12424.bugfix.rst deleted file mode 100644 index 7ad1126858b..00000000000 --- a/changelog/12424.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix crash with `assert testcase is not None` assertion failure when re-running unittest tests using plugins like pytest-rerunfailures. Regressed in 8.2.2. diff --git a/changelog/12467.improvement.rst b/changelog/12467.improvement.rst deleted file mode 100644 index b1e0581ed16..00000000000 --- a/changelog/12467.improvement.rst +++ /dev/null @@ -1,3 +0,0 @@ -Migrated all internal type-annotations to the python3.10+ style by using the `annotations` future import. - --- by :user:`RonnyPfannschmidt` diff --git a/changelog/12469.doc.rst b/changelog/12469.doc.rst deleted file mode 100644 index 2340315353c..00000000000 --- a/changelog/12469.doc.rst +++ /dev/null @@ -1,6 +0,0 @@ -The external plugin mentions in the documentation now avoid mentioning -:std:doc:`setuptools entry-points ` as the concept is -much more generic nowadays. Instead, the terminology of "external", -"installed", or "third-party" plugins (or packages) replaces that. - --- by :user:`webknjaz` diff --git a/changelog/12469.improvement.rst b/changelog/12469.improvement.rst deleted file mode 100644 index a90fb1e6610..00000000000 --- a/changelog/12469.improvement.rst +++ /dev/null @@ -1,4 +0,0 @@ -The console output now uses the "third-party plugins" terminology, -replacing the previously established but confusing and outdated -reference to :std:doc:`setuptools ` --- by :user:`webknjaz`. diff --git a/changelog/12472.bugfix.rst b/changelog/12472.bugfix.rst deleted file mode 100644 index f08e9d1f90b..00000000000 --- a/changelog/12472.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed a crash when returning category ``"error"`` or ``"failed"`` with a custom test status from :hook:`pytest_report_teststatus` hook -- :user:`pbrezina`. diff --git a/changelog/12493.contrib.rst b/changelog/12493.contrib.rst deleted file mode 100644 index db3d045697e..00000000000 --- a/changelog/12493.contrib.rst +++ /dev/null @@ -1,13 +0,0 @@ -The change log draft preview integration has been refactored to use a -third party extension ``sphinxcontib-towncrier``. The previous in-repo -script was putting the change log preview file at -:file:`doc/en/_changelog_towncrier_draft.rst`. Said file is no longer -ignored in Git and might show up among untracked files in the -development environments of the contributors. To address that, the -contributors can run the following command that will clean it up: - -.. code-block:: console - - $ git clean -x -i -- doc/en/_changelog_towncrier_draft.rst - --- by :user:`webknjaz` diff --git a/changelog/12498.contrib.rst b/changelog/12498.contrib.rst deleted file mode 100644 index 436c6f0e9ed..00000000000 --- a/changelog/12498.contrib.rst +++ /dev/null @@ -1,5 +0,0 @@ -All the undocumented ``tox`` environments now have descriptions. -They can be listed in one's development environment by invoking -``tox -av`` in a terminal. - --- by :user:`webknjaz` diff --git a/changelog/12501.contrib.rst b/changelog/12501.contrib.rst deleted file mode 100644 index 6f434c287b3..00000000000 --- a/changelog/12501.contrib.rst +++ /dev/null @@ -1,11 +0,0 @@ -The changelog configuration has been updated to introduce more accurate -audience-tailored categories. Previously, there was a ``trivial`` -change log fragment type with an unclear and broad meaning. It was -removed and we now have ``contrib``, ``misc`` and ``packaging`` in -place of it. - -The new change note types target the readers who are downstream -packagers and project contributors. Additionally, the miscellaneous -section is kept for unspecified updates that do not fit anywhere else. - --- by :user:`webknjaz` diff --git a/changelog/12502.contrib.rst b/changelog/12502.contrib.rst deleted file mode 100644 index 940a2d7a120..00000000000 --- a/changelog/12502.contrib.rst +++ /dev/null @@ -1,7 +0,0 @@ -The UX of the GitHub automation making pull requests to update the -plugin list has been updated. Previously, the maintainers had to close -the automatically created pull requests and re-open them to trigger the -CI runs. From now on, they only need to click the `Ready for review` -button instead. - --- by :user:`webknjaz` diff --git a/changelog/12505.bugfix.rst b/changelog/12505.bugfix.rst deleted file mode 100644 index f55a8a17e4b..00000000000 --- a/changelog/12505.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Improve handling of invalid regex patterns in :func:`pytest.raises(match=r'...') ` by providing a clear error message. diff --git a/changelog/12522.contrib.rst b/changelog/12522.contrib.rst deleted file mode 100644 index dd994317165..00000000000 --- a/changelog/12522.contrib.rst +++ /dev/null @@ -1,4 +0,0 @@ -The ``:pull:`` RST role has been replaced with a shorter -``:pr:`` due to starting to use the implementation from -the third-party :pypi:`sphinx-issues` Sphinx extension --- by :user:`webknjaz`. diff --git a/changelog/12531.contrib.rst b/changelog/12531.contrib.rst deleted file mode 100644 index 12083fc320e..00000000000 --- a/changelog/12531.contrib.rst +++ /dev/null @@ -1,6 +0,0 @@ -The coverage reporting configuration has been updated to exclude -pytest's own tests marked as expected to fail from the coverage -report. This has an effect of reducing the influence of flaky -tests on the resulting number. - --- by :user:`webknjaz` diff --git a/changelog/12533.contrib.rst b/changelog/12533.contrib.rst deleted file mode 100644 index 3da7007a0fd..00000000000 --- a/changelog/12533.contrib.rst +++ /dev/null @@ -1,7 +0,0 @@ -The ``extlinks`` Sphinx extension is no longer enabled. The ``:bpo:`` -role it used to declare has been removed with that. BPO itself has -migrated to GitHub some years ago and it is possible to link the -respective issues by using their GitHub issue numbers and the -``:issue:`` role that the ``sphinx-issues`` extension implements. - --- by :user:`webknjaz` diff --git a/changelog/12544.improvement.rst b/changelog/12544.improvement.rst deleted file mode 100644 index 41125f5d939..00000000000 --- a/changelog/12544.improvement.rst +++ /dev/null @@ -1,3 +0,0 @@ -The ``_in_venv()`` function now detects Python virtual environments by -checking for a :file:`pyvenv.cfg` file, ensuring reliable detection on -various platforms -- by :user:`zachsnickers`. diff --git a/changelog/12545.improvement.rst b/changelog/12545.improvement.rst deleted file mode 120000 index 41a1e6bfa49..00000000000 --- a/changelog/12545.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -12544.improvement.rst \ No newline at end of file diff --git a/changelog/12557.contrib.rst b/changelog/12557.contrib.rst deleted file mode 120000 index c036c519093..00000000000 --- a/changelog/12557.contrib.rst +++ /dev/null @@ -1 +0,0 @@ -11771.contrib.rst \ No newline at end of file diff --git a/changelog/12562.contrib.rst b/changelog/12562.contrib.rst deleted file mode 100644 index 0d30495983a..00000000000 --- a/changelog/12562.contrib.rst +++ /dev/null @@ -1,2 +0,0 @@ -Possible typos in using the ``:user:`` RST role is now being linted -through the pre-commit tool integration -- by :user:`webknjaz`. diff --git a/changelog/12567.feature.rst b/changelog/12567.feature.rst deleted file mode 100644 index 3690d7aff68..00000000000 --- a/changelog/12567.feature.rst +++ /dev/null @@ -1,7 +0,0 @@ -Added ``--no-fold-skipped`` command line option - -If this option is set, then skipped tests in short summary are no longer grouped -by reason but all tests are printed individually with correct nodeid in the same -way as other statuses. - --- by :user:`pbrezina` diff --git a/changelog/12577.doc.rst b/changelog/12577.doc.rst deleted file mode 100644 index 0bd427e177d..00000000000 --- a/changelog/12577.doc.rst +++ /dev/null @@ -1,3 +0,0 @@ -`CI` and `BUILD_NUMBER` environment variables role is discribed in -the reference doc. They now also appears when doing `pytest -h` --- by :user:`MarcBresson`. diff --git a/changelog/12580.bugfix.rst b/changelog/12580.bugfix.rst deleted file mode 100644 index 9186ef1a4c9..00000000000 --- a/changelog/12580.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed a crash when using the cache class on Windows and the cache directory was created concurrently. diff --git a/changelog/2871.improvement.rst b/changelog/2871.improvement.rst deleted file mode 100644 index 1ba399550c7..00000000000 --- a/changelog/2871.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Do not truncate arguments to functions in output when running with `-vvv`. diff --git a/changelog/389.improvement.rst b/changelog/389.improvement.rst deleted file mode 100644 index f8e2c19fde0..00000000000 --- a/changelog/389.improvement.rst +++ /dev/null @@ -1,38 +0,0 @@ -The readability of assertion introspection of bound methods has been enhanced --- by :user:`farbodahm`, :user:`webknjaz`, :user:`obestwalter`, :user:`flub` -and :user:`glyphack`. - -Earlier, it was like: - -.. code-block:: console - - =================================== FAILURES =================================== - _____________________________________ test _____________________________________ - - def test(): - > assert Help().fun() == 2 - E assert 1 == 2 - E + where 1 = >() - E + where > = .fun - E + where = Help() - - example.py:7: AssertionError - =========================== 1 failed in 0.03 seconds =========================== - - -And now it's like: - -.. code-block:: console - - =================================== FAILURES =================================== - _____________________________________ test _____________________________________ - - def test(): - > assert Help().fun() == 2 - E assert 1 == 2 - E + where 1 = fun() - E + where fun = .fun - E + where = Help() - - test_local.py:13: AssertionError - =========================== 1 failed in 0.03 seconds =========================== diff --git a/changelog/6962.bugfix.rst b/changelog/6962.bugfix.rst deleted file mode 100644 index 030b6e06392..00000000000 --- a/changelog/6962.bugfix.rst +++ /dev/null @@ -1,2 +0,0 @@ -Parametrization parameters are now compared using `==` instead of `is` (`is` is still used as a fallback if the parameter does not support `==`). -This fixes use of parameters such as lists, which have a different `id` but compare equal, causing fixtures to be re-computed instead of being cached. diff --git a/changelog/7166.bugfix.rst b/changelog/7166.bugfix.rst deleted file mode 100644 index 98e6821f2ff..00000000000 --- a/changelog/7166.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed progress percentages (the ``[ 87%]`` at the edge of the screen) sometimes not aligning correctly when running with pytest-xdist ``-n``. diff --git a/changelog/7662.improvement.rst b/changelog/7662.improvement.rst deleted file mode 100644 index b6ae1ba7e4c..00000000000 --- a/changelog/7662.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Added timezone information to the testsuite timestamp in the JUnit XML report. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index c65eb5f3613..429cb8249a1 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,8 @@ Release announcements :maxdepth: 2 + release-8.3.1 + release-8.3.0 release-8.2.2 release-8.2.1 release-8.2.0 diff --git a/doc/en/announce/release-8.3.0.rst b/doc/en/announce/release-8.3.0.rst new file mode 100644 index 00000000000..ec5cd3d0db9 --- /dev/null +++ b/doc/en/announce/release-8.3.0.rst @@ -0,0 +1,60 @@ +pytest-8.3.0 +======================================= + +The pytest team is proud to announce the 8.3.0 release! + +This release contains new features, improvements, and bug fixes, +the full list of changes is available in the changelog: + + https://docs.pytest.org/en/stable/changelog.html + +For complete documentation, please visit: + + https://docs.pytest.org/en/stable/ + +As usual, you can upgrade from PyPI via: + + pip install -U pytest + +Thanks to all of the contributors to this release: + +* Anita Hammer +* Ben Brown +* Brian Okken +* Bruno Oliveira +* Cornelius Riemenschneider +* Farbod Ahmadian +* Florian Bruhin +* Hynek Schlawack +* James Frost +* Jason R. Coombs +* Jelle Zijlstra +* Josh Soref +* Marc Bresson +* Michael Vogt +* Nathan Goldbaum +* Nicolas Simonds +* Oliver Bestwalter +* Pavel Březina +* Pierre Sassoulas +* Pradyun Gedam +* Ran Benita +* Ronny Pfannschmidt +* SOUBHIK KUMAR MITRA +* Sam Jirovec +* Stavros Ntentos +* Sviatoslav Sydorenko +* Sviatoslav Sydorenko (Святослав Сидоренко) +* Tomasz Kłoczko +* Virendra Patil +* Yutian Li +* Zach Snicker +* dj +* holger krekel +* joseph-sentry +* lovetheguitar +* neutraljump + + +Happy testing, +The pytest Development Team diff --git a/doc/en/announce/release-8.3.1.rst b/doc/en/announce/release-8.3.1.rst new file mode 100644 index 00000000000..0fb9b40d9c7 --- /dev/null +++ b/doc/en/announce/release-8.3.1.rst @@ -0,0 +1,19 @@ +pytest-8.3.1 +======================================= + +pytest 8.3.1 has just been released to PyPI. + +This is a bug-fix release, being a drop-in replacement. To upgrade:: + + pip install --upgrade pytest + +The full changelog is available at https://docs.pytest.org/en/stable/changelog.html. + +Thanks to all of the contributors to this release: + +* Bruno Oliveira +* Ran Benita + + +Happy testing, +The pytest Development Team diff --git a/doc/en/builtin.rst b/doc/en/builtin.rst index 8dfffb0828a..b4c0f91f8e5 100644 --- a/doc/en/builtin.rst +++ b/doc/en/builtin.rst @@ -22,7 +22,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a cachedir: .pytest_cache rootdir: /home/sweet/project collected 0 items - cache -- .../_pytest/cacheprovider.py:560 + cache -- .../_pytest/cacheprovider.py:558 Return a cache object that can persist state between testing sessions. cache.get(key, default) @@ -33,7 +33,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a Values can be any object handled by the json stdlib module. - capsysbinary -- .../_pytest/capture.py:1003 + capsysbinary -- .../_pytest/capture.py:1005 Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``. The captured output is made available via ``capsysbinary.readouterr()`` @@ -43,6 +43,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a Returns an instance of :class:`CaptureFixture[bytes] `. Example: + .. code-block:: python def test_output(capsysbinary): @@ -50,7 +51,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capsysbinary.readouterr() assert captured.out == b"hello\n" - capfd -- .../_pytest/capture.py:1030 + capfd -- .../_pytest/capture.py:1033 Enable text capturing of writes to file descriptors ``1`` and ``2``. The captured output is made available via ``capfd.readouterr()`` method @@ -60,6 +61,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a Returns an instance of :class:`CaptureFixture[str] `. Example: + .. code-block:: python def test_system_echo(capfd): @@ -67,7 +69,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capfd.readouterr() assert captured.out == "hello\n" - capfdbinary -- .../_pytest/capture.py:1057 + capfdbinary -- .../_pytest/capture.py:1061 Enable bytes capturing of writes to file descriptors ``1`` and ``2``. The captured output is made available via ``capfd.readouterr()`` method @@ -77,6 +79,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a Returns an instance of :class:`CaptureFixture[bytes] `. Example: + .. code-block:: python def test_system_echo(capfdbinary): @@ -84,7 +87,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capfdbinary.readouterr() assert captured.out == b"hello\n" - capsys -- .../_pytest/capture.py:976 + capsys -- .../_pytest/capture.py:977 Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``. The captured output is made available via ``capsys.readouterr()`` method @@ -94,6 +97,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a Returns an instance of :class:`CaptureFixture[str] `. Example: + .. code-block:: python def test_output(capsys): @@ -101,7 +105,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capsys.readouterr() assert captured.out == "hello\n" - doctest_namespace [session scope] -- .../_pytest/doctest.py:738 + doctest_namespace [session scope] -- .../_pytest/doctest.py:740 Fixture that returns a :py:class:`dict` that will be injected into the namespace of doctests. @@ -115,7 +119,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a For more details: :ref:`doctest_namespace`. - pytestconfig [session scope] -- .../_pytest/fixtures.py:1338 + pytestconfig [session scope] -- .../_pytest/fixtures.py:1344 Session-scoped fixture that returns the session's :class:`pytest.Config` object. @@ -125,7 +129,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a if pytestconfig.getoption("verbose") > 0: ... - record_property -- .../_pytest/junitxml.py:284 + record_property -- .../_pytest/junitxml.py:280 Add extra properties to the calling test. User properties become part of the test report and are available to the @@ -139,13 +143,13 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a def test_function(record_property): record_property("example_key", 1) - record_xml_attribute -- .../_pytest/junitxml.py:307 + record_xml_attribute -- .../_pytest/junitxml.py:303 Add extra xml attributes to the tag for the calling test. The fixture is callable with ``name, value``. The value is automatically XML-encoded. - record_testsuite_property [session scope] -- .../_pytest/junitxml.py:345 + record_testsuite_property [session scope] -- .../_pytest/junitxml.py:341 Record a new ```` tag as child of the root ````. This is suitable to writing global information regarding the entire test @@ -170,10 +174,10 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a `pytest-xdist `__ plugin. See :issue:`7767` for details. - tmpdir_factory [session scope] -- .../_pytest/legacypath.py:303 + tmpdir_factory [session scope] -- .../_pytest/legacypath.py:298 Return a :class:`pytest.TempdirFactory` instance for the test session. - tmpdir -- .../_pytest/legacypath.py:310 + tmpdir -- .../_pytest/legacypath.py:305 Return a temporary directory path object which is unique to each test function invocation, created as a sub directory of the base temporary directory. @@ -192,7 +196,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a .. _legacy_path: https://py.readthedocs.io/en/latest/path.html - caplog -- .../_pytest/logging.py:602 + caplog -- .../_pytest/logging.py:600 Access and control log capturing. Captured logs are available through the following properties/methods:: @@ -203,7 +207,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a * caplog.record_tuples -> list of (logger_name, level, message) tuples * caplog.clear() -> clear captured records and formatted log output string - monkeypatch -- .../_pytest/monkeypatch.py:33 + monkeypatch -- .../_pytest/monkeypatch.py:31 A convenient fixture for monkey-patching. The fixture provides these methods to modify objects, dictionaries, or @@ -227,7 +231,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a To undo modifications done by the fixture in a contained scope, use :meth:`context() `. - recwarn -- .../_pytest/recwarn.py:32 + recwarn -- .../_pytest/recwarn.py:35 Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions. See https://docs.pytest.org/en/latest/how-to/capture-warnings.html for information diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index 8e3efd0479b..f6aefbd3b13 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -31,6 +31,269 @@ with advance notice in the **Deprecations** section of releases. .. towncrier release notes start +pytest 8.3.1 (2024-07-20) +========================= + +The 8.3.0 release failed to include the change notes and docs for the release. This patch release remedies this. There are no other changes. + + +pytest 8.3.0 (2024-07-20) +========================= + +New features +------------ + +- `#12231 `_: Added `--xfail-tb` flag, which turns on traceback output for XFAIL results. + + * If the `--xfail-tb` flag is not given, tracebacks for XFAIL results are NOT shown. + * The style of traceback for XFAIL is set with `--tb`, and can be `auto|long|short|line|native|no`. + * Note: Even if you have `--xfail-tb` set, you won't see them if `--tb=no`. + + Some history: + + With pytest 8.0, `-rx` or `-ra` would not only turn on summary reports for xfail, but also report the tracebacks for xfail results. This caused issues with some projects that utilize xfail, but don't want to see all of the xfail tracebacks. + + This change detaches xfail tracebacks from `-rx`, and now we turn on xfail tracebacks with `--xfail-tb`. With this, the default `-rx`/ `-ra` behavior is identical to pre-8.0 with respect to xfail tracebacks. While this is a behavior change, it brings default behavior back to pre-8.0.0 behavior, which ultimately was considered the better course of action. + + +- `#12281 `_: Added support for keyword matching in marker expressions. + + Now tests can be selected by marker keyword arguments. + Supported values are :class:`int`, (unescaped) :class:`str`, :class:`bool` & :data:`None`. + + See :ref:`marker examples ` for more information. + + -- by :user:`lovetheguitar` + + +- `#12567 `_: Added ``--no-fold-skipped`` command line option. + + If this option is set, then skipped tests in short summary are no longer grouped + by reason but all tests are printed individually with their nodeid in the same + way as other statuses. + + -- by :user:`pbrezina` + + + +Improvements in existing functionality +-------------------------------------- + +- `#12469 `_: The console output now uses the "third-party plugins" terminology, + replacing the previously established but confusing and outdated + reference to :std:doc:`setuptools ` + -- by :user:`webknjaz`. + + +- `#12544 `_, `#12545 `_: Python virtual environment detection was improved by + checking for a :file:`pyvenv.cfg` file, ensuring reliable detection on + various platforms -- by :user:`zachsnickers`. + + +- `#2871 `_: Do not truncate arguments to functions in output when running with `-vvv`. + + +- `#389 `_: The readability of assertion introspection of bound methods has been enhanced + -- by :user:`farbodahm`, :user:`webknjaz`, :user:`obestwalter`, :user:`flub` + and :user:`glyphack`. + + Earlier, it was like: + + .. code-block:: console + + =================================== FAILURES =================================== + _____________________________________ test _____________________________________ + + def test(): + > assert Help().fun() == 2 + E assert 1 == 2 + E + where 1 = >() + E + where > = .fun + E + where = Help() + + example.py:7: AssertionError + =========================== 1 failed in 0.03 seconds =========================== + + + And now it's like: + + .. code-block:: console + + =================================== FAILURES =================================== + _____________________________________ test _____________________________________ + + def test(): + > assert Help().fun() == 2 + E assert 1 == 2 + E + where 1 = fun() + E + where fun = .fun + E + where = Help() + + test_local.py:13: AssertionError + =========================== 1 failed in 0.03 seconds =========================== + + +- `#7662 `_: Added timezone information to the testsuite timestamp in the JUnit XML report. + + + +Bug fixes +--------- + +- `#11706 `_: Fixed reporting of teardown errors in higher-scoped fixtures when using `--maxfail` or `--stepwise`. + + Originally added in pytest 8.0.0, but reverted in 8.0.2 due to a regression in pytest-xdist. + This regression was fixed in pytest-xdist 3.6.1. + + +- `#11797 `_: :func:`pytest.approx` now correctly handles :class:`Sequence `-like objects. + + +- `#12204 `_, `#12264 `_: Fixed a regression in pytest 8.0 where tracebacks get longer and longer when multiple + tests fail due to a shared higher-scope fixture which raised -- by :user:`bluetech`. + + Also fixed a similar regression in pytest 5.4 for collectors which raise during setup. + + The fix necessitated internal changes which may affect some plugins: + + * ``FixtureDef.cached_result[2]`` is now a tuple ``(exc, tb)`` + instead of ``exc``. + * ``SetupState.stack`` failures are now a tuple ``(exc, tb)`` + instead of ``exc``. + + +- `#12275 `_: Fixed collection error upon encountering an :mod:`abstract ` class, including abstract `unittest.TestCase` subclasses. + + +- `#12328 `_: Fixed a regression in pytest 8.0.0 where package-scoped parameterized items were not correctly reordered to minimize setups/teardowns in some cases. + + +- `#12424 `_: Fixed crash with `assert testcase is not None` assertion failure when re-running unittest tests using plugins like pytest-rerunfailures. Regressed in 8.2.2. + + +- `#12472 `_: Fixed a crash when returning category ``"error"`` or ``"failed"`` with a custom test status from :hook:`pytest_report_teststatus` hook -- :user:`pbrezina`. + + +- `#12505 `_: Improved handling of invalid regex patterns in :func:`pytest.raises(match=r'...') ` by providing a clear error message. + + +- `#12580 `_: Fixed a crash when using the cache class on Windows and the cache directory was created concurrently. + + +- `#6962 `_: Parametrization parameters are now compared using `==` instead of `is` (`is` is still used as a fallback if the parameter does not support `==`). + This fixes use of parameters such as lists, which have a different `id` but compare equal, causing fixtures to be re-computed instead of being cached. + + +- `#7166 `_: Fixed progress percentages (the ``[ 87%]`` at the edge of the screen) sometimes not aligning correctly when running with pytest-xdist ``-n``. + + + +Improved documentation +---------------------- + +- `#12153 `_: Documented using :envvar:`PYTEST_VERSION` to detect if code is running from within a pytest run. + + +- `#12469 `_: The external plugin mentions in the documentation now avoid mentioning + :std:doc:`setuptools entry-points ` as the concept is + much more generic nowadays. Instead, the terminology of "external", + "installed", or "third-party" plugins (or packages) replaces that. + + -- by :user:`webknjaz` + + +- `#12577 `_: `CI` and `BUILD_NUMBER` environment variables role is discribed in + the reference doc. They now also appear when doing `pytest -h` + -- by :user:`MarcBresson`. + + + +Contributor-facing changes +-------------------------- + +- `#12467 `_: Migrated all internal type-annotations to the python3.10+ style by using the `annotations` future import. + + -- by :user:`RonnyPfannschmidt` + + +- `#11771 `_, `#12557 `_: The PyPy runtime version has been updated to 3.9 from 3.8 that introduced + a flaky bug at the garbage collector which was not expected to fix there + as the 3.8 is EoL. + + -- by :user:`x612skm` + + +- `#12493 `_: The change log draft preview integration has been refactored to use a + third party extension ``sphinxcontib-towncrier``. The previous in-repo + script was putting the change log preview file at + :file:`doc/en/_changelog_towncrier_draft.rst`. Said file is no longer + ignored in Git and might show up among untracked files in the + development environments of the contributors. To address that, the + contributors can run the following command that will clean it up: + + .. code-block:: console + + $ git clean -x -i -- doc/en/_changelog_towncrier_draft.rst + + -- by :user:`webknjaz` + + +- `#12498 `_: All the undocumented ``tox`` environments now have descriptions. + They can be listed in one's development environment by invoking + ``tox -av`` in a terminal. + + -- by :user:`webknjaz` + + +- `#12501 `_: The changelog configuration has been updated to introduce more accurate + audience-tailored categories. Previously, there was a ``trivial`` + change log fragment type with an unclear and broad meaning. It was + removed and we now have ``contrib``, ``misc`` and ``packaging`` in + place of it. + + The new change note types target the readers who are downstream + packagers and project contributors. Additionally, the miscellaneous + section is kept for unspecified updates that do not fit anywhere else. + + -- by :user:`webknjaz` + + +- `#12502 `_: The UX of the GitHub automation making pull requests to update the + plugin list has been updated. Previously, the maintainers had to close + the automatically created pull requests and re-open them to trigger the + CI runs. From now on, they only need to click the `Ready for review` + button instead. + + -- by :user:`webknjaz` + + +- `#12522 `_: The ``:pull:`` RST role has been replaced with a shorter + ``:pr:`` due to starting to use the implementation from + the third-party :pypi:`sphinx-issues` Sphinx extension + -- by :user:`webknjaz`. + + +- `#12531 `_: The coverage reporting configuration has been updated to exclude + pytest's own tests marked as expected to fail from the coverage + report. This has an effect of reducing the influence of flaky + tests on the resulting number. + + -- by :user:`webknjaz` + + +- `#12533 `_: The ``extlinks`` Sphinx extension is no longer enabled. The ``:bpo:`` + role it used to declare has been removed with that. BPO itself has + migrated to GitHub some years ago and it is possible to link the + respective issues by using their GitHub issue numbers and the + ``:issue:`` role that the ``sphinx-issues`` extension implements. + + -- by :user:`webknjaz` + + +- `#12562 `_: Possible typos in using the ``:user:`` RST role is now being linted + through the pre-commit tool integration -- by :user:`webknjaz`. + + pytest 8.2.2 (2024-06-04) ========================= diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index d540bf08337..b5679ff6305 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -162,7 +162,7 @@ objects, they are still using the default pytest representation: rootdir: /home/sweet/project collected 8 items - + @@ -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 - + @@ -318,7 +318,7 @@ Let's first see how it looks like at collection time: rootdir: /home/sweet/project collected 2 items - + @@ -505,8 +505,8 @@ Running it results in some skips if we don't have all the python interpreters in . $ pytest -rs -q multipython.py ssssssssssss...ssssssssssss [100%] ========================= short test summary info ========================== - SKIPPED [12] multipython.py:65: 'python3.9' not found - SKIPPED [12] multipython.py:65: 'python3.11' not found + SKIPPED [12] multipython.py:67: 'python3.9' not found + SKIPPED [12] multipython.py:67: 'python3.11' not found 3 passed, 24 skipped in 0.12s Parametrization of optional implementations/imports diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 39b799ed934..9705ccf94f8 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -152,7 +152,7 @@ The test collection would look like this: configfile: pytest.ini collected 2 items - + @@ -215,7 +215,7 @@ You can always peek at the collection tree without running tests like this: configfile: pytest.ini collected 3 items - + diff --git a/doc/en/example/reportingdemo.rst b/doc/en/example/reportingdemo.rst index 2c34cc2b00d..0da58d0490e 100644 --- a/doc/en/example/reportingdemo.rst +++ b/doc/en/example/reportingdemo.rst @@ -25,7 +25,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: > assert param1 * 2 < param2 E assert (3 * 2) < 6 - failure_demo.py:19: AssertionError + failure_demo.py:21: AssertionError _________________________ TestFailing.test_simple __________________________ self = @@ -42,7 +42,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E + where 42 = .f at 0xdeadbeef0002>() E + and 43 = .g at 0xdeadbeef0003>() - failure_demo.py:30: AssertionError + failure_demo.py:32: AssertionError ____________________ TestFailing.test_simple_multiline _____________________ self = @@ -50,7 +50,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: def test_simple_multiline(self): > otherfunc_multi(42, 6 * 9) - failure_demo.py:33: + failure_demo.py:35: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ a = 42, b = 54 @@ -59,7 +59,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: > assert a == b E assert 42 == 54 - failure_demo.py:14: AssertionError + failure_demo.py:16: AssertionError ___________________________ TestFailing.test_not ___________________________ self = @@ -72,7 +72,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E assert not 42 E + where 42 = .f at 0xdeadbeef0006>() - failure_demo.py:39: AssertionError + failure_demo.py:41: AssertionError _________________ TestSpecialisedExplanations.test_eq_text _________________ self = @@ -84,7 +84,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E - eggs E + spam - failure_demo.py:44: AssertionError + failure_demo.py:46: AssertionError _____________ TestSpecialisedExplanations.test_eq_similar_text _____________ self = @@ -98,7 +98,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E + foo 1 bar E ? ^ - failure_demo.py:47: AssertionError + failure_demo.py:49: AssertionError ____________ TestSpecialisedExplanations.test_eq_multiline_text ____________ self = @@ -112,7 +112,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E + spam E bar - failure_demo.py:50: AssertionError + failure_demo.py:52: AssertionError ______________ TestSpecialisedExplanations.test_eq_long_text _______________ self = @@ -130,7 +130,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E + 1111111111a222222222 E ? ^ - failure_demo.py:55: AssertionError + failure_demo.py:57: AssertionError _________ TestSpecialisedExplanations.test_eq_long_text_multiline __________ self = @@ -150,7 +150,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E E ...Full output truncated (7 lines hidden), use '-vv' to show - failure_demo.py:60: AssertionError + failure_demo.py:62: AssertionError _________________ TestSpecialisedExplanations.test_eq_list _________________ self = @@ -162,7 +162,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E At index 2 diff: 2 != 3 E Use -v to get more diff - failure_demo.py:63: AssertionError + failure_demo.py:65: AssertionError ______________ TestSpecialisedExplanations.test_eq_list_long _______________ self = @@ -176,7 +176,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E At index 100 diff: 1 != 2 E Use -v to get more diff - failure_demo.py:68: AssertionError + failure_demo.py:70: AssertionError _________________ TestSpecialisedExplanations.test_eq_dict _________________ self = @@ -194,7 +194,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E {'d': 0} E Use -v to get more diff - failure_demo.py:71: AssertionError + failure_demo.py:73: AssertionError _________________ TestSpecialisedExplanations.test_eq_set __________________ self = @@ -212,7 +212,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E 21 E Use -v to get more diff - failure_demo.py:74: AssertionError + failure_demo.py:76: AssertionError _____________ TestSpecialisedExplanations.test_eq_longer_list ______________ self = @@ -224,7 +224,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E Right contains one more item: 3 E Use -v to get more diff - failure_demo.py:77: AssertionError + failure_demo.py:79: AssertionError _________________ TestSpecialisedExplanations.test_in_list _________________ self = @@ -233,7 +233,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: > assert 1 in [0, 2, 3, 4, 5] E assert 1 in [0, 2, 3, 4, 5] - failure_demo.py:80: AssertionError + failure_demo.py:82: AssertionError __________ TestSpecialisedExplanations.test_not_in_text_multiline __________ self = @@ -252,7 +252,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E and a E tail - failure_demo.py:84: AssertionError + failure_demo.py:86: AssertionError ___________ TestSpecialisedExplanations.test_not_in_text_single ____________ self = @@ -266,7 +266,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E single foo line E ? +++ - failure_demo.py:88: AssertionError + failure_demo.py:90: AssertionError _________ TestSpecialisedExplanations.test_not_in_text_single_long _________ self = @@ -280,7 +280,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E head head foo tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail E ? +++ - failure_demo.py:92: AssertionError + failure_demo.py:94: AssertionError ______ TestSpecialisedExplanations.test_not_in_text_single_long_term _______ self = @@ -294,7 +294,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E head head fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffftail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail E ? ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - failure_demo.py:96: AssertionError + failure_demo.py:98: AssertionError ______________ TestSpecialisedExplanations.test_eq_dataclass _______________ self = @@ -321,7 +321,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E - c E + b - failure_demo.py:108: AssertionError + failure_demo.py:110: AssertionError ________________ TestSpecialisedExplanations.test_eq_attrs _________________ self = @@ -348,7 +348,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E - c E + b - failure_demo.py:120: AssertionError + failure_demo.py:122: AssertionError ______________________________ test_attribute ______________________________ def test_attribute(): @@ -360,7 +360,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E assert 1 == 2 E + where 1 = .Foo object at 0xdeadbeef0018>.b - failure_demo.py:128: AssertionError + failure_demo.py:130: AssertionError _________________________ test_attribute_instance __________________________ def test_attribute_instance(): @@ -372,7 +372,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E + where 1 = .Foo object at 0xdeadbeef0019>.b E + where .Foo object at 0xdeadbeef0019> = .Foo'>() - failure_demo.py:135: AssertionError + failure_demo.py:137: AssertionError __________________________ test_attribute_failure __________________________ def test_attribute_failure(): @@ -385,7 +385,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: i = Foo() > assert i.b == 2 - failure_demo.py:146: + failure_demo.py:148: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = .Foo object at 0xdeadbeef001a> @@ -394,7 +394,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: > raise Exception("Failed to get attrib") E Exception: Failed to get attrib - failure_demo.py:141: Exception + failure_demo.py:143: Exception _________________________ test_attribute_multiple __________________________ def test_attribute_multiple(): @@ -411,7 +411,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E + and 2 = .Bar object at 0xdeadbeef001c>.b E + where .Bar object at 0xdeadbeef001c> = .Bar'>() - failure_demo.py:156: AssertionError + failure_demo.py:158: AssertionError __________________________ TestRaises.test_raises __________________________ self = @@ -421,7 +421,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: > raises(TypeError, int, s) E ValueError: invalid literal for int() with base 10: 'qwe' - failure_demo.py:166: ValueError + failure_demo.py:168: ValueError ______________________ TestRaises.test_raises_doesnt _______________________ self = @@ -430,7 +430,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: > raises(OSError, int, "3") E Failed: DID NOT RAISE - failure_demo.py:169: Failed + failure_demo.py:171: Failed __________________________ TestRaises.test_raise ___________________________ self = @@ -439,7 +439,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: > raise ValueError("demo error") E ValueError: demo error - failure_demo.py:172: ValueError + failure_demo.py:174: ValueError ________________________ TestRaises.test_tupleerror ________________________ self = @@ -448,7 +448,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: > a, b = [1] # noqa: F841 E ValueError: not enough values to unpack (expected 2, got 1) - failure_demo.py:175: ValueError + failure_demo.py:177: ValueError ______ TestRaises.test_reinterpret_fails_with_print_for_the_fun_of_it ______ self = @@ -459,7 +459,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: > a, b = items.pop() E TypeError: cannot unpack non-iterable int object - failure_demo.py:180: TypeError + failure_demo.py:182: TypeError --------------------------- Captured stdout call --------------------------- items is [1, 2, 3] ________________________ TestRaises.test_some_error ________________________ @@ -470,7 +470,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: > if namenotexi: # noqa: F821 E NameError: name 'namenotexi' is not defined - failure_demo.py:183: NameError + failure_demo.py:185: NameError ____________________ test_dynamic_compile_shows_nicely _____________________ def test_dynamic_compile_shows_nicely(): @@ -486,7 +486,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: sys.modules[name] = module > module.foo() - failure_demo.py:202: + failure_demo.py:204: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > ??? @@ -506,9 +506,9 @@ Here is a nice run of several failures and how ``pytest`` presents things: > somefunc(f(), g()) - failure_demo.py:213: + failure_demo.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ - failure_demo.py:10: in somefunc + failure_demo.py:12: in somefunc otherfunc(x, y) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @@ -518,7 +518,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: > assert a == b E assert 44 == 43 - failure_demo.py:6: AssertionError + failure_demo.py:8: AssertionError ___________________ TestMoreErrors.test_z1_unpack_error ____________________ self = @@ -528,7 +528,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: > a, b = items E ValueError: not enough values to unpack (expected 2, got 0) - failure_demo.py:217: ValueError + failure_demo.py:219: ValueError ____________________ TestMoreErrors.test_z2_type_error _____________________ self = @@ -538,7 +538,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: > a, b = items E TypeError: cannot unpack non-iterable int object - failure_demo.py:221: TypeError + failure_demo.py:223: TypeError ______________________ TestMoreErrors.test_startswith ______________________ self = @@ -551,7 +551,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E + where False = ('456') E + where = '123'.startswith - failure_demo.py:226: AssertionError + failure_demo.py:228: AssertionError __________________ TestMoreErrors.test_startswith_nested ___________________ self = @@ -570,7 +570,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E + where '123' = .f at 0xdeadbeef0029>() E + and '456' = .g at 0xdeadbeef002a>() - failure_demo.py:235: AssertionError + failure_demo.py:237: AssertionError _____________________ TestMoreErrors.test_global_func ______________________ self = @@ -581,7 +581,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E + where False = isinstance(43, float) E + where 43 = globf(42) - failure_demo.py:238: AssertionError + failure_demo.py:240: AssertionError _______________________ TestMoreErrors.test_instance _______________________ self = @@ -592,7 +592,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E assert 42 != 42 E + where 42 = .x - failure_demo.py:242: AssertionError + failure_demo.py:244: AssertionError _______________________ TestMoreErrors.test_compare ________________________ self = @@ -602,7 +602,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E assert 11 < 5 E + where 11 = globf(10) - failure_demo.py:245: AssertionError + failure_demo.py:247: AssertionError _____________________ TestMoreErrors.test_try_finally ______________________ self = @@ -613,7 +613,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: > assert x == 0 E assert 1 == 0 - failure_demo.py:250: AssertionError + failure_demo.py:252: AssertionError ___________________ TestCustomAssertMsg.test_single_line ___________________ self = @@ -628,7 +628,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E assert 1 == 2 E + where 1 = .A'>.a - failure_demo.py:261: AssertionError + failure_demo.py:263: AssertionError ____________________ TestCustomAssertMsg.test_multiline ____________________ self = @@ -647,7 +647,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E assert 1 == 2 E + where 1 = .A'>.a - failure_demo.py:268: AssertionError + failure_demo.py:270: AssertionError ___________________ TestCustomAssertMsg.test_custom_repr ___________________ self = @@ -669,7 +669,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: E assert 1 == 2 E + where 1 = This is JSON\n{\n 'foo': 'bar'\n}.a - failure_demo.py:281: AssertionError + failure_demo.py:283: AssertionError ========================= short test summary info ========================== FAILED failure_demo.py::test_generative[3-6] - assert (3 * 2) < 6 FAILED failure_demo.py::TestFailing::test_simple - assert 42 == 43 diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index d4ace3f0413..a5e2e78c397 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -645,31 +645,6 @@ If we run this: E assert 0 test_step.py:11: AssertionError - ================================ XFAILURES ================================= - ______________________ TestUserHandling.test_deletion ______________________ - - item = - - 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 ================== diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 85bee729ba1..b519656a182 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -22,7 +22,7 @@ Install ``pytest`` .. code-block:: bash $ pytest --version - pytest 8.2.2 + pytest 8.3.1 .. _`simpletest`: diff --git a/doc/en/how-to/fixtures.rst b/doc/en/how-to/fixtures.rst index ecd297867c5..5c66c348eca 100644 --- a/doc/en/how-to/fixtures.rst +++ b/doc/en/how-to/fixtures.rst @@ -1418,7 +1418,7 @@ Running the above tests results in the following test IDs being used: rootdir: /home/sweet/project collected 12 items - + diff --git a/doc/en/how-to/output.rst b/doc/en/how-to/output.rst index 4994ad1af69..8b15f95f0fd 100644 --- a/doc/en/how-to/output.rst +++ b/doc/en/how-to/output.rst @@ -444,14 +444,6 @@ 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 diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index d1222728e13..099c8a00260 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1939,18 +1939,19 @@ All the command-line flags can be obtained by running ``pytest --help``:: general: -k EXPRESSION Only run tests which match the given substring expression. An expression is a Python evaluable - expression where all names are substring-matched against - test names and their parent classes. Example: -k - 'test_method or test_other' matches all test functions - and classes whose name contains 'test_method' or - 'test_other', while -k 'not test_method' matches those - that don't contain 'test_method' in their names. -k 'not - test_method and not test_other' will eliminate the - matches. Additionally keywords are matched to classes - and functions containing extra names in their - 'extra_keyword_matches' set, as well as functions which - have names assigned directly to them. The matching is - case-insensitive. + expression where all names are substring-matched + against test names and their parent classes. + Example: -k 'test_method or test_other' matches all + test functions and classes whose name contains + 'test_method' or 'test_other', while -k 'not + test_method' matches those that don't contain + 'test_method' in their names. -k 'not test_method + and not test_other' will eliminate the matches. + Additionally keywords are matched to classes and + functions containing extra names in their + 'extra_keyword_matches' set, as well as functions + which have names assigned directly to them. The + matching is case-insensitive. -m MARKEXPR Only run tests matching given mark expression. For example: -m 'mark1 and not mark2'. --markers show markers (builtin, plugin and per-project ones). @@ -1968,28 +1969,28 @@ All the command-line flags can be obtained by running ``pytest --help``:: --trace Immediately break when running each test --capture=method Per-test capturing method: one of fd|sys|no|tee-sys -s Shortcut for --capture=no - --runxfail Report the results of xfail tests as if they were not - marked - --lf, --last-failed Rerun only the tests that failed at the last run (or all - if none failed) - --ff, --failed-first Run all tests, but run the last failures first. This may - re-order tests and thus lead to repeated fixture + --runxfail Report the results of xfail tests as if they were + not marked + --lf, --last-failed Rerun only the tests that failed at the last run (or + all if none failed) + --ff, --failed-first Run all tests, but run the last failures first. This + may re-order tests and thus lead to repeated fixture setup/teardown. --nf, --new-first Run tests from new files first, then the rest of the tests sorted by file mtime --cache-show=[CACHESHOW] - Show cache contents, don't perform collection or tests. - Optional argument: glob (default: '*'). + Show cache contents, don't perform collection or + tests. Optional argument: glob (default: '*'). --cache-clear Remove all cache contents at start of test run --lfnf={all,none}, --last-failed-no-failures={all,none} - With ``--lf``, determines whether to execute tests when - there are no previously (known) failures or when no - cached ``lastfailed`` data was found. ``all`` (the - default) runs the full test suite again. ``none`` just - emits a message about no known failures and exits - successfully. - --sw, --stepwise Exit on test failure and continue from last failing test - next time + With ``--lf``, determines whether to execute tests + when there are no previously (known) failures or + when no cached ``lastfailed`` data was found. + ``all`` (the default) runs the full test suite + again. ``none`` just emits a message about no known + failures and exits successfully. + --sw, --stepwise Exit on test failure and continue from last failing + test next time --sw-skip, --stepwise-skip Ignore the first failing test but stop on the next failing test. Implicitly enables --stepwise. @@ -2001,20 +2002,22 @@ All the command-line flags can be obtained by running ``pytest --help``:: -v, --verbose Increase verbosity --no-header Disable header --no-summary Disable summary + --no-fold-skipped Do not fold skipped tests in short summary. -q, --quiet Decrease verbosity --verbosity=VERBOSE Set verbosity. Default: 0. -r chars Show extra test summary info as specified by chars: (f)ailed, (E)rror, (s)kipped, (x)failed, (X)passed, (p)assed, (P)assed with output, (a)ll except passed - (p/P), or (A)ll. (w)arnings are enabled by default (see - --disable-warnings), 'N' can be used to reset the list. - (default: 'fE'). + (p/P), or (A)ll. (w)arnings are enabled by default + (see --disable-warnings), 'N' can be used to reset + the list. (default: 'fE'). --disable-warnings, --disable-pytest-warnings Disable warnings summary -l, --showlocals Show locals in tracebacks (disabled by default) - --no-showlocals Hide locals in tracebacks (negate --showlocals passed - through addopts) - --tb=style Traceback print mode (auto/long/short/line/native/no) + --no-showlocals Hide locals in tracebacks (negate --showlocals + passed through addopts) + --tb=style Traceback print mode + (auto/long/short/line/native/no) --xfail-tb Show tracebacks for xfail (as long as --tb != no) --show-capture={no,stdout,stderr,log,all} Controls how captured stdout/stderr/log is shown on @@ -2022,37 +2025,39 @@ All the command-line flags can be obtained by running ``pytest --help``:: --full-trace Don't cut any tracebacks (default is to cut) --color=color Color terminal output (yes/no/auto) --code-highlight={yes,no} - Whether code should be highlighted (only if --color is - also enabled). Default: yes. + Whether code should be highlighted (only if --color + is also enabled). Default: yes. --pastebin=mode Send failed|all info to bpaste.net pastebin service --junit-xml=path Create junit-xml style report file at given path --junit-prefix=str Prepend prefix to classnames in junit-xml output pytest-warnings: -W PYTHONWARNINGS, --pythonwarnings=PYTHONWARNINGS - Set which warnings to report, see -W option of Python - itself + Set which warnings to report, see -W option of + Python itself --maxfail=num Exit after first num failures or errors --strict-config Any warnings encountered while parsing the `pytest` section of the configuration file raise errors - --strict-markers Markers not registered in the `markers` section of the - configuration file raise errors + --strict-markers Markers not registered in the `markers` section of + the configuration file raise errors --strict (Deprecated) alias to --strict-markers -c FILE, --config-file=FILE Load configuration from `FILE` instead of trying to locate one of the implicit configuration files. --continue-on-collection-errors Force test execution even if collection errors occur - --rootdir=ROOTDIR Define root directory for tests. Can be relative path: - 'root_dir', './root_dir', 'root_dir/another_dir/'; - absolute path: '/home/user/root_dir'; path with - variables: '$HOME/root_dir'. + --rootdir=ROOTDIR Define root directory for tests. Can be relative + path: 'root_dir', './root_dir', + 'root_dir/another_dir/'; absolute path: + '/home/user/root_dir'; path with variables: + '$HOME/root_dir'. collection: --collect-only, --co Only collect tests, don't execute them --pyargs Try to interpret all arguments as Python packages --ignore=path Ignore path during collection (multi-allowed) - --ignore-glob=path Ignore path pattern during collection (multi-allowed) + --ignore-glob=path Ignore path pattern during collection (multi- + allowed) --deselect=nodeid_prefix Deselect item (via node id prefix) during collection (multi-allowed) @@ -2062,8 +2067,8 @@ All the command-line flags can be obtained by running ``pytest --help``:: --collect-in-virtualenv Don't ignore tests in a local virtualenv directory --import-mode={prepend,append,importlib} - Prepend/append to sys.path when importing test modules - and conftest files. Default: prepend. + Prepend/append to sys.path when importing test + modules and conftest files. Default: prepend. --doctest-modules Run doctests in all .py modules --doctest-report={none,cdiff,ndiff,udiff,only_first_failure} Choose another output format for diffs on doctest @@ -2076,37 +2081,38 @@ All the command-line flags can be obtained by running ``pytest --help``:: failure test session debugging and configuration: - --basetemp=dir Base temporary directory for this test run. (Warning: - this directory is removed if it exists.) - -V, --version Display pytest version and information about plugins. - When given twice, also display information about - plugins. + --basetemp=dir Base temporary directory for this test run. + (Warning: this directory is removed if it exists.) + -V, --version Display pytest version and information about + plugins. When given twice, also display information + about plugins. -h, --help Show help message and configuration info -p name Early-load given plugin module name or entry point - (multi-allowed). To avoid loading of plugins, use the - `no:` prefix, e.g. `no:doctest`. + (multi-allowed). To avoid loading of plugins, use + the `no:` prefix, e.g. `no:doctest`. --trace-config Trace considerations of conftest.py files --debug=[DEBUG_FILE_NAME] Store internal tracing debug information in this log - file. This file is opened with 'w' and truncated as a - result, care advised. Default: pytestdebug.log. + file. This file is opened with 'w' and truncated as + a result, care advised. Default: pytestdebug.log. -o OVERRIDE_INI, --override-ini=OVERRIDE_INI - Override ini option with "option=value" style, e.g. `-o - xfail_strict=True -o cache_dir=cache`. + Override ini option with "option=value" style, e.g. + `-o xfail_strict=True -o cache_dir=cache`. --assert=MODE Control assertion debugging tools. 'plain' performs no assertion debugging. - 'rewrite' (the default) rewrites assert statements in - test modules on import to provide assert expression - information. + 'rewrite' (the default) rewrites assert statements + in test modules on import to provide assert + expression information. --setup-only Only setup fixtures, do not execute tests --setup-show Show setup of fixtures while executing tests - --setup-plan Show what fixtures and tests would be executed but don't - execute anything + --setup-plan Show what fixtures and tests would be executed but + don't execute anything logging: - --log-level=LEVEL Level of messages to catch/display. Not set by default, - so it depends on the root/parent log handler's effective - level, where it is "WARNING" by default. + --log-level=LEVEL Level of messages to catch/display. Not set by + default, so it depends on the root/parent log + handler's effective level, where it is "WARNING" by + default. --log-format=LOG_FORMAT Log format used by the logging module --log-date-format=LOG_DATE_FORMAT @@ -2130,13 +2136,8 @@ All the command-line flags can be obtained by running ``pytest --help``:: Auto-indent multiline messages passed to the logging module. Accepts true|on, false|off or an integer. --log-disable=LOGGER_DISABLE - Disable a logger by name. Can be passed multiple times. - - Custom options: - --lsof Run FD checks if lsof is available - --runpytest={inprocess,subprocess} - Run pytest sub runs in tests using an 'inprocess' or - 'subprocess' (python -m main) method + Disable a logger by name. Can be passed multiple + times. [pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg|pyproject.toml file found: @@ -2151,33 +2152,37 @@ All the command-line flags can be obtained by running ``pytest --help``:: warnings.filterwarnings. Processed after -W/--pythonwarnings. consider_namespace_packages (bool): - Consider namespace packages when resolving module names - during import - usefixtures (args): List of default fixtures to be used with this project + Consider namespace packages when resolving module + names during import + usefixtures (args): List of default fixtures to be used with this + project python_files (args): Glob-style file patterns for Python test module discovery python_classes (args): - Prefixes or glob names for Python test class discovery + Prefixes or glob names for Python test class + discovery python_functions (args): Prefixes or glob names for Python test function and method discovery disable_test_id_escaping_and_forfeit_all_rights_to_community_support (bool): - Disable string escape non-ASCII characters, might cause - unwanted side effects(use at your own risk) + Disable string escape non-ASCII characters, might + cause unwanted side effects(use at your own risk) console_output_style (string): - Console output: "classic", or with additional progress - information ("progress" (percentage) | "count" | - "progress-even-when-capture-no" (forces progress even - when capture=no) + Console output: "classic", or with additional + progress information ("progress" (percentage) | + "count" | "progress-even-when-capture-no" (forces + progress even when capture=no) verbosity_test_cases (string): Specify a verbosity level for test case execution, - overriding the main level. Higher levels will provide - more detailed information about each test case executed. - xfail_strict (bool): Default for the strict parameter of xfail markers when - not given explicitly (default: False) + overriding the main level. Higher levels will + provide more detailed information about each test + case executed. + xfail_strict (bool): Default for the strict parameter of xfail markers + when not given explicitly (default: False) tmp_path_retention_count (string): How many sessions should we keep the `tmp_path` - directories, according to `tmp_path_retention_policy`. + directories, according to + `tmp_path_retention_policy`. tmp_path_retention_policy (string): Controls which directories created by the `tmp_path` fixture are kept around, based on test outcome. @@ -2186,9 +2191,9 @@ All the command-line flags can be obtained by running ``pytest --help``:: Enables the pytest_assertion_pass hook. Make sure to delete any previously generated pyc cache files. verbosity_assertions (string): - Specify a verbosity level for assertions, overriding the - main level. Higher levels will provide more detailed - explanation when an assertion fails. + Specify a verbosity level for assertions, overriding + the main level. Higher levels will provide more + detailed explanation when an assertion fails. junit_suite_name (string): Test suite name for JUnit report junit_logging (string): @@ -2210,8 +2215,8 @@ All the command-line flags can be obtained by running ``pytest --help``:: log_format (string): Default value for --log-format log_date_format (string): Default value for --log-date-format - log_cli (bool): Enable log display during test run (also known as "live - logging") + log_cli (bool): Enable log display during test run (also known as + "live logging") log_cli_level (string): Default value for --log-cli-level log_cli_format (string): @@ -2231,18 +2236,16 @@ All the command-line flags can be obtained by running ``pytest --help``:: Default value for --log-auto-indent pythonpath (paths): Add paths to sys.path faulthandler_timeout (string): - Dump the traceback of all threads if a test takes more - than TIMEOUT seconds to finish + Dump the traceback of all threads if a test takes + more than TIMEOUT seconds to finish addopts (args): Extra command line options minversion (string): Minimally required pytest version required_plugins (args): Plugins that must be present for pytest to run - pytester_example_dir (string): - Directory to take the pytester example files from Environment variables: CI When set (regardless of value), pytest knows it is running in a CI process and does not truncate summary info - BUILD_NUMBER equivalent to CI + BUILD_NUMBER Equivalent to CI PYTEST_ADDOPTS Extra command line options PYTEST_PLUGINS Comma-separated plugins to load during startup PYTEST_DISABLE_PLUGIN_AUTOLOAD Set to disable plugin auto-loading From 908c77185e12c77b1c001b41f5c81cea91e3e3c9 Mon Sep 17 00:00:00 2001 From: pytest bot Date: Sun, 21 Jul 2024 00:22:46 +0000 Subject: [PATCH 003/445] [automated] Update plugin list --- doc/en/reference/plugin_list.rst | 126 ++++++++++++++++++------------- 1 file changed, 75 insertions(+), 51 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 7526b055943..8bdce41627b 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =7; extra == "pytest" - :pypi:`nuts` Network Unit Testing System May 28, 2024 N/A pytest<8,>=7 + :pypi:`nuts` Network Unit Testing System Jul 19, 2024 N/A pytest<8,>=7 :pypi:`pytest-abq` Pytest integration for the ABQ universal test runner. Apr 07, 2023 N/A N/A :pypi:`pytest-abstracts` A contextmanager pytest fixture for handling multiple mock abstracts May 25, 2022 N/A N/A :pypi:`pytest-accept` A pytest-plugin for updating doctest outputs Feb 10, 2024 N/A pytest (>=6) @@ -111,7 +111,7 @@ This list contains 1487 plugins. :pypi:`pytest-ast-transformer` May 04, 2019 3 - Alpha pytest :pypi:`pytest_async` pytest-async - Run your coroutine in event loop without decorator Feb 26, 2020 N/A N/A :pypi:`pytest-async-generators` Pytest fixtures for async generators Jul 05, 2023 N/A N/A - :pypi:`pytest-asyncio` Pytest support for asyncio May 19, 2024 4 - Beta pytest<9,>=7.0.0 + :pypi:`pytest-asyncio` Pytest support for asyncio Jul 17, 2024 4 - Beta pytest<9,>=7.0.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Jul 04, 2024 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) :pypi:`pytest-async-mongodb` pytest plugin for async MongoDB Oct 18, 2017 5 - Production/Stable pytest (>=2.5.2) @@ -143,7 +143,7 @@ This list contains 1487 plugins. :pypi:`pytest-bandit-xayon` A bandit plugin for pytest Oct 17, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-base-url` pytest plugin for URL based testing Jan 31, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-batch-regression` A pytest plugin to repeat the entire test suite in batches. May 08, 2024 N/A pytest>=6.0.0 - :pypi:`pytest-bazel` A pytest runner with bazel support Jul 12, 2024 4 - Beta pytest + :pypi:`pytest-bazel` A pytest runner with bazel support Jul 20, 2024 4 - Beta pytest :pypi:`pytest-bdd` BDD for pytest Jun 04, 2024 6 - Mature pytest>=6.2.0 :pypi:`pytest-bdd-html` pytest plugin to display BDD info in HTML test report Nov 22, 2022 3 - Alpha pytest (!=6.0.0,>=5.0) :pypi:`pytest-bdd-ng` BDD for pytest Dec 31, 2023 4 - Beta pytest >=5.0 @@ -153,7 +153,7 @@ This list contains 1487 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Jan 25, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Jul 08, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Jul 19, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -176,7 +176,7 @@ This list contains 1487 plugins. :pypi:`pytest-board` Local continuous test runner with pytest and watchdog. Jan 20, 2019 N/A N/A :pypi:`pytest-boost-xml` Plugin for pytest to generate boost xml reports Nov 30, 2022 4 - Beta N/A :pypi:`pytest-bootstrap` Mar 04, 2022 N/A N/A - :pypi:`pytest-boto-mock` Thin-wrapper around the mock package for easier use with pytest Jun 05, 2024 5 - Production/Stable pytest>=8.2.0 + :pypi:`pytest-boto-mock` Thin-wrapper around the mock package for easier use with pytest Jul 16, 2024 5 - Production/Stable pytest>=8.2.0 :pypi:`pytest-bpdb` A py.test plug-in to enable drop to bpdb debugger on test failure. Jan 19, 2015 2 - Pre-Alpha N/A :pypi:`pytest-bq` BigQuery fixtures and fixture factories for Pytest. May 08, 2024 5 - Production/Stable pytest>=6.2 :pypi:`pytest-bravado` Pytest-bravado automatically generates from OpenAPI specification client fixtures. Feb 15, 2022 N/A N/A @@ -210,7 +210,7 @@ This list contains 1487 plugins. :pypi:`pytest-cassandra` Cassandra CCM Test Fixtures for pytest Nov 04, 2017 1 - Planning N/A :pypi:`pytest-catchlog` py.test plugin to catch log messages. This is a fork of pytest-capturelog. Jan 24, 2016 4 - Beta pytest (>=2.6) :pypi:`pytest-catch-server` Pytest plugin with server for catching HTTP requests. Dec 12, 2019 5 - Production/Stable N/A - :pypi:`pytest-celery` Pytest plugin for Celery Apr 11, 2024 4 - Beta N/A + :pypi:`pytest-celery` Pytest plugin for Celery Jul 17, 2024 4 - Beta N/A :pypi:`pytest-cfg-fetcher` Pass config options to your unit tests. Feb 26, 2024 N/A N/A :pypi:`pytest-chainmaker` pytest plugin for chainmaker Oct 15, 2021 N/A N/A :pypi:`pytest-chalice` A set of py.test fixtures for AWS Chalice Jul 01, 2020 4 - Beta N/A @@ -436,7 +436,7 @@ This list contains 1487 plugins. :pypi:`pytest-dryrun` A Pytest plugin to ignore tests during collection without reporting them in the test summary. Jul 18, 2023 5 - Production/Stable pytest (>=7.4.0,<8.0.0) :pypi:`pytest-dummynet` A py.test plugin providing access to a dummynet. Dec 15, 2021 5 - Production/Stable pytest :pypi:`pytest-dump2json` A pytest plugin for dumping test results to json. Jun 29, 2015 N/A N/A - :pypi:`pytest-duration-insights` Jun 25, 2021 N/A N/A + :pypi:`pytest-duration-insights` Jul 15, 2024 N/A N/A :pypi:`pytest-durations` Pytest plugin reporting fixtures and test functions execution time. Apr 22, 2022 5 - Production/Stable pytest (>=4.6) :pypi:`pytest-dynamicrerun` A pytest plugin to rerun tests dynamically based off of test outcome and output. Aug 15, 2020 4 - Beta N/A :pypi:`pytest-dynamodb` DynamoDB fixtures for pytest Mar 12, 2024 5 - Production/Stable pytest @@ -523,6 +523,7 @@ This list contains 1487 plugins. :pypi:`pytest-failed-screenshot` Test case fails,take a screenshot,save it,attach it to the allure Apr 21, 2021 N/A N/A :pypi:`pytest-failed-to-verify` A pytest plugin that helps better distinguishing real test failures from setup flakiness. Aug 08, 2019 5 - Production/Stable pytest (>=4.1.0) :pypi:`pytest-fail-slow` Fail tests that take too long to run Jun 01, 2024 N/A pytest>=7.0 + :pypi:`pytest-failure-tracker` A pytest plugin for tracking test failures over multiple runs Jul 17, 2024 N/A pytest>=6.0.0 :pypi:`pytest-faker` Faker integration with the pytest framework. Dec 19, 2016 6 - Mature N/A :pypi:`pytest-falcon` Pytest helpers for Falcon. Sep 07, 2016 4 - Beta N/A :pypi:`pytest-falcon-client` A package to prevent Dependency Confusion attacks against Yandex. Feb 21, 2024 N/A N/A @@ -557,7 +558,7 @@ This list contains 1487 plugins. :pypi:`pytest-fixtures` Common fixtures for pytest May 01, 2019 5 - Production/Stable N/A :pypi:`pytest-fixture-tools` Plugin for pytest which provides tools for fixtures Aug 18, 2020 6 - Mature pytest :pypi:`pytest-fixture-typecheck` A pytest plugin to assert type annotations at runtime. Aug 24, 2021 N/A pytest - :pypi:`pytest-flake8` pytest plugin to check FLAKE8 requirements Mar 18, 2022 4 - Beta pytest (>=7.0) + :pypi:`pytest-flake8` pytest plugin to check FLAKE8 requirements Jul 19, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-flake8-path` A pytest fixture for testing flake8 plugins. Jul 10, 2023 5 - Production/Stable pytest :pypi:`pytest-flake8-v2` pytest plugin to check FLAKE8 requirements Mar 01, 2022 5 - Production/Stable pytest (>=7.0) :pypi:`pytest-flakefinder` Runs tests multiple times to expose flakiness. Oct 26, 2022 4 - Beta pytest (>=2.7.1) @@ -642,12 +643,12 @@ This list contains 1487 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Oct 09, 2023 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Jul 11, 2024 3 - Alpha pytest==8.2.0 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Jul 20, 2024 3 - Alpha pytest==8.2.0 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Apr 18, 2024 N/A N/A :pypi:`pytest-hot-test` A plugin that tracks test changes Dec 10, 2022 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-houdini` pytest plugin for testing code in Houdini. Jul 05, 2024 N/A pytest + :pypi:`pytest-houdini` pytest plugin for testing code in Houdini. Jul 15, 2024 N/A pytest :pypi:`pytest-hoverfly` Simplify working with Hoverfly from pytest Jan 30, 2023 N/A pytest (>=5.0) :pypi:`pytest-hoverfly-wrapper` Integrates the Hoverfly HTTP proxy into Pytest Feb 27, 2023 5 - Production/Stable pytest (>=3.7.0) :pypi:`pytest-hpfeeds` Helpers for testing hpfeeds in your python project Feb 28, 2023 4 - Beta pytest (>=6.2.4,<7.0.0) @@ -665,7 +666,7 @@ This list contains 1487 plugins. :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace Jan 10, 2024 3 - Alpha pytest >=7.0.0 :pypi:`pytest-http-mocker` Pytest plugin for http mocking (via https://github.com/vilus/mocker) Oct 20, 2019 N/A N/A :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A - :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Feb 24, 2024 3 - Alpha N/A + :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Jul 19, 2024 3 - Alpha N/A :pypi:`pytest-httptesting` http_testing framework on top of pytest May 08, 2024 N/A pytest<9.0.0,>=8.2.0 :pypi:`pytest-httpx` Send responses to httpx. Feb 21, 2024 5 - Production/Stable pytest <9,>=7 :pypi:`pytest-httpx-blockage` Disable httpx requests during a test run Feb 16, 2023 N/A pytest (>=7.2.1) @@ -683,6 +684,7 @@ This list contains 1487 plugins. :pypi:`pytest-ignore-test-results` A pytest plugin to ignore test results. Aug 17, 2023 2 - Pre-Alpha pytest>=7.0 :pypi:`pytest-image-diff` Mar 09, 2023 3 - Alpha pytest :pypi:`pytest-image-snapshot` A pytest plugin for image snapshot management and comparison. Jul 01, 2024 4 - Beta pytest>=3.5.0 + :pypi:`pytest-import-check` pytest plugin to check whether Python modules can be imported Jul 19, 2024 3 - Alpha pytest>=8.1 :pypi:`pytest-incremental` an incremental test runner (pytest plugin) Apr 24, 2021 5 - Production/Stable N/A :pypi:`pytest-infinity` Jun 09, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-influxdb` Plugin for influxdb and pytest integration. Apr 20, 2021 N/A N/A @@ -725,7 +727,7 @@ This list contains 1487 plugins. :pypi:`pytest-jinja` A plugin to generate customizable jinja-based HTML reports in pytest Oct 04, 2022 3 - Alpha pytest (>=6.2.5,<7.0.0) :pypi:`pytest-jira` py.test JIRA integration plugin, using markers Apr 30, 2024 3 - Alpha N/A :pypi:`pytest-jira-xfail` Plugin skips (xfail) tests if unresolved Jira issue(s) linked Jul 09, 2024 N/A pytest>=7.2.0 - :pypi:`pytest-jira-xray` pytest plugin to integrate tests with JIRA XRAY Mar 27, 2024 4 - Beta pytest>=6.2.4 + :pypi:`pytest-jira-xray` pytest plugin to integrate tests with JIRA XRAY Jul 19, 2024 4 - Beta pytest>=6.2.4 :pypi:`pytest-job-selection` A pytest plugin for load balancing test suites Jan 30, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-jobserver` Limit parallel tests with posix jobserver. May 15, 2019 5 - Production/Stable pytest :pypi:`pytest-joke` Test failures are better served with humor. Oct 08, 2019 4 - Beta pytest (>=4.2.1) @@ -762,7 +764,7 @@ This list contains 1487 plugins. :pypi:`pytest-launchable` Launchable Pytest Plugin Apr 05, 2023 N/A pytest (>=4.2.0) :pypi:`pytest-layab` Pytest fixtures for layab. Oct 05, 2020 5 - Production/Stable N/A :pypi:`pytest-lazy-fixture` It helps to use fixtures in pytest.mark.parametrize Feb 01, 2020 4 - Beta pytest (>=3.2.5) - :pypi:`pytest-lazy-fixtures` Allows you to use fixtures in @pytest.mark.parametrize. Mar 16, 2024 N/A pytest (>=7) + :pypi:`pytest-lazy-fixtures` Allows you to use fixtures in @pytest.mark.parametrize. Jul 17, 2024 N/A pytest>=7 :pypi:`pytest-ldap` python-ldap fixtures for pytest Aug 18, 2020 N/A pytest :pypi:`pytest-leak-finder` Find the test that's leaking before the one that fails Feb 15, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-leaks` A pytest plugin to trace resource leaks. Nov 27, 2019 1 - Planning N/A @@ -796,6 +798,7 @@ This list contains 1487 plugins. :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) :pypi:`pytest-logikal` Common testing environment Jun 27, 2024 5 - Production/Stable pytest==8.2.2 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A + :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Jul 19, 2024 4 - Beta N/A :pypi:`pytest-loguru` Pytest Loguru Mar 20, 2024 5 - Production/Stable pytest; extra == "test" :pypi:`pytest-loop` pytest plugin for looping tests Mar 30, 2024 5 - Production/Stable pytest :pypi:`pytest-lsp` A pytest plugin for end-to-end testing of language servers May 22, 2024 3 - Alpha pytest @@ -1043,7 +1046,7 @@ This list contains 1487 plugins. :pypi:`pytest-pydocstyle` pytest plugin to run pydocstyle Jan 05, 2023 3 - Alpha N/A :pypi:`pytest-pylint` pytest plugin to check source code with pylint Oct 06, 2023 5 - Production/Stable pytest >=7.0 :pypi:`pytest-pymysql-autorecord` Record PyMySQL queries and mock with the stored data. Sep 02, 2022 N/A N/A - :pypi:`pytest-pyodide` Pytest plugin for testing applications that use Pyodide Jun 12, 2024 N/A pytest + :pypi:`pytest-pyodide` Pytest plugin for testing applications that use Pyodide Jul 15, 2024 N/A pytest :pypi:`pytest-pypi` Easily test your HTTP library against a local copy of pypi Mar 04, 2018 3 - Alpha N/A :pypi:`pytest-pypom-navigation` Core engine for cookiecutter-qa and pytest-play packages Feb 18, 2019 4 - Beta pytest (>=3.0.7) :pypi:`pytest-pyppeteer` A plugin to run pyppeteer in pytest Apr 28, 2022 N/A pytest (>=6.2.5,<7.0.0) @@ -1136,7 +1139,7 @@ This list contains 1487 plugins. :pypi:`pytest-rerunfailures` pytest plugin to re-run tests to eliminate flaky failures Mar 13, 2024 5 - Production/Stable pytest >=7.2 :pypi:`pytest-rerunfailures-all-logs` pytest plugin to re-run tests to eliminate flaky failures Mar 07, 2022 5 - Production/Stable N/A :pypi:`pytest-reserial` Pytest fixture for recording and replaying serial port traffic. May 23, 2024 4 - Beta pytest - :pypi:`pytest-resilient-circuits` Resilient Circuits fixtures for PyTest May 17, 2024 N/A pytest~=4.6; python_version == "2.7" + :pypi:`pytest-resilient-circuits` Resilient Circuits fixtures for PyTest Jul 16, 2024 N/A pytest~=7.0 :pypi:`pytest-resource` Load resource fixture plugin to use with pytest Nov 14, 2018 4 - Beta N/A :pypi:`pytest-resource-path` Provides path for uniform access to test resources in isolated directory May 01, 2021 5 - Production/Stable pytest (>=3.5.0) :pypi:`pytest-resource-usage` Pytest plugin for reporting running time and peak memory usage Nov 06, 2022 5 - Production/Stable pytest>=7.0.0 @@ -1185,7 +1188,7 @@ This list contains 1487 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Jul 08, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Jul 19, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 :pypi:`pytest-schedule` The job of test scheduling for humans. Jan 07, 2023 5 - Production/Stable N/A @@ -1195,7 +1198,7 @@ This list contains 1487 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Jul 08, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Jul 19, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1205,7 +1208,7 @@ This list contains 1487 plugins. :pypi:`pytest-server` test server exec cmd Jun 24, 2024 N/A N/A :pypi:`pytest-server-fixtures` Extensible server fixures for py.test Dec 19, 2023 5 - Production/Stable pytest :pypi:`pytest-serverless` Automatically mocks resources from serverless.yml in pytest using moto. May 09, 2022 4 - Beta N/A - :pypi:`pytest-servers` pytest servers Jun 17, 2024 3 - Alpha pytest>=6.2 + :pypi:`pytest-servers` pytest servers Jul 19, 2024 3 - Alpha pytest>=6.2 :pypi:`pytest-service` May 11, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-services` Services plugin for pytest testing framework Oct 30, 2020 6 - Mature N/A :pypi:`pytest-session2file` pytest-session2file (aka: pytest-session_to_file for v0.1.0 - v0.1.2) is a py.test plugin for capturing and saving to file the stdout of py.test. Jan 26, 2021 3 - Alpha pytest @@ -1288,7 +1291,7 @@ This list contains 1487 plugins. :pypi:`pytest-start-from` Start pytest run from a given point Apr 11, 2016 N/A N/A :pypi:`pytest-star-track-issue` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A :pypi:`pytest-static` pytest-static Jun 20, 2024 1 - Planning pytest<8.0.0,>=7.4.3 - :pypi:`pytest-stats` Collects tests metadata for future analysis, easy to extend for any data store Jul 03, 2024 N/A pytest>=8.0.0 + :pypi:`pytest-stats` Collects tests metadata for future analysis, easy to extend for any data store Jul 18, 2024 N/A pytest>=8.0.0 :pypi:`pytest-statsd` pytest plugin for reporting to graphite Nov 30, 2018 5 - Production/Stable pytest (>=3.0.0) :pypi:`pytest-stepfunctions` A small description May 08, 2021 4 - Beta pytest :pypi:`pytest-steps` Create step-wise / incremental tests in pytest. Sep 23, 2021 5 - Production/Stable N/A @@ -1305,7 +1308,7 @@ This list contains 1487 plugins. :pypi:`pytest-subinterpreter` Run pytest in a subinterpreter Nov 25, 2023 N/A pytest>=7.0.0 :pypi:`pytest-subprocess` A plugin to fake subprocess for pytest Jan 28, 2023 5 - Production/Stable pytest (>=4.0.0) :pypi:`pytest-subtesthack` A hack to explicitly set up and tear down fixtures. Jul 16, 2022 N/A N/A - :pypi:`pytest-subtests` unittest subTest() support and subtests fixture Jul 07, 2024 4 - Beta pytest>=7.0 + :pypi:`pytest-subtests` unittest subTest() support and subtests fixture Jul 17, 2024 4 - Beta pytest>=7.0 :pypi:`pytest-subunit` pytest-subunit is a plugin for py.test which outputs testsresult in subunit format. Sep 17, 2023 N/A pytest (>=2.3) :pypi:`pytest-sugar` pytest-sugar is a plugin for pytest that changes the default look and feel of pytest (e.g. progressbar, show tests that fail instantly). Feb 01, 2024 4 - Beta pytest >=6.2.0 :pypi:`pytest-suitemanager` A simple plugin to use with pytest Apr 28, 2023 4 - Beta N/A @@ -1365,7 +1368,7 @@ This list contains 1487 plugins. :pypi:`pytest-testslide` TestSlide fixture for pytest Jan 07, 2021 5 - Production/Stable pytest (~=6.2) :pypi:`pytest-test-this` Plugin for py.test to run relevant tests, based on naively checking if a test contains a reference to the symbol you supply Sep 15, 2019 2 - Pre-Alpha pytest (>=2.3) :pypi:`pytest-test-tracer-for-pytest` A plugin that allows coll test data for use on Test Tracer Jun 28, 2024 4 - Beta pytest>=6.2.0 - :pypi:`pytest-test-tracer-for-pytest-bdd` A plugin that allows coll test data for use on Test Tracer Jul 01, 2024 4 - Beta pytest>=6.2.0 + :pypi:`pytest-test-tracer-for-pytest-bdd` A plugin that allows coll test data for use on Test Tracer Jul 17, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-test-utils` Feb 08, 2024 N/A pytest >=3.9 :pypi:`pytest-tesults` Tesults plugin for pytest Feb 15, 2024 5 - Production/Stable pytest >=3.5.0 :pypi:`pytest-textual-snapshot` Snapshot testing for Textual apps Aug 23, 2023 4 - Beta pytest (>=7.0.0) @@ -1501,7 +1504,7 @@ This list contains 1487 plugins. :pypi:`pytest-xvfb` A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. May 29, 2023 4 - Beta pytest (>=2.8.1) :pypi:`pytest-xvirt` A pytest plugin to virtualize test. For example to transparently running them on a remote box. Jul 03, 2024 4 - Beta pytest>=7.2.2 :pypi:`pytest-yaml` This plugin is used to load yaml output to your test using pytest framework. Oct 05, 2018 N/A pytest - :pypi:`pytest-yaml-sanmu` pytest plugin for generating test cases by yaml Jul 12, 2024 N/A pytest>=7.4.0 + :pypi:`pytest-yaml-sanmu` Pytest plugin for generating test cases with YAML. In test cases, you can use markers, fixtures, variables, and even call Python functions. Jul 20, 2024 N/A pytest~=8.2.2 :pypi:`pytest-yamltree` Create or check file/directory trees described by YAML Mar 02, 2020 4 - Beta pytest (>=3.1.1) :pypi:`pytest-yamlwsgi` Run tests against wsgi apps defined in yaml May 11, 2010 N/A N/A :pypi:`pytest-yaml-yoyo` http/https API run by yaml Jun 19, 2023 N/A pytest (>=7.2.0) @@ -1541,7 +1544,7 @@ This list contains 1487 plugins. Test whether your code is logging correctly 🪵 :pypi:`nuts` - *last release*: May 28, 2024, + *last release*: Jul 19, 2024, *status*: N/A, *requires*: pytest<8,>=7 @@ -2066,7 +2069,7 @@ This list contains 1487 plugins. Pytest fixtures for async generators :pypi:`pytest-asyncio` - *last release*: May 19, 2024, + *last release*: Jul 17, 2024, *status*: 4 - Beta, *requires*: pytest<9,>=7.0.0 @@ -2290,7 +2293,7 @@ This list contains 1487 plugins. A pytest plugin to repeat the entire test suite in batches. :pypi:`pytest-bazel` - *last release*: Jul 12, 2024, + *last release*: Jul 20, 2024, *status*: 4 - Beta, *requires*: pytest @@ -2360,7 +2363,7 @@ This list contains 1487 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Jul 08, 2024, + *last release*: Jul 19, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -2521,7 +2524,7 @@ This list contains 1487 plugins. :pypi:`pytest-boto-mock` - *last release*: Jun 05, 2024, + *last release*: Jul 16, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=8.2.0 @@ -2759,7 +2762,7 @@ This list contains 1487 plugins. Pytest plugin with server for catching HTTP requests. :pypi:`pytest-celery` - *last release*: Apr 11, 2024, + *last release*: Jul 17, 2024, *status*: 4 - Beta, *requires*: N/A @@ -4341,7 +4344,7 @@ This list contains 1487 plugins. A pytest plugin for dumping test results to json. :pypi:`pytest-duration-insights` - *last release*: Jun 25, 2021, + *last release*: Jul 15, 2024, *status*: N/A, *requires*: N/A @@ -4949,6 +4952,13 @@ This list contains 1487 plugins. Fail tests that take too long to run + :pypi:`pytest-failure-tracker` + *last release*: Jul 17, 2024, + *status*: N/A, + *requires*: pytest>=6.0.0 + + A pytest plugin for tracking test failures over multiple runs + :pypi:`pytest-faker` *last release*: Dec 19, 2016, *status*: 6 - Mature, @@ -5188,9 +5198,9 @@ This list contains 1487 plugins. A pytest plugin to assert type annotations at runtime. :pypi:`pytest-flake8` - *last release*: Mar 18, 2022, - *status*: 4 - Beta, - *requires*: pytest (>=7.0) + *last release*: Jul 19, 2024, + *status*: 5 - Production/Stable, + *requires*: pytest>=7.0 pytest plugin to check FLAKE8 requirements @@ -5783,7 +5793,7 @@ This list contains 1487 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Jul 11, 2024, + *last release*: Jul 20, 2024, *status*: 3 - Alpha, *requires*: pytest==8.2.0 @@ -5818,7 +5828,7 @@ This list contains 1487 plugins. A plugin that tracks test changes :pypi:`pytest-houdini` - *last release*: Jul 05, 2024, + *last release*: Jul 15, 2024, *status*: N/A, *requires*: pytest @@ -5944,7 +5954,7 @@ This list contains 1487 plugins. A thin wrapper of HTTPretty for pytest :pypi:`pytest_httpserver` - *last release*: Feb 24, 2024, + *last release*: Jul 19, 2024, *status*: 3 - Alpha, *requires*: N/A @@ -6069,6 +6079,13 @@ This list contains 1487 plugins. A pytest plugin for image snapshot management and comparison. + :pypi:`pytest-import-check` + *last release*: Jul 19, 2024, + *status*: 3 - Alpha, + *requires*: pytest>=8.1 + + pytest plugin to check whether Python modules can be imported + :pypi:`pytest-incremental` *last release*: Apr 24, 2021, *status*: 5 - Production/Stable, @@ -6364,7 +6381,7 @@ This list contains 1487 plugins. Plugin skips (xfail) tests if unresolved Jira issue(s) linked :pypi:`pytest-jira-xray` - *last release*: Mar 27, 2024, + *last release*: Jul 19, 2024, *status*: 4 - Beta, *requires*: pytest>=6.2.4 @@ -6623,9 +6640,9 @@ This list contains 1487 plugins. It helps to use fixtures in pytest.mark.parametrize :pypi:`pytest-lazy-fixtures` - *last release*: Mar 16, 2024, + *last release*: Jul 17, 2024, *status*: N/A, - *requires*: pytest (>=7) + *requires*: pytest>=7 Allows you to use fixtures in @pytest.mark.parametrize. @@ -6860,6 +6877,13 @@ This list contains 1487 plugins. Package for creating a pytest test run reprot + :pypi:`pytest-logscanner` + *last release*: Jul 19, 2024, + *status*: 4 - Beta, + *requires*: N/A + + Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) + :pypi:`pytest-loguru` *last release*: Mar 20, 2024, *status*: 5 - Production/Stable, @@ -8590,7 +8614,7 @@ This list contains 1487 plugins. Record PyMySQL queries and mock with the stored data. :pypi:`pytest-pyodide` - *last release*: Jun 12, 2024, + *last release*: Jul 15, 2024, *status*: N/A, *requires*: pytest @@ -9241,9 +9265,9 @@ This list contains 1487 plugins. Pytest fixture for recording and replaying serial port traffic. :pypi:`pytest-resilient-circuits` - *last release*: May 17, 2024, + *last release*: Jul 16, 2024, *status*: N/A, - *requires*: pytest~=4.6; python_version == "2.7" + *requires*: pytest~=7.0 Resilient Circuits fixtures for PyTest @@ -9584,7 +9608,7 @@ This list contains 1487 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Jul 08, 2024, + *last release*: Jul 19, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9654,7 +9678,7 @@ This list contains 1487 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Jul 08, 2024, + *last release*: Jul 19, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9724,7 +9748,7 @@ This list contains 1487 plugins. Automatically mocks resources from serverless.yml in pytest using moto. :pypi:`pytest-servers` - *last release*: Jun 17, 2024, + *last release*: Jul 19, 2024, *status*: 3 - Alpha, *requires*: pytest>=6.2 @@ -10305,7 +10329,7 @@ This list contains 1487 plugins. pytest-static :pypi:`pytest-stats` - *last release*: Jul 03, 2024, + *last release*: Jul 18, 2024, *status*: N/A, *requires*: pytest>=8.0.0 @@ -10424,7 +10448,7 @@ This list contains 1487 plugins. A hack to explicitly set up and tear down fixtures. :pypi:`pytest-subtests` - *last release*: Jul 07, 2024, + *last release*: Jul 17, 2024, *status*: 4 - Beta, *requires*: pytest>=7.0 @@ -10844,7 +10868,7 @@ This list contains 1487 plugins. A plugin that allows coll test data for use on Test Tracer :pypi:`pytest-test-tracer-for-pytest-bdd` - *last release*: Jul 01, 2024, + *last release*: Jul 17, 2024, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -11796,11 +11820,11 @@ This list contains 1487 plugins. This plugin is used to load yaml output to your test using pytest framework. :pypi:`pytest-yaml-sanmu` - *last release*: Jul 12, 2024, + *last release*: Jul 20, 2024, *status*: N/A, - *requires*: pytest>=7.4.0 + *requires*: pytest~=8.2.2 - pytest plugin for generating test cases by yaml + Pytest plugin for generating test cases with YAML. In test cases, you can use markers, fixtures, variables, and even call Python functions. :pypi:`pytest-yamltree` *last release*: Mar 02, 2020, From 82b297cf22f62d9129a91d6413d86d0ed9c53505 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 21 Jul 2024 09:23:51 +0300 Subject: [PATCH 004/445] doc/changelog: update user tag --- doc/en/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index f6aefbd3b13..083d30abf86 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -55,6 +55,8 @@ New features This change detaches xfail tracebacks from `-rx`, and now we turn on xfail tracebacks with `--xfail-tb`. With this, the default `-rx`/ `-ra` behavior is identical to pre-8.0 with respect to xfail tracebacks. While this is a behavior change, it brings default behavior back to pre-8.0.0 behavior, which ultimately was considered the better course of action. + -- by :user:`okken` + - `#12281 `_: Added support for keyword matching in marker expressions. From 1590cfb7a5f89d18a137cd0fd217c9a026e22666 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 09:34:06 -0300 Subject: [PATCH 005/445] build(deps): Bump hynek/build-and-inspect-python-package (#12643) Bumps [hynek/build-and-inspect-python-package](https://github.com/hynek/build-and-inspect-python-package) from 2.6.0 to 2.7.0. - [Release notes](https://github.com/hynek/build-and-inspect-python-package/releases) - [Changelog](https://github.com/hynek/build-and-inspect-python-package/blob/main/CHANGELOG.md) - [Commits](https://github.com/hynek/build-and-inspect-python-package/compare/v2.6.0...v2.7.0) --- updated-dependencies: - dependency-name: hynek/build-and-inspect-python-package dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/deploy.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f5ea4d39764..3718d180f94 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,7 +31,7 @@ jobs: persist-credentials: false - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v2.6.0 + uses: hynek/build-and-inspect-python-package@v2.7.0 with: attest-build-provenance-github: 'true' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9158d6bcc72..b2fb5131221 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,7 +40,7 @@ jobs: fetch-depth: 0 persist-credentials: false - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v2.6.0 + uses: hynek/build-and-inspect-python-package@v2.7.0 build: needs: [package] From 643845feb76f99d7619655609e34e78b6a628b32 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:08:16 -0300 Subject: [PATCH 006/445] build(deps): Bump pytest-asyncio in /testing/plugins_integration (#12644) Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.23.7 to 0.23.8. - [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases) - [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.23.7...v0.23.8) --- updated-dependencies: - dependency-name: pytest-asyncio dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 4c1efcf32ed..cdb3e7264a0 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,6 +1,6 @@ anyio[curio,trio]==4.4.0 django==5.0.7 -pytest-asyncio==0.23.7 +pytest-asyncio==0.23.8 pytest-bdd==7.2.0 pytest-cov==5.0.0 pytest-django==4.8.0 From 51c40c4f4aaf6a17e1db3c0628b76a4773bdfdb6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 22:33:00 +0000 Subject: [PATCH 007/445] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.2 → v0.5.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.2...v0.5.4) - [github.com/pre-commit/mirrors-mypy: v1.10.1 → v1.11.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.10.1...v1.11.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 419addd95be..79697cf1caa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.5.2" + rev: "v0.5.4" hooks: - id: ruff args: ["--fix"] @@ -21,7 +21,7 @@ repos: hooks: - id: python-use-type-annotations - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.10.1 + rev: v1.11.0 hooks: - id: mypy files: ^(src/|testing/|scripts/) From 69a4a71ef07097a511bf3ddd4385f9840112d492 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 23 Jul 2024 09:57:35 -0300 Subject: [PATCH 008/445] Adapt code after updating to mypy 1.11 --- src/_pytest/_io/pprint.py | 4 ++-- src/_pytest/capture.py | 1 + src/_pytest/faulthandler.py | 1 + testing/test_assertion.py | 2 +- testing/test_monkeypatch.py | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/_pytest/_io/pprint.py b/src/_pytest/_io/pprint.py index 7213be7ba9b..fc29989be0b 100644 --- a/src/_pytest/_io/pprint.py +++ b/src/_pytest/_io/pprint.py @@ -111,7 +111,7 @@ def _format( p(self, object, stream, indent, allowance, context, level + 1) context.remove(objid) elif ( - _dataclasses.is_dataclass(object) + _dataclasses.is_dataclass(object) # type:ignore[unreachable] and not isinstance(object, type) and object.__dataclass_params__.repr and @@ -119,7 +119,7 @@ def _format( hasattr(object.__repr__, "__wrapped__") and "__create_fn__" in object.__repr__.__wrapped__.__qualname__ ): - context.add(objid) + context.add(objid) # type:ignore[unreachable] self._pprint_dataclass( object, stream, indent, allowance, context, level + 1 ) diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index c4dfcc27552..b9652843279 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -202,6 +202,7 @@ def write(self, s: str) -> int: class DontReadFromInput(TextIO): @property def encoding(self) -> str: + assert sys.__stdin__ is not None return sys.__stdin__.encoding def read(self, size: int = -1) -> str: diff --git a/src/_pytest/faulthandler.py b/src/_pytest/faulthandler.py index 07e60f03fc9..d16aea1eb88 100644 --- a/src/_pytest/faulthandler.py +++ b/src/_pytest/faulthandler.py @@ -64,6 +64,7 @@ def get_stderr_fileno() -> int: # pytest-xdist monkeypatches sys.stderr with an object that is not an actual file. # https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors # This is potentially dangerous, but the best we can do. + assert sys.__stderr__ is not None return sys.__stderr__.fileno() diff --git a/testing/test_assertion.py b/testing/test_assertion.py index 69ca0f73ff2..31192df0f6f 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -823,7 +823,7 @@ def __setitem__(self, item, value): def __delitem__(self, item): pass - def insert(self, item, index): + def insert(self, index, value): pass expl = callequal(TestSequence([0, 1]), list([0, 2])) diff --git a/testing/test_monkeypatch.py b/testing/test_monkeypatch.py index 079d8ff60ad..944d91f6e65 100644 --- a/testing/test_monkeypatch.py +++ b/testing/test_monkeypatch.py @@ -415,7 +415,7 @@ def test_context() -> None: with monkeypatch.context() as m: m.setattr(functools, "partial", 3) assert not inspect.isclass(functools.partial) - assert inspect.isclass(functools.partial) + assert inspect.isclass(functools.partial) # type:ignore[unreachable] def test_context_classmethod() -> None: From b3ddf7cddcb3616fda302d773443ca51d9b14fe9 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 23 Jul 2024 20:23:32 +0200 Subject: [PATCH 009/445] Revert "doc: Add changing RTD version to checklist (#9606)" This reverts commit 77a38a3b754e6a82332a1f7bd11bc684c345af28. --- RELEASING.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/RELEASING.rst b/RELEASING.rst index 08004a84c00..030a5c8652f 100644 --- a/RELEASING.rst +++ b/RELEASING.rst @@ -158,8 +158,6 @@ Both automatic and manual processes described above follow the same steps from t git tag MAJOR.{MINOR+1}.0.dev0 git push upstream MAJOR.{MINOR+1}.0.dev0 -#. For major and minor releases, change the default version in the `Read the Docs Settings `_ to the new branch. - #. Send an email announcement with the contents from:: doc/en/announce/release-.rst From d0f7884a1d11ac08a20af3ddf0a17bc4990c4784 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Tue, 23 Jul 2024 23:43:59 +0200 Subject: [PATCH 010/445] explicitly detect conda envs - fixes #12652 initially we accidentially detected conda environmnts by just testing too many files after steamlining we no longer detected conda environments now we explicitly detect conda environments and test for support --- changelog/12652.bugfix.rst | 4 ++++ src/_pytest/main.py | 13 +++++++++++-- testing/test_collection.py | 28 ++++++++++++++++++++-------- 3 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 changelog/12652.bugfix.rst diff --git a/changelog/12652.bugfix.rst b/changelog/12652.bugfix.rst new file mode 100644 index 00000000000..78398212ceb --- /dev/null +++ b/changelog/12652.bugfix.rst @@ -0,0 +1,4 @@ +Resolve the regression in conda environment detection by +explicitly expanding virtualenv detection to conda environents + +-- by :user:`RonnyPfannschmidt` diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 8ec26906003..0ec3377163e 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -370,9 +370,18 @@ def pytest_runtestloop(session: Session) -> bool: def _in_venv(path: Path) -> bool: """Attempt to detect if ``path`` is the root of a Virtual Environment by checking for the existence of the pyvenv.cfg file. - [https://peps.python.org/pep-0405/]""" + + [https://peps.python.org/pep-0405/] + + for regression protection we also check for conda environments that do not include pyenv.cfg yet + https://github.com/conda/conda/issues/13337 is the conda issue tracking adding pyenv.cfg + + """ try: - return path.joinpath("pyvenv.cfg").is_file() + return ( + path.joinpath("pyvenv.cfg").is_file() + or path.joinpath("conda-meta", "history").is_file() + ) except OSError: return False diff --git a/testing/test_collection.py b/testing/test_collection.py index f5822240335..aba8f8ea48d 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -3,6 +3,7 @@ import os from pathlib import Path +from pathlib import PurePath import pprint import shutil import sys @@ -152,8 +153,17 @@ def test_ignored_certain_directories(self, pytester: Pytester) -> None: assert "test_notfound" not in s assert "test_found" in s - def test_ignored_virtualenvs(self, pytester: Pytester) -> None: - ensure_file(pytester.path / "virtual" / "pyvenv.cfg") + known_environment_types = pytest.mark.parametrize( + "env_path", + [ + pytest.param(PurePath("pyvenv.cfg"), id="venv"), + pytest.param(PurePath("conda-meta", "history"), id="conda"), + ], + ) + + @known_environment_types + def test_ignored_virtualenvs(self, pytester: Pytester, env_path: PurePath) -> None: + ensure_file(pytester.path / "virtual" / env_path) testfile = ensure_file(pytester.path / "virtual" / "test_invenv.py") testfile.write_text("def test_hello(): pass", encoding="utf-8") @@ -167,11 +177,12 @@ def test_ignored_virtualenvs(self, pytester: Pytester) -> None: result = pytester.runpytest("virtual") assert "test_invenv" in result.stdout.str() + @known_environment_types def test_ignored_virtualenvs_norecursedirs_precedence( - self, pytester: Pytester + self, pytester: Pytester, env_path ) -> None: # norecursedirs takes priority - ensure_file(pytester.path / ".virtual" / "pyvenv.cfg") + ensure_file(pytester.path / ".virtual" / env_path) testfile = ensure_file(pytester.path / ".virtual" / "test_invenv.py") testfile.write_text("def test_hello(): pass", encoding="utf-8") result = pytester.runpytest("--collect-in-virtualenv") @@ -180,13 +191,14 @@ def test_ignored_virtualenvs_norecursedirs_precedence( result = pytester.runpytest("--collect-in-virtualenv", ".virtual") assert "test_invenv" in result.stdout.str() - def test__in_venv(self, pytester: Pytester) -> None: + @known_environment_types + def test__in_venv(self, pytester: Pytester, env_path: PurePath) -> None: """Directly test the virtual env detection function""" - # no pyvenv.cfg, not a virtualenv + # no env path, not a env base_path = pytester.mkdir("venv") assert _in_venv(base_path) is False - # with pyvenv.cfg, totally a virtualenv - base_path.joinpath("pyvenv.cfg").touch() + # with env path, totally a env + ensure_file(base_path.joinpath(env_path)) assert _in_venv(base_path) is True def test_custom_norecursedirs(self, pytester: Pytester) -> None: From fa915f6aa8e5c5aa223efd23b44248cf4e6e4582 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Wed, 24 Jul 2024 07:48:58 +0200 Subject: [PATCH 011/445] Apply suggestions from code review Co-authored-by: Bruno Oliveira --- changelog/12652.bugfix.rst | 3 +-- src/_pytest/main.py | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/changelog/12652.bugfix.rst b/changelog/12652.bugfix.rst index 78398212ceb..da7644df06d 100644 --- a/changelog/12652.bugfix.rst +++ b/changelog/12652.bugfix.rst @@ -1,4 +1,3 @@ -Resolve the regression in conda environment detection by -explicitly expanding virtualenv detection to conda environents +Resolve regression `conda` environments where no longer being automatically detected. -- by :user:`RonnyPfannschmidt` diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 0ec3377163e..226693805f7 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -373,8 +373,10 @@ def _in_venv(path: Path) -> bool: [https://peps.python.org/pep-0405/] - for regression protection we also check for conda environments that do not include pyenv.cfg yet - https://github.com/conda/conda/issues/13337 is the conda issue tracking adding pyenv.cfg + For regression protection we also check for conda environments that do not include pyenv.cfg yet -- + https://github.com/conda/conda/issues/13337 is the conda issue tracking adding pyenv.cfg. + + Checking for the `conda-meta/history` file per https://github.com/pytest-dev/pytest/issues/12652#issuecomment-2246336902. """ try: From 1f7c917f07716d861235770e0eeef642c0bddf33 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 24 Jul 2024 05:51:11 +0000 Subject: [PATCH 012/445] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/_pytest/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 226693805f7..befc7ccce6e 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -373,9 +373,9 @@ def _in_venv(path: Path) -> bool: [https://peps.python.org/pep-0405/] - For regression protection we also check for conda environments that do not include pyenv.cfg yet -- + For regression protection we also check for conda environments that do not include pyenv.cfg yet -- https://github.com/conda/conda/issues/13337 is the conda issue tracking adding pyenv.cfg. - + Checking for the `conda-meta/history` file per https://github.com/pytest-dev/pytest/issues/12652#issuecomment-2246336902. """ From d0a904faa4acbada493a8b2961e50c57a823e0c4 Mon Sep 17 00:00:00 2001 From: pytest bot Date: Sun, 28 Jul 2024 00:23:08 +0000 Subject: [PATCH 013/445] [automated] Update plugin list --- doc/en/reference/plugin_list.rst | 128 +++++++++++++++++-------------- 1 file changed, 72 insertions(+), 56 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 8bdce41627b..4cec461b9eb 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =3.5.0) :pypi:`pytest-annotate` pytest-annotate: Generate PyAnnotate annotations from your pytest tests. Jun 07, 2022 3 - Alpha pytest (<8.0.0,>=3.2.0) - :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures Jul 10, 2024 5 - Production/Stable pytest>=6 + :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures Jul 24, 2024 5 - Production/Stable pytest>=6 :pypi:`pytest-ansible-playbook` Pytest fixture which runs given ansible playbook file. Mar 08, 2019 4 - Beta N/A :pypi:`pytest-ansible-playbook-runner` Pytest fixture which runs given ansible playbook file. Dec 02, 2020 4 - Beta pytest (>=3.1.0) :pypi:`pytest-ansible-units` A pytest plugin for running unit tests within an ansible collection Apr 14, 2022 N/A N/A @@ -123,17 +123,18 @@ This list contains 1490 plugins. :pypi:`pytest-austin` Austin plugin for pytest Oct 11, 2020 4 - Beta N/A :pypi:`pytest-autocap` automatically capture test & fixture stdout/stderr to files May 15, 2022 N/A pytest (<7.2,>=7.1.2) :pypi:`pytest-autochecklog` automatically check condition and log all the checks Apr 25, 2015 4 - Beta N/A + :pypi:`pytest-auto-fixture` ... Jul 23, 2024 N/A pytest>=8 :pypi:`pytest-automation` pytest plugin for building a test suite, using YAML files to extend pytest parameterize functionality. Apr 24, 2024 N/A pytest>=7.0.0 :pypi:`pytest-automock` Pytest plugin for automatical mocks creation May 16, 2023 N/A pytest ; extra == 'dev' :pypi:`pytest-auto-parametrize` pytest plugin: avoid repeating arguments in parametrize Oct 02, 2016 3 - Alpha N/A :pypi:`pytest-autotest` This fixture provides a configured "driver" for Android Automated Testing, using uiautomator2. Aug 25, 2021 N/A pytest - :pypi:`pytest-aux` templates/examples and aux for pytest Jul 05, 2024 N/A N/A + :pypi:`pytest-aux` templates/examples and aux for pytest Jul 26, 2024 N/A N/A :pypi:`pytest-aviator` Aviator's Flakybot pytest plugin that automatically reruns flaky tests. Nov 04, 2022 4 - Beta pytest :pypi:`pytest-avoidance` Makes pytest skip tests that don not need rerunning May 23, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-aws` pytest plugin for testing AWS resource configurations Oct 04, 2017 4 - Beta N/A :pypi:`pytest-aws-apigateway` pytest plugin for AWS ApiGateway May 24, 2024 4 - Beta pytest :pypi:`pytest-aws-config` Protect your AWS credentials in unit tests May 28, 2021 N/A N/A - :pypi:`pytest-aws-fixtures` A series of fixtures to use in integration tests involving actual AWS services. Feb 02, 2024 N/A pytest (>=8.0.0,<9.0.0) + :pypi:`pytest-aws-fixtures` A series of fixtures to use in integration tests involving actual AWS services. Jul 25, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-axe` pytest plugin for axe-selenium-python Nov 12, 2018 N/A pytest (>=3.0.0) :pypi:`pytest-axe-playwright-snapshot` A pytest plugin that runs Axe-core on Playwright pages and takes snapshots of the results. Jul 25, 2023 N/A pytest :pypi:`pytest-azure` Pytest utilities and mocks for Azure Jan 18, 2023 3 - Alpha pytest @@ -153,7 +154,7 @@ This list contains 1490 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Jan 25, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Jul 19, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Jul 25, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -453,7 +454,7 @@ This list contains 1490 plugins. :pypi:`pytest-elasticsearch` Elasticsearch fixtures and fixture factories for Pytest. Mar 15, 2024 5 - Production/Stable pytest >=7.0 :pypi:`pytest-elements` Tool to help automate user interfaces Jan 13, 2021 N/A pytest (>=5.4,<6.0) :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) - :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Apr 04, 2024 4 - Beta pytest>=3.5.0 + :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. May 31, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. May 23, 2024 5 - Production/Stable N/A @@ -558,7 +559,7 @@ This list contains 1490 plugins. :pypi:`pytest-fixtures` Common fixtures for pytest May 01, 2019 5 - Production/Stable N/A :pypi:`pytest-fixture-tools` Plugin for pytest which provides tools for fixtures Aug 18, 2020 6 - Mature pytest :pypi:`pytest-fixture-typecheck` A pytest plugin to assert type annotations at runtime. Aug 24, 2021 N/A pytest - :pypi:`pytest-flake8` pytest plugin to check FLAKE8 requirements Jul 19, 2024 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-flake8` pytest plugin to check FLAKE8 requirements Jul 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-flake8-path` A pytest fixture for testing flake8 plugins. Jul 10, 2023 5 - Production/Stable pytest :pypi:`pytest-flake8-v2` pytest plugin to check FLAKE8 requirements Mar 01, 2022 5 - Production/Stable pytest (>=7.0) :pypi:`pytest-flakefinder` Runs tests multiple times to expose flakiness. Oct 26, 2022 4 - Beta pytest (>=2.7.1) @@ -624,7 +625,7 @@ This list contains 1490 plugins. :pypi:`pytest-group-by-class` A Pytest plugin for running a subset of your tests by splitting them in to groups of classes. Jun 27, 2023 5 - Production/Stable pytest (>=2.5) :pypi:`pytest-growl` Growl notifications for pytest results. Jan 13, 2014 5 - Production/Stable N/A :pypi:`pytest-grpc` pytest plugin for grpc May 01, 2020 N/A pytest (>=3.6.0) - :pypi:`pytest-grunnur` Py.Test plugin for Grunnur-based packages. Feb 05, 2023 N/A N/A + :pypi:`pytest-grunnur` Py.Test plugin for Grunnur-based packages. Jul 26, 2024 N/A pytest>=6 :pypi:`pytest_gui_status` Show pytest status in gui Jan 23, 2016 N/A pytest :pypi:`pytest-hammertime` Display "🔨 " instead of "." for passed pytest tests. Jul 28, 2018 N/A pytest :pypi:`pytest-hardware-test-report` A simple plugin to use with pytest Apr 01, 2024 4 - Beta pytest<9.0.0,>=8.0.0 @@ -666,15 +667,15 @@ This list contains 1490 plugins. :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace Jan 10, 2024 3 - Alpha pytest >=7.0.0 :pypi:`pytest-http-mocker` Pytest plugin for http mocking (via https://github.com/vilus/mocker) Oct 20, 2019 N/A N/A :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A - :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Jul 19, 2024 3 - Alpha N/A - :pypi:`pytest-httptesting` http_testing framework on top of pytest May 08, 2024 N/A pytest<9.0.0,>=8.2.0 + :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Jul 21, 2024 3 - Alpha N/A + :pypi:`pytest-httptesting` http_testing framework on top of pytest Jul 25, 2024 N/A pytest<9.0.0,>=8.2.0 :pypi:`pytest-httpx` Send responses to httpx. Feb 21, 2024 5 - Production/Stable pytest <9,>=7 :pypi:`pytest-httpx-blockage` Disable httpx requests during a test run Feb 16, 2023 N/A pytest (>=7.2.1) :pypi:`pytest-httpx-recorder` Recorder feature based on pytest_httpx, like recorder feature in responses. Jan 04, 2024 5 - Production/Stable pytest :pypi:`pytest-hue` Visualise PyTest status via your Phillips Hue lights May 09, 2019 N/A N/A :pypi:`pytest-hylang` Pytest plugin to allow running tests written in hylang Mar 28, 2021 N/A pytest :pypi:`pytest-hypo-25` help hypo module for pytest Jan 12, 2020 3 - Alpha N/A - :pypi:`pytest-iam` A fully functional OAUTH2 / OpenID Connect (OIDC) server to be used in your testsuite Apr 22, 2024 3 - Alpha pytest>=7.0.0 + :pypi:`pytest-iam` A fully functional OAUTH2 / OpenID Connect (OIDC) server to be used in your testsuite Jul 25, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-ibutsu` A plugin to sent pytest results to an Ibutsu server Aug 05, 2022 4 - Beta pytest>=7.1 :pypi:`pytest-icdiff` use icdiff for better error messages in pytest assertions Dec 05, 2023 4 - Beta pytest :pypi:`pytest-idapro` A pytest plugin for idapython. Allows a pytest setup to run tests outside and inside IDA in an automated manner by runnig pytest inside IDA and by mocking idapython api Nov 03, 2018 N/A N/A @@ -696,8 +697,8 @@ This list contains 1490 plugins. :pypi:`pytest-initry` Plugin for sending automation test data from Pytest to the initry Apr 30, 2024 N/A pytest<9.0.0,>=8.1.1 :pypi:`pytest-inline` A pytest plugin for writing inline tests. Oct 19, 2023 4 - Beta pytest >=7.0.0 :pypi:`pytest-inmanta` A py.test plugin providing fixtures to simplify inmanta modules testing. Jul 05, 2024 5 - Production/Stable pytest - :pypi:`pytest-inmanta-extensions` Inmanta tests package Jul 05, 2024 5 - Production/Stable N/A - :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Jul 06, 2024 5 - Production/Stable N/A + :pypi:`pytest-inmanta-extensions` Inmanta tests package Jul 22, 2024 5 - Production/Stable N/A + :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Jul 24, 2024 5 - Production/Stable N/A :pypi:`pytest-inmanta-yang` Common fixtures used in inmanta yang related modules Feb 22, 2024 4 - Beta pytest :pypi:`pytest-Inomaly` A simple image diff plugin for pytest Feb 13, 2018 4 - Beta N/A :pypi:`pytest-in-robotframework` The extension enables easy execution of pytest tests within the Robot Framework environment. Mar 02, 2024 N/A pytest @@ -714,7 +715,7 @@ This list contains 1490 plugins. :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A - :pypi:`pytest-ipywidgets` Jul 11, 2024 N/A pytest + :pypi:`pytest-ipywidgets` Jul 23, 2024 N/A pytest :pypi:`pytest-isolate` Feb 20, 2023 4 - Beta pytest :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-it` Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it. Jan 29, 2024 4 - Beta N/A @@ -738,7 +739,7 @@ This list contains 1490 plugins. :pypi:`pytest-json-report` A pytest plugin to report test results as JSON files Mar 15, 2022 4 - Beta pytest (>=3.8.0) :pypi:`pytest-json-report-wip` A pytest plugin to report test results as JSON files Oct 28, 2023 4 - Beta pytest >=3.8.0 :pypi:`pytest-jsonschema` A pytest plugin to perform JSONSchema validations Mar 27, 2024 4 - Beta pytest>=6.2.0 - :pypi:`pytest-jtr` pytest plugin supporting json test report output Jun 04, 2024 N/A pytest<8.0.0,>=7.1.2 + :pypi:`pytest-jtr` pytest plugin supporting json test report output Jul 21, 2024 N/A pytest<8.0.0,>=7.1.2 :pypi:`pytest-jupyter` A pytest plugin for testing Jupyter libraries and extensions. Apr 04, 2024 4 - Beta pytest>=7.0 :pypi:`pytest-jupyterhub` A reusable JupyterHub pytest plugin Apr 25, 2023 5 - Production/Stable pytest :pypi:`pytest-kafka` Zookeeper, Kafka server, and Kafka consumer fixtures for Pytest Jun 14, 2023 N/A pytest @@ -764,7 +765,7 @@ This list contains 1490 plugins. :pypi:`pytest-launchable` Launchable Pytest Plugin Apr 05, 2023 N/A pytest (>=4.2.0) :pypi:`pytest-layab` Pytest fixtures for layab. Oct 05, 2020 5 - Production/Stable N/A :pypi:`pytest-lazy-fixture` It helps to use fixtures in pytest.mark.parametrize Feb 01, 2020 4 - Beta pytest (>=3.2.5) - :pypi:`pytest-lazy-fixtures` Allows you to use fixtures in @pytest.mark.parametrize. Jul 17, 2024 N/A pytest>=7 + :pypi:`pytest-lazy-fixtures` Allows you to use fixtures in @pytest.mark.parametrize. Jul 22, 2024 N/A pytest>=7 :pypi:`pytest-ldap` python-ldap fixtures for pytest Aug 18, 2020 N/A pytest :pypi:`pytest-leak-finder` Find the test that's leaking before the one that fails Feb 15, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-leaks` A pytest plugin to trace resource leaks. Nov 27, 2019 1 - Planning N/A @@ -825,7 +826,7 @@ This list contains 1490 plugins. :pypi:`pytest-meilisearch` Pytest helpers for testing projects using Meilisearch Feb 15, 2024 N/A pytest (>=7.4.3) :pypi:`pytest-memlog` Log memory usage during tests May 03, 2023 N/A pytest (>=7.3.0,<8.0.0) :pypi:`pytest-memprof` Estimates memory consumption of test functions Mar 29, 2019 4 - Beta N/A - :pypi:`pytest-memray` A simple plugin to use with pytest Apr 18, 2024 N/A pytest>=7.2 + :pypi:`pytest-memray` A simple plugin to use with pytest Jul 25, 2024 N/A pytest>=7.2 :pypi:`pytest-menu` A pytest plugin for console based interactive test selection just after the collection phase Oct 04, 2017 3 - Alpha pytest (>=2.4.2) :pypi:`pytest-mercurial` pytest plugin to write integration tests for projects using Mercurial Python internals Nov 21, 2020 1 - Planning N/A :pypi:`pytest-mesh` pytest_mesh插件 Aug 05, 2022 N/A pytest (==7.1.2) @@ -1046,7 +1047,7 @@ This list contains 1490 plugins. :pypi:`pytest-pydocstyle` pytest plugin to run pydocstyle Jan 05, 2023 3 - Alpha N/A :pypi:`pytest-pylint` pytest plugin to check source code with pylint Oct 06, 2023 5 - Production/Stable pytest >=7.0 :pypi:`pytest-pymysql-autorecord` Record PyMySQL queries and mock with the stored data. Sep 02, 2022 N/A N/A - :pypi:`pytest-pyodide` Pytest plugin for testing applications that use Pyodide Jul 15, 2024 N/A pytest + :pypi:`pytest-pyodide` Pytest plugin for testing applications that use Pyodide Jul 23, 2024 N/A pytest :pypi:`pytest-pypi` Easily test your HTTP library against a local copy of pypi Mar 04, 2018 3 - Alpha N/A :pypi:`pytest-pypom-navigation` Core engine for cookiecutter-qa and pytest-play packages Feb 18, 2019 4 - Beta pytest (>=3.0.7) :pypi:`pytest-pyppeteer` A plugin to run pyppeteer in pytest Apr 28, 2022 N/A pytest (>=6.2.5,<7.0.0) @@ -1127,6 +1128,7 @@ This list contains 1490 plugins. :pypi:`pytest-reportportal` Agent for Reporting results of tests to the Report Portal Mar 27, 2024 N/A pytest>=3.8.0 :pypi:`pytest-report-stream` A pytest plugin which allows to stream test reports at runtime Oct 22, 2023 4 - Beta N/A :pypi:`pytest-repo-structure` Pytest Repo Structure Mar 18, 2024 1 - Planning N/A + :pypi:`pytest-req` pytest requests plugin Jul 26, 2024 N/A pytest<9.0.0,>=8.3.1 :pypi:`pytest-reqs` pytest plugin to check pinned requirements May 12, 2019 N/A pytest (>=2.4.2) :pypi:`pytest-requests` A simple plugin to use with pytest Jun 24, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-requestselapsed` collect and show http requests elapsed time Aug 14, 2022 N/A N/A @@ -1138,7 +1140,7 @@ This list contains 1490 plugins. :pypi:`pytest-rerunclassfailures` pytest rerun class failures plugin Apr 24, 2024 5 - Production/Stable pytest>=7.2 :pypi:`pytest-rerunfailures` pytest plugin to re-run tests to eliminate flaky failures Mar 13, 2024 5 - Production/Stable pytest >=7.2 :pypi:`pytest-rerunfailures-all-logs` pytest plugin to re-run tests to eliminate flaky failures Mar 07, 2022 5 - Production/Stable N/A - :pypi:`pytest-reserial` Pytest fixture for recording and replaying serial port traffic. May 23, 2024 4 - Beta pytest + :pypi:`pytest-reserial` Pytest fixture for recording and replaying serial port traffic. Jul 23, 2024 4 - Beta pytest :pypi:`pytest-resilient-circuits` Resilient Circuits fixtures for PyTest Jul 16, 2024 N/A pytest~=7.0 :pypi:`pytest-resource` Load resource fixture plugin to use with pytest Nov 14, 2018 4 - Beta N/A :pypi:`pytest-resource-path` Provides path for uniform access to test resources in isolated directory May 01, 2021 5 - Production/Stable pytest (>=3.5.0) @@ -1170,7 +1172,7 @@ This list contains 1490 plugins. :pypi:`pytest-rst` Test code from RST documents with pytest Jan 26, 2023 N/A N/A :pypi:`pytest-rt` pytest data collector plugin for Testgr May 05, 2022 N/A N/A :pypi:`pytest-rts` Coverage-based regression test selection (RTS) plugin for pytest May 17, 2021 N/A pytest - :pypi:`pytest-ruff` pytest plugin to check ruff requirements. Jul 09, 2024 4 - Beta pytest>=5 + :pypi:`pytest-ruff` pytest plugin to check ruff requirements. Jul 21, 2024 4 - Beta pytest>=5 :pypi:`pytest-run-changed` Pytest plugin that runs changed tests only Apr 02, 2021 3 - Alpha pytest :pypi:`pytest-runfailed` implement a --failed option for pytest Mar 24, 2016 N/A N/A :pypi:`pytest-run-subprocess` Pytest Plugin for running and testing subprocesses. Nov 12, 2022 5 - Production/Stable pytest @@ -1188,7 +1190,7 @@ This list contains 1490 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Jul 19, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Jul 26, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 :pypi:`pytest-schedule` The job of test scheduling for humans. Jan 07, 2023 5 - Production/Stable N/A @@ -1198,7 +1200,7 @@ This list contains 1490 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Jul 19, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Jul 26, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1276,7 +1278,7 @@ This list contains 1490 plugins. :pypi:`pytest-splitio` Split.io SDK integration for e2e tests Sep 22, 2020 N/A pytest (<7,>=5.0) :pypi:`pytest-split-tests` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Forked from Mark Adams' original project pytest-test-groups. Jul 30, 2021 5 - Production/Stable pytest (>=2.5) :pypi:`pytest-split-tests-tresorit` Feb 22, 2021 1 - Planning N/A - :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Jul 11, 2024 N/A pytest<8,>5.4.0 + :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Jul 24, 2024 N/A pytest<8,>5.4.0 :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Jul 10, 2024 N/A N/A :pypi:`pytest-splunk-env` pytest fixtures for interaction with Splunk Enterprise and Splunk Cloud Oct 22, 2020 N/A pytest (>=6.1.1,<7.0.0) :pypi:`pytest-sqitch` sqitch for pytest Apr 06, 2020 4 - Beta N/A @@ -1300,13 +1302,13 @@ This list contains 1490 plugins. :pypi:`pytest-stoq` A plugin to pytest stoq Feb 09, 2021 4 - Beta N/A :pypi:`pytest-store` Pytest plugin to store values from test runs Nov 16, 2023 3 - Alpha pytest (>=7.0.0) :pypi:`pytest-stress` A Pytest plugin that allows you to loop tests for a user defined amount of time. Dec 07, 2019 4 - Beta pytest (>=3.6.0) - :pypi:`pytest-structlog` Structured logging assertions Jun 09, 2024 N/A pytest + :pypi:`pytest-structlog` Structured logging assertions Jul 25, 2024 N/A pytest :pypi:`pytest-structmpd` provide structured temporary directory Oct 17, 2018 N/A N/A :pypi:`pytest-stub` Stub packages, modules and attributes. Apr 28, 2020 5 - Production/Stable N/A :pypi:`pytest-stubprocess` Provide stub implementations for subprocesses in Python tests Sep 17, 2018 3 - Alpha pytest (>=3.5.0) :pypi:`pytest-study` A pytest plugin to organize long run tests (named studies) without interfering the regular tests Sep 26, 2017 3 - Alpha pytest (>=2.0) :pypi:`pytest-subinterpreter` Run pytest in a subinterpreter Nov 25, 2023 N/A pytest>=7.0.0 - :pypi:`pytest-subprocess` A plugin to fake subprocess for pytest Jan 28, 2023 5 - Production/Stable pytest (>=4.0.0) + :pypi:`pytest-subprocess` A plugin to fake subprocess for pytest Jul 24, 2024 5 - Production/Stable pytest>=4.0.0 :pypi:`pytest-subtesthack` A hack to explicitly set up and tear down fixtures. Jul 16, 2022 N/A N/A :pypi:`pytest-subtests` unittest subTest() support and subtests fixture Jul 17, 2024 4 - Beta pytest>=7.0 :pypi:`pytest-subunit` pytest-subunit is a plugin for py.test which outputs testsresult in subunit format. Sep 17, 2023 N/A pytest (>=2.3) @@ -1371,7 +1373,7 @@ This list contains 1490 plugins. :pypi:`pytest-test-tracer-for-pytest-bdd` A plugin that allows coll test data for use on Test Tracer Jul 17, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-test-utils` Feb 08, 2024 N/A pytest >=3.9 :pypi:`pytest-tesults` Tesults plugin for pytest Feb 15, 2024 5 - Production/Stable pytest >=3.5.0 - :pypi:`pytest-textual-snapshot` Snapshot testing for Textual apps Aug 23, 2023 4 - Beta pytest (>=7.0.0) + :pypi:`pytest-textual-snapshot` Snapshot testing for Textual apps Jul 22, 2024 4 - Beta pytest>=8.0.0 :pypi:`pytest-tezos` pytest-ligo Jan 16, 2020 4 - Beta N/A :pypi:`pytest-tf` Test your OpenTofu and Terraform config using a PyTest plugin May 29, 2024 N/A pytest<9.0.0,>=8.2.1 :pypi:`pytest-th2-bdd` pytest_th2_bdd May 13, 2022 N/A N/A @@ -1810,7 +1812,7 @@ This list contains 1490 plugins. pytest-annotate: Generate PyAnnotate annotations from your pytest tests. :pypi:`pytest-ansible` - *last release*: Jul 10, 2024, + *last release*: Jul 24, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=6 @@ -2152,6 +2154,13 @@ This list contains 1490 plugins. automatically check condition and log all the checks + :pypi:`pytest-auto-fixture` + *last release*: Jul 23, 2024, + *status*: N/A, + *requires*: pytest>=8 + + ... + :pypi:`pytest-automation` *last release*: Apr 24, 2024, *status*: N/A, @@ -2181,7 +2190,7 @@ This list contains 1490 plugins. This fixture provides a configured "driver" for Android Automated Testing, using uiautomator2. :pypi:`pytest-aux` - *last release*: Jul 05, 2024, + *last release*: Jul 26, 2024, *status*: N/A, *requires*: N/A @@ -2223,9 +2232,9 @@ This list contains 1490 plugins. Protect your AWS credentials in unit tests :pypi:`pytest-aws-fixtures` - *last release*: Feb 02, 2024, + *last release*: Jul 25, 2024, *status*: N/A, - *requires*: pytest (>=8.0.0,<9.0.0) + *requires*: pytest<9.0.0,>=8.0.0 A series of fixtures to use in integration tests involving actual AWS services. @@ -2363,7 +2372,7 @@ This list contains 1490 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Jul 19, 2024, + *last release*: Jul 25, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -4463,7 +4472,7 @@ This list contains 1490 plugins. An eliot plugin for pytest. :pypi:`pytest-elk-reporter` - *last release*: Apr 04, 2024, + *last release*: Jul 25, 2024, *status*: 4 - Beta, *requires*: pytest>=3.5.0 @@ -5198,7 +5207,7 @@ This list contains 1490 plugins. A pytest plugin to assert type annotations at runtime. :pypi:`pytest-flake8` - *last release*: Jul 19, 2024, + *last release*: Jul 21, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 @@ -5660,9 +5669,9 @@ This list contains 1490 plugins. pytest plugin for grpc :pypi:`pytest-grunnur` - *last release*: Feb 05, 2023, + *last release*: Jul 26, 2024, *status*: N/A, - *requires*: N/A + *requires*: pytest>=6 Py.Test plugin for Grunnur-based packages. @@ -5954,14 +5963,14 @@ This list contains 1490 plugins. A thin wrapper of HTTPretty for pytest :pypi:`pytest_httpserver` - *last release*: Jul 19, 2024, + *last release*: Jul 21, 2024, *status*: 3 - Alpha, *requires*: N/A pytest-httpserver is a httpserver for pytest :pypi:`pytest-httptesting` - *last release*: May 08, 2024, + *last release*: Jul 25, 2024, *status*: N/A, *requires*: pytest<9.0.0,>=8.2.0 @@ -6010,8 +6019,8 @@ This list contains 1490 plugins. help hypo module for pytest :pypi:`pytest-iam` - *last release*: Apr 22, 2024, - *status*: 3 - Alpha, + *last release*: Jul 25, 2024, + *status*: 4 - Beta, *requires*: pytest>=7.0.0 A fully functional OAUTH2 / OpenID Connect (OIDC) server to be used in your testsuite @@ -6164,14 +6173,14 @@ This list contains 1490 plugins. A py.test plugin providing fixtures to simplify inmanta modules testing. :pypi:`pytest-inmanta-extensions` - *last release*: Jul 05, 2024, + *last release*: Jul 22, 2024, *status*: 5 - Production/Stable, *requires*: N/A Inmanta tests package :pypi:`pytest-inmanta-lsm` - *last release*: Jul 06, 2024, + *last release*: Jul 24, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -6290,7 +6299,7 @@ This list contains 1490 plugins. THIS PROJECT IS ABANDONED :pypi:`pytest-ipywidgets` - *last release*: Jul 11, 2024, + *last release*: Jul 23, 2024, *status*: N/A, *requires*: pytest @@ -6458,7 +6467,7 @@ This list contains 1490 plugins. A pytest plugin to perform JSONSchema validations :pypi:`pytest-jtr` - *last release*: Jun 04, 2024, + *last release*: Jul 21, 2024, *status*: N/A, *requires*: pytest<8.0.0,>=7.1.2 @@ -6640,7 +6649,7 @@ This list contains 1490 plugins. It helps to use fixtures in pytest.mark.parametrize :pypi:`pytest-lazy-fixtures` - *last release*: Jul 17, 2024, + *last release*: Jul 22, 2024, *status*: N/A, *requires*: pytest>=7 @@ -7067,7 +7076,7 @@ This list contains 1490 plugins. Estimates memory consumption of test functions :pypi:`pytest-memray` - *last release*: Apr 18, 2024, + *last release*: Jul 25, 2024, *status*: N/A, *requires*: pytest>=7.2 @@ -8614,7 +8623,7 @@ This list contains 1490 plugins. Record PyMySQL queries and mock with the stored data. :pypi:`pytest-pyodide` - *last release*: Jul 15, 2024, + *last release*: Jul 23, 2024, *status*: N/A, *requires*: pytest @@ -9180,6 +9189,13 @@ This list contains 1490 plugins. Pytest Repo Structure + :pypi:`pytest-req` + *last release*: Jul 26, 2024, + *status*: N/A, + *requires*: pytest<9.0.0,>=8.3.1 + + pytest requests plugin + :pypi:`pytest-reqs` *last release*: May 12, 2019, *status*: N/A, @@ -9258,7 +9274,7 @@ This list contains 1490 plugins. pytest plugin to re-run tests to eliminate flaky failures :pypi:`pytest-reserial` - *last release*: May 23, 2024, + *last release*: Jul 23, 2024, *status*: 4 - Beta, *requires*: pytest @@ -9482,7 +9498,7 @@ This list contains 1490 plugins. Coverage-based regression test selection (RTS) plugin for pytest :pypi:`pytest-ruff` - *last release*: Jul 09, 2024, + *last release*: Jul 21, 2024, *status*: 4 - Beta, *requires*: pytest>=5 @@ -9608,7 +9624,7 @@ This list contains 1490 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Jul 19, 2024, + *last release*: Jul 26, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9678,7 +9694,7 @@ This list contains 1490 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Jul 19, 2024, + *last release*: Jul 26, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10224,7 +10240,7 @@ This list contains 1490 plugins. :pypi:`pytest-splunk-addon` - *last release*: Jul 11, 2024, + *last release*: Jul 24, 2024, *status*: N/A, *requires*: pytest<8,>5.4.0 @@ -10392,7 +10408,7 @@ This list contains 1490 plugins. A Pytest plugin that allows you to loop tests for a user defined amount of time. :pypi:`pytest-structlog` - *last release*: Jun 09, 2024, + *last release*: Jul 25, 2024, *status*: N/A, *requires*: pytest @@ -10434,9 +10450,9 @@ This list contains 1490 plugins. Run pytest in a subinterpreter :pypi:`pytest-subprocess` - *last release*: Jan 28, 2023, + *last release*: Jul 24, 2024, *status*: 5 - Production/Stable, - *requires*: pytest (>=4.0.0) + *requires*: pytest>=4.0.0 A plugin to fake subprocess for pytest @@ -10889,9 +10905,9 @@ This list contains 1490 plugins. Tesults plugin for pytest :pypi:`pytest-textual-snapshot` - *last release*: Aug 23, 2023, + *last release*: Jul 22, 2024, *status*: 4 - Beta, - *requires*: pytest (>=7.0.0) + *requires*: pytest>=8.0.0 Snapshot testing for Textual apps From 3594adc066ab33dcfcc1bce5276b29266613a83b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 05:52:48 +0200 Subject: [PATCH 014/445] build(deps): Bump hynek/build-and-inspect-python-package (#12666) Bumps [hynek/build-and-inspect-python-package](https://github.com/hynek/build-and-inspect-python-package) from 2.7.0 to 2.8.0. - [Release notes](https://github.com/hynek/build-and-inspect-python-package/releases) - [Changelog](https://github.com/hynek/build-and-inspect-python-package/blob/main/CHANGELOG.md) - [Commits](https://github.com/hynek/build-and-inspect-python-package/compare/v2.7.0...v2.8.0) --- updated-dependencies: - dependency-name: hynek/build-and-inspect-python-package dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/deploy.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3718d180f94..34a0b25c63c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,7 +31,7 @@ jobs: persist-credentials: false - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v2.7.0 + uses: hynek/build-and-inspect-python-package@v2.8.0 with: attest-build-provenance-github: 'true' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b2fb5131221..83a3d9cb33e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,7 +40,7 @@ jobs: fetch-depth: 0 persist-credentials: false - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v2.7.0 + uses: hynek/build-and-inspect-python-package@v2.8.0 build: needs: [package] From 7ce3222764193feb581abfea58f8920b36e259de Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Mon, 29 Jul 2024 13:46:39 +0200 Subject: [PATCH 015/445] Make TerminalReporter public API and add to reference docs #6649 (#12661) Fixes #6649 --- changelog/6649.doc.rst | 1 + changelog/6649.misc.rst | 1 + doc/en/reference/reference.rst | 7 +++++++ src/_pytest/terminal.py | 2 +- src/pytest/__init__.py | 2 ++ 5 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 changelog/6649.doc.rst create mode 100644 changelog/6649.misc.rst diff --git a/changelog/6649.doc.rst b/changelog/6649.doc.rst new file mode 100644 index 00000000000..cf5bb781b87 --- /dev/null +++ b/changelog/6649.doc.rst @@ -0,0 +1 @@ +Added :class:`~pytest.TerminalReporter` to the :ref:`api-reference` documentation page. diff --git a/changelog/6649.misc.rst b/changelog/6649.misc.rst new file mode 100644 index 00000000000..cec8c3f4506 --- /dev/null +++ b/changelog/6649.misc.rst @@ -0,0 +1 @@ +Added :class:`~pytest.TerminalReporter` to the public pytest API, as it is part of the signature of the :hook:`pytest_terminal_summary` hook. diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 099c8a00260..3a5063b6b58 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1013,6 +1013,13 @@ PytestPluginManager :inherited-members: :show-inheritance: +TerminalReporter +~~~~~~~~~~~~~~~~ + +.. autoclass:: pytest.TerminalReporter + :members: + :inherited-members: + TestReport ~~~~~~~~~~ diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 8c722124d04..cdda5a90ea1 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -1340,7 +1340,7 @@ def build_summary_stats_line(self) -> tuple[list[tuple[str, dict[str, bool]]], s The summary stats line is the line shown at the end, "=== 12 passed, 2 errors in Xs===". This function builds a list of the "parts" that make up for the text in that line, in - the example above it would be: + the example above it would be:: [ ("12 passed", {"green": True}), diff --git a/src/pytest/__init__.py b/src/pytest/__init__.py index 90abcdab036..92152b7c7b4 100644 --- a/src/pytest/__init__.py +++ b/src/pytest/__init__.py @@ -68,6 +68,7 @@ from _pytest.runner import CallInfo from _pytest.stash import Stash from _pytest.stash import StashKey +from _pytest.terminal import TerminalReporter from _pytest.terminal import TestShortLogReport from _pytest.tmpdir import TempPathFactory from _pytest.warning_types import PytestAssertRewriteWarning @@ -161,6 +162,7 @@ "version_tuple", "TempdirFactory", "TempPathFactory", + "TerminalReporter", "Testdir", "TestReport", "TestShortLogReport", From 8509fe8be58ea1c093b4b0ac89382bfdacea0083 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Jul 2024 07:25:50 +0200 Subject: [PATCH 016/445] [pre-commit.ci] pre-commit autoupdate (#12669) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.4 → v0.5.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.4...v0.5.5) - [github.com/asottile/pyupgrade: v3.16.0 → v3.17.0](https://github.com/asottile/pyupgrade/compare/v3.16.0...v3.17.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 79697cf1caa..aaa28d6b7c4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.5.4" + rev: "v0.5.5" hooks: - id: ruff args: ["--fix"] @@ -44,7 +44,7 @@ repos: # https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version additional_dependencies: ["tox>=4.9"] - repo: https://github.com/asottile/pyupgrade - rev: v3.16.0 + rev: v3.17.0 hooks: - id: pyupgrade stages: [manual] From cd0dd3c9787a2bd1c5a91c911679b1c1e8531afc Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 31 Jul 2024 16:49:04 -0300 Subject: [PATCH 017/445] Pin towncrier due to incompatibility with sphinxcontrib-towncrier Pin `towncrier` until we find a solution to https://github.com/sphinx-contrib/sphinxcontrib-towncrier/issues/92. --- doc/en/broken-dep-constraints.txt | 6 ++++++ doc/en/requirements.txt | 1 + 2 files changed, 7 insertions(+) create mode 100644 doc/en/broken-dep-constraints.txt diff --git a/doc/en/broken-dep-constraints.txt b/doc/en/broken-dep-constraints.txt new file mode 100644 index 00000000000..f7c3211a9a0 --- /dev/null +++ b/doc/en/broken-dep-constraints.txt @@ -0,0 +1,6 @@ +# This file contains transitive dependencies that need to be pinned for some reason. +# Eventually this file will be empty, but in this case keep it around for future use. + +# Pin towncrier temporarily due to incompatibility with sphinxcontrib-towncrier: +# https://github.com/sphinx-contrib/sphinxcontrib-towncrier/issues/92 +towncrier!=24.7.0,!=24.7.1 diff --git a/doc/en/requirements.txt b/doc/en/requirements.txt index 0637c967b8a..42225057e2b 100644 --- a/doc/en/requirements.txt +++ b/doc/en/requirements.txt @@ -1,3 +1,4 @@ +-c broken-dep-constraints.txt pluggy>=1.5.0 pygments-pytest>=2.3.0 sphinx-removed-in>=0.2.0 From 303e5c51b9bfaa9d699f8852feaf70029ac5ecdc Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 31 Jul 2024 16:51:27 -0300 Subject: [PATCH 018/445] Remove explicit package dependency package was previously an explicit dependency because it was pinned in https://github.com/pytest-dev/pytest/pull/10578, however since then the pin has been removed, so the explicit dependency is no longer necessary. --- doc/en/requirements.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/doc/en/requirements.txt b/doc/en/requirements.txt index 42225057e2b..ddcb7efb99b 100644 --- a/doc/en/requirements.txt +++ b/doc/en/requirements.txt @@ -5,10 +5,6 @@ sphinx-removed-in>=0.2.0 sphinx>=7 sphinxcontrib-trio sphinxcontrib-svg2pdfconverter -# Pin packaging because it no longer handles 'latest' version, which -# is the version that is assigned to the docs. -# See https://github.com/pytest-dev/pytest/pull/10578#issuecomment-1348249045. -packaging furo sphinxcontrib-towncrier sphinx-issues From c6c7ade7aa827329fb1531fbeff969c244dc2fec Mon Sep 17 00:00:00 2001 From: Rob Arrow Date: Thu, 1 Aug 2024 16:07:57 +0100 Subject: [PATCH 019/445] Remove quotes from example tmp_path_retention_policy Previously the docs contained an example for `tmp_path_retention_policy` which included quotes around the value. If the configuration was actually set with this value. The following error would be encountered `INTERNALERROR> ValueError: tmp_path_retention_policy must be either all, failed, none. Current input: "all".` This is because the value of the field was not being unwrapped from the quotes when parsed. This commit removes the quotes from the example so that if used in the configuration file, no error will occur. --- AUTHORS | 1 + changelog/12678.doc.rst | 1 + doc/en/reference/reference.rst | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelog/12678.doc.rst diff --git a/AUTHORS b/AUTHORS index 9b6cb6a9d23..8103a1d52a5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -351,6 +351,7 @@ Rafal Semik Raquel Alegre Ravi Chandra Reagan Lee +Rob Arrow Robert Holt Roberto Aldera Roberto Polli diff --git a/changelog/12678.doc.rst b/changelog/12678.doc.rst new file mode 100644 index 00000000000..9d79ec41007 --- /dev/null +++ b/changelog/12678.doc.rst @@ -0,0 +1 @@ +Remove erroneous quotes from `tmp_path_retention_policy` example in docs. diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 3a5063b6b58..7ea5921f581 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1873,7 +1873,7 @@ passed multiple times. The expected format is ``name=value``. For example:: .. code-block:: ini [pytest] - tmp_path_retention_policy = "all" + tmp_path_retention_policy = all Default: ``all`` From 90d70465ef2a09415a2d6ee7211d8dbc1e0c8650 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 1 Aug 2024 23:41:31 +0200 Subject: [PATCH 020/445] Merge pull request #12660 from pytest-dev/release-8.3.2 (cherry picked from commit 7b62fef8e15b58eaf5a6c8a201feeb97592df0aa) --- changelog/12652.bugfix.rst | 3 --- doc/en/announce/index.rst | 1 + doc/en/announce/release-8.3.2.rst | 19 +++++++++++++++++++ doc/en/changelog.rst | 11 +++++++++++ doc/en/example/parametrize.rst | 6 +++--- doc/en/example/pythoncollection.rst | 4 ++-- doc/en/getting-started.rst | 2 +- doc/en/how-to/fixtures.rst | 2 +- 8 files changed, 38 insertions(+), 10 deletions(-) delete mode 100644 changelog/12652.bugfix.rst create mode 100644 doc/en/announce/release-8.3.2.rst diff --git a/changelog/12652.bugfix.rst b/changelog/12652.bugfix.rst deleted file mode 100644 index da7644df06d..00000000000 --- a/changelog/12652.bugfix.rst +++ /dev/null @@ -1,3 +0,0 @@ -Resolve regression `conda` environments where no longer being automatically detected. - --- by :user:`RonnyPfannschmidt` diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index 429cb8249a1..09311a1a1ab 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-8.3.2 release-8.3.1 release-8.3.0 release-8.2.2 diff --git a/doc/en/announce/release-8.3.2.rst b/doc/en/announce/release-8.3.2.rst new file mode 100644 index 00000000000..1e4a071692c --- /dev/null +++ b/doc/en/announce/release-8.3.2.rst @@ -0,0 +1,19 @@ +pytest-8.3.2 +======================================= + +pytest 8.3.2 has just been released to PyPI. + +This is a bug-fix release, being a drop-in replacement. To upgrade:: + + pip install --upgrade pytest + +The full changelog is available at https://docs.pytest.org/en/stable/changelog.html. + +Thanks to all of the contributors to this release: + +* Ran Benita +* Ronny Pfannschmidt + + +Happy testing, +The pytest Development Team diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index 083d30abf86..3178f82044d 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -31,6 +31,17 @@ with advance notice in the **Deprecations** section of releases. .. towncrier release notes start +pytest 8.3.2 (2024-07-24) +========================= + +Bug fixes +--------- + +- `#12652 `_: Resolve regression `conda` environments where no longer being automatically detected. + + -- by :user:`RonnyPfannschmidt` + + pytest 8.3.1 (2024-07-20) ========================= diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index b5679ff6305..3e449b2eaa2 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -162,7 +162,7 @@ objects, they are still using the default pytest representation: rootdir: /home/sweet/project collected 8 items - + @@ -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 - + @@ -318,7 +318,7 @@ Let's first see how it looks like at collection time: rootdir: /home/sweet/project collected 2 items - + diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 9705ccf94f8..5bd03035c14 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -152,7 +152,7 @@ The test collection would look like this: configfile: pytest.ini collected 2 items - + @@ -215,7 +215,7 @@ You can always peek at the collection tree without running tests like this: configfile: pytest.ini collected 3 items - + diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index b519656a182..050fd2d80ec 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -22,7 +22,7 @@ Install ``pytest`` .. code-block:: bash $ pytest --version - pytest 8.3.1 + pytest 8.3.2 .. _`simpletest`: diff --git a/doc/en/how-to/fixtures.rst b/doc/en/how-to/fixtures.rst index 5c66c348eca..f4d59ff93c0 100644 --- a/doc/en/how-to/fixtures.rst +++ b/doc/en/how-to/fixtures.rst @@ -1418,7 +1418,7 @@ Running the above tests results in the following test IDs being used: rootdir: /home/sweet/project collected 12 items - + From 5a0158368798f466ac74c8e89aef40829cd86d5c Mon Sep 17 00:00:00 2001 From: fazeelghafoor <33656455+fazeelghafoor@users.noreply.github.com> Date: Thu, 1 Aug 2024 18:26:50 -0400 Subject: [PATCH 021/445] Improve approx repr for better readability (#12665) Adjust `ApproxScalar.__repr__` to format tolerances in decimal form for smaller ranges. Closes #6985 --------- Co-authored-by: Bruno Oliveira Co-authored-by: Pierre Sassoulas --- changelog/6985.improvement.rst | 21 +++++++++++++++++++++ src/_pytest/python_api.py | 6 +++++- testing/python/approx.py | 16 +++++++++++----- 3 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 changelog/6985.improvement.rst diff --git a/changelog/6985.improvement.rst b/changelog/6985.improvement.rst new file mode 100644 index 00000000000..34ee8edc77d --- /dev/null +++ b/changelog/6985.improvement.rst @@ -0,0 +1,21 @@ +Improved :func:`pytest.approx` to enhance the readability of value ranges and tolerances between 0.001 and 1000. + * The `repr` method now provides clearer output for values within those ranges, making it easier to interpret the results. + * Previously, the output for those ranges of values and tolerances was displayed in scientific notation (e.g., `42 ± 1.0e+00`). The updated method now presents the tolerance as a decimal for better readability (e.g., `42 ± 1`). + + Example: + + **Previous Output:** + + .. code-block:: console + + >>> pytest.approx(42, abs=1) + 42 ± 1.0e+00 + + **Current Output:** + + .. code-block:: console + + >>> pytest.approx(42, abs=1) + 42 ± 1 + + -- by :user:`fazeelghafoor` diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 4174a55b589..d2107c2fc78 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -406,7 +406,11 @@ def __repr__(self) -> str: # If a sensible tolerance can't be calculated, self.tolerance will # raise a ValueError. In this case, display '???'. try: - vetted_tolerance = f"{self.tolerance:.1e}" + if 1e-3 <= self.tolerance < 1e3: + vetted_tolerance = f"{self.tolerance:n}" + else: + vetted_tolerance = f"{self.tolerance:.1e}" + if ( isinstance(self.expected, Complex) and self.expected.imag diff --git a/testing/python/approx.py b/testing/python/approx.py index 69743cdbe17..21932059cc6 100644 --- a/testing/python/approx.py +++ b/testing/python/approx.py @@ -92,6 +92,7 @@ def do_assert(lhs, rhs, expected_message, verbosity_level=0): SOME_FLOAT = r"[+-]?([0-9]*[.])?[0-9]+\s*" SOME_INT = r"[0-9]+\s*" +SOME_TOLERANCE = rf"({SOME_FLOAT}|[+-]?[0-9]+(\.[0-9]+)?[eE][+-]?[0-9]+\s*)" class TestApprox: @@ -103,7 +104,7 @@ def test_error_messages_native_dtypes(self, assert_approx_raises_regex): "", " comparison failed", f" Obtained: {SOME_FLOAT}", - f" Expected: {SOME_FLOAT} ± {SOME_FLOAT}", + f" Expected: {SOME_FLOAT} ± {SOME_TOLERANCE}", ], ) @@ -119,9 +120,9 @@ def test_error_messages_native_dtypes(self, assert_approx_raises_regex): r" comparison failed. Mismatched elements: 2 / 3:", rf" Max absolute difference: {SOME_FLOAT}", rf" Max relative difference: {SOME_FLOAT}", - r" Index \| Obtained\s+\| Expected ", - rf" a \| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}", - rf" c \| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_FLOAT}", + r" Index \| Obtained\s+\| Expected\s+", + rf" a \| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_TOLERANCE}", + rf" c \| {SOME_FLOAT} \| {SOME_FLOAT} ± {SOME_TOLERANCE}", ], ) @@ -334,6 +335,11 @@ def test_repr_string(self): "approx({'b': 2.0 ± 2.0e-06, 'a': 1.0 ± 1.0e-06})", ) + assert repr(approx(42, abs=1)) == "42 ± 1" + assert repr(approx(5, rel=0.01)) == "5 ± 0.05" + assert repr(approx(24000, abs=500)) == "24000 ± 500" + assert repr(approx(1500, abs=555)) == "1500 ± 555" + def test_repr_complex_numbers(self): assert repr(approx(inf + 1j)) == "(inf+1j)" assert repr(approx(1.0j, rel=inf)) == "1j ± inf" @@ -347,7 +353,7 @@ def test_repr_complex_numbers(self): assert repr(approx(3 + 4 * 1j)) == "(3+4j) ± 5.0e-06 ∠ ±180°" # absolute tolerance is not scaled - assert repr(approx(3.3 + 4.4 * 1j, abs=0.02)) == "(3.3+4.4j) ± 2.0e-02 ∠ ±180°" + assert repr(approx(3.3 + 4.4 * 1j, abs=0.02)) == "(3.3+4.4j) ± 0.02 ∠ ±180°" @pytest.mark.parametrize( "value, expected_repr_string", From 69b7b83763a0086aa37e0b603e2b12e9be239010 Mon Sep 17 00:00:00 2001 From: pytest bot Date: Sun, 4 Aug 2024 00:22:52 +0000 Subject: [PATCH 022/445] [automated] Update plugin list --- doc/en/reference/plugin_list.rst | 146 ++++++++++++++++--------------- 1 file changed, 77 insertions(+), 69 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 4cec461b9eb..c031c6371c9 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =6.2.2) :pypi:`pytest-ai1899` pytest plugin for connecting to ai1899 smart system stack Mar 13, 2024 5 - Production/Stable N/A - :pypi:`pytest-aio` Pytest plugin for testing async python code Apr 08, 2024 5 - Production/Stable pytest + :pypi:`pytest-aio` Pytest plugin for testing async python code Jul 31, 2024 5 - Production/Stable pytest :pypi:`pytest-aiofiles` pytest fixtures for writing aiofiles tests with pyfakefs May 14, 2017 5 - Production/Stable N/A :pypi:`pytest-aiogram` May 06, 2023 N/A N/A :pypi:`pytest-aiohttp` Pytest plugin for aiohttp support Sep 06, 2023 4 - Beta pytest >=6.1.0 @@ -60,7 +60,7 @@ This list contains 1492 plugins. :pypi:`pytest-aioworkers` A plugin to test aioworkers project with pytest May 01, 2023 5 - Production/Stable pytest>=6.1.0 :pypi:`pytest-airflow` pytest support for airflow. Apr 03, 2019 3 - Alpha pytest (>=4.4.0) :pypi:`pytest-airflow-utils` Nov 15, 2021 N/A N/A - :pypi:`pytest-alembic` A pytest plugin for verifying alembic migrations. Mar 04, 2024 N/A pytest (>=6.0) + :pypi:`pytest-alembic` A pytest plugin for verifying alembic migrations. Jul 29, 2024 N/A pytest>=6.0 :pypi:`pytest-allclose` Pytest fixture extending Numpy's allclose function Jul 30, 2019 5 - Production/Stable pytest :pypi:`pytest-allure-adaptor` Plugin for py.test to generate allure xml reports Jan 10, 2018 N/A pytest (>=2.7.3) :pypi:`pytest-allure-adaptor2` Plugin for py.test to generate allure xml reports Oct 14, 2020 N/A pytest (>=2.7.3) @@ -78,7 +78,7 @@ This list contains 1492 plugins. :pypi:`pytest-ansible-playbook` Pytest fixture which runs given ansible playbook file. Mar 08, 2019 4 - Beta N/A :pypi:`pytest-ansible-playbook-runner` Pytest fixture which runs given ansible playbook file. Dec 02, 2020 4 - Beta pytest (>=3.1.0) :pypi:`pytest-ansible-units` A pytest plugin for running unit tests within an ansible collection Apr 14, 2022 N/A N/A - :pypi:`pytest-antilru` Bust functools.lru_cache when running pytest to avoid test pollution Jul 05, 2022 5 - Production/Stable pytest + :pypi:`pytest-antilru` Bust functools.lru_cache when running pytest to avoid test pollution Jul 28, 2024 5 - Production/Stable pytest>=7; python_version >= "3.10" :pypi:`pytest-anyio` The pytest anyio plugin is built into anyio. You don't need this package. Jun 29, 2021 N/A pytest :pypi:`pytest-anything` Pytest fixtures to assert anything and something Jan 18, 2024 N/A pytest :pypi:`pytest-aoc` Downloads puzzle inputs for Advent of Code and synthesizes PyTest fixtures Dec 02, 2023 5 - Production/Stable pytest ; extra == 'test' @@ -111,7 +111,7 @@ This list contains 1492 plugins. :pypi:`pytest-ast-transformer` May 04, 2019 3 - Alpha pytest :pypi:`pytest_async` pytest-async - Run your coroutine in event loop without decorator Feb 26, 2020 N/A N/A :pypi:`pytest-async-generators` Pytest fixtures for async generators Jul 05, 2023 N/A N/A - :pypi:`pytest-asyncio` Pytest support for asyncio Jul 17, 2024 4 - Beta pytest<9,>=7.0.0 + :pypi:`pytest-asyncio` Pytest support for asyncio Jul 30, 2024 4 - Beta pytest<9,>=7.0.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Jul 04, 2024 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) :pypi:`pytest-async-mongodb` pytest plugin for async MongoDB Oct 18, 2017 5 - Production/Stable pytest (>=2.5.2) @@ -123,18 +123,18 @@ This list contains 1492 plugins. :pypi:`pytest-austin` Austin plugin for pytest Oct 11, 2020 4 - Beta N/A :pypi:`pytest-autocap` automatically capture test & fixture stdout/stderr to files May 15, 2022 N/A pytest (<7.2,>=7.1.2) :pypi:`pytest-autochecklog` automatically check condition and log all the checks Apr 25, 2015 4 - Beta N/A - :pypi:`pytest-auto-fixture` ... Jul 23, 2024 N/A pytest>=8 + :pypi:`pytest-autofixture` simplify pytest fixtures Aug 01, 2024 N/A pytest>=8 :pypi:`pytest-automation` pytest plugin for building a test suite, using YAML files to extend pytest parameterize functionality. Apr 24, 2024 N/A pytest>=7.0.0 :pypi:`pytest-automock` Pytest plugin for automatical mocks creation May 16, 2023 N/A pytest ; extra == 'dev' :pypi:`pytest-auto-parametrize` pytest plugin: avoid repeating arguments in parametrize Oct 02, 2016 3 - Alpha N/A :pypi:`pytest-autotest` This fixture provides a configured "driver" for Android Automated Testing, using uiautomator2. Aug 25, 2021 N/A pytest - :pypi:`pytest-aux` templates/examples and aux for pytest Jul 26, 2024 N/A N/A + :pypi:`pytest-aux` templates/examples and aux for pytest Aug 02, 2024 N/A N/A :pypi:`pytest-aviator` Aviator's Flakybot pytest plugin that automatically reruns flaky tests. Nov 04, 2022 4 - Beta pytest :pypi:`pytest-avoidance` Makes pytest skip tests that don not need rerunning May 23, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-aws` pytest plugin for testing AWS resource configurations Oct 04, 2017 4 - Beta N/A :pypi:`pytest-aws-apigateway` pytest plugin for AWS ApiGateway May 24, 2024 4 - Beta pytest :pypi:`pytest-aws-config` Protect your AWS credentials in unit tests May 28, 2021 N/A N/A - :pypi:`pytest-aws-fixtures` A series of fixtures to use in integration tests involving actual AWS services. Jul 25, 2024 N/A pytest<9.0.0,>=8.0.0 + :pypi:`pytest-aws-fixtures` A series of fixtures to use in integration tests involving actual AWS services. Jul 30, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-axe` pytest plugin for axe-selenium-python Nov 12, 2018 N/A pytest (>=3.0.0) :pypi:`pytest-axe-playwright-snapshot` A pytest plugin that runs Axe-core on Playwright pages and takes snapshots of the results. Jul 25, 2023 N/A pytest :pypi:`pytest-azure` Pytest utilities and mocks for Azure Jan 18, 2023 3 - Alpha pytest @@ -154,7 +154,7 @@ This list contains 1492 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Jan 25, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Jul 25, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Aug 01, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -243,14 +243,14 @@ This list contains 1492 plugins. :pypi:`pytest-cleanslate` Collects and executes pytest tests separately Jun 17, 2024 N/A pytest :pypi:`pytest_cleanup` Automated, comprehensive and well-organised pytest test cases. Jan 28, 2020 N/A N/A :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Mar 19, 2024 5 - Production/Stable N/A - :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Jun 27, 2024 N/A pytest<9.0.0,>=8.0.0 + :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Jul 30, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-click` Pytest plugin for Click Feb 11, 2022 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-cli-fixtures` Automatically register fixtures for custom CLI arguments Jul 28, 2022 N/A pytest (~=7.0) :pypi:`pytest-clld` Jul 06, 2022 N/A pytest (>=3.6) :pypi:`pytest-cloud` Distributed tests planner plugin for pytest testing framework. Oct 05, 2020 6 - Mature N/A :pypi:`pytest-cloudflare-worker` pytest plugin for testing cloudflare workers Mar 30, 2021 4 - Beta pytest (>=6.0.0) :pypi:`pytest-cloudist` Distribute tests to cloud machines without fuss Sep 02, 2022 4 - Beta pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-cmake` Provide CMake module for Pytest May 31, 2024 N/A pytest<9,>=4 + :pypi:`pytest-cmake` Provide CMake module for Pytest Aug 01, 2024 N/A pytest<9,>=4 :pypi:`pytest-cmake-presets` Execute CMake Presets via pytest Dec 26, 2022 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-cobra` PyTest plugin for testing Smart Contracts for Ethereum blockchain. Jun 29, 2019 3 - Alpha pytest (<4.0.0,>=3.7.1) :pypi:`pytest_codeblocks` Test code blocks in your READMEs Sep 17, 2023 5 - Production/Stable pytest >= 7.0.0 @@ -289,7 +289,7 @@ This list contains 1492 plugins. :pypi:`pytest-cover` Pytest plugin for measuring coverage. Forked from \`pytest-cov\`. Aug 01, 2015 5 - Production/Stable N/A :pypi:`pytest-coverage` Jun 17, 2015 N/A N/A :pypi:`pytest-coverage-context` Coverage dynamic context support for PyTest, including sub-processes Jun 28, 2023 4 - Beta N/A - :pypi:`pytest-coveragemarkers` Using pytest markers to track functional coverage and filtering of tests Jun 04, 2024 N/A pytest<8.0.0,>=7.1.2 + :pypi:`pytest-coveragemarkers` Using pytest markers to track functional coverage and filtering of tests Jul 28, 2024 N/A pytest<8.0.0,>=7.1.2 :pypi:`pytest-cov-exclude` Pytest plugin for excluding tests based on coverage data Apr 29, 2016 4 - Beta pytest (>=2.8.0,<2.9.0); extra == 'dev' :pypi:`pytest_covid` Too many faillure, less tests. Jun 24, 2020 N/A N/A :pypi:`pytest-cpp` Use pytest's runner to discover and execute C++ tests Nov 01, 2023 5 - Production/Stable pytest >=7.0 @@ -329,7 +329,7 @@ This list contains 1492 plugins. :pypi:`pytest-datafixtures` Data fixtures for pytest made simple Dec 05, 2020 5 - Production/Stable N/A :pypi:`pytest-data-from-files` pytest plugin to provide data from files loaded automatically Oct 13, 2021 4 - Beta pytest :pypi:`pytest-dataplugin` A pytest plugin for managing an archive of test data. Sep 16, 2017 1 - Planning N/A - :pypi:`pytest-datarecorder` A py.test plugin recording and comparing test output. Feb 15, 2024 5 - Production/Stable pytest + :pypi:`pytest-datarecorder` A py.test plugin recording and comparing test output. Jul 31, 2024 5 - Production/Stable pytest :pypi:`pytest-dataset` Plugin for loading different datasets for pytest by prefix from json or yaml files Sep 01, 2023 5 - Production/Stable N/A :pypi:`pytest-data-suites` Class-based pytest parametrization Apr 06, 2024 N/A pytest<9.0,>=6.0 :pypi:`pytest-datatest` A pytest plugin for test driven data-wrangling (this is the development version of datatest's pytest integration). Oct 15, 2020 4 - Beta pytest (>=3.3) @@ -430,6 +430,7 @@ This list contains 1492 plugins. :pypi:`pytest-doorstop` A pytest plugin for adding test results into doorstop items. Jun 09, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-dotenv` A py.test plugin that parses environment files before running tests Jun 16, 2020 4 - Beta pytest (>=5.0.0) :pypi:`pytest-dot-only-pkcopley` A Pytest marker for only running a single test Oct 27, 2023 N/A N/A + :pypi:`pytest-dpg` pytest-dpg is a pytest plugin for testing Dear PyGui (DPG) applications. Aug 01, 2024 N/A N/A :pypi:`pytest-draw` Pytest plugin for randomly selecting a specific number of tests Mar 21, 2023 3 - Alpha pytest :pypi:`pytest-drf` A Django REST framework plugin for pytest. Jul 12, 2022 5 - Production/Stable pytest (>=3.7) :pypi:`pytest-drivings` Tool to allow webdriver automation to be ran locally or remotely Jan 13, 2021 N/A N/A @@ -456,14 +457,14 @@ This list contains 1492 plugins. :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. May 31, 2024 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. May 23, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. May 23, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. May 23, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. May 23, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. May 31, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. May 31, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. May 23, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Jul 31, 2024 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Jul 31, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Jul 31, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Jul 31, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Jul 31, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Jul 31, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Jul 31, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Jul 31, 2024 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -534,7 +535,7 @@ This list contains 1492 plugins. :pypi:`pytest-fastest` Use SCM and coverage to run only needed tests Oct 04, 2023 4 - Beta pytest (>=4.4) :pypi:`pytest-fast-first` Pytest plugin that runs fast tests first Jan 19, 2023 3 - Alpha pytest :pypi:`pytest-faulthandler` py.test plugin that activates the fault handler module for tests (dummy package) Jul 04, 2019 6 - Mature pytest (>=5.0) - :pypi:`pytest-fauna` A collection of helpful test fixtures for Fauna DB. May 30, 2024 N/A N/A + :pypi:`pytest-fauna` A collection of helpful test fixtures for Fauna DB. Jul 31, 2024 N/A N/A :pypi:`pytest-fauxfactory` Integration of fauxfactory into pytest. Dec 06, 2017 5 - Production/Stable pytest (>=3.2) :pypi:`pytest-figleaf` py.test figleaf coverage plugin Jan 18, 2010 5 - Production/Stable N/A :pypi:`pytest-file` Pytest File Mar 18, 2024 1 - Planning N/A @@ -580,7 +581,7 @@ This list contains 1492 plugins. :pypi:`pytest-forks` Fork helper for pytest Mar 05, 2024 N/A N/A :pypi:`pytest-forward-compatability` A name to avoid typosquating pytest-foward-compatibility Sep 06, 2020 N/A N/A :pypi:`pytest-forward-compatibility` A pytest plugin to shim pytest commandline options for fowards compatibility Sep 29, 2020 N/A N/A - :pypi:`pytest-frappe` Pytest Frappe Plugin - A set of pytest fixtures to test Frappe applications Oct 29, 2023 4 - Beta pytest>=7.0.0 + :pypi:`pytest-frappe` Pytest Frappe Plugin - A set of pytest fixtures to test Frappe applications Jul 30, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-freezeblaster` Wrap tests with fixtures in freeze_time Jul 10, 2024 N/A pytest>=6.2.5 :pypi:`pytest-freezegun` Wrap tests with fixtures in freeze_time Jul 19, 2020 4 - Beta pytest (>=3.0.0) :pypi:`pytest-freezer` Pytest plugin providing a fixture interface for spulec/freezegun Jun 21, 2023 N/A pytest >= 3.6 @@ -642,9 +643,9 @@ This list contains 1492 plugins. :pypi:`pytest-historic` Custom report to display pytest historical execution records Apr 08, 2020 N/A pytest :pypi:`pytest-historic-hook` Custom listener to store execution results into MYSQL DB, which is used for pytest-historic report Apr 08, 2020 N/A pytest :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) - :pypi:`pytest-home` Home directory fixtures Oct 09, 2023 5 - Production/Stable pytest + :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Jul 20, 2024 3 - Alpha pytest==8.2.0 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Jul 31, 2024 3 - Alpha pytest==8.2.0 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Apr 18, 2024 N/A N/A @@ -710,12 +711,12 @@ This list contains 1492 plugins. :pypi:`pytest-integration-mark` Automatic integration test marking and excluding plugin for pytest May 22, 2023 N/A pytest (>=5.2) :pypi:`pytest-interactive` A pytest plugin for console based interactive test selection just after the collection phase Nov 30, 2017 3 - Alpha N/A :pypi:`pytest-intercept-remote` Pytest plugin for intercepting outgoing connection requests during pytest run. May 24, 2021 4 - Beta pytest (>=4.6) - :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Feb 09, 2024 4 - Beta pytest + :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Jul 30, 2024 4 - Beta pytest :pypi:`pytest-invenio` Pytest fixtures for Invenio. Jun 27, 2024 5 - Production/Stable pytest<7.2.0,>=6 :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A - :pypi:`pytest-ipywidgets` Jul 23, 2024 N/A pytest + :pypi:`pytest-ipywidgets` Aug 02, 2024 N/A pytest :pypi:`pytest-isolate` Feb 20, 2023 4 - Beta pytest :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-it` Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it. Jan 29, 2024 4 - Beta N/A @@ -813,7 +814,7 @@ This list contains 1492 plugins. :pypi:`pytest-mark-manage` 用例标签化管理 Jul 08, 2024 N/A pytest :pypi:`pytest-mark-no-py3` pytest plugin and bowler codemod to help migrate tests to Python 3 May 17, 2019 N/A pytest :pypi:`pytest-marks` UNKNOWN Nov 23, 2012 3 - Alpha N/A - :pypi:`pytest-matcher` Easy way to match captured \`pytest\` output against expectations stored in files Mar 15, 2024 5 - Production/Stable pytest + :pypi:`pytest-matcher` Easy way to match captured \`pytest\` output against expectations stored in files Aug 01, 2024 5 - Production/Stable pytest :pypi:`pytest-match-skip` Skip matching marks. Matches partial marks using wildcards. May 15, 2019 4 - Beta pytest (>=4.4.1) :pypi:`pytest-mat-report` this is report Jan 20, 2021 N/A N/A :pypi:`pytest-matrix` Provide tools for generating tests from combinations of fixtures. Jun 24, 2020 5 - Production/Stable pytest (>=5.4.3,<6.0.0) @@ -867,10 +868,10 @@ This list contains 1492 plugins. :pypi:`pytest-motor` A pytest plugin for motor, the non-blocking MongoDB driver. Jul 21, 2021 3 - Alpha pytest :pypi:`pytest-mp` A test batcher for multiprocessed Pytest runs May 23, 2018 4 - Beta pytest :pypi:`pytest-mpi` pytest plugin to collect information from tests Jan 08, 2022 3 - Alpha pytest - :pypi:`pytest-mpiexec` pytest plugin for running individual tests with mpiexec Apr 13, 2023 3 - Alpha pytest + :pypi:`pytest-mpiexec` pytest plugin for running individual tests with mpiexec Jul 29, 2024 3 - Alpha pytest :pypi:`pytest-mpl` pytest plugin to help with testing figures output from Matplotlib Feb 14, 2024 4 - Beta pytest :pypi:`pytest-mproc` low-startup-overhead, scalable, distributed-testing pytest plugin Nov 15, 2022 4 - Beta pytest (>=6) - :pypi:`pytest-mqtt` pytest-mqtt supports testing systems based on MQTT May 08, 2024 4 - Beta pytest<9; extra == "test" + :pypi:`pytest-mqtt` pytest-mqtt supports testing systems based on MQTT Jul 29, 2024 4 - Beta pytest<9; extra == "test" :pypi:`pytest-multihost` Utility for writing multi-host tests for pytest Apr 07, 2020 4 - Beta N/A :pypi:`pytest-multilog` Multi-process logs handling and other helpers for pytest Jan 17, 2023 N/A pytest :pypi:`pytest-multithreading` a pytest plugin for th and concurrent testing Dec 07, 2022 N/A N/A @@ -1190,7 +1191,7 @@ This list contains 1492 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Jul 26, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Aug 03, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 :pypi:`pytest-schedule` The job of test scheduling for humans. Jan 07, 2023 5 - Production/Stable N/A @@ -1200,7 +1201,7 @@ This list contains 1492 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Jul 26, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Aug 03, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1370,7 +1371,7 @@ This list contains 1492 plugins. :pypi:`pytest-testslide` TestSlide fixture for pytest Jan 07, 2021 5 - Production/Stable pytest (~=6.2) :pypi:`pytest-test-this` Plugin for py.test to run relevant tests, based on naively checking if a test contains a reference to the symbol you supply Sep 15, 2019 2 - Pre-Alpha pytest (>=2.3) :pypi:`pytest-test-tracer-for-pytest` A plugin that allows coll test data for use on Test Tracer Jun 28, 2024 4 - Beta pytest>=6.2.0 - :pypi:`pytest-test-tracer-for-pytest-bdd` A plugin that allows coll test data for use on Test Tracer Jul 17, 2024 4 - Beta pytest>=6.2.0 + :pypi:`pytest-test-tracer-for-pytest-bdd` A plugin that allows coll test data for use on Test Tracer Jul 29, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-test-utils` Feb 08, 2024 N/A pytest >=3.9 :pypi:`pytest-tesults` Tesults plugin for pytest Feb 15, 2024 5 - Production/Stable pytest >=3.5.0 :pypi:`pytest-textual-snapshot` Snapshot testing for Textual apps Jul 22, 2024 4 - Beta pytest>=8.0.0 @@ -1644,7 +1645,7 @@ This list contains 1492 plugins. pytest plugin for connecting to ai1899 smart system stack :pypi:`pytest-aio` - *last release*: Apr 08, 2024, + *last release*: Jul 31, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -1714,9 +1715,9 @@ This list contains 1492 plugins. :pypi:`pytest-alembic` - *last release*: Mar 04, 2024, + *last release*: Jul 29, 2024, *status*: N/A, - *requires*: pytest (>=6.0) + *requires*: pytest>=6.0 A pytest plugin for verifying alembic migrations. @@ -1840,9 +1841,9 @@ This list contains 1492 plugins. A pytest plugin for running unit tests within an ansible collection :pypi:`pytest-antilru` - *last release*: Jul 05, 2022, + *last release*: Jul 28, 2024, *status*: 5 - Production/Stable, - *requires*: pytest + *requires*: pytest>=7; python_version >= "3.10" Bust functools.lru_cache when running pytest to avoid test pollution @@ -2071,7 +2072,7 @@ This list contains 1492 plugins. Pytest fixtures for async generators :pypi:`pytest-asyncio` - *last release*: Jul 17, 2024, + *last release*: Jul 30, 2024, *status*: 4 - Beta, *requires*: pytest<9,>=7.0.0 @@ -2154,12 +2155,12 @@ This list contains 1492 plugins. automatically check condition and log all the checks - :pypi:`pytest-auto-fixture` - *last release*: Jul 23, 2024, + :pypi:`pytest-autofixture` + *last release*: Aug 01, 2024, *status*: N/A, *requires*: pytest>=8 - ... + simplify pytest fixtures :pypi:`pytest-automation` *last release*: Apr 24, 2024, @@ -2190,7 +2191,7 @@ This list contains 1492 plugins. This fixture provides a configured "driver" for Android Automated Testing, using uiautomator2. :pypi:`pytest-aux` - *last release*: Jul 26, 2024, + *last release*: Aug 02, 2024, *status*: N/A, *requires*: N/A @@ -2232,7 +2233,7 @@ This list contains 1492 plugins. Protect your AWS credentials in unit tests :pypi:`pytest-aws-fixtures` - *last release*: Jul 25, 2024, + *last release*: Jul 30, 2024, *status*: N/A, *requires*: pytest<9.0.0,>=8.0.0 @@ -2372,7 +2373,7 @@ This list contains 1492 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Jul 25, 2024, + *last release*: Aug 01, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -2995,7 +2996,7 @@ This list contains 1492 plugins. A cleanup plugin for pytest :pypi:`pytest-clerk` - *last release*: Jun 27, 2024, + *last release*: Jul 30, 2024, *status*: N/A, *requires*: pytest<9.0.0,>=8.0.0 @@ -3044,7 +3045,7 @@ This list contains 1492 plugins. Distribute tests to cloud machines without fuss :pypi:`pytest-cmake` - *last release*: May 31, 2024, + *last release*: Aug 01, 2024, *status*: N/A, *requires*: pytest<9,>=4 @@ -3317,7 +3318,7 @@ This list contains 1492 plugins. Coverage dynamic context support for PyTest, including sub-processes :pypi:`pytest-coveragemarkers` - *last release*: Jun 04, 2024, + *last release*: Jul 28, 2024, *status*: N/A, *requires*: pytest<8.0.0,>=7.1.2 @@ -3597,7 +3598,7 @@ This list contains 1492 plugins. A pytest plugin for managing an archive of test data. :pypi:`pytest-datarecorder` - *last release*: Feb 15, 2024, + *last release*: Jul 31, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -4303,6 +4304,13 @@ This list contains 1492 plugins. A Pytest marker for only running a single test + :pypi:`pytest-dpg` + *last release*: Aug 01, 2024, + *status*: N/A, + *requires*: N/A + + pytest-dpg is a pytest plugin for testing Dear PyGui (DPG) applications. + :pypi:`pytest-draw` *last release*: Mar 21, 2023, *status*: 3 - Alpha, @@ -4486,56 +4494,56 @@ This list contains 1492 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: May 31, 2024, + *last release*: Jul 31, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: May 23, 2024, + *last release*: Jul 31, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: May 23, 2024, + *last release*: Jul 31, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: May 23, 2024, + *last release*: Jul 31, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. :pypi:`pytest-embedded-qemu` - *last release*: May 23, 2024, + *last release*: Jul 31, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: May 31, 2024, + *last release*: Jul 31, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: May 31, 2024, + *last release*: Jul 31, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: May 23, 2024, + *last release*: Jul 31, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -5032,7 +5040,7 @@ This list contains 1492 plugins. py.test plugin that activates the fault handler module for tests (dummy package) :pypi:`pytest-fauna` - *last release*: May 30, 2024, + *last release*: Jul 31, 2024, *status*: N/A, *requires*: N/A @@ -5354,7 +5362,7 @@ This list contains 1492 plugins. A pytest plugin to shim pytest commandline options for fowards compatibility :pypi:`pytest-frappe` - *last release*: Oct 29, 2023, + *last release*: Jul 30, 2024, *status*: 4 - Beta, *requires*: pytest>=7.0.0 @@ -5788,7 +5796,7 @@ This list contains 1492 plugins. Pytest plugin to keep a history of your pytest runs :pypi:`pytest-home` - *last release*: Oct 09, 2023, + *last release*: Jul 28, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -5802,7 +5810,7 @@ This list contains 1492 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Jul 20, 2024, + *last release*: Jul 31, 2024, *status*: 3 - Alpha, *requires*: pytest==8.2.0 @@ -6264,7 +6272,7 @@ This list contains 1492 plugins. Pytest plugin for intercepting outgoing connection requests during pytest run. :pypi:`pytest-interface-tester` - *last release*: Feb 09, 2024, + *last release*: Jul 30, 2024, *status*: 4 - Beta, *requires*: pytest @@ -6299,7 +6307,7 @@ This list contains 1492 plugins. THIS PROJECT IS ABANDONED :pypi:`pytest-ipywidgets` - *last release*: Jul 23, 2024, + *last release*: Aug 02, 2024, *status*: N/A, *requires*: pytest @@ -6985,7 +6993,7 @@ This list contains 1492 plugins. UNKNOWN :pypi:`pytest-matcher` - *last release*: Mar 15, 2024, + *last release*: Aug 01, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -7363,7 +7371,7 @@ This list contains 1492 plugins. pytest plugin to collect information from tests :pypi:`pytest-mpiexec` - *last release*: Apr 13, 2023, + *last release*: Jul 29, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -7384,7 +7392,7 @@ This list contains 1492 plugins. low-startup-overhead, scalable, distributed-testing pytest plugin :pypi:`pytest-mqtt` - *last release*: May 08, 2024, + *last release*: Jul 29, 2024, *status*: 4 - Beta, *requires*: pytest<9; extra == "test" @@ -9624,7 +9632,7 @@ This list contains 1492 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Jul 26, 2024, + *last release*: Aug 03, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9694,7 +9702,7 @@ This list contains 1492 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Jul 26, 2024, + *last release*: Aug 03, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10884,7 +10892,7 @@ This list contains 1492 plugins. A plugin that allows coll test data for use on Test Tracer :pypi:`pytest-test-tracer-for-pytest-bdd` - *last release*: Jul 17, 2024, + *last release*: Jul 29, 2024, *status*: 4 - Beta, *requires*: pytest>=6.2.0 From bc1e17e90c5324797b4ebc5fd229d2662ad15e6e Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 5 Aug 2024 10:40:42 -0300 Subject: [PATCH 023/445] Obey verbosity level when printing 'msg' part of assertions (#12662) Seems like we just missed that case when more fine-grained verbosity levels were added. Fixes #6682, #12307 --- changelog/6682.bugfix.rst | 1 + src/_pytest/assertion/rewrite.py | 2 +- testing/test_assertrewrite.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 changelog/6682.bugfix.rst diff --git a/changelog/6682.bugfix.rst b/changelog/6682.bugfix.rst new file mode 100644 index 00000000000..7f756cbd9c2 --- /dev/null +++ b/changelog/6682.bugfix.rst @@ -0,0 +1 @@ +Fixed bug where the verbosity levels where not being respected when printing the "msg" part of failed assertion (as in ``assert condition, msg``). diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index bfcbcbd3f8d..f7ff4f6f7a2 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -451,7 +451,7 @@ def _format_assertmsg(obj: object) -> str: # However in either case we want to preserve the newline. replaces = [("\n", "\n~"), ("%", "%%")] if not isinstance(obj, str): - obj = saferepr(obj) + obj = saferepr(obj, _get_maxsize_for_saferepr(util._config)) replaces.append(("\\n", "\n~")) for r1, r2 in replaces: diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index 5ee40ee6568..11688acb6f5 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -341,6 +341,34 @@ def test_assertion_messages_bytes(self, pytester: Pytester) -> None: assert result.ret == 1 result.stdout.fnmatch_lines(["*AssertionError: b'ohai!'", "*assert False"]) + def test_assertion_message_verbosity(self, pytester: Pytester) -> None: + """ + Obey verbosity levels when printing the "message" part of assertions, when they are + non-strings (#6682). + """ + pytester.makepyfile( + """ + class LongRepr: + + def __repr__(self): + return "A" * 500 + + def test_assertion_verbosity(): + assert False, LongRepr() + """ + ) + # Normal verbosity: assertion message gets abbreviated. + result = pytester.runpytest() + assert result.ret == 1 + result.stdout.re_match_lines( + [r".*AssertionError: A+\.\.\.A+$", ".*assert False"] + ) + + # High-verbosity: do not abbreviate the assertion message. + result = pytester.runpytest("-vv") + assert result.ret == 1 + result.stdout.re_match_lines([r".*AssertionError: A+$", ".*assert False"]) + def test_boolop(self) -> None: def f1() -> None: f = g = False From 2b99703acace3194a7e28c05a097d06d29949aa9 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 6 Aug 2024 07:44:13 -0300 Subject: [PATCH 024/445] Add merge/squash guidelines to CONTRIBUTING.rst (#12672) As discussed in https://github.com/pytest-dev/pytest/discussions/12633. --- CONTRIBUTING.rst | 55 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 12e2b18bb52..6e96fd24c40 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -380,6 +380,57 @@ pull requests from other contributors yourself after having reviewed them. +Merge/squash guidelines +----------------------- + +When a PR is approved and ready to be integrated to the ``main`` branch, one has the option to *merge* the commits unchanged, or *squash* all the commits into a single commit. + +Here are some guidelines on how to proceed, based on examples of a single PR commit history: + +1. Miscellaneous commits: + + * ``Implement X`` + * ``Fix test_a`` + * ``Add myself to AUTHORS`` + * ``fixup! Fix test_a`` + * ``Update tests/test_integration.py`` + * ``Merge origin/main into PR branch`` + * ``Update tests/test_integration.py`` + + In this case, prefer to use the **Squash** merge strategy: the commit history is a bit messy (not in a derogatory way, often one just commits changes because they know the changes will eventually be squashed together), so squashing everything into a single commit is best. You must clean up the commit message, making sure it contains useful details. + +2. Separate commits related to the same topic: + + * ``Implement X`` + * ``Add myself to AUTHORS`` + * ``Update CHANGELOG for X`` + + In this case, prefer to use the **Squash** merge strategy: while the commit history is not "messy" as in the example above, the individual commits do not bring much value overall, specially when looking at the changes a few months/years down the line. + +3. Separate commits, each with their own topic (refactorings, renames, etc), but still have a larger topic/purpose. + + * ``Refactor class X in preparation for feature Y`` + * ``Remove unused method`` + * ``Implement feature Y`` + + In this case, prefer to use the **Merge** strategy: each commit is valuable on its own, even if they serve a common topic overall. Looking at the history later, it is useful to have the removal of the unused method separately on its own commit, along with more information (such as how it became unused in the first place). + +4. Separate commits, each with their own topic, but without a larger topic/purpose other than improve the code base (using more modern techniques, improve typing, removing clutter, etc). + + * ``Improve internal names in X`` + * ``Add type annotations to Y`` + * ``Remove unnecessary dict access`` + * ``Remove unreachable code due to EOL Python`` + + In this case, prefer to use the **Merge** strategy: each commit is valuable on its own, and the information on each is valuable in the long term. + + +As mentioned, those are overall guidelines, not rules cast in stone. This topic was discussed in `#12633 `_. + + +*Backport PRs* (as those created automatically from a ``backport`` label) should always be **squashed**, as they preserve the original PR author. + + Backporting bug fixes for the next patch release ------------------------------------------------ @@ -438,6 +489,8 @@ above? All the above are not rules, but merely some guidelines/suggestions on what we should expect about backports. +Backports should be **squashed** (rather than **merged**), as doing so preserves the original PR author correctly. + Handling stale issues/PRs ------------------------- @@ -485,7 +538,7 @@ When closing a Pull Request, it needs to be acknowledging the time, effort, and -Closing Issues +Closing issues -------------- When a pull request is submitted to fix an issue, add text like ``closes #XYZW`` to the PR description and/or commits (where ``XYZW`` is the issue number). See the `GitHub docs `_ for more information. From 85760bff2776989b365167c7aeb35c86308ab76b Mon Sep 17 00:00:00 2001 From: Daniel Miller Date: Tue, 6 Aug 2024 06:47:27 -0400 Subject: [PATCH 025/445] Apply pythonpath option as early as possible (#12536) This allows plugins loaded via '-p' to benefit from the new PYTHONPATH, making the option useful in more cases and less surprising. For this to work it was required for the functionality to be part of Config rather than a separate plugin, which is unfortunate but in the end considered a small price to pay. Fix #11118. --------- Co-authored-by: Bruno Oliveira --- changelog/11118.improvement.rst | 3 +++ doc/en/reference/reference.rst | 5 ----- src/_pytest/config/__init__.py | 17 ++++++++++++++++- src/_pytest/python_path.py | 26 -------------------------- testing/test_config.py | 1 - testing/test_python_path.py | 33 +++++++++++++++++++++++++-------- 6 files changed, 44 insertions(+), 41 deletions(-) create mode 100644 changelog/11118.improvement.rst delete mode 100644 src/_pytest/python_path.py diff --git a/changelog/11118.improvement.rst b/changelog/11118.improvement.rst new file mode 100644 index 00000000000..4760dbe9d64 --- /dev/null +++ b/changelog/11118.improvement.rst @@ -0,0 +1,3 @@ +Now :confval:`pythonpath` configures `$PYTHONPATH` earlier than before during the initialization process, which now also affects plugins loaded via the `-p` command-line option. + +-- by :user:`millerdev` diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 7ea5921f581..c1f94957d9c 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1796,11 +1796,6 @@ passed multiple times. The expected format is ``name=value``. For example:: [pytest] pythonpath = src1 src2 - .. note:: - - ``pythonpath`` does not affect some imports that happen very early, - most notably plugins loaded using the ``-p`` command line option. - .. confval:: required_plugins diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 0c1850df503..fbb5fb6fdea 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -268,7 +268,6 @@ def directory_arg(path: str, optname: str) -> str: "warnings", "logging", "reports", - "python_path", "unraisableexception", "threadexception", "faulthandler", @@ -1245,6 +1244,9 @@ def _initini(self, args: Sequence[str]) -> None: self._parser.extra_info["inifile"] = str(self.inipath) self._parser.addini("addopts", "Extra command line options", "args") self._parser.addini("minversion", "Minimally required pytest version") + self._parser.addini( + "pythonpath", type="paths", help="Add paths to sys.path", default=[] + ) self._parser.addini( "required_plugins", "Plugins that must be present for pytest to run", @@ -1294,6 +1296,18 @@ def _mark_plugins_for_rewrite(self, hook) -> None: for name in _iter_rewritable_modules(package_files): hook.mark_rewrite(name) + def _configure_python_path(self) -> None: + # `pythonpath = a b` will set `sys.path` to `[a, b, x, y, z, ...]` + for path in reversed(self.getini("pythonpath")): + sys.path.insert(0, str(path)) + self.add_cleanup(self._unconfigure_python_path) + + def _unconfigure_python_path(self) -> None: + for path in self.getini("pythonpath"): + path_str = str(path) + if path_str in sys.path: + sys.path.remove(path_str) + def _validate_args(self, args: list[str], via: str) -> list[str]: """Validate known args.""" self._parser._config_source_hint = via # type: ignore @@ -1370,6 +1384,7 @@ def _preparse(self, args: list[str], addopts: bool = True) -> None: ) self._checkversion() self._consider_importhook(args) + self._configure_python_path() self.pluginmanager.consider_preparse(args, exclude_only=False) if not os.environ.get("PYTEST_DISABLE_PLUGIN_AUTOLOAD"): # Don't autoload from distribution package entry point. Only diff --git a/src/_pytest/python_path.py b/src/_pytest/python_path.py deleted file mode 100644 index 6e33c8a39f2..00000000000 --- a/src/_pytest/python_path.py +++ /dev/null @@ -1,26 +0,0 @@ -from __future__ import annotations - -import sys - -import pytest -from pytest import Config -from pytest import Parser - - -def pytest_addoption(parser: Parser) -> None: - parser.addini("pythonpath", type="paths", help="Add paths to sys.path", default=[]) - - -@pytest.hookimpl(tryfirst=True) -def pytest_load_initial_conftests(early_config: Config) -> None: - # `pythonpath = a b` will set `sys.path` to `[a, b, x, y, z, ...]` - for path in reversed(early_config.getini("pythonpath")): - sys.path.insert(0, str(path)) - - -@pytest.hookimpl(trylast=True) -def pytest_unconfigure(config: Config) -> None: - for path in config.getini("pythonpath"): - path_str = str(path) - if path_str in sys.path: - sys.path.remove(path_str) diff --git a/testing/test_config.py b/testing/test_config.py index 232839399e2..aa3e4147927 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -1409,7 +1409,6 @@ def pytest_load_initial_conftests(self): ("_pytest.config", "nonwrapper"), (m.__module__, "nonwrapper"), ("_pytest.legacypath", "nonwrapper"), - ("_pytest.python_path", "nonwrapper"), ("_pytest.capture", "wrapper"), ("_pytest.warnings", "wrapper"), ] diff --git a/testing/test_python_path.py b/testing/test_python_path.py index 1db02252d22..d12ef96115f 100644 --- a/testing/test_python_path.py +++ b/testing/test_python_path.py @@ -3,7 +3,6 @@ import sys from textwrap import dedent -from typing import Generator from _pytest.pytester import Pytester import pytest @@ -62,6 +61,27 @@ def test_two_dirs(pytester: Pytester, file_structure) -> None: result.assert_outcomes(passed=2) +def test_local_plugin(pytester: Pytester, file_structure) -> None: + """`pythonpath` kicks early enough to load plugins via -p (#11118).""" + localplugin_py = pytester.path / "sub" / "localplugin.py" + content = dedent( + """ + def pytest_load_initial_conftests(): + print("local plugin load") + + def pytest_unconfigure(): + print("local plugin unconfig") + """ + ) + localplugin_py.write_text(content, encoding="utf-8") + + pytester.makeini("[pytest]\npythonpath=sub\n") + result = pytester.runpytest("-plocalplugin", "-s", "test_foo.py") + result.stdout.fnmatch_lines(["local plugin load", "local plugin unconfig"]) + assert result.ret == 0 + result.assert_outcomes(passed=1) + + def test_module_not_found(pytester: Pytester, file_structure) -> None: """Without the pythonpath setting, the module should not be found.""" pytester.makefile(".ini", pytest="[pytest]\n") @@ -95,16 +115,13 @@ def test_clean_up(pytester: Pytester) -> None: after: list[str] | None = None class Plugin: - @pytest.hookimpl(wrapper=True, tryfirst=True) - def pytest_unconfigure(self) -> Generator[None, None, None]: - nonlocal before, after + @pytest.hookimpl(tryfirst=True) + def pytest_unconfigure(self) -> None: + nonlocal before before = sys.path.copy() - try: - return (yield) - finally: - after = sys.path.copy() result = pytester.runpytest_inprocess(plugins=[Plugin()]) + after = sys.path.copy() assert result.ret == 0 assert before is not None From a01dca5321c899dd01f01c6ff698af87d86b9fd3 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 6 Aug 2024 14:01:38 -0300 Subject: [PATCH 026/445] Add Pierre to official contacts (#12694) As part of onboarding Pierre to the core team. Also add contacts in alphabetical order --- doc/en/contact.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/en/contact.rst b/doc/en/contact.rst index ef9d1e8edca..d650a7efbab 100644 --- a/doc/en/contact.rst +++ b/doc/en/contact.rst @@ -33,10 +33,11 @@ Mail discussed in public. Mails sent there will be distributed among the members in the pytest core team, who can also be contacted individually: - * Ronny Pfannschmidt (:user:`RonnyPfannschmidt`, `ronny@pytest.org `_) - * Florian Bruhin (:user:`The-Compiler`, `florian@pytest.org `_) * Bruno Oliveira (:user:`nicoddemus`, `bruno@pytest.org `_) + * Florian Bruhin (:user:`The-Compiler`, `florian@pytest.org `_) + * Pierre Sassoulas (:user:`Pierre-Sassoulas`, `pierre@pytest.org `_) * Ran Benita (:user:`bluetech`, `ran@pytest.org `_) + * Ronny Pfannschmidt (:user:`RonnyPfannschmidt`, `ronny@pytest.org `_) * Zac Hatfield-Dodds (:user:`Zac-HD`, `zac@pytest.org `_) Other From 4aa43d5521c011e3612031c46abc1ad9133beff4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 23:10:25 +0000 Subject: [PATCH 027/445] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.5 → v0.5.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.5...v0.5.6) - [github.com/pre-commit/mirrors-mypy: v1.11.0 → v1.11.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.11.0...v1.11.1) - [github.com/tox-dev/pyproject-fmt: 2.1.4 → 2.2.1](https://github.com/tox-dev/pyproject-fmt/compare/2.1.4...2.2.1) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aaa28d6b7c4..5348fdde93d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.5.5" + rev: "v0.5.6" hooks: - id: ruff args: ["--fix"] @@ -21,7 +21,7 @@ repos: hooks: - id: python-use-type-annotations - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.0 + rev: v1.11.1 hooks: - id: mypy files: ^(src/|testing/|scripts/) @@ -38,7 +38,7 @@ repos: # on <3.11 - exceptiongroup>=1.0.0rc8 - repo: https://github.com/tox-dev/pyproject-fmt - rev: "2.1.4" + rev: "2.2.1" hooks: - id: pyproject-fmt # https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version From 127544b9b6c761348f5b90053fae72dbccadfed2 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 7 Aug 2024 08:42:58 -0300 Subject: [PATCH 028/445] Replace types-pkg-resources by types-setuptools According to https://pypi.org/project/types-pkg-resources/#history, that package has been supplanted by `types-setuptools`. --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5348fdde93d..f27c46f3a54 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,7 +32,7 @@ repos: - pluggy>=1.5.0 - packaging - tomli - - types-pkg_resources + - types-setuptools - types-tabulate # for mypy running on python>=3.11 since exceptiongroup is only a dependency # on <3.11 From ef9b8f9d748b6f50eab5d43e32d93008f7880899 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Aug 2024 22:33:50 +0200 Subject: [PATCH 029/445] build(deps): Bump django in /testing/plugins_integration (#12698) Bumps [django](https://github.com/django/django) from 5.0.7 to 5.0.8. - [Commits](https://github.com/django/django/compare/5.0.7...5.0.8) --- updated-dependencies: - dependency-name: django dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index cdb3e7264a0..512c20c6450 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,5 +1,5 @@ anyio[curio,trio]==4.4.0 -django==5.0.7 +django==5.0.8 pytest-asyncio==0.23.8 pytest-bdd==7.2.0 pytest-cov==5.0.0 From 49eafce55bf31c1993db9f411bc2d669804d5bb3 Mon Sep 17 00:00:00 2001 From: Eugene Mwangi Date: Fri, 9 Aug 2024 18:23:03 +0300 Subject: [PATCH 030/445] docs: Revise `cache_dir` option section (#12701) Update the description for the `cache_dir` configuration options section to improve semantics and clarity for an unclear sentence in the file `reference.rst`. --- doc/en/reference/reference.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index c1f94957d9c..f7dfb3ffa71 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1294,10 +1294,10 @@ passed multiple times. The expected format is ``name=value``. For example:: .. confval:: cache_dir - Sets a directory where stores content of cache plugin. Default directory is + Sets the directory where the cache plugin's content is stored. Default directory is ``.pytest_cache`` which is created in :ref:`rootdir `. Directory may be relative or absolute path. If setting relative path, then directory is created - relative to :ref:`rootdir `. Additionally path may contain environment + relative to :ref:`rootdir `. Additionally, a path may contain environment variables, that will be expanded. For more information about cache plugin please refer to :ref:`cache_provider`. From cb98538e9c2ba3c65baf07432229d97fd5a29657 Mon Sep 17 00:00:00 2001 From: Reagan Lee <96998476+reaganjlee@users.noreply.github.com> Date: Fri, 9 Aug 2024 08:26:34 -0700 Subject: [PATCH 031/445] Fix `errisinstance` typing (#12700) Fixes #12667 --- changelog/12667.bugfix.rst | 1 + src/_pytest/_code/code.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog/12667.bugfix.rst diff --git a/changelog/12667.bugfix.rst b/changelog/12667.bugfix.rst new file mode 100644 index 00000000000..eceee86cb53 --- /dev/null +++ b/changelog/12667.bugfix.rst @@ -0,0 +1 @@ +Fixed a regression where type change in `ExceptionInfo.errisinstance` caused `mypy` to fail. diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index e7452825756..8fac39ea298 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -56,7 +56,7 @@ TracebackStyle = Literal["long", "short", "line", "no", "native", "value", "auto"] -EXCEPTION_OR_MORE = Union[Type[Exception], Tuple[Type[Exception], ...]] +EXCEPTION_OR_MORE = Union[Type[BaseException], Tuple[Type[BaseException], ...]] class Code: From 6a3ac51ee2350d5072fdd082040e7cfa22331fc0 Mon Sep 17 00:00:00 2001 From: Sadra Barikbin Date: Sun, 11 Aug 2024 08:06:32 +0330 Subject: [PATCH 032/445] Revert the unintended change in tests reordering from #11220 (#12542) In #11220, an unintended change in reordering was introduced by changing the way indices were assigned to direct params. This PR reverts that change and reduces #11220 changes to just refactors. After this PR we could safely decide on the solutions discussed in #12008, i.e. #12082 or the one initially introduced in #11220 . Fixes #12008 Co-authored-by: Bruno Oliveira Co-authored-by: Bruno Oliveira --- changelog/12008.bugfix.rst | 1 + src/_pytest/python.py | 10 ++++++++++ testing/example_scripts/issue_519.py | 4 ++-- testing/python/metafunc.py | 6 +++--- 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 changelog/12008.bugfix.rst diff --git a/changelog/12008.bugfix.rst b/changelog/12008.bugfix.rst new file mode 100644 index 00000000000..b9680b89236 --- /dev/null +++ b/changelog/12008.bugfix.rst @@ -0,0 +1 @@ +In :pr:`11220`, an unintended change in reordering was introduced by changing the way indices were assigned to direct params. More specifically, before that change, the indices of direct params to metafunc's callspecs were assigned after all parametrizations took place. Now, that change is reverted. diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 9182ce7dfe9..094113bd1b4 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -464,6 +464,7 @@ def _genfunctions(self, name: str, funcobj) -> Iterator[Function]: if not metafunc._calls: yield Function.from_parent(self, name=name, fixtureinfo=fixtureinfo) else: + metafunc._recompute_direct_params_indices() # Direct parametrizations taking place in module/class-specific # `metafunc.parametrize` calls may have shadowed some fixtures, so make sure # we update what the function really needs a.k.a its fixture closure. Note that @@ -1131,6 +1132,8 @@ def __init__( # Result of parametrize(). self._calls: list[CallSpec2] = [] + self._params_directness: dict[str, Literal["indirect", "direct"]] = {} + def parametrize( self, argnames: str | Sequence[str], @@ -1273,6 +1276,7 @@ def parametrize( name2pseudofixturedef_key, default ) arg_directness = self._resolve_args_directness(argnames, indirect) + self._params_directness.update(arg_directness) for argname in argnames: if arg_directness[argname] == "indirect": continue @@ -1445,6 +1449,12 @@ def _validate_if_using_arg_names( pytrace=False, ) + def _recompute_direct_params_indices(self) -> None: + for argname, param_type in self._params_directness.items(): + if param_type == "direct": + for i, callspec in enumerate(self._calls): + callspec.indices[argname] = i + def _find_parametrized_scope( argnames: Sequence[str], diff --git a/testing/example_scripts/issue_519.py b/testing/example_scripts/issue_519.py index 138c07e95be..da5f5ad6aa9 100644 --- a/testing/example_scripts/issue_519.py +++ b/testing/example_scripts/issue_519.py @@ -23,13 +23,13 @@ def checked_order(): assert order == [ ("issue_519.py", "fix1", "arg1v1"), ("test_one[arg1v1-arg2v1]", "fix2", "arg2v1"), - ("test_one[arg1v1-arg2v2]", "fix2", "arg2v2"), ("test_two[arg1v1-arg2v1]", "fix2", "arg2v1"), + ("test_one[arg1v1-arg2v2]", "fix2", "arg2v2"), ("test_two[arg1v1-arg2v2]", "fix2", "arg2v2"), ("issue_519.py", "fix1", "arg1v2"), ("test_one[arg1v2-arg2v1]", "fix2", "arg2v1"), - ("test_one[arg1v2-arg2v2]", "fix2", "arg2v2"), ("test_two[arg1v2-arg2v1]", "fix2", "arg2v1"), + ("test_one[arg1v2-arg2v2]", "fix2", "arg2v2"), ("test_two[arg1v2-arg2v2]", "fix2", "arg2v2"), ] diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 2dd85607e71..be224d9e20b 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -1005,14 +1005,14 @@ def test3(arg1): result.stdout.re_match_lines( [ r" ", - r" ", r" ", + r" ", + r" ", r" ", + r" ", r" ", - r" ", r" ", r" ", - r" ", r" ", ] ) From ccd1f95602c0730046afc0e6dcf8ff3cbcb499a4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 06:26:15 +0200 Subject: [PATCH 033/445] build(deps): Bump twisted in /testing/plugins_integration (#12711) Bumps [twisted](https://github.com/twisted/twisted) from 24.3.0 to 24.7.0. - [Release notes](https://github.com/twisted/twisted/releases) - [Changelog](https://github.com/twisted/twisted/blob/trunk/NEWS.rst) - [Commits](https://github.com/twisted/twisted/compare/twisted-24.3.0...twisted-24.7.0) --- updated-dependencies: - dependency-name: twisted dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 512c20c6450..edab9c4261d 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -11,5 +11,5 @@ pytest-rerunfailures==14.0 pytest-sugar==1.0.0 pytest-trio==0.8.0 pytest-twisted==1.14.2 -twisted==24.3.0 +twisted==24.7.0 pytest-xvfb==3.0.0 From 9446f024df846eefb8f2213d2854f7ec5552822a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 06:26:55 +0200 Subject: [PATCH 034/445] build(deps): Bump django in /testing/plugins_integration (#12710) Bumps [django](https://github.com/django/django) from 5.0.8 to 5.1. - [Commits](https://github.com/django/django/compare/5.0.8...5.1) --- updated-dependencies: - dependency-name: django dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index edab9c4261d..bd554c6307d 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,5 +1,5 @@ anyio[curio,trio]==4.4.0 -django==5.0.8 +django==5.1 pytest-asyncio==0.23.8 pytest-bdd==7.2.0 pytest-cov==5.0.0 From 38ad84bafd18d15ceff1960d636c693560337844 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 11:29:43 +0000 Subject: [PATCH 035/445] [automated] Update plugin list (#12709) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 184 ++++++++++++++++++------------- 1 file changed, 108 insertions(+), 76 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index c031c6371c9..6aea0dd86c0 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =3.5.0) :pypi:`pytest-aws` pytest plugin for testing AWS resource configurations Oct 04, 2017 4 - Beta N/A @@ -148,12 +148,12 @@ This list contains 1493 plugins. :pypi:`pytest-bdd` BDD for pytest Jun 04, 2024 6 - Mature pytest>=6.2.0 :pypi:`pytest-bdd-html` pytest plugin to display BDD info in HTML test report Nov 22, 2022 3 - Alpha pytest (!=6.0.0,>=5.0) :pypi:`pytest-bdd-ng` BDD for pytest Dec 31, 2023 4 - Beta pytest >=5.0 - :pypi:`pytest-bdd-report` A pytest-bdd plugin for generating useful and informative BDD test reports May 20, 2024 N/A pytest >=7.1.3 + :pypi:`pytest-bdd-report` A pytest-bdd plugin for generating useful and informative BDD test reports Aug 04, 2024 N/A pytest>=7.1.3 :pypi:`pytest-bdd-splinter` Common steps for pytest bdd and splinter integration Aug 12, 2019 5 - Production/Stable pytest (>=4.0.0) :pypi:`pytest-bdd-web` A simple plugin to use with pytest Jan 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest - :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Jan 25, 2024 N/A pytest + :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Aug 08, 2024 N/A pytest :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Aug 01, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A @@ -169,7 +169,7 @@ This list contains 1493 plugins. :pypi:`pytest-black-multipy` Allow '--black' on older Pythons Jan 14, 2021 5 - Production/Stable pytest (!=3.7.3,>=3.5) ; extra == 'testing' :pypi:`pytest-black-ng` A pytest plugin to enable format checking with black Oct 20, 2022 4 - Beta pytest (>=7.0.0) :pypi:`pytest-blame` A pytest plugin helps developers to debug by providing useful commits history. May 04, 2019 N/A pytest (>=4.4.0) - :pypi:`pytest-blender` Blender Pytest plugin. Aug 10, 2023 N/A pytest ; extra == 'dev' + :pypi:`pytest-blender` Blender Pytest plugin. Aug 02, 2024 N/A pytest :pypi:`pytest-blink1` Pytest plugin to emit notifications via the Blink(1) RGB LED Jan 07, 2018 4 - Beta N/A :pypi:`pytest-blockage` Disable network requests during a test run. Dec 21, 2021 N/A pytest :pypi:`pytest-blocker` pytest plugin to mark a test as blocker and skip all other tests Sep 07, 2015 4 - Beta N/A @@ -250,7 +250,7 @@ This list contains 1493 plugins. :pypi:`pytest-cloud` Distributed tests planner plugin for pytest testing framework. Oct 05, 2020 6 - Mature N/A :pypi:`pytest-cloudflare-worker` pytest plugin for testing cloudflare workers Mar 30, 2021 4 - Beta pytest (>=6.0.0) :pypi:`pytest-cloudist` Distribute tests to cloud machines without fuss Sep 02, 2022 4 - Beta pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-cmake` Provide CMake module for Pytest Aug 01, 2024 N/A pytest<9,>=4 + :pypi:`pytest-cmake` Provide CMake module for Pytest Aug 09, 2024 N/A pytest<9,>=4 :pypi:`pytest-cmake-presets` Execute CMake Presets via pytest Dec 26, 2022 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-cobra` PyTest plugin for testing Smart Contracts for Ethereum blockchain. Jun 29, 2019 3 - Alpha pytest (<4.0.0,>=3.7.1) :pypi:`pytest_codeblocks` Test code blocks in your READMEs Sep 17, 2023 5 - Production/Stable pytest >= 7.0.0 @@ -317,7 +317,7 @@ This list contains 1493 plugins. :pypi:`pytest-dash` pytest fixtures to run dash applications. Mar 18, 2019 N/A N/A :pypi:`pytest-dashboard` May 30, 2024 N/A pytest<8.0.0,>=7.4.3 :pypi:`pytest-data` Useful functions for managing data for pytest fixtures Nov 01, 2016 5 - Production/Stable N/A - :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Jul 02, 2024 4 - Beta pytest + :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Aug 07, 2024 4 - Beta pytest :pypi:`pytest-databricks` Pytest plugin for remote Databricks notebooks testing Jul 29, 2020 N/A pytest :pypi:`pytest-datadir` pytest plugin for test data directories and files Oct 03, 2023 5 - Production/Stable pytest >=5.0 :pypi:`pytest-datadir-mgr` Manager for test data: downloads, artifact caching, and a tmpdir context. Apr 06, 2023 5 - Production/Stable pytest (>=7.1) @@ -430,7 +430,7 @@ This list contains 1493 plugins. :pypi:`pytest-doorstop` A pytest plugin for adding test results into doorstop items. Jun 09, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-dotenv` A py.test plugin that parses environment files before running tests Jun 16, 2020 4 - Beta pytest (>=5.0.0) :pypi:`pytest-dot-only-pkcopley` A Pytest marker for only running a single test Oct 27, 2023 N/A N/A - :pypi:`pytest-dpg` pytest-dpg is a pytest plugin for testing Dear PyGui (DPG) applications. Aug 01, 2024 N/A N/A + :pypi:`pytest-dpg` pytest-dpg is a pytest plugin for testing Dear PyGui (DPG) applications Aug 07, 2024 N/A N/A :pypi:`pytest-draw` Pytest plugin for randomly selecting a specific number of tests Mar 21, 2023 3 - Alpha pytest :pypi:`pytest-drf` A Django REST framework plugin for pytest. Jul 12, 2022 5 - Production/Stable pytest (>=3.7) :pypi:`pytest-drivings` Tool to allow webdriver automation to be ran locally or remotely Jan 13, 2021 N/A N/A @@ -457,14 +457,14 @@ This list contains 1493 plugins. :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Jul 31, 2024 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Jul 31, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Jul 31, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Jul 31, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Jul 31, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Jul 31, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Jul 31, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Jul 31, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Aug 09, 2024 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Aug 09, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Aug 09, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Aug 09, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Aug 09, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Aug 09, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Aug 09, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Aug 09, 2024 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -493,7 +493,7 @@ This list contains 1493 plugins. :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Jul 02, 2024 4 - Beta pytest>=7 :pypi:`pytest-exasol-itde` Jul 01, 2024 N/A pytest<9,>=7 - :pypi:`pytest-exasol-saas` Jun 07, 2024 N/A pytest<9,>=7 + :pypi:`pytest-exasol-saas` Aug 06, 2024 N/A pytest<9,>=7 :pypi:`pytest-excel` pytest plugin for generating excel reports Jun 18, 2024 5 - Production/Stable pytest>3.6 :pypi:`pytest-exceptional` Better exceptions Mar 16, 2017 4 - Beta N/A :pypi:`pytest-exception-script` Walk your code through exception script to check it's resiliency to failures. Aug 04, 2020 3 - Alpha pytest @@ -633,7 +633,7 @@ This list contains 1493 plugins. :pypi:`pytest-harmony` Chain tests and data with pytest Jan 17, 2023 N/A pytest (>=7.2.1,<8.0.0) :pypi:`pytest-harvest` Store data created during your pytest tests execution, and retrieve it at the end of the session, e.g. for applicative benchmarking purposes. Mar 16, 2024 5 - Production/Stable N/A :pypi:`pytest-helm-charts` A plugin to provide different types and configs of Kubernetes clusters that can be used for testing. Feb 07, 2024 4 - Beta pytest (>=8.0.0,<9.0.0) - :pypi:`pytest-helm-templates` Pytest fixtures for unit testing the output of helm templates May 08, 2024 N/A pytest~=7.4.0; extra == "dev" + :pypi:`pytest-helm-templates` Pytest fixtures for unit testing the output of helm templates Aug 07, 2024 N/A pytest~=7.4.0; extra == "dev" :pypi:`pytest-helper` Functions to help in using the pytest testing framework May 31, 2019 5 - Production/Stable N/A :pypi:`pytest-helpers` pytest helpers May 17, 2020 N/A pytest :pypi:`pytest-helpers-namespace` Pytest Helpers Namespace Plugin Dec 29, 2021 5 - Production/Stable pytest (>=6.0.0) @@ -645,7 +645,7 @@ This list contains 1493 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Jul 31, 2024 3 - Alpha pytest==8.2.0 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Aug 08, 2024 3 - Alpha pytest==8.3.1 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Apr 18, 2024 N/A N/A @@ -711,7 +711,7 @@ This list contains 1493 plugins. :pypi:`pytest-integration-mark` Automatic integration test marking and excluding plugin for pytest May 22, 2023 N/A pytest (>=5.2) :pypi:`pytest-interactive` A pytest plugin for console based interactive test selection just after the collection phase Nov 30, 2017 3 - Alpha N/A :pypi:`pytest-intercept-remote` Pytest plugin for intercepting outgoing connection requests during pytest run. May 24, 2021 4 - Beta pytest (>=4.6) - :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Jul 30, 2024 4 - Beta pytest + :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Aug 09, 2024 4 - Beta pytest :pypi:`pytest-invenio` Pytest fixtures for Invenio. Jun 27, 2024 5 - Production/Stable pytest<7.2.0,>=6 :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A @@ -745,6 +745,7 @@ This list contains 1493 plugins. :pypi:`pytest-jupyterhub` A reusable JupyterHub pytest plugin Apr 25, 2023 5 - Production/Stable pytest :pypi:`pytest-kafka` Zookeeper, Kafka server, and Kafka consumer fixtures for Pytest Jun 14, 2023 N/A pytest :pypi:`pytest-kafkavents` A plugin to send pytest events to Kafka Sep 08, 2021 4 - Beta pytest + :pypi:`pytest-kairos` Pytest plugin with random number generation, reproducibility, and test repetition Aug 08, 2024 5 - Production/Stable pytest>=5.0.0 :pypi:`pytest-kasima` Display horizontal lines above and below the captured standard output for easy viewing. Jan 26, 2023 5 - Production/Stable pytest (>=7.2.1,<8.0.0) :pypi:`pytest-keep-together` Pytest plugin to customize test ordering by running all 'related' tests together Dec 07, 2022 5 - Production/Stable pytest :pypi:`pytest-kexi` Apr 29, 2022 N/A pytest (>=7.1.2,<8.0.0) @@ -798,7 +799,7 @@ This list contains 1493 plugins. :pypi:`pytest-logger` Plugin configuring handlers for loggers from Python logging module. Mar 10, 2024 5 - Production/Stable pytest (>=3.2) :pypi:`pytest-logging` Configures logging and allows tweaking the log level with a py.test flag Nov 04, 2015 4 - Beta N/A :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-logikal` Common testing environment Jun 27, 2024 5 - Production/Stable pytest==8.2.2 + :pypi:`pytest-logikal` Common testing environment Aug 08, 2024 5 - Production/Stable pytest==8.3.2 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Jul 19, 2024 4 - Beta N/A :pypi:`pytest-loguru` Pytest Loguru Mar 20, 2024 5 - Production/Stable pytest; extra == "test" @@ -814,6 +815,7 @@ This list contains 1493 plugins. :pypi:`pytest-mark-manage` 用例标签化管理 Jul 08, 2024 N/A pytest :pypi:`pytest-mark-no-py3` pytest plugin and bowler codemod to help migrate tests to Python 3 May 17, 2019 N/A pytest :pypi:`pytest-marks` UNKNOWN Nov 23, 2012 3 - Alpha N/A + :pypi:`pytest-mask-secrets` Pytest plugin to hide sensitive data in test reports Aug 06, 2024 N/A N/A :pypi:`pytest-matcher` Easy way to match captured \`pytest\` output against expectations stored in files Aug 01, 2024 5 - Production/Stable pytest :pypi:`pytest-match-skip` Skip matching marks. Matches partial marks using wildcards. May 15, 2019 4 - Beta pytest (>=4.4.1) :pypi:`pytest-mat-report` this is report Jan 20, 2021 N/A N/A @@ -835,7 +837,7 @@ This list contains 1493 plugins. :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A :pypi:`pytest-metadata` pytest plugin for test session metadata Feb 12, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-metrics` Custom metrics report for pytest Apr 04, 2020 N/A pytest - :pypi:`pytest-mh` Pytest multihost plugin Jul 02, 2024 N/A pytest + :pypi:`pytest-mh` Pytest multihost plugin Aug 02, 2024 N/A pytest :pypi:`pytest-mimesis` Mimesis integration with the pytest test runner Mar 21, 2020 5 - Production/Stable pytest (>=4.2) :pypi:`pytest-minecraft` A pytest plugin for running tests against Minecraft releases Apr 06, 2022 N/A pytest (>=6.0.1) :pypi:`pytest-mini` A plugin to test mp Feb 06, 2023 N/A pytest (>=7.2.0,<8.0.0) @@ -874,7 +876,7 @@ This list contains 1493 plugins. :pypi:`pytest-mqtt` pytest-mqtt supports testing systems based on MQTT Jul 29, 2024 4 - Beta pytest<9; extra == "test" :pypi:`pytest-multihost` Utility for writing multi-host tests for pytest Apr 07, 2020 4 - Beta N/A :pypi:`pytest-multilog` Multi-process logs handling and other helpers for pytest Jan 17, 2023 N/A pytest - :pypi:`pytest-multithreading` a pytest plugin for th and concurrent testing Dec 07, 2022 N/A N/A + :pypi:`pytest-multithreading` a pytest plugin for th and concurrent testing Aug 05, 2024 N/A N/A :pypi:`pytest-multithreading-allure` pytest_multithreading_allure Nov 25, 2022 N/A N/A :pypi:`pytest-mutagen` Add the mutation testing feature to pytest Jul 24, 2020 N/A pytest (>=5.4) :pypi:`pytest-my-cool-lib` Nov 02, 2023 N/A pytest (>=7.1.3,<8.0.0) @@ -889,6 +891,7 @@ This list contains 1493 plugins. :pypi:`pytest-needle` pytest plugin for visual testing websites using selenium Dec 10, 2018 4 - Beta pytest (<5.0.0,>=3.0.0) :pypi:`pytest-neo` pytest-neo is a plugin for pytest that shows tests like screen of Matrix. Jan 08, 2022 3 - Alpha pytest (>=6.2.0) :pypi:`pytest-neos` Pytest plugin for neos Jun 11, 2024 1 - Planning N/A + :pypi:`pytest-netconf` A pytest plugin that provides a mock NETCONF (RFC6241/RFC6242) server for local testing. Aug 08, 2024 N/A N/A :pypi:`pytest-netdut` "Automated software testing for switches using pytest" Jul 05, 2024 N/A pytest<7.3,>=3.5.0 :pypi:`pytest-network` A simple plugin to disable network on socket level. May 07, 2020 N/A N/A :pypi:`pytest-network-endpoints` Network endpoints plugin for pytest Mar 06, 2022 N/A pytest @@ -900,8 +903,8 @@ This list contains 1493 plugins. :pypi:`pytest-nhsd-apim` Pytest plugin accessing NHSDigital's APIM proxies Jul 01, 2024 N/A pytest<9.0.0,>=8.2.0 :pypi:`pytest-nice` A pytest plugin that alerts user of failed test cases with screen notifications May 04, 2019 4 - Beta pytest :pypi:`pytest-nice-parametrize` A small snippet for nicer PyTest's Parametrize Apr 17, 2021 5 - Production/Stable N/A - :pypi:`pytest_nlcov` Pytest plugin to get the coverage of the new lines (based on git diff) only Apr 11, 2024 N/A N/A - :pypi:`pytest-nocustom` Run all tests without custom markers Apr 11, 2024 5 - Production/Stable N/A + :pypi:`pytest_nlcov` Pytest plugin to get the coverage of the new lines (based on git diff) only Aug 05, 2024 N/A N/A + :pypi:`pytest-nocustom` Run all tests without custom markers Aug 05, 2024 5 - Production/Stable N/A :pypi:`pytest-node-dependency` pytest plugin for controlling execution flow Apr 10, 2024 5 - Production/Stable N/A :pypi:`pytest-nodev` Test-driven source code search for Python. Jul 21, 2016 4 - Beta pytest (>=2.8.1) :pypi:`pytest-nogarbage` Ensure a test produces no garbage Aug 29, 2021 5 - Production/Stable pytest (>=4.6.0) @@ -954,6 +957,7 @@ This list contains 1493 plugins. :pypi:`pytest-parametrized` Pytest decorator for parametrizing tests with default iterables. Nov 03, 2023 5 - Production/Stable pytest :pypi:`pytest-parametrize-suite` A simple pytest extension for creating a named test suite. Jan 19, 2023 5 - Production/Stable pytest :pypi:`pytest_param_files` Create pytest parametrize decorators from external files. Jul 29, 2023 N/A pytest + :pypi:`pytest-params` Simplified pytest test case parameters. Aug 05, 2024 N/A pytest>=7.0.0 :pypi:`pytest-param-scope` pytest parametrize scope fixture workaround Oct 18, 2023 N/A pytest :pypi:`pytest-parawtf` Finally spell paramete?ri[sz]e correctly Dec 03, 2018 4 - Beta pytest (>=3.6.0) :pypi:`pytest-pass` Check out https://github.com/elilutsky/pytest-pass Dec 04, 2019 N/A N/A @@ -1119,7 +1123,7 @@ This list contains 1493 plugins. :pypi:`pytest-repo-health` A pytest plugin to report on repository standards conformance Apr 17, 2023 3 - Alpha pytest :pypi:`pytest-report` Creates json report that is compatible with atom.io's linter message format May 11, 2016 4 - Beta N/A :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest - :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Jun 28, 2024 4 - Beta N/A + :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Aug 08, 2024 4 - Beta N/A :pypi:`pytest-reporter-html-dots` A basic HTML report for pytest using Jinja2 template engine. Jan 22, 2023 N/A N/A :pypi:`pytest-reportinfra` Pytest plugin for reportinfra Aug 11, 2019 3 - Alpha N/A :pypi:`pytest-reporting` A plugin to report summarized results in a table format Oct 25, 2019 4 - Beta pytest (>=3.5.0) @@ -1191,7 +1195,7 @@ This list contains 1493 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Aug 03, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Aug 07, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 :pypi:`pytest-schedule` The job of test scheduling for humans. Jan 07, 2023 5 - Production/Stable N/A @@ -1201,7 +1205,7 @@ This list contains 1493 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Aug 03, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Aug 07, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1212,7 +1216,7 @@ This list contains 1493 plugins. :pypi:`pytest-server-fixtures` Extensible server fixures for py.test Dec 19, 2023 5 - Production/Stable pytest :pypi:`pytest-serverless` Automatically mocks resources from serverless.yml in pytest using moto. May 09, 2022 4 - Beta N/A :pypi:`pytest-servers` pytest servers Jul 19, 2024 3 - Alpha pytest>=6.2 - :pypi:`pytest-service` May 11, 2024 5 - Production/Stable pytest>=6.0.0 + :pypi:`pytest-service` Aug 06, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-services` Services plugin for pytest testing framework Oct 30, 2020 6 - Mature N/A :pypi:`pytest-session2file` pytest-session2file (aka: pytest-session_to_file for v0.1.0 - v0.1.2) is a py.test plugin for capturing and saving to file the stdout of py.test. Jan 26, 2021 3 - Alpha pytest :pypi:`pytest-session-fixture-globalize` py.test plugin to make session fixtures behave as if written in conftest, even if it is written in some modules May 15, 2018 4 - Beta N/A @@ -1267,7 +1271,7 @@ This list contains 1493 plugins. :pypi:`pytest-sourceorder` Test-ordering plugin for pytest Sep 01, 2021 4 - Beta pytest :pypi:`pytest-spark` pytest plugin to run the tests with support of pyspark. Feb 23, 2020 4 - Beta pytest :pypi:`pytest-spawner` py.test plugin to spawn process and communicate with them. Jul 31, 2015 4 - Beta N/A - :pypi:`pytest-spec` Library pytest-spec is a pytest plugin to display test execution output like a SPECIFICATION. May 04, 2021 N/A N/A + :pypi:`pytest-spec` Library pytest-spec is a pytest plugin to display test execution output like a SPECIFICATION. Aug 04, 2024 N/A pytest; extra == "test" :pypi:`pytest-spec2md` Library pytest-spec2md is a pytest plugin to create a markdown specification while running pytest. Apr 10, 2024 N/A pytest>7.0 :pypi:`pytest-speed` Modern benchmarking library for python with pytest integration. Jan 22, 2023 3 - Alpha pytest>=7 :pypi:`pytest-sphinx` Doctest plugin for pytest with support for Sphinx-specific doctest-directives Apr 13, 2024 4 - Beta pytest>=8.1.1 @@ -1279,7 +1283,7 @@ This list contains 1493 plugins. :pypi:`pytest-splitio` Split.io SDK integration for e2e tests Sep 22, 2020 N/A pytest (<7,>=5.0) :pypi:`pytest-split-tests` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Forked from Mark Adams' original project pytest-test-groups. Jul 30, 2021 5 - Production/Stable pytest (>=2.5) :pypi:`pytest-split-tests-tresorit` Feb 22, 2021 1 - Planning N/A - :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Jul 24, 2024 N/A pytest<8,>5.4.0 + :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Aug 07, 2024 N/A pytest<8,>5.4.0 :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Jul 10, 2024 N/A N/A :pypi:`pytest-splunk-env` pytest fixtures for interaction with Splunk Enterprise and Splunk Cloud Oct 22, 2020 N/A pytest (>=6.1.1,<7.0.0) :pypi:`pytest-sqitch` sqitch for pytest Apr 06, 2020 4 - Beta N/A @@ -1293,7 +1297,7 @@ This list contains 1493 plugins. :pypi:`pytest-ssh` pytest plugin for ssh command run May 27, 2019 N/A pytest :pypi:`pytest-start-from` Start pytest run from a given point Apr 11, 2016 N/A N/A :pypi:`pytest-star-track-issue` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A - :pypi:`pytest-static` pytest-static Jun 20, 2024 1 - Planning pytest<8.0.0,>=7.4.3 + :pypi:`pytest-static` pytest-static Aug 09, 2024 1 - Planning pytest<8.0.0,>=7.4.3 :pypi:`pytest-stats` Collects tests metadata for future analysis, easy to extend for any data store Jul 18, 2024 N/A pytest>=8.0.0 :pypi:`pytest-statsd` pytest plugin for reporting to graphite Nov 30, 2018 5 - Production/Stable pytest (>=3.0.0) :pypi:`pytest-stepfunctions` A small description May 08, 2021 4 - Beta pytest @@ -1496,8 +1500,8 @@ This list contains 1493 plugins. :pypi:`pytest-xfiles` Pytest fixtures providing data read from function, module or package related (x)files. Feb 27, 2018 N/A N/A :pypi:`pytest-xiuyu` This is a pytest plugin Jul 25, 2023 5 - Production/Stable N/A :pypi:`pytest-xlog` Extended logging for test and decorators May 31, 2020 4 - Beta N/A - :pypi:`pytest-xlsx` pytest plugin for generating test cases by xlsx(excel) Apr 23, 2024 N/A pytest~=7.0 - :pypi:`pytest-xpara` An extended parametrizing plugin of pytest. Oct 30, 2017 3 - Alpha pytest + :pypi:`pytest-xlsx` pytest plugin for generating test cases by xlsx(excel) Aug 07, 2024 N/A pytest~=8.2.2 + :pypi:`pytest-xpara` An extended parametrizing plugin of pytest. Aug 07, 2024 3 - Alpha pytest :pypi:`pytest-xprocess` A pytest plugin for managing processes across test runs. May 19, 2024 4 - Beta pytest>=2.8 :pypi:`pytest-xray` May 30, 2019 3 - Alpha N/A :pypi:`pytest-xrayjira` Mar 17, 2020 3 - Alpha pytest (==4.3.1) @@ -1507,7 +1511,7 @@ This list contains 1493 plugins. :pypi:`pytest-xvfb` A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. May 29, 2023 4 - Beta pytest (>=2.8.1) :pypi:`pytest-xvirt` A pytest plugin to virtualize test. For example to transparently running them on a remote box. Jul 03, 2024 4 - Beta pytest>=7.2.2 :pypi:`pytest-yaml` This plugin is used to load yaml output to your test using pytest framework. Oct 05, 2018 N/A pytest - :pypi:`pytest-yaml-sanmu` Pytest plugin for generating test cases with YAML. In test cases, you can use markers, fixtures, variables, and even call Python functions. Jul 20, 2024 N/A pytest~=8.2.2 + :pypi:`pytest-yaml-sanmu` Pytest plugin for generating test cases with YAML. In test cases, you can use markers, fixtures, variables, and even call Python functions. Aug 03, 2024 N/A pytest~=8.2.2 :pypi:`pytest-yamltree` Create or check file/directory trees described by YAML Mar 02, 2020 4 - Beta pytest (>=3.1.1) :pypi:`pytest-yamlwsgi` Run tests against wsgi apps defined in yaml May 11, 2010 N/A N/A :pypi:`pytest-yaml-yoyo` http/https API run by yaml Jun 19, 2023 N/A pytest (>=7.2.0) @@ -2191,7 +2195,7 @@ This list contains 1493 plugins. This fixture provides a configured "driver" for Android Automated Testing, using uiautomator2. :pypi:`pytest-aux` - *last release*: Aug 02, 2024, + *last release*: Aug 06, 2024, *status*: N/A, *requires*: N/A @@ -2331,9 +2335,9 @@ This list contains 1493 plugins. BDD for pytest :pypi:`pytest-bdd-report` - *last release*: May 20, 2024, + *last release*: Aug 04, 2024, *status*: N/A, - *requires*: pytest >=7.1.3 + *requires*: pytest>=7.1.3 A pytest-bdd plugin for generating useful and informative BDD test reports @@ -2366,7 +2370,7 @@ This list contains 1493 plugins. A pytest plugin that reports test results to the BeakerLib framework :pypi:`pytest-beartype` - *last release*: Jan 25, 2024, + *last release*: Aug 08, 2024, *status*: N/A, *requires*: pytest @@ -2478,9 +2482,9 @@ This list contains 1493 plugins. A pytest plugin helps developers to debug by providing useful commits history. :pypi:`pytest-blender` - *last release*: Aug 10, 2023, + *last release*: Aug 02, 2024, *status*: N/A, - *requires*: pytest ; extra == 'dev' + *requires*: pytest Blender Pytest plugin. @@ -3045,7 +3049,7 @@ This list contains 1493 plugins. Distribute tests to cloud machines without fuss :pypi:`pytest-cmake` - *last release*: Aug 01, 2024, + *last release*: Aug 09, 2024, *status*: N/A, *requires*: pytest<9,>=4 @@ -3514,7 +3518,7 @@ This list contains 1493 plugins. Useful functions for managing data for pytest fixtures :pypi:`pytest-databases` - *last release*: Jul 02, 2024, + *last release*: Aug 07, 2024, *status*: 4 - Beta, *requires*: pytest @@ -4305,11 +4309,11 @@ This list contains 1493 plugins. A Pytest marker for only running a single test :pypi:`pytest-dpg` - *last release*: Aug 01, 2024, + *last release*: Aug 07, 2024, *status*: N/A, *requires*: N/A - pytest-dpg is a pytest plugin for testing Dear PyGui (DPG) applications. + pytest-dpg is a pytest plugin for testing Dear PyGui (DPG) applications :pypi:`pytest-draw` *last release*: Mar 21, 2023, @@ -4494,56 +4498,56 @@ This list contains 1493 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: Jul 31, 2024, + *last release*: Aug 09, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: Jul 31, 2024, + *last release*: Aug 09, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: Jul 31, 2024, + *last release*: Aug 09, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: Jul 31, 2024, + *last release*: Aug 09, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. :pypi:`pytest-embedded-qemu` - *last release*: Jul 31, 2024, + *last release*: Aug 09, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: Jul 31, 2024, + *last release*: Aug 09, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: Jul 31, 2024, + *last release*: Aug 09, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: Jul 31, 2024, + *last release*: Aug 09, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -4746,7 +4750,7 @@ This list contains 1493 plugins. :pypi:`pytest-exasol-saas` - *last release*: Jun 07, 2024, + *last release*: Aug 06, 2024, *status*: N/A, *requires*: pytest<9,>=7 @@ -5726,7 +5730,7 @@ This list contains 1493 plugins. A plugin to provide different types and configs of Kubernetes clusters that can be used for testing. :pypi:`pytest-helm-templates` - *last release*: May 08, 2024, + *last release*: Aug 07, 2024, *status*: N/A, *requires*: pytest~=7.4.0; extra == "dev" @@ -5810,9 +5814,9 @@ This list contains 1493 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Jul 31, 2024, + *last release*: Aug 08, 2024, *status*: 3 - Alpha, - *requires*: pytest==8.2.0 + *requires*: pytest==8.3.1 Experimental package to automatically extract test plugins for Home Assistant custom components @@ -6272,7 +6276,7 @@ This list contains 1493 plugins. Pytest plugin for intercepting outgoing connection requests during pytest run. :pypi:`pytest-interface-tester` - *last release*: Jul 30, 2024, + *last release*: Aug 09, 2024, *status*: 4 - Beta, *requires*: pytest @@ -6509,6 +6513,13 @@ This list contains 1493 plugins. A plugin to send pytest events to Kafka + :pypi:`pytest-kairos` + *last release*: Aug 08, 2024, + *status*: 5 - Production/Stable, + *requires*: pytest>=5.0.0 + + Pytest plugin with random number generation, reproducibility, and test repetition + :pypi:`pytest-kasima` *last release*: Jan 26, 2023, *status*: 5 - Production/Stable, @@ -6881,9 +6892,9 @@ This list contains 1493 plugins. :pypi:`pytest-logikal` - *last release*: Jun 27, 2024, + *last release*: Aug 08, 2024, *status*: 5 - Production/Stable, - *requires*: pytest==8.2.2 + *requires*: pytest==8.3.2 Common testing environment @@ -6992,6 +7003,13 @@ This list contains 1493 plugins. UNKNOWN + :pypi:`pytest-mask-secrets` + *last release*: Aug 06, 2024, + *status*: N/A, + *requires*: N/A + + Pytest plugin to hide sensitive data in test reports + :pypi:`pytest-matcher` *last release*: Aug 01, 2024, *status*: 5 - Production/Stable, @@ -7140,7 +7158,7 @@ This list contains 1493 plugins. Custom metrics report for pytest :pypi:`pytest-mh` - *last release*: Jul 02, 2024, + *last release*: Aug 02, 2024, *status*: N/A, *requires*: pytest @@ -7413,7 +7431,7 @@ This list contains 1493 plugins. Multi-process logs handling and other helpers for pytest :pypi:`pytest-multithreading` - *last release*: Dec 07, 2022, + *last release*: Aug 05, 2024, *status*: N/A, *requires*: N/A @@ -7517,6 +7535,13 @@ This list contains 1493 plugins. Pytest plugin for neos + :pypi:`pytest-netconf` + *last release*: Aug 08, 2024, + *status*: N/A, + *requires*: N/A + + A pytest plugin that provides a mock NETCONF (RFC6241/RFC6242) server for local testing. + :pypi:`pytest-netdut` *last release*: Jul 05, 2024, *status*: N/A, @@ -7595,14 +7620,14 @@ This list contains 1493 plugins. A small snippet for nicer PyTest's Parametrize :pypi:`pytest_nlcov` - *last release*: Apr 11, 2024, + *last release*: Aug 05, 2024, *status*: N/A, *requires*: N/A Pytest plugin to get the coverage of the new lines (based on git diff) only :pypi:`pytest-nocustom` - *last release*: Apr 11, 2024, + *last release*: Aug 05, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -7972,6 +7997,13 @@ This list contains 1493 plugins. Create pytest parametrize decorators from external files. + :pypi:`pytest-params` + *last release*: Aug 05, 2024, + *status*: N/A, + *requires*: pytest>=7.0.0 + + Simplified pytest test case parameters. + :pypi:`pytest-param-scope` *last release*: Oct 18, 2023, *status*: N/A, @@ -9128,7 +9160,7 @@ This list contains 1493 plugins. Generate Pytest reports with templates :pypi:`pytest-reporter-html1` - *last release*: Jun 28, 2024, + *last release*: Aug 08, 2024, *status*: 4 - Beta, *requires*: N/A @@ -9632,7 +9664,7 @@ This list contains 1493 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Aug 03, 2024, + *last release*: Aug 07, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9702,7 +9734,7 @@ This list contains 1493 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Aug 03, 2024, + *last release*: Aug 07, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9779,7 +9811,7 @@ This list contains 1493 plugins. pytest servers :pypi:`pytest-service` - *last release*: May 11, 2024, + *last release*: Aug 06, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=6.0.0 @@ -10164,9 +10196,9 @@ This list contains 1493 plugins. py.test plugin to spawn process and communicate with them. :pypi:`pytest-spec` - *last release*: May 04, 2021, + *last release*: Aug 04, 2024, *status*: N/A, - *requires*: N/A + *requires*: pytest; extra == "test" Library pytest-spec is a pytest plugin to display test execution output like a SPECIFICATION. @@ -10248,7 +10280,7 @@ This list contains 1493 plugins. :pypi:`pytest-splunk-addon` - *last release*: Jul 24, 2024, + *last release*: Aug 07, 2024, *status*: N/A, *requires*: pytest<8,>5.4.0 @@ -10346,7 +10378,7 @@ This list contains 1493 plugins. A package to prevent Dependency Confusion attacks against Yandex. :pypi:`pytest-static` - *last release*: Jun 20, 2024, + *last release*: Aug 09, 2024, *status*: 1 - Planning, *requires*: pytest<8.0.0,>=7.4.3 @@ -11767,14 +11799,14 @@ This list contains 1493 plugins. Extended logging for test and decorators :pypi:`pytest-xlsx` - *last release*: Apr 23, 2024, + *last release*: Aug 07, 2024, *status*: N/A, - *requires*: pytest~=7.0 + *requires*: pytest~=8.2.2 pytest plugin for generating test cases by xlsx(excel) :pypi:`pytest-xpara` - *last release*: Oct 30, 2017, + *last release*: Aug 07, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -11844,7 +11876,7 @@ This list contains 1493 plugins. This plugin is used to load yaml output to your test using pytest framework. :pypi:`pytest-yaml-sanmu` - *last release*: Jul 20, 2024, + *last release*: Aug 03, 2024, *status*: N/A, *requires*: pytest~=8.2.2 From b08b41cefb5e83271a055bf6a22c79d52a06a8c3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 14 Aug 2024 21:53:50 +0200 Subject: [PATCH 036/445] [pre-commit.ci] pre-commit autoupdate (#12712) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.6 → v0.5.7](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.6...v0.5.7) * Apply pyupgrade latest changes Co-authored-by: Pierre Sassoulas --- .pre-commit-config.yaml | 2 +- src/_pytest/cacheprovider.py | 6 ++---- src/_pytest/capture.py | 22 +++++++++++----------- src/_pytest/doctest.py | 2 +- src/_pytest/logging.py | 22 ++++++++++------------ src/_pytest/monkeypatch.py | 4 ++-- src/_pytest/pytester.py | 4 ++-- src/_pytest/python.py | 8 ++++---- src/_pytest/recwarn.py | 2 +- src/_pytest/skipping.py | 2 +- src/_pytest/terminal.py | 4 ++-- src/_pytest/threadexception.py | 8 ++++---- src/_pytest/tmpdir.py | 2 +- src/_pytest/unittest.py | 4 ++-- src/_pytest/unraisableexception.py | 8 ++++---- src/_pytest/warnings.py | 8 ++++---- testing/conftest.py | 2 +- testing/io/test_terminalwriter.py | 4 +--- testing/test_assertrewrite.py | 2 +- testing/test_cacheprovider.py | 2 +- testing/test_capture.py | 2 +- testing/test_conftest.py | 4 +--- testing/test_monkeypatch.py | 2 +- testing/test_pathlib.py | 2 +- 24 files changed, 60 insertions(+), 68 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f27c46f3a54..0e36d1e6137 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.5.6" + rev: "v0.5.7" hooks: - id: ruff args: ["--fix"] diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index 20bb262e05d..7190810570e 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -369,7 +369,7 @@ def pytest_collectreport(self, report: CollectReport) -> None: @hookimpl(wrapper=True, tryfirst=True) def pytest_collection_modifyitems( self, config: Config, items: list[nodes.Item] - ) -> Generator[None, None, None]: + ) -> Generator[None]: res = yield if not self.active: @@ -439,9 +439,7 @@ def __init__(self, config: Config) -> None: self.cached_nodeids = set(config.cache.get("cache/nodeids", [])) @hookimpl(wrapper=True, tryfirst=True) - def pytest_collection_modifyitems( - self, items: list[nodes.Item] - ) -> Generator[None, None, None]: + def pytest_collection_modifyitems(self, items: list[nodes.Item]) -> Generator[None]: res = yield if self.active: diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index b9652843279..506c0b3d287 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -135,7 +135,7 @@ def _reopen_stdio(f, mode): @hookimpl(wrapper=True) -def pytest_load_initial_conftests(early_config: Config) -> Generator[None, None, None]: +def pytest_load_initial_conftests(early_config: Config) -> Generator[None]: ns = early_config.known_args_namespace if ns.capture == "fd": _windowsconsoleio_workaround(sys.stdout) @@ -818,7 +818,7 @@ def resume_fixture(self) -> None: # Helper context managers @contextlib.contextmanager - def global_and_fixture_disabled(self) -> Generator[None, None, None]: + def global_and_fixture_disabled(self) -> Generator[None]: """Context manager to temporarily disable global and current fixture capturing.""" do_fixture = self._capture_fixture and self._capture_fixture._is_started() if do_fixture: @@ -835,7 +835,7 @@ def global_and_fixture_disabled(self) -> Generator[None, None, None]: self.resume_fixture() @contextlib.contextmanager - def item_capture(self, when: str, item: Item) -> Generator[None, None, None]: + def item_capture(self, when: str, item: Item) -> Generator[None]: self.resume_global_capture() self.activate_fixture() try: @@ -870,17 +870,17 @@ def pytest_make_collect_report( return rep @hookimpl(wrapper=True) - def pytest_runtest_setup(self, item: Item) -> Generator[None, None, None]: + def pytest_runtest_setup(self, item: Item) -> Generator[None]: with self.item_capture("setup", item): return (yield) @hookimpl(wrapper=True) - def pytest_runtest_call(self, item: Item) -> Generator[None, None, None]: + def pytest_runtest_call(self, item: Item) -> Generator[None]: with self.item_capture("call", item): return (yield) @hookimpl(wrapper=True) - def pytest_runtest_teardown(self, item: Item) -> Generator[None, None, None]: + def pytest_runtest_teardown(self, item: Item) -> Generator[None]: with self.item_capture("teardown", item): return (yield) @@ -962,7 +962,7 @@ def _is_started(self) -> bool: return False @contextlib.contextmanager - def disabled(self) -> Generator[None, None, None]: + def disabled(self) -> Generator[None]: """Temporarily disable capturing while inside the ``with`` block.""" capmanager: CaptureManager = self.request.config.pluginmanager.getplugin( "capturemanager" @@ -975,7 +975,7 @@ def disabled(self) -> Generator[None, None, None]: @fixture -def capsys(request: SubRequest) -> Generator[CaptureFixture[str], None, None]: +def capsys(request: SubRequest) -> Generator[CaptureFixture[str]]: r"""Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``. The captured output is made available via ``capsys.readouterr()`` method @@ -1003,7 +1003,7 @@ def test_output(capsys): @fixture -def capsysbinary(request: SubRequest) -> Generator[CaptureFixture[bytes], None, None]: +def capsysbinary(request: SubRequest) -> Generator[CaptureFixture[bytes]]: r"""Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``. The captured output is made available via ``capsysbinary.readouterr()`` @@ -1031,7 +1031,7 @@ def test_output(capsysbinary): @fixture -def capfd(request: SubRequest) -> Generator[CaptureFixture[str], None, None]: +def capfd(request: SubRequest) -> Generator[CaptureFixture[str]]: r"""Enable text capturing of writes to file descriptors ``1`` and ``2``. The captured output is made available via ``capfd.readouterr()`` method @@ -1059,7 +1059,7 @@ def test_system_echo(capfd): @fixture -def capfdbinary(request: SubRequest) -> Generator[CaptureFixture[bytes], None, None]: +def capfdbinary(request: SubRequest) -> Generator[CaptureFixture[bytes]]: r"""Enable bytes capturing of writes to file descriptors ``1`` and ``2``. The captured output is made available via ``capfd.readouterr()`` method diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index cb46d9a3bb5..675f4322328 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -467,7 +467,7 @@ def _is_mocked(obj: object) -> bool: @contextmanager -def _patch_unwrap_mock_aware() -> Generator[None, None, None]: +def _patch_unwrap_mock_aware() -> Generator[None]: """Context manager which replaces ``inspect.unwrap`` with a version that's aware of mock objects and doesn't recurse into them.""" real_unwrap = inspect.unwrap diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index 44af8ff2041..9f3417e9af2 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -554,9 +554,7 @@ def set_level(self, level: int | str, logger: str | None = None) -> None: self._initial_disabled_logging_level = initial_disabled_logging_level @contextmanager - def at_level( - self, level: int | str, logger: str | None = None - ) -> Generator[None, None, None]: + def at_level(self, level: int | str, logger: str | None = None) -> Generator[None]: """Context manager that sets the level for capturing of logs. After the end of the 'with' statement the level is restored to its original value. @@ -580,7 +578,7 @@ def at_level( logging.disable(original_disable_level) @contextmanager - def filtering(self, filter_: logging.Filter) -> Generator[None, None, None]: + def filtering(self, filter_: logging.Filter) -> Generator[None]: """Context manager that temporarily adds the given filter to the caplog's :meth:`handler` for the 'with' statement block, and removes that filter at the end of the block. @@ -597,7 +595,7 @@ def filtering(self, filter_: logging.Filter) -> Generator[None, None, None]: @fixture -def caplog(request: FixtureRequest) -> Generator[LogCaptureFixture, None, None]: +def caplog(request: FixtureRequest) -> Generator[LogCaptureFixture]: """Access and control log capturing. Captured logs are available through the following properties/methods:: @@ -776,7 +774,7 @@ def _log_cli_enabled(self) -> bool: return True @hookimpl(wrapper=True, tryfirst=True) - def pytest_sessionstart(self) -> Generator[None, None, None]: + def pytest_sessionstart(self) -> Generator[None]: self.log_cli_handler.set_when("sessionstart") with catching_logs(self.log_cli_handler, level=self.log_cli_level): @@ -784,7 +782,7 @@ def pytest_sessionstart(self) -> Generator[None, None, None]: return (yield) @hookimpl(wrapper=True, tryfirst=True) - def pytest_collection(self) -> Generator[None, None, None]: + def pytest_collection(self) -> Generator[None]: self.log_cli_handler.set_when("collection") with catching_logs(self.log_cli_handler, level=self.log_cli_level): @@ -813,7 +811,7 @@ def pytest_runtest_logstart(self) -> None: def pytest_runtest_logreport(self) -> None: self.log_cli_handler.set_when("logreport") - def _runtest_for(self, item: nodes.Item, when: str) -> Generator[None, None, None]: + def _runtest_for(self, item: nodes.Item, when: str) -> Generator[None]: """Implement the internals of the pytest_runtest_xxx() hooks.""" with catching_logs( self.caplog_handler, @@ -834,7 +832,7 @@ def _runtest_for(self, item: nodes.Item, when: str) -> Generator[None, None, Non item.add_report_section(when, "log", log) @hookimpl(wrapper=True) - def pytest_runtest_setup(self, item: nodes.Item) -> Generator[None, None, None]: + def pytest_runtest_setup(self, item: nodes.Item) -> Generator[None]: self.log_cli_handler.set_when("setup") empty: dict[str, list[logging.LogRecord]] = {} @@ -842,13 +840,13 @@ def pytest_runtest_setup(self, item: nodes.Item) -> Generator[None, None, None]: yield from self._runtest_for(item, "setup") @hookimpl(wrapper=True) - def pytest_runtest_call(self, item: nodes.Item) -> Generator[None, None, None]: + def pytest_runtest_call(self, item: nodes.Item) -> Generator[None]: self.log_cli_handler.set_when("call") yield from self._runtest_for(item, "call") @hookimpl(wrapper=True) - def pytest_runtest_teardown(self, item: nodes.Item) -> Generator[None, None, None]: + def pytest_runtest_teardown(self, item: nodes.Item) -> Generator[None]: self.log_cli_handler.set_when("teardown") try: @@ -862,7 +860,7 @@ def pytest_runtest_logfinish(self) -> None: self.log_cli_handler.set_when("finish") @hookimpl(wrapper=True, tryfirst=True) - def pytest_sessionfinish(self) -> Generator[None, None, None]: + def pytest_sessionfinish(self) -> Generator[None]: self.log_cli_handler.set_when("sessionfinish") with catching_logs(self.log_cli_handler, level=self.log_cli_level): diff --git a/src/_pytest/monkeypatch.py b/src/_pytest/monkeypatch.py index 75b019a3be6..46eb1724e35 100644 --- a/src/_pytest/monkeypatch.py +++ b/src/_pytest/monkeypatch.py @@ -28,7 +28,7 @@ @fixture -def monkeypatch() -> Generator[MonkeyPatch, None, None]: +def monkeypatch() -> Generator[MonkeyPatch]: """A convenient fixture for monkey-patching. The fixture provides these methods to modify objects, dictionaries, or @@ -135,7 +135,7 @@ def __init__(self) -> None: @classmethod @contextmanager - def context(cls) -> Generator[MonkeyPatch, None, None]: + def context(cls) -> Generator[MonkeyPatch]: """Context manager that returns a new :class:`MonkeyPatch` object which undoes any patching done inside the ``with`` block upon exit. diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 5c6ce5e889f..3f7520ee4ad 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -491,7 +491,7 @@ def pytester( @fixture -def _sys_snapshot() -> Generator[None, None, None]: +def _sys_snapshot() -> Generator[None]: snappaths = SysPathsSnapshot() snapmods = SysModulesSnapshot() yield @@ -500,7 +500,7 @@ def _sys_snapshot() -> Generator[None, None, None]: @fixture -def _config_for_test() -> Generator[Config, None, None]: +def _config_for_test() -> Generator[Config]: from _pytest.config import get_config config = get_config() diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 094113bd1b4..3a8c77fd2f0 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -569,7 +569,7 @@ def _register_setup_module_fixture(self) -> None: if setup_module is None and teardown_module is None: return - def xunit_setup_module_fixture(request) -> Generator[None, None, None]: + def xunit_setup_module_fixture(request) -> Generator[None]: module = request.module if setup_module is not None: _call_with_optional_argument(setup_module, module) @@ -600,7 +600,7 @@ def _register_setup_function_fixture(self) -> None: if setup_function is None and teardown_function is None: return - def xunit_setup_function_fixture(request) -> Generator[None, None, None]: + def xunit_setup_function_fixture(request) -> Generator[None]: if request.instance is not None: # in this case we are bound to an instance, so we need to let # setup_method handle this @@ -781,7 +781,7 @@ def _register_setup_class_fixture(self) -> None: if setup_class is None and teardown_class is None: return - def xunit_setup_class_fixture(request) -> Generator[None, None, None]: + def xunit_setup_class_fixture(request) -> Generator[None]: cls = request.cls if setup_class is not None: func = getimfunc(setup_class) @@ -814,7 +814,7 @@ def _register_setup_method_fixture(self) -> None: if setup_method is None and teardown_method is None: return - def xunit_setup_method_fixture(request) -> Generator[None, None, None]: + def xunit_setup_method_fixture(request) -> Generator[None]: instance = request.instance method = request.function if setup_method is not None: diff --git a/src/_pytest/recwarn.py b/src/_pytest/recwarn.py index 3fc00d94736..85d8de84abb 100644 --- a/src/_pytest/recwarn.py +++ b/src/_pytest/recwarn.py @@ -32,7 +32,7 @@ @fixture -def recwarn() -> Generator[WarningsRecorder, None, None]: +def recwarn() -> Generator[WarningsRecorder]: """Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions. See https://docs.pytest.org/en/latest/how-to/capture-warnings.html for information diff --git a/src/_pytest/skipping.py b/src/_pytest/skipping.py index 08fcb283eb2..9818be2ab03 100644 --- a/src/_pytest/skipping.py +++ b/src/_pytest/skipping.py @@ -245,7 +245,7 @@ def pytest_runtest_setup(item: Item) -> None: @hookimpl(wrapper=True) -def pytest_runtest_call(item: Item) -> Generator[None, None, None]: +def pytest_runtest_call(item: Item) -> Generator[None]: xfailed = item.stash.get(xfailed_key, None) if xfailed is None: item.stash[xfailed_key] = xfailed = evaluate_xfail_marks(item) diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index cdda5a90ea1..55ef1ea8eee 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -889,7 +889,7 @@ def _printcollecteditems(self, items: Sequence[Item]) -> None: @hookimpl(wrapper=True) def pytest_sessionfinish( self, session: Session, exitstatus: int | ExitCode - ) -> Generator[None, None, None]: + ) -> Generator[None]: result = yield self._tw.line("") summary_exit_codes = ( @@ -914,7 +914,7 @@ def pytest_sessionfinish( return result @hookimpl(wrapper=True) - def pytest_terminal_summary(self) -> Generator[None, None, None]: + def pytest_terminal_summary(self) -> Generator[None]: self.summary_errors() self.summary_failures() self.summary_xfailures() diff --git a/src/_pytest/threadexception.py b/src/_pytest/threadexception.py index d78c32c852f..c1ed80387aa 100644 --- a/src/_pytest/threadexception.py +++ b/src/_pytest/threadexception.py @@ -62,7 +62,7 @@ def __exit__( del self.args -def thread_exception_runtest_hook() -> Generator[None, None, None]: +def thread_exception_runtest_hook() -> Generator[None]: with catch_threading_exception() as cm: try: yield @@ -83,15 +83,15 @@ def thread_exception_runtest_hook() -> Generator[None, None, None]: @pytest.hookimpl(wrapper=True, trylast=True) -def pytest_runtest_setup() -> Generator[None, None, None]: +def pytest_runtest_setup() -> Generator[None]: yield from thread_exception_runtest_hook() @pytest.hookimpl(wrapper=True, tryfirst=True) -def pytest_runtest_call() -> Generator[None, None, None]: +def pytest_runtest_call() -> Generator[None]: yield from thread_exception_runtest_hook() @pytest.hookimpl(wrapper=True, tryfirst=True) -def pytest_runtest_teardown() -> Generator[None, None, None]: +def pytest_runtest_teardown() -> Generator[None]: yield from thread_exception_runtest_hook() diff --git a/src/_pytest/tmpdir.py b/src/_pytest/tmpdir.py index 91109ea69ef..de0cbcfeb1c 100644 --- a/src/_pytest/tmpdir.py +++ b/src/_pytest/tmpdir.py @@ -256,7 +256,7 @@ def _mk_tmp(request: FixtureRequest, factory: TempPathFactory) -> Path: @fixture def tmp_path( request: FixtureRequest, tmp_path_factory: TempPathFactory -) -> Generator[Path, None, None]: +) -> Generator[Path]: """Return a temporary directory path object which is unique to each test function invocation, created as a sub directory of the base temporary directory. diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py index aefea1333d9..8cecd4f9339 100644 --- a/src/_pytest/unittest.py +++ b/src/_pytest/unittest.py @@ -137,7 +137,7 @@ def process_teardown_exceptions() -> None: def unittest_setup_class_fixture( request: FixtureRequest, - ) -> Generator[None, None, None]: + ) -> Generator[None]: cls = request.cls if _is_skipped(cls): reason = cls.__unittest_skip_why__ @@ -178,7 +178,7 @@ def _register_unittest_setup_method_fixture(self, cls: type) -> None: def unittest_setup_method_fixture( request: FixtureRequest, - ) -> Generator[None, None, None]: + ) -> Generator[None]: self = request.instance if _is_skipped(self): reason = self.__unittest_skip_why__ diff --git a/src/_pytest/unraisableexception.py b/src/_pytest/unraisableexception.py index c191703a3de..77a2de20041 100644 --- a/src/_pytest/unraisableexception.py +++ b/src/_pytest/unraisableexception.py @@ -64,7 +64,7 @@ def __exit__( del self.unraisable -def unraisable_exception_runtest_hook() -> Generator[None, None, None]: +def unraisable_exception_runtest_hook() -> Generator[None]: with catch_unraisable_exception() as cm: try: yield @@ -86,15 +86,15 @@ def unraisable_exception_runtest_hook() -> Generator[None, None, None]: @pytest.hookimpl(wrapper=True, tryfirst=True) -def pytest_runtest_setup() -> Generator[None, None, None]: +def pytest_runtest_setup() -> Generator[None]: yield from unraisable_exception_runtest_hook() @pytest.hookimpl(wrapper=True, tryfirst=True) -def pytest_runtest_call() -> Generator[None, None, None]: +def pytest_runtest_call() -> Generator[None]: yield from unraisable_exception_runtest_hook() @pytest.hookimpl(wrapper=True, tryfirst=True) -def pytest_runtest_teardown() -> Generator[None, None, None]: +def pytest_runtest_teardown() -> Generator[None]: yield from unraisable_exception_runtest_hook() diff --git a/src/_pytest/warnings.py b/src/_pytest/warnings.py index 5c59e55c5db..eeb4772649d 100644 --- a/src/_pytest/warnings.py +++ b/src/_pytest/warnings.py @@ -30,7 +30,7 @@ def catch_warnings_for_item( ihook, when: Literal["config", "collect", "runtest"], item: Item | None, -) -> Generator[None, None, None]: +) -> Generator[None]: """Context manager that catches warnings generated in the contained execution block. ``item`` can be None if we are not in the context of an item execution. @@ -124,7 +124,7 @@ def pytest_collection(session: Session) -> Generator[None, object, object]: @pytest.hookimpl(wrapper=True) def pytest_terminal_summary( terminalreporter: TerminalReporter, -) -> Generator[None, None, None]: +) -> Generator[None]: config = terminalreporter.config with catch_warnings_for_item( config=config, ihook=config.hook, when="config", item=None @@ -133,7 +133,7 @@ def pytest_terminal_summary( @pytest.hookimpl(wrapper=True) -def pytest_sessionfinish(session: Session) -> Generator[None, None, None]: +def pytest_sessionfinish(session: Session) -> Generator[None]: config = session.config with catch_warnings_for_item( config=config, ihook=config.hook, when="config", item=None @@ -144,7 +144,7 @@ def pytest_sessionfinish(session: Session) -> Generator[None, None, None]: @pytest.hookimpl(wrapper=True) def pytest_load_initial_conftests( early_config: Config, -) -> Generator[None, None, None]: +) -> Generator[None]: with catch_warnings_for_item( config=early_config, ihook=early_config.hook, when="config", item=None ): diff --git a/testing/conftest.py b/testing/conftest.py index 24e5d183094..046bb77a109 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -46,7 +46,7 @@ def reset_colors(monkeypatch: pytest.MonkeyPatch) -> None: @pytest.hookimpl(wrapper=True, tryfirst=True) -def pytest_collection_modifyitems(items) -> Generator[None, None, None]: +def pytest_collection_modifyitems(items) -> Generator[None]: """Prefer faster tests. Use a hook wrapper to do this in the beginning, so e.g. --ff still works diff --git a/testing/io/test_terminalwriter.py b/testing/io/test_terminalwriter.py index 043c2d1d904..92cde240a11 100644 --- a/testing/io/test_terminalwriter.py +++ b/testing/io/test_terminalwriter.py @@ -67,9 +67,7 @@ def test_terminalwriter_not_unicode() -> None: class TestTerminalWriter: @pytest.fixture(params=["path", "stringio"]) - def tw( - self, request, tmp_path: Path - ) -> Generator[terminalwriter.TerminalWriter, None, None]: + def tw(self, request, tmp_path: Path) -> Generator[terminalwriter.TerminalWriter]: if request.param == "path": p = tmp_path.joinpath("tmpfile") f = open(str(p), "w+", encoding="utf8") diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index 11688acb6f5..73c11a1a9d8 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -1660,7 +1660,7 @@ class TestEarlyRewriteBailout: @pytest.fixture def hook( self, pytestconfig, monkeypatch, pytester: Pytester - ) -> Generator[AssertionRewritingHook, None, None]: + ) -> Generator[AssertionRewritingHook]: """Returns a patched AssertionRewritingHook instance so we can configure its initial paths and track if PathFinder.find_spec has been called. """ diff --git a/testing/test_cacheprovider.py b/testing/test_cacheprovider.py index 72b4265cf75..94bc55d3047 100644 --- a/testing/test_cacheprovider.py +++ b/testing/test_cacheprovider.py @@ -69,7 +69,7 @@ def test_cache_writefail_cachefile_silent(self, pytester: Pytester) -> None: cache.set("test/broken", []) @pytest.fixture - def unwritable_cache_dir(self, pytester: Pytester) -> Generator[Path, None, None]: + def unwritable_cache_dir(self, pytester: Pytester) -> Generator[Path]: cache_dir = pytester.path.joinpath(".pytest_cache") cache_dir.mkdir() mode = cache_dir.stat().st_mode diff --git a/testing/test_capture.py b/testing/test_capture.py index fe6bd7d14fa..328de740e8a 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -939,7 +939,7 @@ def test_captureresult() -> None: @pytest.fixture -def tmpfile(pytester: Pytester) -> Generator[BinaryIO, None, None]: +def tmpfile(pytester: Pytester) -> Generator[BinaryIO]: f = pytester.makepyfile("").open("wb+") yield f if not f.closed: diff --git a/testing/test_conftest.py b/testing/test_conftest.py index d51846f2f5f..ea60c1909c2 100644 --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -44,9 +44,7 @@ def conftest_setinitial( @pytest.mark.usefixtures("_sys_snapshot") class TestConftestValueAccessGlobal: @pytest.fixture(scope="module", params=["global", "inpackage"]) - def basedir( - self, request, tmp_path_factory: TempPathFactory - ) -> Generator[Path, None, None]: + def basedir(self, request, tmp_path_factory: TempPathFactory) -> Generator[Path]: tmp_path = tmp_path_factory.mktemp("basedir", numbered=True) tmp_path.joinpath("adir/b").mkdir(parents=True) tmp_path.joinpath("adir/conftest.py").write_text( diff --git a/testing/test_monkeypatch.py b/testing/test_monkeypatch.py index 944d91f6e65..7c62d90f2b9 100644 --- a/testing/test_monkeypatch.py +++ b/testing/test_monkeypatch.py @@ -14,7 +14,7 @@ @pytest.fixture -def mp() -> Generator[MonkeyPatch, None, None]: +def mp() -> Generator[MonkeyPatch]: cwd = os.getcwd() sys_path = list(sys.path) yield MonkeyPatch() diff --git a/testing/test_pathlib.py b/testing/test_pathlib.py index 81aba25f78f..377c30ca900 100644 --- a/testing/test_pathlib.py +++ b/testing/test_pathlib.py @@ -125,7 +125,7 @@ class TestImportPath: """ @pytest.fixture(scope="session") - def path1(self, tmp_path_factory: TempPathFactory) -> Generator[Path, None, None]: + def path1(self, tmp_path_factory: TempPathFactory) -> Generator[Path]: path = tmp_path_factory.mktemp("path") self.setuptestfs(path) yield path From 7cb7cfc704ddcbece7b65fbdc6deccff6cc51b62 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 18 Aug 2024 01:53:14 +0000 Subject: [PATCH 037/445] [automated] Update plugin list (#12720) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 206 ++++++++++++++++++------------- 1 file changed, 119 insertions(+), 87 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 6aea0dd86c0..43fa0be55a8 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =3.5.0) :pypi:`pytest-annotate` pytest-annotate: Generate PyAnnotate annotations from your pytest tests. Jun 07, 2022 3 - Alpha pytest (<8.0.0,>=3.2.0) - :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures Jul 24, 2024 5 - Production/Stable pytest>=6 + :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures Aug 16, 2024 5 - Production/Stable pytest>=6 :pypi:`pytest-ansible-playbook` Pytest fixture which runs given ansible playbook file. Mar 08, 2019 4 - Beta N/A :pypi:`pytest-ansible-playbook-runner` Pytest fixture which runs given ansible playbook file. Dec 02, 2020 4 - Beta pytest (>=3.1.0) :pypi:`pytest-ansible-units` A pytest plugin for running unit tests within an ansible collection Apr 14, 2022 N/A N/A @@ -111,7 +111,7 @@ This list contains 1497 plugins. :pypi:`pytest-ast-transformer` May 04, 2019 3 - Alpha pytest :pypi:`pytest_async` pytest-async - Run your coroutine in event loop without decorator Feb 26, 2020 N/A N/A :pypi:`pytest-async-generators` Pytest fixtures for async generators Jul 05, 2023 N/A N/A - :pypi:`pytest-asyncio` Pytest support for asyncio Jul 30, 2024 4 - Beta pytest<9,>=7.0.0 + :pypi:`pytest-asyncio` Pytest support for asyncio Aug 09, 2024 4 - Beta pytest<9,>=7.0.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Jul 04, 2024 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) :pypi:`pytest-async-mongodb` pytest plugin for async MongoDB Oct 18, 2017 5 - Production/Stable pytest (>=2.5.2) @@ -154,7 +154,7 @@ This list contains 1497 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Aug 08, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Aug 01, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Aug 17, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -211,7 +211,7 @@ This list contains 1497 plugins. :pypi:`pytest-cassandra` Cassandra CCM Test Fixtures for pytest Nov 04, 2017 1 - Planning N/A :pypi:`pytest-catchlog` py.test plugin to catch log messages. This is a fork of pytest-capturelog. Jan 24, 2016 4 - Beta pytest (>=2.6) :pypi:`pytest-catch-server` Pytest plugin with server for catching HTTP requests. Dec 12, 2019 5 - Production/Stable N/A - :pypi:`pytest-celery` Pytest plugin for Celery Jul 17, 2024 4 - Beta N/A + :pypi:`pytest-celery` Pytest plugin for Celery Aug 12, 2024 4 - Beta N/A :pypi:`pytest-cfg-fetcher` Pass config options to your unit tests. Feb 26, 2024 N/A N/A :pypi:`pytest-chainmaker` pytest plugin for chainmaker Oct 15, 2021 N/A N/A :pypi:`pytest-chalice` A set of py.test fixtures for AWS Chalice Jul 01, 2020 4 - Beta N/A @@ -243,14 +243,14 @@ This list contains 1497 plugins. :pypi:`pytest-cleanslate` Collects and executes pytest tests separately Jun 17, 2024 N/A pytest :pypi:`pytest_cleanup` Automated, comprehensive and well-organised pytest test cases. Jan 28, 2020 N/A N/A :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Mar 19, 2024 5 - Production/Stable N/A - :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Jul 30, 2024 N/A pytest<9.0.0,>=8.0.0 + :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Aug 15, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-click` Pytest plugin for Click Feb 11, 2022 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-cli-fixtures` Automatically register fixtures for custom CLI arguments Jul 28, 2022 N/A pytest (~=7.0) :pypi:`pytest-clld` Jul 06, 2022 N/A pytest (>=3.6) :pypi:`pytest-cloud` Distributed tests planner plugin for pytest testing framework. Oct 05, 2020 6 - Mature N/A :pypi:`pytest-cloudflare-worker` pytest plugin for testing cloudflare workers Mar 30, 2021 4 - Beta pytest (>=6.0.0) :pypi:`pytest-cloudist` Distribute tests to cloud machines without fuss Sep 02, 2022 4 - Beta pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-cmake` Provide CMake module for Pytest Aug 09, 2024 N/A pytest<9,>=4 + :pypi:`pytest-cmake` Provide CMake module for Pytest Aug 16, 2024 N/A pytest<9,>=4 :pypi:`pytest-cmake-presets` Execute CMake Presets via pytest Dec 26, 2022 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-cobra` PyTest plugin for testing Smart Contracts for Ethereum blockchain. Jun 29, 2019 3 - Alpha pytest (<4.0.0,>=3.7.1) :pypi:`pytest_codeblocks` Test code blocks in your READMEs Sep 17, 2023 5 - Production/Stable pytest >= 7.0.0 @@ -289,7 +289,7 @@ This list contains 1497 plugins. :pypi:`pytest-cover` Pytest plugin for measuring coverage. Forked from \`pytest-cov\`. Aug 01, 2015 5 - Production/Stable N/A :pypi:`pytest-coverage` Jun 17, 2015 N/A N/A :pypi:`pytest-coverage-context` Coverage dynamic context support for PyTest, including sub-processes Jun 28, 2023 4 - Beta N/A - :pypi:`pytest-coveragemarkers` Using pytest markers to track functional coverage and filtering of tests Jul 28, 2024 N/A pytest<8.0.0,>=7.1.2 + :pypi:`pytest-coveragemarkers` Using pytest markers to track functional coverage and filtering of tests Aug 14, 2024 N/A pytest<8.0.0,>=7.1.2 :pypi:`pytest-cov-exclude` Pytest plugin for excluding tests based on coverage data Apr 29, 2016 4 - Beta pytest (>=2.8.0,<2.9.0); extra == 'dev' :pypi:`pytest_covid` Too many faillure, less tests. Jun 24, 2020 N/A N/A :pypi:`pytest-cpp` Use pytest's runner to discover and execute C++ tests Nov 01, 2023 5 - Production/Stable pytest >=7.0 @@ -399,21 +399,21 @@ This list contains 1497 plugins. :pypi:`pytest-docfiles` pytest plugin to test codeblocks in your documentation. Dec 22, 2021 4 - Beta pytest (>=3.7.0) :pypi:`pytest-docgen` An RST Documentation Generator for pytest-based test suites Apr 17, 2020 N/A N/A :pypi:`pytest-docker` Simple pytest fixtures for Docker and Docker Compose based tests Feb 02, 2024 N/A pytest <9.0,>=4.0 - :pypi:`pytest-docker-apache-fixtures` Pytest fixtures for testing with apache2 (httpd). Feb 16, 2022 4 - Beta pytest + :pypi:`pytest-docker-apache-fixtures` Pytest fixtures for testing with apache2 (httpd). Aug 12, 2024 4 - Beta pytest :pypi:`pytest-docker-butla` Jun 16, 2019 3 - Alpha N/A :pypi:`pytest-dockerc` Run, manage and stop Docker Compose project from Docker API Oct 09, 2020 5 - Production/Stable pytest (>=3.0) :pypi:`pytest-docker-compose` Manages Docker containers during your integration tests Jan 26, 2021 5 - Production/Stable pytest (>=3.3) :pypi:`pytest-docker-compose-v2` Manages Docker containers during your integration tests Feb 28, 2024 4 - Beta pytest<8,>=7.2.2 :pypi:`pytest-docker-db` A plugin to use docker databases for pytests Mar 20, 2021 5 - Production/Stable pytest (>=3.1.1) :pypi:`pytest-docker-fixtures` pytest docker fixtures Apr 03, 2024 3 - Alpha N/A - :pypi:`pytest-docker-git-fixtures` Pytest fixtures for testing with git scm. Feb 09, 2022 4 - Beta pytest - :pypi:`pytest-docker-haproxy-fixtures` Pytest fixtures for testing with haproxy. Feb 09, 2022 4 - Beta pytest + :pypi:`pytest-docker-git-fixtures` Pytest fixtures for testing with git scm. Aug 12, 2024 4 - Beta pytest + :pypi:`pytest-docker-haproxy-fixtures` Pytest fixtures for testing with haproxy. Aug 12, 2024 4 - Beta pytest :pypi:`pytest-docker-pexpect` pytest plugin for writing functional tests with pexpect and docker Jan 14, 2019 N/A pytest :pypi:`pytest-docker-postgresql` A simple plugin to use with pytest Sep 24, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-docker-py` Easy to use, simple to extend, pytest plugin that minimally leverages docker-py. Nov 27, 2018 N/A pytest (==4.0.0) - :pypi:`pytest-docker-registry-fixtures` Pytest fixtures for testing with docker registries. Apr 08, 2022 4 - Beta pytest + :pypi:`pytest-docker-registry-fixtures` Pytest fixtures for testing with docker registries. Aug 12, 2024 4 - Beta pytest :pypi:`pytest-docker-service` pytest plugin to start docker container Jan 03, 2024 3 - Alpha pytest (>=7.1.3) - :pypi:`pytest-docker-squid-fixtures` Pytest fixtures for testing with squid. Feb 09, 2022 4 - Beta pytest + :pypi:`pytest-docker-squid-fixtures` Pytest fixtures for testing with squid. Aug 12, 2024 4 - Beta pytest :pypi:`pytest-docker-tools` Docker integration tests for pytest Feb 17, 2022 4 - Beta pytest (>=6.0.1) :pypi:`pytest-docs` Documentation tool for pytest Nov 11, 2018 4 - Beta pytest (>=3.5.0) :pypi:`pytest-docstyle` pytest plugin to run pydocstyle Mar 23, 2020 3 - Alpha N/A @@ -430,7 +430,7 @@ This list contains 1497 plugins. :pypi:`pytest-doorstop` A pytest plugin for adding test results into doorstop items. Jun 09, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-dotenv` A py.test plugin that parses environment files before running tests Jun 16, 2020 4 - Beta pytest (>=5.0.0) :pypi:`pytest-dot-only-pkcopley` A Pytest marker for only running a single test Oct 27, 2023 N/A N/A - :pypi:`pytest-dpg` pytest-dpg is a pytest plugin for testing Dear PyGui (DPG) applications Aug 07, 2024 N/A N/A + :pypi:`pytest-dpg` pytest-dpg is a pytest plugin for testing Dear PyGui (DPG) applications Aug 13, 2024 N/A N/A :pypi:`pytest-draw` Pytest plugin for randomly selecting a specific number of tests Mar 21, 2023 3 - Alpha pytest :pypi:`pytest-drf` A Django REST framework plugin for pytest. Jul 12, 2022 5 - Production/Stable pytest (>=3.7) :pypi:`pytest-drivings` Tool to allow webdriver automation to be ran locally or remotely Jan 13, 2021 N/A N/A @@ -457,14 +457,14 @@ This list contains 1497 plugins. :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Aug 09, 2024 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Aug 09, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Aug 09, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Aug 09, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Aug 09, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Aug 09, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Aug 09, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Aug 09, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Aug 16, 2024 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Aug 16, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Aug 16, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Aug 16, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Aug 16, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Aug 16, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Aug 16, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Aug 16, 2024 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -491,9 +491,11 @@ This list contains 1497 plugins. :pypi:`pytest-eventlet` Applies eventlet monkey-patch as a pytest plugin. Oct 04, 2021 N/A pytest ; extra == 'dev' :pypi:`pytest-evm` The testing package containing tools to test Web3-based projects Apr 22, 2024 4 - Beta pytest<9.0.0,>=8.1.1 :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A - :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Jul 02, 2024 4 - Beta pytest>=7 + :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Aug 13, 2024 4 - Beta pytest>=7 + :pypi:`pytest-exasol-backend` Aug 14, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-itde` Jul 01, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-saas` Aug 06, 2024 N/A pytest<9,>=7 + :pypi:`pytest-exasol-slc` Aug 15, 2024 N/A pytest<9,>=7 :pypi:`pytest-excel` pytest plugin for generating excel reports Jun 18, 2024 5 - Production/Stable pytest>3.6 :pypi:`pytest-exceptional` Better exceptions Mar 16, 2017 4 - Beta N/A :pypi:`pytest-exception-script` Walk your code through exception script to check it's resiliency to failures. Aug 04, 2020 3 - Alpha pytest @@ -558,7 +560,7 @@ This list contains 1497 plugins. :pypi:`pytest-fixture-remover` A LibCST codemod to remove pytest fixtures applied via the usefixtures decorator, as well as its parametrizations. Feb 14, 2024 5 - Production/Stable N/A :pypi:`pytest-fixture-rtttg` Warn or fail on fixture name clash Feb 23, 2022 N/A pytest (>=7.0.1,<8.0.0) :pypi:`pytest-fixtures` Common fixtures for pytest May 01, 2019 5 - Production/Stable N/A - :pypi:`pytest-fixture-tools` Plugin for pytest which provides tools for fixtures Aug 18, 2020 6 - Mature pytest + :pypi:`pytest-fixture-tools` Plugin for pytest which provides tools for fixtures Aug 15, 2024 6 - Mature pytest :pypi:`pytest-fixture-typecheck` A pytest plugin to assert type annotations at runtime. Aug 24, 2021 N/A pytest :pypi:`pytest-flake8` pytest plugin to check FLAKE8 requirements Jul 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-flake8-path` A pytest fixture for testing flake8 plugins. Jul 10, 2023 5 - Production/Stable pytest @@ -571,7 +573,7 @@ This list contains 1497 plugins. :pypi:`pytest-flask-sqlalchemy` A pytest plugin for preserving test isolation in Flask-SQlAlchemy using database transactions. Apr 30, 2022 4 - Beta pytest (>=3.2.1) :pypi:`pytest-flask-sqlalchemy-transactions` Run tests in transactions using pytest, Flask, and SQLalchemy. Aug 02, 2018 4 - Beta pytest (>=3.2.1) :pypi:`pytest-flexreport` Apr 15, 2023 4 - Beta pytest - :pypi:`pytest-fluent` A pytest plugin in order to provide logs via fluentd Jun 05, 2024 4 - Beta pytest>=7.0.0 + :pypi:`pytest-fluent` A pytest plugin in order to provide logs via fluentd Aug 14, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-fluentbit` A pytest plugin in order to provide logs via fluentbit Jun 16, 2023 4 - Beta pytest (>=7.0.0) :pypi:`pytest-fly` pytest observer Apr 14, 2024 3 - Alpha pytest :pypi:`pytest-flyte` Pytest fixtures for simplifying Flyte integration testing May 03, 2021 N/A pytest @@ -593,7 +595,7 @@ This list contains 1497 plugins. :pypi:`pytest-fxtest` Oct 27, 2020 N/A N/A :pypi:`pytest-fzf` fzf-based test selector for pytest Jul 03, 2024 4 - Beta pytest>=6.0.0 :pypi:`pytest_gae` pytest plugin for apps written with Google's AppEngine Aug 03, 2016 3 - Alpha N/A - :pypi:`pytest-gather-fixtures` set up asynchronous pytest fixtures concurrently Apr 12, 2022 N/A pytest (>=6.0.0) + :pypi:`pytest-gather-fixtures` set up asynchronous pytest fixtures concurrently Aug 12, 2024 N/A pytest>=7.0.0 :pypi:`pytest-gc` The garbage collector plugin for py.test Feb 01, 2018 N/A N/A :pypi:`pytest-gcov` Uses gcov to measure test coverage of a C library Feb 01, 2018 3 - Alpha N/A :pypi:`pytest-gcs` GCS fixtures and fixture factories for Pytest. Mar 01, 2024 5 - Production/Stable pytest >=6.2 @@ -604,7 +606,7 @@ This list contains 1497 plugins. :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Jul 08, 2024 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test May 28, 2019 5 - Production/Stable pytest - :pypi:`pytest-gitconfig` Provide a gitconfig sandbox for testing Oct 15, 2023 4 - Beta pytest>=7.1.2 + :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-git-diff` Pytest plugin that allows the user to select the tests affected by a range of git commits Apr 02, 2024 N/A N/A :pypi:`pytest-git-fixtures` Pytest fixtures for testing with git. Mar 11, 2021 4 - Beta pytest @@ -645,7 +647,7 @@ This list contains 1497 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Aug 08, 2024 3 - Alpha pytest==8.3.1 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Aug 17, 2024 3 - Alpha pytest==8.3.1 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Apr 18, 2024 N/A N/A @@ -668,8 +670,8 @@ This list contains 1497 plugins. :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace Jan 10, 2024 3 - Alpha pytest >=7.0.0 :pypi:`pytest-http-mocker` Pytest plugin for http mocking (via https://github.com/vilus/mocker) Oct 20, 2019 N/A N/A :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A - :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Jul 21, 2024 3 - Alpha N/A - :pypi:`pytest-httptesting` http_testing framework on top of pytest Jul 25, 2024 N/A pytest<9.0.0,>=8.2.0 + :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Aug 11, 2024 3 - Alpha N/A + :pypi:`pytest-httptesting` http_testing framework on top of pytest Aug 10, 2024 N/A pytest<9.0.0,>=8.2.0 :pypi:`pytest-httpx` Send responses to httpx. Feb 21, 2024 5 - Production/Stable pytest <9,>=7 :pypi:`pytest-httpx-blockage` Disable httpx requests during a test run Feb 16, 2023 N/A pytest (>=7.2.1) :pypi:`pytest-httpx-recorder` Recorder feature based on pytest_httpx, like recorder feature in responses. Jan 04, 2024 5 - Production/Stable pytest @@ -699,7 +701,7 @@ This list contains 1497 plugins. :pypi:`pytest-inline` A pytest plugin for writing inline tests. Oct 19, 2023 4 - Beta pytest >=7.0.0 :pypi:`pytest-inmanta` A py.test plugin providing fixtures to simplify inmanta modules testing. Jul 05, 2024 5 - Production/Stable pytest :pypi:`pytest-inmanta-extensions` Inmanta tests package Jul 22, 2024 5 - Production/Stable N/A - :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Jul 24, 2024 5 - Production/Stable N/A + :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Aug 12, 2024 5 - Production/Stable N/A :pypi:`pytest-inmanta-yang` Common fixtures used in inmanta yang related modules Feb 22, 2024 4 - Beta pytest :pypi:`pytest-Inomaly` A simple image diff plugin for pytest Feb 13, 2018 4 - Beta N/A :pypi:`pytest-in-robotframework` The extension enables easy execution of pytest tests within the Robot Framework environment. Mar 02, 2024 N/A pytest @@ -743,7 +745,7 @@ This list contains 1497 plugins. :pypi:`pytest-jtr` pytest plugin supporting json test report output Jul 21, 2024 N/A pytest<8.0.0,>=7.1.2 :pypi:`pytest-jupyter` A pytest plugin for testing Jupyter libraries and extensions. Apr 04, 2024 4 - Beta pytest>=7.0 :pypi:`pytest-jupyterhub` A reusable JupyterHub pytest plugin Apr 25, 2023 5 - Production/Stable pytest - :pypi:`pytest-kafka` Zookeeper, Kafka server, and Kafka consumer fixtures for Pytest Jun 14, 2023 N/A pytest + :pypi:`pytest-kafka` Zookeeper, Kafka server, and Kafka consumer fixtures for Pytest Aug 14, 2024 N/A pytest :pypi:`pytest-kafkavents` A plugin to send pytest events to Kafka Sep 08, 2021 4 - Beta pytest :pypi:`pytest-kairos` Pytest plugin with random number generation, reproducibility, and test repetition Aug 08, 2024 5 - Production/Stable pytest>=5.0.0 :pypi:`pytest-kasima` Display horizontal lines above and below the captured standard output for easy viewing. Jan 26, 2023 5 - Production/Stable pytest (>=7.2.1,<8.0.0) @@ -812,11 +814,12 @@ This list contains 1497 plugins. :pypi:`pytest-marker-bugzilla` py.test bugzilla integration plugin, using markers Jan 09, 2020 N/A N/A :pypi:`pytest-markers-presence` A simple plugin to detect missed pytest tags and markers" Feb 04, 2021 4 - Beta pytest (>=6.0) :pypi:`pytest-markfiltration` UNKNOWN Nov 08, 2011 3 - Alpha N/A - :pypi:`pytest-mark-manage` 用例标签化管理 Jul 08, 2024 N/A pytest + :pypi:`pytest-mark-manage` 用例标签化管理 Aug 15, 2024 N/A pytest :pypi:`pytest-mark-no-py3` pytest plugin and bowler codemod to help migrate tests to Python 3 May 17, 2019 N/A pytest :pypi:`pytest-marks` UNKNOWN Nov 23, 2012 3 - Alpha N/A :pypi:`pytest-mask-secrets` Pytest plugin to hide sensitive data in test reports Aug 06, 2024 N/A N/A :pypi:`pytest-matcher` Easy way to match captured \`pytest\` output against expectations stored in files Aug 01, 2024 5 - Production/Stable pytest + :pypi:`pytest-matchers` Matchers for pytest Aug 16, 2024 N/A N/A :pypi:`pytest-match-skip` Skip matching marks. Matches partial marks using wildcards. May 15, 2019 4 - Beta pytest (>=4.4.1) :pypi:`pytest-mat-report` this is report Jan 20, 2021 N/A N/A :pypi:`pytest-matrix` Provide tools for generating tests from combinations of fixtures. Jun 24, 2020 5 - Production/Stable pytest (>=5.4.3,<6.0.0) @@ -976,7 +979,7 @@ This list contains 1497 plugins. :pypi:`pytest-performance` A simple plugin to ensure the execution of critical sections of code has not been impacted Sep 11, 2020 5 - Production/Stable pytest (>=3.7.0) :pypi:`pytest-performancetotal` A performance plugin for pytest Mar 19, 2024 4 - Beta N/A :pypi:`pytest-persistence` Pytest tool for persistent objects May 23, 2024 N/A N/A - :pypi:`pytest-pexpect` Pytest pexpect plugin. Mar 27, 2024 4 - Beta pytest>=6.2.0 + :pypi:`pytest-pexpect` Pytest pexpect plugin. Aug 13, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-pg` A tiny plugin for pytest which runs PostgreSQL in Docker May 21, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-pgsql` Pytest plugins and helpers for tests using a Postgres database. May 13, 2020 5 - Production/Stable pytest (>=3.0.0) :pypi:`pytest-phmdoctest` pytest plugin to test Python examples in Markdown using phmdoctest. Apr 15, 2022 4 - Beta pytest (>=5.4.3) @@ -1019,7 +1022,7 @@ This list contains 1497 plugins. :pypi:`pytest-porringer` Jan 18, 2024 N/A pytest>=7.4.4 :pypi:`pytest-portion` Select a portion of the collected tests Jan 28, 2021 4 - Beta pytest (>=3.5.0) :pypi:`pytest-postgres` Run PostgreSQL in Docker container in Pytest. Mar 22, 2020 N/A pytest - :pypi:`pytest-postgresql` Postgresql fixtures and fixture factories for Pytest. Mar 11, 2024 5 - Production/Stable pytest >=6.2 + :pypi:`pytest-postgresql` Postgresql fixtures and fixture factories for Pytest. Aug 14, 2024 5 - Production/Stable pytest>=6.2 :pypi:`pytest-power` pytest plugin with powerful fixtures Dec 31, 2020 N/A pytest (>=5.4) :pypi:`pytest-powerpack` Mar 17, 2024 N/A pytest (>=8.1.1,<9.0.0) :pypi:`pytest-prefer-nested-dup-tests` A Pytest plugin to drop duplicated tests during collection, but will prefer keeping nested packages. Apr 27, 2022 4 - Beta pytest (>=7.1.1,<8.0.0) @@ -1101,6 +1104,7 @@ This list contains 1497 plugins. :pypi:`pytest-recorder` Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. Jun 27, 2024 N/A N/A :pypi:`pytest-recording` A pytest plugin that allows you recording of network interactions via VCR.py Jul 09, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-recordings` Provides pytest plugins for reporting request/response traffic, screenshots, and more to ReportPortal Aug 13, 2020 N/A N/A + :pypi:`pytest-record-video` 用例执行过程中录制视频 Aug 15, 2024 N/A N/A :pypi:`pytest-redis` Redis fixtures and fixture factories for Pytest. Jun 19, 2024 5 - Production/Stable pytest>=6.2 :pypi:`pytest-redislite` Pytest plugin for testing code using Redis Apr 05, 2022 4 - Beta pytest :pypi:`pytest-redmine` Pytest plugin for redmine Mar 19, 2018 1 - Planning N/A @@ -1195,7 +1199,7 @@ This list contains 1497 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Aug 07, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Aug 13, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 :pypi:`pytest-schedule` The job of test scheduling for humans. Jan 07, 2023 5 - Production/Stable N/A @@ -1205,7 +1209,7 @@ This list contains 1497 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Aug 07, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Aug 13, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1215,7 +1219,7 @@ This list contains 1497 plugins. :pypi:`pytest-server` test server exec cmd Jun 24, 2024 N/A N/A :pypi:`pytest-server-fixtures` Extensible server fixures for py.test Dec 19, 2023 5 - Production/Stable pytest :pypi:`pytest-serverless` Automatically mocks resources from serverless.yml in pytest using moto. May 09, 2022 4 - Beta N/A - :pypi:`pytest-servers` pytest servers Jul 19, 2024 3 - Alpha pytest>=6.2 + :pypi:`pytest-servers` pytest servers Aug 15, 2024 3 - Alpha pytest>=6.2 :pypi:`pytest-service` Aug 06, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-services` Services plugin for pytest testing framework Oct 30, 2020 6 - Mature N/A :pypi:`pytest-session2file` pytest-session2file (aka: pytest-session_to_file for v0.1.0 - v0.1.2) is a py.test plugin for capturing and saving to file the stdout of py.test. Jan 26, 2021 3 - Alpha pytest @@ -1237,7 +1241,7 @@ This list contains 1497 plugins. :pypi:`pytest-simple-plugin` Simple pytest plugin Nov 27, 2019 N/A N/A :pypi:`pytest-simple-settings` simple-settings plugin for pytest Nov 17, 2020 4 - Beta pytest :pypi:`pytest-single-file-logging` Allow for multiple processes to log to a single file May 05, 2016 4 - Beta pytest (>=2.8.1) - :pypi:`pytest-skip-markers` Pytest Salt Plugin Jan 04, 2024 5 - Production/Stable pytest >=7.1.0 + :pypi:`pytest-skip-markers` Pytest Salt Plugin Aug 09, 2024 5 - Production/Stable pytest>=7.1.0 :pypi:`pytest-skipper` A plugin that selects only tests with changes in execution path Mar 26, 2017 3 - Alpha pytest (>=3.0.6) :pypi:`pytest-skippy` Automatically skip tests that don't need to run! Jan 27, 2018 3 - Alpha pytest (>=2.3.4) :pypi:`pytest-skip-slow` A pytest plugin to skip \`@pytest.mark.slow\` tests by default. Feb 09, 2023 N/A pytest>=6.2.0 @@ -1283,12 +1287,12 @@ This list contains 1497 plugins. :pypi:`pytest-splitio` Split.io SDK integration for e2e tests Sep 22, 2020 N/A pytest (<7,>=5.0) :pypi:`pytest-split-tests` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Forked from Mark Adams' original project pytest-test-groups. Jul 30, 2021 5 - Production/Stable pytest (>=2.5) :pypi:`pytest-split-tests-tresorit` Feb 22, 2021 1 - Planning N/A - :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Aug 07, 2024 N/A pytest<8,>5.4.0 + :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Aug 14, 2024 N/A pytest<8,>5.4.0 :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Jul 10, 2024 N/A N/A :pypi:`pytest-splunk-env` pytest fixtures for interaction with Splunk Enterprise and Splunk Cloud Oct 22, 2020 N/A pytest (>=6.1.1,<7.0.0) :pypi:`pytest-sqitch` sqitch for pytest Apr 06, 2020 4 - Beta N/A :pypi:`pytest-sqlalchemy` pytest plugin with sqlalchemy related fixtures Mar 13, 2018 3 - Alpha N/A - :pypi:`pytest-sqlalchemy-mock` pytest sqlalchemy plugin for mock May 21, 2024 3 - Alpha pytest>=7.0.0 + :pypi:`pytest-sqlalchemy-mock` pytest sqlalchemy plugin for mock Aug 10, 2024 3 - Alpha pytest>=7.0.0 :pypi:`pytest-sqlalchemy-session` A pytest plugin for preserving test isolation that use SQLAlchemy. May 19, 2023 4 - Beta pytest (>=7.0) :pypi:`pytest-sql-bigquery` Yet another SQL-testing framework for BigQuery provided by pytest plugin Dec 19, 2019 N/A pytest :pypi:`pytest-sqlfluff` A pytest plugin to use sqlfluff to enable format checking of sql files. Dec 21, 2022 4 - Beta pytest (>=3.5.0) @@ -1511,7 +1515,7 @@ This list contains 1497 plugins. :pypi:`pytest-xvfb` A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. May 29, 2023 4 - Beta pytest (>=2.8.1) :pypi:`pytest-xvirt` A pytest plugin to virtualize test. For example to transparently running them on a remote box. Jul 03, 2024 4 - Beta pytest>=7.2.2 :pypi:`pytest-yaml` This plugin is used to load yaml output to your test using pytest framework. Oct 05, 2018 N/A pytest - :pypi:`pytest-yaml-sanmu` Pytest plugin for generating test cases with YAML. In test cases, you can use markers, fixtures, variables, and even call Python functions. Aug 03, 2024 N/A pytest~=8.2.2 + :pypi:`pytest-yaml-sanmu` Pytest plugin for generating test cases with YAML. In test cases, you can use markers, fixtures, variables, and even call Python functions. Aug 16, 2024 N/A pytest~=8.2.2 :pypi:`pytest-yamltree` Create or check file/directory trees described by YAML Mar 02, 2020 4 - Beta pytest (>=3.1.1) :pypi:`pytest-yamlwsgi` Run tests against wsgi apps defined in yaml May 11, 2010 N/A N/A :pypi:`pytest-yaml-yoyo` http/https API run by yaml Jun 19, 2023 N/A pytest (>=7.2.0) @@ -1817,7 +1821,7 @@ This list contains 1497 plugins. pytest-annotate: Generate PyAnnotate annotations from your pytest tests. :pypi:`pytest-ansible` - *last release*: Jul 24, 2024, + *last release*: Aug 16, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=6 @@ -2076,7 +2080,7 @@ This list contains 1497 plugins. Pytest fixtures for async generators :pypi:`pytest-asyncio` - *last release*: Jul 30, 2024, + *last release*: Aug 09, 2024, *status*: 4 - Beta, *requires*: pytest<9,>=7.0.0 @@ -2377,7 +2381,7 @@ This list contains 1497 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Aug 01, 2024, + *last release*: Aug 17, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -2776,7 +2780,7 @@ This list contains 1497 plugins. Pytest plugin with server for catching HTTP requests. :pypi:`pytest-celery` - *last release*: Jul 17, 2024, + *last release*: Aug 12, 2024, *status*: 4 - Beta, *requires*: N/A @@ -3000,7 +3004,7 @@ This list contains 1497 plugins. A cleanup plugin for pytest :pypi:`pytest-clerk` - *last release*: Jul 30, 2024, + *last release*: Aug 15, 2024, *status*: N/A, *requires*: pytest<9.0.0,>=8.0.0 @@ -3049,7 +3053,7 @@ This list contains 1497 plugins. Distribute tests to cloud machines without fuss :pypi:`pytest-cmake` - *last release*: Aug 09, 2024, + *last release*: Aug 16, 2024, *status*: N/A, *requires*: pytest<9,>=4 @@ -3322,7 +3326,7 @@ This list contains 1497 plugins. Coverage dynamic context support for PyTest, including sub-processes :pypi:`pytest-coveragemarkers` - *last release*: Jul 28, 2024, + *last release*: Aug 14, 2024, *status*: N/A, *requires*: pytest<8.0.0,>=7.1.2 @@ -4092,7 +4096,7 @@ This list contains 1497 plugins. Simple pytest fixtures for Docker and Docker Compose based tests :pypi:`pytest-docker-apache-fixtures` - *last release*: Feb 16, 2022, + *last release*: Aug 12, 2024, *status*: 4 - Beta, *requires*: pytest @@ -4141,14 +4145,14 @@ This list contains 1497 plugins. pytest docker fixtures :pypi:`pytest-docker-git-fixtures` - *last release*: Feb 09, 2022, + *last release*: Aug 12, 2024, *status*: 4 - Beta, *requires*: pytest Pytest fixtures for testing with git scm. :pypi:`pytest-docker-haproxy-fixtures` - *last release*: Feb 09, 2022, + *last release*: Aug 12, 2024, *status*: 4 - Beta, *requires*: pytest @@ -4176,7 +4180,7 @@ This list contains 1497 plugins. Easy to use, simple to extend, pytest plugin that minimally leverages docker-py. :pypi:`pytest-docker-registry-fixtures` - *last release*: Apr 08, 2022, + *last release*: Aug 12, 2024, *status*: 4 - Beta, *requires*: pytest @@ -4190,7 +4194,7 @@ This list contains 1497 plugins. pytest plugin to start docker container :pypi:`pytest-docker-squid-fixtures` - *last release*: Feb 09, 2022, + *last release*: Aug 12, 2024, *status*: 4 - Beta, *requires*: pytest @@ -4309,7 +4313,7 @@ This list contains 1497 plugins. A Pytest marker for only running a single test :pypi:`pytest-dpg` - *last release*: Aug 07, 2024, + *last release*: Aug 13, 2024, *status*: N/A, *requires*: N/A @@ -4498,56 +4502,56 @@ This list contains 1497 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: Aug 09, 2024, + *last release*: Aug 16, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: Aug 09, 2024, + *last release*: Aug 16, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: Aug 09, 2024, + *last release*: Aug 16, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: Aug 09, 2024, + *last release*: Aug 16, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. :pypi:`pytest-embedded-qemu` - *last release*: Aug 09, 2024, + *last release*: Aug 16, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: Aug 09, 2024, + *last release*: Aug 16, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: Aug 09, 2024, + *last release*: Aug 16, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: Aug 09, 2024, + *last release*: Aug 16, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -4736,12 +4740,19 @@ This list contains 1497 plugins. Parse queries in Lucene and Elasticsearch syntaxes :pypi:`pytest-examples` - *last release*: Jul 02, 2024, + *last release*: Aug 13, 2024, *status*: 4 - Beta, *requires*: pytest>=7 Pytest plugin for testing examples in docstrings and markdown files. + :pypi:`pytest-exasol-backend` + *last release*: Aug 14, 2024, + *status*: N/A, + *requires*: pytest<9,>=7 + + + :pypi:`pytest-exasol-itde` *last release*: Jul 01, 2024, *status*: N/A, @@ -4756,6 +4767,13 @@ This list contains 1497 plugins. + :pypi:`pytest-exasol-slc` + *last release*: Aug 15, 2024, + *status*: N/A, + *requires*: pytest<9,>=7 + + + :pypi:`pytest-excel` *last release*: Jun 18, 2024, *status*: 5 - Production/Stable, @@ -5205,7 +5223,7 @@ This list contains 1497 plugins. Common fixtures for pytest :pypi:`pytest-fixture-tools` - *last release*: Aug 18, 2020, + *last release*: Aug 15, 2024, *status*: 6 - Mature, *requires*: pytest @@ -5296,7 +5314,7 @@ This list contains 1497 plugins. :pypi:`pytest-fluent` - *last release*: Jun 05, 2024, + *last release*: Aug 14, 2024, *status*: 4 - Beta, *requires*: pytest>=7.0.0 @@ -5450,9 +5468,9 @@ This list contains 1497 plugins. pytest plugin for apps written with Google's AppEngine :pypi:`pytest-gather-fixtures` - *last release*: Apr 12, 2022, + *last release*: Aug 12, 2024, *status*: N/A, - *requires*: pytest (>=6.0.0) + *requires*: pytest>=7.0.0 set up asynchronous pytest fixtures concurrently @@ -5527,11 +5545,11 @@ This list contains 1497 plugins. Git repository fixture for py.test :pypi:`pytest-gitconfig` - *last release*: Oct 15, 2023, + *last release*: Aug 11, 2024, *status*: 4 - Beta, *requires*: pytest>=7.1.2 - Provide a gitconfig sandbox for testing + Provide a Git config sandbox for testing :pypi:`pytest-gitcov` *last release*: Jan 11, 2020, @@ -5814,7 +5832,7 @@ This list contains 1497 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Aug 08, 2024, + *last release*: Aug 17, 2024, *status*: 3 - Alpha, *requires*: pytest==8.3.1 @@ -5975,14 +5993,14 @@ This list contains 1497 plugins. A thin wrapper of HTTPretty for pytest :pypi:`pytest_httpserver` - *last release*: Jul 21, 2024, + *last release*: Aug 11, 2024, *status*: 3 - Alpha, *requires*: N/A pytest-httpserver is a httpserver for pytest :pypi:`pytest-httptesting` - *last release*: Jul 25, 2024, + *last release*: Aug 10, 2024, *status*: N/A, *requires*: pytest<9.0.0,>=8.2.0 @@ -6192,7 +6210,7 @@ This list contains 1497 plugins. Inmanta tests package :pypi:`pytest-inmanta-lsm` - *last release*: Jul 24, 2024, + *last release*: Aug 12, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -6500,7 +6518,7 @@ This list contains 1497 plugins. A reusable JupyterHub pytest plugin :pypi:`pytest-kafka` - *last release*: Jun 14, 2023, + *last release*: Aug 14, 2024, *status*: N/A, *requires*: pytest @@ -6983,7 +7001,7 @@ This list contains 1497 plugins. UNKNOWN :pypi:`pytest-mark-manage` - *last release*: Jul 08, 2024, + *last release*: Aug 15, 2024, *status*: N/A, *requires*: pytest @@ -7017,6 +7035,13 @@ This list contains 1497 plugins. Easy way to match captured \`pytest\` output against expectations stored in files + :pypi:`pytest-matchers` + *last release*: Aug 16, 2024, + *status*: N/A, + *requires*: N/A + + Matchers for pytest + :pypi:`pytest-match-skip` *last release*: May 15, 2019, *status*: 4 - Beta, @@ -8131,7 +8156,7 @@ This list contains 1497 plugins. Pytest tool for persistent objects :pypi:`pytest-pexpect` - *last release*: Mar 27, 2024, + *last release*: Aug 13, 2024, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -8432,9 +8457,9 @@ This list contains 1497 plugins. Run PostgreSQL in Docker container in Pytest. :pypi:`pytest-postgresql` - *last release*: Mar 11, 2024, + *last release*: Aug 14, 2024, *status*: 5 - Production/Stable, - *requires*: pytest >=6.2 + *requires*: pytest>=6.2 Postgresql fixtures and fixture factories for Pytest. @@ -9005,6 +9030,13 @@ This list contains 1497 plugins. Provides pytest plugins for reporting request/response traffic, screenshots, and more to ReportPortal + :pypi:`pytest-record-video` + *last release*: Aug 15, 2024, + *status*: N/A, + *requires*: N/A + + 用例执行过程中录制视频 + :pypi:`pytest-redis` *last release*: Jun 19, 2024, *status*: 5 - Production/Stable, @@ -9664,7 +9696,7 @@ This list contains 1497 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Aug 07, 2024, + *last release*: Aug 13, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9734,7 +9766,7 @@ This list contains 1497 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Aug 07, 2024, + *last release*: Aug 13, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9804,7 +9836,7 @@ This list contains 1497 plugins. Automatically mocks resources from serverless.yml in pytest using moto. :pypi:`pytest-servers` - *last release*: Jul 19, 2024, + *last release*: Aug 15, 2024, *status*: 3 - Alpha, *requires*: pytest>=6.2 @@ -9958,9 +9990,9 @@ This list contains 1497 plugins. Allow for multiple processes to log to a single file :pypi:`pytest-skip-markers` - *last release*: Jan 04, 2024, + *last release*: Aug 09, 2024, *status*: 5 - Production/Stable, - *requires*: pytest >=7.1.0 + *requires*: pytest>=7.1.0 Pytest Salt Plugin @@ -10280,7 +10312,7 @@ This list contains 1497 plugins. :pypi:`pytest-splunk-addon` - *last release*: Aug 07, 2024, + *last release*: Aug 14, 2024, *status*: N/A, *requires*: pytest<8,>5.4.0 @@ -10315,7 +10347,7 @@ This list contains 1497 plugins. pytest plugin with sqlalchemy related fixtures :pypi:`pytest-sqlalchemy-mock` - *last release*: May 21, 2024, + *last release*: Aug 10, 2024, *status*: 3 - Alpha, *requires*: pytest>=7.0.0 @@ -11876,7 +11908,7 @@ This list contains 1497 plugins. This plugin is used to load yaml output to your test using pytest framework. :pypi:`pytest-yaml-sanmu` - *last release*: Aug 03, 2024, + *last release*: Aug 16, 2024, *status*: N/A, *requires*: pytest~=8.2.2 From 33db65c112e5d76e89dd45024e272df214d2ea9c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 21:06:03 -0300 Subject: [PATCH 038/445] [pre-commit.ci] pre-commit autoupdate (#12725) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.5.7 → v0.6.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.7...v0.6.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e36d1e6137..a841a4a9a0f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.5.7" + rev: "v0.6.1" hooks: - id: ruff args: ["--fix"] From 51845fc70dba0fba27387e21e2db39d583892dec Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Thu, 22 Aug 2024 17:55:35 +0200 Subject: [PATCH 039/445] docs: clarify `pytest_deselected`/`pytest_collection_modifyitems` usage (#12729) Closes #12663 --- changelog/12663.doc.rst | 1 + src/_pytest/hookspec.py | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 changelog/12663.doc.rst diff --git a/changelog/12663.doc.rst b/changelog/12663.doc.rst new file mode 100644 index 00000000000..e665bc67a10 --- /dev/null +++ b/changelog/12663.doc.rst @@ -0,0 +1 @@ +Clarify that the `pytest_deselected` hook should be called from `pytest_collection_modifyitems` hook implementations when items are deselected. diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py index 99614899994..0a41b0aca47 100644 --- a/src/_pytest/hookspec.py +++ b/src/_pytest/hookspec.py @@ -274,6 +274,11 @@ def pytest_collection_modifyitems( """Called after collection has been performed. May filter or re-order the items in-place. + When items are deselected (filtered out from ``items``), + the hook :hook:`pytest_deselected` must be called explicitly + with the deselected items to properly notify other plugins, + e.g. with ``config.hook.pytest_deselected(deselected_items)``. + :param session: The pytest session object. :param config: The pytest config object. :param items: List of item objects. @@ -454,6 +459,12 @@ def pytest_collectreport(report: CollectReport) -> None: def pytest_deselected(items: Sequence[Item]) -> None: """Called for deselected test items, e.g. by keyword. + Note that this hook has two integration aspects for plugins: + + - it can be *implemented* to be notified of deselected items + - it must be *called* from :hook:`pytest_collection_modifyitems` + implementations when items are deselected (to properly notify other plugins). + May be called multiple times. :param items: From 05c43afae25b8ee7da3f69978802ce0f5e562e4e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 27 Aug 2024 23:32:54 +0200 Subject: [PATCH 040/445] [pre-commit.ci] pre-commit autoupdate (#12741) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.1 → v0.6.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.1...v0.6.2) - [github.com/pre-commit/mirrors-mypy: v1.11.1 → v1.11.2](https://github.com/pre-commit/mirrors-mypy/compare/v1.11.1...v1.11.2) * Fix sphinx with a more robust fix Until https://github.com/sphinx-contrib/sphinxcontrib-towncrier/issues/92 is resolved. Co-authored-by: Pierre Sassoulas --- .pre-commit-config.yaml | 4 ++-- doc/en/broken-dep-constraints.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a841a4a9a0f..938b0bf407b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.1" + rev: "v0.6.2" hooks: - id: ruff args: ["--fix"] @@ -21,7 +21,7 @@ repos: hooks: - id: python-use-type-annotations - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.1 + rev: v1.11.2 hooks: - id: mypy files: ^(src/|testing/|scripts/) diff --git a/doc/en/broken-dep-constraints.txt b/doc/en/broken-dep-constraints.txt index f7c3211a9a0..3a8d2c34b5a 100644 --- a/doc/en/broken-dep-constraints.txt +++ b/doc/en/broken-dep-constraints.txt @@ -3,4 +3,4 @@ # Pin towncrier temporarily due to incompatibility with sphinxcontrib-towncrier: # https://github.com/sphinx-contrib/sphinxcontrib-towncrier/issues/92 -towncrier!=24.7.0,!=24.7.1 +towncrier<24.7 From 8a834a26e932ef00acc9a354ded4efd675597429 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 17:32:46 +0000 Subject: [PATCH 041/445] build(deps): Bump pytest-asyncio in /testing/plugins_integration (#12739) Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.23.8 to 0.24.0. - [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases) - [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.23.8...v0.24.0) --- updated-dependencies: - dependency-name: pytest-asyncio dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index bd554c6307d..c48b55c0ae2 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,6 +1,6 @@ anyio[curio,trio]==4.4.0 django==5.1 -pytest-asyncio==0.23.8 +pytest-asyncio==0.24.0 pytest-bdd==7.2.0 pytest-cov==5.0.0 pytest-django==4.8.0 From e2483991561dfd7adbad9d78d7ba9585acd1547c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Wed, 28 Aug 2024 14:30:47 -0700 Subject: [PATCH 042/445] MAINT: adding back Python 3.13 classifier (#12743) * adding max_supported_python to pyproject-fmt config --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index f3eba4a08a8..ccd349fcdc7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Testing", "Topic :: Utilities", @@ -313,6 +314,7 @@ ignore = "W009" [tool.pyproject-fmt] indent = 4 +max_supported_python = "3.13" [tool.pytest.ini_options] minversion = "2.0" From ab259a36e3359659e4568358fb0e9d43b10be5de Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 28 Aug 2024 21:34:09 +0000 Subject: [PATCH 043/445] [automated] Update plugin list (#12738) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 210 +++++++++++++++++-------------- 1 file changed, 113 insertions(+), 97 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 43fa0be55a8..d425454ea87 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =7.0.0 + :pypi:`pytest-asyncio` Pytest support for asyncio Aug 22, 2024 4 - Beta pytest<9,>=8.2 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Jul 04, 2024 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) :pypi:`pytest-async-mongodb` pytest plugin for async MongoDB Oct 18, 2017 5 - Production/Stable pytest (>=2.5.2) @@ -154,7 +154,7 @@ This list contains 1501 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Aug 08, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Aug 17, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Aug 22, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -256,7 +256,7 @@ This list contains 1501 plugins. :pypi:`pytest_codeblocks` Test code blocks in your READMEs Sep 17, 2023 5 - Production/Stable pytest >= 7.0.0 :pypi:`pytest-codecarbon` Pytest plugin for measuring carbon emissions Jun 15, 2022 N/A pytest :pypi:`pytest-codecheckers` pytest plugin to add source code sanity checks (pep8 and friends) Feb 13, 2010 N/A N/A - :pypi:`pytest-codecov` Pytest plugin for uploading pytest-cov results to codecov.io Nov 29, 2022 4 - Beta pytest (>=4.6.0) + :pypi:`pytest-codecov` Pytest plugin for uploading pytest-cov results to codecov.io Aug 21, 2024 4 - Beta pytest>=4.6.0 :pypi:`pytest-codegen` Automatically create pytest test signatures Aug 23, 2020 2 - Pre-Alpha N/A :pypi:`pytest-codeowners` Pytest plugin for selecting tests by GitHub CODEOWNERS. Mar 30, 2022 4 - Beta pytest (>=6.0.0) :pypi:`pytest-codestyle` pytest plugin to run pycodestyle Mar 23, 2020 3 - Alpha N/A @@ -293,7 +293,6 @@ This list contains 1501 plugins. :pypi:`pytest-cov-exclude` Pytest plugin for excluding tests based on coverage data Apr 29, 2016 4 - Beta pytest (>=2.8.0,<2.9.0); extra == 'dev' :pypi:`pytest_covid` Too many faillure, less tests. Jun 24, 2020 N/A N/A :pypi:`pytest-cpp` Use pytest's runner to discover and execute C++ tests Nov 01, 2023 5 - Production/Stable pytest >=7.0 - :pypi:`pytest-cppython` A pytest plugin that imports CPPython testing types Mar 14, 2024 N/A N/A :pypi:`pytest-cqase` Custom qase pytest plugin Aug 22, 2022 N/A pytest (>=7.1.2,<8.0.0) :pypi:`pytest-cram` Run cram tests with pytest. Aug 08, 2020 N/A N/A :pypi:`pytest-crate` Manages CrateDB instances during your integration tests May 28, 2019 3 - Alpha pytest (>=4.0) @@ -317,7 +316,7 @@ This list contains 1501 plugins. :pypi:`pytest-dash` pytest fixtures to run dash applications. Mar 18, 2019 N/A N/A :pypi:`pytest-dashboard` May 30, 2024 N/A pytest<8.0.0,>=7.4.3 :pypi:`pytest-data` Useful functions for managing data for pytest fixtures Nov 01, 2016 5 - Production/Stable N/A - :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Aug 07, 2024 4 - Beta pytest + :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Aug 20, 2024 4 - Beta pytest :pypi:`pytest-databricks` Pytest plugin for remote Databricks notebooks testing Jul 29, 2020 N/A pytest :pypi:`pytest-datadir` pytest plugin for test data directories and files Oct 03, 2023 5 - Production/Stable pytest >=5.0 :pypi:`pytest-datadir-mgr` Manager for test data: downloads, artifact caching, and a tmpdir context. Apr 06, 2023 5 - Production/Stable pytest (>=7.1) @@ -333,7 +332,7 @@ This list contains 1501 plugins. :pypi:`pytest-dataset` Plugin for loading different datasets for pytest by prefix from json or yaml files Sep 01, 2023 5 - Production/Stable N/A :pypi:`pytest-data-suites` Class-based pytest parametrization Apr 06, 2024 N/A pytest<9.0,>=6.0 :pypi:`pytest-datatest` A pytest plugin for test driven data-wrangling (this is the development version of datatest's pytest integration). Oct 15, 2020 4 - Beta pytest (>=3.3) - :pypi:`pytest-db` Session scope fixture "db" for mysql query or change Dec 04, 2019 N/A N/A + :pypi:`pytest-db` Session scope fixture "db" for mysql query or change Aug 22, 2024 N/A pytest :pypi:`pytest-dbfixtures` Databases fixtures plugin for py.test. Dec 07, 2016 4 - Beta N/A :pypi:`pytest-db-plugin` Nov 27, 2021 N/A pytest (>=5.0) :pypi:`pytest-dbt` Unit test dbt models with standard python tooling Jun 08, 2023 2 - Pre-Alpha pytest (>=7.0.0,<8.0.0) @@ -453,18 +452,19 @@ This list contains 1501 plugins. :pypi:`pytest-edit` Edit the source code of a failed test with \`pytest --edit\`. Jun 09, 2024 N/A pytest :pypi:`pytest-ekstazi` Pytest plugin to select test using Ekstazi algorithm Sep 10, 2022 N/A pytest :pypi:`pytest-elasticsearch` Elasticsearch fixtures and fixture factories for Pytest. Mar 15, 2024 5 - Production/Stable pytest >=7.0 + :pypi:`pytest-elasticsearch-test` Elasticsearch fixtures and fixture factories for Pytest. Aug 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-elements` Tool to help automate user interfaces Jan 13, 2021 N/A pytest (>=5.4,<6.0) :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Aug 16, 2024 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Aug 16, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Aug 16, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Aug 16, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Aug 16, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Aug 16, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Aug 16, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Aug 16, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Aug 19, 2024 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Aug 19, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Aug 19, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Aug 19, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Aug 19, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Aug 19, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Aug 19, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Aug 19, 2024 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -492,7 +492,7 @@ This list contains 1501 plugins. :pypi:`pytest-evm` The testing package containing tools to test Web3-based projects Apr 22, 2024 4 - Beta pytest<9.0.0,>=8.1.1 :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Aug 13, 2024 4 - Beta pytest>=7 - :pypi:`pytest-exasol-backend` Aug 14, 2024 N/A pytest<9,>=7 + :pypi:`pytest-exasol-backend` Aug 23, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-itde` Jul 01, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-saas` Aug 06, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-slc` Aug 15, 2024 N/A pytest<9,>=7 @@ -595,7 +595,7 @@ This list contains 1501 plugins. :pypi:`pytest-fxtest` Oct 27, 2020 N/A N/A :pypi:`pytest-fzf` fzf-based test selector for pytest Jul 03, 2024 4 - Beta pytest>=6.0.0 :pypi:`pytest_gae` pytest plugin for apps written with Google's AppEngine Aug 03, 2016 3 - Alpha N/A - :pypi:`pytest-gather-fixtures` set up asynchronous pytest fixtures concurrently Aug 12, 2024 N/A pytest>=7.0.0 + :pypi:`pytest-gather-fixtures` set up asynchronous pytest fixtures concurrently Aug 18, 2024 N/A pytest>=7.0.0 :pypi:`pytest-gc` The garbage collector plugin for py.test Feb 01, 2018 N/A N/A :pypi:`pytest-gcov` Uses gcov to measure test coverage of a C library Feb 01, 2018 3 - Alpha N/A :pypi:`pytest-gcs` GCS fixtures and fixture factories for Pytest. Mar 01, 2024 5 - Production/Stable pytest >=6.2 @@ -657,7 +657,7 @@ This list contains 1501 plugins. :pypi:`pytest-hoverfly-wrapper` Integrates the Hoverfly HTTP proxy into Pytest Feb 27, 2023 5 - Production/Stable pytest (>=3.7.0) :pypi:`pytest-hpfeeds` Helpers for testing hpfeeds in your python project Feb 28, 2023 4 - Beta pytest (>=6.2.4,<7.0.0) :pypi:`pytest-html` pytest plugin for generating HTML reports Nov 07, 2023 5 - Production/Stable pytest>=7.0.0 - :pypi:`pytest-html-cn` pytest plugin for generating HTML reports Aug 01, 2023 5 - Production/Stable N/A + :pypi:`pytest-html-cn` pytest plugin for generating HTML reports Aug 19, 2024 5 - Production/Stable pytest!=6.0.0,>=5.0 :pypi:`pytest-html-lee` optimized pytest plugin for generating HTML reports Jun 30, 2020 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-html-merger` Pytest HTML reports merging utility Jul 12, 2024 N/A N/A :pypi:`pytest-html-object-storage` Pytest report plugin for send HTML report on object-storage Jan 17, 2024 5 - Production/Stable N/A @@ -665,7 +665,7 @@ This list contains 1501 plugins. :pypi:`pytest-html-reporter` Generates a static html report based on pytest framework Feb 13, 2022 N/A N/A :pypi:`pytest-html-report-merger` May 22, 2024 N/A N/A :pypi:`pytest-html-thread` pytest plugin for generating HTML reports Dec 29, 2020 5 - Production/Stable N/A - :pypi:`pytest-http` Fixture "http" for http requests Dec 05, 2019 N/A N/A + :pypi:`pytest-http` Fixture "http" for http requests Aug 22, 2024 N/A pytest :pypi:`pytest-httpbin` Easily test your HTTP library against a local copy of httpbin May 08, 2023 5 - Production/Stable pytest ; extra == 'test' :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace Jan 10, 2024 3 - Alpha pytest >=7.0.0 :pypi:`pytest-http-mocker` Pytest plugin for http mocking (via https://github.com/vilus/mocker) Oct 20, 2019 N/A N/A @@ -699,9 +699,9 @@ This list contains 1501 plugins. :pypi:`pytest-ini` Reuse pytest.ini to store env variables Apr 26, 2022 N/A N/A :pypi:`pytest-initry` Plugin for sending automation test data from Pytest to the initry Apr 30, 2024 N/A pytest<9.0.0,>=8.1.1 :pypi:`pytest-inline` A pytest plugin for writing inline tests. Oct 19, 2023 4 - Beta pytest >=7.0.0 - :pypi:`pytest-inmanta` A py.test plugin providing fixtures to simplify inmanta modules testing. Jul 05, 2024 5 - Production/Stable pytest + :pypi:`pytest-inmanta` A py.test plugin providing fixtures to simplify inmanta modules testing. Aug 19, 2024 5 - Production/Stable pytest :pypi:`pytest-inmanta-extensions` Inmanta tests package Jul 22, 2024 5 - Production/Stable N/A - :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Aug 12, 2024 5 - Production/Stable N/A + :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Aug 20, 2024 5 - Production/Stable N/A :pypi:`pytest-inmanta-yang` Common fixtures used in inmanta yang related modules Feb 22, 2024 4 - Beta pytest :pypi:`pytest-Inomaly` A simple image diff plugin for pytest Feb 13, 2018 4 - Beta N/A :pypi:`pytest-in-robotframework` The extension enables easy execution of pytest tests within the Robot Framework environment. Mar 02, 2024 N/A pytest @@ -718,11 +718,12 @@ This list contains 1501 plugins. :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A - :pypi:`pytest-ipywidgets` Aug 02, 2024 N/A pytest + :pypi:`pytest-ipywidgets` Aug 21, 2024 N/A pytest :pypi:`pytest-isolate` Feb 20, 2023 4 - Beta pytest :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-it` Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it. Jan 29, 2024 4 - Beta N/A :pypi:`pytest-iterassert` Nicer list and iterable assertion messages for pytest May 11, 2020 3 - Alpha N/A + :pypi:`pytest-iteration` Add iteration mark for tests Aug 22, 2024 N/A pytest :pypi:`pytest-iters` A contextmanager pytest fixture for handling multiple mock iters May 24, 2022 N/A N/A :pypi:`pytest_jar_yuan` A allure and pytest used package Dec 12, 2022 N/A N/A :pypi:`pytest-jasmine` Run jasmine tests from your pytest test suite Nov 04, 2017 1 - Planning N/A @@ -736,7 +737,7 @@ This list contains 1501 plugins. :pypi:`pytest-jobserver` Limit parallel tests with posix jobserver. May 15, 2019 5 - Production/Stable pytest :pypi:`pytest-joke` Test failures are better served with humor. Oct 08, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-json` Generate JSON test reports Jan 18, 2016 4 - Beta N/A - :pypi:`pytest-json-ctrf` Pytest plugin to generate json report in CTRF (Common Test Report Format) Jun 15, 2024 N/A pytest>6.0.0 + :pypi:`pytest-json-ctrf` Pytest plugin to generate json report in CTRF (Common Test Report Format) Aug 17, 2024 N/A pytest>6.0.0 :pypi:`pytest-json-fixtures` JSON output for the --fixtures flag Mar 14, 2023 4 - Beta N/A :pypi:`pytest-jsonlint` UNKNOWN Aug 04, 2016 N/A N/A :pypi:`pytest-json-report` A pytest plugin to report test results as JSON files Mar 15, 2022 4 - Beta pytest (>=3.8.0) @@ -789,7 +790,7 @@ This list contains 1501 plugins. :pypi:`pytest-live` Live results for pytest Mar 08, 2020 N/A pytest :pypi:`pytest-local-badge` Generate local badges (shields) reporting your test suite status. Jan 15, 2023 N/A pytest (>=6.1.0) :pypi:`pytest-localftpserver` A PyTest plugin which provides an FTP fixture for your tests May 19, 2024 5 - Production/Stable pytest - :pypi:`pytest-localserver` pytest plugin to test server connections locally. Oct 12, 2023 4 - Beta N/A + :pypi:`pytest-localserver` pytest plugin to test server connections locally. Aug 17, 2024 4 - Beta N/A :pypi:`pytest-localstack` Pytest plugin for AWS integration tests Jun 07, 2023 4 - Beta pytest (>=6.0.0,<7.0.0) :pypi:`pytest-lock` pytest-lock is a pytest plugin that allows you to "lock" the results of unit tests, storing them in a local cache. This is particularly useful for tests that are resource-intensive or don't need to be run every time. When the tests are run subsequently, pytest-lock will compare the current results with the locked results and issue a warning if there are any discrepancies. Feb 03, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-lockable` lockable resource plugin for pytest Jan 24, 2024 5 - Production/Stable pytest @@ -819,7 +820,7 @@ This list contains 1501 plugins. :pypi:`pytest-marks` UNKNOWN Nov 23, 2012 3 - Alpha N/A :pypi:`pytest-mask-secrets` Pytest plugin to hide sensitive data in test reports Aug 06, 2024 N/A N/A :pypi:`pytest-matcher` Easy way to match captured \`pytest\` output against expectations stored in files Aug 01, 2024 5 - Production/Stable pytest - :pypi:`pytest-matchers` Matchers for pytest Aug 16, 2024 N/A N/A + :pypi:`pytest-matchers` Matchers for pytest Aug 24, 2024 N/A pytest<9.0,>=7.0 :pypi:`pytest-match-skip` Skip matching marks. Matches partial marks using wildcards. May 15, 2019 4 - Beta pytest (>=4.4.1) :pypi:`pytest-mat-report` this is report Jan 20, 2021 N/A N/A :pypi:`pytest-matrix` Provide tools for generating tests from combinations of fixtures. Jun 24, 2020 5 - Production/Stable pytest (>=5.4.3,<6.0.0) @@ -940,14 +941,14 @@ This list contains 1501 plugins. :pypi:`pytest-optional` include/exclude values of fixtures in pytest Oct 07, 2015 N/A N/A :pypi:`pytest-optional-tests` Easy declaration of optional tests (i.e., that are not run by default) Jul 09, 2019 4 - Beta pytest (>=4.5.0) :pypi:`pytest-orchestration` A pytest plugin for orchestrating tests Jul 18, 2019 N/A N/A - :pypi:`pytest-order` pytest plugin to run your tests in a specific order Apr 02, 2024 4 - Beta pytest>=5.0; python_version < "3.10" + :pypi:`pytest-order` pytest plugin to run your tests in a specific order Aug 22, 2024 5 - Production/Stable pytest>=5.0; python_version < "3.10" :pypi:`pytest-ordering` pytest plugin to run your tests in a specific order Nov 14, 2018 4 - Beta pytest :pypi:`pytest-order-modify` 新增run_marker 来自定义用例的执行顺序 Nov 04, 2022 N/A N/A :pypi:`pytest-osxnotify` OS X notifications for py.test results. May 15, 2015 N/A N/A :pypi:`pytest-ot` A pytest plugin for instrumenting test runs via OpenTelemetry Mar 21, 2024 N/A pytest; extra == "dev" :pypi:`pytest-otel` OpenTelemetry plugin for Pytest Mar 18, 2024 N/A pytest==8.1.1 :pypi:`pytest-override-env-var` Pytest mark to override a value of an environment variable. Feb 25, 2023 N/A N/A - :pypi:`pytest-owner` Add owner mark for tests Apr 25, 2022 N/A N/A + :pypi:`pytest-owner` Add owner mark for tests Aug 19, 2024 N/A pytest :pypi:`pytest-pact` A simple plugin to use with pytest Jan 07, 2019 4 - Beta N/A :pypi:`pytest-pahrametahrize` Parametrize your tests with a Boston accent. Nov 24, 2021 4 - Beta pytest (>=6.0,<7.0) :pypi:`pytest-parallel` a pytest plugin for parallel and concurrent testing Oct 10, 2021 3 - Alpha pytest (>=3.0.0) @@ -978,7 +979,7 @@ This list contains 1501 plugins. :pypi:`pytest-perf` Run performance tests against the mainline code. May 20, 2024 5 - Production/Stable pytest!=8.1.*,>=6; extra == "testing" :pypi:`pytest-performance` A simple plugin to ensure the execution of critical sections of code has not been impacted Sep 11, 2020 5 - Production/Stable pytest (>=3.7.0) :pypi:`pytest-performancetotal` A performance plugin for pytest Mar 19, 2024 4 - Beta N/A - :pypi:`pytest-persistence` Pytest tool for persistent objects May 23, 2024 N/A N/A + :pypi:`pytest-persistence` Pytest tool for persistent objects Aug 21, 2024 N/A N/A :pypi:`pytest-pexpect` Pytest pexpect plugin. Aug 13, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-pg` A tiny plugin for pytest which runs PostgreSQL in Docker May 21, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-pgsql` Pytest plugins and helpers for tests using a Postgres database. May 13, 2020 5 - Production/Stable pytest (>=3.0.0) @@ -1019,7 +1020,6 @@ This list contains 1501 plugins. :pypi:`pytest-poo-fail` Visualize your failed tests with poo Feb 12, 2015 5 - Production/Stable N/A :pypi:`pytest-pook` Pytest plugin for pook Feb 15, 2024 4 - Beta pytest :pypi:`pytest-pop` A pytest plugin to help with testing pop projects May 09, 2023 5 - Production/Stable pytest - :pypi:`pytest-porringer` Jan 18, 2024 N/A pytest>=7.4.4 :pypi:`pytest-portion` Select a portion of the collected tests Jan 28, 2021 4 - Beta pytest (>=3.5.0) :pypi:`pytest-postgres` Run PostgreSQL in Docker container in Pytest. Mar 22, 2020 N/A pytest :pypi:`pytest-postgresql` Postgresql fixtures and fixture factories for Pytest. Aug 14, 2024 5 - Production/Stable pytest>=6.2 @@ -1030,7 +1030,7 @@ This list contains 1501 plugins. :pypi:`pytest-pretty-terminal` pytest plugin for generating prettier terminal output Jan 31, 2022 N/A pytest (>=3.4.1) :pypi:`pytest-pride` Minitest-style test colors Apr 02, 2016 3 - Alpha N/A :pypi:`pytest-print` pytest-print adds the printer fixture you can use to print messages to the user (directly to the pytest runner, not stdout) Aug 25, 2023 5 - Production/Stable pytest>=7.4 - :pypi:`pytest-priority` pytest plugin for add priority for tests Jul 23, 2023 N/A N/A + :pypi:`pytest-priority` pytest plugin for add priority for tests Aug 19, 2024 N/A pytest :pypi:`pytest-proceed` Apr 10, 2024 N/A pytest :pypi:`pytest-profiles` pytest plugin for configuration profiles Dec 09, 2021 4 - Beta pytest (>=3.7.0) :pypi:`pytest-profiling` Profiling plugin for py.test May 28, 2019 5 - Production/Stable pytest @@ -1064,7 +1064,7 @@ This list contains 1501 plugins. :pypi:`pytest-pyramid-server` Pyramid server fixture for py.test May 28, 2019 5 - Production/Stable pytest :pypi:`pytest-pyreport` PyReport is a lightweight reporting plugin for Pytest that provides concise HTML report May 05, 2024 N/A pytest :pypi:`pytest-pyright` Pytest plugin for type checking code with Pyright Jan 26, 2024 4 - Beta pytest >=7.0.0 - :pypi:`pytest-pyspec` A plugin that transforms the pytest output into a result similar to the RSpec. It enables the use of docstrings to display results and also enables the use of the prefixes "describe", "with" and "it". Jan 02, 2024 N/A pytest (>=7.2.1,<8.0.0) + :pypi:`pytest-pyspec` A plugin that transforms the pytest output into a result similar to the RSpec. It enables the use of docstrings to display results and also enables the use of the prefixes "describe", "with" and "it". Aug 17, 2024 N/A pytest<9.0.0,>=8.3.2 :pypi:`pytest-pystack` Plugin to run pystack after a timeout for a test suite. Jan 04, 2024 N/A pytest >=3.5.0 :pypi:`pytest-pytestrail` Pytest plugin for interaction with TestRail Aug 27, 2020 4 - Beta pytest (>=3.8.0) :pypi:`pytest-pythonhashseed` Pytest plugin to set PYTHONHASHSEED env var. Feb 25, 2024 4 - Beta pytest>=3.0.0 @@ -1100,7 +1100,7 @@ This list contains 1501 plugins. :pypi:`pytest-random-order` Randomise the order in which pytest tests are run with some control over the randomness Jan 20, 2024 5 - Production/Stable pytest >=3.0.0 :pypi:`pytest-ranking` A Pytest plugin for automatically prioritizing/ranking tests to speed up failure detection Jun 07, 2024 4 - Beta pytest>=7.4.3 :pypi:`pytest-readme` Test your README.md file Sep 02, 2022 5 - Production/Stable N/A - :pypi:`pytest-reana` Pytest fixtures for REANA. Mar 14, 2024 3 - Alpha N/A + :pypi:`pytest-reana` Pytest fixtures for REANA. Aug 21, 2024 3 - Alpha N/A :pypi:`pytest-recorder` Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. Jun 27, 2024 N/A N/A :pypi:`pytest-recording` A pytest plugin that allows you recording of network interactions via VCR.py Jul 09, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-recordings` Provides pytest plugins for reporting request/response traffic, screenshots, and more to ReportPortal Aug 13, 2020 N/A N/A @@ -1174,7 +1174,7 @@ This list contains 1501 plugins. :pypi:`pytest-rmsis` Sycronise pytest results to Jira RMsis Aug 10, 2022 N/A pytest (>=5.3.5) :pypi:`pytest-rng` Fixtures for seeding tests and making randomness reproducible Aug 08, 2019 5 - Production/Stable pytest :pypi:`pytest-roast` pytest plugin for ROAST configuration override and fixtures Nov 09, 2022 5 - Production/Stable pytest - :pypi:`pytest_robotframework` a pytest plugin that can run both python and robotframework tests while generating robot reports for them Jul 01, 2024 N/A pytest<9,>=7 + :pypi:`pytest_robotframework` a pytest plugin that can run both python and robotframework tests while generating robot reports for them Aug 21, 2024 N/A pytest<9,>=7 :pypi:`pytest-rocketchat` Pytest to Rocket.Chat reporting plugin Apr 18, 2021 5 - Production/Stable N/A :pypi:`pytest-rotest` Pytest integration with rotest Sep 08, 2019 N/A pytest (>=3.5.0) :pypi:`pytest-rpc` Extend py.test for RPC OpenStack testing. Feb 22, 2019 4 - Beta pytest (~=3.6) @@ -1205,6 +1205,7 @@ This list contains 1501 plugins. :pypi:`pytest-schedule` The job of test scheduling for humans. Jan 07, 2023 5 - Production/Stable N/A :pypi:`pytest-schema` 👍 Validate return values against a schema-like object in testing Feb 16, 2024 5 - Production/Stable pytest >=3.5.0 :pypi:`pytest-screenshot-on-failure` Saves a screenshot when a test case from a pytest execution fails Jul 21, 2023 4 - Beta N/A + :pypi:`pytest-scrutinize` Scrutinize your pytest test suites for slow fixtures, tests and more. Aug 19, 2024 4 - Beta pytest>=6 :pypi:`pytest-securestore` An encrypted password store for use within pytest cases Nov 08, 2021 4 - Beta N/A :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 @@ -1304,6 +1305,7 @@ This list contains 1501 plugins. :pypi:`pytest-static` pytest-static Aug 09, 2024 1 - Planning pytest<8.0.0,>=7.4.3 :pypi:`pytest-stats` Collects tests metadata for future analysis, easy to extend for any data store Jul 18, 2024 N/A pytest>=8.0.0 :pypi:`pytest-statsd` pytest plugin for reporting to graphite Nov 30, 2018 5 - Production/Stable pytest (>=3.0.0) + :pypi:`pytest-status` Add status mark for tests Aug 22, 2024 N/A pytest :pypi:`pytest-stepfunctions` A small description May 08, 2021 4 - Beta pytest :pypi:`pytest-steps` Create step-wise / incremental tests in pytest. Sep 23, 2021 5 - Production/Stable N/A :pypi:`pytest-stepwise` Run a test suite one failing test at a time. Dec 01, 2015 4 - Beta N/A @@ -1327,7 +1329,6 @@ This list contains 1501 plugins. :pypi:`pytest-supercov` Pytest plugin for measuring explicit test-file to source-file coverage Jul 02, 2023 N/A N/A :pypi:`pytest-svn` SVN repository fixture for py.test May 28, 2019 5 - Production/Stable pytest :pypi:`pytest-symbols` pytest-symbols is a pytest plugin that adds support for passing test environment symbols into pytest tests. Nov 20, 2017 3 - Alpha N/A - :pypi:`pytest-synodic` Synodic Pytest utilities Mar 09, 2024 N/A pytest>=8.0.2 :pypi:`pytest-system-statistics` Pytest plugin to track and report system usage statistics Feb 16, 2022 5 - Production/Stable pytest (>=6.0.0) :pypi:`pytest-system-test-plugin` Pyst - Pytest System-Test Plugin Feb 03, 2022 N/A N/A :pypi:`pytest_tagging` a pytest plugin to tag tests Apr 08, 2024 N/A pytest<8.0.0,>=7.1.3 @@ -1379,7 +1380,7 @@ This list contains 1501 plugins. :pypi:`pytest-testslide` TestSlide fixture for pytest Jan 07, 2021 5 - Production/Stable pytest (~=6.2) :pypi:`pytest-test-this` Plugin for py.test to run relevant tests, based on naively checking if a test contains a reference to the symbol you supply Sep 15, 2019 2 - Pre-Alpha pytest (>=2.3) :pypi:`pytest-test-tracer-for-pytest` A plugin that allows coll test data for use on Test Tracer Jun 28, 2024 4 - Beta pytest>=6.2.0 - :pypi:`pytest-test-tracer-for-pytest-bdd` A plugin that allows coll test data for use on Test Tracer Jul 29, 2024 4 - Beta pytest>=6.2.0 + :pypi:`pytest-test-tracer-for-pytest-bdd` A plugin that allows coll test data for use on Test Tracer Aug 20, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-test-utils` Feb 08, 2024 N/A pytest >=3.9 :pypi:`pytest-tesults` Tesults plugin for pytest Feb 15, 2024 5 - Production/Stable pytest >=3.5.0 :pypi:`pytest-textual-snapshot` Snapshot testing for Textual apps Jul 22, 2024 4 - Beta pytest>=8.0.0 @@ -1530,6 +1531,7 @@ This list contains 1501 plugins. :pypi:`pytest-zcc` eee Jun 02, 2024 N/A N/A :pypi:`pytest-zebrunner` Pytest connector for Zebrunner reporting Jul 04, 2024 5 - Production/Stable pytest>=4.5.0 :pypi:`pytest-zeebe` Pytest fixtures for testing Camunda 8 processes using a Zeebe test engine. Feb 01, 2024 N/A pytest (>=7.4.2,<8.0.0) + :pypi:`pytest-zephyr-scale-integration` A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest Aug 20, 2024 N/A pytest :pypi:`pytest-zest` Zesty additions to pytest. Nov 17, 2022 N/A N/A :pypi:`pytest-zhongwen-wendang` PyTest 中文文档 Mar 04, 2024 4 - Beta N/A :pypi:`pytest-zigzag` Extend py.test for RPC OpenStack testing. Feb 27, 2019 4 - Beta pytest (~=3.6) @@ -2080,9 +2082,9 @@ This list contains 1501 plugins. Pytest fixtures for async generators :pypi:`pytest-asyncio` - *last release*: Aug 09, 2024, + *last release*: Aug 22, 2024, *status*: 4 - Beta, - *requires*: pytest<9,>=7.0.0 + *requires*: pytest<9,>=8.2 Pytest support for asyncio @@ -2381,7 +2383,7 @@ This list contains 1501 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Aug 17, 2024, + *last release*: Aug 22, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -3095,9 +3097,9 @@ This list contains 1501 plugins. pytest plugin to add source code sanity checks (pep8 and friends) :pypi:`pytest-codecov` - *last release*: Nov 29, 2022, + *last release*: Aug 21, 2024, *status*: 4 - Beta, - *requires*: pytest (>=4.6.0) + *requires*: pytest>=4.6.0 Pytest plugin for uploading pytest-cov results to codecov.io @@ -3353,13 +3355,6 @@ This list contains 1501 plugins. Use pytest's runner to discover and execute C++ tests - :pypi:`pytest-cppython` - *last release*: Mar 14, 2024, - *status*: N/A, - *requires*: N/A - - A pytest plugin that imports CPPython testing types - :pypi:`pytest-cqase` *last release*: Aug 22, 2022, *status*: N/A, @@ -3522,7 +3517,7 @@ This list contains 1501 plugins. Useful functions for managing data for pytest fixtures :pypi:`pytest-databases` - *last release*: Aug 07, 2024, + *last release*: Aug 20, 2024, *status*: 4 - Beta, *requires*: pytest @@ -3634,9 +3629,9 @@ This list contains 1501 plugins. A pytest plugin for test driven data-wrangling (this is the development version of datatest's pytest integration). :pypi:`pytest-db` - *last release*: Dec 04, 2019, + *last release*: Aug 22, 2024, *status*: N/A, - *requires*: N/A + *requires*: pytest Session scope fixture "db" for mysql query or change @@ -4473,6 +4468,13 @@ This list contains 1501 plugins. Elasticsearch fixtures and fixture factories for Pytest. + :pypi:`pytest-elasticsearch-test` + *last release*: Aug 21, 2024, + *status*: 5 - Production/Stable, + *requires*: pytest>=7.0 + + Elasticsearch fixtures and fixture factories for Pytest. + :pypi:`pytest-elements` *last release*: Jan 13, 2021, *status*: N/A, @@ -4502,56 +4504,56 @@ This list contains 1501 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: Aug 16, 2024, + *last release*: Aug 19, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: Aug 16, 2024, + *last release*: Aug 19, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: Aug 16, 2024, + *last release*: Aug 19, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: Aug 16, 2024, + *last release*: Aug 19, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. :pypi:`pytest-embedded-qemu` - *last release*: Aug 16, 2024, + *last release*: Aug 19, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: Aug 16, 2024, + *last release*: Aug 19, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: Aug 16, 2024, + *last release*: Aug 19, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: Aug 16, 2024, + *last release*: Aug 19, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -4747,7 +4749,7 @@ This list contains 1501 plugins. Pytest plugin for testing examples in docstrings and markdown files. :pypi:`pytest-exasol-backend` - *last release*: Aug 14, 2024, + *last release*: Aug 23, 2024, *status*: N/A, *requires*: pytest<9,>=7 @@ -5468,7 +5470,7 @@ This list contains 1501 plugins. pytest plugin for apps written with Google's AppEngine :pypi:`pytest-gather-fixtures` - *last release*: Aug 12, 2024, + *last release*: Aug 18, 2024, *status*: N/A, *requires*: pytest>=7.0.0 @@ -5902,9 +5904,9 @@ This list contains 1501 plugins. pytest plugin for generating HTML reports :pypi:`pytest-html-cn` - *last release*: Aug 01, 2023, + *last release*: Aug 19, 2024, *status*: 5 - Production/Stable, - *requires*: N/A + *requires*: pytest!=6.0.0,>=5.0 pytest plugin for generating HTML reports @@ -5958,9 +5960,9 @@ This list contains 1501 plugins. pytest plugin for generating HTML reports :pypi:`pytest-http` - *last release*: Dec 05, 2019, + *last release*: Aug 22, 2024, *status*: N/A, - *requires*: N/A + *requires*: pytest Fixture "http" for http requests @@ -6196,7 +6198,7 @@ This list contains 1501 plugins. A pytest plugin for writing inline tests. :pypi:`pytest-inmanta` - *last release*: Jul 05, 2024, + *last release*: Aug 19, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -6210,7 +6212,7 @@ This list contains 1501 plugins. Inmanta tests package :pypi:`pytest-inmanta-lsm` - *last release*: Aug 12, 2024, + *last release*: Aug 20, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -6329,7 +6331,7 @@ This list contains 1501 plugins. THIS PROJECT IS ABANDONED :pypi:`pytest-ipywidgets` - *last release*: Aug 02, 2024, + *last release*: Aug 21, 2024, *status*: N/A, *requires*: pytest @@ -6363,6 +6365,13 @@ This list contains 1501 plugins. Nicer list and iterable assertion messages for pytest + :pypi:`pytest-iteration` + *last release*: Aug 22, 2024, + *status*: N/A, + *requires*: pytest + + Add iteration mark for tests + :pypi:`pytest-iters` *last release*: May 24, 2022, *status*: N/A, @@ -6455,7 +6464,7 @@ This list contains 1501 plugins. Generate JSON test reports :pypi:`pytest-json-ctrf` - *last release*: Jun 15, 2024, + *last release*: Aug 17, 2024, *status*: N/A, *requires*: pytest>6.0.0 @@ -6826,7 +6835,7 @@ This list contains 1501 plugins. A PyTest plugin which provides an FTP fixture for your tests :pypi:`pytest-localserver` - *last release*: Oct 12, 2023, + *last release*: Aug 17, 2024, *status*: 4 - Beta, *requires*: N/A @@ -7036,9 +7045,9 @@ This list contains 1501 plugins. Easy way to match captured \`pytest\` output against expectations stored in files :pypi:`pytest-matchers` - *last release*: Aug 16, 2024, + *last release*: Aug 24, 2024, *status*: N/A, - *requires*: N/A + *requires*: pytest<9.0,>=7.0 Matchers for pytest @@ -7883,8 +7892,8 @@ This list contains 1501 plugins. A pytest plugin for orchestrating tests :pypi:`pytest-order` - *last release*: Apr 02, 2024, - *status*: 4 - Beta, + *last release*: Aug 22, 2024, + *status*: 5 - Production/Stable, *requires*: pytest>=5.0; python_version < "3.10" pytest plugin to run your tests in a specific order @@ -7932,9 +7941,9 @@ This list contains 1501 plugins. Pytest mark to override a value of an environment variable. :pypi:`pytest-owner` - *last release*: Apr 25, 2022, + *last release*: Aug 19, 2024, *status*: N/A, - *requires*: N/A + *requires*: pytest Add owner mark for tests @@ -8149,7 +8158,7 @@ This list contains 1501 plugins. A performance plugin for pytest :pypi:`pytest-persistence` - *last release*: May 23, 2024, + *last release*: Aug 21, 2024, *status*: N/A, *requires*: N/A @@ -8435,13 +8444,6 @@ This list contains 1501 plugins. A pytest plugin to help with testing pop projects - :pypi:`pytest-porringer` - *last release*: Jan 18, 2024, - *status*: N/A, - *requires*: pytest>=7.4.4 - - - :pypi:`pytest-portion` *last release*: Jan 28, 2021, *status*: 4 - Beta, @@ -8513,9 +8515,9 @@ This list contains 1501 plugins. pytest-print adds the printer fixture you can use to print messages to the user (directly to the pytest runner, not stdout) :pypi:`pytest-priority` - *last release*: Jul 23, 2023, + *last release*: Aug 19, 2024, *status*: N/A, - *requires*: N/A + *requires*: pytest pytest plugin for add priority for tests @@ -8751,9 +8753,9 @@ This list contains 1501 plugins. Pytest plugin for type checking code with Pyright :pypi:`pytest-pyspec` - *last release*: Jan 02, 2024, + *last release*: Aug 17, 2024, *status*: N/A, - *requires*: pytest (>=7.2.1,<8.0.0) + *requires*: pytest<9.0.0,>=8.3.2 A plugin that transforms the pytest output into a result similar to the RSpec. It enables the use of docstrings to display results and also enables the use of the prefixes "describe", "with" and "it". @@ -9003,7 +9005,7 @@ This list contains 1501 plugins. Test your README.md file :pypi:`pytest-reana` - *last release*: Mar 14, 2024, + *last release*: Aug 21, 2024, *status*: 3 - Alpha, *requires*: N/A @@ -9521,7 +9523,7 @@ This list contains 1501 plugins. pytest plugin for ROAST configuration override and fixtures :pypi:`pytest_robotframework` - *last release*: Jul 01, 2024, + *last release*: Aug 21, 2024, *status*: N/A, *requires*: pytest<9,>=7 @@ -9737,6 +9739,13 @@ This list contains 1501 plugins. Saves a screenshot when a test case from a pytest execution fails + :pypi:`pytest-scrutinize` + *last release*: Aug 19, 2024, + *status*: 4 - Beta, + *requires*: pytest>=6 + + Scrutinize your pytest test suites for slow fixtures, tests and more. + :pypi:`pytest-securestore` *last release*: Nov 08, 2021, *status*: 4 - Beta, @@ -10430,6 +10439,13 @@ This list contains 1501 plugins. pytest plugin for reporting to graphite + :pypi:`pytest-status` + *last release*: Aug 22, 2024, + *status*: N/A, + *requires*: pytest + + Add status mark for tests + :pypi:`pytest-stepfunctions` *last release*: May 08, 2021, *status*: 4 - Beta, @@ -10591,13 +10607,6 @@ This list contains 1501 plugins. pytest-symbols is a pytest plugin that adds support for passing test environment symbols into pytest tests. - :pypi:`pytest-synodic` - *last release*: Mar 09, 2024, - *status*: N/A, - *requires*: pytest>=8.0.2 - - Synodic Pytest utilities - :pypi:`pytest-system-statistics` *last release*: Feb 16, 2022, *status*: 5 - Production/Stable, @@ -10956,7 +10965,7 @@ This list contains 1501 plugins. A plugin that allows coll test data for use on Test Tracer :pypi:`pytest-test-tracer-for-pytest-bdd` - *last release*: Jul 29, 2024, + *last release*: Aug 20, 2024, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -12012,6 +12021,13 @@ This list contains 1501 plugins. Pytest fixtures for testing Camunda 8 processes using a Zeebe test engine. + :pypi:`pytest-zephyr-scale-integration` + *last release*: Aug 20, 2024, + *status*: N/A, + *requires*: pytest + + A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest + :pypi:`pytest-zest` *last release*: Nov 17, 2022, *status*: N/A, From c947145fbb4aeec810a259b19f70fcb52fd53ad4 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 29 Aug 2024 07:54:47 -0400 Subject: [PATCH 044/445] Replaced `typing.Self` with `typing_extensions.Self` (#12744) Fix incorrect Self import from typing instead of typing_extensions. --------- Co-authored-by: Bruno Oliveira --- changelog/12744.bugfix.rst | 1 + src/_pytest/doctest.py | 3 ++- src/_pytest/nodes.py | 2 +- src/_pytest/python.py | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelog/12744.bugfix.rst diff --git a/changelog/12744.bugfix.rst b/changelog/12744.bugfix.rst new file mode 100644 index 00000000000..7814b59c180 --- /dev/null +++ b/changelog/12744.bugfix.rst @@ -0,0 +1 @@ +Fixed typing compatibility with Python 3.9 or less -- replaced `typing.Self` with `typing_extensions.Self` -- by :user:`Avasam` diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index 675f4322328..384dea976ad 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -44,7 +44,8 @@ if TYPE_CHECKING: import doctest - from typing import Self + + from typing_extensions import Self DOCTEST_REPORT_CHOICE_NONE = "none" DOCTEST_REPORT_CHOICE_CDIFF = "cdiff" diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index bbde2664b90..cc678695848 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -43,7 +43,7 @@ if TYPE_CHECKING: - from typing import Self + from typing_extensions import Self # Imported here due to circular import. from _pytest.main import Session diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 3a8c77fd2f0..6507c299225 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -78,7 +78,7 @@ if TYPE_CHECKING: - from typing import Self + from typing_extensions import Self def pytest_addoption(parser: Parser) -> None: From 419bc7a7c39d21af8a2b7cf29928ee93b7e02b19 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 29 Aug 2024 17:51:54 -0300 Subject: [PATCH 045/445] Use oldest supported Python in mypy pre-commit checks (#12747) Follow up to #12744, this ensures type checking works at the oldest Python version supported by pytest. --- .pre-commit-config.yaml | 1 + src/_pytest/main.py | 2 +- src/_pytest/runner.py | 4 ++-- testing/test_runner.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 938b0bf407b..8c7fde3f2c4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,6 +26,7 @@ repos: - id: mypy files: ^(src/|testing/|scripts/) args: [] + language_version: "3.8" additional_dependencies: - iniconfig>=1.1.0 - attrs>=19.2.0 diff --git a/src/_pytest/main.py b/src/_pytest/main.py index befc7ccce6e..e5534e98d69 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -49,7 +49,7 @@ if TYPE_CHECKING: - from typing import Self + from typing_extensions import Self from _pytest.fixtures import FixtureManager diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index 716c4948f4a..d0e1cdc7faa 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -167,7 +167,7 @@ def pytest_runtest_call(item: Item) -> None: del sys.last_value del sys.last_traceback if sys.version_info >= (3, 12, 0): - del sys.last_exc + del sys.last_exc # type:ignore[attr-defined] except AttributeError: pass try: @@ -177,7 +177,7 @@ def pytest_runtest_call(item: Item) -> None: sys.last_type = type(e) sys.last_value = e if sys.version_info >= (3, 12, 0): - sys.last_exc = e + sys.last_exc = e # type:ignore[attr-defined] assert e.__traceback__ is not None # Skip *this* frame sys.last_traceback = e.__traceback__.tb_next diff --git a/testing/test_runner.py b/testing/test_runner.py index 1b59ff78633..0d9facdcd71 100644 --- a/testing/test_runner.py +++ b/testing/test_runner.py @@ -1030,7 +1030,7 @@ def runtest(self): assert sys.last_type is IndexError assert isinstance(sys.last_value, IndexError) if sys.version_info >= (3, 12, 0): - assert isinstance(sys.last_exc, IndexError) + assert isinstance(sys.last_exc, IndexError) # type:ignore[attr-defined] assert sys.last_value.args[0] == "TEST" assert sys.last_traceback From 9a444d113658be6ccb8dc9f57ed118a1ef17c94c Mon Sep 17 00:00:00 2001 From: dongfangtianyu <7629022+dongfangtianyu@users.noreply.github.com> Date: Fri, 30 Aug 2024 22:37:18 +0800 Subject: [PATCH 046/445] Fix assertion rewriting with importlib mode (#12716) Fixes #12659 --- AUTHORS | 1 + changelog/12659.bugfix.rst | 1 + src/_pytest/assertion/rewrite.py | 10 +++++++++ src/_pytest/pathlib.py | 4 +++- testing/test_pathlib.py | 36 ++++++++++++++++++++++++++++++++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 changelog/12659.bugfix.rst diff --git a/AUTHORS b/AUTHORS index 8103a1d52a5..db993353689 100644 --- a/AUTHORS +++ b/AUTHORS @@ -412,6 +412,7 @@ Ted Xiao Terje Runde Thomas Grainger Thomas Hisch +Tianyu Dongfang Tim Hoffmann Tim Strazny TJ Bruno diff --git a/changelog/12659.bugfix.rst b/changelog/12659.bugfix.rst new file mode 100644 index 00000000000..297381b9602 --- /dev/null +++ b/changelog/12659.bugfix.rst @@ -0,0 +1 @@ +Fixed the issue of not displaying assertion failure differences when using the parameter ``--import-mode=importlib`` in pytest>=8.1. diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index f7ff4f6f7a2..a7a92c0f1fe 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -101,6 +101,16 @@ def find_spec( # Type ignored because mypy is confused about the `self` binding here. spec = self._find_spec(name, path) # type: ignore + + if spec is None and path is not None: + # With --import-mode=importlib, PathFinder cannot find spec without modifying `sys.path`, + # causing inability to assert rewriting (#12659). + # At this point, try using the file path to find the module spec. + for _path_str in path: + spec = importlib.util.spec_from_file_location(name, _path_str) + if spec is not None: + break + if ( # the import machinery could not find a file to import spec is None diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index e4dc4eddc9c..81e52ea729d 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -621,7 +621,9 @@ def _import_module_using_spec( # Checking with sys.meta_path first in case one of its hooks can import this module, # such as our own assertion-rewrite hook. for meta_importer in sys.meta_path: - spec = meta_importer.find_spec(module_name, [str(module_location)]) + spec = meta_importer.find_spec( + module_name, [str(module_location), str(module_path)] + ) if spec_matches_module_path(spec, module_path): break else: diff --git a/testing/test_pathlib.py b/testing/test_pathlib.py index 377c30ca900..7c0a0e03d76 100644 --- a/testing/test_pathlib.py +++ b/testing/test_pathlib.py @@ -1372,6 +1372,42 @@ def test_resolve_pkg_root_and_module_name_ns_multiple_levels( ) assert mod is mod2 + def test_ns_multiple_levels_import_rewrite_assertions( + self, + tmp_path: Path, + monkeypatch: MonkeyPatch, + pytester: Pytester, + ) -> None: + """Check assert rewriting with `--import-mode=importlib` (#12659).""" + self.setup_directories(tmp_path, monkeypatch, pytester) + code = dedent(""" + def test(): + assert "four lights" == "five lights" + """) + + # A case is in a subdirectory with an `__init__.py` file. + test_py = tmp_path / "src/dist2/com/company/calc/algo/test_demo.py" + test_py.write_text(code, encoding="UTF-8") + + pkg_root, module_name = resolve_pkg_root_and_module_name( + test_py, consider_namespace_packages=True + ) + assert (pkg_root, module_name) == ( + tmp_path / "src/dist2", + "com.company.calc.algo.test_demo", + ) + + result = pytester.runpytest("--import-mode=importlib", test_py) + + result.stdout.fnmatch_lines( + [ + "E AssertionError: assert 'four lights' == 'five lights'", + "E *", + "E - five lights*", + "E + four lights", + ] + ) + @pytest.mark.parametrize("import_mode", ["prepend", "append", "importlib"]) def test_incorrect_namespace_package( self, From 4604387ae444a4f3478243f6d12f40b0cc48e121 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 1 Sep 2024 11:05:13 -0300 Subject: [PATCH 047/445] [automated] Update plugin list (#12759) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 172 ++++++++++++++++++++++--------- 1 file changed, 122 insertions(+), 50 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index d425454ea87..992dc3d2be7 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =6.2.0 :pypi:`pytest-bdd-html` pytest plugin to display BDD info in HTML test report Nov 22, 2022 3 - Alpha pytest (!=6.0.0,>=5.0) :pypi:`pytest-bdd-ng` BDD for pytest Dec 31, 2023 4 - Beta pytest >=5.0 - :pypi:`pytest-bdd-report` A pytest-bdd plugin for generating useful and informative BDD test reports Aug 04, 2024 N/A pytest>=7.1.3 + :pypi:`pytest-bdd-report` A pytest-bdd plugin for generating useful and informative BDD test reports Aug 26, 2024 N/A pytest>=7.1.3 :pypi:`pytest-bdd-splinter` Common steps for pytest bdd and splinter integration Aug 12, 2019 5 - Production/Stable pytest (>=4.0.0) :pypi:`pytest-bdd-web` A simple plugin to use with pytest Jan 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Aug 08, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Aug 22, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Aug 30, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -220,7 +220,7 @@ This list contains 1503 plugins. :pypi:`pytest-change-report` turn . into √,turn F into x Sep 14, 2020 N/A pytest :pypi:`pytest-change-xds` turn . into √,turn F into x Apr 16, 2022 N/A pytest :pypi:`pytest-chdir` A pytest fixture for changing current working directory Jan 28, 2020 N/A pytest (>=5.0.0,<6.0.0) - :pypi:`pytest-check` A pytest plugin that allows multiple failures per test. Jan 18, 2024 N/A pytest>=7.0.0 + :pypi:`pytest-check` A pytest plugin that allows multiple failures per test. Aug 28, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-checkdocs` check the README when running tests Apr 30, 2024 5 - Production/Stable pytest!=8.1.*,>=6; extra == "testing" :pypi:`pytest-checkipdb` plugin to check if there are ipdb debugs left Dec 04, 2023 5 - Production/Stable pytest >=2.9.2 :pypi:`pytest-check-library` check your missing library Jul 17, 2022 N/A N/A @@ -242,7 +242,7 @@ This list contains 1503 plugins. :pypi:`pytest-cldf` Easy quality control for CLDF datasets using pytest Nov 07, 2022 N/A pytest (>=3.6) :pypi:`pytest-cleanslate` Collects and executes pytest tests separately Jun 17, 2024 N/A pytest :pypi:`pytest_cleanup` Automated, comprehensive and well-organised pytest test cases. Jan 28, 2020 N/A N/A - :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Mar 19, 2024 5 - Production/Stable N/A + :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Aug 26, 2024 5 - Production/Stable N/A :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Aug 15, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-click` Pytest plugin for Click Feb 11, 2022 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-cli-fixtures` Automatically register fixtures for custom CLI arguments Jul 28, 2022 N/A pytest (~=7.0) @@ -252,6 +252,7 @@ This list contains 1503 plugins. :pypi:`pytest-cloudist` Distribute tests to cloud machines without fuss Sep 02, 2022 4 - Beta pytest (>=7.1.2,<8.0.0) :pypi:`pytest-cmake` Provide CMake module for Pytest Aug 16, 2024 N/A pytest<9,>=4 :pypi:`pytest-cmake-presets` Execute CMake Presets via pytest Dec 26, 2022 N/A pytest (>=7.2.0,<8.0.0) + :pypi:`pytest-cmdline-add-args` Pytest plugin for custom argument handling and Allure reporting. This plugin allows you to add arguments before running a test. Aug 31, 2024 N/A N/A :pypi:`pytest-cobra` PyTest plugin for testing Smart Contracts for Ethereum blockchain. Jun 29, 2019 3 - Alpha pytest (<4.0.0,>=3.7.1) :pypi:`pytest_codeblocks` Test code blocks in your READMEs Sep 17, 2023 5 - Production/Stable pytest >= 7.0.0 :pypi:`pytest-codecarbon` Pytest plugin for measuring carbon emissions Jun 15, 2022 N/A pytest @@ -429,6 +430,7 @@ This list contains 1503 plugins. :pypi:`pytest-doorstop` A pytest plugin for adding test results into doorstop items. Jun 09, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-dotenv` A py.test plugin that parses environment files before running tests Jun 16, 2020 4 - Beta pytest (>=5.0.0) :pypi:`pytest-dot-only-pkcopley` A Pytest marker for only running a single test Oct 27, 2023 N/A N/A + :pypi:`pytest-dparam` A more readable alternative to @pytest.mark.parametrize. Aug 27, 2024 6 - Mature pytest :pypi:`pytest-dpg` pytest-dpg is a pytest plugin for testing Dear PyGui (DPG) applications Aug 13, 2024 N/A N/A :pypi:`pytest-draw` Pytest plugin for randomly selecting a specific number of tests Mar 21, 2023 3 - Alpha pytest :pypi:`pytest-drf` A Django REST framework plugin for pytest. Jul 12, 2022 5 - Production/Stable pytest (>=3.7) @@ -468,7 +470,7 @@ This list contains 1503 plugins. :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) - :pypi:`pytest-enabler` Enable installed pytest plugins Mar 21, 2024 5 - Production/Stable pytest>=6; extra == "testing" + :pypi:`pytest-enabler` Enable installed pytest plugins Aug 29, 2024 5 - Production/Stable pytest!=8.1.*,>=6; extra == "test" :pypi:`pytest-encode` set your encoding and logger Nov 06, 2021 N/A N/A :pypi:`pytest-encode-kane` set your encoding and logger Nov 16, 2021 N/A pytest :pypi:`pytest-encoding` set your encoding and logger Aug 11, 2023 N/A pytest @@ -495,7 +497,7 @@ This list contains 1503 plugins. :pypi:`pytest-exasol-backend` Aug 23, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-itde` Jul 01, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-saas` Aug 06, 2024 N/A pytest<9,>=7 - :pypi:`pytest-exasol-slc` Aug 15, 2024 N/A pytest<9,>=7 + :pypi:`pytest-exasol-slc` Aug 29, 2024 N/A pytest<9,>=7 :pypi:`pytest-excel` pytest plugin for generating excel reports Jun 18, 2024 5 - Production/Stable pytest>3.6 :pypi:`pytest-exceptional` Better exceptions Mar 16, 2017 4 - Beta N/A :pypi:`pytest-exception-script` Walk your code through exception script to check it's resiliency to failures. Aug 04, 2020 3 - Alpha pytest @@ -614,6 +616,7 @@ This list contains 1503 plugins. :pypi:`pytest-github-actions-annotate-failures` pytest plugin to annotate failed tests with a workflow command for GitHub Actions May 04, 2023 5 - Production/Stable pytest (>=4.0.0) :pypi:`pytest-github-report` Generate a GitHub report using pytest in GitHub Workflows Jun 03, 2022 4 - Beta N/A :pypi:`pytest-gitignore` py.test plugin to ignore the same files as git Jul 17, 2015 4 - Beta N/A + :pypi:`pytest-gitlab` Pytest Plugin for Gitlab Aug 30, 2024 N/A N/A :pypi:`pytest-gitlabci-parallelized` Parallelize pytest across GitLab CI workers. Mar 08, 2023 N/A N/A :pypi:`pytest-gitlab-code-quality` Collects warnings while testing and generates a GitLab Code Quality Report. Apr 03, 2024 N/A pytest>=8.1.1 :pypi:`pytest-gitlab-fold` Folds output sections in GitLab CI build log Dec 31, 2023 4 - Beta pytest >=2.6.0 @@ -647,7 +650,7 @@ This list contains 1503 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Aug 17, 2024 3 - Alpha pytest==8.3.1 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Aug 31, 2024 3 - Alpha pytest==8.3.1 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Apr 18, 2024 N/A N/A @@ -718,7 +721,7 @@ This list contains 1503 plugins. :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A - :pypi:`pytest-ipywidgets` Aug 21, 2024 N/A pytest + :pypi:`pytest-ipywidgets` Aug 30, 2024 N/A pytest :pypi:`pytest-isolate` Feb 20, 2023 4 - Beta pytest :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-it` Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it. Jan 29, 2024 4 - Beta N/A @@ -802,12 +805,12 @@ This list contains 1503 plugins. :pypi:`pytest-logger` Plugin configuring handlers for loggers from Python logging module. Mar 10, 2024 5 - Production/Stable pytest (>=3.2) :pypi:`pytest-logging` Configures logging and allows tweaking the log level with a py.test flag Nov 04, 2015 4 - Beta N/A :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-logikal` Common testing environment Aug 08, 2024 5 - Production/Stable pytest==8.3.2 + :pypi:`pytest-logikal` Common testing environment Aug 30, 2024 5 - Production/Stable pytest==8.3.2 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Jul 19, 2024 4 - Beta N/A :pypi:`pytest-loguru` Pytest Loguru Mar 20, 2024 5 - Production/Stable pytest; extra == "test" :pypi:`pytest-loop` pytest plugin for looping tests Mar 30, 2024 5 - Production/Stable pytest - :pypi:`pytest-lsp` A pytest plugin for end-to-end testing of language servers May 22, 2024 3 - Alpha pytest + :pypi:`pytest-lsp` A pytest plugin for end-to-end testing of language servers Aug 28, 2024 3 - Alpha pytest :pypi:`pytest-manual-marker` pytest marker for marking manual tests Aug 04, 2022 3 - Alpha pytest>=7 :pypi:`pytest-markdoctest` A pytest plugin to doctest your markdown files Jul 22, 2022 4 - Beta pytest (>=6) :pypi:`pytest-markdown` Test your markdown docs with pytest Jan 15, 2021 4 - Beta pytest (>=6.0.1,<7.0.0) @@ -820,7 +823,7 @@ This list contains 1503 plugins. :pypi:`pytest-marks` UNKNOWN Nov 23, 2012 3 - Alpha N/A :pypi:`pytest-mask-secrets` Pytest plugin to hide sensitive data in test reports Aug 06, 2024 N/A N/A :pypi:`pytest-matcher` Easy way to match captured \`pytest\` output against expectations stored in files Aug 01, 2024 5 - Production/Stable pytest - :pypi:`pytest-matchers` Matchers for pytest Aug 24, 2024 N/A pytest<9.0,>=7.0 + :pypi:`pytest-matchers` Matchers for pytest Aug 26, 2024 N/A pytest<9.0,>=7.0 :pypi:`pytest-match-skip` Skip matching marks. Matches partial marks using wildcards. May 15, 2019 4 - Beta pytest (>=4.4.1) :pypi:`pytest-mat-report` this is report Jan 20, 2021 N/A N/A :pypi:`pytest-matrix` Provide tools for generating tests from combinations of fixtures. Jun 24, 2020 5 - Production/Stable pytest (>=5.4.3,<6.0.0) @@ -830,7 +833,7 @@ This list contains 1503 plugins. :pypi:`pytest-mccabe` pytest plugin to run the mccabe code complexity checker. Jul 22, 2020 3 - Alpha pytest (>=5.4.0) :pypi:`pytest-md` Plugin for generating Markdown reports for pytest results Jul 11, 2019 3 - Alpha pytest (>=4.2.1) :pypi:`pytest-md-report` A pytest plugin to generate test outcomes reports with markdown table format. May 18, 2024 4 - Beta pytest!=6.0.0,<9,>=3.3.2 - :pypi:`pytest-meilisearch` Pytest helpers for testing projects using Meilisearch Feb 15, 2024 N/A pytest (>=7.4.3) + :pypi:`pytest-meilisearch` Pytest helpers for testing projects using Meilisearch Aug 27, 2024 N/A pytest>=7.4.3 :pypi:`pytest-memlog` Log memory usage during tests May 03, 2023 N/A pytest (>=7.3.0,<8.0.0) :pypi:`pytest-memprof` Estimates memory consumption of test functions Mar 29, 2019 4 - Beta N/A :pypi:`pytest-memray` A simple plugin to use with pytest Jul 25, 2024 N/A pytest>=7.2 @@ -845,8 +848,9 @@ This list contains 1503 plugins. :pypi:`pytest-mimesis` Mimesis integration with the pytest test runner Mar 21, 2020 5 - Production/Stable pytest (>=4.2) :pypi:`pytest-minecraft` A pytest plugin for running tests against Minecraft releases Apr 06, 2022 N/A pytest (>=6.0.1) :pypi:`pytest-mini` A plugin to test mp Feb 06, 2023 N/A pytest (>=7.2.0,<8.0.0) - :pypi:`pytest-minio-mock` A pytest plugin for mocking Minio S3 interactions May 26, 2024 N/A pytest>=5.0.0 + :pypi:`pytest-minio-mock` A pytest plugin for mocking Minio S3 interactions Aug 27, 2024 N/A pytest>=5.0.0 :pypi:`pytest-missing-fixtures` Pytest plugin that creates missing fixtures Oct 14, 2020 4 - Beta pytest (>=3.5.0) + :pypi:`pytest-missing-modules` Pytest plugin to easily fake missing modules Aug 26, 2024 N/A pytest>=8.3.2 :pypi:`pytest-mitmproxy` pytest plugin for mitmproxy tests May 28, 2024 N/A pytest>=7.0 :pypi:`pytest-ml` Test your machine learning! May 04, 2019 4 - Beta N/A :pypi:`pytest-mocha` pytest plugin to display test execution output like a mochajs Apr 02, 2020 4 - Beta pytest (>=5.4.0) @@ -1051,6 +1055,7 @@ This list contains 1503 plugins. :pypi:`pytest-py125` Dec 03, 2022 N/A N/A :pypi:`pytest-pycharm` Plugin for py.test to enter PyCharm debugger on uncaught exceptions Aug 13, 2020 5 - Production/Stable pytest (>=2.3) :pypi:`pytest-pycodestyle` pytest plugin to run pycodestyle Oct 28, 2022 3 - Alpha N/A + :pypi:`pytest-pydantic-schema-sync` Pytest plugin to synchronise Pydantic model schemas with JSONSchema files Aug 29, 2024 N/A pytest>=6 :pypi:`pytest-pydev` py.test plugin to connect to a remote debug server with PyDev or PyCharm. Nov 15, 2017 3 - Alpha N/A :pypi:`pytest-pydocstyle` pytest plugin to run pydocstyle Jan 05, 2023 3 - Alpha N/A :pypi:`pytest-pylint` pytest plugin to check source code with pylint Oct 06, 2023 5 - Production/Stable pytest >=7.0 @@ -1073,7 +1078,7 @@ This list contains 1503 plugins. :pypi:`pytest-pytorch` pytest plugin for a better developer experience when working with the PyTorch test suite May 25, 2021 4 - Beta pytest :pypi:`pytest-pyvenv` A package for create venv in tests Feb 27, 2024 N/A pytest ; extra == 'test' :pypi:`pytest-pyvista` Pytest-pyvista package Sep 29, 2023 4 - Beta pytest>=3.5.0 - :pypi:`pytest-qanova` A pytest plugin to collect test information May 26, 2024 3 - Alpha pytest + :pypi:`pytest-qanova` A pytest plugin to collect test information Aug 26, 2024 3 - Alpha pytest :pypi:`pytest-qaseio` Pytest plugin for Qase.io integration May 30, 2024 4 - Beta pytest<9.0.0,>=7.2.2 :pypi:`pytest-qasync` Pytest support for qasync. Jul 12, 2021 4 - Beta pytest (>=5.4.0) :pypi:`pytest-qatouch` Pytest plugin for uploading test results to your QA Touch Testrun. Feb 14, 2023 4 - Beta pytest (>=6.2.0) @@ -1115,6 +1120,7 @@ This list contains 1503 plugins. :pypi:`pytest-regressions` Easy to use fixtures to write regression tests. Aug 31, 2023 5 - Production/Stable pytest >=6.2.0 :pypi:`pytest-regtest` pytest plugin for snapshot regression testing Feb 26, 2024 N/A pytest>7.2 :pypi:`pytest-relative-order` a pytest plugin that sorts tests using "before" and "after" markers May 17, 2021 4 - Beta N/A + :pypi:`pytest-relative-path` Handle relative path in pytest options or ini configs Aug 30, 2024 N/A pytest :pypi:`pytest-relaxed` Relaxed test discovery/organization for pytest Mar 29, 2024 5 - Production/Stable pytest>=7 :pypi:`pytest-remfiles` Pytest plugin to create a temporary directory with remote files Jul 01, 2019 5 - Production/Stable N/A :pypi:`pytest-remotedata` Pytest plugin for controlling remote data access. Sep 26, 2023 5 - Production/Stable pytest >=4.6 @@ -1199,7 +1205,7 @@ This list contains 1503 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Aug 13, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Aug 30, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 :pypi:`pytest-schedule` The job of test scheduling for humans. Jan 07, 2023 5 - Production/Stable N/A @@ -1210,7 +1216,7 @@ This list contains 1503 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Aug 13, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Aug 30, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1229,10 +1235,11 @@ This list contains 1503 plugins. :pypi:`pytest-setupinfo` Displaying setup info during pytest command run Jan 23, 2023 N/A N/A :pypi:`pytest-sftpserver` py.test plugin to locally test sftp server connections. Sep 16, 2019 4 - Beta N/A :pypi:`pytest-shard` Dec 11, 2020 4 - Beta pytest + :pypi:`pytest-shared-session-scope` Aug 28, 2024 N/A pytest>=7 :pypi:`pytest-share-hdf` Plugin to save test data in HDF files and retrieve them for comparison Sep 21, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-sharkreport` this is pytest report plugin. Jul 11, 2022 N/A pytest (>=3.5) :pypi:`pytest-shell` A pytest plugin to help with testing shell scripts / black box commands Mar 27, 2022 N/A N/A - :pypi:`pytest-shell-utilities` Pytest plugin to simplify running shell commands against the system Feb 23, 2024 5 - Production/Stable pytest >=7.4.0 + :pypi:`pytest-shell-utilities` Pytest plugin to simplify running shell commands against the system Aug 26, 2024 5 - Production/Stable pytest>=7.4.0 :pypi:`pytest-sheraf` Versatile ZODB abstraction layer - pytest fixtures Feb 11, 2020 N/A pytest :pypi:`pytest-sherlock` pytest plugin help to find coupled tests Aug 14, 2023 5 - Production/Stable pytest >=3.5.1 :pypi:`pytest-shortcuts` Expand command-line shortcuts listed in pytest configuration Oct 29, 2020 4 - Beta pytest (>=3.5.0) @@ -1288,7 +1295,7 @@ This list contains 1503 plugins. :pypi:`pytest-splitio` Split.io SDK integration for e2e tests Sep 22, 2020 N/A pytest (<7,>=5.0) :pypi:`pytest-split-tests` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Forked from Mark Adams' original project pytest-test-groups. Jul 30, 2021 5 - Production/Stable pytest (>=2.5) :pypi:`pytest-split-tests-tresorit` Feb 22, 2021 1 - Planning N/A - :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Aug 14, 2024 N/A pytest<8,>5.4.0 + :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Aug 28, 2024 N/A pytest<8,>5.4.0 :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Jul 10, 2024 N/A N/A :pypi:`pytest-splunk-env` pytest fixtures for interaction with Splunk Enterprise and Splunk Cloud Oct 22, 2020 N/A pytest (>=6.1.1,<7.0.0) :pypi:`pytest-sqitch` sqitch for pytest Apr 06, 2020 4 - Beta N/A @@ -1331,7 +1338,7 @@ This list contains 1503 plugins. :pypi:`pytest-symbols` pytest-symbols is a pytest plugin that adds support for passing test environment symbols into pytest tests. Nov 20, 2017 3 - Alpha N/A :pypi:`pytest-system-statistics` Pytest plugin to track and report system usage statistics Feb 16, 2022 5 - Production/Stable pytest (>=6.0.0) :pypi:`pytest-system-test-plugin` Pyst - Pytest System-Test Plugin Feb 03, 2022 N/A N/A - :pypi:`pytest_tagging` a pytest plugin to tag tests Apr 08, 2024 N/A pytest<8.0.0,>=7.1.3 + :pypi:`pytest_tagging` a pytest plugin to tag tests Aug 31, 2024 N/A pytest<8.0.0,>=7.1.3 :pypi:`pytest-takeltest` Fixtures for ansible, testinfra and molecule Feb 15, 2023 N/A N/A :pypi:`pytest-talisker` Nov 28, 2021 N/A N/A :pypi:`pytest-tally` A Pytest plugin to generate realtime summary stats, and display them in-console using a text-based dashboard. May 22, 2023 4 - Beta pytest (>=6.2.5) @@ -1350,6 +1357,7 @@ This list contains 1503 plugins. :pypi:`pytest-terraform-fixture` generate terraform resources to use with pytest Nov 14, 2018 4 - Beta N/A :pypi:`pytest-testbook` A plugin to run tests written in Jupyter notebook Dec 11, 2016 3 - Alpha N/A :pypi:`pytest-testconfig` Test configuration plugin for pytest. Jan 11, 2020 4 - Beta pytest (>=3.5.0) + :pypi:`pytest-testdata` Get and load testdata in pytest projects Aug 30, 2024 N/A pytest :pypi:`pytest-testdirectory` A py.test plugin providing temporary directories in unit tests. May 02, 2023 5 - Production/Stable pytest :pypi:`pytest-testdox` A testdox format reporter for pytest Jul 22, 2023 5 - Production/Stable pytest (>=4.6.0) :pypi:`pytest-test-grouping` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Feb 01, 2023 5 - Production/Stable pytest (>=2.5) @@ -1391,7 +1399,7 @@ This list contains 1503 plugins. :pypi:`pytest-thread` Jul 07, 2023 N/A N/A :pypi:`pytest-threadleak` Detects thread leaks Jul 03, 2022 4 - Beta pytest (>=3.1.1) :pypi:`pytest-tick` Ticking on tests Aug 31, 2021 5 - Production/Stable pytest (>=6.2.5,<7.0.0) - :pypi:`pytest-time` Jun 24, 2023 3 - Alpha pytest + :pypi:`pytest-time` Aug 28, 2024 3 - Alpha pytest :pypi:`pytest-timeassert-ethan` execution duration Dec 25, 2023 N/A pytest :pypi:`pytest-timeit` A pytest plugin to time test function runs Oct 13, 2016 4 - Beta N/A :pypi:`pytest-timeout` pytest plugin to abort hanging tests Mar 07, 2024 5 - Production/Stable pytest >=7.0.0 @@ -1400,7 +1408,7 @@ This list contains 1503 plugins. :pypi:`pytest-timestamper` Pytest plugin to add a timestamp prefix to the pytest output Mar 27, 2024 N/A N/A :pypi:`pytest-timestamps` A simple plugin to view timestamps for each test Sep 11, 2023 N/A pytest (>=7.3,<8.0) :pypi:`pytest-tiny-api-client` The companion pytest plugin for tiny-api-client Jan 04, 2024 5 - Production/Stable pytest - :pypi:`pytest-tinybird` A pytest plugin to report test results to tinybird Jun 26, 2023 4 - Beta pytest (>=3.8.0) + :pypi:`pytest-tinybird` A pytest plugin to report test results to tinybird Aug 29, 2024 4 - Beta pytest>=3.8.0 :pypi:`pytest-tipsi-django` Better fixtures for django Feb 05, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-tipsi-testing` Better fixtures management. Various helpers Feb 04, 2024 5 - Production/Stable pytest>=3.3.0 :pypi:`pytest-tldr` A pytest plugin that limits the output to just the things you need. Oct 26, 2022 4 - Beta pytest (>=3.5.0) @@ -1441,6 +1449,7 @@ This list contains 1503 plugins. :pypi:`pytest-typhoon-config` A Typhoon HIL plugin that facilitates test parameter configuration at runtime Apr 07, 2022 5 - Production/Stable N/A :pypi:`pytest-typhoon-polarion` Typhoontest plugin for Siemens Polarion Feb 01, 2024 4 - Beta N/A :pypi:`pytest-typhoon-xray` Typhoon HIL plugin for pytest Aug 15, 2023 4 - Beta N/A + :pypi:`pytest-typing-runner` Pytest plugin to make it easier to run and check python code against static type checkers Aug 29, 2024 N/A pytest==8.2.2; extra == "tests" :pypi:`pytest-tytest` Typhoon HIL plugin for pytest May 25, 2020 4 - Beta pytest (>=5.4.2) :pypi:`pytest-ubersmith` Easily mock calls to ubersmith at the \`requests\` level. Apr 13, 2015 N/A N/A :pypi:`pytest-ui` Text User Interface for running python tests Jul 05, 2021 4 - Beta pytest @@ -1481,7 +1490,7 @@ This list contains 1503 plugins. :pypi:`pytest-wa-e2e-plugin` Pytest plugin for testing whatsapp bots with end to end tests Feb 18, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-wake` Mar 20, 2024 N/A pytest :pypi:`pytest-watch` Local continuous test runner with pytest and watchdog. May 20, 2018 N/A N/A - :pypi:`pytest-watcher` Automatically rerun your tests on file modifications Apr 01, 2024 4 - Beta N/A + :pypi:`pytest-watcher` Automatically rerun your tests on file modifications Aug 28, 2024 4 - Beta N/A :pypi:`pytest_wdb` Trace pytest tests with wdb to halt on error with --wdb. Jul 04, 2016 N/A N/A :pypi:`pytest-wdl` Pytest plugin for testing WDL workflows. Nov 17, 2020 5 - Production/Stable N/A :pypi:`pytest-web3-data` A pytest plugin to fetch test data from IPFS HTTP gateways during pytest execution. Oct 04, 2023 4 - Beta pytest @@ -2341,7 +2350,7 @@ This list contains 1503 plugins. BDD for pytest :pypi:`pytest-bdd-report` - *last release*: Aug 04, 2024, + *last release*: Aug 26, 2024, *status*: N/A, *requires*: pytest>=7.1.3 @@ -2383,7 +2392,7 @@ This list contains 1503 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Aug 22, 2024, + *last release*: Aug 30, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -2845,8 +2854,8 @@ This list contains 1503 plugins. A pytest fixture for changing current working directory :pypi:`pytest-check` - *last release*: Jan 18, 2024, - *status*: N/A, + *last release*: Aug 28, 2024, + *status*: 5 - Production/Stable, *requires*: pytest>=7.0.0 A pytest plugin that allows multiple failures per test. @@ -2999,7 +3008,7 @@ This list contains 1503 plugins. Automated, comprehensive and well-organised pytest test cases. :pypi:`pytest-cleanuptotal` - *last release*: Mar 19, 2024, + *last release*: Aug 26, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -3068,6 +3077,13 @@ This list contains 1503 plugins. Execute CMake Presets via pytest + :pypi:`pytest-cmdline-add-args` + *last release*: Aug 31, 2024, + *status*: N/A, + *requires*: N/A + + Pytest plugin for custom argument handling and Allure reporting. This plugin allows you to add arguments before running a test. + :pypi:`pytest-cobra` *last release*: Jun 29, 2019, *status*: 3 - Alpha, @@ -4307,6 +4323,13 @@ This list contains 1503 plugins. A Pytest marker for only running a single test + :pypi:`pytest-dparam` + *last release*: Aug 27, 2024, + *status*: 6 - Mature, + *requires*: pytest + + A more readable alternative to @pytest.mark.parametrize. + :pypi:`pytest-dpg` *last release*: Aug 13, 2024, *status*: N/A, @@ -4581,9 +4604,9 @@ This list contains 1503 plugins. Pytest plugin to represent test output with emoji support :pypi:`pytest-enabler` - *last release*: Mar 21, 2024, + *last release*: Aug 29, 2024, *status*: 5 - Production/Stable, - *requires*: pytest>=6; extra == "testing" + *requires*: pytest!=8.1.*,>=6; extra == "test" Enable installed pytest plugins @@ -4770,7 +4793,7 @@ This list contains 1503 plugins. :pypi:`pytest-exasol-slc` - *last release*: Aug 15, 2024, + *last release*: Aug 29, 2024, *status*: N/A, *requires*: pytest<9,>=7 @@ -5602,6 +5625,13 @@ This list contains 1503 plugins. py.test plugin to ignore the same files as git + :pypi:`pytest-gitlab` + *last release*: Aug 30, 2024, + *status*: N/A, + *requires*: N/A + + Pytest Plugin for Gitlab + :pypi:`pytest-gitlabci-parallelized` *last release*: Mar 08, 2023, *status*: N/A, @@ -5834,7 +5864,7 @@ This list contains 1503 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Aug 17, 2024, + *last release*: Aug 31, 2024, *status*: 3 - Alpha, *requires*: pytest==8.3.1 @@ -6331,7 +6361,7 @@ This list contains 1503 plugins. THIS PROJECT IS ABANDONED :pypi:`pytest-ipywidgets` - *last release*: Aug 21, 2024, + *last release*: Aug 30, 2024, *status*: N/A, *requires*: pytest @@ -6919,7 +6949,7 @@ This list contains 1503 plugins. :pypi:`pytest-logikal` - *last release*: Aug 08, 2024, + *last release*: Aug 30, 2024, *status*: 5 - Production/Stable, *requires*: pytest==8.3.2 @@ -6954,7 +6984,7 @@ This list contains 1503 plugins. pytest plugin for looping tests :pypi:`pytest-lsp` - *last release*: May 22, 2024, + *last release*: Aug 28, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -7045,7 +7075,7 @@ This list contains 1503 plugins. Easy way to match captured \`pytest\` output against expectations stored in files :pypi:`pytest-matchers` - *last release*: Aug 24, 2024, + *last release*: Aug 26, 2024, *status*: N/A, *requires*: pytest<9.0,>=7.0 @@ -7115,9 +7145,9 @@ This list contains 1503 plugins. A pytest plugin to generate test outcomes reports with markdown table format. :pypi:`pytest-meilisearch` - *last release*: Feb 15, 2024, + *last release*: Aug 27, 2024, *status*: N/A, - *requires*: pytest (>=7.4.3) + *requires*: pytest>=7.4.3 Pytest helpers for testing projects using Meilisearch @@ -7220,7 +7250,7 @@ This list contains 1503 plugins. A plugin to test mp :pypi:`pytest-minio-mock` - *last release*: May 26, 2024, + *last release*: Aug 27, 2024, *status*: N/A, *requires*: pytest>=5.0.0 @@ -7233,6 +7263,13 @@ This list contains 1503 plugins. Pytest plugin that creates missing fixtures + :pypi:`pytest-missing-modules` + *last release*: Aug 26, 2024, + *status*: N/A, + *requires*: pytest>=8.3.2 + + Pytest plugin to easily fake missing modules + :pypi:`pytest-mitmproxy` *last release*: May 28, 2024, *status*: N/A, @@ -8661,6 +8698,13 @@ This list contains 1503 plugins. pytest plugin to run pycodestyle + :pypi:`pytest-pydantic-schema-sync` + *last release*: Aug 29, 2024, + *status*: N/A, + *requires*: pytest>=6 + + Pytest plugin to synchronise Pydantic model schemas with JSONSchema files + :pypi:`pytest-pydev` *last release*: Nov 15, 2017, *status*: 3 - Alpha, @@ -8816,7 +8860,7 @@ This list contains 1503 plugins. Pytest-pyvista package :pypi:`pytest-qanova` - *last release*: May 26, 2024, + *last release*: Aug 26, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -9109,6 +9153,13 @@ This list contains 1503 plugins. a pytest plugin that sorts tests using "before" and "after" markers + :pypi:`pytest-relative-path` + *last release*: Aug 30, 2024, + *status*: N/A, + *requires*: pytest + + Handle relative path in pytest options or ini configs + :pypi:`pytest-relaxed` *last release*: Mar 29, 2024, *status*: 5 - Production/Stable, @@ -9698,7 +9749,7 @@ This list contains 1503 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Aug 13, 2024, + *last release*: Aug 30, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9775,7 +9826,7 @@ This list contains 1503 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Aug 13, 2024, + *last release*: Aug 30, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9907,6 +9958,13 @@ This list contains 1503 plugins. + :pypi:`pytest-shared-session-scope` + *last release*: Aug 28, 2024, + *status*: N/A, + *requires*: pytest>=7 + + + :pypi:`pytest-share-hdf` *last release*: Sep 21, 2022, *status*: 4 - Beta, @@ -9929,9 +9987,9 @@ This list contains 1503 plugins. A pytest plugin to help with testing shell scripts / black box commands :pypi:`pytest-shell-utilities` - *last release*: Feb 23, 2024, + *last release*: Aug 26, 2024, *status*: 5 - Production/Stable, - *requires*: pytest >=7.4.0 + *requires*: pytest>=7.4.0 Pytest plugin to simplify running shell commands against the system @@ -10321,7 +10379,7 @@ This list contains 1503 plugins. :pypi:`pytest-splunk-addon` - *last release*: Aug 14, 2024, + *last release*: Aug 28, 2024, *status*: N/A, *requires*: pytest<8,>5.4.0 @@ -10622,7 +10680,7 @@ This list contains 1503 plugins. Pyst - Pytest System-Test Plugin :pypi:`pytest_tagging` - *last release*: Apr 08, 2024, + *last release*: Aug 31, 2024, *status*: N/A, *requires*: pytest<8.0.0,>=7.1.3 @@ -10754,6 +10812,13 @@ This list contains 1503 plugins. Test configuration plugin for pytest. + :pypi:`pytest-testdata` + *last release*: Aug 30, 2024, + *status*: N/A, + *requires*: pytest + + Get and load testdata in pytest projects + :pypi:`pytest-testdirectory` *last release*: May 02, 2023, *status*: 5 - Production/Stable, @@ -11042,7 +11107,7 @@ This list contains 1503 plugins. Ticking on tests :pypi:`pytest-time` - *last release*: Jun 24, 2023, + *last release*: Aug 28, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -11105,9 +11170,9 @@ This list contains 1503 plugins. The companion pytest plugin for tiny-api-client :pypi:`pytest-tinybird` - *last release*: Jun 26, 2023, + *last release*: Aug 29, 2024, *status*: 4 - Beta, - *requires*: pytest (>=3.8.0) + *requires*: pytest>=3.8.0 A pytest plugin to report test results to tinybird @@ -11391,6 +11456,13 @@ This list contains 1503 plugins. Typhoon HIL plugin for pytest + :pypi:`pytest-typing-runner` + *last release*: Aug 29, 2024, + *status*: N/A, + *requires*: pytest==8.2.2; extra == "tests" + + Pytest plugin to make it easier to run and check python code against static type checkers + :pypi:`pytest-tytest` *last release*: May 25, 2020, *status*: 4 - Beta, @@ -11672,7 +11744,7 @@ This list contains 1503 plugins. Local continuous test runner with pytest and watchdog. :pypi:`pytest-watcher` - *last release*: Apr 01, 2024, + *last release*: Aug 28, 2024, *status*: 4 - Beta, *requires*: N/A From 4f60c781be6351ec4e0015c1f1a547ba650b3726 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 03:53:52 +0000 Subject: [PATCH 048/445] build(deps): Bump pypa/gh-action-pypi-publish from 1.9.0 to 1.10.0 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.9.0 to 1.10.0. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.9.0...v1.10.0) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 34a0b25c63c..02e7c6c0217 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -54,7 +54,7 @@ jobs: path: dist - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@v1.9.0 + uses: pypa/gh-action-pypi-publish@v1.10.0 - name: Push tag run: | From f8d3e4102fe72fba1bb4ef922121d3856bd80473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sviatoslav=20Sydorenko=20=28=D0=A1=D0=B2=D1=8F=D1=82=D0=BE?= =?UTF-8?q?=D1=81=D0=BB=D0=B0=D0=B2=20=D0=A1=D0=B8=D0=B4=D0=BE=D1=80=D0=B5?= =?UTF-8?q?=D0=BD=D0=BA=D0=BE=29?= Date: Tue, 3 Sep 2024 00:13:38 +0200 Subject: [PATCH 049/445] Opt into uploading PEP 740 digital publish attestations to PyPI --- .github/workflows/deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 02e7c6c0217..abbdead2ca9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -55,6 +55,8 @@ jobs: - name: Publish package to PyPI uses: pypa/gh-action-pypi-publish@v1.10.0 + with: + attestations: true - name: Push tag run: | From 7928dade67fdd6851efade25f3462ff6f0ad2d49 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 21:26:21 -0300 Subject: [PATCH 050/445] [pre-commit.ci] pre-commit autoupdate (#12767) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.2 → v0.6.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.2...v0.6.3) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8c7fde3f2c4..612188c4ff5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.2" + rev: "v0.6.3" hooks: - id: ruff args: ["--fix"] From c6a0ef175a802efd01115454e8d18d0711ca350d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 3 Sep 2024 22:03:46 +0200 Subject: [PATCH 051/445] doc: Remove past training (#12772) --- doc/en/index.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/en/index.rst b/doc/en/index.rst index 95044e8a544..8b34d589643 100644 --- a/doc/en/index.rst +++ b/doc/en/index.rst @@ -2,7 +2,6 @@ .. sidebar:: **Next Open Trainings and Events** - - `pytest: Professionelles Testen (nicht nur) für Python `_, at `CH Open Workshoptage `_, **September 2nd 2024**, HSLU Rotkreuz (CH) - `Professional Testing with Python `_, via `Python Academy `_ (3 day in-depth training), **March 4th -- 6th 2025**, Leipzig (DE) / Remote Also see :doc:`previous talks and blogposts ` From 09e386e3e0df5a58ef9ab4f8e43f55c650633be7 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 3 Sep 2024 22:26:49 +0200 Subject: [PATCH 052/445] Fix typos and introduce codespell pre-commit hook (#12769) --- .pre-commit-config.yaml | 7 +++++++ AUTHORS | 1 + CONTRIBUTING.rst | 2 +- changelog/12769.misc.rst | 1 + doc/en/announce/release-2.3.0.rst | 4 ++-- doc/en/changelog.rst | 8 ++++---- doc/en/deprecations.rst | 2 +- doc/en/explanation/fixtures.rst | 2 +- doc/en/funcarg_compare.rst | 6 +++--- doc/en/how-to/fixtures.rst | 2 +- doc/en/how-to/unittest.rst | 2 +- pyproject.toml | 5 +++++ src/_pytest/config/__init__.py | 2 +- src/_pytest/debugging.py | 2 +- testing/python/fixtures.py | 2 +- testing/test_config.py | 2 +- 16 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 changelog/12769.misc.rst diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 612188c4ff5..dfeca73648b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,6 +16,13 @@ repos: hooks: - id: blacken-docs additional_dependencies: [black==24.1.1] +- repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + args: ["--toml=pyproject.toml"] + additional_dependencies: + - tomli - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.10.0 hooks: diff --git a/AUTHORS b/AUTHORS index db993353689..8bc8ad5cbde 100644 --- a/AUTHORS +++ b/AUTHORS @@ -85,6 +85,7 @@ Chris NeJame Chris Rose Chris Wheeler Christian Boelsen +Christian Clauss Christian Fetzer Christian Neumüller Christian Theunert diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 6e96fd24c40..d615e5fb113 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -543,4 +543,4 @@ Closing issues When a pull request is submitted to fix an issue, add text like ``closes #XYZW`` to the PR description and/or commits (where ``XYZW`` is the issue number). See the `GitHub docs `_ for more information. -When an issue is due to user error (e.g. misunderstanding of a functionality), please politely explain to the user why the issue raised is really a non-issue and ask them to close the issue if they have no further questions. If the original requestor is unresponsive, the issue will be handled as described in the section `Handling stale issues/PRs`_ above. +When an issue is due to user error (e.g. misunderstanding of a functionality), please politely explain to the user why the issue raised is really a non-issue and ask them to close the issue if they have no further questions. If the original requester is unresponsive, the issue will be handled as described in the section `Handling stale issues/PRs`_ above. diff --git a/changelog/12769.misc.rst b/changelog/12769.misc.rst new file mode 100644 index 00000000000..aae4d137a0d --- /dev/null +++ b/changelog/12769.misc.rst @@ -0,0 +1 @@ +Fix typos discovered by codespell and add codespell to pre-commit hooks. diff --git a/doc/en/announce/release-2.3.0.rst b/doc/en/announce/release-2.3.0.rst index 6905b77b923..c405073ef40 100644 --- a/doc/en/announce/release-2.3.0.rst +++ b/doc/en/announce/release-2.3.0.rst @@ -6,10 +6,10 @@ and parametrized testing in Python. It is now easier, more efficient and more predictable to re-run the same tests with different fixture instances. Also, you can directly declare the caching "scope" of fixtures so that dependent tests throughout your whole test suite can -re-use database or other expensive fixture objects with ease. Lastly, +reuse database or other expensive fixture objects with ease. Lastly, it's possible for fixture functions (formerly known as funcarg factories) to use other fixtures, allowing for a completely modular and -re-usable fixture design. +reusable fixture design. For detailed info and tutorial-style examples, see: diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index 3178f82044d..9da6f487f8d 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -215,7 +215,7 @@ Improved documentation -- by :user:`webknjaz` -- `#12577 `_: `CI` and `BUILD_NUMBER` environment variables role is discribed in +- `#12577 `_: `CI` and `BUILD_NUMBER` environment variables role is described in the reference doc. They now also appear when doing `pytest -h` -- by :user:`MarcBresson`. @@ -319,7 +319,7 @@ Bug Fixes - `#12367 `_: Fix a regression in pytest 8.2.0 where unittest class instances (a fresh one is created for each test) were not released promptly on test teardown but only on session teardown. -- `#12381 `_: Fix possible "Directory not empty" crashes arising from concurent cache dir (``.pytest_cache``) creation. Regressed in pytest 8.2.0. +- `#12381 `_: Fix possible "Directory not empty" crashes arising from concurrent cache dir (``.pytest_cache``) creation. Regressed in pytest 8.2.0. @@ -330,7 +330,7 @@ Improved Documentation - `#12356 `_: Added a subsection to the documentation for debugging flaky tests to mention - lack of thread safety in pytest as a possible source of flakyness. + lack of thread safety in pytest as a possible source of flakiness. - `#12363 `_: The documentation webpages now links to a canonical version to reduce outdated documentation in search engine results. @@ -676,7 +676,7 @@ Bug Fixes This bug was introduced in pytest 8.0.0rc1. -- `#9765 `_, `#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. +- `#9765 `_, `#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 interchangeably 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*. diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index bf6268a4980..153d5195476 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -43,7 +43,7 @@ If the import attempt raises :class:`ModuleNotFoundError` (the usual case), then warning is emitted. This way, the usual cases will keep working the same way, while unexpected errors will now issue a warning, with -users being able to supress the warning by passing ``exc_type=ImportError`` explicitly. +users being able to suppress the warning by passing ``exc_type=ImportError`` explicitly. In ``9.0``, the warning will turn into an error, and in ``9.1`` :func:`pytest.importorskip` will only capture :class:`ModuleNotFoundError` by default and no warnings will be issued anymore -- but users can still capture diff --git a/doc/en/explanation/fixtures.rst b/doc/en/explanation/fixtures.rst index 0bb3bf49fb0..53d4796c825 100644 --- a/doc/en/explanation/fixtures.rst +++ b/doc/en/explanation/fixtures.rst @@ -75,7 +75,7 @@ style of setup/teardown functions: * fixture management scales from simple unit to complex functional testing, allowing to parametrize fixtures and tests according - to configuration and component options, or to re-use fixtures + to configuration and component options, or to reuse fixtures across function, class, module or whole test session scopes. * teardown logic can be easily, and safely managed, no matter how many fixtures diff --git a/doc/en/funcarg_compare.rst b/doc/en/funcarg_compare.rst index 8b900d30f20..bc5e7d3c515 100644 --- a/doc/en/funcarg_compare.rst +++ b/doc/en/funcarg_compare.rst @@ -16,7 +16,7 @@ Shortcomings of the previous ``pytest_funcarg__`` mechanism The pre pytest-2.3 funcarg mechanism calls a factory each time a funcarg for a test function is required. If a factory wants to -re-use a resource across different scopes, it often used +reuse a resource across different scopes, it often used the ``request.cached_setup()`` helper to manage caching of resources. Here is a basic example how we could implement a per-session Database object: @@ -107,7 +107,7 @@ the tests requiring "db" will run twice as well. The "mysql" and "pg" values will also be used for reporting the test-invocation variants. This new way of parametrizing funcarg factories should in many cases -allow to re-use already written factories because effectively +allow to reuse already written factories because effectively ``request.param`` was already used when test functions/classes were parametrized via :py:func:`metafunc.parametrize(indirect=True) ` calls. @@ -164,7 +164,7 @@ hook which are often used to setup global resources. This suffers from several problems: 1. in distributed testing the managing process would setup test resources - that are never needed because it only co-ordinates the test run + that are never needed because it only coordinates the test run activities of the worker processes. 2. if you only perform a collection (with "--collect-only") diff --git a/doc/en/how-to/fixtures.rst b/doc/en/how-to/fixtures.rst index f4d59ff93c0..d60635c4fea 100644 --- a/doc/en/how-to/fixtures.rst +++ b/doc/en/how-to/fixtures.rst @@ -1487,7 +1487,7 @@ Modularity: using fixtures from a fixture function In addition to using fixtures in test functions, fixture functions can use other fixtures themselves. This contributes to a modular design -of your fixtures and allows re-use of framework-specific fixtures across +of your fixtures and allows reuse of framework-specific fixtures across many projects. As a simple example, we can extend the previous example and instantiate an object ``app`` where we stick the already defined ``smtp_connection`` resource into it: diff --git a/doc/en/how-to/unittest.rst b/doc/en/how-to/unittest.rst index 508aebde016..62e32b6d28f 100644 --- a/doc/en/how-to/unittest.rst +++ b/doc/en/how-to/unittest.rst @@ -109,7 +109,7 @@ achieves this by receiving a special ``request`` object which gives access to :ref:`the requesting test context ` such as the ``cls`` attribute, denoting the class from which the fixture is used. This architecture de-couples fixture writing from actual test -code and allows re-use of the fixture by a minimal reference, the fixture +code and allows reuse of the fixture by a minimal reference, the fixture name. So let's write an actual ``unittest.TestCase`` class using our fixture definition: diff --git a/pyproject.toml b/pyproject.toml index ccd349fcdc7..2fd11df1bf4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -307,6 +307,11 @@ disable = [ "wrong-import-position", # handled by isort / ruff ] +[tool.codespell] +ignore-words-list = "afile,asser,assertio,feld,hove,ned,noes,notin,paramete,parth,socio-economic,tesults,varius,wil" +skip = "*/plugin_list.rst" +write-changes = true + [tool.check-wheel-contents] # check-wheel-contents is executed by the build-and-inspect-python-package action. # W009: Wheel contains multiple toplevel library entries diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index fbb5fb6fdea..2299e90fdc4 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -360,7 +360,7 @@ def _get_legacy_hook_marks( opt_names: tuple[str, ...], ) -> dict[str, bool]: if TYPE_CHECKING: - # abuse typeguard from importlib to avoid massive method type union thats lacking a alias + # abuse typeguard from importlib to avoid massive method type union that's lacking an alias assert inspect.isroutine(method) known_marks: set[str] = {m.name for m in getattr(method, "pytestmark", [])} must_warn: list[str] = [] diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py index 3e1463fff26..2dfe321e968 100644 --- a/src/_pytest/debugging.py +++ b/src/_pytest/debugging.py @@ -332,7 +332,7 @@ def maybe_wrap_pytest_function_for_tracing(pyfuncitem) -> None: def _enter_pdb( node: Node, excinfo: ExceptionInfo[BaseException], rep: BaseReport ) -> BaseReport: - # XXX we re-use the TerminalReporter's terminalwriter + # XXX we reuse the TerminalReporter's terminalwriter # because this seems to avoid some encoding related troubles # for not completely clear reasons. tw = node.config.pluginmanager.getplugin("terminalreporter")._tw diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index 8d2646309a8..46f0a762cbb 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -4338,7 +4338,7 @@ def test_func(self, f2, f1, m2): assert request.fixturenames == "s1 p1 m1 m2 c1 f2 f1".split() def test_parametrized_package_scope_reordering(self, pytester: Pytester) -> None: - """A paramaterized package-scoped fixture correctly reorders items to + """A parameterized package-scoped fixture correctly reorders items to minimize setups & teardowns. Regression test for #12328. diff --git a/testing/test_config.py b/testing/test_config.py index aa3e4147927..3f5f884ef7a 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -917,7 +917,7 @@ def pytest_addoption(parser): # default for string is "" value = config.getini("string1") assert value == "" - # should return None if None is explicity set as default value + # should return None if None is explicitly set as default value # irrespective of the type argument value = config.getini("none_1") assert value is None From 72c682ff9773ad2690711105a100423ebf7c7c15 Mon Sep 17 00:00:00 2001 From: GTowers1 <130098608+GTowers1@users.noreply.github.com> Date: Thu, 5 Sep 2024 04:04:12 -0700 Subject: [PATCH 053/445] Streamline checks for verbose option (#12706) Instead of calling `Config.option.verbose`, call the new `Config.get_verbosity` function to determine the verbosity level. This enables pytest to run correctly with the terminal plugin disabled. Fix #9422 --- changelog/9422.bugfix.rst | 3 +++ doc/en/example/simple.rst | 2 +- src/_pytest/cacheprovider.py | 2 +- src/_pytest/config/__init__.py | 2 +- src/_pytest/fixtures.py | 6 +++--- src/_pytest/logging.py | 2 +- src/_pytest/nodes.py | 4 ++-- src/_pytest/python.py | 2 +- src/_pytest/runner.py | 2 +- src/_pytest/stepwise.py | 2 +- testing/acceptance_test.py | 7 +++++++ 11 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 changelog/9422.bugfix.rst diff --git a/changelog/9422.bugfix.rst b/changelog/9422.bugfix.rst new file mode 100644 index 00000000000..38196340fd5 --- /dev/null +++ b/changelog/9422.bugfix.rst @@ -0,0 +1,3 @@ +Fix bug where disabling the terminal plugin via ``-p no:terminal`` would cause crashes related to missing the ``verbose`` option. + +-- by :user:`GTowers1` diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index a5e2e78c397..a14c34c19c3 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -460,7 +460,7 @@ display more information if applicable: def pytest_report_header(config): - if config.getoption("verbose") > 0: + if config.get_verbosity() > 0: return ["info1: did you know that ...", "did you?"] which will add info only when run with "--v": diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index 7190810570e..1b236efdc9b 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -347,7 +347,7 @@ def get_last_failed_paths(self) -> set[Path]: return {x for x in result if x.exists()} def pytest_report_collectionfinish(self) -> str | None: - if self.active and self.config.getoption("verbose") >= 0: + if self.active and self.config.get_verbosity() >= 0: return f"run-last-failure: {self._report_status}" return None diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 2299e90fdc4..29e5a58c4ac 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1759,7 +1759,7 @@ def get_verbosity(self, verbosity_type: str | None = None) -> int: print(config.get_verbosity()) # 1 print(config.get_verbosity(Config.VERBOSITY_ASSERTIONS)) # 2 """ - global_level = self.option.verbose + global_level = self.getoption("verbose", default=0) assert isinstance(global_level, int) if verbosity_type is None: return global_level diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 7d0b40b150a..aaa92c63725 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1348,7 +1348,7 @@ def pytestconfig(request: FixtureRequest) -> Config: Example:: def test_foo(pytestconfig): - if pytestconfig.getoption("verbose") > 0: + if pytestconfig.get_verbosity() > 0: ... """ @@ -1807,7 +1807,7 @@ def _show_fixtures_per_test(config: Config, session: Session) -> None: session.perform_collect() invocation_dir = config.invocation_params.dir tw = _pytest.config.create_terminal_writer(config) - verbose = config.getvalue("verbose") + verbose = config.get_verbosity() def get_best_relpath(func) -> str: loc = getlocation(func, invocation_dir) @@ -1866,7 +1866,7 @@ def _showfixtures_main(config: Config, session: Session) -> None: session.perform_collect() invocation_dir = config.invocation_params.dir tw = _pytest.config.create_terminal_writer(config) - verbose = config.getvalue("verbose") + verbose = config.get_verbosity() fm = session._fixturemanager diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index 9f3417e9af2..08c826ff6d4 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -794,7 +794,7 @@ def pytest_runtestloop(self, session: Session) -> Generator[None, object, object if session.config.option.collectonly: return (yield) - if self._log_cli_enabled() and self._config.getoption("verbose") < 1: + if self._log_cli_enabled() and self._config.get_verbosity() < 1: # The verbose flag is needed to avoid messy test progress output. self._config.option.verbose = 1 diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index cc678695848..51bc5174628 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -435,12 +435,12 @@ def _repr_failure_py( else: style = "long" - if self.config.getoption("verbose", 0) > 1: + if self.config.get_verbosity() > 1: truncate_locals = False else: truncate_locals = True - truncate_args = False if self.config.getoption("verbose", 0) > 2 else True + truncate_args = False if self.config.get_verbosity() > 2 else True # excinfo.getrepr() formats paths relative to the CWD if `abspath` is False. # It is possible for a fixture/test to change the CWD while this code runs, which diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 6507c299225..9c54dd20f80 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -513,7 +513,7 @@ def importtestmodule( ) from e except ImportError as e: exc_info = ExceptionInfo.from_current() - if config.getoption("verbose") < 2: + if config.get_verbosity() < 2: exc_info.traceback = exc_info.traceback.filter(filter_traceback) exc_repr = ( exc_info.getrepr(style="short") diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index d0e1cdc7faa..0b60301bf5f 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -71,7 +71,7 @@ def pytest_addoption(parser: Parser) -> None: def pytest_terminal_summary(terminalreporter: TerminalReporter) -> None: durations = terminalreporter.config.option.durations durations_min = terminalreporter.config.option.durations_min - verbose = terminalreporter.config.getvalue("verbose") + verbose = terminalreporter.config.get_verbosity() if durations is None: return tr = terminalreporter diff --git a/src/_pytest/stepwise.py b/src/_pytest/stepwise.py index bd906ce63c1..c7860808c35 100644 --- a/src/_pytest/stepwise.py +++ b/src/_pytest/stepwise.py @@ -113,7 +113,7 @@ def pytest_runtest_logreport(self, report: TestReport) -> None: self.lastfailed = None def pytest_report_collectionfinish(self) -> str | None: - if self.config.getoption("verbose") >= 0 and self.report_status: + if self.config.get_verbosity() >= 0 and self.report_status: return f"stepwise: {self.report_status}" return None diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 01d911e8ca4..64a07ba8554 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1486,3 +1486,10 @@ def my_fixture(self, request): raise AssertionError( f"pytest command failed:\n{exc.stdout=!s}\n{exc.stderr=!s}" ) from exc + + +def test_no_terminal_plugin(pytester: Pytester) -> None: + """Smoke test to ensure pytest can execute without the terminal plugin (#9422).""" + pytester.makepyfile("def test(): assert 1 == 2") + result = pytester.runpytest("-pno:terminal", "-s") + assert result.ret == ExitCode.TESTS_FAILED From 9bde63f2baaf4b9a66a340b6389c059da757c3dc Mon Sep 17 00:00:00 2001 From: Stephen McDowell Date: Fri, 6 Sep 2024 18:00:11 -0400 Subject: [PATCH 054/445] [doc] Fix minor typo in example/parametrize.rst A space is needed for ``ZeroDivisionError`` to render as teletype. --- doc/en/example/parametrize.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index 3e449b2eaa2..b175510da6a 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -686,5 +686,5 @@ For example: assert (6 / example_input) == e In the example above, the first three test cases should run without any -exceptions, while the fourth should raise a``ZeroDivisionError`` exception, +exceptions, while the fourth should raise a ``ZeroDivisionError`` exception, which is expected by pytest. From 3cc88d980166e0741f69c00bd7acbb0a245dcaec Mon Sep 17 00:00:00 2001 From: Ashley Whetter Date: Sat, 7 Sep 2024 08:11:17 -0700 Subject: [PATCH 055/445] Exception chains can be navigated when dropped into Pdb in Python 3.13+ (#12708) Closes #12707 --- AUTHORS | 1 + changelog/12707.improvement.rst | 1 + src/_pytest/debugging.py | 34 ++++++++++++++++++++--------- testing/test_debugging.py | 38 ++++++++++++++++++++++++++++++++- 4 files changed, 63 insertions(+), 11 deletions(-) create mode 100644 changelog/12707.improvement.rst diff --git a/AUTHORS b/AUTHORS index 8bc8ad5cbde..6da8cbfef80 100644 --- a/AUTHORS +++ b/AUTHORS @@ -51,6 +51,7 @@ Aron Coyle Aron Curzon Arthur Richard Ashish Kurmi +Ashley Whetter Aviral Verma Aviv Palivoda Babak Keyvani diff --git a/changelog/12707.improvement.rst b/changelog/12707.improvement.rst new file mode 100644 index 00000000000..4684b6561c8 --- /dev/null +++ b/changelog/12707.improvement.rst @@ -0,0 +1 @@ +Exception chains can be navigated when dropped into Pdb in Python 3.13+. diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py index 2dfe321e968..763606cd60e 100644 --- a/src/_pytest/debugging.py +++ b/src/_pytest/debugging.py @@ -292,8 +292,8 @@ def pytest_exception_interact( _enter_pdb(node, call.excinfo, report) def pytest_internalerror(self, excinfo: ExceptionInfo[BaseException]) -> None: - tb = _postmortem_traceback(excinfo) - post_mortem(tb) + exc_or_tb = _postmortem_exc_or_tb(excinfo) + post_mortem(exc_or_tb) class PdbTrace: @@ -354,32 +354,46 @@ def _enter_pdb( tw.sep(">", "traceback") rep.toterminal(tw) tw.sep(">", "entering PDB") - tb = _postmortem_traceback(excinfo) + tb_or_exc = _postmortem_exc_or_tb(excinfo) rep._pdbshown = True # type: ignore[attr-defined] - post_mortem(tb) + post_mortem(tb_or_exc) return rep -def _postmortem_traceback(excinfo: ExceptionInfo[BaseException]) -> types.TracebackType: +def _postmortem_exc_or_tb( + excinfo: ExceptionInfo[BaseException], +) -> types.TracebackType | BaseException: from doctest import UnexpectedException + get_exc = sys.version_info >= (3, 13) if isinstance(excinfo.value, UnexpectedException): # A doctest.UnexpectedException is not useful for post_mortem. # Use the underlying exception instead: - return excinfo.value.exc_info[2] + underlying_exc = excinfo.value + if get_exc: + return underlying_exc.exc_info[1] + + return underlying_exc.exc_info[2] elif isinstance(excinfo.value, ConftestImportFailure): # A config.ConftestImportFailure is not useful for post_mortem. # Use the underlying exception instead: - assert excinfo.value.cause.__traceback__ is not None - return excinfo.value.cause.__traceback__ + cause = excinfo.value.cause + if get_exc: + return cause + + assert cause.__traceback__ is not None + return cause.__traceback__ else: assert excinfo._excinfo is not None + if get_exc: + return excinfo._excinfo[1] + return excinfo._excinfo[2] -def post_mortem(t: types.TracebackType) -> None: +def post_mortem(tb_or_exc: types.TracebackType | BaseException) -> None: p = pytestPDB._init_pdb("post_mortem") p.reset() - p.interaction(None, t) + p.interaction(None, tb_or_exc) if p.quitting: outcomes.exit("Quitting debugger") diff --git a/testing/test_debugging.py b/testing/test_debugging.py index 37032f92354..d86c9018b80 100644 --- a/testing/test_debugging.py +++ b/testing/test_debugging.py @@ -103,7 +103,10 @@ def test_func(): ) assert rep.failed assert len(pdblist) == 1 - tb = _pytest._code.Traceback(pdblist[0][0]) + if sys.version_info < (3, 13): + tb = _pytest._code.Traceback(pdblist[0][0]) + else: + tb = _pytest._code.Traceback(pdblist[0][0].__traceback__) assert tb[-1].name == "test_func" def test_pdb_on_xfail(self, pytester: Pytester, pdblist) -> None: @@ -921,6 +924,39 @@ def test_foo(): child.expect("custom set_trace>") self.flush(child) + @pytest.mark.skipif( + sys.version_info < (3, 13), + reason="Navigating exception chains was introduced in 3.13", + ) + def test_pdb_exception_chain_navigation(self, pytester: Pytester) -> None: + p1 = pytester.makepyfile( + """ + def inner_raise(): + is_inner = True + raise RuntimeError("Woops") + + def outer_raise(): + is_inner = False + try: + inner_raise() + except RuntimeError: + raise RuntimeError("Woopsie") + + def test_1(): + outer_raise() + assert True + """ + ) + child = pytester.spawn_pytest(f"--pdb {p1}") + child.expect("Pdb") + child.sendline("is_inner") + child.expect_exact("False") + child.sendline("exceptions 0") + child.sendline("is_inner") + child.expect_exact("True") + child.sendeof() + self.flush(child) + class TestDebuggingBreakpoints: @pytest.mark.parametrize("arg", ["--pdb", ""]) From de56e7c832f0ba3bf12d976dd552f8dd0b233377 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 8 Sep 2024 11:53:43 +0000 Subject: [PATCH 056/445] [automated] Update plugin list (#12786) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 128 ++++++++++++++++--------------- 1 file changed, 68 insertions(+), 60 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 992dc3d2be7..ffca5c08380 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =6.2.0 :pypi:`pytest-bdd-html` pytest plugin to display BDD info in HTML test report Nov 22, 2022 3 - Alpha pytest (!=6.0.0,>=5.0) - :pypi:`pytest-bdd-ng` BDD for pytest Dec 31, 2023 4 - Beta pytest >=5.0 + :pypi:`pytest-bdd-ng` BDD for pytest Sep 01, 2024 4 - Beta pytest>=5.0 :pypi:`pytest-bdd-report` A pytest-bdd plugin for generating useful and informative BDD test reports Aug 26, 2024 N/A pytest>=7.1.3 :pypi:`pytest-bdd-splinter` Common steps for pytest bdd and splinter integration Aug 12, 2019 5 - Production/Stable pytest (>=4.0.0) :pypi:`pytest-bdd-web` A simple plugin to use with pytest Jan 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Aug 08, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Aug 30, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Sep 05, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -240,7 +240,7 @@ This list contains 1512 plugins. :pypi:`pytest-ckan` Backport of CKAN 2.9 pytest plugin and fixtures to CAKN 2.8 Apr 28, 2020 4 - Beta pytest :pypi:`pytest-clarity` A plugin providing an alternative, colourful diff output for failing assertions. Jun 11, 2021 N/A N/A :pypi:`pytest-cldf` Easy quality control for CLDF datasets using pytest Nov 07, 2022 N/A pytest (>=3.6) - :pypi:`pytest-cleanslate` Collects and executes pytest tests separately Jun 17, 2024 N/A pytest + :pypi:`pytest-cleanslate` Collects and executes pytest tests separately Sep 04, 2024 N/A pytest :pypi:`pytest_cleanup` Automated, comprehensive and well-organised pytest test cases. Jan 28, 2020 N/A N/A :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Aug 26, 2024 5 - Production/Stable N/A :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Aug 15, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -252,7 +252,7 @@ This list contains 1512 plugins. :pypi:`pytest-cloudist` Distribute tests to cloud machines without fuss Sep 02, 2022 4 - Beta pytest (>=7.1.2,<8.0.0) :pypi:`pytest-cmake` Provide CMake module for Pytest Aug 16, 2024 N/A pytest<9,>=4 :pypi:`pytest-cmake-presets` Execute CMake Presets via pytest Dec 26, 2022 N/A pytest (>=7.2.0,<8.0.0) - :pypi:`pytest-cmdline-add-args` Pytest plugin for custom argument handling and Allure reporting. This plugin allows you to add arguments before running a test. Aug 31, 2024 N/A N/A + :pypi:`pytest-cmdline-add-args` Pytest plugin for custom argument handling and Allure reporting. This plugin allows you to add arguments before running a test. Sep 01, 2024 N/A N/A :pypi:`pytest-cobra` PyTest plugin for testing Smart Contracts for Ethereum blockchain. Jun 29, 2019 3 - Alpha pytest (<4.0.0,>=3.7.1) :pypi:`pytest_codeblocks` Test code blocks in your READMEs Sep 17, 2023 5 - Production/Stable pytest >= 7.0.0 :pypi:`pytest-codecarbon` Pytest plugin for measuring carbon emissions Jun 15, 2022 N/A pytest @@ -340,7 +340,7 @@ This list contains 1512 plugins. :pypi:`pytest-dbt-adapter` A pytest plugin for testing dbt adapter plugins Nov 24, 2021 N/A pytest (<7,>=6) :pypi:`pytest-dbt-conventions` A pytest plugin for linting a dbt project's conventions Mar 02, 2022 N/A pytest (>=6.2.5,<7.0.0) :pypi:`pytest-dbt-core` Pytest extension for dbt. Jun 04, 2024 N/A pytest>=6.2.5; extra == "test" - :pypi:`pytest-dbt-postgres` Pytest tooling to unittest DBT & Postgres models Jan 02, 2024 N/A pytest (>=7.4.3,<8.0.0) + :pypi:`pytest-dbt-postgres` Pytest tooling to unittest DBT & Postgres models Sep 03, 2024 N/A pytest<9.0.0,>=8.3.2 :pypi:`pytest-dbus-notification` D-BUS notifications for pytest results. Mar 05, 2014 5 - Production/Stable N/A :pypi:`pytest-dbx` Pytest plugin to run unit tests for dbx (Databricks CLI extensions) related code Nov 29, 2022 N/A pytest (>=7.1.3,<8.0.0) :pypi:`pytest-dc` Manages Docker containers during your integration tests Aug 16, 2023 5 - Production/Stable pytest >=3.3 @@ -373,7 +373,7 @@ This list contains 1512 plugins. :pypi:`pytest-ditto` Snapshot testing pytest plugin with minimal ceremony and flexible persistence formats. Jun 09, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-ditto-pandas` pytest-ditto plugin for pandas snapshots. May 29, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-ditto-pyarrow` pytest-ditto plugin for pyarrow tables. Jun 09, 2024 4 - Beta pytest>=3.5.0 - :pypi:`pytest-django` A Django plugin for pytest. Jan 30, 2024 5 - Production/Stable pytest >=7.0.0 + :pypi:`pytest-django` A Django plugin for pytest. Sep 02, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-django-ahead` A Django plugin for pytest. Oct 27, 2016 5 - Production/Stable pytest (>=2.9) :pypi:`pytest-djangoapp` Nice pytest plugin to help you with Django pluggable application testing. May 19, 2023 4 - Beta pytest :pypi:`pytest-django-cache-xdist` A djangocachexdist plugin for pytest May 12, 2020 4 - Beta N/A @@ -593,6 +593,7 @@ This list contains 1512 plugins. :pypi:`pytest-frozen-uuids` Deterministically frozen UUID's for your tests Apr 17, 2022 N/A pytest (>=3.0) :pypi:`pytest-func-cov` Pytest plugin for measuring function coverage Apr 15, 2021 3 - Alpha pytest (>=5) :pypi:`pytest-funparam` An alternative way to parametrize test cases. Dec 02, 2021 4 - Beta pytest >=4.6.0 + :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Sep 06, 2024 N/A pytest :pypi:`pytest-fxa` pytest plugin for Firefox Accounts Aug 28, 2018 5 - Production/Stable N/A :pypi:`pytest-fxtest` Oct 27, 2020 N/A N/A :pypi:`pytest-fzf` fzf-based test selector for pytest Jul 03, 2024 4 - Beta pytest>=6.0.0 @@ -616,7 +617,7 @@ This list contains 1512 plugins. :pypi:`pytest-github-actions-annotate-failures` pytest plugin to annotate failed tests with a workflow command for GitHub Actions May 04, 2023 5 - Production/Stable pytest (>=4.0.0) :pypi:`pytest-github-report` Generate a GitHub report using pytest in GitHub Workflows Jun 03, 2022 4 - Beta N/A :pypi:`pytest-gitignore` py.test plugin to ignore the same files as git Jul 17, 2015 4 - Beta N/A - :pypi:`pytest-gitlab` Pytest Plugin for Gitlab Aug 30, 2024 N/A N/A + :pypi:`pytest-gitlab` Pytest Plugin for Gitlab Sep 06, 2024 N/A N/A :pypi:`pytest-gitlabci-parallelized` Parallelize pytest across GitLab CI workers. Mar 08, 2023 N/A N/A :pypi:`pytest-gitlab-code-quality` Collects warnings while testing and generates a GitLab Code Quality Report. Apr 03, 2024 N/A pytest>=8.1.1 :pypi:`pytest-gitlab-fold` Folds output sections in GitLab CI build log Dec 31, 2023 4 - Beta pytest >=2.6.0 @@ -650,7 +651,7 @@ This list contains 1512 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Aug 31, 2024 3 - Alpha pytest==8.3.1 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Sep 07, 2024 3 - Alpha pytest==8.3.1 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Apr 18, 2024 N/A N/A @@ -755,7 +756,7 @@ This list contains 1512 plugins. :pypi:`pytest-kasima` Display horizontal lines above and below the captured standard output for easy viewing. Jan 26, 2023 5 - Production/Stable pytest (>=7.2.1,<8.0.0) :pypi:`pytest-keep-together` Pytest plugin to customize test ordering by running all 'related' tests together Dec 07, 2022 5 - Production/Stable pytest :pypi:`pytest-kexi` Apr 29, 2022 N/A pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-keyring` A Pytest plugin to access the system's keyring to provide credentials for tests Oct 01, 2023 N/A pytest (>=7.1) + :pypi:`pytest-keyring` A Pytest plugin to access the system's keyring to provide credentials for tests Sep 05, 2024 N/A pytest>=8.0.2 :pypi:`pytest-kind` Kubernetes test support with KIND for pytest Nov 30, 2022 5 - Production/Stable N/A :pypi:`pytest-kivy` Kivy GUI tests fixtures using pytest Jul 06, 2021 4 - Beta pytest (>=3.6) :pypi:`pytest-knows` A pytest plugin that can automaticly skip test case based on dependence info calculated by trace Aug 22, 2014 N/A N/A @@ -780,7 +781,7 @@ This list contains 1512 plugins. :pypi:`pytest-leaping` A simple plugin to use with pytest Mar 27, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-level` Select tests of a given level or lower Oct 21, 2019 N/A pytest :pypi:`pytest-libfaketime` A python-libfaketime plugin for pytest Apr 12, 2024 4 - Beta pytest>=3.0.0 - :pypi:`pytest-libiio` A pytest plugin to manage interfacing with libiio contexts Dec 22, 2023 4 - Beta N/A + :pypi:`pytest-libiio` A pytest plugin to manage interfacing with libiio contexts Sep 05, 2024 4 - Beta N/A :pypi:`pytest-libnotify` Pytest plugin that shows notifications about the test run Apr 02, 2021 3 - Alpha pytest :pypi:`pytest-ligo` Jan 16, 2020 4 - Beta N/A :pypi:`pytest-lineno` A pytest plugin to show the line numbers of test functions Dec 04, 2020 N/A pytest @@ -810,7 +811,7 @@ This list contains 1512 plugins. :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Jul 19, 2024 4 - Beta N/A :pypi:`pytest-loguru` Pytest Loguru Mar 20, 2024 5 - Production/Stable pytest; extra == "test" :pypi:`pytest-loop` pytest plugin for looping tests Mar 30, 2024 5 - Production/Stable pytest - :pypi:`pytest-lsp` A pytest plugin for end-to-end testing of language servers Aug 28, 2024 3 - Alpha pytest + :pypi:`pytest-lsp` A pytest plugin for end-to-end testing of language servers Sep 04, 2024 3 - Alpha pytest :pypi:`pytest-manual-marker` pytest marker for marking manual tests Aug 04, 2022 3 - Alpha pytest>=7 :pypi:`pytest-markdoctest` A pytest plugin to doctest your markdown files Jul 22, 2022 4 - Beta pytest (>=6) :pypi:`pytest-markdown` Test your markdown docs with pytest Jan 15, 2021 4 - Beta pytest (>=6.0.1,<7.0.0) @@ -850,7 +851,7 @@ This list contains 1512 plugins. :pypi:`pytest-mini` A plugin to test mp Feb 06, 2023 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-minio-mock` A pytest plugin for mocking Minio S3 interactions Aug 27, 2024 N/A pytest>=5.0.0 :pypi:`pytest-missing-fixtures` Pytest plugin that creates missing fixtures Oct 14, 2020 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-missing-modules` Pytest plugin to easily fake missing modules Aug 26, 2024 N/A pytest>=8.3.2 + :pypi:`pytest-missing-modules` Pytest plugin to easily fake missing modules Sep 03, 2024 N/A pytest>=8.3.2 :pypi:`pytest-mitmproxy` pytest plugin for mitmproxy tests May 28, 2024 N/A pytest>=7.0 :pypi:`pytest-ml` Test your machine learning! May 04, 2019 4 - Beta N/A :pypi:`pytest-mocha` pytest plugin to display test execution output like a mochajs Apr 02, 2020 4 - Beta pytest (>=5.4.0) @@ -940,7 +941,7 @@ This list contains 1512 plugins. :pypi:`pytest-oot` Run object-oriented tests in a simple format Sep 18, 2016 4 - Beta N/A :pypi:`pytest-openfiles` Pytest plugin for detecting inadvertent open file handles Jun 05, 2024 3 - Alpha pytest>=4.6 :pypi:`pytest-opentelemetry` A pytest plugin for instrumenting test runs via OpenTelemetry Oct 01, 2023 N/A pytest - :pypi:`pytest-opentmi` pytest plugin for publish results to opentmi Jun 02, 2022 5 - Production/Stable pytest (>=5.0) + :pypi:`pytest-opentmi` pytest plugin for publish results to opentmi Sep 05, 2024 5 - Production/Stable pytest>=5.0 :pypi:`pytest-operator` Fixtures for Operators Sep 28, 2022 N/A pytest :pypi:`pytest-optional` include/exclude values of fixtures in pytest Oct 07, 2015 N/A N/A :pypi:`pytest-optional-tests` Easy declaration of optional tests (i.e., that are not run by default) Jul 09, 2019 4 - Beta pytest (>=4.5.0) @@ -1026,7 +1027,7 @@ This list contains 1512 plugins. :pypi:`pytest-pop` A pytest plugin to help with testing pop projects May 09, 2023 5 - Production/Stable pytest :pypi:`pytest-portion` Select a portion of the collected tests Jan 28, 2021 4 - Beta pytest (>=3.5.0) :pypi:`pytest-postgres` Run PostgreSQL in Docker container in Pytest. Mar 22, 2020 N/A pytest - :pypi:`pytest-postgresql` Postgresql fixtures and fixture factories for Pytest. Aug 14, 2024 5 - Production/Stable pytest>=6.2 + :pypi:`pytest-postgresql` Postgresql fixtures and fixture factories for Pytest. Sep 05, 2024 5 - Production/Stable pytest>=6.2 :pypi:`pytest-power` pytest plugin with powerful fixtures Dec 31, 2020 N/A pytest (>=5.4) :pypi:`pytest-powerpack` Mar 17, 2024 N/A pytest (>=8.1.1,<9.0.0) :pypi:`pytest-prefer-nested-dup-tests` A Pytest plugin to drop duplicated tests during collection, but will prefer keeping nested packages. Apr 27, 2022 4 - Beta pytest (>=7.1.1,<8.0.0) @@ -1078,7 +1079,7 @@ This list contains 1512 plugins. :pypi:`pytest-pytorch` pytest plugin for a better developer experience when working with the PyTorch test suite May 25, 2021 4 - Beta pytest :pypi:`pytest-pyvenv` A package for create venv in tests Feb 27, 2024 N/A pytest ; extra == 'test' :pypi:`pytest-pyvista` Pytest-pyvista package Sep 29, 2023 4 - Beta pytest>=3.5.0 - :pypi:`pytest-qanova` A pytest plugin to collect test information Aug 26, 2024 3 - Alpha pytest + :pypi:`pytest-qanova` A pytest plugin to collect test information Sep 05, 2024 3 - Alpha pytest :pypi:`pytest-qaseio` Pytest plugin for Qase.io integration May 30, 2024 4 - Beta pytest<9.0.0,>=7.2.2 :pypi:`pytest-qasync` Pytest support for qasync. Jul 12, 2021 4 - Beta pytest (>=5.4.0) :pypi:`pytest-qatouch` Pytest plugin for uploading test results to your QA Touch Testrun. Feb 14, 2023 4 - Beta pytest (>=6.2.0) @@ -1105,7 +1106,7 @@ This list contains 1512 plugins. :pypi:`pytest-random-order` Randomise the order in which pytest tests are run with some control over the randomness Jan 20, 2024 5 - Production/Stable pytest >=3.0.0 :pypi:`pytest-ranking` A Pytest plugin for automatically prioritizing/ranking tests to speed up failure detection Jun 07, 2024 4 - Beta pytest>=7.4.3 :pypi:`pytest-readme` Test your README.md file Sep 02, 2022 5 - Production/Stable N/A - :pypi:`pytest-reana` Pytest fixtures for REANA. Aug 21, 2024 3 - Alpha N/A + :pypi:`pytest-reana` Pytest fixtures for REANA. Sep 04, 2024 3 - Alpha N/A :pypi:`pytest-recorder` Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. Jun 27, 2024 N/A N/A :pypi:`pytest-recording` A pytest plugin that allows you recording of network interactions via VCR.py Jul 09, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-recordings` Provides pytest plugins for reporting request/response traffic, screenshots, and more to ReportPortal Aug 13, 2020 N/A N/A @@ -1129,7 +1130,7 @@ This list contains 1512 plugins. :pypi:`pytest-reorder` Reorder tests depending on their paths and names. May 31, 2018 4 - Beta pytest :pypi:`pytest-repeat` pytest plugin for repeating tests Oct 09, 2023 5 - Production/Stable pytest :pypi:`pytest_repeater` py.test plugin for repeating single test multiple times. Feb 09, 2018 1 - Planning N/A - :pypi:`pytest-replay` Saves previous test runs and allow re-execute previous pytest runs to reproduce crashes or flaky tests Jan 11, 2024 5 - Production/Stable pytest + :pypi:`pytest-replay` Saves previous test runs and allow re-execute previous pytest runs to reproduce crashes or flaky tests Sep 03, 2024 5 - Production/Stable pytest :pypi:`pytest-repo-health` A pytest plugin to report on repository standards conformance Apr 17, 2023 3 - Alpha pytest :pypi:`pytest-report` Creates json report that is compatible with atom.io's linter message format May 11, 2016 4 - Beta N/A :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest @@ -1143,7 +1144,7 @@ This list contains 1512 plugins. :pypi:`pytest-reportportal` Agent for Reporting results of tests to the Report Portal Mar 27, 2024 N/A pytest>=3.8.0 :pypi:`pytest-report-stream` A pytest plugin which allows to stream test reports at runtime Oct 22, 2023 4 - Beta N/A :pypi:`pytest-repo-structure` Pytest Repo Structure Mar 18, 2024 1 - Planning N/A - :pypi:`pytest-req` pytest requests plugin Jul 26, 2024 N/A pytest<9.0.0,>=8.3.1 + :pypi:`pytest-req` pytest requests plugin Aug 31, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.2 :pypi:`pytest-reqs` pytest plugin to check pinned requirements May 12, 2019 N/A pytest (>=2.4.2) :pypi:`pytest-requests` A simple plugin to use with pytest Jun 24, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-requestselapsed` collect and show http requests elapsed time Aug 14, 2022 N/A N/A @@ -1205,7 +1206,7 @@ This list contains 1512 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Aug 30, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Sep 05, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 :pypi:`pytest-schedule` The job of test scheduling for humans. Jan 07, 2023 5 - Production/Stable N/A @@ -1216,11 +1217,11 @@ This list contains 1512 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Aug 30, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Sep 05, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 - :pypi:`pytest-send-email` Send pytest execution result email Dec 04, 2019 N/A N/A + :pypi:`pytest-send-email` Send pytest execution result email Sep 02, 2024 N/A pytest :pypi:`pytest-sentry` A pytest plugin to send testrun information to Sentry.io Apr 25, 2024 N/A pytest :pypi:`pytest-sequence-markers` Pytest plugin for sequencing markers for execution of tests May 23, 2023 5 - Production/Stable N/A :pypi:`pytest-server` test server exec cmd Jun 24, 2024 N/A N/A @@ -1235,7 +1236,7 @@ This list contains 1512 plugins. :pypi:`pytest-setupinfo` Displaying setup info during pytest command run Jan 23, 2023 N/A N/A :pypi:`pytest-sftpserver` py.test plugin to locally test sftp server connections. Sep 16, 2019 4 - Beta N/A :pypi:`pytest-shard` Dec 11, 2020 4 - Beta pytest - :pypi:`pytest-shared-session-scope` Aug 28, 2024 N/A pytest>=7 + :pypi:`pytest-shared-session-scope` Sep 05, 2024 N/A pytest>=7 :pypi:`pytest-share-hdf` Plugin to save test data in HDF files and retrieve them for comparison Sep 21, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-sharkreport` this is pytest report plugin. Jul 11, 2022 N/A pytest (>=3.5) :pypi:`pytest-shell` A pytest plugin to help with testing shell scripts / black box commands Mar 27, 2022 N/A N/A @@ -1295,7 +1296,7 @@ This list contains 1512 plugins. :pypi:`pytest-splitio` Split.io SDK integration for e2e tests Sep 22, 2020 N/A pytest (<7,>=5.0) :pypi:`pytest-split-tests` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Forked from Mark Adams' original project pytest-test-groups. Jul 30, 2021 5 - Production/Stable pytest (>=2.5) :pypi:`pytest-split-tests-tresorit` Feb 22, 2021 1 - Planning N/A - :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Aug 28, 2024 N/A pytest<8,>5.4.0 + :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Sep 04, 2024 N/A pytest<8,>5.4.0 :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Jul 10, 2024 N/A N/A :pypi:`pytest-splunk-env` pytest fixtures for interaction with Splunk Enterprise and Splunk Cloud Oct 22, 2020 N/A pytest (>=6.1.1,<7.0.0) :pypi:`pytest-sqitch` sqitch for pytest Apr 06, 2020 4 - Beta N/A @@ -1318,7 +1319,7 @@ This list contains 1512 plugins. :pypi:`pytest-stepwise` Run a test suite one failing test at a time. Dec 01, 2015 4 - Beta N/A :pypi:`pytest-stf` pytest plugin for openSTF Mar 25, 2024 N/A pytest>=5.0 :pypi:`pytest-stoq` A plugin to pytest stoq Feb 09, 2021 4 - Beta N/A - :pypi:`pytest-store` Pytest plugin to store values from test runs Nov 16, 2023 3 - Alpha pytest (>=7.0.0) + :pypi:`pytest-store` Pytest plugin to store values from test runs Sep 04, 2024 3 - Alpha pytest>=7.0.0 :pypi:`pytest-stress` A Pytest plugin that allows you to loop tests for a user defined amount of time. Dec 07, 2019 4 - Beta pytest (>=3.6.0) :pypi:`pytest-structlog` Structured logging assertions Jul 25, 2024 N/A pytest :pypi:`pytest-structmpd` provide structured temporary directory Oct 17, 2018 N/A N/A @@ -1540,7 +1541,7 @@ This list contains 1512 plugins. :pypi:`pytest-zcc` eee Jun 02, 2024 N/A N/A :pypi:`pytest-zebrunner` Pytest connector for Zebrunner reporting Jul 04, 2024 5 - Production/Stable pytest>=4.5.0 :pypi:`pytest-zeebe` Pytest fixtures for testing Camunda 8 processes using a Zeebe test engine. Feb 01, 2024 N/A pytest (>=7.4.2,<8.0.0) - :pypi:`pytest-zephyr-scale-integration` A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest Aug 20, 2024 N/A pytest + :pypi:`pytest-zephyr-scale-integration` A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest Sep 04, 2024 N/A pytest :pypi:`pytest-zest` Zesty additions to pytest. Nov 17, 2022 N/A N/A :pypi:`pytest-zhongwen-wendang` PyTest 中文文档 Mar 04, 2024 4 - Beta N/A :pypi:`pytest-zigzag` Extend py.test for RPC OpenStack testing. Feb 27, 2019 4 - Beta pytest (~=3.6) @@ -2343,9 +2344,9 @@ This list contains 1512 plugins. pytest plugin to display BDD info in HTML test report :pypi:`pytest-bdd-ng` - *last release*: Dec 31, 2023, + *last release*: Sep 01, 2024, *status*: 4 - Beta, - *requires*: pytest >=5.0 + *requires*: pytest>=5.0 BDD for pytest @@ -2392,7 +2393,7 @@ This list contains 1512 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Aug 30, 2024, + *last release*: Sep 05, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -2994,7 +2995,7 @@ This list contains 1512 plugins. Easy quality control for CLDF datasets using pytest :pypi:`pytest-cleanslate` - *last release*: Jun 17, 2024, + *last release*: Sep 04, 2024, *status*: N/A, *requires*: pytest @@ -3078,7 +3079,7 @@ This list contains 1512 plugins. Execute CMake Presets via pytest :pypi:`pytest-cmdline-add-args` - *last release*: Aug 31, 2024, + *last release*: Sep 01, 2024, *status*: N/A, *requires*: N/A @@ -3694,9 +3695,9 @@ This list contains 1512 plugins. Pytest extension for dbt. :pypi:`pytest-dbt-postgres` - *last release*: Jan 02, 2024, + *last release*: Sep 03, 2024, *status*: N/A, - *requires*: pytest (>=7.4.3,<8.0.0) + *requires*: pytest<9.0.0,>=8.3.2 Pytest tooling to unittest DBT & Postgres models @@ -3925,9 +3926,9 @@ This list contains 1512 plugins. pytest-ditto plugin for pyarrow tables. :pypi:`pytest-django` - *last release*: Jan 30, 2024, + *last release*: Sep 02, 2024, *status*: 5 - Production/Stable, - *requires*: pytest >=7.0.0 + *requires*: pytest>=7.0.0 A Django plugin for pytest. @@ -5464,6 +5465,13 @@ This list contains 1512 plugins. An alternative way to parametrize test cases. + :pypi:`pytest-fv` + *last release*: Sep 06, 2024, + *status*: N/A, + *requires*: pytest + + pytest extensions to support running functional-verification jobs + :pypi:`pytest-fxa` *last release*: Aug 28, 2018, *status*: 5 - Production/Stable, @@ -5626,7 +5634,7 @@ This list contains 1512 plugins. py.test plugin to ignore the same files as git :pypi:`pytest-gitlab` - *last release*: Aug 30, 2024, + *last release*: Sep 06, 2024, *status*: N/A, *requires*: N/A @@ -5864,7 +5872,7 @@ This list contains 1512 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Aug 31, 2024, + *last release*: Sep 07, 2024, *status*: 3 - Alpha, *requires*: pytest==8.3.1 @@ -6599,9 +6607,9 @@ This list contains 1512 plugins. :pypi:`pytest-keyring` - *last release*: Oct 01, 2023, + *last release*: Sep 05, 2024, *status*: N/A, - *requires*: pytest (>=7.1) + *requires*: pytest>=8.0.2 A Pytest plugin to access the system's keyring to provide credentials for tests @@ -6774,7 +6782,7 @@ This list contains 1512 plugins. A python-libfaketime plugin for pytest :pypi:`pytest-libiio` - *last release*: Dec 22, 2023, + *last release*: Sep 05, 2024, *status*: 4 - Beta, *requires*: N/A @@ -6984,7 +6992,7 @@ This list contains 1512 plugins. pytest plugin for looping tests :pypi:`pytest-lsp` - *last release*: Aug 28, 2024, + *last release*: Sep 04, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -7264,7 +7272,7 @@ This list contains 1512 plugins. Pytest plugin that creates missing fixtures :pypi:`pytest-missing-modules` - *last release*: Aug 26, 2024, + *last release*: Sep 03, 2024, *status*: N/A, *requires*: pytest>=8.3.2 @@ -7894,9 +7902,9 @@ This list contains 1512 plugins. A pytest plugin for instrumenting test runs via OpenTelemetry :pypi:`pytest-opentmi` - *last release*: Jun 02, 2022, + *last release*: Sep 05, 2024, *status*: 5 - Production/Stable, - *requires*: pytest (>=5.0) + *requires*: pytest>=5.0 pytest plugin for publish results to opentmi @@ -8496,7 +8504,7 @@ This list contains 1512 plugins. Run PostgreSQL in Docker container in Pytest. :pypi:`pytest-postgresql` - *last release*: Aug 14, 2024, + *last release*: Sep 05, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=6.2 @@ -8860,7 +8868,7 @@ This list contains 1512 plugins. Pytest-pyvista package :pypi:`pytest-qanova` - *last release*: Aug 26, 2024, + *last release*: Sep 05, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -9049,7 +9057,7 @@ This list contains 1512 plugins. Test your README.md file :pypi:`pytest-reana` - *last release*: Aug 21, 2024, + *last release*: Sep 04, 2024, *status*: 3 - Alpha, *requires*: N/A @@ -9217,7 +9225,7 @@ This list contains 1512 plugins. py.test plugin for repeating single test multiple times. :pypi:`pytest-replay` - *last release*: Jan 11, 2024, + *last release*: Sep 03, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -9315,9 +9323,9 @@ This list contains 1512 plugins. Pytest Repo Structure :pypi:`pytest-req` - *last release*: Jul 26, 2024, - *status*: N/A, - *requires*: pytest<9.0.0,>=8.3.1 + *last release*: Aug 31, 2024, + *status*: 5 - Production/Stable, + *requires*: pytest<9.0.0,>=8.3.2 pytest requests plugin @@ -9749,7 +9757,7 @@ This list contains 1512 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Aug 30, 2024, + *last release*: Sep 05, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9826,7 +9834,7 @@ This list contains 1512 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Aug 30, 2024, + *last release*: Sep 05, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9854,9 +9862,9 @@ This list contains 1512 plugins. A pytest plugin for selfie snapshot testing. :pypi:`pytest-send-email` - *last release*: Dec 04, 2019, + *last release*: Sep 02, 2024, *status*: N/A, - *requires*: N/A + *requires*: pytest Send pytest execution result email @@ -9959,7 +9967,7 @@ This list contains 1512 plugins. :pypi:`pytest-shared-session-scope` - *last release*: Aug 28, 2024, + *last release*: Sep 05, 2024, *status*: N/A, *requires*: pytest>=7 @@ -10379,7 +10387,7 @@ This list contains 1512 plugins. :pypi:`pytest-splunk-addon` - *last release*: Aug 28, 2024, + *last release*: Sep 04, 2024, *status*: N/A, *requires*: pytest<8,>5.4.0 @@ -10540,9 +10548,9 @@ This list contains 1512 plugins. A plugin to pytest stoq :pypi:`pytest-store` - *last release*: Nov 16, 2023, + *last release*: Sep 04, 2024, *status*: 3 - Alpha, - *requires*: pytest (>=7.0.0) + *requires*: pytest>=7.0.0 Pytest plugin to store values from test runs @@ -12094,7 +12102,7 @@ This list contains 1512 plugins. Pytest fixtures for testing Camunda 8 processes using a Zeebe test engine. :pypi:`pytest-zephyr-scale-integration` - *last release*: Aug 20, 2024, + *last release*: Sep 04, 2024, *status*: N/A, *requires*: pytest From d35b802805b210c6d5281864d663f53c6a72f153 Mon Sep 17 00:00:00 2001 From: Nauman Ahmed <90570675+nauman897@users.noreply.github.com> Date: Sun, 8 Sep 2024 19:32:23 +0500 Subject: [PATCH 057/445] Fix issue with slashes being turned into backslashes on Windows (#12760) Fix #12745 --- AUTHORS | 1 + changelog/12745.bugfix.rst | 1 + src/_pytest/config/__init__.py | 8 ++++++-- testing/test_terminal.py | 35 ++++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 changelog/12745.bugfix.rst diff --git a/AUTHORS b/AUTHORS index 6da8cbfef80..374e6ad9bcc 100644 --- a/AUTHORS +++ b/AUTHORS @@ -301,6 +301,7 @@ mrbean-bremen Nathan Goldbaum Nathaniel Compton Nathaniel Waisbrot +Nauman Ahmed Ned Batchelder Neil Martin Neven Mundar diff --git a/changelog/12745.bugfix.rst b/changelog/12745.bugfix.rst new file mode 100644 index 00000000000..420be931ce9 --- /dev/null +++ b/changelog/12745.bugfix.rst @@ -0,0 +1 @@ +Fixed an issue with backslashes being incorrectly converted in nodeid paths on Windows, ensuring consistent path handling across environments. diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 29e5a58c4ac..c53661dbeb5 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1178,8 +1178,12 @@ def notify_exception( def cwd_relative_nodeid(self, nodeid: str) -> str: # nodeid's are relative to the rootpath, compute relative to cwd. if self.invocation_params.dir != self.rootpath: - fullpath = self.rootpath / nodeid - nodeid = bestrelpath(self.invocation_params.dir, fullpath) + base_path_part, *nodeid_part = nodeid.split("::") + # Only process path part + fullpath = self.rootpath / base_path_part + relative_path = bestrelpath(self.invocation_params.dir, fullpath) + + nodeid = "::".join([relative_path, *nodeid_part]) return nodeid @classmethod diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 11ad623fb6b..14c152d6123 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -3067,3 +3067,38 @@ def test_pass(): "*= 1 xpassed in * =*", ] ) + + +class TestNodeIDHandling: + def test_nodeid_handling_windows_paths(self, pytester: Pytester, tmp_path) -> None: + """Test the correct handling of Windows-style paths with backslashes.""" + pytester.makeini("[pytest]") # Change `config.rootpath` + + test_path = pytester.path / "tests" / "test_foo.py" + test_path.parent.mkdir() + os.chdir(test_path.parent) # Change `config.invocation_params.dir` + + test_path.write_text( + textwrap.dedent( + """ + import pytest + + @pytest.mark.parametrize("a", ["x/y", "C:/path", "\\\\", "C:\\\\path", "a::b/"]) + def test_x(a): + assert False + """ + ), + encoding="utf-8", + ) + + result = pytester.runpytest("-v") + + result.stdout.re_match_lines( + [ + r".*test_foo.py::test_x\[x/y\] .*FAILED.*", + r".*test_foo.py::test_x\[C:/path\] .*FAILED.*", + r".*test_foo.py::test_x\[\\\\\] .*FAILED.*", + r".*test_foo.py::test_x\[C:\\\\path\] .*FAILED.*", + r".*test_foo.py::test_x\[a::b/\] .*FAILED.*", + ] + ) From c6a529032231ccddd3040e8ab1a5a756eb9ea4a0 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 8 Sep 2024 10:45:05 -0400 Subject: [PATCH 058/445] Do not discover properties when iterating fixtures (#12781) Resolves #12446 --- changelog/12446.bugfix.rst | 1 + src/_pytest/fixtures.py | 16 +++++++++++++--- testing/python/collect.py | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 changelog/12446.bugfix.rst diff --git a/changelog/12446.bugfix.rst b/changelog/12446.bugfix.rst new file mode 100644 index 00000000000..2f591c48eed --- /dev/null +++ b/changelog/12446.bugfix.rst @@ -0,0 +1 @@ +Avoid calling ``@property`` (and other instance descriptors) during fixture discovery -- by :user:`asottile` diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index aaa92c63725..6b882fa3515 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -53,6 +53,7 @@ from _pytest.compat import NOTSET from _pytest.compat import NotSetType from _pytest.compat import safe_getattr +from _pytest.compat import safe_isclass from _pytest.config import _PluggyPlugin from _pytest.config import Config from _pytest.config import ExitCode @@ -1724,17 +1725,26 @@ def parsefactories( if holderobj in self._holderobjseen: return + # Avoid accessing `@property` (and other descriptors) when iterating fixtures. + if not safe_isclass(holderobj) and not isinstance(holderobj, types.ModuleType): + holderobj_tp: object = type(holderobj) + else: + holderobj_tp = holderobj + self._holderobjseen.add(holderobj) for name in dir(holderobj): # The attribute can be an arbitrary descriptor, so the attribute - # access below can raise. safe_getatt() ignores such exceptions. - obj = safe_getattr(holderobj, name, None) - marker = getfixturemarker(obj) + # access below can raise. safe_getattr() ignores such exceptions. + obj_ub = safe_getattr(holderobj_tp, name, None) + marker = getfixturemarker(obj_ub) if not isinstance(marker, FixtureFunctionMarker): # Magic globals with __getattr__ might have got us a wrong # fixture attribute. continue + # OK we know it is a fixture -- now safe to look up on the _instance_. + obj = getattr(holderobj, name) + if marker.name: name = marker.name diff --git a/testing/python/collect.py b/testing/python/collect.py index 06386611279..530f1c340ff 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -263,6 +263,43 @@ def prop(self): result = pytester.runpytest() assert result.ret == ExitCode.NO_TESTS_COLLECTED + def test_does_not_discover_properties(self, pytester: Pytester) -> None: + """Regression test for #12446.""" + pytester.makepyfile( + """\ + class TestCase: + @property + def oops(self): + raise SystemExit('do not call me!') + """ + ) + result = pytester.runpytest() + assert result.ret == ExitCode.NO_TESTS_COLLECTED + + def test_does_not_discover_instance_descriptors(self, pytester: Pytester) -> None: + """Regression test for #12446.""" + pytester.makepyfile( + """\ + # not `@property`, but it acts like one + # this should cover the case of things like `@cached_property` / etc. + class MyProperty: + def __init__(self, func): + self._func = func + def __get__(self, inst, owner): + if inst is None: + return self + else: + return self._func.__get__(inst, owner)() + + class TestCase: + @MyProperty + def oops(self): + raise SystemExit('do not call me!') + """ + ) + result = pytester.runpytest() + assert result.ret == ExitCode.NO_TESTS_COLLECTED + def test_abstract_class_is_not_collected(self, pytester: Pytester) -> None: """Regression test for #12275 (non-unittest version).""" pytester.makepyfile( From 0b75b3ae66a030da0fb931878fccfd72de58ee9d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 08:59:27 -0300 Subject: [PATCH 059/445] build(deps): Bump pytest-django in /testing/plugins_integration (#12792) Bumps [pytest-django](https://github.com/pytest-dev/pytest-django) from 4.8.0 to 4.9.0. - [Release notes](https://github.com/pytest-dev/pytest-django/releases) - [Changelog](https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst) - [Commits](https://github.com/pytest-dev/pytest-django/compare/v4.8.0...v4.9.0) --- updated-dependencies: - dependency-name: pytest-django dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index c48b55c0ae2..aa5e0fb6caa 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -3,7 +3,7 @@ django==5.1 pytest-asyncio==0.24.0 pytest-bdd==7.2.0 pytest-cov==5.0.0 -pytest-django==4.8.0 +pytest-django==4.9.0 pytest-flakes==4.0.5 pytest-html==4.1.1 pytest-mock==3.14.0 From 39bd14ad1679e45583ab1ee35f152c35e3239226 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 08:59:38 -0300 Subject: [PATCH 060/445] build(deps): Bump django in /testing/plugins_integration (#12793) Bumps [django](https://github.com/django/django) from 5.1 to 5.1.1. - [Commits](https://github.com/django/django/compare/5.1...5.1.1) --- updated-dependencies: - dependency-name: django dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index aa5e0fb6caa..70fac9e1f1c 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,5 +1,5 @@ anyio[curio,trio]==4.4.0 -django==5.1 +django==5.1.1 pytest-asyncio==0.24.0 pytest-bdd==7.2.0 pytest-cov==5.0.0 From 63a5e11514501f8bd3ff50d88a09c33a7a5de0c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 09:04:10 -0300 Subject: [PATCH 061/445] build(deps): Bump pypa/gh-action-pypi-publish from 1.10.0 to 1.10.1 (#12790) Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.0 to 1.10.1. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.10.0...v1.10.1) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index abbdead2ca9..1299c4c57c3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -54,7 +54,7 @@ jobs: path: dist - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@v1.10.0 + uses: pypa/gh-action-pypi-publish@v1.10.1 with: attestations: true From 7316b42df28ddf8de0038e5d6df1811408730dbd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 09:05:39 -0300 Subject: [PATCH 062/445] build(deps): Bump peter-evans/create-pull-request from 6.1.0 to 7.0.1 (#12791) Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 6.1.0 to 7.0.1. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/c5a7806660adbe173f04e3e038b0ccdcd758773c...8867c4aba1b742c39f8d0ba35429c2dfa4b6cb20) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/update-plugin-list.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-plugin-list.yml b/.github/workflows/update-plugin-list.yml index ade8452afd5..2f1fb14ea70 100644 --- a/.github/workflows/update-plugin-list.yml +++ b/.github/workflows/update-plugin-list.yml @@ -47,7 +47,7 @@ jobs: - name: Create Pull Request id: pr - uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c + uses: peter-evans/create-pull-request@8867c4aba1b742c39f8d0ba35429c2dfa4b6cb20 with: commit-message: '[automated] Update plugin list' author: 'pytest bot ' From e8504ed49be73e516ee1559a250daec659e96b9d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 9 Sep 2024 18:28:15 -0300 Subject: [PATCH 063/445] Include co-authors in release announcement (#12795) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As noted in #12789, the `release.py` script did not consider `Co-authored-by` fields, and since we introduced the new backport bot, this problem became more apparent due to how the backport commit and PR are generated. Previously, the list of authors produced by the script in the #12789 branch was: ``` * Avasam * Bruno Oliveira * Ronny Pfannschmidt * Sviatoslav Sydorenko (Святослав Сидоренко) ``` With this script: ``` * Anthony Sottile * Avasam * Bruno Oliveira * Christian Clauss * Eugene Mwangi * Florian Bruhin * GTowers1 * Nauman Ahmed * Pierre Sassoulas * Reagan Lee * Ronny Pfannschmidt * Stefaan Lippens * Sviatoslav Sydorenko (Святослав Сидоренко) * dongfangtianyu ``` --- scripts/release.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/release.py b/scripts/release.py index 545919cd60b..aef5d6d5f73 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -6,6 +6,7 @@ import argparse import os from pathlib import Path +import re from subprocess import call from subprocess import check_call from subprocess import check_output @@ -16,17 +17,27 @@ def announce(version: str, template_name: str, doc_version: str) -> None: """Generates a new release announcement entry in the docs.""" - # Get our list of authors + # Get our list of authors and co-authors. stdout = check_output(["git", "describe", "--abbrev=0", "--tags"], encoding="UTF-8") last_version = stdout.strip() + rev_range = f"{last_version}..HEAD" - stdout = check_output( - ["git", "log", f"{last_version}..HEAD", "--format=%aN"], encoding="UTF-8" + authors = check_output( + ["git", "log", rev_range, "--format=%aN"], encoding="UTF-8" + ).splitlines() + + co_authors_output = check_output( + ["git", "log", rev_range, "--format=%(trailers:key=Co-authored-by) "], + encoding="UTF-8", ) + co_authors: list[str] = [] + for co_author_line in co_authors_output.splitlines(): + if m := re.search(r"Co-authored-by: (.+?)<", co_author_line): + co_authors.append(m.group(1).strip()) contributors = { name - for name in stdout.splitlines() + for name in authors + co_authors if not name.endswith("[bot]") and name != "pytest bot" } From 3905a74b09ab4faded2a0aff7c4147fbb5b1a1e7 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 10 Sep 2024 07:53:09 -0300 Subject: [PATCH 064/445] Merge pull request #12798 from pytest-dev/release-8.3.3 Prepare release 8.3.3 (cherry picked from commit 03d8fb79aa3731f8c46f582bde8d590dbb278aba) --- changelog/12446.bugfix.rst | 1 - changelog/12659.bugfix.rst | 1 - changelog/12663.doc.rst | 1 - changelog/12667.bugfix.rst | 1 - changelog/12678.doc.rst | 1 - changelog/12744.bugfix.rst | 1 - changelog/12745.bugfix.rst | 1 - changelog/12769.misc.rst | 1 - changelog/6682.bugfix.rst | 1 - changelog/9422.bugfix.rst | 3 -- doc/en/announce/index.rst | 1 + doc/en/announce/release-8.3.3.rst | 31 +++++++++++++++++++ doc/en/builtin.rst | 18 +++++------ doc/en/changelog.rst | 46 +++++++++++++++++++++++++++++ doc/en/example/parametrize.rst | 6 ++-- doc/en/example/pythoncollection.rst | 4 +-- doc/en/getting-started.rst | 2 +- doc/en/how-to/fixtures.rst | 2 +- 18 files changed, 94 insertions(+), 28 deletions(-) delete mode 100644 changelog/12446.bugfix.rst delete mode 100644 changelog/12659.bugfix.rst delete mode 100644 changelog/12663.doc.rst delete mode 100644 changelog/12667.bugfix.rst delete mode 100644 changelog/12678.doc.rst delete mode 100644 changelog/12744.bugfix.rst delete mode 100644 changelog/12745.bugfix.rst delete mode 100644 changelog/12769.misc.rst delete mode 100644 changelog/6682.bugfix.rst delete mode 100644 changelog/9422.bugfix.rst create mode 100644 doc/en/announce/release-8.3.3.rst diff --git a/changelog/12446.bugfix.rst b/changelog/12446.bugfix.rst deleted file mode 100644 index 2f591c48eed..00000000000 --- a/changelog/12446.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Avoid calling ``@property`` (and other instance descriptors) during fixture discovery -- by :user:`asottile` diff --git a/changelog/12659.bugfix.rst b/changelog/12659.bugfix.rst deleted file mode 100644 index 297381b9602..00000000000 --- a/changelog/12659.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed the issue of not displaying assertion failure differences when using the parameter ``--import-mode=importlib`` in pytest>=8.1. diff --git a/changelog/12663.doc.rst b/changelog/12663.doc.rst deleted file mode 100644 index e665bc67a10..00000000000 --- a/changelog/12663.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Clarify that the `pytest_deselected` hook should be called from `pytest_collection_modifyitems` hook implementations when items are deselected. diff --git a/changelog/12667.bugfix.rst b/changelog/12667.bugfix.rst deleted file mode 100644 index eceee86cb53..00000000000 --- a/changelog/12667.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed a regression where type change in `ExceptionInfo.errisinstance` caused `mypy` to fail. diff --git a/changelog/12678.doc.rst b/changelog/12678.doc.rst deleted file mode 100644 index 9d79ec41007..00000000000 --- a/changelog/12678.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Remove erroneous quotes from `tmp_path_retention_policy` example in docs. diff --git a/changelog/12744.bugfix.rst b/changelog/12744.bugfix.rst deleted file mode 100644 index 7814b59c180..00000000000 --- a/changelog/12744.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed typing compatibility with Python 3.9 or less -- replaced `typing.Self` with `typing_extensions.Self` -- by :user:`Avasam` diff --git a/changelog/12745.bugfix.rst b/changelog/12745.bugfix.rst deleted file mode 100644 index 420be931ce9..00000000000 --- a/changelog/12745.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed an issue with backslashes being incorrectly converted in nodeid paths on Windows, ensuring consistent path handling across environments. diff --git a/changelog/12769.misc.rst b/changelog/12769.misc.rst deleted file mode 100644 index aae4d137a0d..00000000000 --- a/changelog/12769.misc.rst +++ /dev/null @@ -1 +0,0 @@ -Fix typos discovered by codespell and add codespell to pre-commit hooks. diff --git a/changelog/6682.bugfix.rst b/changelog/6682.bugfix.rst deleted file mode 100644 index 7f756cbd9c2..00000000000 --- a/changelog/6682.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed bug where the verbosity levels where not being respected when printing the "msg" part of failed assertion (as in ``assert condition, msg``). diff --git a/changelog/9422.bugfix.rst b/changelog/9422.bugfix.rst deleted file mode 100644 index 38196340fd5..00000000000 --- a/changelog/9422.bugfix.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fix bug where disabling the terminal plugin via ``-p no:terminal`` would cause crashes related to missing the ``verbose`` option. - --- by :user:`GTowers1` diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index 09311a1a1ab..61e4a772beb 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-8.3.3 release-8.3.2 release-8.3.1 release-8.3.0 diff --git a/doc/en/announce/release-8.3.3.rst b/doc/en/announce/release-8.3.3.rst new file mode 100644 index 00000000000..5e3eb36b921 --- /dev/null +++ b/doc/en/announce/release-8.3.3.rst @@ -0,0 +1,31 @@ +pytest-8.3.3 +======================================= + +pytest 8.3.3 has just been released to PyPI. + +This is a bug-fix release, being a drop-in replacement. To upgrade:: + + pip install --upgrade pytest + +The full changelog is available at https://docs.pytest.org/en/stable/changelog.html. + +Thanks to all of the contributors to this release: + +* Anthony Sottile +* Avasam +* Bruno Oliveira +* Christian Clauss +* Eugene Mwangi +* Florian Bruhin +* GTowers1 +* Nauman Ahmed +* Pierre Sassoulas +* Reagan Lee +* Ronny Pfannschmidt +* Stefaan Lippens +* Sviatoslav Sydorenko (Святослав Сидоренко) +* dongfangtianyu + + +Happy testing, +The pytest Development Team diff --git a/doc/en/builtin.rst b/doc/en/builtin.rst index b4c0f91f8e5..9b406a6a512 100644 --- a/doc/en/builtin.rst +++ b/doc/en/builtin.rst @@ -22,7 +22,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a cachedir: .pytest_cache rootdir: /home/sweet/project collected 0 items - cache -- .../_pytest/cacheprovider.py:558 + cache -- .../_pytest/cacheprovider.py:556 Return a cache object that can persist state between testing sessions. cache.get(key, default) @@ -33,7 +33,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a Values can be any object handled by the json stdlib module. - capsysbinary -- .../_pytest/capture.py:1005 + capsysbinary -- .../_pytest/capture.py:1006 Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``. The captured output is made available via ``capsysbinary.readouterr()`` @@ -51,7 +51,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capsysbinary.readouterr() assert captured.out == b"hello\n" - capfd -- .../_pytest/capture.py:1033 + capfd -- .../_pytest/capture.py:1034 Enable text capturing of writes to file descriptors ``1`` and ``2``. The captured output is made available via ``capfd.readouterr()`` method @@ -69,7 +69,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capfd.readouterr() assert captured.out == "hello\n" - capfdbinary -- .../_pytest/capture.py:1061 + capfdbinary -- .../_pytest/capture.py:1062 Enable bytes capturing of writes to file descriptors ``1`` and ``2``. The captured output is made available via ``capfd.readouterr()`` method @@ -87,7 +87,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capfdbinary.readouterr() assert captured.out == b"hello\n" - capsys -- .../_pytest/capture.py:977 + capsys -- .../_pytest/capture.py:978 Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``. The captured output is made available via ``capsys.readouterr()`` method @@ -105,7 +105,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capsys.readouterr() assert captured.out == "hello\n" - doctest_namespace [session scope] -- .../_pytest/doctest.py:740 + doctest_namespace [session scope] -- .../_pytest/doctest.py:741 Fixture that returns a :py:class:`dict` that will be injected into the namespace of doctests. @@ -119,14 +119,14 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a For more details: :ref:`doctest_namespace`. - pytestconfig [session scope] -- .../_pytest/fixtures.py:1344 + pytestconfig [session scope] -- .../_pytest/fixtures.py:1345 Session-scoped fixture that returns the session's :class:`pytest.Config` object. Example:: def test_foo(pytestconfig): - if pytestconfig.getoption("verbose") > 0: + if pytestconfig.get_verbosity() > 0: ... record_property -- .../_pytest/junitxml.py:280 @@ -196,7 +196,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a .. _legacy_path: https://py.readthedocs.io/en/latest/path.html - caplog -- .../_pytest/logging.py:600 + caplog -- .../_pytest/logging.py:598 Access and control log capturing. Captured logs are available through the following properties/methods:: diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index 9da6f487f8d..9f30c86be3a 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -31,6 +31,52 @@ with advance notice in the **Deprecations** section of releases. .. towncrier release notes start +pytest 8.3.3 (2024-09-09) +========================= + +Bug fixes +--------- + +- `#12446 `_: Avoid calling ``@property`` (and other instance descriptors) during fixture discovery -- by :user:`asottile` + + +- `#12659 `_: Fixed the issue of not displaying assertion failure differences when using the parameter ``--import-mode=importlib`` in pytest>=8.1. + + +- `#12667 `_: Fixed a regression where type change in `ExceptionInfo.errisinstance` caused `mypy` to fail. + + +- `#12744 `_: Fixed typing compatibility with Python 3.9 or less -- replaced `typing.Self` with `typing_extensions.Self` -- by :user:`Avasam` + + +- `#12745 `_: Fixed an issue with backslashes being incorrectly converted in nodeid paths on Windows, ensuring consistent path handling across environments. + + +- `#6682 `_: Fixed bug where the verbosity levels where not being respected when printing the "msg" part of failed assertion (as in ``assert condition, msg``). + + +- `#9422 `_: Fix bug where disabling the terminal plugin via ``-p no:terminal`` would cause crashes related to missing the ``verbose`` option. + + -- by :user:`GTowers1` + + + +Improved documentation +---------------------- + +- `#12663 `_: Clarify that the `pytest_deselected` hook should be called from `pytest_collection_modifyitems` hook implementations when items are deselected. + + +- `#12678 `_: Remove erroneous quotes from `tmp_path_retention_policy` example in docs. + + + +Miscellaneous internal changes +------------------------------ + +- `#12769 `_: Fix typos discovered by codespell and add codespell to pre-commit hooks. + + pytest 8.3.2 (2024-07-24) ========================= diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index b175510da6a..fa43308d045 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -162,7 +162,7 @@ objects, they are still using the default pytest representation: rootdir: /home/sweet/project collected 8 items - + @@ -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 - + @@ -318,7 +318,7 @@ Let's first see how it looks like at collection time: rootdir: /home/sweet/project collected 2 items - + diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 5bd03035c14..42a603f114c 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -152,7 +152,7 @@ The test collection would look like this: configfile: pytest.ini collected 2 items - + @@ -215,7 +215,7 @@ You can always peek at the collection tree without running tests like this: configfile: pytest.ini collected 3 items - + diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 050fd2d80ec..faf81154c48 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -22,7 +22,7 @@ Install ``pytest`` .. code-block:: bash $ pytest --version - pytest 8.3.2 + pytest 8.3.3 .. _`simpletest`: diff --git a/doc/en/how-to/fixtures.rst b/doc/en/how-to/fixtures.rst index d60635c4fea..4f6e8cbee06 100644 --- a/doc/en/how-to/fixtures.rst +++ b/doc/en/how-to/fixtures.rst @@ -1418,7 +1418,7 @@ Running the above tests results in the following test IDs being used: rootdir: /home/sweet/project collected 12 items - + From 222457d7d9898681bc3e035e8a65133503d13e04 Mon Sep 17 00:00:00 2001 From: sven <42868792+FreerGit@users.noreply.github.com> Date: Thu, 12 Sep 2024 19:33:16 +0200 Subject: [PATCH 065/445] Add `discover_imports` in conf - Allows a user to define whether or not pytest should treat imported (but not in testpaths) as test classes. - Imagine a class is called TestFoo defined in src/ dir, when discover_imports is disabled, TestFoo is not treated as a test class. --- AUTHORS | 1 + changelog/12749.feature.rst | 3 ++ src/_pytest/main.py | 5 ++ src/_pytest/python.py | 6 +++ testing/test_discover_imports.py | 88 ++++++++++++++++++++++++++++++++ 5 files changed, 103 insertions(+) create mode 100644 changelog/12749.feature.rst create mode 100644 testing/test_discover_imports.py diff --git a/AUTHORS b/AUTHORS index 374e6ad9bcc..b1dd40dbd4c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -400,6 +400,7 @@ Stefanie Molin Stefano Taschini Steffen Allner Stephan Obermann +Sven Sven-Hendrik Haase Sviatoslav Sydorenko Sylvain Marié diff --git a/changelog/12749.feature.rst b/changelog/12749.feature.rst new file mode 100644 index 00000000000..138a5bc7914 --- /dev/null +++ b/changelog/12749.feature.rst @@ -0,0 +1,3 @@ +Add :confval:`discover_imports`, when disabled (default) will make sure to not consider classes which are imported by a test file and starts with Test. + +-- by :user:`FreerGit` \ No newline at end of file diff --git a/src/_pytest/main.py b/src/_pytest/main.py index e5534e98d69..4887d336b2d 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -78,6 +78,11 @@ def pytest_addoption(parser: Parser) -> None: type="args", default=[], ) + parser.addini( + "discover_imports", + "Whether to discover tests in imported modules outside `testpaths`", + default=False, + ) group = parser.getgroup("general", "Running and selection options") group._addoption( "-x", diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 9c54dd20f80..9467b26fd02 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -741,6 +741,12 @@ def newinstance(self): return self.obj() def collect(self) -> Iterable[nodes.Item | nodes.Collector]: + if self.config.getini("discover_imports") == ("false" or False): + paths = self.config.getini("testpaths") + class_file = inspect.getfile(self.obj) + if not any(string in class_file for string in paths): + return [] + if not safe_getattr(self.obj, "__test__", True): return [] if hasinit(self.obj): diff --git a/testing/test_discover_imports.py b/testing/test_discover_imports.py new file mode 100644 index 00000000000..829b614ed46 --- /dev/null +++ b/testing/test_discover_imports.py @@ -0,0 +1,88 @@ +import pytest +import textwrap + +def test_discover_imports_enabled(pytester): + src_dir = pytester.mkdir("src") + tests_dir = pytester.mkdir("tests") + pytester.makeini(""" + [pytest] + testpaths = "tests" + discover_imports = true + """) + + src_file = src_dir / "foo.py" + + src_file.write_text(textwrap.dedent("""\ + class TestClass(object): + def __init__(self): + super().__init__() + + def test_foobar(self): + return true + """ + ), encoding="utf-8") + + test_file = tests_dir / "foo_test.py" + test_file.write_text(textwrap.dedent("""\ + import sys + import os + + current_file = os.path.abspath(__file__) + current_dir = os.path.dirname(current_file) + parent_dir = os.path.abspath(os.path.join(current_dir, '..')) + sys.path.append(parent_dir) + + from src.foo import TestClass + + class TestDomain: + def test_testament(self): + testament = TestClass() + pass + """), encoding="utf-8") + + result = pytester.runpytest() + result.assert_outcomes(errors=1) + +def test_discover_imports_disabled(pytester): + + src_dir = pytester.mkdir("src") + tests_dir = pytester.mkdir("tests") + pytester.makeini(""" + [pytest] + testpaths = "tests" + discover_imports = false + """) + + src_file = src_dir / "foo.py" + + src_file.write_text(textwrap.dedent("""\ + class Testament(object): + def __init__(self): + super().__init__() + self.collections = ["stamp", "coin"] + + def personal_property(self): + return [f"my {x} collection" for x in self.collections] + """ + ), encoding="utf-8") + + test_file = tests_dir / "foo_test.py" + test_file.write_text(textwrap.dedent("""\ + import sys + import os + + current_file = os.path.abspath(__file__) + current_dir = os.path.dirname(current_file) + parent_dir = os.path.abspath(os.path.join(current_dir, '..')) + sys.path.append(parent_dir) + + from src.foo import Testament + + class TestDomain: + def test_testament(self): + testament = Testament() + assert testament.personal_property() + """), encoding="utf-8") + + result = pytester.runpytest() + result.assert_outcomes(passed=1) \ No newline at end of file From fa3b6310c8202e820cd0195960d14d10a1f99303 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:38:20 +0000 Subject: [PATCH 066/445] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- changelog/12749.feature.rst | 2 +- testing/test_discover_imports.py | 38 +++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/changelog/12749.feature.rst b/changelog/12749.feature.rst index 138a5bc7914..a6fb8bf9e62 100644 --- a/changelog/12749.feature.rst +++ b/changelog/12749.feature.rst @@ -1,3 +1,3 @@ Add :confval:`discover_imports`, when disabled (default) will make sure to not consider classes which are imported by a test file and starts with Test. --- by :user:`FreerGit` \ No newline at end of file +-- by :user:`FreerGit` diff --git a/testing/test_discover_imports.py b/testing/test_discover_imports.py index 829b614ed46..cdb55916ba6 100644 --- a/testing/test_discover_imports.py +++ b/testing/test_discover_imports.py @@ -1,6 +1,8 @@ -import pytest +from __future__ import annotations + import textwrap + def test_discover_imports_enabled(pytester): src_dir = pytester.mkdir("src") tests_dir = pytester.mkdir("tests") @@ -12,18 +14,21 @@ def test_discover_imports_enabled(pytester): src_file = src_dir / "foo.py" - src_file.write_text(textwrap.dedent("""\ + src_file.write_text( + textwrap.dedent("""\ class TestClass(object): def __init__(self): super().__init__() def test_foobar(self): return true - """ - ), encoding="utf-8") + """), + encoding="utf-8", + ) test_file = tests_dir / "foo_test.py" - test_file.write_text(textwrap.dedent("""\ + test_file.write_text( + textwrap.dedent("""\ import sys import os @@ -38,13 +43,15 @@ class TestDomain: def test_testament(self): testament = TestClass() pass - """), encoding="utf-8") + """), + encoding="utf-8", + ) result = pytester.runpytest() result.assert_outcomes(errors=1) + def test_discover_imports_disabled(pytester): - src_dir = pytester.mkdir("src") tests_dir = pytester.mkdir("tests") pytester.makeini(""" @@ -55,7 +62,8 @@ def test_discover_imports_disabled(pytester): src_file = src_dir / "foo.py" - src_file.write_text(textwrap.dedent("""\ + src_file.write_text( + textwrap.dedent("""\ class Testament(object): def __init__(self): super().__init__() @@ -63,11 +71,13 @@ def __init__(self): def personal_property(self): return [f"my {x} collection" for x in self.collections] - """ - ), encoding="utf-8") + """), + encoding="utf-8", + ) test_file = tests_dir / "foo_test.py" - test_file.write_text(textwrap.dedent("""\ + test_file.write_text( + textwrap.dedent("""\ import sys import os @@ -82,7 +92,9 @@ class TestDomain: def test_testament(self): testament = Testament() assert testament.personal_property() - """), encoding="utf-8") + """), + encoding="utf-8", + ) result = pytester.runpytest() - result.assert_outcomes(passed=1) \ No newline at end of file + result.assert_outcomes(passed=1) From 26cb6ccebdbfb5e505407917ee8db53a2a47c5c6 Mon Sep 17 00:00:00 2001 From: pytest bot Date: Sun, 15 Sep 2024 00:25:17 +0000 Subject: [PATCH 067/445] [automated] Update plugin list --- doc/en/reference/plugin_list.rst | 150 +++++++++++++++++-------------- 1 file changed, 83 insertions(+), 67 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index ffca5c08380..23e95e27730 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =7 :pypi:`pytest-abq` Pytest integration for the ABQ universal test runner. Apr 07, 2023 N/A N/A :pypi:`pytest-abstracts` A contextmanager pytest fixture for handling multiple mock abstracts May 25, 2022 N/A N/A - :pypi:`pytest-accept` A pytest-plugin for updating doctest outputs Feb 10, 2024 N/A pytest (>=6) + :pypi:`pytest-accept` A pytest-plugin for updating doctest outputs Sep 09, 2024 N/A pytest>=7 :pypi:`pytest-adaptavist` pytest plugin for generating test execution results within Jira Test Management (tm4j) Oct 13, 2022 N/A pytest (>=5.4.0) :pypi:`pytest-adaptavist-fixed` pytest plugin for generating test execution results within Jira Test Management (tm4j) Nov 08, 2023 N/A pytest >=5.4.0 :pypi:`pytest-addons-test` 用于测试pytest的插件 Aug 02, 2021 N/A pytest (>=6.2.4,<7.0.0) @@ -74,7 +74,7 @@ This list contains 1513 plugins. :pypi:`pytest-android` This fixture provides a configured "driver" for Android Automated Testing, using uiautomator2. Feb 21, 2019 3 - Alpha pytest :pypi:`pytest-anki` A pytest plugin for testing Anki add-ons Jul 31, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-annotate` pytest-annotate: Generate PyAnnotate annotations from your pytest tests. Jun 07, 2022 3 - Alpha pytest (<8.0.0,>=3.2.0) - :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures Aug 16, 2024 5 - Production/Stable pytest>=6 + :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures Sep 11, 2024 5 - Production/Stable pytest>=6 :pypi:`pytest-ansible-playbook` Pytest fixture which runs given ansible playbook file. Mar 08, 2019 4 - Beta N/A :pypi:`pytest-ansible-playbook-runner` Pytest fixture which runs given ansible playbook file. Dec 02, 2020 4 - Beta pytest (>=3.1.0) :pypi:`pytest-ansible-units` A pytest plugin for running unit tests within an ansible collection Apr 14, 2022 N/A N/A @@ -154,7 +154,7 @@ This list contains 1513 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Aug 08, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Sep 05, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Sep 13, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -175,6 +175,7 @@ This list contains 1513 plugins. :pypi:`pytest-blocker` pytest plugin to mark a test as blocker and skip all other tests Sep 07, 2015 4 - Beta N/A :pypi:`pytest-blue` A pytest plugin that adds a \`blue\` fixture for printing stuff in blue. Sep 05, 2022 N/A N/A :pypi:`pytest-board` Local continuous test runner with pytest and watchdog. Jan 20, 2019 N/A N/A + :pypi:`pytest-boilerplate` The pytest plugin for your Django Boilerplate. Sep 12, 2024 5 - Production/Stable pytest>=4.0.0 :pypi:`pytest-boost-xml` Plugin for pytest to generate boost xml reports Nov 30, 2022 4 - Beta N/A :pypi:`pytest-bootstrap` Mar 04, 2022 N/A N/A :pypi:`pytest-boto-mock` Thin-wrapper around the mock package for easier use with pytest Jul 16, 2024 5 - Production/Stable pytest>=8.2.0 @@ -242,7 +243,7 @@ This list contains 1513 plugins. :pypi:`pytest-cldf` Easy quality control for CLDF datasets using pytest Nov 07, 2022 N/A pytest (>=3.6) :pypi:`pytest-cleanslate` Collects and executes pytest tests separately Sep 04, 2024 N/A pytest :pypi:`pytest_cleanup` Automated, comprehensive and well-organised pytest test cases. Jan 28, 2020 N/A N/A - :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Aug 26, 2024 5 - Production/Stable N/A + :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Sep 14, 2024 5 - Production/Stable N/A :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Aug 15, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-click` Pytest plugin for Click Feb 11, 2022 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-cli-fixtures` Automatically register fixtures for custom CLI arguments Jul 28, 2022 N/A pytest (~=7.0) @@ -317,7 +318,7 @@ This list contains 1513 plugins. :pypi:`pytest-dash` pytest fixtures to run dash applications. Mar 18, 2019 N/A N/A :pypi:`pytest-dashboard` May 30, 2024 N/A pytest<8.0.0,>=7.4.3 :pypi:`pytest-data` Useful functions for managing data for pytest fixtures Nov 01, 2016 5 - Production/Stable N/A - :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Aug 20, 2024 4 - Beta pytest + :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Sep 07, 2024 4 - Beta pytest :pypi:`pytest-databricks` Pytest plugin for remote Databricks notebooks testing Jul 29, 2020 N/A pytest :pypi:`pytest-datadir` pytest plugin for test data directories and files Oct 03, 2023 5 - Production/Stable pytest >=5.0 :pypi:`pytest-datadir-mgr` Manager for test data: downloads, artifact caching, and a tmpdir context. Apr 06, 2023 5 - Production/Stable pytest (>=7.1) @@ -440,7 +441,7 @@ This list contains 1513 plugins. :pypi:`pytest-dummynet` A py.test plugin providing access to a dummynet. Dec 15, 2021 5 - Production/Stable pytest :pypi:`pytest-dump2json` A pytest plugin for dumping test results to json. Jun 29, 2015 N/A N/A :pypi:`pytest-duration-insights` Jul 15, 2024 N/A N/A - :pypi:`pytest-durations` Pytest plugin reporting fixtures and test functions execution time. Apr 22, 2022 5 - Production/Stable pytest (>=4.6) + :pypi:`pytest-durations` Pytest plugin reporting fixtures and test functions execution time. Sep 11, 2024 5 - Production/Stable pytest>=4.6 :pypi:`pytest-dynamicrerun` A pytest plugin to rerun tests dynamically based off of test outcome and output. Aug 15, 2020 4 - Beta N/A :pypi:`pytest-dynamodb` DynamoDB fixtures for pytest Mar 12, 2024 5 - Production/Stable pytest :pypi:`pytest-easy-addoption` pytest-easy-addoption: Easy way to work with pytest addoption Jan 22, 2020 N/A N/A @@ -470,14 +471,14 @@ This list contains 1513 plugins. :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) - :pypi:`pytest-enabler` Enable installed pytest plugins Aug 29, 2024 5 - Production/Stable pytest!=8.1.*,>=6; extra == "test" + :pypi:`pytest-enabler` Enable installed pytest plugins Sep 12, 2024 5 - Production/Stable pytest!=8.1.*,>=6; extra == "test" :pypi:`pytest-encode` set your encoding and logger Nov 06, 2021 N/A N/A :pypi:`pytest-encode-kane` set your encoding and logger Nov 16, 2021 N/A pytest :pypi:`pytest-encoding` set your encoding and logger Aug 11, 2023 N/A pytest :pypi:`pytest_energy_reporter` An energy estimation reporter for pytest Mar 28, 2024 3 - Alpha pytest<9.0.0,>=8.1.1 :pypi:`pytest-enhanced-reports` Enhanced test reports for pytest Dec 15, 2022 N/A N/A :pypi:`pytest-enhancements` Improvements for pytest (rejected upstream) Oct 30, 2019 4 - Beta N/A - :pypi:`pytest-env` pytest plugin that allows you to add environment variables. Nov 28, 2023 5 - Production/Stable pytest>=7.4.3 + :pypi:`pytest-env` pytest plugin that allows you to add environment variables. Sep 07, 2024 5 - Production/Stable pytest>=8.3.2 :pypi:`pytest-envfiles` A py.test plugin that parses environment files before running tests Oct 08, 2015 3 - Alpha N/A :pypi:`pytest-env-info` Push information about the running pytest into envvars Nov 25, 2017 4 - Beta pytest (>=3.1.1) :pypi:`pytest-environment` Pytest Environment Mar 17, 2024 1 - Planning N/A @@ -593,7 +594,7 @@ This list contains 1513 plugins. :pypi:`pytest-frozen-uuids` Deterministically frozen UUID's for your tests Apr 17, 2022 N/A pytest (>=3.0) :pypi:`pytest-func-cov` Pytest plugin for measuring function coverage Apr 15, 2021 3 - Alpha pytest (>=5) :pypi:`pytest-funparam` An alternative way to parametrize test cases. Dec 02, 2021 4 - Beta pytest >=4.6.0 - :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Sep 06, 2024 N/A pytest + :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Sep 11, 2024 N/A pytest :pypi:`pytest-fxa` pytest plugin for Firefox Accounts Aug 28, 2018 5 - Production/Stable N/A :pypi:`pytest-fxtest` Oct 27, 2020 N/A N/A :pypi:`pytest-fzf` fzf-based test selector for pytest Jul 03, 2024 4 - Beta pytest>=6.0.0 @@ -619,7 +620,7 @@ This list contains 1513 plugins. :pypi:`pytest-gitignore` py.test plugin to ignore the same files as git Jul 17, 2015 4 - Beta N/A :pypi:`pytest-gitlab` Pytest Plugin for Gitlab Sep 06, 2024 N/A N/A :pypi:`pytest-gitlabci-parallelized` Parallelize pytest across GitLab CI workers. Mar 08, 2023 N/A N/A - :pypi:`pytest-gitlab-code-quality` Collects warnings while testing and generates a GitLab Code Quality Report. Apr 03, 2024 N/A pytest>=8.1.1 + :pypi:`pytest-gitlab-code-quality` Collects warnings while testing and generates a GitLab Code Quality Report. Sep 09, 2024 N/A pytest>=8.1.1 :pypi:`pytest-gitlab-fold` Folds output sections in GitLab CI build log Dec 31, 2023 4 - Beta pytest >=2.6.0 :pypi:`pytest-git-selector` Utility to select tests that have had its dependencies modified (as identified by git diff) Nov 17, 2022 N/A N/A :pypi:`pytest-glamor-allure` Extends allure-pytest functionality Apr 30, 2024 4 - Beta pytest<=8.2.0 @@ -761,7 +762,7 @@ This list contains 1513 plugins. :pypi:`pytest-kivy` Kivy GUI tests fixtures using pytest Jul 06, 2021 4 - Beta pytest (>=3.6) :pypi:`pytest-knows` A pytest plugin that can automaticly skip test case based on dependence info calculated by trace Aug 22, 2014 N/A N/A :pypi:`pytest-konira` Run Konira DSL tests with py.test Oct 09, 2011 N/A N/A - :pypi:`pytest-kookit` Your simple but kooky integration testing with pytest May 16, 2024 N/A N/A + :pypi:`pytest-kookit` Your simple but kooky integration testing with pytest Sep 10, 2024 N/A N/A :pypi:`pytest-koopmans` A plugin for testing the koopmans package Nov 21, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-krtech-common` pytest krtech common library Nov 28, 2016 4 - Beta N/A :pypi:`pytest-kubernetes` Sep 14, 2023 N/A pytest (>=7.2.1,<8.0.0) @@ -852,7 +853,7 @@ This list contains 1513 plugins. :pypi:`pytest-minio-mock` A pytest plugin for mocking Minio S3 interactions Aug 27, 2024 N/A pytest>=5.0.0 :pypi:`pytest-missing-fixtures` Pytest plugin that creates missing fixtures Oct 14, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-missing-modules` Pytest plugin to easily fake missing modules Sep 03, 2024 N/A pytest>=8.3.2 - :pypi:`pytest-mitmproxy` pytest plugin for mitmproxy tests May 28, 2024 N/A pytest>=7.0 + :pypi:`pytest-mitmproxy` pytest plugin for mitmproxy tests Sep 12, 2024 N/A pytest>=7.0 :pypi:`pytest-ml` Test your machine learning! May 04, 2019 4 - Beta N/A :pypi:`pytest-mocha` pytest plugin to display test execution output like a mochajs Apr 02, 2020 4 - Beta pytest (>=5.4.0) :pypi:`pytest-mock` Thin-wrapper around the mock package for easier use with pytest Mar 21, 2024 5 - Production/Stable pytest>=6.2.5 @@ -899,7 +900,7 @@ This list contains 1513 plugins. :pypi:`pytest-ndb` pytest notebook debugger Apr 28, 2024 N/A pytest :pypi:`pytest-needle` pytest plugin for visual testing websites using selenium Dec 10, 2018 4 - Beta pytest (<5.0.0,>=3.0.0) :pypi:`pytest-neo` pytest-neo is a plugin for pytest that shows tests like screen of Matrix. Jan 08, 2022 3 - Alpha pytest (>=6.2.0) - :pypi:`pytest-neos` Pytest plugin for neos Jun 11, 2024 1 - Planning N/A + :pypi:`pytest-neos` Pytest plugin for neos Sep 10, 2024 5 - Production/Stable pytest<8.0,>=7.2; extra == "dev" :pypi:`pytest-netconf` A pytest plugin that provides a mock NETCONF (RFC6241/RFC6242) server for local testing. Aug 08, 2024 N/A N/A :pypi:`pytest-netdut` "Automated software testing for switches using pytest" Jul 05, 2024 N/A pytest<7.3,>=3.5.0 :pypi:`pytest-network` A simple plugin to disable network on socket level. May 07, 2020 N/A N/A @@ -909,7 +910,7 @@ This list contains 1513 plugins. :pypi:`pytest-nginx-iplweb` nginx fixture for pytest - iplweb temporary fork Mar 01, 2019 5 - Production/Stable N/A :pypi:`pytest-ngrok` Jan 20, 2022 3 - Alpha pytest :pypi:`pytest-ngsfixtures` pytest ngs fixtures Sep 06, 2019 2 - Pre-Alpha pytest (>=5.0.0) - :pypi:`pytest-nhsd-apim` Pytest plugin accessing NHSDigital's APIM proxies Jul 01, 2024 N/A pytest<9.0.0,>=8.2.0 + :pypi:`pytest-nhsd-apim` Pytest plugin accessing NHSDigital's APIM proxies Sep 06, 2024 N/A pytest<9.0.0,>=8.2.0 :pypi:`pytest-nice` A pytest plugin that alerts user of failed test cases with screen notifications May 04, 2019 4 - Beta pytest :pypi:`pytest-nice-parametrize` A small snippet for nicer PyTest's Parametrize Apr 17, 2021 5 - Production/Stable N/A :pypi:`pytest_nlcov` Pytest plugin to get the coverage of the new lines (based on git diff) only Aug 05, 2024 N/A N/A @@ -1002,7 +1003,7 @@ This list contains 1513 plugins. :pypi:`pytest-platform-markers` Markers for pytest to skip tests on specific platforms Sep 09, 2019 4 - Beta pytest (>=3.6.0) :pypi:`pytest-play` pytest plugin that let you automate actions and assertions with test metrics reporting executing plain YAML files Jun 12, 2019 5 - Production/Stable N/A :pypi:`pytest-playbook` Pytest plugin for reading playbooks. Jan 21, 2021 3 - Alpha pytest (>=6.1.2,<7.0.0) - :pypi:`pytest-playwright` A pytest wrapper with fixtures for Playwright to automate web browsers Jul 03, 2024 N/A N/A + :pypi:`pytest-playwright` A pytest wrapper with fixtures for Playwright to automate web browsers Sep 06, 2024 N/A pytest<9.0.0,>=6.2.4 :pypi:`pytest_playwright_async` ASYNC Pytest plugin for Playwright May 24, 2024 N/A N/A :pypi:`pytest-playwright-asyncio` Aug 29, 2023 N/A N/A :pypi:`pytest-playwright-enhanced` A pytest plugin for playwright python Mar 24, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1014,7 +1015,7 @@ This list contains 1513 plugins. :pypi:`pytest-plugin-helpers` A plugin to help developing and testing other plugins Nov 23, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-plus` PyTest Plus Plugin :: extends pytest functionality Mar 26, 2024 5 - Production/Stable pytest>=7.4.2 :pypi:`pytest-pmisc` Mar 21, 2019 5 - Production/Stable N/A - :pypi:`pytest-pogo` Pytest plugin for pogo-migrate May 22, 2024 1 - Planning pytest<9,>=7 + :pypi:`pytest-pogo` Pytest plugin for pogo-migrate Sep 09, 2024 4 - Beta pytest<9,>=7 :pypi:`pytest-pointers` Pytest plugin to define functions you test with special marks for better navigation and reports Dec 26, 2022 N/A N/A :pypi:`pytest-pokie` Pokie plugin for pytest Oct 19, 2023 5 - Production/Stable N/A :pypi:`pytest-polarion-cfme` pytest plugin for collecting test cases and recording test results Nov 13, 2017 3 - Alpha N/A @@ -1034,7 +1035,7 @@ This list contains 1513 plugins. :pypi:`pytest-pretty` pytest plugin for printing summary data as I want it Apr 05, 2023 5 - Production/Stable pytest>=7 :pypi:`pytest-pretty-terminal` pytest plugin for generating prettier terminal output Jan 31, 2022 N/A pytest (>=3.4.1) :pypi:`pytest-pride` Minitest-style test colors Apr 02, 2016 3 - Alpha N/A - :pypi:`pytest-print` pytest-print adds the printer fixture you can use to print messages to the user (directly to the pytest runner, not stdout) Aug 25, 2023 5 - Production/Stable pytest>=7.4 + :pypi:`pytest-print` pytest-print adds the printer fixture you can use to print messages to the user (directly to the pytest runner, not stdout) Sep 08, 2024 5 - Production/Stable pytest>=8.3.2 :pypi:`pytest-priority` pytest plugin for add priority for tests Aug 19, 2024 N/A pytest :pypi:`pytest-proceed` Apr 10, 2024 N/A pytest :pypi:`pytest-profiles` pytest plugin for configuration profiles Dec 09, 2021 4 - Beta pytest (>=3.7.0) @@ -1141,7 +1142,7 @@ This list contains 1513 plugins. :pypi:`pytest-reportlog` Replacement for the --resultlog option, focused in simplicity and extensibility May 22, 2023 3 - Alpha pytest :pypi:`pytest-report-me` A pytest plugin to generate report. Dec 31, 2020 N/A pytest :pypi:`pytest-report-parameters` pytest plugin for adding tests' parameters to junit report Jun 18, 2020 3 - Alpha pytest (>=2.4.2) - :pypi:`pytest-reportportal` Agent for Reporting results of tests to the Report Portal Mar 27, 2024 N/A pytest>=3.8.0 + :pypi:`pytest-reportportal` Agent for Reporting results of tests to the Report Portal Sep 06, 2024 N/A pytest>=3.8.0 :pypi:`pytest-report-stream` A pytest plugin which allows to stream test reports at runtime Oct 22, 2023 4 - Beta N/A :pypi:`pytest-repo-structure` Pytest Repo Structure Mar 18, 2024 1 - Planning N/A :pypi:`pytest-req` pytest requests plugin Aug 31, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.2 @@ -1181,7 +1182,7 @@ This list contains 1513 plugins. :pypi:`pytest-rmsis` Sycronise pytest results to Jira RMsis Aug 10, 2022 N/A pytest (>=5.3.5) :pypi:`pytest-rng` Fixtures for seeding tests and making randomness reproducible Aug 08, 2019 5 - Production/Stable pytest :pypi:`pytest-roast` pytest plugin for ROAST configuration override and fixtures Nov 09, 2022 5 - Production/Stable pytest - :pypi:`pytest_robotframework` a pytest plugin that can run both python and robotframework tests while generating robot reports for them Aug 21, 2024 N/A pytest<9,>=7 + :pypi:`pytest_robotframework` a pytest plugin that can run both python and robotframework tests while generating robot reports for them Sep 10, 2024 N/A pytest<9,>=7 :pypi:`pytest-rocketchat` Pytest to Rocket.Chat reporting plugin Apr 18, 2021 5 - Production/Stable N/A :pypi:`pytest-rotest` Pytest integration with rotest Sep 08, 2019 N/A pytest (>=3.5.0) :pypi:`pytest-rpc` Extend py.test for RPC OpenStack testing. Feb 22, 2019 4 - Beta pytest (~=3.6) @@ -1206,7 +1207,7 @@ This list contains 1513 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Sep 05, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Sep 12, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 :pypi:`pytest-schedule` The job of test scheduling for humans. Jan 07, 2023 5 - Production/Stable N/A @@ -1217,14 +1218,14 @@ This list contains 1513 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Sep 05, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Sep 12, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-send-email` Send pytest execution result email Sep 02, 2024 N/A pytest :pypi:`pytest-sentry` A pytest plugin to send testrun information to Sentry.io Apr 25, 2024 N/A pytest :pypi:`pytest-sequence-markers` Pytest plugin for sequencing markers for execution of tests May 23, 2023 5 - Production/Stable N/A - :pypi:`pytest-server` test server exec cmd Jun 24, 2024 N/A N/A + :pypi:`pytest-server` test server exec cmd Sep 09, 2024 N/A N/A :pypi:`pytest-server-fixtures` Extensible server fixures for py.test Dec 19, 2023 5 - Production/Stable pytest :pypi:`pytest-serverless` Automatically mocks resources from serverless.yml in pytest using moto. May 09, 2022 4 - Beta N/A :pypi:`pytest-servers` pytest servers Aug 15, 2024 3 - Alpha pytest>=6.2 @@ -1236,7 +1237,7 @@ This list contains 1513 plugins. :pypi:`pytest-setupinfo` Displaying setup info during pytest command run Jan 23, 2023 N/A N/A :pypi:`pytest-sftpserver` py.test plugin to locally test sftp server connections. Sep 16, 2019 4 - Beta N/A :pypi:`pytest-shard` Dec 11, 2020 4 - Beta pytest - :pypi:`pytest-shared-session-scope` Sep 05, 2024 N/A pytest>=7 + :pypi:`pytest-shared-session-scope` Pytest session-scoped fixture that works with xdist Sep 08, 2024 N/A pytest>=7 :pypi:`pytest-share-hdf` Plugin to save test data in HDF files and retrieve them for comparison Sep 21, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-sharkreport` this is pytest report plugin. Jul 11, 2022 N/A pytest (>=3.5) :pypi:`pytest-shell` A pytest plugin to help with testing shell scripts / black box commands Mar 27, 2022 N/A N/A @@ -1340,7 +1341,7 @@ This list contains 1513 plugins. :pypi:`pytest-system-statistics` Pytest plugin to track and report system usage statistics Feb 16, 2022 5 - Production/Stable pytest (>=6.0.0) :pypi:`pytest-system-test-plugin` Pyst - Pytest System-Test Plugin Feb 03, 2022 N/A N/A :pypi:`pytest_tagging` a pytest plugin to tag tests Aug 31, 2024 N/A pytest<8.0.0,>=7.1.3 - :pypi:`pytest-takeltest` Fixtures for ansible, testinfra and molecule Feb 15, 2023 N/A N/A + :pypi:`pytest-takeltest` Fixtures for ansible, testinfra and molecule Sep 07, 2024 N/A N/A :pypi:`pytest-talisker` Nov 28, 2021 N/A N/A :pypi:`pytest-tally` A Pytest plugin to generate realtime summary stats, and display them in-console using a text-based dashboard. May 22, 2023 4 - Beta pytest (>=6.2.5) :pypi:`pytest-tap` Test Anything Protocol (TAP) reporting plugin for pytest Jul 15, 2023 5 - Production/Stable pytest (>=3.0) @@ -1391,7 +1392,7 @@ This list contains 1513 plugins. :pypi:`pytest-test-tracer-for-pytest` A plugin that allows coll test data for use on Test Tracer Jun 28, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-test-tracer-for-pytest-bdd` A plugin that allows coll test data for use on Test Tracer Aug 20, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-test-utils` Feb 08, 2024 N/A pytest >=3.9 - :pypi:`pytest-tesults` Tesults plugin for pytest Feb 15, 2024 5 - Production/Stable pytest >=3.5.0 + :pypi:`pytest-tesults` Tesults plugin for pytest Sep 09, 2024 5 - Production/Stable pytest>=3.5.0 :pypi:`pytest-textual-snapshot` Snapshot testing for Textual apps Jul 22, 2024 4 - Beta pytest>=8.0.0 :pypi:`pytest-tezos` pytest-ligo Jan 16, 2020 4 - Beta N/A :pypi:`pytest-tf` Test your OpenTofu and Terraform config using a PyTest plugin May 29, 2024 N/A pytest<9.0.0,>=8.2.1 @@ -1445,12 +1446,12 @@ This list contains 1513 plugins. :pypi:`pytest-tui` Text User Interface (TUI) and HTML report for Pytest test runs Dec 08, 2023 4 - Beta N/A :pypi:`pytest-tutorials` Mar 11, 2023 N/A N/A :pypi:`pytest-twilio-conversations-client-mock` Aug 02, 2022 N/A N/A - :pypi:`pytest-twisted` A twisted plugin for pytest. Jul 10, 2024 5 - Production/Stable pytest>=2.3 + :pypi:`pytest-twisted` A twisted plugin for pytest. Sep 10, 2024 5 - Production/Stable pytest>=2.3 :pypi:`pytest-typechecker` Run type checkers on specified test files Feb 04, 2022 N/A pytest (>=6.2.5,<7.0.0) :pypi:`pytest-typhoon-config` A Typhoon HIL plugin that facilitates test parameter configuration at runtime Apr 07, 2022 5 - Production/Stable N/A :pypi:`pytest-typhoon-polarion` Typhoontest plugin for Siemens Polarion Feb 01, 2024 4 - Beta N/A :pypi:`pytest-typhoon-xray` Typhoon HIL plugin for pytest Aug 15, 2023 4 - Beta N/A - :pypi:`pytest-typing-runner` Pytest plugin to make it easier to run and check python code against static type checkers Aug 29, 2024 N/A pytest==8.2.2; extra == "tests" + :pypi:`pytest-typing-runner` Pytest plugin to make it easier to run and check python code against static type checkers Sep 09, 2024 N/A pytest==8.2.2; extra == "tests" :pypi:`pytest-tytest` Typhoon HIL plugin for pytest May 25, 2020 4 - Beta pytest (>=5.4.2) :pypi:`pytest-ubersmith` Easily mock calls to ubersmith at the \`requests\` level. Apr 13, 2015 N/A N/A :pypi:`pytest-ui` Text User Interface for running python tests Jul 05, 2021 4 - Beta pytest @@ -1492,6 +1493,7 @@ This list contains 1513 plugins. :pypi:`pytest-wake` Mar 20, 2024 N/A pytest :pypi:`pytest-watch` Local continuous test runner with pytest and watchdog. May 20, 2018 N/A N/A :pypi:`pytest-watcher` Automatically rerun your tests on file modifications Aug 28, 2024 4 - Beta N/A + :pypi:`pytest-watch-plugin` Placeholder for internal package Sep 12, 2024 N/A N/A :pypi:`pytest_wdb` Trace pytest tests with wdb to halt on error with --wdb. Jul 04, 2016 N/A N/A :pypi:`pytest-wdl` Pytest plugin for testing WDL workflows. Nov 17, 2020 5 - Production/Stable N/A :pypi:`pytest-web3-data` A pytest plugin to fetch test data from IPFS HTTP gateways during pytest execution. Oct 04, 2023 4 - Beta pytest @@ -1541,7 +1543,7 @@ This list contains 1513 plugins. :pypi:`pytest-zcc` eee Jun 02, 2024 N/A N/A :pypi:`pytest-zebrunner` Pytest connector for Zebrunner reporting Jul 04, 2024 5 - Production/Stable pytest>=4.5.0 :pypi:`pytest-zeebe` Pytest fixtures for testing Camunda 8 processes using a Zeebe test engine. Feb 01, 2024 N/A pytest (>=7.4.2,<8.0.0) - :pypi:`pytest-zephyr-scale-integration` A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest Sep 04, 2024 N/A pytest + :pypi:`pytest-zephyr-scale-integration` A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest Sep 11, 2024 N/A pytest :pypi:`pytest-zest` Zesty additions to pytest. Nov 17, 2022 N/A N/A :pypi:`pytest-zhongwen-wendang` PyTest 中文文档 Mar 04, 2024 4 - Beta N/A :pypi:`pytest-zigzag` Extend py.test for RPC OpenStack testing. Feb 27, 2019 4 - Beta pytest (~=3.6) @@ -1588,9 +1590,9 @@ This list contains 1513 plugins. A contextmanager pytest fixture for handling multiple mock abstracts :pypi:`pytest-accept` - *last release*: Feb 10, 2024, + *last release*: Sep 09, 2024, *status*: N/A, - *requires*: pytest (>=6) + *requires*: pytest>=7 A pytest-plugin for updating doctest outputs @@ -1833,7 +1835,7 @@ This list contains 1513 plugins. pytest-annotate: Generate PyAnnotate annotations from your pytest tests. :pypi:`pytest-ansible` - *last release*: Aug 16, 2024, + *last release*: Sep 11, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=6 @@ -2393,7 +2395,7 @@ This list contains 1513 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Sep 05, 2024, + *last release*: Sep 13, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -2539,6 +2541,13 @@ This list contains 1513 plugins. Local continuous test runner with pytest and watchdog. + :pypi:`pytest-boilerplate` + *last release*: Sep 12, 2024, + *status*: 5 - Production/Stable, + *requires*: pytest>=4.0.0 + + The pytest plugin for your Django Boilerplate. + :pypi:`pytest-boost-xml` *last release*: Nov 30, 2022, *status*: 4 - Beta, @@ -3009,7 +3018,7 @@ This list contains 1513 plugins. Automated, comprehensive and well-organised pytest test cases. :pypi:`pytest-cleanuptotal` - *last release*: Aug 26, 2024, + *last release*: Sep 14, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -3534,7 +3543,7 @@ This list contains 1513 plugins. Useful functions for managing data for pytest fixtures :pypi:`pytest-databases` - *last release*: Aug 20, 2024, + *last release*: Sep 07, 2024, *status*: 4 - Beta, *requires*: pytest @@ -4395,9 +4404,9 @@ This list contains 1513 plugins. :pypi:`pytest-durations` - *last release*: Apr 22, 2022, + *last release*: Sep 11, 2024, *status*: 5 - Production/Stable, - *requires*: pytest (>=4.6) + *requires*: pytest>=4.6 Pytest plugin reporting fixtures and test functions execution time. @@ -4605,7 +4614,7 @@ This list contains 1513 plugins. Pytest plugin to represent test output with emoji support :pypi:`pytest-enabler` - *last release*: Aug 29, 2024, + *last release*: Sep 12, 2024, *status*: 5 - Production/Stable, *requires*: pytest!=8.1.*,>=6; extra == "test" @@ -4654,9 +4663,9 @@ This list contains 1513 plugins. Improvements for pytest (rejected upstream) :pypi:`pytest-env` - *last release*: Nov 28, 2023, + *last release*: Sep 07, 2024, *status*: 5 - Production/Stable, - *requires*: pytest>=7.4.3 + *requires*: pytest>=8.3.2 pytest plugin that allows you to add environment variables. @@ -5466,7 +5475,7 @@ This list contains 1513 plugins. An alternative way to parametrize test cases. :pypi:`pytest-fv` - *last release*: Sep 06, 2024, + *last release*: Sep 11, 2024, *status*: N/A, *requires*: pytest @@ -5648,7 +5657,7 @@ This list contains 1513 plugins. Parallelize pytest across GitLab CI workers. :pypi:`pytest-gitlab-code-quality` - *last release*: Apr 03, 2024, + *last release*: Sep 09, 2024, *status*: N/A, *requires*: pytest>=8.1.1 @@ -6642,7 +6651,7 @@ This list contains 1513 plugins. Run Konira DSL tests with py.test :pypi:`pytest-kookit` - *last release*: May 16, 2024, + *last release*: Sep 10, 2024, *status*: N/A, *requires*: N/A @@ -7279,7 +7288,7 @@ This list contains 1513 plugins. Pytest plugin to easily fake missing modules :pypi:`pytest-mitmproxy` - *last release*: May 28, 2024, + *last release*: Sep 12, 2024, *status*: N/A, *requires*: pytest>=7.0 @@ -7608,9 +7617,9 @@ This list contains 1513 plugins. pytest-neo is a plugin for pytest that shows tests like screen of Matrix. :pypi:`pytest-neos` - *last release*: Jun 11, 2024, - *status*: 1 - Planning, - *requires*: N/A + *last release*: Sep 10, 2024, + *status*: 5 - Production/Stable, + *requires*: pytest<8.0,>=7.2; extra == "dev" Pytest plugin for neos @@ -7678,7 +7687,7 @@ This list contains 1513 plugins. pytest ngs fixtures :pypi:`pytest-nhsd-apim` - *last release*: Jul 01, 2024, + *last release*: Sep 06, 2024, *status*: N/A, *requires*: pytest<9.0.0,>=8.2.0 @@ -8329,9 +8338,9 @@ This list contains 1513 plugins. Pytest plugin for reading playbooks. :pypi:`pytest-playwright` - *last release*: Jul 03, 2024, + *last release*: Sep 06, 2024, *status*: N/A, - *requires*: N/A + *requires*: pytest<9.0.0,>=6.2.4 A pytest wrapper with fixtures for Playwright to automate web browsers @@ -8413,8 +8422,8 @@ This list contains 1513 plugins. :pypi:`pytest-pogo` - *last release*: May 22, 2024, - *status*: 1 - Planning, + *last release*: Sep 09, 2024, + *status*: 4 - Beta, *requires*: pytest<9,>=7 Pytest plugin for pogo-migrate @@ -8553,9 +8562,9 @@ This list contains 1513 plugins. Minitest-style test colors :pypi:`pytest-print` - *last release*: Aug 25, 2023, + *last release*: Sep 08, 2024, *status*: 5 - Production/Stable, - *requires*: pytest>=7.4 + *requires*: pytest>=8.3.2 pytest-print adds the printer fixture you can use to print messages to the user (directly to the pytest runner, not stdout) @@ -9302,7 +9311,7 @@ This list contains 1513 plugins. pytest plugin for adding tests' parameters to junit report :pypi:`pytest-reportportal` - *last release*: Mar 27, 2024, + *last release*: Sep 06, 2024, *status*: N/A, *requires*: pytest>=3.8.0 @@ -9582,7 +9591,7 @@ This list contains 1513 plugins. pytest plugin for ROAST configuration override and fixtures :pypi:`pytest_robotframework` - *last release*: Aug 21, 2024, + *last release*: Sep 10, 2024, *status*: N/A, *requires*: pytest<9,>=7 @@ -9757,7 +9766,7 @@ This list contains 1513 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Sep 05, 2024, + *last release*: Sep 12, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9834,7 +9843,7 @@ This list contains 1513 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Sep 05, 2024, + *last release*: Sep 12, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9883,7 +9892,7 @@ This list contains 1513 plugins. Pytest plugin for sequencing markers for execution of tests :pypi:`pytest-server` - *last release*: Jun 24, 2024, + *last release*: Sep 09, 2024, *status*: N/A, *requires*: N/A @@ -9967,11 +9976,11 @@ This list contains 1513 plugins. :pypi:`pytest-shared-session-scope` - *last release*: Sep 05, 2024, + *last release*: Sep 08, 2024, *status*: N/A, *requires*: pytest>=7 - + Pytest session-scoped fixture that works with xdist :pypi:`pytest-share-hdf` *last release*: Sep 21, 2022, @@ -10695,7 +10704,7 @@ This list contains 1513 plugins. a pytest plugin to tag tests :pypi:`pytest-takeltest` - *last release*: Feb 15, 2023, + *last release*: Sep 07, 2024, *status*: N/A, *requires*: N/A @@ -11052,9 +11061,9 @@ This list contains 1513 plugins. :pypi:`pytest-tesults` - *last release*: Feb 15, 2024, + *last release*: Sep 09, 2024, *status*: 5 - Production/Stable, - *requires*: pytest >=3.5.0 + *requires*: pytest>=3.5.0 Tesults plugin for pytest @@ -11430,7 +11439,7 @@ This list contains 1513 plugins. :pypi:`pytest-twisted` - *last release*: Jul 10, 2024, + *last release*: Sep 10, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=2.3 @@ -11465,7 +11474,7 @@ This list contains 1513 plugins. Typhoon HIL plugin for pytest :pypi:`pytest-typing-runner` - *last release*: Aug 29, 2024, + *last release*: Sep 09, 2024, *status*: N/A, *requires*: pytest==8.2.2; extra == "tests" @@ -11758,6 +11767,13 @@ This list contains 1513 plugins. Automatically rerun your tests on file modifications + :pypi:`pytest-watch-plugin` + *last release*: Sep 12, 2024, + *status*: N/A, + *requires*: N/A + + Placeholder for internal package + :pypi:`pytest_wdb` *last release*: Jul 04, 2016, *status*: N/A, @@ -12102,7 +12118,7 @@ This list contains 1513 plugins. Pytest fixtures for testing Camunda 8 processes using a Zeebe test engine. :pypi:`pytest-zephyr-scale-integration` - *last release*: Sep 04, 2024, + *last release*: Sep 11, 2024, *status*: N/A, *requires*: pytest From c22b012ba86ad91e4578e9826c4987e77463f390 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 09:43:57 +0200 Subject: [PATCH 068/445] build(deps): Bump hynek/build-and-inspect-python-package (#12822) Bumps [hynek/build-and-inspect-python-package](https://github.com/hynek/build-and-inspect-python-package) from 2.8.0 to 2.9.0. - [Release notes](https://github.com/hynek/build-and-inspect-python-package/releases) - [Changelog](https://github.com/hynek/build-and-inspect-python-package/blob/main/CHANGELOG.md) - [Commits](https://github.com/hynek/build-and-inspect-python-package/compare/v2.8.0...v2.9.0) --- updated-dependencies: - dependency-name: hynek/build-and-inspect-python-package dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/deploy.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1299c4c57c3..cb053552ccd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,7 +31,7 @@ jobs: persist-credentials: false - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v2.8.0 + uses: hynek/build-and-inspect-python-package@v2.9.0 with: attest-build-provenance-github: 'true' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 83a3d9cb33e..8e66f5eae5c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,7 +40,7 @@ jobs: fetch-depth: 0 persist-credentials: false - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v2.8.0 + uses: hynek/build-and-inspect-python-package@v2.9.0 build: needs: [package] From e7e3f5067754294392ed646c294a81d8f3db217b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 08:01:42 +0000 Subject: [PATCH 069/445] build(deps): Bump peter-evans/create-pull-request from 7.0.1 to 7.0.2 (#12821) Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 7.0.1 to 7.0.2. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/8867c4aba1b742c39f8d0ba35429c2dfa4b6cb20...d121e62763d8cc35b5fb1710e887d6e69a52d3a4) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/update-plugin-list.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-plugin-list.yml b/.github/workflows/update-plugin-list.yml index 2f1fb14ea70..3029436ce79 100644 --- a/.github/workflows/update-plugin-list.yml +++ b/.github/workflows/update-plugin-list.yml @@ -47,7 +47,7 @@ jobs: - name: Create Pull Request id: pr - uses: peter-evans/create-pull-request@8867c4aba1b742c39f8d0ba35429c2dfa4b6cb20 + uses: peter-evans/create-pull-request@d121e62763d8cc35b5fb1710e887d6e69a52d3a4 with: commit-message: '[automated] Update plugin list' author: 'pytest bot ' From d32dee15372ae0090575ebfad559bdecaf0cf3ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 13:10:41 +0200 Subject: [PATCH 070/445] build(deps): Bump pytest-twisted in /testing/plugins_integration (#12820) Bumps [pytest-twisted](https://github.com/pytest-dev/pytest-twisted) from 1.14.2 to 1.14.3. - [Release notes](https://github.com/pytest-dev/pytest-twisted/releases) - [Commits](https://github.com/pytest-dev/pytest-twisted/compare/v1.14.2...v1.14.3) --- updated-dependencies: - dependency-name: pytest-twisted dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Pierre Sassoulas --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 70fac9e1f1c..379b4ffa5e8 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -10,6 +10,6 @@ pytest-mock==3.14.0 pytest-rerunfailures==14.0 pytest-sugar==1.0.0 pytest-trio==0.8.0 -pytest-twisted==1.14.2 +pytest-twisted==1.14.3 twisted==24.7.0 pytest-xvfb==3.0.0 From c22a0cf8f5d8667960c6ce9556e77376e2077a76 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 22:36:45 +0000 Subject: [PATCH 071/445] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.3 → v0.6.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.3...v0.6.5) - [github.com/tox-dev/pyproject-fmt: 2.2.1 → 2.2.3](https://github.com/tox-dev/pyproject-fmt/compare/2.2.1...2.2.3) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dfeca73648b..b6f2a16424a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.3" + rev: "v0.6.5" hooks: - id: ruff args: ["--fix"] @@ -46,7 +46,7 @@ repos: # on <3.11 - exceptiongroup>=1.0.0rc8 - repo: https://github.com/tox-dev/pyproject-fmt - rev: "2.2.1" + rev: "2.2.3" hooks: - id: pyproject-fmt # https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version From 50044f61446837dc3e2c4b56d7ad516d52808838 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 16 Sep 2024 20:17:09 -0300 Subject: [PATCH 072/445] Ignore ruff error about EncodingWarning not defined in Python<3.10 We have a runtime guard right above it, so it is OK to ignore it. --- testing/_py/test_local.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/_py/test_local.py b/testing/_py/test_local.py index 4a95e2d0cd9..21fbfb3e3ad 100644 --- a/testing/_py/test_local.py +++ b/testing/_py/test_local.py @@ -19,7 +19,7 @@ def ignore_encoding_warning(): with warnings.catch_warnings(): if sys.version_info > (3, 10): - warnings.simplefilter("ignore", EncodingWarning) + warnings.simplefilter("ignore", EncodingWarning) # noqa: F821 yield From 4508d0b2d465eb02c97dc526c0bc8119e2b162f5 Mon Sep 17 00:00:00 2001 From: Serge Smertin <259697+nfx@users.noreply.github.com> Date: Thu, 19 Sep 2024 15:59:54 +0200 Subject: [PATCH 073/445] Added Databricks fixture plugin for PyTest (#12826) Adding it as a `ADDITIONAL_PROJECTS`, because our naming conventions can't fit `pytest-` as a prefix. https://github.com/databrickslabs/pytester https://pypi.org/project/databricks-labs-pytester/ --- scripts/update-plugin-list.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/update-plugin-list.py b/scripts/update-plugin-list.py index 75df0ddba40..556004d9e98 100644 --- a/scripts/update-plugin-list.py +++ b/scripts/update-plugin-list.py @@ -66,6 +66,7 @@ "logot", "nuts", "flask_fixture", + "databricks-labs-pytester", } From d924a63871df8542a6accbeb973e857a3b40eb85 Mon Sep 17 00:00:00 2001 From: Pavel Zhukov <48322035+zhukoff-pavel@users.noreply.github.com> Date: Sat, 21 Sep 2024 16:00:56 +0300 Subject: [PATCH 074/445] Implement truncation thresholds config options (#12766) Fixes #12765 Co-authored-by: Bruno Oliveira --- AUTHORS | 1 + changelog/12765.feature.rst | 3 ++ doc/en/how-to/output.rst | 22 ++++++++++++ doc/en/reference/reference.rst | 40 +++++++++++++++++++++ src/_pytest/assertion/__init__.py | 12 +++++++ src/_pytest/assertion/truncate.py | 58 ++++++++++++++++++++---------- testing/test_assertion.py | 60 +++++++++++++++++++++++++++++++ 7 files changed, 177 insertions(+), 19 deletions(-) create mode 100644 changelog/12765.feature.rst diff --git a/AUTHORS b/AUTHORS index 374e6ad9bcc..1ee868448d4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -328,6 +328,7 @@ Paul Müller Paul Reece Pauli Virtanen Pavel Karateev +Pavel Zhukov Paweł Adamczak Pedro Algarvio Petter Strandmark diff --git a/changelog/12765.feature.rst b/changelog/12765.feature.rst new file mode 100644 index 00000000000..193c75621f7 --- /dev/null +++ b/changelog/12765.feature.rst @@ -0,0 +1,3 @@ +Thresholds to trigger snippet truncation can now be set with :confval:`truncation_limit_lines` and :confval:`truncation_limit_chars`. + +See :ref:`truncation-params` for more information. diff --git a/doc/en/how-to/output.rst b/doc/en/how-to/output.rst index 8b15f95f0fd..d53dd4b8ec7 100644 --- a/doc/en/how-to/output.rst +++ b/doc/en/how-to/output.rst @@ -549,6 +549,28 @@ captured output: By default, parametrized variants of skipped tests are grouped together if they share the same skip reason. You can use ``--no-fold-skipped`` to print each skipped test separately. + +.. _truncation-params: + +Modifying truncation limits +-------------------------------------------------- + +.. versionadded: 8.4 + +Default truncation limits are 8 lines or 640 characters, whichever comes first. +To set custom truncation limits you can use following ``pytest.ini`` file options: + +.. code-block:: ini + + [pytest] + truncation_limit_lines = 10 + truncation_limit_chars = 90 + +That will cause pytest to truncate the assertions to 10 lines or 90 characters, whichever comes first. + +Setting both :confval:`truncation_limit_lines` and :confval:`truncation_limit_chars` to ``0`` will disable the truncation. +However, setting only one of those values will disable one truncation mode, but will leave the other one intact. + Creating resultlog format files -------------------------------------------------- diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index f7dfb3ffa71..73398ac811e 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1873,6 +1873,46 @@ passed multiple times. The expected format is ``name=value``. For example:: Default: ``all`` +.. confval:: truncation_limit_chars + + Controls maximum number of characters to truncate assertion message contents. + + Setting value to ``0`` disables the character limit for truncation. + + .. code-block:: ini + + [pytest] + truncation_limit_chars = 640 + + pytest truncates the assert messages to a certain limit by default to prevent comparison with large data to overload the console output. + + Default: ``640`` + + .. note:: + + If pytest detects it is :ref:`running on CI `, truncation is disabled automatically. + + +.. confval:: truncation_limit_lines + + Controls maximum number of linesto truncate assertion message contents. + + Setting value to ``0`` disables the lines limit for truncation. + + .. code-block:: ini + + [pytest] + truncation_limit_lines = 8 + + pytest truncates the assert messages to a certain limit by default to prevent comparison with large data to overload the console output. + + Default: ``8`` + + .. note:: + + If pytest detects it is :ref:`running on CI `, truncation is disabled automatically. + + .. confval:: usefixtures List of fixtures that will be applied to all test functions; this is semantically the same to apply diff --git a/src/_pytest/assertion/__init__.py b/src/_pytest/assertion/__init__.py index f2f1d029b4c..cbdf9fa0298 100644 --- a/src/_pytest/assertion/__init__.py +++ b/src/_pytest/assertion/__init__.py @@ -45,6 +45,18 @@ def pytest_addoption(parser: Parser) -> None: help="Enables the pytest_assertion_pass hook. " "Make sure to delete any previously generated pyc cache files.", ) + + parser.addini( + "truncation_limit_lines", + default=None, + help="Set threshold of LINES after which truncation will take effect", + ) + parser.addini( + "truncation_limit_chars", + default=None, + help=("Set threshold of CHARS after which truncation will take effect"), + ) + Config._add_verbosity_ini( parser, Config.VERBOSITY_ASSERTIONS, diff --git a/src/_pytest/assertion/truncate.py b/src/_pytest/assertion/truncate.py index b67f02ccaf8..4854a62ba6b 100644 --- a/src/_pytest/assertion/truncate.py +++ b/src/_pytest/assertion/truncate.py @@ -12,41 +12,54 @@ DEFAULT_MAX_LINES = 8 -DEFAULT_MAX_CHARS = 8 * 80 +DEFAULT_MAX_CHARS = DEFAULT_MAX_LINES * 80 USAGE_MSG = "use '-vv' to show" -def truncate_if_required( - explanation: list[str], item: Item, max_length: int | None = None -) -> list[str]: +def truncate_if_required(explanation: list[str], item: Item) -> list[str]: """Truncate this assertion explanation if the given test item is eligible.""" - if _should_truncate_item(item): - return _truncate_explanation(explanation) + should_truncate, max_lines, max_chars = _get_truncation_parameters(item) + if should_truncate: + return _truncate_explanation( + explanation, + max_lines=max_lines, + max_chars=max_chars, + ) return explanation -def _should_truncate_item(item: Item) -> bool: - """Whether or not this test item is eligible for truncation.""" +def _get_truncation_parameters(item: Item) -> tuple[bool, int, int]: + """Return the truncation parameters related to the given item, as (should truncate, max lines, max chars).""" + # We do not need to truncate if one of conditions is met: + # 1. Verbosity level is 2 or more; + # 2. Test is being run in CI environment; + # 3. Both truncation_limit_lines and truncation_limit_chars + # .ini parameters are set to 0 explicitly. + max_lines = item.config.getini("truncation_limit_lines") + max_lines = int(max_lines if max_lines is not None else DEFAULT_MAX_LINES) + + max_chars = item.config.getini("truncation_limit_chars") + max_chars = int(max_chars if max_chars is not None else DEFAULT_MAX_CHARS) + verbose = item.config.get_verbosity(Config.VERBOSITY_ASSERTIONS) - return verbose < 2 and not util.running_on_ci() + + should_truncate = verbose < 2 and not util.running_on_ci() + should_truncate = should_truncate and (max_lines > 0 or max_chars > 0) + + return should_truncate, max_lines, max_chars def _truncate_explanation( input_lines: list[str], - max_lines: int | None = None, - max_chars: int | None = None, + max_lines: int, + max_chars: int, ) -> list[str]: """Truncate given list of strings that makes up the assertion explanation. - Truncates to either 8 lines, or 640 characters - whichever the input reaches + Truncates to either max_lines, or max_chars - whichever the input reaches first, taking the truncation explanation into account. The remaining lines will be replaced by a usage message. """ - if max_lines is None: - max_lines = DEFAULT_MAX_LINES - if max_chars is None: - max_chars = DEFAULT_MAX_CHARS - # Check if truncation required input_char_count = len("".join(input_lines)) # The length of the truncation explanation depends on the number of lines @@ -71,16 +84,23 @@ def _truncate_explanation( ): return input_lines # Truncate first to max_lines, and then truncate to max_chars if necessary - truncated_explanation = input_lines[:max_lines] + if max_lines > 0: + truncated_explanation = input_lines[:max_lines] + else: + truncated_explanation = input_lines truncated_char = True # We reevaluate the need to truncate chars following removal of some lines - if len("".join(truncated_explanation)) > tolerable_max_chars: + if len("".join(truncated_explanation)) > tolerable_max_chars and max_chars > 0: truncated_explanation = _truncate_by_char_count( truncated_explanation, max_chars ) else: truncated_char = False + if truncated_explanation == input_lines: + # No truncation happened, so we do not need to add any explanations + return truncated_explanation + truncated_line_count = len(input_lines) - len(truncated_explanation) if truncated_explanation[-1]: # Add ellipsis and take into account part-truncated final line diff --git a/testing/test_assertion.py b/testing/test_assertion.py index 31192df0f6f..b10ca1c91f4 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -1435,6 +1435,66 @@ def test_many_lines(): result = pytester.runpytest() result.stdout.fnmatch_lines(["* 6*"]) + @pytest.mark.parametrize( + ["truncation_lines", "truncation_chars", "expected_lines_hidden"], + ( + (3, None, 3), + (4, None, 0), + (0, None, 0), + (None, 8, 6), + (None, 9, 0), + (None, 0, 0), + (0, 0, 0), + (0, 1000, 0), + (1000, 0, 0), + ), + ) + def test_truncation_with_ini( + self, + monkeypatch, + pytester: Pytester, + truncation_lines: int | None, + truncation_chars: int | None, + expected_lines_hidden: int, + ) -> None: + pytester.makepyfile( + """\ + string_a = "123456789\\n23456789\\n3" + string_b = "123456789\\n23456789\\n4" + + def test(): + assert string_a == string_b + """ + ) + + # This test produces 6 lines of diff output or 79 characters + # So the effect should be when threshold is < 4 lines (considering 2 additional lines for explanation) + # Or < 9 characters (considering 70 additional characters for explanation) + + monkeypatch.delenv("CI", raising=False) + + ini = "[pytest]\n" + if truncation_lines is not None: + ini += f"truncation_limit_lines = {truncation_lines}\n" + if truncation_chars is not None: + ini += f"truncation_limit_chars = {truncation_chars}\n" + pytester.makeini(ini) + + result = pytester.runpytest() + + if expected_lines_hidden != 0: + result.stdout.fnmatch_lines( + [f"*truncated ({expected_lines_hidden} lines hidden)*"] + ) + else: + result.stdout.no_fnmatch_line("*truncated*") + result.stdout.fnmatch_lines( + [ + "*- 4*", + "*+ 3*", + ] + ) + def test_python25_compile_issue257(pytester: Pytester) -> None: pytester.makepyfile( From 2a22a696e7fa32c50672f057030ede2a1a9ddae4 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Sat, 21 Sep 2024 22:10:33 +0100 Subject: [PATCH 075/445] Remove missing msg parameter from docs --- doc/en/reference/reference.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 73398ac811e..3bb03cc0386 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -54,7 +54,7 @@ pytest.fail **Tutorial**: :ref:`skipping` -.. autofunction:: pytest.fail(reason, [pytrace=True, msg=None]) +.. autofunction:: pytest.fail(reason, [pytrace=True]) .. class:: pytest.fail.Exception @@ -63,7 +63,7 @@ pytest.fail pytest.skip ~~~~~~~~~~~ -.. autofunction:: pytest.skip(reason, [allow_module_level=False, msg=None]) +.. autofunction:: pytest.skip(reason, [allow_module_level=False]) .. class:: pytest.skip.Exception @@ -88,7 +88,7 @@ pytest.xfail pytest.exit ~~~~~~~~~~~ -.. autofunction:: pytest.exit(reason, [returncode=None, msg=None]) +.. autofunction:: pytest.exit(reason, [returncode=None]) .. class:: pytest.exit.Exception From 16fa1ee5e2a72e4dea3276d069e805d5d7abf5b9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 22 Sep 2024 08:44:47 +0000 Subject: [PATCH 076/445] [automated] Update plugin list (#12831) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 154 ++++++++++++++++++++----------- 1 file changed, 101 insertions(+), 53 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 23e95e27730..53028c576da 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,13 +27,14 @@ please refer to `the update script =8.3 :pypi:`logassert` Simple but powerful assertion and verification of logged lines. May 20, 2022 5 - Production/Stable N/A :pypi:`logot` Test whether your code is logging correctly 🪵 Mar 23, 2024 5 - Production/Stable pytest<9,>=7; extra == "pytest" :pypi:`nuts` Network Unit Testing System Jul 19, 2024 N/A pytest<8,>=7 @@ -70,6 +71,7 @@ This list contains 1515 plugins. :pypi:`pytest-allure-intersection` Oct 27, 2022 N/A pytest (<5) :pypi:`pytest-allure-spec-coverage` The pytest plugin aimed to display test coverage of the specs(requirements) in Allure Oct 26, 2021 N/A pytest :pypi:`pytest-alphamoon` Static code checks used at Alphamoon Dec 30, 2021 5 - Production/Stable pytest (>=3.5.0) + :pypi:`pytest-amaranth-sim` Fixture to automate running Amaranth simulations Sep 21, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-analyzer` this plugin allows to analyze tests in pytest project, collect test metadata and sync it with testomat.io TCM system Feb 21, 2024 N/A pytest <8.0.0,>=7.3.1 :pypi:`pytest-android` This fixture provides a configured "driver" for Android Automated Testing, using uiautomator2. Feb 21, 2019 3 - Alpha pytest :pypi:`pytest-anki` A pytest plugin for testing Anki add-ons Jul 31, 2022 4 - Beta pytest (>=3.5.0) @@ -154,7 +156,7 @@ This list contains 1515 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Aug 08, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Sep 13, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Sep 18, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -212,7 +214,7 @@ This list contains 1515 plugins. :pypi:`pytest-cassandra` Cassandra CCM Test Fixtures for pytest Nov 04, 2017 1 - Planning N/A :pypi:`pytest-catchlog` py.test plugin to catch log messages. This is a fork of pytest-capturelog. Jan 24, 2016 4 - Beta pytest (>=2.6) :pypi:`pytest-catch-server` Pytest plugin with server for catching HTTP requests. Dec 12, 2019 5 - Production/Stable N/A - :pypi:`pytest-celery` Pytest plugin for Celery Aug 12, 2024 4 - Beta N/A + :pypi:`pytest-celery` Pytest plugin for Celery Sep 20, 2024 4 - Beta N/A :pypi:`pytest-cfg-fetcher` Pass config options to your unit tests. Feb 26, 2024 N/A N/A :pypi:`pytest-chainmaker` pytest plugin for chainmaker Oct 15, 2021 N/A N/A :pypi:`pytest-chalice` A set of py.test fixtures for AWS Chalice Jul 01, 2020 4 - Beta N/A @@ -262,7 +264,7 @@ This list contains 1515 plugins. :pypi:`pytest-codegen` Automatically create pytest test signatures Aug 23, 2020 2 - Pre-Alpha N/A :pypi:`pytest-codeowners` Pytest plugin for selecting tests by GitHub CODEOWNERS. Mar 30, 2022 4 - Beta pytest (>=6.0.0) :pypi:`pytest-codestyle` pytest plugin to run pycodestyle Mar 23, 2020 3 - Alpha N/A - :pypi:`pytest-codspeed` Pytest plugin to create CodSpeed benchmarks Mar 19, 2024 5 - Production/Stable pytest>=3.8 + :pypi:`pytest-codspeed` Pytest plugin to create CodSpeed benchmarks Sep 20, 2024 5 - Production/Stable pytest>=3.8 :pypi:`pytest-collect-appoint-info` set your encoding Aug 03, 2023 N/A pytest :pypi:`pytest-collect-formatter` Formatter for pytest collect output Mar 29, 2021 5 - Production/Stable N/A :pypi:`pytest-collect-formatter2` Formatter for pytest collect output May 31, 2021 5 - Production/Stable N/A @@ -294,7 +296,7 @@ This list contains 1515 plugins. :pypi:`pytest-coveragemarkers` Using pytest markers to track functional coverage and filtering of tests Aug 14, 2024 N/A pytest<8.0.0,>=7.1.2 :pypi:`pytest-cov-exclude` Pytest plugin for excluding tests based on coverage data Apr 29, 2016 4 - Beta pytest (>=2.8.0,<2.9.0); extra == 'dev' :pypi:`pytest_covid` Too many faillure, less tests. Jun 24, 2020 N/A N/A - :pypi:`pytest-cpp` Use pytest's runner to discover and execute C++ tests Nov 01, 2023 5 - Production/Stable pytest >=7.0 + :pypi:`pytest-cpp` Use pytest's runner to discover and execute C++ tests Sep 18, 2024 5 - Production/Stable pytest :pypi:`pytest-cqase` Custom qase pytest plugin Aug 22, 2022 N/A pytest (>=7.1.2,<8.0.0) :pypi:`pytest-cram` Run cram tests with pytest. Aug 08, 2020 N/A N/A :pypi:`pytest-crate` Manages CrateDB instances during your integration tests May 28, 2019 3 - Alpha pytest (>=4.0) @@ -478,7 +480,7 @@ This list contains 1515 plugins. :pypi:`pytest_energy_reporter` An energy estimation reporter for pytest Mar 28, 2024 3 - Alpha pytest<9.0.0,>=8.1.1 :pypi:`pytest-enhanced-reports` Enhanced test reports for pytest Dec 15, 2022 N/A N/A :pypi:`pytest-enhancements` Improvements for pytest (rejected upstream) Oct 30, 2019 4 - Beta N/A - :pypi:`pytest-env` pytest plugin that allows you to add environment variables. Sep 07, 2024 5 - Production/Stable pytest>=8.3.2 + :pypi:`pytest-env` pytest plugin that allows you to add environment variables. Sep 17, 2024 5 - Production/Stable pytest>=8.3.3 :pypi:`pytest-envfiles` A py.test plugin that parses environment files before running tests Oct 08, 2015 3 - Alpha N/A :pypi:`pytest-env-info` Push information about the running pytest into envvars Nov 25, 2017 4 - Beta pytest (>=3.1.1) :pypi:`pytest-environment` Pytest Environment Mar 17, 2024 1 - Planning N/A @@ -492,10 +494,11 @@ This list contains 1515 plugins. :pypi:`pytest-ethereum` pytest-ethereum: Pytest library for ethereum projects. Jun 24, 2019 3 - Alpha pytest (==3.3.2); extra == 'dev' :pypi:`pytest-eucalyptus` Pytest Plugin for BDD Jun 28, 2022 N/A pytest (>=4.2.0) :pypi:`pytest-eventlet` Applies eventlet monkey-patch as a pytest plugin. Oct 04, 2021 N/A pytest ; extra == 'dev' - :pypi:`pytest-evm` The testing package containing tools to test Web3-based projects Apr 22, 2024 4 - Beta pytest<9.0.0,>=8.1.1 + :pypi:`pytest_evm` The testing package containing tools to test Web3-based projects Sep 15, 2024 4 - Beta pytest<9.0.0,>=8.1.1 :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Aug 13, 2024 4 - Beta pytest>=7 - :pypi:`pytest-exasol-backend` Aug 23, 2024 N/A pytest<9,>=7 + :pypi:`pytest-exasol-backend` Sep 18, 2024 N/A pytest<9,>=7 + :pypi:`pytest-exasol-extension` Sep 18, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-itde` Jul 01, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-saas` Aug 06, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-slc` Aug 29, 2024 N/A pytest<9,>=7 @@ -512,7 +515,7 @@ This list contains 1515 plugins. :pypi:`pytest-expect-test` A fixture to support expect tests in pytest Apr 10, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-experiments` A pytest plugin to help developers of research-oriented software projects keep track of the results of their numerical experiments. Dec 13, 2021 4 - Beta pytest (>=6.2.5,<7.0.0) :pypi:`pytest-explicit` A Pytest plugin to ignore certain marked tests by default Jun 15, 2021 5 - Production/Stable pytest - :pypi:`pytest-exploratory` Interactive console for pytest. Aug 18, 2023 N/A pytest (>=6.2) + :pypi:`pytest-exploratory` Interactive console for pytest. Sep 18, 2024 N/A pytest>=6.2 :pypi:`pytest-explorer` terminal ui for exploring and running tests Aug 01, 2023 N/A N/A :pypi:`pytest-ext` pytest plugin for automation test Mar 31, 2024 N/A pytest>=5.3 :pypi:`pytest-extensions` A collection of helpers for pytest to ease testing Aug 17, 2022 4 - Beta pytest ; extra == 'testing' @@ -618,7 +621,7 @@ This list contains 1515 plugins. :pypi:`pytest-github-actions-annotate-failures` pytest plugin to annotate failed tests with a workflow command for GitHub Actions May 04, 2023 5 - Production/Stable pytest (>=4.0.0) :pypi:`pytest-github-report` Generate a GitHub report using pytest in GitHub Workflows Jun 03, 2022 4 - Beta N/A :pypi:`pytest-gitignore` py.test plugin to ignore the same files as git Jul 17, 2015 4 - Beta N/A - :pypi:`pytest-gitlab` Pytest Plugin for Gitlab Sep 06, 2024 N/A N/A + :pypi:`pytest-gitlab` Pytest Plugin for Gitlab Sep 18, 2024 N/A N/A :pypi:`pytest-gitlabci-parallelized` Parallelize pytest across GitLab CI workers. Mar 08, 2023 N/A N/A :pypi:`pytest-gitlab-code-quality` Collects warnings while testing and generates a GitLab Code Quality Report. Sep 09, 2024 N/A pytest>=8.1.1 :pypi:`pytest-gitlab-fold` Folds output sections in GitLab CI build log Dec 31, 2023 4 - Beta pytest >=2.6.0 @@ -652,7 +655,7 @@ This list contains 1515 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Sep 07, 2024 3 - Alpha pytest==8.3.1 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Sep 17, 2024 3 - Alpha pytest==8.3.1 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Apr 18, 2024 N/A N/A @@ -671,13 +674,13 @@ This list contains 1515 plugins. :pypi:`pytest-html-report-merger` May 22, 2024 N/A N/A :pypi:`pytest-html-thread` pytest plugin for generating HTML reports Dec 29, 2020 5 - Production/Stable N/A :pypi:`pytest-http` Fixture "http" for http requests Aug 22, 2024 N/A pytest - :pypi:`pytest-httpbin` Easily test your HTTP library against a local copy of httpbin May 08, 2023 5 - Production/Stable pytest ; extra == 'test' + :pypi:`pytest-httpbin` Easily test your HTTP library against a local copy of httpbin Sep 18, 2024 5 - Production/Stable pytest; extra == "test" :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace Jan 10, 2024 3 - Alpha pytest >=7.0.0 :pypi:`pytest-http-mocker` Pytest plugin for http mocking (via https://github.com/vilus/mocker) Oct 20, 2019 N/A N/A :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Aug 11, 2024 3 - Alpha N/A :pypi:`pytest-httptesting` http_testing framework on top of pytest Aug 10, 2024 N/A pytest<9.0.0,>=8.2.0 - :pypi:`pytest-httpx` Send responses to httpx. Feb 21, 2024 5 - Production/Stable pytest <9,>=7 + :pypi:`pytest-httpx` Send responses to httpx. Sep 20, 2024 5 - Production/Stable pytest==8.* :pypi:`pytest-httpx-blockage` Disable httpx requests during a test run Feb 16, 2023 N/A pytest (>=7.2.1) :pypi:`pytest-httpx-recorder` Recorder feature based on pytest_httpx, like recorder feature in responses. Jan 04, 2024 5 - Production/Stable pytest :pypi:`pytest-hue` Visualise PyTest status via your Phillips Hue lights May 09, 2019 N/A N/A @@ -718,13 +721,14 @@ This list contains 1515 plugins. :pypi:`pytest-integration-mark` Automatic integration test marking and excluding plugin for pytest May 22, 2023 N/A pytest (>=5.2) :pypi:`pytest-interactive` A pytest plugin for console based interactive test selection just after the collection phase Nov 30, 2017 3 - Alpha N/A :pypi:`pytest-intercept-remote` Pytest plugin for intercepting outgoing connection requests during pytest run. May 24, 2021 4 - Beta pytest (>=4.6) - :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Aug 09, 2024 4 - Beta pytest + :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Sep 18, 2024 4 - Beta pytest :pypi:`pytest-invenio` Pytest fixtures for Invenio. Jun 27, 2024 5 - Production/Stable pytest<7.2.0,>=6 :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A :pypi:`pytest-ipywidgets` Aug 30, 2024 N/A pytest :pypi:`pytest-isolate` Feb 20, 2023 4 - Beta pytest + :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Sep 18, 2024 4 - Beta pytest>=5 :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-it` Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it. Jan 29, 2024 4 - Beta N/A :pypi:`pytest-iterassert` Nicer list and iterable assertion messages for pytest May 11, 2020 3 - Alpha N/A @@ -846,7 +850,7 @@ This list contains 1515 plugins. :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A :pypi:`pytest-metadata` pytest plugin for test session metadata Feb 12, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-metrics` Custom metrics report for pytest Apr 04, 2020 N/A pytest - :pypi:`pytest-mh` Pytest multihost plugin Aug 02, 2024 N/A pytest + :pypi:`pytest-mh` Pytest multihost plugin Sep 19, 2024 N/A pytest :pypi:`pytest-mimesis` Mimesis integration with the pytest test runner Mar 21, 2020 5 - Production/Stable pytest (>=4.2) :pypi:`pytest-minecraft` A pytest plugin for running tests against Minecraft releases Apr 06, 2022 N/A pytest (>=6.0.1) :pypi:`pytest-mini` A plugin to test mp Feb 06, 2023 N/A pytest (>=7.2.0,<8.0.0) @@ -862,7 +866,7 @@ This list contains 1515 plugins. :pypi:`pytest-mock-helper` Help you mock HTTP call and generate mock code Jan 24, 2018 N/A pytest :pypi:`pytest-mockito` Base fixtures for mockito Jul 11, 2018 4 - Beta N/A :pypi:`pytest-mockredis` An in-memory mock of a Redis server that runs in a separate thread. This is to be used for unit-tests that require a Redis database. Jan 02, 2018 2 - Pre-Alpha N/A - :pypi:`pytest-mock-resources` A pytest plugin for easily instantiating reproducible mock resources. Jun 20, 2024 N/A pytest>=1.0 + :pypi:`pytest-mock-resources` A pytest plugin for easily instantiating reproducible mock resources. Sep 17, 2024 N/A pytest>=1.0 :pypi:`pytest-mock-server` Mock server plugin for pytest Jan 09, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-mockservers` A set of fixtures to test your requests to HTTP/UDP servers Mar 31, 2020 N/A pytest (>=4.3.0) :pypi:`pytest-mocktcp` A pytest plugin for testing TCP clients Oct 11, 2022 N/A pytest @@ -931,7 +935,7 @@ This list contains 1515 plugins. :pypi:`pytest-object-getter` Import any object from a 3rd party module while mocking its namespace on demand. Jul 31, 2022 5 - Production/Stable pytest :pypi:`pytest-ochrus` pytest results data-base and HTML reporter Feb 21, 2018 4 - Beta N/A :pypi:`pytest-odc` A pytest plugin for simplifying ODC database tests Aug 04, 2023 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-odoo` py.test plugin to run Odoo tests Jul 06, 2023 4 - Beta pytest (>=7.2.0) + :pypi:`pytest-odoo` py.test plugin to run Odoo tests Sep 20, 2024 4 - Beta pytest<8.0.0,>=7.2.0 :pypi:`pytest-odoo-fixtures` Project description Jun 25, 2019 N/A N/A :pypi:`pytest-oerp` pytest plugin to test OpenERP modules Feb 28, 2012 3 - Alpha N/A :pypi:`pytest-offline` Mar 09, 2023 1 - Planning pytest (>=7.0.0,<8.0.0) @@ -963,6 +967,7 @@ This list contains 1515 plugins. :pypi:`pytest-param` pytest plugin to test all, first, last or random params Sep 11, 2016 4 - Beta pytest (>=2.6.0) :pypi:`pytest-paramark` Configure pytest fixtures using a combination of"parametrize" and markers Jan 10, 2020 4 - Beta pytest (>=4.5.0) :pypi:`pytest-parametrization` Simpler PyTest parametrization May 22, 2022 5 - Production/Stable N/A + :pypi:`pytest-parametrize` pytest decorator for parametrizing test cases in a dict-way Sep 16, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.0 :pypi:`pytest-parametrize-cases` A more user-friendly way to write parametrized tests. Mar 13, 2022 N/A pytest (>=6.1.2) :pypi:`pytest-parametrized` Pytest decorator for parametrizing tests with default iterables. Nov 03, 2023 5 - Production/Stable pytest :pypi:`pytest-parametrize-suite` A simple pytest extension for creating a named test suite. Jan 19, 2023 5 - Production/Stable pytest @@ -1035,7 +1040,7 @@ This list contains 1515 plugins. :pypi:`pytest-pretty` pytest plugin for printing summary data as I want it Apr 05, 2023 5 - Production/Stable pytest>=7 :pypi:`pytest-pretty-terminal` pytest plugin for generating prettier terminal output Jan 31, 2022 N/A pytest (>=3.4.1) :pypi:`pytest-pride` Minitest-style test colors Apr 02, 2016 3 - Alpha N/A - :pypi:`pytest-print` pytest-print adds the printer fixture you can use to print messages to the user (directly to the pytest runner, not stdout) Sep 08, 2024 5 - Production/Stable pytest>=8.3.2 + :pypi:`pytest-print` pytest-print adds the printer fixture you can use to print messages to the user (directly to the pytest runner, not stdout) Sep 17, 2024 5 - Production/Stable pytest>=8.3.2 :pypi:`pytest-priority` pytest plugin for add priority for tests Aug 19, 2024 N/A pytest :pypi:`pytest-proceed` Apr 10, 2024 N/A pytest :pypi:`pytest-profiles` pytest plugin for configuration profiles Dec 09, 2021 4 - Beta pytest (>=3.7.0) @@ -1207,7 +1212,7 @@ This list contains 1515 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Sep 12, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Sep 16, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 :pypi:`pytest-schedule` The job of test scheduling for humans. Jan 07, 2023 5 - Production/Stable N/A @@ -1218,7 +1223,7 @@ This list contains 1515 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Sep 12, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Sep 16, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1228,7 +1233,7 @@ This list contains 1515 plugins. :pypi:`pytest-server` test server exec cmd Sep 09, 2024 N/A N/A :pypi:`pytest-server-fixtures` Extensible server fixures for py.test Dec 19, 2023 5 - Production/Stable pytest :pypi:`pytest-serverless` Automatically mocks resources from serverless.yml in pytest using moto. May 09, 2022 4 - Beta N/A - :pypi:`pytest-servers` pytest servers Aug 15, 2024 3 - Alpha pytest>=6.2 + :pypi:`pytest-servers` pytest servers Sep 17, 2024 3 - Alpha pytest>=6.2 :pypi:`pytest-service` Aug 06, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-services` Services plugin for pytest testing framework Oct 30, 2020 6 - Mature N/A :pypi:`pytest-session2file` pytest-session2file (aka: pytest-session_to_file for v0.1.0 - v0.1.2) is a py.test plugin for capturing and saving to file the stdout of py.test. Jan 26, 2021 3 - Alpha pytest @@ -1237,7 +1242,7 @@ This list contains 1515 plugins. :pypi:`pytest-setupinfo` Displaying setup info during pytest command run Jan 23, 2023 N/A N/A :pypi:`pytest-sftpserver` py.test plugin to locally test sftp server connections. Sep 16, 2019 4 - Beta N/A :pypi:`pytest-shard` Dec 11, 2020 4 - Beta pytest - :pypi:`pytest-shared-session-scope` Pytest session-scoped fixture that works with xdist Sep 08, 2024 N/A pytest>=7 + :pypi:`pytest-shared-session-scope` Pytest session-scoped fixture that works with xdist Sep 19, 2024 N/A pytest>=7.0.0 :pypi:`pytest-share-hdf` Plugin to save test data in HDF files and retrieve them for comparison Sep 21, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-sharkreport` this is pytest report plugin. Jul 11, 2022 N/A pytest (>=3.5) :pypi:`pytest-shell` A pytest plugin to help with testing shell scripts / black box commands Mar 27, 2022 N/A N/A @@ -1298,7 +1303,7 @@ This list contains 1515 plugins. :pypi:`pytest-split-tests` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Forked from Mark Adams' original project pytest-test-groups. Jul 30, 2021 5 - Production/Stable pytest (>=2.5) :pypi:`pytest-split-tests-tresorit` Feb 22, 2021 1 - Planning N/A :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Sep 04, 2024 N/A pytest<8,>5.4.0 - :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Jul 10, 2024 N/A N/A + :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Sep 19, 2024 N/A N/A :pypi:`pytest-splunk-env` pytest fixtures for interaction with Splunk Enterprise and Splunk Cloud Oct 22, 2020 N/A pytest (>=6.1.1,<7.0.0) :pypi:`pytest-sqitch` sqitch for pytest Apr 06, 2020 4 - Beta N/A :pypi:`pytest-sqlalchemy` pytest plugin with sqlalchemy related fixtures Mar 13, 2018 3 - Alpha N/A @@ -1498,6 +1503,7 @@ This list contains 1515 plugins. :pypi:`pytest-wdl` Pytest plugin for testing WDL workflows. Nov 17, 2020 5 - Production/Stable N/A :pypi:`pytest-web3-data` A pytest plugin to fetch test data from IPFS HTTP gateways during pytest execution. Oct 04, 2023 4 - Beta pytest :pypi:`pytest-webdriver` Selenium webdriver fixture for py.test May 28, 2019 5 - Production/Stable pytest + :pypi:`pytest-webstage` Test web apps with pytest Sep 20, 2024 N/A pytest<9.0,>=7.0 :pypi:`pytest-webtest-extras` Pytest plugin to enhance pytest-html and allure reports of webtest projects by adding screenshots, comments and webpage sources. Jun 08, 2024 N/A pytest>=7.0.0 :pypi:`pytest-wetest` Welian API Automation test framework pytest plugin Nov 10, 2018 4 - Beta N/A :pypi:`pytest-when` Utility which makes mocking more readable and controllable May 28, 2024 N/A pytest>=7.3.1 @@ -1554,6 +1560,13 @@ This list contains 1515 plugins. .. only:: latex + :pypi:`databricks-labs-pytester` + *last release*: Sep 19, 2024, + *status*: 4 - Beta, + *requires*: pytest>=8.3 + + Python Testing for Databricks + :pypi:`logassert` *last release*: May 20, 2022, *status*: 5 - Production/Stable, @@ -1806,6 +1819,13 @@ This list contains 1515 plugins. Static code checks used at Alphamoon + :pypi:`pytest-amaranth-sim` + *last release*: Sep 21, 2024, + *status*: 4 - Beta, + *requires*: pytest>=6.2.0 + + Fixture to automate running Amaranth simulations + :pypi:`pytest-analyzer` *last release*: Feb 21, 2024, *status*: N/A, @@ -2395,7 +2415,7 @@ This list contains 1515 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Sep 13, 2024, + *last release*: Sep 18, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -2801,7 +2821,7 @@ This list contains 1515 plugins. Pytest plugin with server for catching HTTP requests. :pypi:`pytest-celery` - *last release*: Aug 12, 2024, + *last release*: Sep 20, 2024, *status*: 4 - Beta, *requires*: N/A @@ -3151,7 +3171,7 @@ This list contains 1515 plugins. pytest plugin to run pycodestyle :pypi:`pytest-codspeed` - *last release*: Mar 19, 2024, + *last release*: Sep 20, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=3.8 @@ -3375,9 +3395,9 @@ This list contains 1515 plugins. Too many faillure, less tests. :pypi:`pytest-cpp` - *last release*: Nov 01, 2023, + *last release*: Sep 18, 2024, *status*: 5 - Production/Stable, - *requires*: pytest >=7.0 + *requires*: pytest Use pytest's runner to discover and execute C++ tests @@ -4663,9 +4683,9 @@ This list contains 1515 plugins. Improvements for pytest (rejected upstream) :pypi:`pytest-env` - *last release*: Sep 07, 2024, + *last release*: Sep 17, 2024, *status*: 5 - Production/Stable, - *requires*: pytest>=8.3.2 + *requires*: pytest>=8.3.3 pytest plugin that allows you to add environment variables. @@ -4760,8 +4780,8 @@ This list contains 1515 plugins. Applies eventlet monkey-patch as a pytest plugin. - :pypi:`pytest-evm` - *last release*: Apr 22, 2024, + :pypi:`pytest_evm` + *last release*: Sep 15, 2024, *status*: 4 - Beta, *requires*: pytest<9.0.0,>=8.1.1 @@ -4782,7 +4802,14 @@ This list contains 1515 plugins. Pytest plugin for testing examples in docstrings and markdown files. :pypi:`pytest-exasol-backend` - *last release*: Aug 23, 2024, + *last release*: Sep 18, 2024, + *status*: N/A, + *requires*: pytest<9,>=7 + + + + :pypi:`pytest-exasol-extension` + *last release*: Sep 18, 2024, *status*: N/A, *requires*: pytest<9,>=7 @@ -4901,9 +4928,9 @@ This list contains 1515 plugins. A Pytest plugin to ignore certain marked tests by default :pypi:`pytest-exploratory` - *last release*: Aug 18, 2023, + *last release*: Sep 18, 2024, *status*: N/A, - *requires*: pytest (>=6.2) + *requires*: pytest>=6.2 Interactive console for pytest. @@ -5643,7 +5670,7 @@ This list contains 1515 plugins. py.test plugin to ignore the same files as git :pypi:`pytest-gitlab` - *last release*: Sep 06, 2024, + *last release*: Sep 18, 2024, *status*: N/A, *requires*: N/A @@ -5881,7 +5908,7 @@ This list contains 1515 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Sep 07, 2024, + *last release*: Sep 17, 2024, *status*: 3 - Alpha, *requires*: pytest==8.3.1 @@ -6014,9 +6041,9 @@ This list contains 1515 plugins. Fixture "http" for http requests :pypi:`pytest-httpbin` - *last release*: May 08, 2023, + *last release*: Sep 18, 2024, *status*: 5 - Production/Stable, - *requires*: pytest ; extra == 'test' + *requires*: pytest; extra == "test" Easily test your HTTP library against a local copy of httpbin @@ -6056,9 +6083,9 @@ This list contains 1515 plugins. http_testing framework on top of pytest :pypi:`pytest-httpx` - *last release*: Feb 21, 2024, + *last release*: Sep 20, 2024, *status*: 5 - Production/Stable, - *requires*: pytest <9,>=7 + *requires*: pytest==8.* Send responses to httpx. @@ -6343,7 +6370,7 @@ This list contains 1515 plugins. Pytest plugin for intercepting outgoing connection requests during pytest run. :pypi:`pytest-interface-tester` - *last release*: Aug 09, 2024, + *last release*: Sep 18, 2024, *status*: 4 - Beta, *requires*: pytest @@ -6391,6 +6418,13 @@ This list contains 1515 plugins. + :pypi:`pytest-isolate-mpi` + *last release*: Sep 18, 2024, + *status*: 4 - Beta, + *requires*: pytest>=5 + + pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner + :pypi:`pytest-isort` *last release*: Mar 05, 2024, *status*: 5 - Production/Stable, @@ -7239,7 +7273,7 @@ This list contains 1515 plugins. Custom metrics report for pytest :pypi:`pytest-mh` - *last release*: Aug 02, 2024, + *last release*: Sep 19, 2024, *status*: N/A, *requires*: pytest @@ -7351,7 +7385,7 @@ This list contains 1515 plugins. An in-memory mock of a Redis server that runs in a separate thread. This is to be used for unit-tests that require a Redis database. :pypi:`pytest-mock-resources` - *last release*: Jun 20, 2024, + *last release*: Sep 17, 2024, *status*: N/A, *requires*: pytest>=1.0 @@ -7834,9 +7868,9 @@ This list contains 1515 plugins. A pytest plugin for simplifying ODC database tests :pypi:`pytest-odoo` - *last release*: Jul 06, 2023, + *last release*: Sep 20, 2024, *status*: 4 - Beta, - *requires*: pytest (>=7.2.0) + *requires*: pytest<8.0.0,>=7.2.0 py.test plugin to run Odoo tests @@ -8057,6 +8091,13 @@ This list contains 1515 plugins. Simpler PyTest parametrization + :pypi:`pytest-parametrize` + *last release*: Sep 16, 2024, + *status*: 5 - Production/Stable, + *requires*: pytest<9.0.0,>=8.3.0 + + pytest decorator for parametrizing test cases in a dict-way + :pypi:`pytest-parametrize-cases` *last release*: Mar 13, 2022, *status*: N/A, @@ -8562,7 +8603,7 @@ This list contains 1515 plugins. Minitest-style test colors :pypi:`pytest-print` - *last release*: Sep 08, 2024, + *last release*: Sep 17, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=8.3.2 @@ -9766,7 +9807,7 @@ This list contains 1515 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Sep 12, 2024, + *last release*: Sep 16, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9843,7 +9884,7 @@ This list contains 1515 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Sep 12, 2024, + *last release*: Sep 16, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9913,7 +9954,7 @@ This list contains 1515 plugins. Automatically mocks resources from serverless.yml in pytest using moto. :pypi:`pytest-servers` - *last release*: Aug 15, 2024, + *last release*: Sep 17, 2024, *status*: 3 - Alpha, *requires*: pytest>=6.2 @@ -9976,9 +10017,9 @@ This list contains 1515 plugins. :pypi:`pytest-shared-session-scope` - *last release*: Sep 08, 2024, + *last release*: Sep 19, 2024, *status*: N/A, - *requires*: pytest>=7 + *requires*: pytest>=7.0.0 Pytest session-scoped fixture that works with xdist @@ -10403,7 +10444,7 @@ This list contains 1515 plugins. A Dynamic test tool for Splunk Apps and Add-ons :pypi:`pytest-splunk-addon-ui-smartx` - *last release*: Jul 10, 2024, + *last release*: Sep 19, 2024, *status*: N/A, *requires*: N/A @@ -11802,6 +11843,13 @@ This list contains 1515 plugins. Selenium webdriver fixture for py.test + :pypi:`pytest-webstage` + *last release*: Sep 20, 2024, + *status*: N/A, + *requires*: pytest<9.0,>=7.0 + + Test web apps with pytest + :pypi:`pytest-webtest-extras` *last release*: Jun 08, 2024, *status*: N/A, From 3231199a092f81c9aac5aca57b2d5452f36b6161 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 12:11:22 +0200 Subject: [PATCH 077/445] build(deps): Bump pytest-bdd in /testing/plugins_integration (#12835) Bumps [pytest-bdd](https://github.com/pytest-dev/pytest-bdd) from 7.2.0 to 7.3.0. - [Release notes](https://github.com/pytest-dev/pytest-bdd/releases) - [Changelog](https://github.com/pytest-dev/pytest-bdd/blob/master/CHANGES.rst) - [Commits](https://github.com/pytest-dev/pytest-bdd/compare/7.2.0...7.3.0) --- updated-dependencies: - dependency-name: pytest-bdd dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 379b4ffa5e8..5e153444847 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,7 +1,7 @@ anyio[curio,trio]==4.4.0 django==5.1.1 pytest-asyncio==0.24.0 -pytest-bdd==7.2.0 +pytest-bdd==7.3.0 pytest-cov==5.0.0 pytest-django==4.9.0 pytest-flakes==4.0.5 From 1413f45b6f467d66b877c007104b99544e356ad0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 12:11:54 +0200 Subject: [PATCH 078/445] build(deps): Bump anyio[curio,trio] in /testing/plugins_integration (#12834) Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 4.4.0 to 4.6.0. - [Release notes](https://github.com/agronholm/anyio/releases) - [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst) - [Commits](https://github.com/agronholm/anyio/compare/4.4.0...4.6.0) --- updated-dependencies: - dependency-name: anyio[curio,trio] dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 5e153444847..9ee706fdc70 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,4 +1,4 @@ -anyio[curio,trio]==4.4.0 +anyio[curio,trio]==4.6.0 django==5.1.1 pytest-asyncio==0.24.0 pytest-bdd==7.3.0 From 25401d0b1d1b0f89e4e58fc5aab0f18e3f3e5984 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 09:07:54 -0300 Subject: [PATCH 079/445] build(deps): Bump pypa/gh-action-pypi-publish from 1.10.1 to 1.10.2 (#12832) Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.1 to 1.10.2. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.10.1...v1.10.2) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index cb053552ccd..f2e2dd4a407 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -54,7 +54,7 @@ jobs: path: dist - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@v1.10.1 + uses: pypa/gh-action-pypi-publish@v1.10.2 with: attestations: true From 245e44203952c5c1149016a18475799793cb8b5c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 09:08:30 -0300 Subject: [PATCH 080/445] build(deps): Bump peter-evans/create-pull-request from 7.0.2 to 7.0.5 (#12833) Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 7.0.2 to 7.0.5. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/d121e62763d8cc35b5fb1710e887d6e69a52d3a4...5e914681df9dc83aa4e4905692ca88beb2f9e91f) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/update-plugin-list.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-plugin-list.yml b/.github/workflows/update-plugin-list.yml index 3029436ce79..0c76b91843c 100644 --- a/.github/workflows/update-plugin-list.yml +++ b/.github/workflows/update-plugin-list.yml @@ -47,7 +47,7 @@ jobs: - name: Create Pull Request id: pr - uses: peter-evans/create-pull-request@d121e62763d8cc35b5fb1710e887d6e69a52d3a4 + uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f with: commit-message: '[automated] Update plugin list' author: 'pytest bot ' From fda1bbd187d99e9b076eaf4b2b2a03f1c242f8d4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2024 06:50:09 +0200 Subject: [PATCH 081/445] [pre-commit.ci] pre-commit autoupdate (#12838) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.5 → v0.6.7](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.5...v0.6.7) - [github.com/tox-dev/pyproject-fmt: 2.2.3 → 2.2.4](https://github.com/tox-dev/pyproject-fmt/compare/2.2.3...2.2.4) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b6f2a16424a..b4d10558b88 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.5" + rev: "v0.6.7" hooks: - id: ruff args: ["--fix"] @@ -46,7 +46,7 @@ repos: # on <3.11 - exceptiongroup>=1.0.0rc8 - repo: https://github.com/tox-dev/pyproject-fmt - rev: "2.2.3" + rev: "2.2.4" hooks: - id: pyproject-fmt # https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version From 68ac4a12e362fedfec7b963739571c7c326b61da Mon Sep 17 00:00:00 2001 From: sven <42868792+FreerGit@users.noreply.github.com> Date: Tue, 24 Sep 2024 14:28:10 +0200 Subject: [PATCH 082/445] `collect_imported_tests` option --- changelog/12749.feature.rst | 4 +- src/_pytest/main.py | 30 ++++++- src/_pytest/python.py | 6 -- testing/test_discover_imports.py | 144 ++++++++++++++++++++++--------- 4 files changed, 133 insertions(+), 51 deletions(-) diff --git a/changelog/12749.feature.rst b/changelog/12749.feature.rst index 138a5bc7914..798d02c6e49 100644 --- a/changelog/12749.feature.rst +++ b/changelog/12749.feature.rst @@ -1,3 +1,3 @@ -Add :confval:`discover_imports`, when disabled (default) will make sure to not consider classes which are imported by a test file and starts with Test. +Add :confval:`collect_imported_tests`, when enabled (default is disabled) will make sure to not consider classes/functions which are imported by a test file and contains Test/test_*/*_test. --- by :user:`FreerGit` \ No newline at end of file +-- by :user:`FreerGit` diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 4887d336b2d..611ce033ea9 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -79,8 +79,9 @@ def pytest_addoption(parser: Parser) -> None: default=[], ) parser.addini( - "discover_imports", - "Whether to discover tests in imported modules outside `testpaths`", + "collect_imported_tests", + "Whether to collect tests in imported modules outside `testpaths`", + type="bool", default=False, ) group = parser.getgroup("general", "Running and selection options") @@ -963,9 +964,22 @@ def collect(self) -> Iterator[nodes.Item | nodes.Collector]: self.trace.root.indent -= 1 def genitems(self, node: nodes.Item | nodes.Collector) -> Iterator[nodes.Item]: + import inspect + + from _pytest.python import Class + from _pytest.python import Function + from _pytest.python import Module + self.trace("genitems", node) if isinstance(node, nodes.Item): node.ihook.pytest_itemcollected(item=node) + if self.config.getini("collect_imported_tests"): + if isinstance(node.parent, Module) and isinstance(node, Function): + if inspect.isfunction(node._getobj()): + fn_defined_at = node._getobj().__module__ + in_module = node.parent._getobj().__name__ + if fn_defined_at != in_module: + return yield node else: assert isinstance(node, nodes.Collector) @@ -973,6 +987,18 @@ def genitems(self, node: nodes.Item | nodes.Collector) -> Iterator[nodes.Item]: # For backward compat, dedup only applies to files. handle_dupes = not (keepduplicates and isinstance(node, nodes.File)) rep, duplicate = self._collect_one_node(node, handle_dupes) + + if self.config.getini("collect_imported_tests"): + for subnode in rep.result: + if isinstance(subnode, Class) and isinstance( + subnode.parent, Module + ): + if inspect.isclass(subnode._getobj()): + class_defined_at = subnode._getobj().__module__ + in_module = subnode.parent._getobj().__name__ + if class_defined_at != in_module: + rep.result.remove(subnode) + if duplicate and not keepduplicates: return if rep.passed: diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 9467b26fd02..9c54dd20f80 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -741,12 +741,6 @@ def newinstance(self): return self.obj() def collect(self) -> Iterable[nodes.Item | nodes.Collector]: - if self.config.getini("discover_imports") == ("false" or False): - paths = self.config.getini("testpaths") - class_file = inspect.getfile(self.obj) - if not any(string in class_file for string in paths): - return [] - if not safe_getattr(self.obj, "__test__", True): return [] if hasinit(self.obj): diff --git a/testing/test_discover_imports.py b/testing/test_discover_imports.py index 829b614ed46..e328d16a182 100644 --- a/testing/test_discover_imports.py +++ b/testing/test_discover_imports.py @@ -1,29 +1,31 @@ -import pytest +from __future__ import annotations + import textwrap -def test_discover_imports_enabled(pytester): +from _pytest.pytester import Pytester + + +def run_import_class_test(pytester: Pytester, passed: int = 0, errors: int = 0) -> None: src_dir = pytester.mkdir("src") tests_dir = pytester.mkdir("tests") - pytester.makeini(""" - [pytest] - testpaths = "tests" - discover_imports = true - """) - src_file = src_dir / "foo.py" - src_file.write_text(textwrap.dedent("""\ - class TestClass(object): + src_file.write_text( + textwrap.dedent("""\ + class Testament(object): def __init__(self): super().__init__() + self.collections = ["stamp", "coin"] - def test_foobar(self): - return true - """ - ), encoding="utf-8") + def personal_property(self): + return [f"my {x} collection" for x in self.collections] + """), + encoding="utf-8", + ) test_file = tests_dir / "foo_test.py" - test_file.write_text(textwrap.dedent("""\ + test_file.write_text( + textwrap.dedent("""\ import sys import os @@ -32,42 +34,78 @@ def test_foobar(self): parent_dir = os.path.abspath(os.path.join(current_dir, '..')) sys.path.append(parent_dir) - from src.foo import TestClass + from src.foo import Testament class TestDomain: def test_testament(self): - testament = TestClass() - pass - """), encoding="utf-8") + testament = Testament() + assert testament.personal_property() + """), + encoding="utf-8", + ) result = pytester.runpytest() - result.assert_outcomes(errors=1) + result.assert_outcomes(passed=passed, errors=errors) -def test_discover_imports_disabled(pytester): - - src_dir = pytester.mkdir("src") - tests_dir = pytester.mkdir("tests") + +def test_collect_imports_disabled(pytester: Pytester) -> None: + pytester.makeini(""" + [pytest] + testpaths = "tests" + collect_imported_tests = false + """) + + run_import_class_test(pytester, errors=1) + + +def test_collect_imports_default(pytester: Pytester) -> None: + pytester.makeini(""" + [pytest] + testpaths = "tests" + """) + + run_import_class_test(pytester, errors=1) + + +def test_collect_imports_enabled(pytester: Pytester) -> None: pytester.makeini(""" [pytest] testpaths = "tests" - discover_imports = false + collect_imported_tests = true """) + run_import_class_test(pytester, passed=1) + + +def run_import_functions_test( + pytester: Pytester, passed: int, errors: int, failed: int +) -> None: + src_dir = pytester.mkdir("src") + tests_dir = pytester.mkdir("tests") + src_file = src_dir / "foo.py" - src_file.write_text(textwrap.dedent("""\ - class Testament(object): - def __init__(self): - super().__init__() - self.collections = ["stamp", "coin"] + # Note that these "tests" are should _not_ be treated as tests. + # They are normal functions that happens to have test_* or *_test in the name. + # Thus should _not_ be collected! + src_file.write_text( + textwrap.dedent("""\ + def test_function(): + some_random_computation = 5 + return some_random_computation - def personal_property(self): - return [f"my {x} collection" for x in self.collections] - """ - ), encoding="utf-8") + def test_bar(): + pass + """), + encoding="utf-8", + ) test_file = tests_dir / "foo_test.py" - test_file.write_text(textwrap.dedent("""\ + + # Inferred from the comment above, this means that there is _only_ one actual test + # which should result in only 1 passing test being ran. + test_file.write_text( + textwrap.dedent("""\ import sys import os @@ -76,13 +114,37 @@ def personal_property(self): parent_dir = os.path.abspath(os.path.join(current_dir, '..')) sys.path.append(parent_dir) - from src.foo import Testament + from src.foo import * class TestDomain: - def test_testament(self): - testament = Testament() - assert testament.personal_property() - """), encoding="utf-8") + def test_important(self): + res = test_function() + if res == 5: + pass + + """), + encoding="utf-8", + ) result = pytester.runpytest() - result.assert_outcomes(passed=1) \ No newline at end of file + result.assert_outcomes(passed=passed, errors=errors, failed=failed) + + +def test_collect_function_imports_enabled(pytester: Pytester) -> None: + pytester.makeini(""" + [pytest] + testpaths = "tests" + collect_imported_tests = true + """) + + run_import_functions_test(pytester, passed=1, errors=0, failed=0) + + +def test_collect_function_imports_disabled(pytester: Pytester) -> None: + pytester.makeini(""" + [pytest] + testpaths = "tests" + collect_imported_tests = false + """) + + run_import_functions_test(pytester, passed=2, errors=0, failed=1) From 326faa25f4e776f082eea5603d84b0812b57773c Mon Sep 17 00:00:00 2001 From: Pradeep Kumar Date: Wed, 25 Sep 2024 18:29:03 +0530 Subject: [PATCH 083/445] Docs: improve "How to capture stdout/stderr output" (#12840) Improve the section by reordering how the topics about text/binary capture are presented, and add proper links to the fixtures. Co-authored-by: Bruno Oliveira --- doc/en/how-to/capture-stdout-stderr.rst | 42 +++++++++---------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/doc/en/how-to/capture-stdout-stderr.rst b/doc/en/how-to/capture-stdout-stderr.rst index 5e23f0c024e..9f7ddce3499 100644 --- a/doc/en/how-to/capture-stdout-stderr.rst +++ b/doc/en/how-to/capture-stdout-stderr.rst @@ -106,9 +106,10 @@ of the failing function and hide the other one: Accessing captured output from a test function --------------------------------------------------- -The ``capsys``, ``capsysbinary``, ``capfd``, and ``capfdbinary`` fixtures -allow access to stdout/stderr output created during test execution. Here is -an example test function that performs some output related checks: +The :fixture:`capsys`, :fixture:`capsysbinary`, :fixture:`capfd`, and :fixture:`capfdbinary` fixtures +allow access to ``stdout``/``stderr`` output created during test execution. + +Here is an example test function that performs some output related checks: .. code-block:: python @@ -125,40 +126,27 @@ an example test function that performs some output related checks: The ``readouterr()`` call snapshots the output so far - and capturing will be continued. After the test function finishes the original streams will -be restored. Using ``capsys`` this way frees your +be restored. Using :fixture:`capsys` this way frees your test from having to care about setting/resetting output streams and also interacts well with pytest's own per-test capturing. -If you want to capture on filedescriptor level you can use -the ``capfd`` fixture which offers the exact -same interface but allows to also capture output from -libraries or subprocesses that directly write to operating -system level output streams (FD1 and FD2). - - - The return value from ``readouterr`` changed to a ``namedtuple`` with two attributes, ``out`` and ``err``. - - -If the code under test writes non-textual data, you can capture this using -the ``capsysbinary`` fixture which instead returns ``bytes`` from +If the code under test writes non-textual data (``bytes``), you can capture this using +the :fixture:`capsysbinary` fixture which instead returns ``bytes`` from the ``readouterr`` method. +If you want to capture at the file descriptor level you can use +the :fixture:`capfd` fixture which offers the exact +same interface but allows to also capture output from +libraries or subprocesses that directly write to operating +system level output streams (FD1 and FD2). Similarly to :fixture:`capsysbinary`, :fixture:`capfdbinary` can be +used to capture ``bytes`` at the file descriptor level. - -If the code under test writes non-textual data, you can capture this using -the ``capfdbinary`` fixture which instead returns ``bytes`` from -the ``readouterr`` method. The ``capfdbinary`` fixture operates on the -filedescriptor level. - - - - -To temporarily disable capture within a test, both ``capsys`` -and ``capfd`` have a ``disabled()`` method that can be used +To temporarily disable capture within a test, the capture fixtures +have a ``disabled()`` method that can be used as a context manager, disabling capture inside the ``with`` block: .. code-block:: python From 6486c3f3a858a0c8043f5c3f7c24297b82a0abe4 Mon Sep 17 00:00:00 2001 From: dongfangtianyu <7629022+dongfangtianyu@users.noreply.github.com> Date: Thu, 26 Sep 2024 09:08:42 +0800 Subject: [PATCH 084/445] Fix KeyError with importlib mode (directories with same name) (#12752) Directories inside a namespace package with the same name as the namespace package would cause a `KeyError` with `--import-mode=importlib`. Fixes #12592 Co-authored-by: Bruno Oliveira --- changelog/12592.bugfix.rst | 1 + src/_pytest/pathlib.py | 131 +++++++++++++++++++++++++++---------- testing/test_pathlib.py | 74 ++++++++++++++++++++- 3 files changed, 171 insertions(+), 35 deletions(-) create mode 100644 changelog/12592.bugfix.rst diff --git a/changelog/12592.bugfix.rst b/changelog/12592.bugfix.rst new file mode 100644 index 00000000000..605783bcab4 --- /dev/null +++ b/changelog/12592.bugfix.rst @@ -0,0 +1 @@ +Fixed :class:`KeyError` crash when using ``--import-mode=importlib`` in a directory layout where a directory contains a child directory with the same name. diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index 81e52ea729d..dd36559ce1b 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -10,6 +10,7 @@ import fnmatch from functools import partial from importlib.machinery import ModuleSpec +from importlib.machinery import PathFinder import importlib.util import itertools import os @@ -37,8 +38,12 @@ from _pytest.warning_types import PytestWarning -LOCK_TIMEOUT = 60 * 60 * 24 * 3 +if sys.version_info < (3, 11): + from importlib._bootstrap_external import _NamespaceLoader as NamespaceLoader +else: + from importlib.machinery import NamespaceLoader +LOCK_TIMEOUT = 60 * 60 * 24 * 3 _AnyPurePath = TypeVar("_AnyPurePath", bound=PurePath) @@ -611,13 +616,78 @@ def _import_module_using_spec( module_name: str, module_path: Path, module_location: Path, *, insert_modules: bool ) -> ModuleType | None: """ - Tries to import a module by its canonical name, path to the .py file, and its - parent location. + Tries to import a module by its canonical name, path, and its parent location. + + :param module_name: + The expected module name, will become the key of `sys.modules`. + + :param module_path: + The file path of the module, for example `/foo/bar/test_demo.py`. + If module is a package, pass the path to the `__init__.py` of the package. + If module is a namespace package, pass directory path. + + :param module_location: + The parent location of the module. + If module is a package, pass the directory containing the `__init__.py` file. :param insert_modules: - If True, will call insert_missing_modules to create empty intermediate modules - for made-up module names (when importing test files not reachable from sys.path). + If True, will call `insert_missing_modules` to create empty intermediate modules + with made-up module names (when importing test files not reachable from `sys.path`). + + Example 1 of parent_module_*: + + module_name: "a.b.c.demo" + module_path: Path("a/b/c/demo.py") + module_location: Path("a/b/c/") + if "a.b.c" is package ("a/b/c/__init__.py" exists), then + parent_module_name: "a.b.c" + parent_module_path: Path("a/b/c/__init__.py") + parent_module_location: Path("a/b/c/") + else: + parent_module_name: "a.b.c" + parent_module_path: Path("a/b/c") + parent_module_location: Path("a/b/") + + Example 2 of parent_module_*: + + module_name: "a.b.c" + module_path: Path("a/b/c/__init__.py") + module_location: Path("a/b/c/") + if "a.b" is package ("a/b/__init__.py" exists), then + parent_module_name: "a.b" + parent_module_path: Path("a/b/__init__.py") + parent_module_location: Path("a/b/") + else: + parent_module_name: "a.b" + parent_module_path: Path("a/b/") + parent_module_location: Path("a/") """ + # Attempt to import the parent module, seems is our responsibility: + # https://github.com/python/cpython/blob/73906d5c908c1e0b73c5436faeff7d93698fc074/Lib/importlib/_bootstrap.py#L1308-L1311 + parent_module_name, _, name = module_name.rpartition(".") + parent_module: ModuleType | None = None + if parent_module_name: + parent_module = sys.modules.get(parent_module_name) + if parent_module is None: + # Get parent_location based on location, get parent_path based on path. + if module_path.name == "__init__.py": + # If the current module is in a package, + # need to leave the package first and then enter the parent module. + parent_module_path = module_path.parent.parent + else: + parent_module_path = module_path.parent + + if (parent_module_path / "__init__.py").is_file(): + # If the parent module is a package, loading by __init__.py file. + parent_module_path = parent_module_path / "__init__.py" + + parent_module = _import_module_using_spec( + parent_module_name, + parent_module_path, + parent_module_path.parent, + insert_modules=insert_modules, + ) + # Checking with sys.meta_path first in case one of its hooks can import this module, # such as our own assertion-rewrite hook. for meta_importer in sys.meta_path: @@ -627,36 +697,18 @@ def _import_module_using_spec( if spec_matches_module_path(spec, module_path): break else: - spec = importlib.util.spec_from_file_location(module_name, str(module_path)) + loader = None + if module_path.is_dir(): + # The `spec_from_file_location` matches a loader based on the file extension by default. + # For a namespace package, need to manually specify a loader. + loader = NamespaceLoader(name, module_path, PathFinder()) + + spec = importlib.util.spec_from_file_location( + module_name, str(module_path), loader=loader + ) if spec_matches_module_path(spec, module_path): assert spec is not None - # Attempt to import the parent module, seems is our responsibility: - # https://github.com/python/cpython/blob/73906d5c908c1e0b73c5436faeff7d93698fc074/Lib/importlib/_bootstrap.py#L1308-L1311 - parent_module_name, _, name = module_name.rpartition(".") - parent_module: ModuleType | None = None - if parent_module_name: - parent_module = sys.modules.get(parent_module_name) - if parent_module is None: - # Find the directory of this module's parent. - parent_dir = ( - module_path.parent.parent - if module_path.name == "__init__.py" - else module_path.parent - ) - # Consider the parent module path as its __init__.py file, if it has one. - parent_module_path = ( - parent_dir / "__init__.py" - if (parent_dir / "__init__.py").is_file() - else parent_dir - ) - parent_module = _import_module_using_spec( - parent_module_name, - parent_module_path, - parent_dir, - insert_modules=insert_modules, - ) - # Find spec and import this module. mod = importlib.util.module_from_spec(spec) sys.modules[module_name] = mod @@ -675,10 +727,21 @@ def _import_module_using_spec( def spec_matches_module_path(module_spec: ModuleSpec | None, module_path: Path) -> bool: """Return true if the given ModuleSpec can be used to import the given module path.""" - if module_spec is None or module_spec.origin is None: + if module_spec is None: return False - return Path(module_spec.origin) == module_path + if module_spec.origin: + return Path(module_spec.origin) == module_path + + # Compare the path with the `module_spec.submodule_Search_Locations` in case + # the module is part of a namespace package. + # https://docs.python.org/3/library/importlib.html#importlib.machinery.ModuleSpec.submodule_search_locations + if module_spec.submodule_search_locations: # can be None. + for path in module_spec.submodule_search_locations: + if Path(path) == module_path: + return True + + return False # Implement a special _is_same function on Windows which returns True if the two filenames diff --git a/testing/test_pathlib.py b/testing/test_pathlib.py index 7c0a0e03d76..62359303f3b 100644 --- a/testing/test_pathlib.py +++ b/testing/test_pathlib.py @@ -17,7 +17,9 @@ from typing import Sequence import unittest.mock +from _pytest.config import ExitCode from _pytest.monkeypatch import MonkeyPatch +from _pytest.pathlib import _import_module_using_spec from _pytest.pathlib import bestrelpath from _pytest.pathlib import commonpath from _pytest.pathlib import compute_module_name @@ -36,6 +38,7 @@ from _pytest.pathlib import resolve_package_path from _pytest.pathlib import resolve_pkg_root_and_module_name from _pytest.pathlib import safe_exists +from _pytest.pathlib import spec_matches_module_path from _pytest.pathlib import symlink_or_skip from _pytest.pathlib import visit from _pytest.pytester import Pytester @@ -416,7 +419,7 @@ def test_no_meta_path_found( del sys.modules[module.__name__] monkeypatch.setattr( - importlib.util, "spec_from_file_location", lambda *args: None + importlib.util, "spec_from_file_location", lambda *args, **kwargs: None ) with pytest.raises(ImportError): import_path( @@ -780,6 +783,62 @@ def test_insert_missing_modules( insert_missing_modules(modules, "") assert modules == {} + @pytest.mark.parametrize("b_is_package", [True, False]) + @pytest.mark.parametrize("insert_modules", [True, False]) + def test_import_module_using_spec( + self, b_is_package, insert_modules, tmp_path: Path + ): + """ + Verify that `_import_module_using_spec` can obtain a spec based on the path, thereby enabling the import. + When importing, not only the target module is imported, but also the parent modules are recursively imported. + """ + file_path = tmp_path / "a/b/c/demo.py" + file_path.parent.mkdir(parents=True) + file_path.write_text("my_name='demo'", encoding="utf-8") + + if b_is_package: + (tmp_path / "a/b/__init__.py").write_text( + "my_name='b.__init__'", encoding="utf-8" + ) + + mod = _import_module_using_spec( + "a.b.c.demo", + file_path, + file_path.parent, + insert_modules=insert_modules, + ) + + # target module is imported + assert mod is not None + assert spec_matches_module_path(mod.__spec__, file_path) is True + + mod_demo = sys.modules["a.b.c.demo"] + assert "demo.py" in str(mod_demo) + assert mod_demo.my_name == "demo" # Imported and available for use + + # parent modules are recursively imported. + mod_a = sys.modules["a"] + mod_b = sys.modules["a.b"] + mod_c = sys.modules["a.b.c"] + + assert mod_a.b is mod_b + assert mod_a.b.c is mod_c + assert mod_a.b.c.demo is mod_demo + + assert "namespace" in str(mod_a).lower() + assert "namespace" in str(mod_c).lower() + + # Compatibility package and namespace package. + if b_is_package: + assert "namespace" not in str(mod_b).lower() + assert "__init__.py" in str(mod_b).lower() # Imported __init__.py + assert mod_b.my_name == "b.__init__" # Imported and available for use + + else: + assert "namespace" in str(mod_b).lower() + with pytest.raises(AttributeError): # Not imported __init__.py + assert mod_b.my_name + def test_parent_contains_child_module_attribute( self, monkeypatch: MonkeyPatch, tmp_path: Path ): @@ -1542,6 +1601,19 @@ def test_full_ns_packages_without_init_files( ) == (tmp_path / "src/dist2", "ns.a.core.foo.m") +def test_ns_import_same_name_directory_12592( + tmp_path: Path, pytester: Pytester +) -> None: + """Regression for `--import-mode=importlib` with directory parent and child with same name (#12592).""" + y_dir = tmp_path / "x/y/y" + y_dir.mkdir(parents=True) + test_y = tmp_path / "x/y/test_y.py" + test_y.write_text("def test(): pass", encoding="UTF-8") + + result = pytester.runpytest("--import-mode=importlib", test_y) + assert result.ret == ExitCode.OK + + def test_is_importable(pytester: Pytester) -> None: pytester.syspathinsert() From 758a4bea481240a3e005620cd01a53d7ad1ee0a4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 07:26:49 -0300 Subject: [PATCH 085/445] [automated] Update plugin list (#12845) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 146 +++++++++++++++++++------------ 1 file changed, 89 insertions(+), 57 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 53028c576da..96ee4fc3830 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,14 +27,14 @@ please refer to `the update script =8.3 + :pypi:`databricks-labs-pytester` Python Testing for Databricks Sep 24, 2024 4 - Beta pytest>=8.3 :pypi:`logassert` Simple but powerful assertion and verification of logged lines. May 20, 2022 5 - Production/Stable N/A :pypi:`logot` Test whether your code is logging correctly 🪵 Mar 23, 2024 5 - Production/Stable pytest<9,>=7; extra == "pytest" :pypi:`nuts` Network Unit Testing System Jul 19, 2024 N/A pytest<8,>=7 @@ -130,7 +130,7 @@ This list contains 1521 plugins. :pypi:`pytest-automock` Pytest plugin for automatical mocks creation May 16, 2023 N/A pytest ; extra == 'dev' :pypi:`pytest-auto-parametrize` pytest plugin: avoid repeating arguments in parametrize Oct 02, 2016 3 - Alpha N/A :pypi:`pytest-autotest` This fixture provides a configured "driver" for Android Automated Testing, using uiautomator2. Aug 25, 2021 N/A pytest - :pypi:`pytest-aux` templates/examples and aux for pytest Aug 06, 2024 N/A N/A + :pypi:`pytest-aux` templates/examples and aux for pytest Sep 23, 2024 N/A N/A :pypi:`pytest-aviator` Aviator's Flakybot pytest plugin that automatically reruns flaky tests. Nov 04, 2022 4 - Beta pytest :pypi:`pytest-avoidance` Makes pytest skip tests that don not need rerunning May 23, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-aws` pytest plugin for testing AWS resource configurations Oct 04, 2017 4 - Beta N/A @@ -146,8 +146,8 @@ This list contains 1521 plugins. :pypi:`pytest-bandit-xayon` A bandit plugin for pytest Oct 17, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-base-url` pytest plugin for URL based testing Jan 31, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-batch-regression` A pytest plugin to repeat the entire test suite in batches. May 08, 2024 N/A pytest>=6.0.0 - :pypi:`pytest-bazel` A pytest runner with bazel support Jul 20, 2024 4 - Beta pytest - :pypi:`pytest-bdd` BDD for pytest Jun 04, 2024 6 - Mature pytest>=6.2.0 + :pypi:`pytest-bazel` A pytest runner with bazel support Sep 27, 2024 4 - Beta pytest + :pypi:`pytest-bdd` BDD for pytest Sep 26, 2024 6 - Mature pytest>=6.2.0 :pypi:`pytest-bdd-html` pytest plugin to display BDD info in HTML test report Nov 22, 2022 3 - Alpha pytest (!=6.0.0,>=5.0) :pypi:`pytest-bdd-ng` BDD for pytest Sep 01, 2024 4 - Beta pytest>=5.0 :pypi:`pytest-bdd-report` A pytest-bdd plugin for generating useful and informative BDD test reports Aug 26, 2024 N/A pytest>=7.1.3 @@ -210,7 +210,7 @@ This list contains 1521 plugins. :pypi:`pytest-caprng` A plugin that replays pRNG state on failure. May 02, 2018 4 - Beta N/A :pypi:`pytest-capture-deprecatedwarnings` pytest plugin to capture all deprecatedwarnings and put them in one file Apr 30, 2019 N/A N/A :pypi:`pytest-capture-warnings` pytest plugin to capture all warnings and put them in one file of your choice May 03, 2022 N/A pytest - :pypi:`pytest-cases` Separate test code from test cases in pytest. Apr 04, 2024 5 - Production/Stable N/A + :pypi:`pytest-cases` Separate test code from test cases in pytest. Sep 26, 2024 5 - Production/Stable N/A :pypi:`pytest-cassandra` Cassandra CCM Test Fixtures for pytest Nov 04, 2017 1 - Planning N/A :pypi:`pytest-catchlog` py.test plugin to catch log messages. This is a fork of pytest-capturelog. Jan 24, 2016 4 - Beta pytest (>=2.6) :pypi:`pytest-catch-server` Pytest plugin with server for catching HTTP requests. Dec 12, 2019 5 - Production/Stable N/A @@ -264,7 +264,7 @@ This list contains 1521 plugins. :pypi:`pytest-codegen` Automatically create pytest test signatures Aug 23, 2020 2 - Pre-Alpha N/A :pypi:`pytest-codeowners` Pytest plugin for selecting tests by GitHub CODEOWNERS. Mar 30, 2022 4 - Beta pytest (>=6.0.0) :pypi:`pytest-codestyle` pytest plugin to run pycodestyle Mar 23, 2020 3 - Alpha N/A - :pypi:`pytest-codspeed` Pytest plugin to create CodSpeed benchmarks Sep 20, 2024 5 - Production/Stable pytest>=3.8 + :pypi:`pytest-codspeed` Pytest plugin to create CodSpeed benchmarks Sep 27, 2024 5 - Production/Stable pytest>=3.8 :pypi:`pytest-collect-appoint-info` set your encoding Aug 03, 2023 N/A pytest :pypi:`pytest-collect-formatter` Formatter for pytest collect output Mar 29, 2021 5 - Production/Stable N/A :pypi:`pytest-collect-formatter2` Formatter for pytest collect output May 31, 2021 5 - Production/Stable N/A @@ -293,7 +293,7 @@ This list contains 1521 plugins. :pypi:`pytest-cover` Pytest plugin for measuring coverage. Forked from \`pytest-cov\`. Aug 01, 2015 5 - Production/Stable N/A :pypi:`pytest-coverage` Jun 17, 2015 N/A N/A :pypi:`pytest-coverage-context` Coverage dynamic context support for PyTest, including sub-processes Jun 28, 2023 4 - Beta N/A - :pypi:`pytest-coveragemarkers` Using pytest markers to track functional coverage and filtering of tests Aug 14, 2024 N/A pytest<8.0.0,>=7.1.2 + :pypi:`pytest-coveragemarkers` Using pytest markers to track functional coverage and filtering of tests Sep 27, 2024 N/A pytest<8.0.0,>=7.1.2 :pypi:`pytest-cov-exclude` Pytest plugin for excluding tests based on coverage data Apr 29, 2016 4 - Beta pytest (>=2.8.0,<2.9.0); extra == 'dev' :pypi:`pytest_covid` Too many faillure, less tests. Jun 24, 2020 N/A N/A :pypi:`pytest-cpp` Use pytest's runner to discover and execute C++ tests Sep 18, 2024 5 - Production/Stable pytest @@ -439,6 +439,7 @@ This list contains 1521 plugins. :pypi:`pytest-drf` A Django REST framework plugin for pytest. Jul 12, 2022 5 - Production/Stable pytest (>=3.7) :pypi:`pytest-drivings` Tool to allow webdriver automation to be ran locally or remotely Jan 13, 2021 N/A N/A :pypi:`pytest-drop-dup-tests` A Pytest plugin to drop duplicated tests during collection Mar 04, 2024 5 - Production/Stable pytest >=7 + :pypi:`pytest-dryci` Test caching plugin for pytest Sep 27, 2024 4 - Beta N/A :pypi:`pytest-dryrun` A Pytest plugin to ignore tests during collection without reporting them in the test summary. Jul 18, 2023 5 - Production/Stable pytest (>=7.4.0,<8.0.0) :pypi:`pytest-dummynet` A py.test plugin providing access to a dummynet. Dec 15, 2021 5 - Production/Stable pytest :pypi:`pytest-dump2json` A pytest plugin for dumping test results to json. Jun 29, 2015 N/A N/A @@ -494,14 +495,14 @@ This list contains 1521 plugins. :pypi:`pytest-ethereum` pytest-ethereum: Pytest library for ethereum projects. Jun 24, 2019 3 - Alpha pytest (==3.3.2); extra == 'dev' :pypi:`pytest-eucalyptus` Pytest Plugin for BDD Jun 28, 2022 N/A pytest (>=4.2.0) :pypi:`pytest-eventlet` Applies eventlet monkey-patch as a pytest plugin. Oct 04, 2021 N/A pytest ; extra == 'dev' - :pypi:`pytest_evm` The testing package containing tools to test Web3-based projects Sep 15, 2024 4 - Beta pytest<9.0.0,>=8.1.1 + :pypi:`pytest_evm` The testing package containing tools to test Web3-based projects Sep 23, 2024 4 - Beta pytest<9.0.0,>=8.1.1 :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Aug 13, 2024 4 - Beta pytest>=7 :pypi:`pytest-exasol-backend` Sep 18, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-extension` Sep 18, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-itde` Jul 01, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-saas` Aug 06, 2024 N/A pytest<9,>=7 - :pypi:`pytest-exasol-slc` Aug 29, 2024 N/A pytest<9,>=7 + :pypi:`pytest-exasol-slc` Sep 24, 2024 N/A pytest<9,>=7 :pypi:`pytest-excel` pytest plugin for generating excel reports Jun 18, 2024 5 - Production/Stable pytest>3.6 :pypi:`pytest-exceptional` Better exceptions Mar 16, 2017 4 - Beta N/A :pypi:`pytest-exception-script` Walk your code through exception script to check it's resiliency to failures. Aug 04, 2020 3 - Alpha pytest @@ -599,6 +600,7 @@ This list contains 1521 plugins. :pypi:`pytest-funparam` An alternative way to parametrize test cases. Dec 02, 2021 4 - Beta pytest >=4.6.0 :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Sep 11, 2024 N/A pytest :pypi:`pytest-fxa` pytest plugin for Firefox Accounts Aug 28, 2018 5 - Production/Stable N/A + :pypi:`pytest-fxa-mte` pytest plugin for Firefox Accounts Sep 25, 2024 5 - Production/Stable N/A :pypi:`pytest-fxtest` Oct 27, 2020 N/A N/A :pypi:`pytest-fzf` fzf-based test selector for pytest Jul 03, 2024 4 - Beta pytest>=6.0.0 :pypi:`pytest_gae` pytest plugin for apps written with Google's AppEngine Aug 03, 2016 3 - Alpha N/A @@ -621,7 +623,7 @@ This list contains 1521 plugins. :pypi:`pytest-github-actions-annotate-failures` pytest plugin to annotate failed tests with a workflow command for GitHub Actions May 04, 2023 5 - Production/Stable pytest (>=4.0.0) :pypi:`pytest-github-report` Generate a GitHub report using pytest in GitHub Workflows Jun 03, 2022 4 - Beta N/A :pypi:`pytest-gitignore` py.test plugin to ignore the same files as git Jul 17, 2015 4 - Beta N/A - :pypi:`pytest-gitlab` Pytest Plugin for Gitlab Sep 18, 2024 N/A N/A + :pypi:`pytest-gitlab` Pytest Plugin for Gitlab Sep 25, 2024 N/A N/A :pypi:`pytest-gitlabci-parallelized` Parallelize pytest across GitLab CI workers. Mar 08, 2023 N/A N/A :pypi:`pytest-gitlab-code-quality` Collects warnings while testing and generates a GitLab Code Quality Report. Sep 09, 2024 N/A pytest>=8.1.1 :pypi:`pytest-gitlab-fold` Folds output sections in GitLab CI build log Dec 31, 2023 4 - Beta pytest >=2.6.0 @@ -655,10 +657,10 @@ This list contains 1521 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Sep 17, 2024 3 - Alpha pytest==8.3.1 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Sep 28, 2024 3 - Alpha pytest==8.3.3 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A - :pypi:`pytest-hot-reloading` Apr 18, 2024 N/A N/A + :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A :pypi:`pytest-hot-test` A plugin that tracks test changes Dec 10, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-houdini` pytest plugin for testing code in Houdini. Jul 15, 2024 N/A pytest :pypi:`pytest-hoverfly` Simplify working with Hoverfly from pytest Jan 30, 2023 N/A pytest (>=5.0) @@ -680,7 +682,7 @@ This list contains 1521 plugins. :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Aug 11, 2024 3 - Alpha N/A :pypi:`pytest-httptesting` http_testing framework on top of pytest Aug 10, 2024 N/A pytest<9.0.0,>=8.2.0 - :pypi:`pytest-httpx` Send responses to httpx. Sep 20, 2024 5 - Production/Stable pytest==8.* + :pypi:`pytest-httpx` Send responses to httpx. Sep 27, 2024 5 - Production/Stable pytest==8.* :pypi:`pytest-httpx-blockage` Disable httpx requests during a test run Feb 16, 2023 N/A pytest (>=7.2.1) :pypi:`pytest-httpx-recorder` Recorder feature based on pytest_httpx, like recorder feature in responses. Jan 04, 2024 5 - Production/Stable pytest :pypi:`pytest-hue` Visualise PyTest status via your Phillips Hue lights May 09, 2019 N/A N/A @@ -721,7 +723,7 @@ This list contains 1521 plugins. :pypi:`pytest-integration-mark` Automatic integration test marking and excluding plugin for pytest May 22, 2023 N/A pytest (>=5.2) :pypi:`pytest-interactive` A pytest plugin for console based interactive test selection just after the collection phase Nov 30, 2017 3 - Alpha N/A :pypi:`pytest-intercept-remote` Pytest plugin for intercepting outgoing connection requests during pytest run. May 24, 2021 4 - Beta pytest (>=4.6) - :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Sep 18, 2024 4 - Beta pytest + :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Sep 25, 2024 4 - Beta pytest :pypi:`pytest-invenio` Pytest fixtures for Invenio. Jun 27, 2024 5 - Production/Stable pytest<7.2.0,>=6 :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A @@ -827,7 +829,7 @@ This list contains 1521 plugins. :pypi:`pytest-mark-manage` 用例标签化管理 Aug 15, 2024 N/A pytest :pypi:`pytest-mark-no-py3` pytest plugin and bowler codemod to help migrate tests to Python 3 May 17, 2019 N/A pytest :pypi:`pytest-marks` UNKNOWN Nov 23, 2012 3 - Alpha N/A - :pypi:`pytest-mask-secrets` Pytest plugin to hide sensitive data in test reports Aug 06, 2024 N/A N/A + :pypi:`pytest-mask-secrets` Pytest plugin to hide sensitive data in test reports Sep 27, 2024 N/A N/A :pypi:`pytest-matcher` Easy way to match captured \`pytest\` output against expectations stored in files Aug 01, 2024 5 - Production/Stable pytest :pypi:`pytest-matchers` Matchers for pytest Aug 26, 2024 N/A pytest<9.0,>=7.0 :pypi:`pytest-match-skip` Skip matching marks. Matches partial marks using wildcards. May 15, 2019 4 - Beta pytest (>=4.4.1) @@ -967,7 +969,7 @@ This list contains 1521 plugins. :pypi:`pytest-param` pytest plugin to test all, first, last or random params Sep 11, 2016 4 - Beta pytest (>=2.6.0) :pypi:`pytest-paramark` Configure pytest fixtures using a combination of"parametrize" and markers Jan 10, 2020 4 - Beta pytest (>=4.5.0) :pypi:`pytest-parametrization` Simpler PyTest parametrization May 22, 2022 5 - Production/Stable N/A - :pypi:`pytest-parametrize` pytest decorator for parametrizing test cases in a dict-way Sep 16, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.0 + :pypi:`pytest-parametrize` pytest decorator for parametrizing test cases in a dict-way Sep 23, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.0 :pypi:`pytest-parametrize-cases` A more user-friendly way to write parametrized tests. Mar 13, 2022 N/A pytest (>=6.1.2) :pypi:`pytest-parametrized` Pytest decorator for parametrizing tests with default iterables. Nov 03, 2023 5 - Production/Stable pytest :pypi:`pytest-parametrize-suite` A simple pytest extension for creating a named test suite. Jan 19, 2023 5 - Production/Stable pytest @@ -1009,7 +1011,7 @@ This list contains 1521 plugins. :pypi:`pytest-play` pytest plugin that let you automate actions and assertions with test metrics reporting executing plain YAML files Jun 12, 2019 5 - Production/Stable N/A :pypi:`pytest-playbook` Pytest plugin for reading playbooks. Jan 21, 2021 3 - Alpha pytest (>=6.1.2,<7.0.0) :pypi:`pytest-playwright` A pytest wrapper with fixtures for Playwright to automate web browsers Sep 06, 2024 N/A pytest<9.0.0,>=6.2.4 - :pypi:`pytest_playwright_async` ASYNC Pytest plugin for Playwright May 24, 2024 N/A N/A + :pypi:`pytest_playwright_async` ASYNC Pytest plugin for Playwright Sep 28, 2024 N/A N/A :pypi:`pytest-playwright-asyncio` Aug 29, 2023 N/A N/A :pypi:`pytest-playwright-enhanced` A pytest plugin for playwright python Mar 24, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-playwrights` A pytest wrapper with fixtures for Playwright to automate web browsers Dec 02, 2021 N/A N/A @@ -1052,7 +1054,7 @@ This list contains 1521 plugins. :pypi:`pytest-prysk` Pytest plugin for prysk Mar 12, 2024 4 - Beta pytest (>=7.3.2) :pypi:`pytest-pspec` A rspec format reporter for Python ptest Jun 02, 2020 4 - Beta pytest (>=3.0.0) :pypi:`pytest-psqlgraph` pytest plugin for testing applications that use psqlgraph Oct 19, 2021 4 - Beta pytest (>=6.0) - :pypi:`pytest-pt` pytest plugin to use \*.pt files as tests May 15, 2024 4 - Beta pytest + :pypi:`pytest-pt` pytest plugin to use \*.pt files as tests Sep 22, 2024 5 - Production/Stable pytest :pypi:`pytest-ptera` Use ptera probes in tests Mar 01, 2022 N/A pytest (>=6.2.4,<7.0.0) :pypi:`pytest-publish` Jun 04, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-pudb` Pytest PuDB debugger integration Oct 25, 2018 3 - Alpha pytest (>=2.0) @@ -1125,7 +1127,7 @@ This list contains 1521 plugins. :pypi:`pytest-regex` Select pytest tests with regular expressions May 29, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-regex-dependency` Management of Pytest dependencies via regex patterns Jun 12, 2022 N/A pytest :pypi:`pytest-regressions` Easy to use fixtures to write regression tests. Aug 31, 2023 5 - Production/Stable pytest >=6.2.0 - :pypi:`pytest-regtest` pytest plugin for snapshot regression testing Feb 26, 2024 N/A pytest>7.2 + :pypi:`pytest-regtest` pytest plugin for snapshot regression testing Sep 25, 2024 N/A pytest>7.2 :pypi:`pytest-relative-order` a pytest plugin that sorts tests using "before" and "after" markers May 17, 2021 4 - Beta N/A :pypi:`pytest-relative-path` Handle relative path in pytest options or ini configs Aug 30, 2024 N/A pytest :pypi:`pytest-relaxed` Relaxed test discovery/organization for pytest Mar 29, 2024 5 - Production/Stable pytest>=7 @@ -1187,7 +1189,7 @@ This list contains 1521 plugins. :pypi:`pytest-rmsis` Sycronise pytest results to Jira RMsis Aug 10, 2022 N/A pytest (>=5.3.5) :pypi:`pytest-rng` Fixtures for seeding tests and making randomness reproducible Aug 08, 2019 5 - Production/Stable pytest :pypi:`pytest-roast` pytest plugin for ROAST configuration override and fixtures Nov 09, 2022 5 - Production/Stable pytest - :pypi:`pytest_robotframework` a pytest plugin that can run both python and robotframework tests while generating robot reports for them Sep 10, 2024 N/A pytest<9,>=7 + :pypi:`pytest_robotframework` a pytest plugin that can run both python and robotframework tests while generating robot reports for them Sep 24, 2024 N/A pytest<9,>=7 :pypi:`pytest-rocketchat` Pytest to Rocket.Chat reporting plugin Apr 18, 2021 5 - Production/Stable N/A :pypi:`pytest-rotest` Pytest integration with rotest Sep 08, 2019 N/A pytest (>=3.5.0) :pypi:`pytest-rpc` Extend py.test for RPC OpenStack testing. Feb 22, 2019 4 - Beta pytest (~=3.6) @@ -1212,7 +1214,7 @@ This list contains 1521 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Sep 16, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Sep 26, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 :pypi:`pytest-schedule` The job of test scheduling for humans. Jan 07, 2023 5 - Production/Stable N/A @@ -1223,7 +1225,7 @@ This list contains 1521 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Sep 16, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Sep 26, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1242,7 +1244,7 @@ This list contains 1521 plugins. :pypi:`pytest-setupinfo` Displaying setup info during pytest command run Jan 23, 2023 N/A N/A :pypi:`pytest-sftpserver` py.test plugin to locally test sftp server connections. Sep 16, 2019 4 - Beta N/A :pypi:`pytest-shard` Dec 11, 2020 4 - Beta pytest - :pypi:`pytest-shared-session-scope` Pytest session-scoped fixture that works with xdist Sep 19, 2024 N/A pytest>=7.0.0 + :pypi:`pytest-shared-session-scope` Pytest session-scoped fixture that works with xdist Sep 22, 2024 N/A pytest>=7.0.0 :pypi:`pytest-share-hdf` Plugin to save test data in HDF files and retrieve them for comparison Sep 21, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-sharkreport` this is pytest report plugin. Jul 11, 2022 N/A pytest (>=3.5) :pypi:`pytest-shell` A pytest plugin to help with testing shell scripts / black box commands Mar 27, 2022 N/A N/A @@ -1303,7 +1305,7 @@ This list contains 1521 plugins. :pypi:`pytest-split-tests` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Forked from Mark Adams' original project pytest-test-groups. Jul 30, 2021 5 - Production/Stable pytest (>=2.5) :pypi:`pytest-split-tests-tresorit` Feb 22, 2021 1 - Planning N/A :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Sep 04, 2024 N/A pytest<8,>5.4.0 - :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Sep 19, 2024 N/A N/A + :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Sep 26, 2024 N/A N/A :pypi:`pytest-splunk-env` pytest fixtures for interaction with Splunk Enterprise and Splunk Cloud Oct 22, 2020 N/A pytest (>=6.1.1,<7.0.0) :pypi:`pytest-sqitch` sqitch for pytest Apr 06, 2020 4 - Beta N/A :pypi:`pytest-sqlalchemy` pytest plugin with sqlalchemy related fixtures Mar 13, 2018 3 - Alpha N/A @@ -1323,7 +1325,7 @@ This list contains 1521 plugins. :pypi:`pytest-stepfunctions` A small description May 08, 2021 4 - Beta pytest :pypi:`pytest-steps` Create step-wise / incremental tests in pytest. Sep 23, 2021 5 - Production/Stable N/A :pypi:`pytest-stepwise` Run a test suite one failing test at a time. Dec 01, 2015 4 - Beta N/A - :pypi:`pytest-stf` pytest plugin for openSTF Mar 25, 2024 N/A pytest>=5.0 + :pypi:`pytest-stf` pytest plugin for openSTF Sep 24, 2024 N/A pytest>=5.0 :pypi:`pytest-stoq` A plugin to pytest stoq Feb 09, 2021 4 - Beta N/A :pypi:`pytest-store` Pytest plugin to store values from test runs Sep 04, 2024 3 - Alpha pytest>=7.0.0 :pypi:`pytest-stress` A Pytest plugin that allows you to loop tests for a user defined amount of time. Dec 07, 2019 4 - Beta pytest (>=3.6.0) @@ -1504,7 +1506,7 @@ This list contains 1521 plugins. :pypi:`pytest-web3-data` A pytest plugin to fetch test data from IPFS HTTP gateways during pytest execution. Oct 04, 2023 4 - Beta pytest :pypi:`pytest-webdriver` Selenium webdriver fixture for py.test May 28, 2019 5 - Production/Stable pytest :pypi:`pytest-webstage` Test web apps with pytest Sep 20, 2024 N/A pytest<9.0,>=7.0 - :pypi:`pytest-webtest-extras` Pytest plugin to enhance pytest-html and allure reports of webtest projects by adding screenshots, comments and webpage sources. Jun 08, 2024 N/A pytest>=7.0.0 + :pypi:`pytest-webtest-extras` Pytest plugin to enhance pytest-html and allure reports of webtest projects by adding screenshots, comments and webpage sources. Sep 25, 2024 N/A pytest>=7.0.0 :pypi:`pytest-wetest` Welian API Automation test framework pytest plugin Nov 10, 2018 4 - Beta N/A :pypi:`pytest-when` Utility which makes mocking more readable and controllable May 28, 2024 N/A pytest>=7.3.1 :pypi:`pytest-whirlwind` Testing Tornado. Jun 12, 2020 N/A N/A @@ -1521,6 +1523,7 @@ This list contains 1521 plugins. :pypi:`pytest-xdist-worker-stats` A pytest plugin to list worker statistics after a xdist run. Apr 16, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-xfaillist` Maintain a xfaillist in an additional file to avoid merge-conflicts. Sep 17, 2021 N/A pytest (>=6.2.2,<7.0.0) :pypi:`pytest-xfiles` Pytest fixtures providing data read from function, module or package related (x)files. Feb 27, 2018 N/A N/A + :pypi:`pytest-xflaky` A simple plugin to use with pytest Sep 23, 2024 4 - Beta pytest>=8.2.1 :pypi:`pytest-xiuyu` This is a pytest plugin Jul 25, 2023 5 - Production/Stable N/A :pypi:`pytest-xlog` Extended logging for test and decorators May 31, 2020 4 - Beta N/A :pypi:`pytest-xlsx` pytest plugin for generating test cases by xlsx(excel) Aug 07, 2024 N/A pytest~=8.2.2 @@ -1549,7 +1552,8 @@ This list contains 1521 plugins. :pypi:`pytest-zcc` eee Jun 02, 2024 N/A N/A :pypi:`pytest-zebrunner` Pytest connector for Zebrunner reporting Jul 04, 2024 5 - Production/Stable pytest>=4.5.0 :pypi:`pytest-zeebe` Pytest fixtures for testing Camunda 8 processes using a Zeebe test engine. Feb 01, 2024 N/A pytest (>=7.4.2,<8.0.0) - :pypi:`pytest-zephyr-scale-integration` A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest Sep 11, 2024 N/A pytest + :pypi:`pytest-zephyr-scale-integration` A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest Sep 23, 2024 N/A pytest + :pypi:`pytest-zephyr-telegram` Плагин для отправки данных автотестов в Телеграм и Зефир Sep 27, 2024 N/A pytest==8.3.2 :pypi:`pytest-zest` Zesty additions to pytest. Nov 17, 2022 N/A N/A :pypi:`pytest-zhongwen-wendang` PyTest 中文文档 Mar 04, 2024 4 - Beta N/A :pypi:`pytest-zigzag` Extend py.test for RPC OpenStack testing. Feb 27, 2019 4 - Beta pytest (~=3.6) @@ -1561,7 +1565,7 @@ This list contains 1521 plugins. :pypi:`databricks-labs-pytester` - *last release*: Sep 19, 2024, + *last release*: Sep 24, 2024, *status*: 4 - Beta, *requires*: pytest>=8.3 @@ -2233,7 +2237,7 @@ This list contains 1521 plugins. This fixture provides a configured "driver" for Android Automated Testing, using uiautomator2. :pypi:`pytest-aux` - *last release*: Aug 06, 2024, + *last release*: Sep 23, 2024, *status*: N/A, *requires*: N/A @@ -2345,14 +2349,14 @@ This list contains 1521 plugins. A pytest plugin to repeat the entire test suite in batches. :pypi:`pytest-bazel` - *last release*: Jul 20, 2024, + *last release*: Sep 27, 2024, *status*: 4 - Beta, *requires*: pytest A pytest runner with bazel support :pypi:`pytest-bdd` - *last release*: Jun 04, 2024, + *last release*: Sep 26, 2024, *status*: 6 - Mature, *requires*: pytest>=6.2.0 @@ -2793,7 +2797,7 @@ This list contains 1521 plugins. pytest plugin to capture all warnings and put them in one file of your choice :pypi:`pytest-cases` - *last release*: Apr 04, 2024, + *last release*: Sep 26, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -3171,7 +3175,7 @@ This list contains 1521 plugins. pytest plugin to run pycodestyle :pypi:`pytest-codspeed` - *last release*: Sep 20, 2024, + *last release*: Sep 27, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=3.8 @@ -3374,7 +3378,7 @@ This list contains 1521 plugins. Coverage dynamic context support for PyTest, including sub-processes :pypi:`pytest-coveragemarkers` - *last release*: Aug 14, 2024, + *last release*: Sep 27, 2024, *status*: N/A, *requires*: pytest<8.0.0,>=7.1.2 @@ -4395,6 +4399,13 @@ This list contains 1521 plugins. A Pytest plugin to drop duplicated tests during collection + :pypi:`pytest-dryci` + *last release*: Sep 27, 2024, + *status*: 4 - Beta, + *requires*: N/A + + Test caching plugin for pytest + :pypi:`pytest-dryrun` *last release*: Jul 18, 2023, *status*: 5 - Production/Stable, @@ -4781,7 +4792,7 @@ This list contains 1521 plugins. Applies eventlet monkey-patch as a pytest plugin. :pypi:`pytest_evm` - *last release*: Sep 15, 2024, + *last release*: Sep 23, 2024, *status*: 4 - Beta, *requires*: pytest<9.0.0,>=8.1.1 @@ -4830,7 +4841,7 @@ This list contains 1521 plugins. :pypi:`pytest-exasol-slc` - *last release*: Aug 29, 2024, + *last release*: Sep 24, 2024, *status*: N/A, *requires*: pytest<9,>=7 @@ -5515,6 +5526,13 @@ This list contains 1521 plugins. pytest plugin for Firefox Accounts + :pypi:`pytest-fxa-mte` + *last release*: Sep 25, 2024, + *status*: 5 - Production/Stable, + *requires*: N/A + + pytest plugin for Firefox Accounts + :pypi:`pytest-fxtest` *last release*: Oct 27, 2020, *status*: N/A, @@ -5670,7 +5688,7 @@ This list contains 1521 plugins. py.test plugin to ignore the same files as git :pypi:`pytest-gitlab` - *last release*: Sep 18, 2024, + *last release*: Sep 25, 2024, *status*: N/A, *requires*: N/A @@ -5908,9 +5926,9 @@ This list contains 1521 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Sep 17, 2024, + *last release*: Sep 28, 2024, *status*: 3 - Alpha, - *requires*: pytest==8.3.1 + *requires*: pytest==8.3.3 Experimental package to automatically extract test plugins for Home Assistant custom components @@ -5929,7 +5947,7 @@ This list contains 1521 plugins. Report on tests that honor constraints, and guard against regressions :pypi:`pytest-hot-reloading` - *last release*: Apr 18, 2024, + *last release*: Sep 23, 2024, *status*: N/A, *requires*: N/A @@ -6083,7 +6101,7 @@ This list contains 1521 plugins. http_testing framework on top of pytest :pypi:`pytest-httpx` - *last release*: Sep 20, 2024, + *last release*: Sep 27, 2024, *status*: 5 - Production/Stable, *requires*: pytest==8.* @@ -6370,7 +6388,7 @@ This list contains 1521 plugins. Pytest plugin for intercepting outgoing connection requests during pytest run. :pypi:`pytest-interface-tester` - *last release*: Sep 18, 2024, + *last release*: Sep 25, 2024, *status*: 4 - Beta, *requires*: pytest @@ -7112,7 +7130,7 @@ This list contains 1521 plugins. UNKNOWN :pypi:`pytest-mask-secrets` - *last release*: Aug 06, 2024, + *last release*: Sep 27, 2024, *status*: N/A, *requires*: N/A @@ -8092,7 +8110,7 @@ This list contains 1521 plugins. Simpler PyTest parametrization :pypi:`pytest-parametrize` - *last release*: Sep 16, 2024, + *last release*: Sep 23, 2024, *status*: 5 - Production/Stable, *requires*: pytest<9.0.0,>=8.3.0 @@ -8386,7 +8404,7 @@ This list contains 1521 plugins. A pytest wrapper with fixtures for Playwright to automate web browsers :pypi:`pytest_playwright_async` - *last release*: May 24, 2024, + *last release*: Sep 28, 2024, *status*: N/A, *requires*: N/A @@ -8687,8 +8705,8 @@ This list contains 1521 plugins. pytest plugin for testing applications that use psqlgraph :pypi:`pytest-pt` - *last release*: May 15, 2024, - *status*: 4 - Beta, + *last release*: Sep 22, 2024, + *status*: 5 - Production/Stable, *requires*: pytest pytest plugin to use \*.pt files as tests @@ -9198,7 +9216,7 @@ This list contains 1521 plugins. Easy to use fixtures to write regression tests. :pypi:`pytest-regtest` - *last release*: Feb 26, 2024, + *last release*: Sep 25, 2024, *status*: N/A, *requires*: pytest>7.2 @@ -9632,7 +9650,7 @@ This list contains 1521 plugins. pytest plugin for ROAST configuration override and fixtures :pypi:`pytest_robotframework` - *last release*: Sep 10, 2024, + *last release*: Sep 24, 2024, *status*: N/A, *requires*: pytest<9,>=7 @@ -9807,7 +9825,7 @@ This list contains 1521 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Sep 16, 2024, + *last release*: Sep 26, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9884,7 +9902,7 @@ This list contains 1521 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Sep 16, 2024, + *last release*: Sep 26, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10017,7 +10035,7 @@ This list contains 1521 plugins. :pypi:`pytest-shared-session-scope` - *last release*: Sep 19, 2024, + *last release*: Sep 22, 2024, *status*: N/A, *requires*: pytest>=7.0.0 @@ -10444,7 +10462,7 @@ This list contains 1521 plugins. A Dynamic test tool for Splunk Apps and Add-ons :pypi:`pytest-splunk-addon-ui-smartx` - *last release*: Sep 19, 2024, + *last release*: Sep 26, 2024, *status*: N/A, *requires*: N/A @@ -10584,7 +10602,7 @@ This list contains 1521 plugins. Run a test suite one failing test at a time. :pypi:`pytest-stf` - *last release*: Mar 25, 2024, + *last release*: Sep 24, 2024, *status*: N/A, *requires*: pytest>=5.0 @@ -11851,7 +11869,7 @@ This list contains 1521 plugins. Test web apps with pytest :pypi:`pytest-webtest-extras` - *last release*: Jun 08, 2024, + *last release*: Sep 25, 2024, *status*: N/A, *requires*: pytest>=7.0.0 @@ -11969,6 +11987,13 @@ This list contains 1521 plugins. Pytest fixtures providing data read from function, module or package related (x)files. + :pypi:`pytest-xflaky` + *last release*: Sep 23, 2024, + *status*: 4 - Beta, + *requires*: pytest>=8.2.1 + + A simple plugin to use with pytest + :pypi:`pytest-xiuyu` *last release*: Jul 25, 2023, *status*: 5 - Production/Stable, @@ -12166,12 +12191,19 @@ This list contains 1521 plugins. Pytest fixtures for testing Camunda 8 processes using a Zeebe test engine. :pypi:`pytest-zephyr-scale-integration` - *last release*: Sep 11, 2024, + *last release*: Sep 23, 2024, *status*: N/A, *requires*: pytest A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest + :pypi:`pytest-zephyr-telegram` + *last release*: Sep 27, 2024, + *status*: N/A, + *requires*: pytest==8.3.2 + + Плагин для отправки данных автотестов в Телеграм и Зефир + :pypi:`pytest-zest` *last release*: Nov 17, 2022, *status*: N/A, From 7add2af7087dc32af19a38f5950a5b64a19d1de5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 10:32:25 +0200 Subject: [PATCH 086/445] [pre-commit.ci] pre-commit autoupdate (#12848) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.7 → v0.6.8](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.7...v0.6.8) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b4d10558b88..7b54534b45d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.7" + rev: "v0.6.8" hooks: - id: ruff args: ["--fix"] From eb8592c526b3d7967573d816efc5b35fc88be2a8 Mon Sep 17 00:00:00 2001 From: sven <42868792+FreerGit@users.noreply.github.com> Date: Tue, 1 Oct 2024 18:41:30 +0200 Subject: [PATCH 087/445] update default and add docs --- changelog/12749.feature.rst | 4 +++- doc/en/reference/reference.rst | 10 +++++++++- src/_pytest/main.py | 6 +++--- testing/test_collect_imports.py | 26 ++++++++++++++++++++++---- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/changelog/12749.feature.rst b/changelog/12749.feature.rst index 798d02c6e49..cda0db6c930 100644 --- a/changelog/12749.feature.rst +++ b/changelog/12749.feature.rst @@ -1,3 +1,5 @@ -Add :confval:`collect_imported_tests`, when enabled (default is disabled) will make sure to not consider classes/functions which are imported by a test file and contains Test/test_*/*_test. +New :confval:`collect_imported_tests`: when enabled (the default) pytest will collect classes/functions in test modules even if they are imported from another file. + +Setting this to False will make pytest collect classes/functions from test files only if they are defined in that file (as opposed to imported there). -- by :user:`FreerGit` diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index f7dfb3ffa71..99b1a19c3a4 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1839,9 +1839,17 @@ passed multiple times. The expected format is ``name=value``. For example:: pytest testing doc -.. confval:: tmp_path_retention_count +.. confval:: collect_imported_tests + + Setting this to `false` will make pytest collect classes/functions from test + files only if they are defined in that file (as opposed to imported there). + + .. code-block:: ini + [pytest] + collect_imported_tests = false +.. confval:: tmp_path_retention_count How many sessions should we keep the `tmp_path` directories, according to `tmp_path_retention_policy`. diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 611ce033ea9..e40f09a9acb 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -82,7 +82,7 @@ def pytest_addoption(parser: Parser) -> None: "collect_imported_tests", "Whether to collect tests in imported modules outside `testpaths`", type="bool", - default=False, + default=True, ) group = parser.getgroup("general", "Running and selection options") group._addoption( @@ -973,7 +973,7 @@ def genitems(self, node: nodes.Item | nodes.Collector) -> Iterator[nodes.Item]: self.trace("genitems", node) if isinstance(node, nodes.Item): node.ihook.pytest_itemcollected(item=node) - if self.config.getini("collect_imported_tests"): + if not self.config.getini("collect_imported_tests"): if isinstance(node.parent, Module) and isinstance(node, Function): if inspect.isfunction(node._getobj()): fn_defined_at = node._getobj().__module__ @@ -988,7 +988,7 @@ def genitems(self, node: nodes.Item | nodes.Collector) -> Iterator[nodes.Item]: handle_dupes = not (keepduplicates and isinstance(node, nodes.File)) rep, duplicate = self._collect_one_node(node, handle_dupes) - if self.config.getini("collect_imported_tests"): + if not self.config.getini("collect_imported_tests"): for subnode in rep.result: if isinstance(subnode, Class) and isinstance( subnode.parent, Module diff --git a/testing/test_collect_imports.py b/testing/test_collect_imports.py index e328d16a182..7922058721c 100644 --- a/testing/test_collect_imports.py +++ b/testing/test_collect_imports.py @@ -55,7 +55,7 @@ def test_collect_imports_disabled(pytester: Pytester) -> None: collect_imported_tests = false """) - run_import_class_test(pytester, errors=1) + run_import_class_test(pytester, passed=1) def test_collect_imports_default(pytester: Pytester) -> None: @@ -74,7 +74,7 @@ def test_collect_imports_enabled(pytester: Pytester) -> None: collect_imported_tests = true """) - run_import_class_test(pytester, passed=1) + run_import_class_test(pytester, errors=1) def run_import_functions_test( @@ -137,14 +137,32 @@ def test_collect_function_imports_enabled(pytester: Pytester) -> None: collect_imported_tests = true """) - run_import_functions_test(pytester, passed=1, errors=0, failed=0) + run_import_functions_test(pytester, passed=2, errors=0, failed=1) def test_collect_function_imports_disabled(pytester: Pytester) -> None: pytester.makeini(""" [pytest] - testpaths = "tests" + # testpaths = "tests" collect_imported_tests = false """) + run_import_functions_test(pytester, passed=1, errors=0, failed=0) + + +def test_behaviour_without_testpaths_set_and_false(pytester: Pytester) -> None: + pytester.makeini(""" + [pytest] + collect_imported_tests = false + """) + + run_import_functions_test(pytester, passed=1, errors=0, failed=0) + + +def test_behaviour_without_testpaths_set_and_true(pytester: Pytester) -> None: + pytester.makeini(""" + [pytest] + collect_imported_tests = true + """) + run_import_functions_test(pytester, passed=2, errors=0, failed=1) From 410c510118e8963d122102f8426dfa3fff626d50 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 6 Oct 2024 05:46:07 +0200 Subject: [PATCH 088/445] [automated] Update plugin list (#12856) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 104 ++++++++++++++++++++----------- 1 file changed, 68 insertions(+), 36 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 96ee4fc3830..e09656e3a61 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =3.5.0) :pypi:`pytest-annotate` pytest-annotate: Generate PyAnnotate annotations from your pytest tests. Jun 07, 2022 3 - Alpha pytest (<8.0.0,>=3.2.0) + :pypi:`pytest-annotated` Pytest plugin to allow use of Annotated in tests to resolve fixtures Sep 30, 2024 N/A pytest>=8.3.3 :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures Sep 11, 2024 5 - Production/Stable pytest>=6 :pypi:`pytest-ansible-playbook` Pytest fixture which runs given ansible playbook file. Mar 08, 2019 4 - Beta N/A :pypi:`pytest-ansible-playbook-runner` Pytest fixture which runs given ansible playbook file. Dec 02, 2020 4 - Beta pytest (>=3.1.0) @@ -156,7 +157,7 @@ This list contains 1525 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Aug 08, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Sep 18, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Oct 02, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -293,7 +294,7 @@ This list contains 1525 plugins. :pypi:`pytest-cover` Pytest plugin for measuring coverage. Forked from \`pytest-cov\`. Aug 01, 2015 5 - Production/Stable N/A :pypi:`pytest-coverage` Jun 17, 2015 N/A N/A :pypi:`pytest-coverage-context` Coverage dynamic context support for PyTest, including sub-processes Jun 28, 2023 4 - Beta N/A - :pypi:`pytest-coveragemarkers` Using pytest markers to track functional coverage and filtering of tests Sep 27, 2024 N/A pytest<8.0.0,>=7.1.2 + :pypi:`pytest-coveragemarkers` Using pytest markers to track functional coverage and filtering of tests Sep 30, 2024 N/A pytest<8.0.0,>=7.1.2 :pypi:`pytest-cov-exclude` Pytest plugin for excluding tests based on coverage data Apr 29, 2016 4 - Beta pytest (>=2.8.0,<2.9.0); extra == 'dev' :pypi:`pytest_covid` Too many faillure, less tests. Jun 24, 2020 N/A N/A :pypi:`pytest-cpp` Use pytest's runner to discover and execute C++ tests Sep 18, 2024 5 - Production/Stable pytest @@ -591,6 +592,7 @@ This list contains 1525 plugins. :pypi:`pytest-forward-compatability` A name to avoid typosquating pytest-foward-compatibility Sep 06, 2020 N/A N/A :pypi:`pytest-forward-compatibility` A pytest plugin to shim pytest commandline options for fowards compatibility Sep 29, 2020 N/A N/A :pypi:`pytest-frappe` Pytest Frappe Plugin - A set of pytest fixtures to test Frappe applications Jul 30, 2024 4 - Beta pytest>=7.0.0 + :pypi:`pytest-freethreaded` pytest plugin for running parallel tests Oct 03, 2024 5 - Production/Stable pytest :pypi:`pytest-freezeblaster` Wrap tests with fixtures in freeze_time Jul 10, 2024 N/A pytest>=6.2.5 :pypi:`pytest-freezegun` Wrap tests with fixtures in freeze_time Jul 19, 2020 4 - Beta pytest (>=3.0.0) :pypi:`pytest-freezer` Pytest plugin providing a fixture interface for spulec/freezegun Jun 21, 2023 N/A pytest >= 3.6 @@ -598,9 +600,9 @@ This list contains 1525 plugins. :pypi:`pytest-frozen-uuids` Deterministically frozen UUID's for your tests Apr 17, 2022 N/A pytest (>=3.0) :pypi:`pytest-func-cov` Pytest plugin for measuring function coverage Apr 15, 2021 3 - Alpha pytest (>=5) :pypi:`pytest-funparam` An alternative way to parametrize test cases. Dec 02, 2021 4 - Beta pytest >=4.6.0 - :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Sep 11, 2024 N/A pytest + :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Oct 03, 2024 N/A pytest :pypi:`pytest-fxa` pytest plugin for Firefox Accounts Aug 28, 2018 5 - Production/Stable N/A - :pypi:`pytest-fxa-mte` pytest plugin for Firefox Accounts Sep 25, 2024 5 - Production/Stable N/A + :pypi:`pytest-fxa-mte` pytest plugin for Firefox Accounts Oct 02, 2024 5 - Production/Stable N/A :pypi:`pytest-fxtest` Oct 27, 2020 N/A N/A :pypi:`pytest-fzf` fzf-based test selector for pytest Jul 03, 2024 4 - Beta pytest>=6.0.0 :pypi:`pytest_gae` pytest plugin for apps written with Google's AppEngine Aug 03, 2016 3 - Alpha N/A @@ -657,7 +659,7 @@ This list contains 1525 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Sep 28, 2024 3 - Alpha pytest==8.3.3 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Oct 05, 2024 3 - Alpha pytest==8.3.3 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -788,7 +790,7 @@ This list contains 1525 plugins. :pypi:`pytest-leaping` A simple plugin to use with pytest Mar 27, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-level` Select tests of a given level or lower Oct 21, 2019 N/A pytest :pypi:`pytest-libfaketime` A python-libfaketime plugin for pytest Apr 12, 2024 4 - Beta pytest>=3.0.0 - :pypi:`pytest-libiio` A pytest plugin to manage interfacing with libiio contexts Sep 05, 2024 4 - Beta N/A + :pypi:`pytest-libiio` A pytest plugin to manage interfacing with libiio contexts Oct 01, 2024 4 - Beta N/A :pypi:`pytest-libnotify` Pytest plugin that shows notifications about the test run Apr 02, 2021 3 - Alpha pytest :pypi:`pytest-ligo` Jan 16, 2020 4 - Beta N/A :pypi:`pytest-lineno` A pytest plugin to show the line numbers of test functions Dec 04, 2020 N/A pytest @@ -815,7 +817,7 @@ This list contains 1525 plugins. :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) :pypi:`pytest-logikal` Common testing environment Aug 30, 2024 5 - Production/Stable pytest==8.3.2 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A - :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Jul 19, 2024 4 - Beta N/A + :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Sep 30, 2024 4 - Beta pytest>=8.2.2 :pypi:`pytest-loguru` Pytest Loguru Mar 20, 2024 5 - Production/Stable pytest; extra == "test" :pypi:`pytest-loop` pytest plugin for looping tests Mar 30, 2024 5 - Production/Stable pytest :pypi:`pytest-lsp` A pytest plugin for end-to-end testing of language servers Sep 04, 2024 3 - Alpha pytest @@ -1037,14 +1039,14 @@ This list contains 1525 plugins. :pypi:`pytest-postgres` Run PostgreSQL in Docker container in Pytest. Mar 22, 2020 N/A pytest :pypi:`pytest-postgresql` Postgresql fixtures and fixture factories for Pytest. Sep 05, 2024 5 - Production/Stable pytest>=6.2 :pypi:`pytest-power` pytest plugin with powerful fixtures Dec 31, 2020 N/A pytest (>=5.4) - :pypi:`pytest-powerpack` Mar 17, 2024 N/A pytest (>=8.1.1,<9.0.0) + :pypi:`pytest-powerpack` A plugin containing extra batteries for pytest Oct 01, 2024 N/A pytest<9.0.0,>=8.1.1 :pypi:`pytest-prefer-nested-dup-tests` A Pytest plugin to drop duplicated tests during collection, but will prefer keeping nested packages. Apr 27, 2022 4 - Beta pytest (>=7.1.1,<8.0.0) :pypi:`pytest-pretty` pytest plugin for printing summary data as I want it Apr 05, 2023 5 - Production/Stable pytest>=7 :pypi:`pytest-pretty-terminal` pytest plugin for generating prettier terminal output Jan 31, 2022 N/A pytest (>=3.4.1) :pypi:`pytest-pride` Minitest-style test colors Apr 02, 2016 3 - Alpha N/A :pypi:`pytest-print` pytest-print adds the printer fixture you can use to print messages to the user (directly to the pytest runner, not stdout) Sep 17, 2024 5 - Production/Stable pytest>=8.3.2 :pypi:`pytest-priority` pytest plugin for add priority for tests Aug 19, 2024 N/A pytest - :pypi:`pytest-proceed` Apr 10, 2024 N/A pytest + :pypi:`pytest-proceed` Oct 01, 2024 N/A pytest :pypi:`pytest-profiles` pytest plugin for configuration profiles Dec 09, 2021 4 - Beta pytest (>=3.7.0) :pypi:`pytest-profiling` Profiling plugin for py.test May 28, 2019 5 - Production/Stable pytest :pypi:`pytest-progress` pytest plugin for instant test progress status Jun 18, 2024 5 - Production/Stable pytest>=2.7 @@ -1127,7 +1129,7 @@ This list contains 1525 plugins. :pypi:`pytest-regex` Select pytest tests with regular expressions May 29, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-regex-dependency` Management of Pytest dependencies via regex patterns Jun 12, 2022 N/A pytest :pypi:`pytest-regressions` Easy to use fixtures to write regression tests. Aug 31, 2023 5 - Production/Stable pytest >=6.2.0 - :pypi:`pytest-regtest` pytest plugin for snapshot regression testing Sep 25, 2024 N/A pytest>7.2 + :pypi:`pytest-regtest` pytest plugin for snapshot regression testing Oct 05, 2024 N/A pytest>7.2 :pypi:`pytest-relative-order` a pytest plugin that sorts tests using "before" and "after" markers May 17, 2021 4 - Beta N/A :pypi:`pytest-relative-path` Handle relative path in pytest options or ini configs Aug 30, 2024 N/A pytest :pypi:`pytest-relaxed` Relaxed test discovery/organization for pytest Mar 29, 2024 5 - Production/Stable pytest>=7 @@ -1199,6 +1201,7 @@ This list contains 1525 plugins. :pypi:`pytest-ruff` pytest plugin to check ruff requirements. Jul 21, 2024 4 - Beta pytest>=5 :pypi:`pytest-run-changed` Pytest plugin that runs changed tests only Apr 02, 2021 3 - Alpha pytest :pypi:`pytest-runfailed` implement a --failed option for pytest Mar 24, 2016 N/A N/A + :pypi:`pytest-run-parallel` A simple pytest plugin to run tests concurrently Sep 30, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-run-subprocess` Pytest Plugin for running and testing subprocesses. Nov 12, 2022 5 - Production/Stable pytest :pypi:`pytest-runtime-types` Checks type annotations on runtime while running tests. Feb 09, 2023 N/A pytest :pypi:`pytest-runtime-xfail` Call runtime_xfail() to mark running test as xfail. Aug 26, 2021 N/A pytest>=5.0.0 @@ -1214,7 +1217,7 @@ This list contains 1525 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Sep 26, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Oct 04, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 :pypi:`pytest-schedule` The job of test scheduling for humans. Jan 07, 2023 5 - Production/Stable N/A @@ -1225,7 +1228,7 @@ This list contains 1525 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Sep 26, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Oct 04, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1492,6 +1495,7 @@ This list contains 1525 plugins. :pypi:`pytest-voluptuous` Pytest plugin for asserting data against voluptuous schema. Jun 09, 2020 N/A pytest :pypi:`pytest-vscodedebug` A pytest plugin to easily enable debugging tests within Visual Studio Code Dec 04, 2020 4 - Beta N/A :pypi:`pytest-vscode-pycharm-cls` A PyTest helper to enable start remote debugger on test start or failure or when pytest.set_trace is used. Feb 01, 2023 N/A pytest + :pypi:`pytest-vtestify` A pytest plugin for visual assertion using SSIM and image comparison. Oct 03, 2024 N/A pytest :pypi:`pytest-vts` pytest plugin for automatic recording of http stubbed tests Jun 05, 2019 N/A pytest (>=2.3) :pypi:`pytest-vulture` A pytest plugin to checks dead code with vulture Jun 01, 2023 N/A pytest (>=7.0.0) :pypi:`pytest-vw` pytest-vw makes your failing test cases succeed under CI tools scrutiny Oct 07, 2015 4 - Beta N/A @@ -1506,7 +1510,7 @@ This list contains 1525 plugins. :pypi:`pytest-web3-data` A pytest plugin to fetch test data from IPFS HTTP gateways during pytest execution. Oct 04, 2023 4 - Beta pytest :pypi:`pytest-webdriver` Selenium webdriver fixture for py.test May 28, 2019 5 - Production/Stable pytest :pypi:`pytest-webstage` Test web apps with pytest Sep 20, 2024 N/A pytest<9.0,>=7.0 - :pypi:`pytest-webtest-extras` Pytest plugin to enhance pytest-html and allure reports of webtest projects by adding screenshots, comments and webpage sources. Sep 25, 2024 N/A pytest>=7.0.0 + :pypi:`pytest-webtest-extras` Pytest plugin to enhance pytest-html and allure reports of webtest projects by adding screenshots, comments and webpage sources. Oct 03, 2024 N/A pytest>=7.0.0 :pypi:`pytest-wetest` Welian API Automation test framework pytest plugin Nov 10, 2018 4 - Beta N/A :pypi:`pytest-when` Utility which makes mocking more readable and controllable May 28, 2024 N/A pytest>=7.3.1 :pypi:`pytest-whirlwind` Testing Tornado. Jun 12, 2020 N/A N/A @@ -1523,7 +1527,7 @@ This list contains 1525 plugins. :pypi:`pytest-xdist-worker-stats` A pytest plugin to list worker statistics after a xdist run. Apr 16, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-xfaillist` Maintain a xfaillist in an additional file to avoid merge-conflicts. Sep 17, 2021 N/A pytest (>=6.2.2,<7.0.0) :pypi:`pytest-xfiles` Pytest fixtures providing data read from function, module or package related (x)files. Feb 27, 2018 N/A N/A - :pypi:`pytest-xflaky` A simple plugin to use with pytest Sep 23, 2024 4 - Beta pytest>=8.2.1 + :pypi:`pytest-xflaky` A simple plugin to use with pytest Oct 04, 2024 4 - Beta pytest>=8.2.1 :pypi:`pytest-xiuyu` This is a pytest plugin Jul 25, 2023 5 - Production/Stable N/A :pypi:`pytest-xlog` Extended logging for test and decorators May 31, 2020 4 - Beta N/A :pypi:`pytest-xlsx` pytest plugin for generating test cases by xlsx(excel) Aug 07, 2024 N/A pytest~=8.2.2 @@ -1535,7 +1539,7 @@ This list contains 1525 plugins. :pypi:`pytest-xskynet` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A :pypi:`pytest-xstress` Jun 01, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-xvfb` A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. May 29, 2023 4 - Beta pytest (>=2.8.1) - :pypi:`pytest-xvirt` A pytest plugin to virtualize test. For example to transparently running them on a remote box. Jul 03, 2024 4 - Beta pytest>=7.2.2 + :pypi:`pytest-xvirt` A pytest plugin to virtualize test. For example to transparently running them on a remote box. Oct 01, 2024 4 - Beta pytest>=7.2.2 :pypi:`pytest-yaml` This plugin is used to load yaml output to your test using pytest framework. Oct 05, 2018 N/A pytest :pypi:`pytest-yaml-sanmu` Pytest plugin for generating test cases with YAML. In test cases, you can use markers, fixtures, variables, and even call Python functions. Aug 16, 2024 N/A pytest~=8.2.2 :pypi:`pytest-yamltree` Create or check file/directory trees described by YAML Mar 02, 2020 4 - Beta pytest (>=3.1.1) @@ -1553,7 +1557,7 @@ This list contains 1525 plugins. :pypi:`pytest-zebrunner` Pytest connector for Zebrunner reporting Jul 04, 2024 5 - Production/Stable pytest>=4.5.0 :pypi:`pytest-zeebe` Pytest fixtures for testing Camunda 8 processes using a Zeebe test engine. Feb 01, 2024 N/A pytest (>=7.4.2,<8.0.0) :pypi:`pytest-zephyr-scale-integration` A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest Sep 23, 2024 N/A pytest - :pypi:`pytest-zephyr-telegram` Плагин для отправки данных автотестов в Телеграм и Зефир Sep 27, 2024 N/A pytest==8.3.2 + :pypi:`pytest-zephyr-telegram` Плагин для отправки данных автотестов в Телеграм и Зефир Sep 30, 2024 N/A pytest==8.3.2 :pypi:`pytest-zest` Zesty additions to pytest. Nov 17, 2022 N/A N/A :pypi:`pytest-zhongwen-wendang` PyTest 中文文档 Mar 04, 2024 4 - Beta N/A :pypi:`pytest-zigzag` Extend py.test for RPC OpenStack testing. Feb 27, 2019 4 - Beta pytest (~=3.6) @@ -1858,6 +1862,13 @@ This list contains 1525 plugins. pytest-annotate: Generate PyAnnotate annotations from your pytest tests. + :pypi:`pytest-annotated` + *last release*: Sep 30, 2024, + *status*: N/A, + *requires*: pytest>=8.3.3 + + Pytest plugin to allow use of Annotated in tests to resolve fixtures + :pypi:`pytest-ansible` *last release*: Sep 11, 2024, *status*: 5 - Production/Stable, @@ -2419,7 +2430,7 @@ This list contains 1525 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Sep 18, 2024, + *last release*: Oct 02, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -3378,7 +3389,7 @@ This list contains 1525 plugins. Coverage dynamic context support for PyTest, including sub-processes :pypi:`pytest-coveragemarkers` - *last release*: Sep 27, 2024, + *last release*: Sep 30, 2024, *status*: N/A, *requires*: pytest<8.0.0,>=7.1.2 @@ -5463,6 +5474,13 @@ This list contains 1525 plugins. Pytest Frappe Plugin - A set of pytest fixtures to test Frappe applications + :pypi:`pytest-freethreaded` + *last release*: Oct 03, 2024, + *status*: 5 - Production/Stable, + *requires*: pytest + + pytest plugin for running parallel tests + :pypi:`pytest-freezeblaster` *last release*: Jul 10, 2024, *status*: N/A, @@ -5513,7 +5531,7 @@ This list contains 1525 plugins. An alternative way to parametrize test cases. :pypi:`pytest-fv` - *last release*: Sep 11, 2024, + *last release*: Oct 03, 2024, *status*: N/A, *requires*: pytest @@ -5527,7 +5545,7 @@ This list contains 1525 plugins. pytest plugin for Firefox Accounts :pypi:`pytest-fxa-mte` - *last release*: Sep 25, 2024, + *last release*: Oct 02, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -5926,7 +5944,7 @@ This list contains 1525 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Sep 28, 2024, + *last release*: Oct 05, 2024, *status*: 3 - Alpha, *requires*: pytest==8.3.3 @@ -6843,7 +6861,7 @@ This list contains 1525 plugins. A python-libfaketime plugin for pytest :pypi:`pytest-libiio` - *last release*: Sep 05, 2024, + *last release*: Oct 01, 2024, *status*: 4 - Beta, *requires*: N/A @@ -7032,9 +7050,9 @@ This list contains 1525 plugins. Package for creating a pytest test run reprot :pypi:`pytest-logscanner` - *last release*: Jul 19, 2024, + *last release*: Sep 30, 2024, *status*: 4 - Beta, - *requires*: N/A + *requires*: pytest>=8.2.2 Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) @@ -8586,11 +8604,11 @@ This list contains 1525 plugins. pytest plugin with powerful fixtures :pypi:`pytest-powerpack` - *last release*: Mar 17, 2024, + *last release*: Oct 01, 2024, *status*: N/A, - *requires*: pytest (>=8.1.1,<9.0.0) - + *requires*: pytest<9.0.0,>=8.1.1 + A plugin containing extra batteries for pytest :pypi:`pytest-prefer-nested-dup-tests` *last release*: Apr 27, 2022, @@ -8635,7 +8653,7 @@ This list contains 1525 plugins. pytest plugin for add priority for tests :pypi:`pytest-proceed` - *last release*: Apr 10, 2024, + *last release*: Oct 01, 2024, *status*: N/A, *requires*: pytest @@ -9216,7 +9234,7 @@ This list contains 1525 plugins. Easy to use fixtures to write regression tests. :pypi:`pytest-regtest` - *last release*: Sep 25, 2024, + *last release*: Oct 05, 2024, *status*: N/A, *requires*: pytest>7.2 @@ -9719,6 +9737,13 @@ This list contains 1525 plugins. implement a --failed option for pytest + :pypi:`pytest-run-parallel` + *last release*: Sep 30, 2024, + *status*: 4 - Beta, + *requires*: pytest>=6.2.0 + + A simple pytest plugin to run tests concurrently + :pypi:`pytest-run-subprocess` *last release*: Nov 12, 2022, *status*: 5 - Production/Stable, @@ -9825,7 +9850,7 @@ This list contains 1525 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Sep 26, 2024, + *last release*: Oct 04, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9902,7 +9927,7 @@ This list contains 1525 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Sep 26, 2024, + *last release*: Oct 04, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -11770,6 +11795,13 @@ This list contains 1525 plugins. A PyTest helper to enable start remote debugger on test start or failure or when pytest.set_trace is used. + :pypi:`pytest-vtestify` + *last release*: Oct 03, 2024, + *status*: N/A, + *requires*: pytest + + A pytest plugin for visual assertion using SSIM and image comparison. + :pypi:`pytest-vts` *last release*: Jun 05, 2019, *status*: N/A, @@ -11869,7 +11901,7 @@ This list contains 1525 plugins. Test web apps with pytest :pypi:`pytest-webtest-extras` - *last release*: Sep 25, 2024, + *last release*: Oct 03, 2024, *status*: N/A, *requires*: pytest>=7.0.0 @@ -11988,7 +12020,7 @@ This list contains 1525 plugins. Pytest fixtures providing data read from function, module or package related (x)files. :pypi:`pytest-xflaky` - *last release*: Sep 23, 2024, + *last release*: Oct 04, 2024, *status*: 4 - Beta, *requires*: pytest>=8.2.1 @@ -12072,7 +12104,7 @@ This list contains 1525 plugins. A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. :pypi:`pytest-xvirt` - *last release*: Jul 03, 2024, + *last release*: Oct 01, 2024, *status*: 4 - Beta, *requires*: pytest>=7.2.2 @@ -12198,7 +12230,7 @@ This list contains 1525 plugins. A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest :pypi:`pytest-zephyr-telegram` - *last release*: Sep 27, 2024, + *last release*: Sep 30, 2024, *status*: N/A, *requires*: pytest==8.3.2 From b451a18cc9db46636bd873e0d8bc7cc71dc818e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 09:34:41 -0300 Subject: [PATCH 089/445] build(deps): Bump pypa/gh-action-pypi-publish from 1.10.2 to 1.10.3 (#12858) Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.2 to 1.10.3. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.10.2...v1.10.3) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f2e2dd4a407..998a2839dc2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -54,7 +54,7 @@ jobs: path: dist - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@v1.10.2 + uses: pypa/gh-action-pypi-publish@v1.10.3 with: attestations: true From 294e1139ec464b569e589fb4173bb7b26d61163a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 06:45:53 +0200 Subject: [PATCH 090/445] [pre-commit.ci] pre-commit autoupdate (#12862) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.8 → v0.6.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.8...v0.6.9) - [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.6.0...v5.0.0) - [github.com/adamchainz/blacken-docs: 1.18.0 → 1.19.0](https://github.com/adamchainz/blacken-docs/compare/1.18.0...1.19.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7b54534b45d..7a3fa1a428a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,18 +1,18 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.8" + rev: "v0.6.9" hooks: - id: ruff args: ["--fix"] - id: ruff-format - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/adamchainz/blacken-docs - rev: 1.18.0 + rev: 1.19.0 hooks: - id: blacken-docs additional_dependencies: [black==24.1.1] From fb740251fe1d7facd1f8a341e22d4aa07ba7833c Mon Sep 17 00:00:00 2001 From: Frank Hoffmann <44680962+15r10nk@users.noreply.github.com> Date: Wed, 9 Oct 2024 21:10:56 +0200 Subject: [PATCH 091/445] Preserve source positions for assertion rewriting Closes #12818 --- AUTHORS | 1 + changelog/12818.bugfix.rst | 1 + src/_pytest/assertion/rewrite.py | 21 ++- testing/test_assertrewrite.py | 211 ++++++++++++++++++++++++++++++- 4 files changed, 223 insertions(+), 11 deletions(-) create mode 100644 changelog/12818.bugfix.rst diff --git a/AUTHORS b/AUTHORS index 1ee868448d4..a42f4ab0c13 100644 --- a/AUTHORS +++ b/AUTHORS @@ -160,6 +160,7 @@ Feng Ma Florian Bruhin Florian Dahlitz Floris Bruynooghe +Frank Hoffmann Fraser Stark Gabriel Landau Gabriel Reis diff --git a/changelog/12818.bugfix.rst b/changelog/12818.bugfix.rst new file mode 100644 index 00000000000..9d74f2fda2a --- /dev/null +++ b/changelog/12818.bugfix.rst @@ -0,0 +1 @@ +Assertion rewriting now preserves the source ranges of the original instructions, making it play well with tools that deal with the ``AST``, like `executing `__. diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index a7a92c0f1fe..37c09b03467 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -792,7 +792,7 @@ def assign(self, expr: ast.expr) -> ast.Name: """Give *expr* a name.""" name = self.variable() self.statements.append(ast.Assign([ast.Name(name, ast.Store())], expr)) - return ast.Name(name, ast.Load()) + return ast.copy_location(ast.Name(name, ast.Load()), expr) def display(self, expr: ast.expr) -> ast.expr: """Call saferepr on the expression.""" @@ -975,7 +975,10 @@ def visit_Assert(self, assert_: ast.Assert) -> list[ast.stmt]: # Fix locations (line numbers/column offsets). for stmt in self.statements: for node in traverse_node(stmt): - ast.copy_location(node, assert_) + if getattr(node, "lineno", None) is None: + # apply the assertion location to all generated ast nodes without source location + # and preserve the location of existing nodes or generated nodes with an correct location. + ast.copy_location(node, assert_) return self.statements def visit_NamedExpr(self, name: ast.NamedExpr) -> tuple[ast.NamedExpr, str]: @@ -1052,7 +1055,7 @@ def visit_BoolOp(self, boolop: ast.BoolOp) -> tuple[ast.Name, str]: def visit_UnaryOp(self, unary: ast.UnaryOp) -> tuple[ast.Name, str]: pattern = UNARY_MAP[unary.op.__class__] operand_res, operand_expl = self.visit(unary.operand) - res = self.assign(ast.UnaryOp(unary.op, operand_res)) + res = self.assign(ast.copy_location(ast.UnaryOp(unary.op, operand_res), unary)) return res, pattern % (operand_expl,) def visit_BinOp(self, binop: ast.BinOp) -> tuple[ast.Name, str]: @@ -1060,7 +1063,9 @@ def visit_BinOp(self, binop: ast.BinOp) -> tuple[ast.Name, str]: left_expr, left_expl = self.visit(binop.left) right_expr, right_expl = self.visit(binop.right) explanation = f"({left_expl} {symbol} {right_expl})" - res = self.assign(ast.BinOp(left_expr, binop.op, right_expr)) + res = self.assign( + ast.copy_location(ast.BinOp(left_expr, binop.op, right_expr), binop) + ) return res, explanation def visit_Call(self, call: ast.Call) -> tuple[ast.Name, str]: @@ -1089,7 +1094,7 @@ def visit_Call(self, call: ast.Call) -> tuple[ast.Name, str]: arg_expls.append("**" + expl) expl = "{}({})".format(func_expl, ", ".join(arg_expls)) - new_call = ast.Call(new_func, new_args, new_kwargs) + new_call = ast.copy_location(ast.Call(new_func, new_args, new_kwargs), call) res = self.assign(new_call) res_expl = self.explanation_param(self.display(res)) outer_expl = f"{res_expl}\n{{{res_expl} = {expl}\n}}" @@ -1105,7 +1110,9 @@ def visit_Attribute(self, attr: ast.Attribute) -> tuple[ast.Name, str]: if not isinstance(attr.ctx, ast.Load): return self.generic_visit(attr) value, value_expl = self.visit(attr.value) - res = self.assign(ast.Attribute(value, attr.attr, ast.Load())) + res = self.assign( + ast.copy_location(ast.Attribute(value, attr.attr, ast.Load()), attr) + ) res_expl = self.explanation_param(self.display(res)) pat = "%s\n{%s = %s.%s\n}" expl = pat % (res_expl, res_expl, value_expl, attr.attr) @@ -1146,7 +1153,7 @@ def visit_Compare(self, comp: ast.Compare) -> tuple[ast.expr, str]: syms.append(ast.Constant(sym)) expl = f"{left_expl} {sym} {next_expl}" expls.append(ast.Constant(expl)) - res_expr = ast.Compare(left_res, [op], [next_res]) + res_expr = ast.copy_location(ast.Compare(left_res, [op], [next_res]), comp) self.statements.append(ast.Assign([store_names[i]], res_expr)) left_res, left_expl = next_res, next_expl # Use pytest.assertion.util._reprcompare if that's available. diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index 73c11a1a9d8..7be473d897a 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -2,10 +2,12 @@ from __future__ import annotations import ast +import dis import errno from functools import partial import glob import importlib +import inspect import marshal import os from pathlib import Path @@ -131,10 +133,211 @@ def test_location_is_set(self) -> None: continue for n in [node, *ast.iter_child_nodes(node)]: assert isinstance(n, (ast.stmt, ast.expr)) - assert n.lineno == 3 - assert n.col_offset == 0 - assert n.end_lineno == 6 - assert n.end_col_offset == 3 + for location in [ + (n.lineno, n.col_offset), + (n.end_lineno, n.end_col_offset), + ]: + assert (3, 0) <= location <= (6, 3) + + def test_positions_are_preserved(self) -> None: + """Ensure AST positions are preserved during rewriting (#12818).""" + + def preserved(code: str) -> None: + s = textwrap.dedent(code) + locations = [] + + def loc(msg: str | None = None) -> None: + frame = inspect.currentframe() + assert frame + frame = frame.f_back + assert frame + frame = frame.f_back + assert frame + + offset = frame.f_lasti + + instructions = {i.offset: i for i in dis.get_instructions(frame.f_code)} + + # skip CACHE instructions + while offset not in instructions and offset >= 0: + offset -= 1 + + instruction = instructions[offset] + if sys.version_info >= (3, 11): + position = instruction.positions + else: + position = instruction.starts_line + + locations.append((msg, instruction.opname, position)) + + globals = {"loc": loc} + + m = rewrite(s) + mod = compile(m, "", "exec") + exec(mod, globals, globals) + transformed_locations = locations + locations = [] + + mod = compile(s, "", "exec") + exec(mod, globals, globals) + original_locations = locations + + assert len(original_locations) > 0 + assert original_locations == transformed_locations + + preserved(""" + def f(): + loc() + return 8 + + assert f() in [8] + assert (f() + in + [8]) + """) + + preserved(""" + class T: + def __init__(self): + loc("init") + def __getitem__(self,index): + loc("getitem") + return index + + assert T()[5] == 5 + assert (T + () + [5] + == + 5) + """) + + for name, op in [ + ("pos", "+"), + ("neg", "-"), + ("invert", "~"), + ]: + preserved(f""" + class T: + def __{name}__(self): + loc("{name}") + return "{name}" + + assert {op}T() == "{name}" + assert ({op} + T + () + == + "{name}") + """) + + for name, op in [ + ("add", "+"), + ("sub", "-"), + ("mul", "*"), + ("truediv", "/"), + ("floordiv", "//"), + ("mod", "%"), + ("pow", "**"), + ("lshift", "<<"), + ("rshift", ">>"), + ("or", "|"), + ("xor", "^"), + ("and", "&"), + ("matmul", "@"), + ]: + preserved(f""" + class T: + def __{name}__(self,other): + loc("{name}") + return other + + def __r{name}__(self,other): + loc("r{name}") + return other + + assert T() {op} 2 == 2 + assert 2 {op} T() == 2 + + assert (T + () + {op} + 2 + == + 2) + + assert (2 + {op} + T + () + == + 2) + """) + + for name, op in [ + ("eq", "=="), + ("ne", "!="), + ("lt", "<"), + ("le", "<="), + ("gt", ">"), + ("ge", ">="), + ]: + preserved(f""" + class T: + def __{name}__(self,other): + loc() + return True + + assert T() {op} 5 + assert (T + () + {op} + 5) + """) + + for name, op in [ + ("eq", "=="), + ("ne", "!="), + ("lt", ">"), + ("le", ">="), + ("gt", "<"), + ("ge", "<="), + ("contains", "in"), + ]: + preserved(f""" + class T: + def __{name}__(self,other): + loc() + return True + + assert 5 {op} T() + assert (5 + {op} + T + ()) + """) + + preserved(""" + def func(value): + loc("func") + return value + + class T: + def __iter__(self): + loc("iter") + return iter([5]) + + assert func(*T()) == 5 + """) + + preserved(""" + class T: + def __getattr__(self,name): + loc() + return name + + assert T().attr == "attr" + """) def test_dont_rewrite(self) -> None: s = """'PYTEST_DONT_REWRITE'\nassert 14""" From 23256dd9677db448a36c9e863cd1591d68c8ce94 Mon Sep 17 00:00:00 2001 From: Christopher Head Date: Wed, 9 Oct 2024 12:13:56 -0700 Subject: [PATCH 092/445] Prohibit pytest.mark.usefixtures in pytest.param (#12828) Mitigates #4112 a bit. Co-authored-by: Bruno Oliveira --- AUTHORS | 1 + changelog/4112.improvement.rst | 1 + src/_pytest/mark/__init__.py | 7 ++++++- src/_pytest/mark/structures.py | 5 +++++ testing/python/integration.py | 17 +++++++++++++++++ 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 changelog/4112.improvement.rst diff --git a/AUTHORS b/AUTHORS index a42f4ab0c13..47a83379224 100644 --- a/AUTHORS +++ b/AUTHORS @@ -95,6 +95,7 @@ Christine Mecklenborg Christoph Buelter Christopher Dignam Christopher Gilling +Christopher Head Claire Cecil Claudio Madotto Clément M.T. Robert diff --git a/changelog/4112.improvement.rst b/changelog/4112.improvement.rst new file mode 100644 index 00000000000..426b87ffa19 --- /dev/null +++ b/changelog/4112.improvement.rst @@ -0,0 +1 @@ +Using :ref:`pytest.mark.usefixtures ` on :func:`pytest.param` now produces an error instead of silently doing nothing. diff --git a/src/_pytest/mark/__init__.py b/src/_pytest/mark/__init__.py index a4f942c5ae3..f76e5212057 100644 --- a/src/_pytest/mark/__init__.py +++ b/src/_pytest/mark/__init__.py @@ -66,7 +66,12 @@ def test_eval(test_input, expected): assert eval(test_input) == expected :param values: Variable args of the values of the parameter set, in order. - :param marks: A single mark or a list of marks to be applied to this parameter set. + + :param marks: + A single mark or a list of marks to be applied to this parameter set. + + :ref:`pytest.mark.usefixtures ` cannot be added via this parameter. + :param id: The id to attribute to this parameter set. """ return ParameterSet.param(*values, marks=marks, id=id) diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 92ade55f7c0..8a92c9470a7 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -88,6 +88,11 @@ def param( marks = (marks,) else: assert isinstance(marks, collections.abc.Collection) + if any(i.name == "usefixtures" for i in marks): + raise ValueError( + "pytest.param cannot add pytest.mark.usefixtures; see " + "https://docs.pytest.org/en/stable/reference/reference.html#pytest-param" + ) if id is not None: if not isinstance(id, str): diff --git a/testing/python/integration.py b/testing/python/integration.py index c52a683a322..c96b6e4c260 100644 --- a/testing/python/integration.py +++ b/testing/python/integration.py @@ -407,6 +407,23 @@ def test_params(a, b): res = pytester.runpytest("--collect-only") res.stdout.fnmatch_lines(["*spam-2*", "*ham-2*"]) + def test_param_rejects_usefixtures(self, pytester: Pytester) -> None: + pytester.makepyfile( + """ + import pytest + + @pytest.mark.parametrize("x", [ + pytest.param(1, marks=[pytest.mark.usefixtures("foo")]), + ]) + def test_foo(x): + pass + """ + ) + res = pytester.runpytest("--collect-only") + res.stdout.fnmatch_lines( + ["*test_param_rejects_usefixtures.py:4*", "*pytest.param(*"] + ) + def test_function_instance(pytester: Pytester) -> None: items = pytester.getitems( From a14c718867a9e7a664e2c957fd4694a4b5cc355b Mon Sep 17 00:00:00 2001 From: moajo Date: Thu, 10 Oct 2024 05:52:26 +0900 Subject: [PATCH 093/445] Fix `disable_test_id_escaping_and_forfeit_all_rights_to_community_support` option when using `pytest.param(..., id="...")` Fixes #9037 --------- Co-authored-by: Ronny Pfannschmidt Co-authored-by: Bruno Oliveira --- AUTHORS | 1 + changelog/9037.bugfix.rst | 1 + doc/en/reference/reference.rst | 23 +++++++++++++++++++++++ src/_pytest/mark/structures.py | 2 -- src/_pytest/python.py | 2 +- testing/python/metafunc.py | 31 +++++++++++++++++++++++++++++++ 6 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 changelog/9037.bugfix.rst diff --git a/AUTHORS b/AUTHORS index 47a83379224..69089354a44 100644 --- a/AUTHORS +++ b/AUTHORS @@ -408,6 +408,7 @@ Sviatoslav Sydorenko Sylvain Marié Tadek Teleżyński Takafumi Arakaki +Takumi Otani Taneli Hukkinen Tanvi Mehta Tanya Agarwal diff --git a/changelog/9037.bugfix.rst b/changelog/9037.bugfix.rst new file mode 100644 index 00000000000..5367452337e --- /dev/null +++ b/changelog/9037.bugfix.rst @@ -0,0 +1 @@ +Honor :confval:`disable_test_id_escaping_and_forfeit_all_rights_to_community_support` when escaping ids in parametrized tests. diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 3bb03cc0386..baf781d4356 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1332,6 +1332,29 @@ passed multiple times. The expected format is ``name=value``. For example:: console_output_style = classic +.. confval:: disable_test_id_escaping_and_forfeit_all_rights_to_community_support + + .. versionadded:: 4.4 + + pytest by default escapes any non-ascii characters used in unicode strings + for the parametrization because it has several downsides. + If however you would like to use unicode strings in parametrization + and see them in the terminal as is (non-escaped), use this option + in your ``pytest.ini``: + + .. code-block:: ini + + [pytest] + disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True + + Keep in mind however that this might cause unwanted side effects and + even bugs depending on the OS used and plugins currently installed, + so use it at your own risk. + + Default: ``False``. + + See :ref:`parametrizemark`. + .. confval:: doctest_encoding diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 8a92c9470a7..14650a64759 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -21,7 +21,6 @@ import warnings from .._code import getfslineno -from ..compat import ascii_escaped from ..compat import NOTSET from ..compat import NotSetType from _pytest.config import Config @@ -97,7 +96,6 @@ def param( if id is not None: if not isinstance(id, str): raise TypeError(f"Expected id to be a string, got {type(id)}: {id!r}") - id = ascii_escaped(id) return cls(values, marks, id) @classmethod diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 9c54dd20f80..dde442e8eda 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -924,7 +924,7 @@ def _resolve_ids(self) -> Iterable[str]: for idx, parameterset in enumerate(self.parametersets): if parameterset.id is not None: # ID provided directly - pytest.param(..., id="...") - yield parameterset.id + yield _ascii_escaped_by_config(parameterset.id, self.config) elif self.ids and idx < len(self.ids) and self.ids[idx] is not None: # ID provided in the IDs list - parametrize(..., ids=[...]). yield self._idval_from_value_required(self.ids[idx], idx) diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index be224d9e20b..0a4ebf2c9af 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -625,6 +625,37 @@ def getini(self, name): ).make_unique_parameterset_ids() assert result == [expected] + def test_idmaker_with_param_id_and_config(self) -> None: + """Unit test for expected behavior to create ids with pytest.param(id=...) and + disable_test_id_escaping_and_forfeit_all_rights_to_community_support + option (#9037). + """ + + class MockConfig: + def __init__(self, config): + self.config = config + + def getini(self, name): + return self.config[name] + + option = "disable_test_id_escaping_and_forfeit_all_rights_to_community_support" + + values: list[tuple[Any, str]] = [ + (MockConfig({option: True}), "ação"), + (MockConfig({option: False}), "a\\xe7\\xe3o"), + ] + for config, expected in values: + result = IdMaker( + ("a",), + [pytest.param("string", id="ação")], + None, + None, + config, + None, + None, + ).make_unique_parameterset_ids() + assert result == [expected] + def test_idmaker_duplicated_empty_str(self) -> None: """Regression test for empty strings parametrized more than once (#11563).""" result = IdMaker( From 26a29bdade7efccdf6233942749f02cef57ce694 Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Thu, 10 Oct 2024 12:43:36 +0200 Subject: [PATCH 094/445] Docs: improve/cleanup reference from/to recwarn (#12866) Co-authored-by: Bruno Oliveira --- changelog/12866.doc.rst | 1 + doc/en/builtin.rst | 3 +-- doc/en/how-to/capture-warnings.rst | 17 ++++++++--------- doc/en/reference/reference.rst | 3 ++- src/_pytest/recwarn.py | 3 +-- 5 files changed, 13 insertions(+), 14 deletions(-) create mode 100644 changelog/12866.doc.rst diff --git a/changelog/12866.doc.rst b/changelog/12866.doc.rst new file mode 100644 index 00000000000..865b2bbc600 --- /dev/null +++ b/changelog/12866.doc.rst @@ -0,0 +1 @@ +Improved cross-references concerning the :fixture:`recwarn` fixture. diff --git a/doc/en/builtin.rst b/doc/en/builtin.rst index 9b406a6a512..822ee48b3fb 100644 --- a/doc/en/builtin.rst +++ b/doc/en/builtin.rst @@ -234,8 +234,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a recwarn -- .../_pytest/recwarn.py:35 Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions. - See https://docs.pytest.org/en/latest/how-to/capture-warnings.html for information - on warning categories. + See :ref:`warnings` for information on warning categories. tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:242 Return a :class:`pytest.TempPathFactory` instance for the test session. diff --git a/doc/en/how-to/capture-warnings.rst b/doc/en/how-to/capture-warnings.rst index afabad5da14..44ed87508a3 100644 --- a/doc/en/how-to/capture-warnings.rst +++ b/doc/en/how-to/capture-warnings.rst @@ -195,7 +195,7 @@ user code and third-party libraries, as recommended by :pep:`565`. This helps users keep their code modern and avoid breakages when deprecated warnings are effectively removed. However, in the specific case where users capture any type of warnings in their test, either with -:func:`pytest.warns`, :func:`pytest.deprecated_call` or using the :ref:`recwarn ` fixture, +:func:`pytest.warns`, :func:`pytest.deprecated_call` or using the :fixture:`recwarn` fixture, no warning will be displayed at all. Sometimes it is useful to hide some specific deprecation warnings that happen in code that you have no control over @@ -332,10 +332,10 @@ additional information: assert record[0].message.args[0] == "another warning" Alternatively, you can examine raised warnings in detail using the -:ref:`recwarn ` fixture (see below). +:fixture:`recwarn` fixture (see :ref:`below `). -The :ref:`recwarn ` fixture automatically ensures to reset the warnings +The :fixture:`recwarn` fixture automatically ensures to reset the warnings filter at the end of the test, so no global state is leaked. .. _`recording warnings`: @@ -345,8 +345,8 @@ filter at the end of the test, so no global state is leaked. Recording warnings ------------------ -You can record raised warnings either using :func:`pytest.warns` or with -the ``recwarn`` fixture. +You can record raised warnings either using the :func:`pytest.warns` context manager or with +the :fixture:`recwarn` fixture. To record with :func:`pytest.warns` without asserting anything about the warnings, pass no arguments as the expected warning type and it will default to a generic Warning: @@ -361,7 +361,7 @@ pass no arguments as the expected warning type and it will default to a generic assert str(record[0].message) == "user" assert str(record[1].message) == "runtime" -The ``recwarn`` fixture will record warnings for the whole function: +The :fixture:`recwarn` fixture will record warnings for the whole function: .. code-block:: python @@ -377,12 +377,11 @@ The ``recwarn`` fixture will record warnings for the whole function: assert w.filename assert w.lineno -Both ``recwarn`` and :func:`pytest.warns` return the same interface for recorded -warnings: a WarningsRecorder instance. To view the recorded warnings, you can +Both the :fixture:`recwarn` fixture and the :func:`pytest.warns` context manager return the same interface for recorded +warnings: a :class:`~_pytest.recwarn.WarningsRecorder` instance. To view the recorded warnings, you can iterate over this instance, call ``len`` on it to get the number of recorded warnings, or index into it to get a particular recorded warning. -Full API: :class:`~_pytest.recwarn.WarningsRecorder`. .. _`warns use cases`: diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index baf781d4356..b6ec5c65e1e 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -529,13 +529,14 @@ record_testsuite_property recwarn ~~~~~~~ -**Tutorial**: :ref:`assertwarnings` +**Tutorial**: :ref:`recwarn` .. autofunction:: _pytest.recwarn.recwarn() :no-auto-options: .. autoclass:: pytest.WarningsRecorder() :members: + :special-members: __getitem__, __iter__, __len__ .. fixture:: request diff --git a/src/_pytest/recwarn.py b/src/_pytest/recwarn.py index 85d8de84abb..0dc002edd94 100644 --- a/src/_pytest/recwarn.py +++ b/src/_pytest/recwarn.py @@ -35,8 +35,7 @@ def recwarn() -> Generator[WarningsRecorder]: """Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions. - See https://docs.pytest.org/en/latest/how-to/capture-warnings.html for information - on warning categories. + See :ref:`warnings` for information on warning categories. """ wrec = WarningsRecorder(_ispytest=True) with wrec: From 2242cd43eb5601e3f282003c049e37e56ece932a Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Thu, 10 Oct 2024 12:52:08 +0200 Subject: [PATCH 095/445] [pre-commit] Use --python-version for mypy instead of forcing a python interpreter (#12869) --- .pre-commit-config.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a3fa1a428a..7cebd15c0d1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,8 +32,7 @@ repos: hooks: - id: mypy files: ^(src/|testing/|scripts/) - args: [] - language_version: "3.8" + args: ["--python-version=3.8"] additional_dependencies: - iniconfig>=1.1.0 - attrs>=19.2.0 From cfd2e209e3958a4f5b0857707f3c6328418fde55 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Thu, 10 Oct 2024 14:31:36 +0200 Subject: [PATCH 096/445] [mypy] python-version independant from pre-commit --- .pre-commit-config.yaml | 1 - pyproject.toml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7cebd15c0d1..c0d7750cf43 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,7 +32,6 @@ repos: hooks: - id: mypy files: ^(src/|testing/|scripts/) - args: ["--python-version=3.8"] additional_dependencies: - iniconfig>=1.1.0 - attrs>=19.2.0 diff --git a/pyproject.toml b/pyproject.toml index 2fd11df1bf4..caeb4bf7f83 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -481,6 +481,7 @@ files = [ mypy_path = [ "src", ] +python_version = "3.8" check_untyped_defs = true disallow_any_generics = true disallow_untyped_defs = true From f92597c664a6caec8b09703eb341af24307466be Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 13 Oct 2024 14:13:51 +0200 Subject: [PATCH 097/445] Fix pdb selftests on Python 3.13 Python 3.13 makes pdb break on the breakpoint() call, rather than on the next line: https://docs.python.org/3/whatsnew/3.13.html#pdb Also runs the pdb tests on Python 3.13 in CI. See #12884 for a more proper solution for that. Fixes #12497 --- .github/workflows/test.yml | 2 +- changelog/12497.contrib.rst | 1 + testing/test_debugging.py | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 changelog/12497.contrib.rst diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e66f5eae5c..ff5b18e2fca 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -147,7 +147,7 @@ jobs: - name: "ubuntu-py313" python: "3.13-dev" os: ubuntu-latest - tox_env: "py313" + tox_env: "py313-pexpect" use_coverage: true - name: "ubuntu-pypy3" python: "pypy-3.9" diff --git a/changelog/12497.contrib.rst b/changelog/12497.contrib.rst new file mode 100644 index 00000000000..ccf89731053 --- /dev/null +++ b/changelog/12497.contrib.rst @@ -0,0 +1 @@ +Fixed two failing pdb-related tests on Python 3.13. diff --git a/testing/test_debugging.py b/testing/test_debugging.py index d86c9018b80..9588da8936f 100644 --- a/testing/test_debugging.py +++ b/testing/test_debugging.py @@ -771,9 +771,13 @@ def test_pdb_used_outside_test(self, pytester: Pytester) -> None: x = 5 """ ) + if sys.version_info[:2] >= (3, 13): + break_line = "pytest.set_trace()" + else: + break_line = "x = 5" child = pytester.spawn(f"{sys.executable} {p1}") - child.expect("x = 5") - child.expect("Pdb") + child.expect_exact(break_line) + child.expect_exact("Pdb") child.sendeof() self.flush(child) @@ -788,9 +792,13 @@ def test_foo(a): pass """ ) + if sys.version_info[:2] >= (3, 13): + break_line = "pytest.set_trace()" + else: + break_line = "x = 5" child = pytester.spawn_pytest(str(p1)) - child.expect("x = 5") - child.expect("Pdb") + child.expect_exact(break_line) + child.expect_exact("Pdb") child.sendeof() self.flush(child) From b1ad6d3793fd3b560effe7c0034f55091640208b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 13 Oct 2024 17:42:25 +0200 Subject: [PATCH 098/445] [automated] Update plugin list (#12881) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 128 +++++++++++++++++-------------- 1 file changed, 72 insertions(+), 56 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index e09656e3a61..45a6f5fb2ba 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,14 +27,14 @@ please refer to `the update script =8.3 + :pypi:`databricks-labs-pytester` Python Testing for Databricks Oct 11, 2024 4 - Beta pytest>=8.3 :pypi:`logassert` Simple but powerful assertion and verification of logged lines. May 20, 2022 5 - Production/Stable N/A :pypi:`logot` Test whether your code is logging correctly 🪵 Mar 23, 2024 5 - Production/Stable pytest<9,>=7; extra == "pytest" :pypi:`nuts` Network Unit Testing System Jul 19, 2024 N/A pytest<8,>=7 @@ -137,7 +137,7 @@ This list contains 1529 plugins. :pypi:`pytest-aws` pytest plugin for testing AWS resource configurations Oct 04, 2017 4 - Beta N/A :pypi:`pytest-aws-apigateway` pytest plugin for AWS ApiGateway May 24, 2024 4 - Beta pytest :pypi:`pytest-aws-config` Protect your AWS credentials in unit tests May 28, 2021 N/A N/A - :pypi:`pytest-aws-fixtures` A series of fixtures to use in integration tests involving actual AWS services. Jul 30, 2024 N/A pytest<9.0.0,>=8.0.0 + :pypi:`pytest-aws-fixtures` A series of fixtures to use in integration tests involving actual AWS services. Oct 07, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-axe` pytest plugin for axe-selenium-python Nov 12, 2018 N/A pytest (>=3.0.0) :pypi:`pytest-axe-playwright-snapshot` A pytest plugin that runs Axe-core on Playwright pages and takes snapshots of the results. Jul 25, 2023 N/A pytest :pypi:`pytest-azure` Pytest utilities and mocks for Azure Jan 18, 2023 3 - Alpha pytest @@ -150,14 +150,14 @@ This list contains 1529 plugins. :pypi:`pytest-bazel` A pytest runner with bazel support Sep 27, 2024 4 - Beta pytest :pypi:`pytest-bdd` BDD for pytest Sep 26, 2024 6 - Mature pytest>=6.2.0 :pypi:`pytest-bdd-html` pytest plugin to display BDD info in HTML test report Nov 22, 2022 3 - Alpha pytest (!=6.0.0,>=5.0) - :pypi:`pytest-bdd-ng` BDD for pytest Sep 01, 2024 4 - Beta pytest>=5.0 + :pypi:`pytest-bdd-ng` BDD for pytest Oct 07, 2024 4 - Beta pytest>=5.0 :pypi:`pytest-bdd-report` A pytest-bdd plugin for generating useful and informative BDD test reports Aug 26, 2024 N/A pytest>=7.1.3 :pypi:`pytest-bdd-splinter` Common steps for pytest bdd and splinter integration Aug 12, 2019 5 - Production/Stable pytest (>=4.0.0) :pypi:`pytest-bdd-web` A simple plugin to use with pytest Jan 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Aug 08, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Oct 02, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Oct 11, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -247,14 +247,14 @@ This list contains 1529 plugins. :pypi:`pytest-cleanslate` Collects and executes pytest tests separately Sep 04, 2024 N/A pytest :pypi:`pytest_cleanup` Automated, comprehensive and well-organised pytest test cases. Jan 28, 2020 N/A N/A :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Sep 14, 2024 5 - Production/Stable N/A - :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Aug 15, 2024 N/A pytest<9.0.0,>=8.0.0 + :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Oct 08, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-click` Pytest plugin for Click Feb 11, 2022 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-cli-fixtures` Automatically register fixtures for custom CLI arguments Jul 28, 2022 N/A pytest (~=7.0) :pypi:`pytest-clld` Jul 06, 2022 N/A pytest (>=3.6) :pypi:`pytest-cloud` Distributed tests planner plugin for pytest testing framework. Oct 05, 2020 6 - Mature N/A :pypi:`pytest-cloudflare-worker` pytest plugin for testing cloudflare workers Mar 30, 2021 4 - Beta pytest (>=6.0.0) :pypi:`pytest-cloudist` Distribute tests to cloud machines without fuss Sep 02, 2022 4 - Beta pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-cmake` Provide CMake module for Pytest Aug 16, 2024 N/A pytest<9,>=4 + :pypi:`pytest-cmake` Provide CMake module for Pytest Oct 12, 2024 N/A pytest<9,>=4 :pypi:`pytest-cmake-presets` Execute CMake Presets via pytest Dec 26, 2022 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-cmdline-add-args` Pytest plugin for custom argument handling and Allure reporting. This plugin allows you to add arguments before running a test. Sep 01, 2024 N/A N/A :pypi:`pytest-cobra` PyTest plugin for testing Smart Contracts for Ethereum blockchain. Jun 29, 2019 3 - Alpha pytest (<4.0.0,>=3.7.1) @@ -301,13 +301,14 @@ This list contains 1529 plugins. :pypi:`pytest-cqase` Custom qase pytest plugin Aug 22, 2022 N/A pytest (>=7.1.2,<8.0.0) :pypi:`pytest-cram` Run cram tests with pytest. Aug 08, 2020 N/A N/A :pypi:`pytest-crate` Manages CrateDB instances during your integration tests May 28, 2019 3 - Alpha pytest (>=4.0) + :pypi:`pytest-cratedb` Manage CrateDB instances for integration tests Oct 08, 2024 4 - Beta pytest<9 :pypi:`pytest-crayons` A pytest plugin for colorful print statements Oct 08, 2023 N/A pytest :pypi:`pytest-create` pytest-create Feb 15, 2023 1 - Planning N/A :pypi:`pytest-cricri` A Cricri plugin for pytest. Jan 27, 2018 N/A pytest :pypi:`pytest-crontab` add crontab task in crontab Dec 09, 2019 N/A N/A :pypi:`pytest-csv` CSV output for pytest. Apr 22, 2021 N/A pytest (>=6.0) :pypi:`pytest-csv-params` Pytest plugin for Test Case Parametrization with CSV files Jul 01, 2023 5 - Production/Stable pytest (>=7.4.0,<8.0.0) - :pypi:`pytest-curio` Pytest support for curio. Oct 07, 2020 N/A N/A + :pypi:`pytest-curio` Pytest support for curio. Oct 06, 2024 N/A pytest :pypi:`pytest-curl-report` pytest plugin to generate curl command line report Dec 11, 2016 4 - Beta N/A :pypi:`pytest-custom-concurrency` Custom grouping concurrence for pytest Feb 08, 2021 N/A N/A :pypi:`pytest-custom-exit-code` Exit pytest test session with custom exit code in different scenarios Aug 07, 2019 4 - Beta pytest (>=4.0.2) @@ -500,7 +501,7 @@ This list contains 1529 plugins. :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Aug 13, 2024 4 - Beta pytest>=7 :pypi:`pytest-exasol-backend` Sep 18, 2024 N/A pytest<9,>=7 - :pypi:`pytest-exasol-extension` Sep 18, 2024 N/A pytest<9,>=7 + :pypi:`pytest-exasol-extension` Oct 10, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-itde` Jul 01, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-saas` Aug 06, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-slc` Sep 24, 2024 N/A pytest<9,>=7 @@ -545,7 +546,7 @@ This list contains 1529 plugins. :pypi:`pytest-fastest` Use SCM and coverage to run only needed tests Oct 04, 2023 4 - Beta pytest (>=4.4) :pypi:`pytest-fast-first` Pytest plugin that runs fast tests first Jan 19, 2023 3 - Alpha pytest :pypi:`pytest-faulthandler` py.test plugin that activates the fault handler module for tests (dummy package) Jul 04, 2019 6 - Mature pytest (>=5.0) - :pypi:`pytest-fauna` A collection of helpful test fixtures for Fauna DB. Jul 31, 2024 N/A N/A + :pypi:`pytest-fauna` A collection of helpful test fixtures for Fauna DB. Oct 10, 2024 N/A N/A :pypi:`pytest-fauxfactory` Integration of fauxfactory into pytest. Dec 06, 2017 5 - Production/Stable pytest (>=3.2) :pypi:`pytest-figleaf` py.test figleaf coverage plugin Jan 18, 2010 5 - Production/Stable N/A :pypi:`pytest-file` Pytest File Mar 18, 2024 1 - Planning N/A @@ -600,7 +601,7 @@ This list contains 1529 plugins. :pypi:`pytest-frozen-uuids` Deterministically frozen UUID's for your tests Apr 17, 2022 N/A pytest (>=3.0) :pypi:`pytest-func-cov` Pytest plugin for measuring function coverage Apr 15, 2021 3 - Alpha pytest (>=5) :pypi:`pytest-funparam` An alternative way to parametrize test cases. Dec 02, 2021 4 - Beta pytest >=4.6.0 - :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Oct 03, 2024 N/A pytest + :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Oct 11, 2024 N/A pytest :pypi:`pytest-fxa` pytest plugin for Firefox Accounts Aug 28, 2018 5 - Production/Stable N/A :pypi:`pytest-fxa-mte` pytest plugin for Firefox Accounts Oct 02, 2024 5 - Production/Stable N/A :pypi:`pytest-fxtest` Oct 27, 2020 N/A N/A @@ -659,7 +660,7 @@ This list contains 1529 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Oct 05, 2024 3 - Alpha pytest==8.3.3 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Oct 12, 2024 3 - Alpha pytest==8.3.3 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -711,8 +712,8 @@ This list contains 1529 plugins. :pypi:`pytest-ini` Reuse pytest.ini to store env variables Apr 26, 2022 N/A N/A :pypi:`pytest-initry` Plugin for sending automation test data from Pytest to the initry Apr 30, 2024 N/A pytest<9.0.0,>=8.1.1 :pypi:`pytest-inline` A pytest plugin for writing inline tests. Oct 19, 2023 4 - Beta pytest >=7.0.0 - :pypi:`pytest-inmanta` A py.test plugin providing fixtures to simplify inmanta modules testing. Aug 19, 2024 5 - Production/Stable pytest - :pypi:`pytest-inmanta-extensions` Inmanta tests package Jul 22, 2024 5 - Production/Stable N/A + :pypi:`pytest-inmanta` A py.test plugin providing fixtures to simplify inmanta modules testing. Oct 10, 2024 5 - Production/Stable pytest + :pypi:`pytest-inmanta-extensions` Inmanta tests package Oct 10, 2024 5 - Production/Stable N/A :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Aug 20, 2024 5 - Production/Stable N/A :pypi:`pytest-inmanta-yang` Common fixtures used in inmanta yang related modules Feb 22, 2024 4 - Beta pytest :pypi:`pytest-Inomaly` A simple image diff plugin for pytest Feb 13, 2018 4 - Beta N/A @@ -750,7 +751,7 @@ This list contains 1529 plugins. :pypi:`pytest-jobserver` Limit parallel tests with posix jobserver. May 15, 2019 5 - Production/Stable pytest :pypi:`pytest-joke` Test failures are better served with humor. Oct 08, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-json` Generate JSON test reports Jan 18, 2016 4 - Beta N/A - :pypi:`pytest-json-ctrf` Pytest plugin to generate json report in CTRF (Common Test Report Format) Aug 17, 2024 N/A pytest>6.0.0 + :pypi:`pytest-json-ctrf` Pytest plugin to generate json report in CTRF (Common Test Report Format) Oct 10, 2024 N/A pytest>6.0.0 :pypi:`pytest-json-fixtures` JSON output for the --fixtures flag Mar 14, 2023 4 - Beta N/A :pypi:`pytest-jsonlint` UNKNOWN Aug 04, 2016 N/A N/A :pypi:`pytest-json-report` A pytest plugin to report test results as JSON files Mar 15, 2022 4 - Beta pytest (>=3.8.0) @@ -803,7 +804,7 @@ This list contains 1529 plugins. :pypi:`pytest-live` Live results for pytest Mar 08, 2020 N/A pytest :pypi:`pytest-local-badge` Generate local badges (shields) reporting your test suite status. Jan 15, 2023 N/A pytest (>=6.1.0) :pypi:`pytest-localftpserver` A PyTest plugin which provides an FTP fixture for your tests May 19, 2024 5 - Production/Stable pytest - :pypi:`pytest-localserver` pytest plugin to test server connections locally. Aug 17, 2024 4 - Beta N/A + :pypi:`pytest-localserver` pytest plugin to test server connections locally. Oct 06, 2024 4 - Beta N/A :pypi:`pytest-localstack` Pytest plugin for AWS integration tests Jun 07, 2023 4 - Beta pytest (>=6.0.0,<7.0.0) :pypi:`pytest-lock` pytest-lock is a pytest plugin that allows you to "lock" the results of unit tests, storing them in a local cache. This is particularly useful for tests that are resource-intensive or don't need to be run every time. When the tests are run subsequently, pytest-lock will compare the current results with the locked results and issue a warning if there are any discrepancies. Feb 03, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-lockable` lockable resource plugin for pytest Jan 24, 2024 5 - Production/Stable pytest @@ -843,7 +844,7 @@ This list contains 1529 plugins. :pypi:`pytest-mccabe` pytest plugin to run the mccabe code complexity checker. Jul 22, 2020 3 - Alpha pytest (>=5.4.0) :pypi:`pytest-md` Plugin for generating Markdown reports for pytest results Jul 11, 2019 3 - Alpha pytest (>=4.2.1) :pypi:`pytest-md-report` A pytest plugin to generate test outcomes reports with markdown table format. May 18, 2024 4 - Beta pytest!=6.0.0,<9,>=3.3.2 - :pypi:`pytest-meilisearch` Pytest helpers for testing projects using Meilisearch Aug 27, 2024 N/A pytest>=7.4.3 + :pypi:`pytest-meilisearch` Pytest helpers for testing projects using Meilisearch Oct 08, 2024 N/A pytest>=7.4.3 :pypi:`pytest-memlog` Log memory usage during tests May 03, 2023 N/A pytest (>=7.3.0,<8.0.0) :pypi:`pytest-memprof` Estimates memory consumption of test functions Mar 29, 2019 4 - Beta N/A :pypi:`pytest-memray` A simple plugin to use with pytest Jul 25, 2024 N/A pytest>=7.2 @@ -939,7 +940,7 @@ This list contains 1529 plugins. :pypi:`pytest-object-getter` Import any object from a 3rd party module while mocking its namespace on demand. Jul 31, 2022 5 - Production/Stable pytest :pypi:`pytest-ochrus` pytest results data-base and HTML reporter Feb 21, 2018 4 - Beta N/A :pypi:`pytest-odc` A pytest plugin for simplifying ODC database tests Aug 04, 2023 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-odoo` py.test plugin to run Odoo tests Sep 20, 2024 4 - Beta pytest<8.0.0,>=7.2.0 + :pypi:`pytest-odoo` py.test plugin to run Odoo tests Oct 08, 2024 5 - Production/Stable pytest>=8 :pypi:`pytest-odoo-fixtures` Project description Jun 25, 2019 N/A N/A :pypi:`pytest-oerp` pytest plugin to test OpenERP modules Feb 28, 2012 3 - Alpha N/A :pypi:`pytest-offline` Mar 09, 2023 1 - Planning pytest (>=7.0.0,<8.0.0) @@ -956,6 +957,7 @@ This list contains 1529 plugins. :pypi:`pytest-optional-tests` Easy declaration of optional tests (i.e., that are not run by default) Jul 09, 2019 4 - Beta pytest (>=4.5.0) :pypi:`pytest-orchestration` A pytest plugin for orchestrating tests Jul 18, 2019 N/A N/A :pypi:`pytest-order` pytest plugin to run your tests in a specific order Aug 22, 2024 5 - Production/Stable pytest>=5.0; python_version < "3.10" + :pypi:`pytest-ordered` Declare the order in which tests should run in your pytest.ini Oct 07, 2024 N/A pytest>=6.2.0 :pypi:`pytest-ordering` pytest plugin to run your tests in a specific order Nov 14, 2018 4 - Beta pytest :pypi:`pytest-order-modify` 新增run_marker 来自定义用例的执行顺序 Nov 04, 2022 N/A N/A :pypi:`pytest-osxnotify` OS X notifications for py.test results. May 15, 2015 N/A N/A @@ -1065,10 +1067,10 @@ This list contains 1529 plugins. :pypi:`pytest-pusher` pytest plugin for push report to minio Jan 06, 2023 5 - Production/Stable pytest (>=3.6) :pypi:`pytest-py125` Dec 03, 2022 N/A N/A :pypi:`pytest-pycharm` Plugin for py.test to enter PyCharm debugger on uncaught exceptions Aug 13, 2020 5 - Production/Stable pytest (>=2.3) - :pypi:`pytest-pycodestyle` pytest plugin to run pycodestyle Oct 28, 2022 3 - Alpha N/A + :pypi:`pytest-pycodestyle` pytest plugin to run pycodestyle Oct 10, 2024 3 - Alpha pytest>=7.0 :pypi:`pytest-pydantic-schema-sync` Pytest plugin to synchronise Pydantic model schemas with JSONSchema files Aug 29, 2024 N/A pytest>=6 :pypi:`pytest-pydev` py.test plugin to connect to a remote debug server with PyDev or PyCharm. Nov 15, 2017 3 - Alpha N/A - :pypi:`pytest-pydocstyle` pytest plugin to run pydocstyle Jan 05, 2023 3 - Alpha N/A + :pypi:`pytest-pydocstyle` pytest plugin to run pydocstyle Oct 09, 2024 3 - Alpha pytest>=7.0 :pypi:`pytest-pylint` pytest plugin to check source code with pylint Oct 06, 2023 5 - Production/Stable pytest >=7.0 :pypi:`pytest-pymysql-autorecord` Record PyMySQL queries and mock with the stored data. Sep 02, 2022 N/A N/A :pypi:`pytest-pyodide` Pytest plugin for testing applications that use Pyodide Jul 23, 2024 N/A pytest @@ -1144,7 +1146,7 @@ This list contains 1529 plugins. :pypi:`pytest-repo-health` A pytest plugin to report on repository standards conformance Apr 17, 2023 3 - Alpha pytest :pypi:`pytest-report` Creates json report that is compatible with atom.io's linter message format May 11, 2016 4 - Beta N/A :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest - :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Aug 08, 2024 4 - Beta N/A + :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Oct 11, 2024 4 - Beta N/A :pypi:`pytest-reporter-html-dots` A basic HTML report for pytest using Jinja2 template engine. Jan 22, 2023 N/A N/A :pypi:`pytest-reportinfra` Pytest plugin for reportinfra Aug 11, 2019 3 - Alpha N/A :pypi:`pytest-reporting` A plugin to report summarized results in a table format Oct 25, 2019 4 - Beta pytest (>=3.5.0) @@ -1217,7 +1219,7 @@ This list contains 1529 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Oct 04, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Oct 07, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 :pypi:`pytest-schedule` The job of test scheduling for humans. Jan 07, 2023 5 - Production/Stable N/A @@ -1228,7 +1230,7 @@ This list contains 1529 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Oct 04, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Oct 07, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1495,7 +1497,7 @@ This list contains 1529 plugins. :pypi:`pytest-voluptuous` Pytest plugin for asserting data against voluptuous schema. Jun 09, 2020 N/A pytest :pypi:`pytest-vscodedebug` A pytest plugin to easily enable debugging tests within Visual Studio Code Dec 04, 2020 4 - Beta N/A :pypi:`pytest-vscode-pycharm-cls` A PyTest helper to enable start remote debugger on test start or failure or when pytest.set_trace is used. Feb 01, 2023 N/A pytest - :pypi:`pytest-vtestify` A pytest plugin for visual assertion using SSIM and image comparison. Oct 03, 2024 N/A pytest + :pypi:`pytest-vtestify` A pytest plugin for visual assertion using SSIM and image comparison. Oct 10, 2024 N/A pytest :pypi:`pytest-vts` pytest plugin for automatic recording of http stubbed tests Jun 05, 2019 N/A pytest (>=2.3) :pypi:`pytest-vulture` A pytest plugin to checks dead code with vulture Jun 01, 2023 N/A pytest (>=7.0.0) :pypi:`pytest-vw` pytest-vw makes your failing test cases succeed under CI tools scrutiny Oct 07, 2015 4 - Beta N/A @@ -1527,7 +1529,7 @@ This list contains 1529 plugins. :pypi:`pytest-xdist-worker-stats` A pytest plugin to list worker statistics after a xdist run. Apr 16, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-xfaillist` Maintain a xfaillist in an additional file to avoid merge-conflicts. Sep 17, 2021 N/A pytest (>=6.2.2,<7.0.0) :pypi:`pytest-xfiles` Pytest fixtures providing data read from function, module or package related (x)files. Feb 27, 2018 N/A N/A - :pypi:`pytest-xflaky` A simple plugin to use with pytest Oct 04, 2024 4 - Beta pytest>=8.2.1 + :pypi:`pytest-xflaky` A simple plugin to use with pytest Oct 08, 2024 4 - Beta pytest>=8.2.1 :pypi:`pytest-xiuyu` This is a pytest plugin Jul 25, 2023 5 - Production/Stable N/A :pypi:`pytest-xlog` Extended logging for test and decorators May 31, 2020 4 - Beta N/A :pypi:`pytest-xlsx` pytest plugin for generating test cases by xlsx(excel) Aug 07, 2024 N/A pytest~=8.2.2 @@ -1556,7 +1558,7 @@ This list contains 1529 plugins. :pypi:`pytest-zcc` eee Jun 02, 2024 N/A N/A :pypi:`pytest-zebrunner` Pytest connector for Zebrunner reporting Jul 04, 2024 5 - Production/Stable pytest>=4.5.0 :pypi:`pytest-zeebe` Pytest fixtures for testing Camunda 8 processes using a Zeebe test engine. Feb 01, 2024 N/A pytest (>=7.4.2,<8.0.0) - :pypi:`pytest-zephyr-scale-integration` A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest Sep 23, 2024 N/A pytest + :pypi:`pytest-zephyr-scale-integration` A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest Oct 08, 2024 N/A pytest :pypi:`pytest-zephyr-telegram` Плагин для отправки данных автотестов в Телеграм и Зефир Sep 30, 2024 N/A pytest==8.3.2 :pypi:`pytest-zest` Zesty additions to pytest. Nov 17, 2022 N/A N/A :pypi:`pytest-zhongwen-wendang` PyTest 中文文档 Mar 04, 2024 4 - Beta N/A @@ -1569,7 +1571,7 @@ This list contains 1529 plugins. :pypi:`databricks-labs-pytester` - *last release*: Sep 24, 2024, + *last release*: Oct 11, 2024, *status*: 4 - Beta, *requires*: pytest>=8.3 @@ -2290,7 +2292,7 @@ This list contains 1529 plugins. Protect your AWS credentials in unit tests :pypi:`pytest-aws-fixtures` - *last release*: Jul 30, 2024, + *last release*: Oct 07, 2024, *status*: N/A, *requires*: pytest<9.0.0,>=8.0.0 @@ -2381,7 +2383,7 @@ This list contains 1529 plugins. pytest plugin to display BDD info in HTML test report :pypi:`pytest-bdd-ng` - *last release*: Sep 01, 2024, + *last release*: Oct 07, 2024, *status*: 4 - Beta, *requires*: pytest>=5.0 @@ -2430,7 +2432,7 @@ This list contains 1529 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Oct 02, 2024, + *last release*: Oct 11, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -3060,7 +3062,7 @@ This list contains 1529 plugins. A cleanup plugin for pytest :pypi:`pytest-clerk` - *last release*: Aug 15, 2024, + *last release*: Oct 08, 2024, *status*: N/A, *requires*: pytest<9.0.0,>=8.0.0 @@ -3109,7 +3111,7 @@ This list contains 1529 plugins. Distribute tests to cloud machines without fuss :pypi:`pytest-cmake` - *last release*: Aug 16, 2024, + *last release*: Oct 12, 2024, *status*: N/A, *requires*: pytest<9,>=4 @@ -3437,6 +3439,13 @@ This list contains 1529 plugins. Manages CrateDB instances during your integration tests + :pypi:`pytest-cratedb` + *last release*: Oct 08, 2024, + *status*: 4 - Beta, + *requires*: pytest<9 + + Manage CrateDB instances for integration tests + :pypi:`pytest-crayons` *last release*: Oct 08, 2023, *status*: N/A, @@ -3480,9 +3489,9 @@ This list contains 1529 plugins. Pytest plugin for Test Case Parametrization with CSV files :pypi:`pytest-curio` - *last release*: Oct 07, 2020, + *last release*: Oct 06, 2024, *status*: N/A, - *requires*: N/A + *requires*: pytest Pytest support for curio. @@ -4831,7 +4840,7 @@ This list contains 1529 plugins. :pypi:`pytest-exasol-extension` - *last release*: Sep 18, 2024, + *last release*: Oct 10, 2024, *status*: N/A, *requires*: pytest<9,>=7 @@ -5146,7 +5155,7 @@ This list contains 1529 plugins. py.test plugin that activates the fault handler module for tests (dummy package) :pypi:`pytest-fauna` - *last release*: Jul 31, 2024, + *last release*: Oct 10, 2024, *status*: N/A, *requires*: N/A @@ -5531,7 +5540,7 @@ This list contains 1529 plugins. An alternative way to parametrize test cases. :pypi:`pytest-fv` - *last release*: Oct 03, 2024, + *last release*: Oct 11, 2024, *status*: N/A, *requires*: pytest @@ -5944,7 +5953,7 @@ This list contains 1529 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Oct 05, 2024, + *last release*: Oct 12, 2024, *status*: 3 - Alpha, *requires*: pytest==8.3.3 @@ -6308,14 +6317,14 @@ This list contains 1529 plugins. A pytest plugin for writing inline tests. :pypi:`pytest-inmanta` - *last release*: Aug 19, 2024, + *last release*: Oct 10, 2024, *status*: 5 - Production/Stable, *requires*: pytest A py.test plugin providing fixtures to simplify inmanta modules testing. :pypi:`pytest-inmanta-extensions` - *last release*: Jul 22, 2024, + *last release*: Oct 10, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -6581,7 +6590,7 @@ This list contains 1529 plugins. Generate JSON test reports :pypi:`pytest-json-ctrf` - *last release*: Aug 17, 2024, + *last release*: Oct 10, 2024, *status*: N/A, *requires*: pytest>6.0.0 @@ -6952,7 +6961,7 @@ This list contains 1529 plugins. A PyTest plugin which provides an FTP fixture for your tests :pypi:`pytest-localserver` - *last release*: Aug 17, 2024, + *last release*: Oct 06, 2024, *status*: 4 - Beta, *requires*: N/A @@ -7232,7 +7241,7 @@ This list contains 1529 plugins. A pytest plugin to generate test outcomes reports with markdown table format. :pypi:`pytest-meilisearch` - *last release*: Aug 27, 2024, + *last release*: Oct 08, 2024, *status*: N/A, *requires*: pytest>=7.4.3 @@ -7904,9 +7913,9 @@ This list contains 1529 plugins. A pytest plugin for simplifying ODC database tests :pypi:`pytest-odoo` - *last release*: Sep 20, 2024, - *status*: 4 - Beta, - *requires*: pytest<8.0.0,>=7.2.0 + *last release*: Oct 08, 2024, + *status*: 5 - Production/Stable, + *requires*: pytest>=8 py.test plugin to run Odoo tests @@ -8022,6 +8031,13 @@ This list contains 1529 plugins. pytest plugin to run your tests in a specific order + :pypi:`pytest-ordered` + *last release*: Oct 07, 2024, + *status*: N/A, + *requires*: pytest>=6.2.0 + + Declare the order in which tests should run in your pytest.ini + :pypi:`pytest-ordering` *last release*: Nov 14, 2018, *status*: 4 - Beta, @@ -8786,9 +8802,9 @@ This list contains 1529 plugins. Plugin for py.test to enter PyCharm debugger on uncaught exceptions :pypi:`pytest-pycodestyle` - *last release*: Oct 28, 2022, + *last release*: Oct 10, 2024, *status*: 3 - Alpha, - *requires*: N/A + *requires*: pytest>=7.0 pytest plugin to run pycodestyle @@ -8807,9 +8823,9 @@ This list contains 1529 plugins. py.test plugin to connect to a remote debug server with PyDev or PyCharm. :pypi:`pytest-pydocstyle` - *last release*: Jan 05, 2023, + *last release*: Oct 09, 2024, *status*: 3 - Alpha, - *requires*: N/A + *requires*: pytest>=7.0 pytest plugin to run pydocstyle @@ -9339,7 +9355,7 @@ This list contains 1529 plugins. Generate Pytest reports with templates :pypi:`pytest-reporter-html1` - *last release*: Aug 08, 2024, + *last release*: Oct 11, 2024, *status*: 4 - Beta, *requires*: N/A @@ -9850,7 +9866,7 @@ This list contains 1529 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Oct 04, 2024, + *last release*: Oct 07, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9927,7 +9943,7 @@ This list contains 1529 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Oct 04, 2024, + *last release*: Oct 07, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -11796,7 +11812,7 @@ This list contains 1529 plugins. A PyTest helper to enable start remote debugger on test start or failure or when pytest.set_trace is used. :pypi:`pytest-vtestify` - *last release*: Oct 03, 2024, + *last release*: Oct 10, 2024, *status*: N/A, *requires*: pytest @@ -12020,7 +12036,7 @@ This list contains 1529 plugins. Pytest fixtures providing data read from function, module or package related (x)files. :pypi:`pytest-xflaky` - *last release*: Oct 04, 2024, + *last release*: Oct 08, 2024, *status*: 4 - Beta, *requires*: pytest>=8.2.1 @@ -12223,7 +12239,7 @@ This list contains 1529 plugins. Pytest fixtures for testing Camunda 8 processes using a Zeebe test engine. :pypi:`pytest-zephyr-scale-integration` - *last release*: Sep 23, 2024, + *last release*: Oct 08, 2024, *status*: N/A, *requires*: pytest From d8d607e937bf5a36815007322bf10239f3330475 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 13 Oct 2024 15:33:56 -0300 Subject: [PATCH 099/445] Improve pytest.Config.getoption docstring (#12886) Closes #10558. --------- Co-authored-by: suspe --- AUTHORS | 1 + changelog/10558.doc.rst | 1 + src/_pytest/config/__init__.py | 9 +++++---- testing/test_config.py | 20 +++++++++++++------- 4 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 changelog/10558.doc.rst diff --git a/AUTHORS b/AUTHORS index 69089354a44..c38f74d9980 100644 --- a/AUTHORS +++ b/AUTHORS @@ -118,6 +118,7 @@ Dave Hunt David Díaz-Barquero David Mohr David Paul Röthlisberger +David Peled David Szotten David Vierra Daw-Ran Liou diff --git a/changelog/10558.doc.rst b/changelog/10558.doc.rst new file mode 100644 index 00000000000..1c242b9cf71 --- /dev/null +++ b/changelog/10558.doc.rst @@ -0,0 +1 @@ +Fix ambiguous docstring of :func:`pytest.Config.getoption`. diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index c53661dbeb5..35ab622de31 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1697,11 +1697,12 @@ def _get_override_ini_value(self, name: str) -> str | None: def getoption(self, name: str, default=notset, skip: bool = False): """Return command line option value. - :param name: Name of the option. You may also specify + :param name: Name of the option. You may also specify the literal ``--OPT`` option instead of the "dest" option name. - :param default: Default value if no option of that name exists. - :param skip: If True, raise pytest.skip if option does not exists - or has a None value. + :param default: Fallback value if no option of that name is **declared** via :hook:`pytest_addoption`. + Note this parameter will be ignored when the option is **declared** even if the option's value is ``None``. + :param skip: If ``True``, raise :func:`pytest.skip` if option is undeclared or has a ``None`` value. + Note that even if ``True``, if a default was specified it will be returned instead of a skip. """ name = self._opt2dest.get(name, name) try: diff --git a/testing/test_config.py b/testing/test_config.py index 3f5f884ef7a..13ba66e8f9d 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -636,7 +636,7 @@ def test_config_trace(self, pytester: Pytester) -> None: assert len(values) == 1 assert values[0] == "hello [config]\n" - def test_config_getoption(self, pytester: Pytester) -> None: + def test_config_getoption_declared_option_name(self, pytester: Pytester) -> None: pytester.makeconftest( """ def pytest_addoption(parser): @@ -648,6 +648,18 @@ def pytest_addoption(parser): assert config.getoption(x) == "this" pytest.raises(ValueError, config.getoption, "qweqwe") + config_novalue = pytester.parseconfig() + assert config_novalue.getoption("hello") is None + assert config_novalue.getoption("hello", default=1) is None + assert config_novalue.getoption("hello", default=1, skip=True) == 1 + + def test_config_getoption_undeclared_option_name(self, pytester: Pytester) -> None: + config = pytester.parseconfig() + with pytest.raises(ValueError): + config.getoption("x") + assert config.getoption("x", default=1) == 1 + assert config.getoption("x", default=1, skip=True) == 1 + def test_config_getoption_unicode(self, pytester: Pytester) -> None: pytester.makeconftest( """ @@ -675,12 +687,6 @@ def pytest_addoption(parser): with pytest.raises(pytest.skip.Exception): config.getvalueorskip("hello") - def test_getoption(self, pytester: Pytester) -> None: - config = pytester.parseconfig() - with pytest.raises(ValueError): - config.getvalue("x") - assert config.getoption("x", 1) == 1 - def test_getconftest_pathlist(self, pytester: Pytester, tmp_path: Path) -> None: somepath = tmp_path.joinpath("x", "y", "z") p = tmp_path.joinpath("conftest.py") From 8c894f5120360edc5a35940bcd7f93d112959dca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 09:20:50 +0200 Subject: [PATCH 100/445] build(deps): Bump anyio[curio,trio] in /testing/plugins_integration (#12891) Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 4.6.0 to 4.6.2. - [Release notes](https://github.com/agronholm/anyio/releases) - [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst) - [Commits](https://github.com/agronholm/anyio/compare/4.6.0...4.6.2) --- updated-dependencies: - dependency-name: anyio[curio,trio] dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 9ee706fdc70..98623b7ce22 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,4 +1,4 @@ -anyio[curio,trio]==4.6.0 +anyio[curio,trio]==4.6.2 django==5.1.1 pytest-asyncio==0.24.0 pytest-bdd==7.3.0 From b90c7825d7f047309c1abd7b299fc1e8c68ecec3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 07:33:24 +0000 Subject: [PATCH 101/445] build(deps): Bump django in /testing/plugins_integration (#12890) Bumps [django](https://github.com/django/django) from 5.1.1 to 5.1.2. - [Commits](https://github.com/django/django/compare/5.1.1...5.1.2) --- updated-dependencies: - dependency-name: django dependency-type: direct:production update-type: version-update:semver-patch ... Co-authored-by: Pierre Sassoulas --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 98623b7ce22..c154149652c 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,5 +1,5 @@ anyio[curio,trio]==4.6.2 -django==5.1.1 +django==5.1.2 pytest-asyncio==0.24.0 pytest-bdd==7.3.0 pytest-cov==5.0.0 From 9cc6b501c07e1f1e7f9b72b0bd3fc0fc786a6335 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 22:45:35 -0300 Subject: [PATCH 102/445] [pre-commit.ci] pre-commit autoupdate (#12893) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/tox-dev/pyproject-fmt: 2.2.4 → 2.3.1](https://github.com/tox-dev/pyproject-fmt/compare/2.2.4...2.3.1) - [github.com/asottile/pyupgrade: v3.17.0 → v3.18.0](https://github.com/asottile/pyupgrade/compare/v3.17.0...v3.18.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c0d7750cf43..096228acf9f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -44,13 +44,13 @@ repos: # on <3.11 - exceptiongroup>=1.0.0rc8 - repo: https://github.com/tox-dev/pyproject-fmt - rev: "2.2.4" + rev: "2.3.1" hooks: - id: pyproject-fmt # https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version additional_dependencies: ["tox>=4.9"] - repo: https://github.com/asottile/pyupgrade - rev: v3.17.0 + rev: v3.18.0 hooks: - id: pyupgrade stages: [manual] From 931f87c9f58d797ea28bbf45ae78636d26e23e21 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 20 Oct 2024 18:52:28 +0000 Subject: [PATCH 103/445] [automated] Update plugin list (#12903) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 182 +++++++++++++++++-------------- 1 file changed, 99 insertions(+), 83 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 45a6f5fb2ba..e5bd2f8805b 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =7.0.0 :pypi:`pytest-batch-regression` A pytest plugin to repeat the entire test suite in batches. May 08, 2024 N/A pytest>=6.0.0 :pypi:`pytest-bazel` A pytest runner with bazel support Sep 27, 2024 4 - Beta pytest - :pypi:`pytest-bdd` BDD for pytest Sep 26, 2024 6 - Mature pytest>=6.2.0 + :pypi:`pytest-bdd` BDD for pytest Oct 15, 2024 6 - Mature pytest>=6.2.0 :pypi:`pytest-bdd-html` pytest plugin to display BDD info in HTML test report Nov 22, 2022 3 - Alpha pytest (!=6.0.0,>=5.0) :pypi:`pytest-bdd-ng` BDD for pytest Oct 07, 2024 4 - Beta pytest>=5.0 :pypi:`pytest-bdd-report` A pytest-bdd plugin for generating useful and informative BDD test reports Aug 26, 2024 N/A pytest>=7.1.3 @@ -157,7 +157,7 @@ This list contains 1531 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Aug 08, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Oct 11, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Oct 18, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -254,7 +254,7 @@ This list contains 1531 plugins. :pypi:`pytest-cloud` Distributed tests planner plugin for pytest testing framework. Oct 05, 2020 6 - Mature N/A :pypi:`pytest-cloudflare-worker` pytest plugin for testing cloudflare workers Mar 30, 2021 4 - Beta pytest (>=6.0.0) :pypi:`pytest-cloudist` Distribute tests to cloud machines without fuss Sep 02, 2022 4 - Beta pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-cmake` Provide CMake module for Pytest Oct 12, 2024 N/A pytest<9,>=4 + :pypi:`pytest-cmake` Provide CMake module for Pytest Oct 16, 2024 N/A pytest<9,>=4 :pypi:`pytest-cmake-presets` Execute CMake Presets via pytest Dec 26, 2022 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-cmdline-add-args` Pytest plugin for custom argument handling and Allure reporting. This plugin allows you to add arguments before running a test. Sep 01, 2024 N/A N/A :pypi:`pytest-cobra` PyTest plugin for testing Smart Contracts for Ethereum blockchain. Jun 29, 2019 3 - Alpha pytest (<4.0.0,>=3.7.1) @@ -294,7 +294,7 @@ This list contains 1531 plugins. :pypi:`pytest-cover` Pytest plugin for measuring coverage. Forked from \`pytest-cov\`. Aug 01, 2015 5 - Production/Stable N/A :pypi:`pytest-coverage` Jun 17, 2015 N/A N/A :pypi:`pytest-coverage-context` Coverage dynamic context support for PyTest, including sub-processes Jun 28, 2023 4 - Beta N/A - :pypi:`pytest-coveragemarkers` Using pytest markers to track functional coverage and filtering of tests Sep 30, 2024 N/A pytest<8.0.0,>=7.1.2 + :pypi:`pytest-coveragemarkers` Using pytest markers to track functional coverage and filtering of tests Oct 15, 2024 N/A pytest<8.0.0,>=7.1.2 :pypi:`pytest-cov-exclude` Pytest plugin for excluding tests based on coverage data Apr 29, 2016 4 - Beta pytest (>=2.8.0,<2.9.0); extra == 'dev' :pypi:`pytest_covid` Too many faillure, less tests. Jun 24, 2020 N/A N/A :pypi:`pytest-cpp` Use pytest's runner to discover and execute C++ tests Sep 18, 2024 5 - Production/Stable pytest @@ -360,7 +360,7 @@ This list contains 1531 plugins. :pypi:`pytest-describe` Describe-style plugin for pytest Feb 10, 2024 5 - Production/Stable pytest <9,>=4.6 :pypi:`pytest-describe-it` plugin for rich text descriptions Jul 19, 2019 4 - Beta pytest :pypi:`pytest-deselect-if` A plugin to deselect pytests tests rather than using skipif Mar 24, 2024 4 - Beta pytest>=6.2.0 - :pypi:`pytest-devpi-server` DevPI server fixture for py.test May 28, 2019 5 - Production/Stable pytest + :pypi:`pytest-devpi-server` DevPI server fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-dhos` Common fixtures for pytest in DHOS services and libraries Sep 07, 2022 N/A N/A :pypi:`pytest-diamond` pytest plugin for diamond Aug 31, 2015 4 - Beta N/A :pypi:`pytest-dicom` pytest plugin to provide DICOM fixtures Dec 19, 2018 3 - Alpha pytest @@ -465,14 +465,14 @@ This list contains 1531 plugins. :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Aug 19, 2024 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Aug 19, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Aug 19, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Aug 19, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Aug 19, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Aug 19, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Aug 19, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Aug 19, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Oct 18, 2024 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Oct 18, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Oct 18, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Oct 18, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Oct 18, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Oct 18, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Oct 18, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Oct 18, 2024 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -546,7 +546,7 @@ This list contains 1531 plugins. :pypi:`pytest-fastest` Use SCM and coverage to run only needed tests Oct 04, 2023 4 - Beta pytest (>=4.4) :pypi:`pytest-fast-first` Pytest plugin that runs fast tests first Jan 19, 2023 3 - Alpha pytest :pypi:`pytest-faulthandler` py.test plugin that activates the fault handler module for tests (dummy package) Jul 04, 2019 6 - Mature pytest (>=5.0) - :pypi:`pytest-fauna` A collection of helpful test fixtures for Fauna DB. Oct 10, 2024 N/A N/A + :pypi:`pytest-fauna` A collection of helpful test fixtures for Fauna DB. Oct 17, 2024 N/A N/A :pypi:`pytest-fauxfactory` Integration of fauxfactory into pytest. Dec 06, 2017 5 - Production/Stable pytest (>=3.2) :pypi:`pytest-figleaf` py.test figleaf coverage plugin Jan 18, 2010 5 - Production/Stable N/A :pypi:`pytest-file` Pytest File Mar 18, 2024 1 - Planning N/A @@ -561,7 +561,7 @@ This list contains 1531 plugins. :pypi:`pytest-firefox` pytest plugin to manipulate firefox Aug 08, 2017 3 - Alpha pytest (>=3.0.2) :pypi:`pytest-fixture-classes` Fixtures as classes that work well with dependency injection, autocompletetion, type checkers, and language servers Sep 02, 2023 5 - Production/Stable pytest :pypi:`pytest-fixturecollection` A pytest plugin to collect tests based on fixtures being used by tests Feb 22, 2024 4 - Beta pytest >=3.5.0 - :pypi:`pytest-fixture-config` Fixture configuration utils for py.test May 28, 2019 5 - Production/Stable pytest + :pypi:`pytest-fixture-config` Fixture configuration utils for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-fixture-maker` Pytest plugin to load fixtures from YAML files Sep 21, 2021 N/A N/A :pypi:`pytest-fixture-marker` A pytest plugin to add markers based on fixtures used. Oct 11, 2020 5 - Production/Stable N/A :pypi:`pytest-fixture-order` pytest plugin to control fixture evaluation order May 16, 2022 5 - Production/Stable pytest (>=3.0) @@ -617,7 +617,7 @@ This list contains 1531 plugins. :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Jul 08, 2024 N/A pytest>=3.6 - :pypi:`pytest-git` Git repository fixture for py.test May 28, 2019 5 - Production/Stable pytest + :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-git-diff` Pytest plugin that allows the user to select the tests affected by a range of git commits Apr 02, 2024 N/A N/A @@ -626,7 +626,7 @@ This list contains 1531 plugins. :pypi:`pytest-github-actions-annotate-failures` pytest plugin to annotate failed tests with a workflow command for GitHub Actions May 04, 2023 5 - Production/Stable pytest (>=4.0.0) :pypi:`pytest-github-report` Generate a GitHub report using pytest in GitHub Workflows Jun 03, 2022 4 - Beta N/A :pypi:`pytest-gitignore` py.test plugin to ignore the same files as git Jul 17, 2015 4 - Beta N/A - :pypi:`pytest-gitlab` Pytest Plugin for Gitlab Sep 25, 2024 N/A N/A + :pypi:`pytest-gitlab` Pytest Plugin for Gitlab Oct 16, 2024 N/A N/A :pypi:`pytest-gitlabci-parallelized` Parallelize pytest across GitLab CI workers. Mar 08, 2023 N/A N/A :pypi:`pytest-gitlab-code-quality` Collects warnings while testing and generates a GitLab Code Quality Report. Sep 09, 2024 N/A pytest>=8.1.1 :pypi:`pytest-gitlab-fold` Folds output sections in GitLab CI build log Dec 31, 2023 4 - Beta pytest >=2.6.0 @@ -660,7 +660,7 @@ This list contains 1531 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Oct 12, 2024 3 - Alpha pytest==8.3.3 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Oct 19, 2024 3 - Alpha pytest==8.3.3 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -704,6 +704,7 @@ This list contains 1531 plugins. :pypi:`pytest-import-check` pytest plugin to check whether Python modules can be imported Jul 19, 2024 3 - Alpha pytest>=8.1 :pypi:`pytest-incremental` an incremental test runner (pytest plugin) Apr 24, 2021 5 - Production/Stable N/A :pypi:`pytest-infinity` Jun 09, 2024 N/A pytest<9.0.0,>=8.0.0 + :pypi:`pytest-influx` Pytest plugin for managing your influx instance between test runs Oct 16, 2024 N/A pytest<9.0.0,>=8.3.3 :pypi:`pytest-influxdb` Plugin for influxdb and pytest integration. Apr 20, 2021 N/A N/A :pypi:`pytest-info-collector` pytest plugin to collect information from tests May 26, 2019 3 - Alpha N/A :pypi:`pytest-info-plugin` Get executed interface information in pytest interface automation framework Sep 14, 2023 N/A N/A @@ -731,7 +732,7 @@ This list contains 1531 plugins. :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A - :pypi:`pytest-ipywidgets` Aug 30, 2024 N/A pytest + :pypi:`pytest-ipywidgets` Oct 15, 2024 N/A pytest :pypi:`pytest-isolate` Feb 20, 2023 4 - Beta pytest :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Sep 18, 2024 4 - Beta pytest>=5 :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) @@ -798,7 +799,7 @@ This list contains 1531 plugins. :pypi:`pytest-line-profiler` Profile code executed by pytest Aug 10, 2023 4 - Beta pytest >=3.5.0 :pypi:`pytest-line-profiler-apn` Profile code executed by pytest Dec 05, 2022 N/A pytest (>=3.5.0) :pypi:`pytest-lisa` Pytest plugin for organizing tests. Jan 21, 2021 3 - Alpha pytest (>=6.1.2,<7.0.0) - :pypi:`pytest-listener` A simple network listener May 28, 2019 5 - Production/Stable pytest + :pypi:`pytest-listener` A simple network listener Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-litf` A pytest plugin that stream output in LITF format Jan 18, 2021 4 - Beta pytest (>=3.1.1) :pypi:`pytest-litter` Pytest plugin which verifies that tests do not modify file trees. Nov 23, 2023 4 - Beta pytest >=6.1 :pypi:`pytest-live` Live results for pytest Mar 08, 2020 N/A pytest @@ -820,9 +821,10 @@ This list contains 1531 plugins. :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Sep 30, 2024 4 - Beta pytest>=8.2.2 :pypi:`pytest-loguru` Pytest Loguru Mar 20, 2024 5 - Production/Stable pytest; extra == "test" - :pypi:`pytest-loop` pytest plugin for looping tests Mar 30, 2024 5 - Production/Stable pytest + :pypi:`pytest-loop` pytest plugin for looping tests Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-lsp` A pytest plugin for end-to-end testing of language servers Sep 04, 2024 3 - Alpha pytest :pypi:`pytest-manual-marker` pytest marker for marking manual tests Aug 04, 2022 3 - Alpha pytest>=7 + :pypi:`pytest-mark-count` Get a count of the number of tests marked, unmarked, and unique tests if tests have multiple markers Oct 18, 2024 4 - Beta pytest>=8.0.0 :pypi:`pytest-markdoctest` A pytest plugin to doctest your markdown files Jul 22, 2022 4 - Beta pytest (>=6) :pypi:`pytest-markdown` Test your markdown docs with pytest Jan 15, 2021 4 - Beta pytest (>=6.0.1,<7.0.0) :pypi:`pytest-markdown-docs` Run markdown code fences through pytest Mar 05, 2024 N/A pytest (>=7.0.0) @@ -986,7 +988,7 @@ This list contains 1531 plugins. :pypi:`pytest-paste-config` Allow setting the path to a paste config file Sep 18, 2013 3 - Alpha N/A :pypi:`pytest-patch` An automagic \`patch\` fixture that can patch objects directly or by name. Apr 29, 2023 3 - Alpha pytest (>=7.0.0) :pypi:`pytest-patches` A contextmanager pytest fixture for handling multiple mock patches Aug 30, 2021 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-patterns` pytest plugin to make testing complicated long string output easy to write and easy to debug Jun 14, 2024 4 - Beta N/A + :pypi:`pytest-patterns` pytest plugin to make testing complicated long string output easy to write and easy to debug Oct 19, 2024 4 - Beta pytest>=6 :pypi:`pytest-pdb` pytest plugin which adds pdb helper commands related to pytest. Jul 31, 2018 N/A N/A :pypi:`pytest-peach` pytest plugin for fuzzing with Peach API Security Apr 12, 2019 4 - Beta pytest (>=2.8.7) :pypi:`pytest-pep257` py.test plugin for pep257 Jul 09, 2016 N/A N/A @@ -1050,7 +1052,7 @@ This list contains 1531 plugins. :pypi:`pytest-priority` pytest plugin for add priority for tests Aug 19, 2024 N/A pytest :pypi:`pytest-proceed` Oct 01, 2024 N/A pytest :pypi:`pytest-profiles` pytest plugin for configuration profiles Dec 09, 2021 4 - Beta pytest (>=3.7.0) - :pypi:`pytest-profiling` Profiling plugin for py.test May 28, 2019 5 - Production/Stable pytest + :pypi:`pytest-profiling` Profiling plugin for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-progress` pytest plugin for instant test progress status Jun 18, 2024 5 - Production/Stable pytest>=2.7 :pypi:`pytest-prometheus` Report test pass / failures to a Prometheus PushGateway Oct 03, 2017 N/A N/A :pypi:`pytest-prometheus-pushgateway` Pytest report plugin for Zulip Sep 27, 2022 5 - Production/Stable pytest @@ -1079,7 +1081,7 @@ This list contains 1531 plugins. :pypi:`pytest-pyppeteer` A plugin to run pyppeteer in pytest Apr 28, 2022 N/A pytest (>=6.2.5,<7.0.0) :pypi:`pytest-pyq` Pytest fixture "q" for pyq Mar 10, 2020 5 - Production/Stable N/A :pypi:`pytest-pyramid` pytest_pyramid - provides fixtures for testing pyramid applications with pytest test suite Oct 11, 2023 5 - Production/Stable pytest - :pypi:`pytest-pyramid-server` Pyramid server fixture for py.test May 28, 2019 5 - Production/Stable pytest + :pypi:`pytest-pyramid-server` Pyramid server fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-pyreport` PyReport is a lightweight reporting plugin for Pytest that provides concise HTML report May 05, 2024 N/A pytest :pypi:`pytest-pyright` Pytest plugin for type checking code with Pyright Jan 26, 2024 4 - Beta pytest >=7.0.0 :pypi:`pytest-pyspec` A plugin that transforms the pytest output into a result similar to the RSpec. It enables the use of docstrings to display results and also enables the use of the prefixes "describe", "with" and "it". Aug 17, 2024 N/A pytest<9.0.0,>=8.3.2 @@ -1099,11 +1101,11 @@ This list contains 1531 plugins. :pypi:`pytest-qml` Run QML Tests with pytest Dec 02, 2020 4 - Beta pytest (>=6.0.0) :pypi:`pytest-qr` pytest plugin to generate test result QR codes Nov 25, 2021 4 - Beta N/A :pypi:`pytest-qt` pytest support for PyQt and PySide applications Feb 07, 2024 5 - Production/Stable pytest - :pypi:`pytest-qt-app` QT app fixture for py.test Dec 23, 2015 5 - Production/Stable N/A + :pypi:`pytest-qt-app` QT app fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-quarantine` A plugin for pytest to manage expected test failures Nov 24, 2019 5 - Production/Stable pytest (>=4.6) :pypi:`pytest-quickcheck` pytest plugin to generate random data inspired by QuickCheck Nov 05, 2022 4 - Beta pytest (>=4.0) :pypi:`pytest_quickify` Run test suites with pytest-quickify. Jun 14, 2019 N/A pytest - :pypi:`pytest-rabbitmq` RabbitMQ process and client fixtures for pytest May 08, 2024 5 - Production/Stable pytest>=6.2 + :pypi:`pytest-rabbitmq` RabbitMQ process and client fixtures for pytest Oct 15, 2024 5 - Production/Stable pytest>=6.2 :pypi:`pytest-race` Race conditions tester for pytest Jun 07, 2022 4 - Beta N/A :pypi:`pytest-rage` pytest plugin to implement PEP712 Oct 21, 2011 3 - Alpha N/A :pypi:`pytest-rail` pytest plugin for creating TestRail runs and adding results May 02, 2022 N/A pytest (>=3.6) @@ -1131,7 +1133,7 @@ This list contains 1531 plugins. :pypi:`pytest-regex` Select pytest tests with regular expressions May 29, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-regex-dependency` Management of Pytest dependencies via regex patterns Jun 12, 2022 N/A pytest :pypi:`pytest-regressions` Easy to use fixtures to write regression tests. Aug 31, 2023 5 - Production/Stable pytest >=6.2.0 - :pypi:`pytest-regtest` pytest plugin for snapshot regression testing Oct 05, 2024 N/A pytest>7.2 + :pypi:`pytest-regtest` pytest plugin for snapshot regression testing Oct 17, 2024 N/A pytest>7.2 :pypi:`pytest-relative-order` a pytest plugin that sorts tests using "before" and "after" markers May 17, 2021 4 - Beta N/A :pypi:`pytest-relative-path` Handle relative path in pytest options or ini configs Aug 30, 2024 N/A pytest :pypi:`pytest-relaxed` Relaxed test discovery/organization for pytest Mar 29, 2024 5 - Production/Stable pytest>=7 @@ -1193,7 +1195,7 @@ This list contains 1531 plugins. :pypi:`pytest-rmsis` Sycronise pytest results to Jira RMsis Aug 10, 2022 N/A pytest (>=5.3.5) :pypi:`pytest-rng` Fixtures for seeding tests and making randomness reproducible Aug 08, 2019 5 - Production/Stable pytest :pypi:`pytest-roast` pytest plugin for ROAST configuration override and fixtures Nov 09, 2022 5 - Production/Stable pytest - :pypi:`pytest_robotframework` a pytest plugin that can run both python and robotframework tests while generating robot reports for them Sep 24, 2024 N/A pytest<9,>=7 + :pypi:`pytest_robotframework` a pytest plugin that can run both python and robotframework tests while generating robot reports for them Oct 15, 2024 N/A pytest<9,>=7 :pypi:`pytest-rocketchat` Pytest to Rocket.Chat reporting plugin Apr 18, 2021 5 - Production/Stable N/A :pypi:`pytest-rotest` Pytest integration with rotest Sep 08, 2019 N/A pytest (>=3.5.0) :pypi:`pytest-rpc` Extend py.test for RPC OpenStack testing. Feb 22, 2019 4 - Beta pytest (~=3.6) @@ -1238,7 +1240,7 @@ This list contains 1531 plugins. :pypi:`pytest-sentry` A pytest plugin to send testrun information to Sentry.io Apr 25, 2024 N/A pytest :pypi:`pytest-sequence-markers` Pytest plugin for sequencing markers for execution of tests May 23, 2023 5 - Production/Stable N/A :pypi:`pytest-server` test server exec cmd Sep 09, 2024 N/A N/A - :pypi:`pytest-server-fixtures` Extensible server fixures for py.test Dec 19, 2023 5 - Production/Stable pytest + :pypi:`pytest-server-fixtures` Extensible server fixtures for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-serverless` Automatically mocks resources from serverless.yml in pytest using moto. May 09, 2022 4 - Beta N/A :pypi:`pytest-servers` pytest servers Sep 17, 2024 3 - Alpha pytest>=6.2 :pypi:`pytest-service` Aug 06, 2024 5 - Production/Stable pytest>=6.0.0 @@ -1253,11 +1255,11 @@ This list contains 1531 plugins. :pypi:`pytest-share-hdf` Plugin to save test data in HDF files and retrieve them for comparison Sep 21, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-sharkreport` this is pytest report plugin. Jul 11, 2022 N/A pytest (>=3.5) :pypi:`pytest-shell` A pytest plugin to help with testing shell scripts / black box commands Mar 27, 2022 N/A N/A - :pypi:`pytest-shell-utilities` Pytest plugin to simplify running shell commands against the system Aug 26, 2024 5 - Production/Stable pytest>=7.4.0 + :pypi:`pytest-shell-utilities` Pytest plugin to simplify running shell commands against the system Oct 18, 2024 5 - Production/Stable pytest>=7.4.0 :pypi:`pytest-sheraf` Versatile ZODB abstraction layer - pytest fixtures Feb 11, 2020 N/A pytest :pypi:`pytest-sherlock` pytest plugin help to find coupled tests Aug 14, 2023 5 - Production/Stable pytest >=3.5.1 :pypi:`pytest-shortcuts` Expand command-line shortcuts listed in pytest configuration Oct 29, 2020 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-shutil` A goodie-bag of unix shell and environment tools for py.test May 28, 2019 5 - Production/Stable pytest + :pypi:`pytest-shutil` A goodie-bag of unix shell and environment tools for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-simbind` Pytest plugin to operate with objects generated by Simbind tool. Mar 28, 2024 N/A pytest>=7.0.0 :pypi:`pytest-simplehttpserver` Simple pytest fixture to spin up an HTTP server Jun 24, 2021 4 - Beta N/A :pypi:`pytest-simple-plugin` Simple pytest plugin Nov 27, 2019 N/A N/A @@ -1304,7 +1306,7 @@ This list contains 1531 plugins. :pypi:`pytest-spiratest` Exports unit tests as test runs in Spira (SpiraTest/Team/Plan) Jan 01, 2024 N/A N/A :pypi:`pytest-splinter` Splinter plugin for pytest testing framework Sep 09, 2022 6 - Mature pytest (>=3.0.0) :pypi:`pytest-splinter4` Pytest plugin for the splinter automation library Feb 01, 2024 6 - Mature pytest >=8.0.0 - :pypi:`pytest-split` Pytest plugin which splits the test suite to equally sized sub suites based on test execution time. Jun 19, 2024 4 - Beta pytest<9,>=5 + :pypi:`pytest-split` Pytest plugin which splits the test suite to equally sized sub suites based on test execution time. Oct 16, 2024 4 - Beta pytest<9,>=5 :pypi:`pytest-split-ext` Pytest plugin which splits the test suite to equally sized sub suites based on test execution time. Sep 23, 2023 4 - Beta pytest (>=5,<8) :pypi:`pytest-splitio` Split.io SDK integration for e2e tests Sep 22, 2020 N/A pytest (<7,>=5.0) :pypi:`pytest-split-tests` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Forked from Mark Adams' original project pytest-test-groups. Jul 30, 2021 5 - Production/Stable pytest (>=2.5) @@ -1348,7 +1350,7 @@ This list contains 1531 plugins. :pypi:`pytest-suitemanager` A simple plugin to use with pytest Apr 28, 2023 4 - Beta N/A :pypi:`pytest-suite-timeout` A pytest plugin for ensuring max suite time Jan 26, 2024 N/A pytest>=7.0.0 :pypi:`pytest-supercov` Pytest plugin for measuring explicit test-file to source-file coverage Jul 02, 2023 N/A N/A - :pypi:`pytest-svn` SVN repository fixture for py.test May 28, 2019 5 - Production/Stable pytest + :pypi:`pytest-svn` SVN repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-symbols` pytest-symbols is a pytest plugin that adds support for passing test environment symbols into pytest tests. Nov 20, 2017 3 - Alpha N/A :pypi:`pytest-system-statistics` Pytest plugin to track and report system usage statistics Feb 16, 2022 5 - Production/Stable pytest (>=6.0.0) :pypi:`pytest-system-test-plugin` Pyst - Pytest System-Test Plugin Feb 03, 2022 N/A N/A @@ -1489,9 +1491,9 @@ This list contains 1531 plugins. :pypi:`pytest-vcrpandas` Test from HTTP interactions to dataframe processed. Jan 12, 2019 4 - Beta pytest :pypi:`pytest-vcs` Sep 22, 2022 4 - Beta N/A :pypi:`pytest-venv` py.test fixture for creating a virtual environment Nov 23, 2023 4 - Beta pytest - :pypi:`pytest-verbose-parametrize` More descriptive output for parametrized py.test tests May 28, 2019 5 - Production/Stable pytest + :pypi:`pytest-verbose-parametrize` More descriptive output for parametrized py.test tests Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-vimqf` A simple pytest plugin that will shrink pytest output when specified, to fit vim quickfix window. Feb 08, 2021 4 - Beta pytest (>=6.2.2,<7.0.0) - :pypi:`pytest-virtualenv` Virtualenv fixture for py.test May 28, 2019 5 - Production/Stable pytest + :pypi:`pytest-virtualenv` Virtualenv fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-visual` Nov 01, 2023 3 - Alpha pytest >=7.0.0 :pypi:`pytest-vnc` VNC client for Pytest Nov 06, 2023 N/A pytest :pypi:`pytest-voluptuous` Pytest plugin for asserting data against voluptuous schema. Jun 09, 2020 N/A pytest @@ -1510,7 +1512,7 @@ This list contains 1531 plugins. :pypi:`pytest_wdb` Trace pytest tests with wdb to halt on error with --wdb. Jul 04, 2016 N/A N/A :pypi:`pytest-wdl` Pytest plugin for testing WDL workflows. Nov 17, 2020 5 - Production/Stable N/A :pypi:`pytest-web3-data` A pytest plugin to fetch test data from IPFS HTTP gateways during pytest execution. Oct 04, 2023 4 - Beta pytest - :pypi:`pytest-webdriver` Selenium webdriver fixture for py.test May 28, 2019 5 - Production/Stable pytest + :pypi:`pytest-webdriver` Selenium webdriver fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-webstage` Test web apps with pytest Sep 20, 2024 N/A pytest<9.0,>=7.0 :pypi:`pytest-webtest-extras` Pytest plugin to enhance pytest-html and allure reports of webtest projects by adding screenshots, comments and webpage sources. Oct 03, 2024 N/A pytest>=7.0.0 :pypi:`pytest-wetest` Welian API Automation test framework pytest plugin Nov 10, 2018 4 - Beta N/A @@ -1529,7 +1531,7 @@ This list contains 1531 plugins. :pypi:`pytest-xdist-worker-stats` A pytest plugin to list worker statistics after a xdist run. Apr 16, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-xfaillist` Maintain a xfaillist in an additional file to avoid merge-conflicts. Sep 17, 2021 N/A pytest (>=6.2.2,<7.0.0) :pypi:`pytest-xfiles` Pytest fixtures providing data read from function, module or package related (x)files. Feb 27, 2018 N/A N/A - :pypi:`pytest-xflaky` A simple plugin to use with pytest Oct 08, 2024 4 - Beta pytest>=8.2.1 + :pypi:`pytest-xflaky` A simple plugin to use with pytest Oct 14, 2024 4 - Beta pytest>=8.2.1 :pypi:`pytest-xiuyu` This is a pytest plugin Jul 25, 2023 5 - Production/Stable N/A :pypi:`pytest-xlog` Extended logging for test and decorators May 31, 2020 4 - Beta N/A :pypi:`pytest-xlsx` pytest plugin for generating test cases by xlsx(excel) Aug 07, 2024 N/A pytest~=8.2.2 @@ -1550,7 +1552,7 @@ This list contains 1531 plugins. :pypi:`pytest-yapf` Run yapf Jul 06, 2017 4 - Beta pytest (>=3.1.1) :pypi:`pytest-yapf3` Validate your Python file format with yapf Mar 29, 2023 5 - Production/Stable pytest (>=7) :pypi:`pytest-yield` PyTest plugin to run tests concurrently, each \`yield\` switch context to other one Jan 23, 2019 N/A N/A - :pypi:`pytest-yls` Pytest plugin to test the YLS as a whole. Mar 30, 2024 N/A pytest<8.0.0,>=7.2.2 + :pypi:`pytest-yls` Pytest plugin to test the YLS as a whole. Oct 18, 2024 N/A pytest<9.0.0,>=8.3.3 :pypi:`pytest-youqu-playwright` pytest-youqu-playwright Jun 12, 2024 N/A pytest :pypi:`pytest-yuk` Display tests you are uneasy with, using 🤢/🤮 for pass/fail of tests marked with yuk. Mar 26, 2021 N/A pytest>=5.0.0 :pypi:`pytest-zafira` A Zafira plugin for pytest Sep 18, 2019 5 - Production/Stable pytest (==4.1.1) @@ -1558,7 +1560,7 @@ This list contains 1531 plugins. :pypi:`pytest-zcc` eee Jun 02, 2024 N/A N/A :pypi:`pytest-zebrunner` Pytest connector for Zebrunner reporting Jul 04, 2024 5 - Production/Stable pytest>=4.5.0 :pypi:`pytest-zeebe` Pytest fixtures for testing Camunda 8 processes using a Zeebe test engine. Feb 01, 2024 N/A pytest (>=7.4.2,<8.0.0) - :pypi:`pytest-zephyr-scale-integration` A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest Oct 08, 2024 N/A pytest + :pypi:`pytest-zephyr-scale-integration` A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest Oct 15, 2024 N/A pytest :pypi:`pytest-zephyr-telegram` Плагин для отправки данных автотестов в Телеграм и Зефир Sep 30, 2024 N/A pytest==8.3.2 :pypi:`pytest-zest` Zesty additions to pytest. Nov 17, 2022 N/A N/A :pypi:`pytest-zhongwen-wendang` PyTest 中文文档 Mar 04, 2024 4 - Beta N/A @@ -2369,7 +2371,7 @@ This list contains 1531 plugins. A pytest runner with bazel support :pypi:`pytest-bdd` - *last release*: Sep 26, 2024, + *last release*: Oct 15, 2024, *status*: 6 - Mature, *requires*: pytest>=6.2.0 @@ -2432,7 +2434,7 @@ This list contains 1531 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Oct 11, 2024, + *last release*: Oct 18, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -3111,7 +3113,7 @@ This list contains 1531 plugins. Distribute tests to cloud machines without fuss :pypi:`pytest-cmake` - *last release*: Oct 12, 2024, + *last release*: Oct 16, 2024, *status*: N/A, *requires*: pytest<9,>=4 @@ -3391,7 +3393,7 @@ This list contains 1531 plugins. Coverage dynamic context support for PyTest, including sub-processes :pypi:`pytest-coveragemarkers` - *last release*: Sep 30, 2024, + *last release*: Oct 15, 2024, *status*: N/A, *requires*: pytest<8.0.0,>=7.1.2 @@ -3853,7 +3855,7 @@ This list contains 1531 plugins. A plugin to deselect pytests tests rather than using skipif :pypi:`pytest-devpi-server` - *last release*: May 28, 2019, + *last release*: Oct 17, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -4588,56 +4590,56 @@ This list contains 1531 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: Aug 19, 2024, + *last release*: Oct 18, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: Aug 19, 2024, + *last release*: Oct 18, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: Aug 19, 2024, + *last release*: Oct 18, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: Aug 19, 2024, + *last release*: Oct 18, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. :pypi:`pytest-embedded-qemu` - *last release*: Aug 19, 2024, + *last release*: Oct 18, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: Aug 19, 2024, + *last release*: Oct 18, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: Aug 19, 2024, + *last release*: Oct 18, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: Aug 19, 2024, + *last release*: Oct 18, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -5155,7 +5157,7 @@ This list contains 1531 plugins. py.test plugin that activates the fault handler module for tests (dummy package) :pypi:`pytest-fauna` - *last release*: Oct 10, 2024, + *last release*: Oct 17, 2024, *status*: N/A, *requires*: N/A @@ -5260,7 +5262,7 @@ This list contains 1531 plugins. A pytest plugin to collect tests based on fixtures being used by tests :pypi:`pytest-fixture-config` - *last release*: May 28, 2019, + *last release*: Oct 17, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -5652,7 +5654,7 @@ This list contains 1531 plugins. A set of pytest fixtures for testing Girder applications. :pypi:`pytest-git` - *last release*: May 28, 2019, + *last release*: Oct 17, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -5715,7 +5717,7 @@ This list contains 1531 plugins. py.test plugin to ignore the same files as git :pypi:`pytest-gitlab` - *last release*: Sep 25, 2024, + *last release*: Oct 16, 2024, *status*: N/A, *requires*: N/A @@ -5953,7 +5955,7 @@ This list contains 1531 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Oct 12, 2024, + *last release*: Oct 19, 2024, *status*: 3 - Alpha, *requires*: pytest==8.3.3 @@ -6260,6 +6262,13 @@ This list contains 1531 plugins. + :pypi:`pytest-influx` + *last release*: Oct 16, 2024, + *status*: N/A, + *requires*: pytest<9.0.0,>=8.3.3 + + Pytest plugin for managing your influx instance between test runs + :pypi:`pytest-influxdb` *last release*: Apr 20, 2021, *status*: N/A, @@ -6450,7 +6459,7 @@ This list contains 1531 plugins. THIS PROJECT IS ABANDONED :pypi:`pytest-ipywidgets` - *last release*: Aug 30, 2024, + *last release*: Oct 15, 2024, *status*: N/A, *requires*: pytest @@ -6919,7 +6928,7 @@ This list contains 1531 plugins. Pytest plugin for organizing tests. :pypi:`pytest-listener` - *last release*: May 28, 2019, + *last release*: Oct 17, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -7073,7 +7082,7 @@ This list contains 1531 plugins. Pytest Loguru :pypi:`pytest-loop` - *last release*: Mar 30, 2024, + *last release*: Oct 17, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -7093,6 +7102,13 @@ This list contains 1531 plugins. pytest marker for marking manual tests + :pypi:`pytest-mark-count` + *last release*: Oct 18, 2024, + *status*: 4 - Beta, + *requires*: pytest>=8.0.0 + + Get a count of the number of tests marked, unmarked, and unique tests if tests have multiple markers + :pypi:`pytest-markdoctest` *last release*: Jul 22, 2022, *status*: 4 - Beta, @@ -8235,9 +8251,9 @@ This list contains 1531 plugins. A contextmanager pytest fixture for handling multiple mock patches :pypi:`pytest-patterns` - *last release*: Jun 14, 2024, + *last release*: Oct 19, 2024, *status*: 4 - Beta, - *requires*: N/A + *requires*: pytest>=6 pytest plugin to make testing complicated long string output easy to write and easy to debug @@ -8683,7 +8699,7 @@ This list contains 1531 plugins. pytest plugin for configuration profiles :pypi:`pytest-profiling` - *last release*: May 28, 2019, + *last release*: Oct 17, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -8886,7 +8902,7 @@ This list contains 1531 plugins. pytest_pyramid - provides fixtures for testing pyramid applications with pytest test suite :pypi:`pytest-pyramid-server` - *last release*: May 28, 2019, + *last release*: Oct 17, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -9026,9 +9042,9 @@ This list contains 1531 plugins. pytest support for PyQt and PySide applications :pypi:`pytest-qt-app` - *last release*: Dec 23, 2015, + *last release*: Oct 17, 2024, *status*: 5 - Production/Stable, - *requires*: N/A + *requires*: pytest QT app fixture for py.test @@ -9054,7 +9070,7 @@ This list contains 1531 plugins. Run test suites with pytest-quickify. :pypi:`pytest-rabbitmq` - *last release*: May 08, 2024, + *last release*: Oct 15, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=6.2 @@ -9250,7 +9266,7 @@ This list contains 1531 plugins. Easy to use fixtures to write regression tests. :pypi:`pytest-regtest` - *last release*: Oct 05, 2024, + *last release*: Oct 17, 2024, *status*: N/A, *requires*: pytest>7.2 @@ -9684,7 +9700,7 @@ This list contains 1531 plugins. pytest plugin for ROAST configuration override and fixtures :pypi:`pytest_robotframework` - *last release*: Sep 24, 2024, + *last release*: Oct 15, 2024, *status*: N/A, *requires*: pytest<9,>=7 @@ -9999,11 +10015,11 @@ This list contains 1531 plugins. test server exec cmd :pypi:`pytest-server-fixtures` - *last release*: Dec 19, 2023, + *last release*: Oct 17, 2024, *status*: 5 - Production/Stable, *requires*: pytest - Extensible server fixures for py.test + Extensible server fixtures for py.test :pypi:`pytest-serverless` *last release*: May 09, 2022, @@ -10104,7 +10120,7 @@ This list contains 1531 plugins. A pytest plugin to help with testing shell scripts / black box commands :pypi:`pytest-shell-utilities` - *last release*: Aug 26, 2024, + *last release*: Oct 18, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=7.4.0 @@ -10132,7 +10148,7 @@ This list contains 1531 plugins. Expand command-line shortcuts listed in pytest configuration :pypi:`pytest-shutil` - *last release*: May 28, 2019, + *last release*: Oct 17, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -10461,7 +10477,7 @@ This list contains 1531 plugins. Pytest plugin for the splinter automation library :pypi:`pytest-split` - *last release*: Jun 19, 2024, + *last release*: Oct 16, 2024, *status*: 4 - Beta, *requires*: pytest<9,>=5 @@ -10769,7 +10785,7 @@ This list contains 1531 plugins. Pytest plugin for measuring explicit test-file to source-file coverage :pypi:`pytest-svn` - *last release*: May 28, 2019, + *last release*: Oct 17, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -11756,7 +11772,7 @@ This list contains 1531 plugins. py.test fixture for creating a virtual environment :pypi:`pytest-verbose-parametrize` - *last release*: May 28, 2019, + *last release*: Oct 17, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -11770,7 +11786,7 @@ This list contains 1531 plugins. A simple pytest plugin that will shrink pytest output when specified, to fit vim quickfix window. :pypi:`pytest-virtualenv` - *last release*: May 28, 2019, + *last release*: Oct 17, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -11903,7 +11919,7 @@ This list contains 1531 plugins. A pytest plugin to fetch test data from IPFS HTTP gateways during pytest execution. :pypi:`pytest-webdriver` - *last release*: May 28, 2019, + *last release*: Oct 17, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -12036,7 +12052,7 @@ This list contains 1531 plugins. Pytest fixtures providing data read from function, module or package related (x)files. :pypi:`pytest-xflaky` - *last release*: Oct 08, 2024, + *last release*: Oct 14, 2024, *status*: 4 - Beta, *requires*: pytest>=8.2.1 @@ -12183,9 +12199,9 @@ This list contains 1531 plugins. PyTest plugin to run tests concurrently, each \`yield\` switch context to other one :pypi:`pytest-yls` - *last release*: Mar 30, 2024, + *last release*: Oct 18, 2024, *status*: N/A, - *requires*: pytest<8.0.0,>=7.2.2 + *requires*: pytest<9.0.0,>=8.3.3 Pytest plugin to test the YLS as a whole. @@ -12239,7 +12255,7 @@ This list contains 1531 plugins. Pytest fixtures for testing Camunda 8 processes using a Zeebe test engine. :pypi:`pytest-zephyr-scale-integration` - *last release*: Oct 08, 2024, + *last release*: Oct 15, 2024, *status*: N/A, *requires*: pytest From 26215b8f795a2b13acc1a8827fdfb6a29b502a6a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 09:21:43 +0200 Subject: [PATCH 104/445] build(deps): Bump anyio[curio,trio] in /testing/plugins_integration (#12905) Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 4.6.2 to 4.6.2.post1. - [Release notes](https://github.com/agronholm/anyio/releases) - [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst) - [Commits](https://github.com/agronholm/anyio/compare/4.6.2...4.6.2.post1) --- updated-dependencies: - dependency-name: anyio[curio,trio] dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index c154149652c..d5ed74940d3 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,4 +1,4 @@ -anyio[curio,trio]==4.6.2 +anyio[curio,trio]==4.6.2.post1 django==5.1.2 pytest-asyncio==0.24.0 pytest-bdd==7.3.0 From 922d6841b0fe3dd1030f2ec4b816778a74a3bf84 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 23 Oct 2024 17:12:04 +0200 Subject: [PATCH 105/445] avoid test failing if the working path contains the string 'error' --- testing/python/fixtures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index 46f0a762cbb..c939b221f22 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -2996,7 +2996,7 @@ def test_finish(): *3 passed* """ ) - result.stdout.no_fnmatch_line("*error*") + assert result.ret == 0 def test_fixture_finalizer(self, pytester: Pytester) -> None: pytester.makeconftest( From 216ec3c0ba87b50af11a3fd6f633b69105a7708e Mon Sep 17 00:00:00 2001 From: jakkdl Date: Fri, 25 Oct 2024 13:36:55 +0200 Subject: [PATCH 106/445] Remove PytestReturnNotNoneWarning and PytestUnhandledCoroutineWarning. Make tests fail instead of raising warning/exception. fix tests. add changelog. --- src/_pytest/config/exceptions.py | 3 ++ src/_pytest/python.py | 48 +++++++++++--------------------- src/_pytest/warning_types.py | 18 ------------ src/pytest/__init__.py | 4 --- testing/acceptance_test.py | 12 ++++---- testing/test_unittest.py | 2 +- 6 files changed, 28 insertions(+), 59 deletions(-) diff --git a/src/_pytest/config/exceptions.py b/src/_pytest/config/exceptions.py index 147afb03e26..90108eca904 100644 --- a/src/_pytest/config/exceptions.py +++ b/src/_pytest/config/exceptions.py @@ -1,6 +1,9 @@ from __future__ import annotations +from typing import final + +@final class UsageError(Exception): """Error in pytest usage or invocation.""" diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 180ef439dd6..d48a6c4a9fb 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -51,7 +51,6 @@ from _pytest.config import Config from _pytest.config import hookimpl from _pytest.config.argparsing import Parser -from _pytest.config.exceptions import UsageError from _pytest.deprecated import check_ispytest from _pytest.fixtures import FixtureDef from _pytest.fixtures import FixtureRequest @@ -74,7 +73,6 @@ from _pytest.scope import Scope from _pytest.stash import StashKey from _pytest.warning_types import PytestCollectionWarning -from _pytest.warning_types import PytestReturnNotNoneWarning if TYPE_CHECKING: @@ -135,48 +133,36 @@ def pytest_configure(config: Config) -> None: ) -@final -class PytestUnhandledCoroutineError(UsageError): - """An unraisable exception resulted in an error. - - Unraisable exceptions are exceptions raised in :meth:`__del__ ` - implementations and similar situations when the exception cannot be raised - as normal. - """ - - -def async_warn_and_skip(nodeid: str) -> None: - msg = "async def functions are not natively supported and have been skipped.\n" - msg += ( +def async_fail(nodeid: str) -> None: + msg = ( + "async def functions are not natively supported.\n" "You need to install a suitable plugin for your async framework, for example:\n" + " - anyio\n" + " - pytest-asyncio\n" + " - pytest-tornasync\n" + " - pytest-trio\n" + " - pytest-twisted" ) - msg += " - anyio\n" - msg += " - pytest-asyncio\n" - msg += " - pytest-tornasync\n" - msg += " - pytest-trio\n" - msg += " - pytest-twisted" - raise PytestUnhandledCoroutineError( - msg.format(nodeid) - ) # TODO: This is the warning to look at - skip(reason="async def function and no async plugin installed (see warnings)") + fail(msg, pytrace=False) @hookimpl(trylast=True) def pytest_pyfunc_call(pyfuncitem: Function) -> object | None: testfunction = pyfuncitem.obj if is_async_function(testfunction): - async_warn_and_skip(pyfuncitem.nodeid) + async_fail(pyfuncitem.nodeid) funcargs = pyfuncitem.funcargs testargs = {arg: funcargs[arg] for arg in pyfuncitem._fixtureinfo.argnames} result = testfunction(**testargs) if hasattr(result, "__await__") or hasattr(result, "__aiter__"): - async_warn_and_skip(pyfuncitem.nodeid) + async_fail(pyfuncitem.nodeid) elif result is not None: - warnings.warn( - PytestReturnNotNoneWarning( - f"Expected None, but {pyfuncitem.nodeid} returned {result!r}, which will be an error in a " - "future version of pytest. Did you mean to use `assert` instead of `return`?" - ) + fail( + ( + f"Expected None, but test returned {result!r}. " + "Did you mean to use `assert` instead of `return`?" + ), + pytrace=False, ) return True diff --git a/src/_pytest/warning_types.py b/src/_pytest/warning_types.py index cf189a407c1..b8e9998cd2e 100644 --- a/src/_pytest/warning_types.py +++ b/src/_pytest/warning_types.py @@ -56,12 +56,6 @@ class PytestRemovedIn9Warning(PytestDeprecationWarning): __module__ = "pytest" -class PytestReturnNotNoneWarning(PytestWarning): - """Warning emitted when a test function is returning value other than None.""" - - __module__ = "pytest" - - @final class PytestExperimentalApiWarning(PytestWarning, FutureWarning): """Warning category used to denote experiments in pytest. @@ -77,18 +71,6 @@ def simple(cls, apiname: str) -> PytestExperimentalApiWarning: return cls(f"{apiname} is an experimental api that may change over time") -@final -class PytestUnhandledCoroutineWarning(PytestReturnNotNoneWarning): # TODO: look at this - """Warning emitted for an unhandled coroutine. - - A coroutine was encountered when collecting test functions, but was not - handled by any async-aware plugin. - Coroutine test functions are not natively supported. - """ - - __module__ = "pytest" - - @final class PytestUnknownMarkWarning(PytestWarning): """Warning emitted on use of unknown markers. diff --git a/src/pytest/__init__.py b/src/pytest/__init__.py index 92152b7c7b4..5ab2a22b0c0 100644 --- a/src/pytest/__init__.py +++ b/src/pytest/__init__.py @@ -78,8 +78,6 @@ from _pytest.warning_types import PytestDeprecationWarning from _pytest.warning_types import PytestExperimentalApiWarning from _pytest.warning_types import PytestRemovedIn9Warning -from _pytest.warning_types import PytestReturnNotNoneWarning -from _pytest.warning_types import PytestUnhandledCoroutineWarning from _pytest.warning_types import PytestUnhandledThreadExceptionWarning from _pytest.warning_types import PytestUnknownMarkWarning from _pytest.warning_types import PytestUnraisableExceptionWarning @@ -142,10 +140,8 @@ "PytestDeprecationWarning", "PytestExperimentalApiWarning", "PytestRemovedIn9Warning", - "PytestReturnNotNoneWarning", "Pytester", "PytestPluginManager", - "PytestUnhandledCoroutineWarning", "PytestUnhandledThreadExceptionWarning", "PytestUnknownMarkWarning", "PytestUnraisableExceptionWarning", diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 6d0537f092c..7a8d871144a 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1235,7 +1235,7 @@ def test_usage_error_code(pytester: Pytester) -> None: assert result.ret == ExitCode.USAGE_ERROR -def test_error_on_async_function(pytester: Pytester) -> None: # TODO: Change this +def test_error_on_async_function(pytester: Pytester) -> None: # In the below we .close() the coroutine only to avoid # "RuntimeWarning: coroutine 'test_2' was never awaited" # which messes with other tests. @@ -1254,16 +1254,16 @@ def test_3(): result = pytester.runpytest() result.stdout.fnmatch_lines( [ + "*async def functions are not natively supported*", "*test_async.py::test_1*", "*test_async.py::test_2*", "*test_async.py::test_3*", - "*async def functions are not natively supported*", ] ) result.assert_outcomes(failed=3) -def test_error_on_async_gen_function(pytester: Pytester) -> None: # TODO: Change this +def test_error_on_async_gen_function(pytester: Pytester) -> None: pytester.makepyfile( test_async=""" async def test_1(): @@ -1277,12 +1277,13 @@ def test_3(): result = pytester.runpytest() result.stdout.fnmatch_lines( [ + "*async def functions are not natively supported*", "*test_async.py::test_1*", "*test_async.py::test_2*", "*test_async.py::test_3*", - "*async def functions are not natively supported*", ] ) + result.assert_outcomes(failed=3) def test_pdb_can_be_rewritten(pytester: Pytester) -> None: @@ -1368,7 +1369,7 @@ def test_no_brokenpipeerror_message(pytester: Pytester) -> None: popen.stderr.close() -def test_function_return_non_none_warning(pytester: Pytester) -> None: +def test_function_return_non_none_error(pytester: Pytester) -> None: pytester.makepyfile( """ def test_stuff(): @@ -1376,6 +1377,7 @@ def test_stuff(): """ ) res = pytester.runpytest() + res.assert_outcomes(failed=1) res.stdout.fnmatch_lines(["*Did you mean to use `assert` instead of `return`?*"]) diff --git a/testing/test_unittest.py b/testing/test_unittest.py index 1f7b2f091c0..56224c08228 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -1314,7 +1314,7 @@ def test_1(self): assert tracked == [] -def test_async_support(pytester: Pytester) -> None: # TODO: Change this +def test_async_support(pytester: Pytester) -> None: pytest.importorskip("unittest.async_case") pytester.copy_example("unittest/test_unittest_asyncio.py") From c7eae3a9575e2822e560156aef9530ec96ae5427 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Fri, 25 Oct 2024 13:37:54 +0200 Subject: [PATCH 107/445] add changelog entries --- changelog/11372.improvement.rst | 1 + changelog/12346.misc.rst | 1 + 2 files changed, 2 insertions(+) create mode 100644 changelog/11372.improvement.rst create mode 100644 changelog/12346.misc.rst diff --git a/changelog/11372.improvement.rst b/changelog/11372.improvement.rst new file mode 100644 index 00000000000..f4b5c3c6f6b --- /dev/null +++ b/changelog/11372.improvement.rst @@ -0,0 +1 @@ +Async tests will now fail, instead of warning+skipping, if you don't have any suitable plugin installed. diff --git a/changelog/12346.misc.rst b/changelog/12346.misc.rst new file mode 100644 index 00000000000..7013cf734c8 --- /dev/null +++ b/changelog/12346.misc.rst @@ -0,0 +1 @@ +Tests will now fail, instead of raising a warning, if they return any value other than None. From 29490af255630b3e4c949e50c3ead1756820707c Mon Sep 17 00:00:00 2001 From: jakkdl Date: Fri, 25 Oct 2024 14:52:34 +0200 Subject: [PATCH 108/445] fix docs --- doc/en/changelog.rst | 2 +- doc/en/deprecations.rst | 2 +- doc/en/reference/reference.rst | 6 ------ 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index 9f30c86be3a..0a32f88c6ff 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -1462,7 +1462,7 @@ pytest 7.2.0 (2022-10-23) Deprecations ------------ -- `#10012 `_: Update :class:`pytest.PytestUnhandledCoroutineWarning` to a deprecation; it will raise an error in pytest 8. +- `#10012 `_: Update ``pytest.PytestUnhandledCoroutineWarning`` to a deprecation; it will raise an error in pytest 8. - `#10396 `_: pytest no longer depends on the ``py`` library. ``pytest`` provides a vendored copy of ``py.error`` and ``py.path`` modules but will use the ``py`` library if it is installed. If you need other ``py.*`` modules, continue to install the deprecated ``py`` library separately, otherwise it can usually be removed as a dependency. diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index 153d5195476..e55f0d71c2e 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -251,7 +251,7 @@ Returning non-None value in test functions .. deprecated:: 7.2 -A :class:`pytest.PytestReturnNotNoneWarning` is now emitted if a test function returns something other than `None`. +A ``pytest.PytestReturnNotNoneWarning`` is now emitted if a test function returns something other than `None`. This prevents a common mistake among beginners that expect that returning a `bool` would cause a test to pass or fail, for example: diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index b6ec5c65e1e..71bf6a8986d 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1229,15 +1229,9 @@ Custom warnings generated in some situations such as improper usage or deprecate .. autoclass:: pytest.PytestExperimentalApiWarning :show-inheritance: -.. autoclass:: pytest.PytestReturnNotNoneWarning - :show-inheritance: - .. autoclass:: pytest.PytestRemovedIn9Warning :show-inheritance: -.. autoclass:: pytest.PytestUnhandledCoroutineWarning - :show-inheritance: - .. autoclass:: pytest.PytestUnknownMarkWarning :show-inheritance: From edfe778bb9f783f10c4270bb83df18f0803c655f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 27 Oct 2024 10:38:53 +0100 Subject: [PATCH 109/445] [automated] Update plugin list (#12921) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 184 +++++++++++++++++-------------- 1 file changed, 104 insertions(+), 80 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index e5bd2f8805b..1cd265578eb 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =3.5.0) :pypi:`pytest-aws` pytest plugin for testing AWS resource configurations Oct 04, 2017 4 - Beta N/A @@ -157,7 +157,7 @@ This list contains 1533 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Aug 08, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Oct 18, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Oct 22, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -250,7 +250,7 @@ This list contains 1533 plugins. :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Oct 08, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-click` Pytest plugin for Click Feb 11, 2022 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-cli-fixtures` Automatically register fixtures for custom CLI arguments Jul 28, 2022 N/A pytest (~=7.0) - :pypi:`pytest-clld` Jul 06, 2022 N/A pytest (>=3.6) + :pypi:`pytest-clld` Oct 23, 2024 N/A pytest>=3.9 :pypi:`pytest-cloud` Distributed tests planner plugin for pytest testing framework. Oct 05, 2020 6 - Mature N/A :pypi:`pytest-cloudflare-worker` pytest plugin for testing cloudflare workers Mar 30, 2021 4 - Beta pytest (>=6.0.0) :pypi:`pytest-cloudist` Distribute tests to cloud machines without fuss Sep 02, 2022 4 - Beta pytest (>=7.1.2,<8.0.0) @@ -307,7 +307,7 @@ This list contains 1533 plugins. :pypi:`pytest-cricri` A Cricri plugin for pytest. Jan 27, 2018 N/A pytest :pypi:`pytest-crontab` add crontab task in crontab Dec 09, 2019 N/A N/A :pypi:`pytest-csv` CSV output for pytest. Apr 22, 2021 N/A pytest (>=6.0) - :pypi:`pytest-csv-params` Pytest plugin for Test Case Parametrization with CSV files Jul 01, 2023 5 - Production/Stable pytest (>=7.4.0,<8.0.0) + :pypi:`pytest-csv-params` Pytest plugin for Test Case Parametrization with CSV files Oct 25, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.0 :pypi:`pytest-curio` Pytest support for curio. Oct 06, 2024 N/A pytest :pypi:`pytest-curl-report` pytest plugin to generate curl command line report Dec 11, 2016 4 - Beta N/A :pypi:`pytest-custom-concurrency` Custom grouping concurrence for pytest Feb 08, 2021 N/A N/A @@ -322,7 +322,7 @@ This list contains 1533 plugins. :pypi:`pytest-dash` pytest fixtures to run dash applications. Mar 18, 2019 N/A N/A :pypi:`pytest-dashboard` May 30, 2024 N/A pytest<8.0.0,>=7.4.3 :pypi:`pytest-data` Useful functions for managing data for pytest fixtures Nov 01, 2016 5 - Production/Stable N/A - :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Sep 07, 2024 4 - Beta pytest + :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Oct 20, 2024 4 - Beta pytest :pypi:`pytest-databricks` Pytest plugin for remote Databricks notebooks testing Jul 29, 2020 N/A pytest :pypi:`pytest-datadir` pytest plugin for test data directories and files Oct 03, 2023 5 - Production/Stable pytest >=5.0 :pypi:`pytest-datadir-mgr` Manager for test data: downloads, artifact caching, and a tmpdir context. Apr 06, 2023 5 - Production/Stable pytest (>=7.1) @@ -448,7 +448,7 @@ This list contains 1533 plugins. :pypi:`pytest-duration-insights` Jul 15, 2024 N/A N/A :pypi:`pytest-durations` Pytest plugin reporting fixtures and test functions execution time. Sep 11, 2024 5 - Production/Stable pytest>=4.6 :pypi:`pytest-dynamicrerun` A pytest plugin to rerun tests dynamically based off of test outcome and output. Aug 15, 2020 4 - Beta N/A - :pypi:`pytest-dynamodb` DynamoDB fixtures for pytest Mar 12, 2024 5 - Production/Stable pytest + :pypi:`pytest-dynamodb` DynamoDB fixtures for pytest Oct 25, 2024 5 - Production/Stable pytest :pypi:`pytest-easy-addoption` pytest-easy-addoption: Easy way to work with pytest addoption Jan 22, 2020 N/A N/A :pypi:`pytest-easy-api` A package to prevent Dependency Confusion attacks against Yandex. Feb 16, 2024 N/A N/A :pypi:`pytest-easyMPI` Package that supports mpi tests in pytest Oct 21, 2020 N/A N/A @@ -465,14 +465,14 @@ This list contains 1533 plugins. :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Oct 18, 2024 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Oct 18, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Oct 18, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Oct 18, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Oct 18, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Oct 18, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Oct 18, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Oct 18, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Oct 25, 2024 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Oct 25, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Oct 25, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Oct 25, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Oct 25, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Oct 25, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Oct 25, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Oct 25, 2024 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -572,7 +572,7 @@ This list contains 1533 plugins. :pypi:`pytest-fixture-tools` Plugin for pytest which provides tools for fixtures Aug 15, 2024 6 - Mature pytest :pypi:`pytest-fixture-typecheck` A pytest plugin to assert type annotations at runtime. Aug 24, 2021 N/A pytest :pypi:`pytest-flake8` pytest plugin to check FLAKE8 requirements Jul 21, 2024 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-flake8-path` A pytest fixture for testing flake8 plugins. Jul 10, 2023 5 - Production/Stable pytest + :pypi:`pytest-flake8-path` A pytest fixture for testing flake8 plugins. Oct 25, 2024 5 - Production/Stable pytest :pypi:`pytest-flake8-v2` pytest plugin to check FLAKE8 requirements Mar 01, 2022 5 - Production/Stable pytest (>=7.0) :pypi:`pytest-flakefinder` Runs tests multiple times to expose flakiness. Oct 26, 2022 4 - Beta pytest (>=2.7.1) :pypi:`pytest-flakes` pytest plugin to check source code with pyflakes Dec 02, 2021 5 - Production/Stable pytest (>=5) @@ -647,7 +647,7 @@ This list contains 1533 plugins. :pypi:`pytest-hardware-test-report` A simple plugin to use with pytest Apr 01, 2024 4 - Beta pytest<9.0.0,>=8.0.0 :pypi:`pytest-harmony` Chain tests and data with pytest Jan 17, 2023 N/A pytest (>=7.2.1,<8.0.0) :pypi:`pytest-harvest` Store data created during your pytest tests execution, and retrieve it at the end of the session, e.g. for applicative benchmarking purposes. Mar 16, 2024 5 - Production/Stable N/A - :pypi:`pytest-helm-charts` A plugin to provide different types and configs of Kubernetes clusters that can be used for testing. Feb 07, 2024 4 - Beta pytest (>=8.0.0,<9.0.0) + :pypi:`pytest-helm-charts` A plugin to provide different types and configs of Kubernetes clusters that can be used for testing. Oct 23, 2024 4 - Beta pytest<9.0.0,>=8.0.0 :pypi:`pytest-helm-templates` Pytest fixtures for unit testing the output of helm templates Aug 07, 2024 N/A pytest~=7.4.0; extra == "dev" :pypi:`pytest-helper` Functions to help in using the pytest testing framework May 31, 2019 5 - Production/Stable N/A :pypi:`pytest-helpers` pytest helpers May 17, 2020 N/A pytest @@ -660,7 +660,7 @@ This list contains 1533 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Oct 19, 2024 3 - Alpha pytest==8.3.3 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Oct 26, 2024 3 - Alpha pytest==8.3.3 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -680,7 +680,7 @@ This list contains 1533 plugins. :pypi:`pytest-html-thread` pytest plugin for generating HTML reports Dec 29, 2020 5 - Production/Stable N/A :pypi:`pytest-http` Fixture "http" for http requests Aug 22, 2024 N/A pytest :pypi:`pytest-httpbin` Easily test your HTTP library against a local copy of httpbin Sep 18, 2024 5 - Production/Stable pytest; extra == "test" - :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace Jan 10, 2024 3 - Alpha pytest >=7.0.0 + :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace Oct 21, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-http-mocker` Pytest plugin for http mocking (via https://github.com/vilus/mocker) Oct 20, 2019 N/A N/A :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Aug 11, 2024 3 - Alpha N/A @@ -712,7 +712,7 @@ This list contains 1533 plugins. :pypi:`pytest-infrastructure` pytest stack validation prior to testing executing Apr 12, 2020 4 - Beta N/A :pypi:`pytest-ini` Reuse pytest.ini to store env variables Apr 26, 2022 N/A N/A :pypi:`pytest-initry` Plugin for sending automation test data from Pytest to the initry Apr 30, 2024 N/A pytest<9.0.0,>=8.1.1 - :pypi:`pytest-inline` A pytest plugin for writing inline tests. Oct 19, 2023 4 - Beta pytest >=7.0.0 + :pypi:`pytest-inline` A pytest plugin for writing inline tests Oct 24, 2024 4 - Beta pytest<9.0,>=7.0 :pypi:`pytest-inmanta` A py.test plugin providing fixtures to simplify inmanta modules testing. Oct 10, 2024 5 - Production/Stable pytest :pypi:`pytest-inmanta-extensions` Inmanta tests package Oct 10, 2024 5 - Production/Stable N/A :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Aug 20, 2024 5 - Production/Stable N/A @@ -827,7 +827,7 @@ This list contains 1533 plugins. :pypi:`pytest-mark-count` Get a count of the number of tests marked, unmarked, and unique tests if tests have multiple markers Oct 18, 2024 4 - Beta pytest>=8.0.0 :pypi:`pytest-markdoctest` A pytest plugin to doctest your markdown files Jul 22, 2022 4 - Beta pytest (>=6) :pypi:`pytest-markdown` Test your markdown docs with pytest Jan 15, 2021 4 - Beta pytest (>=6.0.1,<7.0.0) - :pypi:`pytest-markdown-docs` Run markdown code fences through pytest Mar 05, 2024 N/A pytest (>=7.0.0) + :pypi:`pytest-markdown-docs` Run markdown code fences through pytest Oct 22, 2024 N/A pytest>=7.0.0 :pypi:`pytest-marker-bugzilla` py.test bugzilla integration plugin, using markers Jan 09, 2020 N/A N/A :pypi:`pytest-markers-presence` A simple plugin to detect missed pytest tags and markers" Feb 04, 2021 4 - Beta pytest (>=6.0) :pypi:`pytest-markfiltration` UNKNOWN Nov 08, 2011 3 - Alpha N/A @@ -841,6 +841,7 @@ This list contains 1533 plugins. :pypi:`pytest-mat-report` this is report Jan 20, 2021 N/A N/A :pypi:`pytest-matrix` Provide tools for generating tests from combinations of fixtures. Jun 24, 2020 5 - Production/Stable pytest (>=5.4.3,<6.0.0) :pypi:`pytest-maxcov` Compute the maximum coverage available through pytest with the minimum execution time cost Sep 24, 2023 N/A pytest (>=7.4.0,<8.0.0) + :pypi:`pytest-max-warnings` A Pytest plugin to exit non-zero exit code when the configured maximum warnings has been exceeded. Oct 23, 2024 4 - Beta pytest>=8.3.3 :pypi:`pytest-maybe-context` Simplify tests with warning and exception cases. Apr 16, 2023 N/A pytest (>=7,<8) :pypi:`pytest-maybe-raises` Pytest fixture for optional exception testing. May 27, 2022 N/A pytest ; extra == 'dev' :pypi:`pytest-mccabe` pytest plugin to run the mccabe code complexity checker. Jul 22, 2020 3 - Alpha pytest (>=5.4.0) @@ -888,13 +889,14 @@ This list contains 1533 plugins. :pypi:`pytest-monkeyplus` pytest's monkeypatch subclass with extra functionalities Sep 18, 2012 5 - Production/Stable N/A :pypi:`pytest-monkeytype` pytest-monkeytype: Generate Monkeytype annotations from your pytest tests. Jul 29, 2020 4 - Beta N/A :pypi:`pytest-moto` Fixtures for integration tests of AWS services,uses moto mocking library. Aug 28, 2015 1 - Planning N/A + :pypi:`pytest-moto-fixtures` Fixtures for testing code that interacts with AWS Oct 24, 2024 1 - Planning pytest<9.0,>=8.3; extra == "pytest" :pypi:`pytest-motor` A pytest plugin for motor, the non-blocking MongoDB driver. Jul 21, 2021 3 - Alpha pytest :pypi:`pytest-mp` A test batcher for multiprocessed Pytest runs May 23, 2018 4 - Beta pytest :pypi:`pytest-mpi` pytest plugin to collect information from tests Jan 08, 2022 3 - Alpha pytest :pypi:`pytest-mpiexec` pytest plugin for running individual tests with mpiexec Jul 29, 2024 3 - Alpha pytest :pypi:`pytest-mpl` pytest plugin to help with testing figures output from Matplotlib Feb 14, 2024 4 - Beta pytest :pypi:`pytest-mproc` low-startup-overhead, scalable, distributed-testing pytest plugin Nov 15, 2022 4 - Beta pytest (>=6) - :pypi:`pytest-mqtt` pytest-mqtt supports testing systems based on MQTT Jul 29, 2024 4 - Beta pytest<9; extra == "test" + :pypi:`pytest-mqtt` pytest-mqtt supports testing systems based on MQTT Oct 19, 2024 4 - Beta pytest<9; extra == "test" :pypi:`pytest-multihost` Utility for writing multi-host tests for pytest Apr 07, 2020 4 - Beta N/A :pypi:`pytest-multilog` Multi-process logs handling and other helpers for pytest Jan 17, 2023 N/A pytest :pypi:`pytest-multithreading` a pytest plugin for th and concurrent testing Aug 05, 2024 N/A N/A @@ -977,7 +979,7 @@ This list contains 1533 plugins. :pypi:`pytest-parametrization` Simpler PyTest parametrization May 22, 2022 5 - Production/Stable N/A :pypi:`pytest-parametrize` pytest decorator for parametrizing test cases in a dict-way Sep 23, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.0 :pypi:`pytest-parametrize-cases` A more user-friendly way to write parametrized tests. Mar 13, 2022 N/A pytest (>=6.1.2) - :pypi:`pytest-parametrized` Pytest decorator for parametrizing tests with default iterables. Nov 03, 2023 5 - Production/Stable pytest + :pypi:`pytest-parametrized` Pytest decorator for parametrizing tests with default iterables. Oct 22, 2024 5 - Production/Stable pytest :pypi:`pytest-parametrize-suite` A simple pytest extension for creating a named test suite. Jan 19, 2023 5 - Production/Stable pytest :pypi:`pytest_param_files` Create pytest parametrize decorators from external files. Jul 29, 2023 N/A pytest :pypi:`pytest-params` Simplified pytest test case parameters. Aug 05, 2024 N/A pytest>=7.0.0 @@ -988,7 +990,7 @@ This list contains 1533 plugins. :pypi:`pytest-paste-config` Allow setting the path to a paste config file Sep 18, 2013 3 - Alpha N/A :pypi:`pytest-patch` An automagic \`patch\` fixture that can patch objects directly or by name. Apr 29, 2023 3 - Alpha pytest (>=7.0.0) :pypi:`pytest-patches` A contextmanager pytest fixture for handling multiple mock patches Aug 30, 2021 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-patterns` pytest plugin to make testing complicated long string output easy to write and easy to debug Oct 19, 2024 4 - Beta pytest>=6 + :pypi:`pytest-patterns` pytest plugin to make testing complicated long string output easy to write and easy to debug Oct 22, 2024 4 - Beta pytest>=6 :pypi:`pytest-pdb` pytest plugin which adds pdb helper commands related to pytest. Jul 31, 2018 N/A N/A :pypi:`pytest-peach` pytest plugin for fuzzing with Peach API Security Apr 12, 2019 4 - Beta pytest (>=2.8.7) :pypi:`pytest-pep257` py.test plugin for pep257 Jul 09, 2016 N/A N/A @@ -1080,7 +1082,7 @@ This list contains 1533 plugins. :pypi:`pytest-pypom-navigation` Core engine for cookiecutter-qa and pytest-play packages Feb 18, 2019 4 - Beta pytest (>=3.0.7) :pypi:`pytest-pyppeteer` A plugin to run pyppeteer in pytest Apr 28, 2022 N/A pytest (>=6.2.5,<7.0.0) :pypi:`pytest-pyq` Pytest fixture "q" for pyq Mar 10, 2020 5 - Production/Stable N/A - :pypi:`pytest-pyramid` pytest_pyramid - provides fixtures for testing pyramid applications with pytest test suite Oct 11, 2023 5 - Production/Stable pytest + :pypi:`pytest-pyramid` pytest_pyramid - provides fixtures for testing pyramid applications with pytest test suite Oct 24, 2024 5 - Production/Stable pytest :pypi:`pytest-pyramid-server` Pyramid server fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-pyreport` PyReport is a lightweight reporting plugin for Pytest that provides concise HTML report May 05, 2024 N/A pytest :pypi:`pytest-pyright` Pytest plugin for type checking code with Pyright Jan 26, 2024 4 - Beta pytest >=7.0.0 @@ -1114,7 +1116,7 @@ This list contains 1533 plugins. :pypi:`pytest-raisesregexp` Simple pytest plugin to look for regex in Exceptions Dec 18, 2015 N/A N/A :pypi:`pytest-raisin` Plugin enabling the use of exception instances with pytest.raises Feb 06, 2022 N/A pytest :pypi:`pytest-random` py.test plugin to randomize tests Apr 28, 2013 3 - Alpha N/A - :pypi:`pytest-randomly` Pytest plugin to randomly order tests and control random.seed. Aug 15, 2023 5 - Production/Stable pytest + :pypi:`pytest-randomly` Pytest plugin to randomly order tests and control random.seed. Oct 25, 2024 5 - Production/Stable pytest :pypi:`pytest-randomness` Pytest plugin about random seed management May 30, 2019 3 - Alpha N/A :pypi:`pytest-random-num` Randomise the order in which pytest tests are run with some control over the randomness Oct 19, 2020 5 - Production/Stable N/A :pypi:`pytest-random-order` Randomise the order in which pytest tests are run with some control over the randomness Jan 20, 2024 5 - Production/Stable pytest >=3.0.0 @@ -1155,7 +1157,7 @@ This list contains 1533 plugins. :pypi:`pytest-reportlog` Replacement for the --resultlog option, focused in simplicity and extensibility May 22, 2023 3 - Alpha pytest :pypi:`pytest-report-me` A pytest plugin to generate report. Dec 31, 2020 N/A pytest :pypi:`pytest-report-parameters` pytest plugin for adding tests' parameters to junit report Jun 18, 2020 3 - Alpha pytest (>=2.4.2) - :pypi:`pytest-reportportal` Agent for Reporting results of tests to the Report Portal Sep 06, 2024 N/A pytest>=3.8.0 + :pypi:`pytest-reportportal` Agent for Reporting results of tests to the Report Portal Oct 22, 2024 N/A pytest>=3.8.0 :pypi:`pytest-report-stream` A pytest plugin which allows to stream test reports at runtime Oct 22, 2023 4 - Beta N/A :pypi:`pytest-repo-structure` Pytest Repo Structure Mar 18, 2024 1 - Planning N/A :pypi:`pytest-req` pytest requests plugin Aug 31, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.2 @@ -1178,7 +1180,7 @@ This list contains 1533 plugins. :pypi:`pytest-responsemock` Simplified requests calls mocking for pytest Mar 10, 2022 5 - Production/Stable N/A :pypi:`pytest-responses` py.test integration for responses Oct 11, 2022 N/A pytest (>=2.5) :pypi:`pytest-rest-api` Aug 08, 2022 N/A pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-restrict` Pytest plugin to restrict the test types allowed Jul 10, 2023 5 - Production/Stable pytest + :pypi:`pytest-restrict` Pytest plugin to restrict the test types allowed Oct 24, 2024 5 - Production/Stable pytest :pypi:`pytest-result-log` A pytest plugin that records the start, end, and result information of each use case in a log file Jan 10, 2024 N/A pytest>=7.2.0 :pypi:`pytest-result-sender` Apr 20, 2023 N/A pytest>=7.3.1 :pypi:`pytest-resume` A Pytest plugin to resuming from the last run test Apr 22, 2023 4 - Beta pytest (>=7.0) @@ -1186,7 +1188,7 @@ This list contains 1533 plugins. :pypi:`pytest-retry` Adds the ability to retry flaky tests in CI environments May 14, 2024 N/A pytest>=7.0.0 :pypi:`pytest-retry-class` A pytest plugin to rerun entire class on failure Mar 25, 2023 N/A pytest (>=5.3) :pypi:`pytest-reusable-testcases` Apr 28, 2023 N/A N/A - :pypi:`pytest-reverse` Pytest plugin to reverse test order. Jul 10, 2023 5 - Production/Stable pytest + :pypi:`pytest-reverse` Pytest plugin to reverse test order. Oct 25, 2024 5 - Production/Stable pytest :pypi:`pytest-rich` Leverage rich for richer test session output Mar 03, 2022 4 - Beta pytest (>=7.0) :pypi:`pytest-richer` Pytest plugin providing a Rich based reporter. Oct 27, 2023 3 - Alpha pytest :pypi:`pytest-rich-reporter` A pytest plugin using Rich for beautiful test result formatting. Feb 17, 2022 1 - Planning pytest (>=5.0.0) @@ -1213,7 +1215,7 @@ This list contains 1533 plugins. :pypi:`pytest-saccharin` pytest-saccharin is a updated fork of pytest-sugar, a plugin for pytest that changes the default look and feel of pytest (e.g. progressbar, show tests that fail instantly). Oct 31, 2022 3 - Alpha N/A :pypi:`pytest-salt` Pytest Salt Plugin Jan 27, 2020 4 - Beta N/A :pypi:`pytest-salt-containers` A Pytest plugin that builds and creates docker containers Nov 09, 2016 4 - Beta N/A - :pypi:`pytest-salt-factories` Pytest Salt Plugin Mar 22, 2024 5 - Production/Stable pytest>=7.0.0 + :pypi:`pytest-salt-factories` Pytest Salt Plugin Oct 22, 2024 5 - Production/Stable pytest>=7.4.0 :pypi:`pytest-salt-from-filenames` Simple PyTest Plugin For Salt's Test Suite Specifically Jan 29, 2019 4 - Beta pytest (>=4.1) :pypi:`pytest-salt-runtests-bridge` Simple PyTest Plugin For Salt's Test Suite Specifically Dec 05, 2019 4 - Beta pytest (>=4.1) :pypi:`pytest-sample-argvalues` A utility function to help choose a random sample from your argvalues in pytest. May 07, 2024 N/A pytest @@ -1221,7 +1223,7 @@ This list contains 1533 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Oct 07, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Oct 26, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 :pypi:`pytest-schedule` The job of test scheduling for humans. Jan 07, 2023 5 - Production/Stable N/A @@ -1232,7 +1234,7 @@ This list contains 1533 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Oct 07, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Oct 26, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1255,7 +1257,7 @@ This list contains 1533 plugins. :pypi:`pytest-share-hdf` Plugin to save test data in HDF files and retrieve them for comparison Sep 21, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-sharkreport` this is pytest report plugin. Jul 11, 2022 N/A pytest (>=3.5) :pypi:`pytest-shell` A pytest plugin to help with testing shell scripts / black box commands Mar 27, 2022 N/A N/A - :pypi:`pytest-shell-utilities` Pytest plugin to simplify running shell commands against the system Oct 18, 2024 5 - Production/Stable pytest>=7.4.0 + :pypi:`pytest-shell-utilities` Pytest plugin to simplify running shell commands against the system Oct 22, 2024 5 - Production/Stable pytest>=7.4.0 :pypi:`pytest-sheraf` Versatile ZODB abstraction layer - pytest fixtures Feb 11, 2020 N/A pytest :pypi:`pytest-sherlock` pytest plugin help to find coupled tests Aug 14, 2023 5 - Production/Stable pytest >=3.5.1 :pypi:`pytest-shortcuts` Expand command-line shortcuts listed in pytest configuration Oct 29, 2020 4 - Beta pytest (>=3.5.0) @@ -1325,7 +1327,7 @@ This list contains 1533 plugins. :pypi:`pytest-ssh` pytest plugin for ssh command run May 27, 2019 N/A pytest :pypi:`pytest-start-from` Start pytest run from a given point Apr 11, 2016 N/A N/A :pypi:`pytest-star-track-issue` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A - :pypi:`pytest-static` pytest-static Aug 09, 2024 1 - Planning pytest<8.0.0,>=7.4.3 + :pypi:`pytest-static` pytest-static Oct 20, 2024 1 - Planning pytest<8.0.0,>=7.4.3 :pypi:`pytest-stats` Collects tests metadata for future analysis, easy to extend for any data store Jul 18, 2024 N/A pytest>=8.0.0 :pypi:`pytest-statsd` pytest plugin for reporting to graphite Nov 30, 2018 5 - Production/Stable pytest (>=3.0.0) :pypi:`pytest-status` Add status mark for tests Aug 22, 2024 N/A pytest @@ -1474,8 +1476,9 @@ This list contains 1533 plugins. :pypi:`pytest-uncollect-if` A plugin to uncollect pytests tests rather than using skipif Mar 24, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-unflakable` Unflakable plugin for PyTest Apr 30, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-unhandled-exception-exit-code` Plugin for py.test set a different exit code on uncaught exceptions Jun 22, 2020 5 - Production/Stable pytest (>=2.3) - :pypi:`pytest-unique` Pytest fixture to generate unique values. Sep 15, 2023 N/A pytest (>=7.4.2,<8.0.0) + :pypi:`pytest-unique` Pytest fixture to generate unique values. Oct 21, 2024 N/A pytest<8.0.0,>=7.4.2 :pypi:`pytest-unittest-filter` A pytest plugin for filtering unittest-based test classes Jan 12, 2019 4 - Beta pytest (>=3.1.0) + :pypi:`pytest-unmagic` Pytest fixtures with conventional import semantics Oct 22, 2024 5 - Production/Stable pytest :pypi:`pytest-unmarked` Run only unmarked tests Aug 27, 2019 5 - Production/Stable N/A :pypi:`pytest-unordered` Test equality of unordered collections in pytest Jul 05, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-unstable` Set a test as unstable to return 0 even if it failed Sep 27, 2022 4 - Beta N/A @@ -2252,11 +2255,11 @@ This list contains 1533 plugins. This fixture provides a configured "driver" for Android Automated Testing, using uiautomator2. :pypi:`pytest-aux` - *last release*: Sep 23, 2024, + *last release*: Oct 25, 2024, *status*: N/A, *requires*: N/A - templates/examples and aux for pytest + all moved into module FUNCS_AUXt :pypi:`pytest-aviator` *last release*: Nov 04, 2022, @@ -2434,7 +2437,7 @@ This list contains 1533 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Oct 18, 2024, + *last release*: Oct 22, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -3085,9 +3088,9 @@ This list contains 1533 plugins. Automatically register fixtures for custom CLI arguments :pypi:`pytest-clld` - *last release*: Jul 06, 2022, + *last release*: Oct 23, 2024, *status*: N/A, - *requires*: pytest (>=3.6) + *requires*: pytest>=3.9 @@ -3484,9 +3487,9 @@ This list contains 1533 plugins. CSV output for pytest. :pypi:`pytest-csv-params` - *last release*: Jul 01, 2023, + *last release*: Oct 25, 2024, *status*: 5 - Production/Stable, - *requires*: pytest (>=7.4.0,<8.0.0) + *requires*: pytest<9.0.0,>=8.3.0 Pytest plugin for Test Case Parametrization with CSV files @@ -3589,7 +3592,7 @@ This list contains 1533 plugins. Useful functions for managing data for pytest fixtures :pypi:`pytest-databases` - *last release*: Sep 07, 2024, + *last release*: Oct 20, 2024, *status*: 4 - Beta, *requires*: pytest @@ -4471,7 +4474,7 @@ This list contains 1533 plugins. A pytest plugin to rerun tests dynamically based off of test outcome and output. :pypi:`pytest-dynamodb` - *last release*: Mar 12, 2024, + *last release*: Oct 25, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -4590,56 +4593,56 @@ This list contains 1533 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: Oct 18, 2024, + *last release*: Oct 25, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: Oct 18, 2024, + *last release*: Oct 25, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: Oct 18, 2024, + *last release*: Oct 25, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: Oct 18, 2024, + *last release*: Oct 25, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. :pypi:`pytest-embedded-qemu` - *last release*: Oct 18, 2024, + *last release*: Oct 25, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: Oct 18, 2024, + *last release*: Oct 25, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: Oct 18, 2024, + *last release*: Oct 25, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: Oct 18, 2024, + *last release*: Oct 25, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -5339,7 +5342,7 @@ This list contains 1533 plugins. pytest plugin to check FLAKE8 requirements :pypi:`pytest-flake8-path` - *last release*: Jul 10, 2023, + *last release*: Oct 25, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -5864,9 +5867,9 @@ This list contains 1533 plugins. Store data created during your pytest tests execution, and retrieve it at the end of the session, e.g. for applicative benchmarking purposes. :pypi:`pytest-helm-charts` - *last release*: Feb 07, 2024, + *last release*: Oct 23, 2024, *status*: 4 - Beta, - *requires*: pytest (>=8.0.0,<9.0.0) + *requires*: pytest<9.0.0,>=8.0.0 A plugin to provide different types and configs of Kubernetes clusters that can be used for testing. @@ -5955,7 +5958,7 @@ This list contains 1533 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Oct 19, 2024, + *last release*: Oct 26, 2024, *status*: 3 - Alpha, *requires*: pytest==8.3.3 @@ -6095,9 +6098,9 @@ This list contains 1533 plugins. Easily test your HTTP library against a local copy of httpbin :pypi:`pytest-httpdbg` - *last release*: Jan 10, 2024, - *status*: 3 - Alpha, - *requires*: pytest >=7.0.0 + *last release*: Oct 21, 2024, + *status*: 4 - Beta, + *requires*: pytest>=7.0.0 A pytest plugin to record HTTP(S) requests with stack trace @@ -6319,11 +6322,11 @@ This list contains 1533 plugins. Plugin for sending automation test data from Pytest to the initry :pypi:`pytest-inline` - *last release*: Oct 19, 2023, + *last release*: Oct 24, 2024, *status*: 4 - Beta, - *requires*: pytest >=7.0.0 + *requires*: pytest<9.0,>=7.0 - A pytest plugin for writing inline tests. + A pytest plugin for writing inline tests :pypi:`pytest-inmanta` *last release*: Oct 10, 2024, @@ -7124,9 +7127,9 @@ This list contains 1533 plugins. Test your markdown docs with pytest :pypi:`pytest-markdown-docs` - *last release*: Mar 05, 2024, + *last release*: Oct 22, 2024, *status*: N/A, - *requires*: pytest (>=7.0.0) + *requires*: pytest>=7.0.0 Run markdown code fences through pytest @@ -7221,6 +7224,13 @@ This list contains 1533 plugins. Compute the maximum coverage available through pytest with the minimum execution time cost + :pypi:`pytest-max-warnings` + *last release*: Oct 23, 2024, + *status*: 4 - Beta, + *requires*: pytest>=8.3.3 + + A Pytest plugin to exit non-zero exit code when the configured maximum warnings has been exceeded. + :pypi:`pytest-maybe-context` *last release*: Apr 16, 2023, *status*: N/A, @@ -7550,6 +7560,13 @@ This list contains 1533 plugins. Fixtures for integration tests of AWS services,uses moto mocking library. + :pypi:`pytest-moto-fixtures` + *last release*: Oct 24, 2024, + *status*: 1 - Planning, + *requires*: pytest<9.0,>=8.3; extra == "pytest" + + Fixtures for testing code that interacts with AWS + :pypi:`pytest-motor` *last release*: Jul 21, 2021, *status*: 3 - Alpha, @@ -7593,7 +7610,7 @@ This list contains 1533 plugins. low-startup-overhead, scalable, distributed-testing pytest plugin :pypi:`pytest-mqtt` - *last release*: Jul 29, 2024, + *last release*: Oct 19, 2024, *status*: 4 - Beta, *requires*: pytest<9; extra == "test" @@ -8174,7 +8191,7 @@ This list contains 1533 plugins. A more user-friendly way to write parametrized tests. :pypi:`pytest-parametrized` - *last release*: Nov 03, 2023, + *last release*: Oct 22, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -8251,7 +8268,7 @@ This list contains 1533 plugins. A contextmanager pytest fixture for handling multiple mock patches :pypi:`pytest-patterns` - *last release*: Oct 19, 2024, + *last release*: Oct 22, 2024, *status*: 4 - Beta, *requires*: pytest>=6 @@ -8895,7 +8912,7 @@ This list contains 1533 plugins. Pytest fixture "q" for pyq :pypi:`pytest-pyramid` - *last release*: Oct 11, 2023, + *last release*: Oct 24, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -9133,7 +9150,7 @@ This list contains 1533 plugins. py.test plugin to randomize tests :pypi:`pytest-randomly` - *last release*: Aug 15, 2023, + *last release*: Oct 25, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -9420,7 +9437,7 @@ This list contains 1533 plugins. pytest plugin for adding tests' parameters to junit report :pypi:`pytest-reportportal` - *last release*: Sep 06, 2024, + *last release*: Oct 22, 2024, *status*: N/A, *requires*: pytest>=3.8.0 @@ -9581,7 +9598,7 @@ This list contains 1533 plugins. :pypi:`pytest-restrict` - *last release*: Jul 10, 2023, + *last release*: Oct 24, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -9637,7 +9654,7 @@ This list contains 1533 plugins. :pypi:`pytest-reverse` - *last release*: Jul 10, 2023, + *last release*: Oct 25, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -9826,9 +9843,9 @@ This list contains 1533 plugins. A Pytest plugin that builds and creates docker containers :pypi:`pytest-salt-factories` - *last release*: Mar 22, 2024, + *last release*: Oct 22, 2024, *status*: 5 - Production/Stable, - *requires*: pytest>=7.0.0 + *requires*: pytest>=7.4.0 Pytest Salt Plugin @@ -9882,7 +9899,7 @@ This list contains 1533 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Oct 07, 2024, + *last release*: Oct 26, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9959,7 +9976,7 @@ This list contains 1533 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Oct 07, 2024, + *last release*: Oct 26, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10120,7 +10137,7 @@ This list contains 1533 plugins. A pytest plugin to help with testing shell scripts / black box commands :pypi:`pytest-shell-utilities` - *last release*: Oct 18, 2024, + *last release*: Oct 22, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=7.4.0 @@ -10610,7 +10627,7 @@ This list contains 1533 plugins. A package to prevent Dependency Confusion attacks against Yandex. :pypi:`pytest-static` - *last release*: Aug 09, 2024, + *last release*: Oct 20, 2024, *status*: 1 - Planning, *requires*: pytest<8.0.0,>=7.4.3 @@ -11653,9 +11670,9 @@ This list contains 1533 plugins. Plugin for py.test set a different exit code on uncaught exceptions :pypi:`pytest-unique` - *last release*: Sep 15, 2023, + *last release*: Oct 21, 2024, *status*: N/A, - *requires*: pytest (>=7.4.2,<8.0.0) + *requires*: pytest<8.0.0,>=7.4.2 Pytest fixture to generate unique values. @@ -11666,6 +11683,13 @@ This list contains 1533 plugins. A pytest plugin for filtering unittest-based test classes + :pypi:`pytest-unmagic` + *last release*: Oct 22, 2024, + *status*: 5 - Production/Stable, + *requires*: pytest + + Pytest fixtures with conventional import semantics + :pypi:`pytest-unmarked` *last release*: Aug 27, 2019, *status*: 5 - Production/Stable, From 256203a5c9aae87741ca195c29510414dd5ddc73 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Oct 2024 06:05:23 +0100 Subject: [PATCH 110/445] build(deps): Bump twisted in /testing/plugins_integration (#12922) Bumps [twisted](https://github.com/twisted/twisted) from 24.7.0 to 24.10.0. - [Release notes](https://github.com/twisted/twisted/releases) - [Changelog](https://github.com/twisted/twisted/blob/trunk/NEWS.rst) - [Commits](https://github.com/twisted/twisted/compare/twisted-24.7.0...twisted-24.10.0) --- updated-dependencies: - dependency-name: twisted dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index d5ed74940d3..c465041d64d 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -11,5 +11,5 @@ pytest-rerunfailures==14.0 pytest-sugar==1.0.0 pytest-trio==0.8.0 pytest-twisted==1.14.3 -twisted==24.7.0 +twisted==24.10.0 pytest-xvfb==3.0.0 From a1a491837b35b719d77b4f03be318b505d495386 Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Thu, 31 Oct 2024 11:28:03 +0100 Subject: [PATCH 111/445] Improve docs on basetemp and retention (#12912) Improve coverage of current handling of `--basetemp` option and its lack of retention functionality. Also document `PYTEST_DEBUG_TEMPROOT`. Related to #10829 --------- Co-authored-by: Bruno Oliveira --- changelog/10829.doc.rst | 1 + doc/en/how-to/tmp_path.rst | 50 ++++++++++++++++++++++++---------- doc/en/reference/reference.rst | 5 ++++ src/_pytest/legacypath.py | 15 ++++------ src/_pytest/tmpdir.py | 22 +++++---------- 5 files changed, 53 insertions(+), 40 deletions(-) create mode 100644 changelog/10829.doc.rst diff --git a/changelog/10829.doc.rst b/changelog/10829.doc.rst new file mode 100644 index 00000000000..1be45c7049d --- /dev/null +++ b/changelog/10829.doc.rst @@ -0,0 +1 @@ +Improve documentation on the current handling of the ``--basetemp`` option and its lack of retention functionality (:ref:`temporary directory location and retention`). diff --git a/doc/en/how-to/tmp_path.rst b/doc/en/how-to/tmp_path.rst index 3cc5152e992..d19950431e5 100644 --- a/doc/en/how-to/tmp_path.rst +++ b/doc/en/how-to/tmp_path.rst @@ -133,27 +133,47 @@ API for details. 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 -``NUM`` will be incremented with each test run. -By default, entries older than 3 temporary directories will be removed. -This behavior can be configured with :confval:`tmp_path_retention_count` and -:confval:`tmp_path_retention_policy`. +The temporary directories, +as returned by the :fixture:`tmp_path` and (now deprecated) :fixture:`tmpdir` fixtures, +are automatically created under a base temporary directory, +in a structure that depends on the ``--basetemp`` option: -Using the ``--basetemp`` -option will remove the directory before every run, effectively meaning the temporary directories -of only the most recent run will be kept. +- By default (when the ``--basetemp`` option is not set), + the temporary directories will follow this template: -You can override the default temporary directory setting like this: + .. code-block:: text -.. code-block:: bash + {temproot}/pytest-of-{user}/pytest-{num}/{testname}/ - pytest --basetemp=mydir + where: -.. warning:: + - ``{temproot}`` is the system temporary directory + as determined by :py:func:`tempfile.gettempdir`. + It can be overridden by the :envvar:`PYTEST_DEBUG_TEMPROOT` environment variable. + - ``{user}`` is the user name running the tests, + - ``{num}`` is a number that is incremented with each test suite run + - ``{testname}`` is a sanitized version of :py:attr:`the name of the current test <_pytest.nodes.Node.name>`. - The contents of ``mydir`` will be completely removed, so make sure to use a directory - for that purpose only. + The auto-incrementing ``{num}`` placeholder provides a basic retention feature + and avoids that existing results of previous test runs are blindly removed. + By default, the last 3 temporary directories are kept, + but this behavior can be configured with + :confval:`tmp_path_retention_count` and :confval:`tmp_path_retention_policy`. + +- When the ``--basetemp`` option is used (e.g. ``pytest --basetemp=mydir``), + it will be used directly as base temporary directory: + + .. code-block:: text + + {basetemp}/{testname}/ + + Note that there is no retention feature in this case: + only the results of the most recent run will be kept. + + .. warning:: + + The directory given to ``--basetemp`` will be cleared blindly before each test run, + so make sure to use a directory 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 diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 71bf6a8986d..bb77806c6a3 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1153,6 +1153,11 @@ processes can inspect it, see :ref:`pytest current test env` for more informatio When set, pytest will print tracing and debug information. +.. envvar:: PYTEST_DEBUG_TEMPROOT + +Root for temporary directories produced by fixtures like :fixture:`tmp_path` +as discussed in :ref:`temporary directory location and retention`. + .. envvar:: PYTEST_DISABLE_PLUGIN_AUTOLOAD When set, disables plugin auto-loading through :std:doc:`entry point packaging diff --git a/src/_pytest/legacypath.py b/src/_pytest/legacypath.py index 61476d68932..59e8ef6e742 100644 --- a/src/_pytest/legacypath.py +++ b/src/_pytest/legacypath.py @@ -304,16 +304,11 @@ def tmpdir_factory(request: FixtureRequest) -> TempdirFactory: @staticmethod @fixture def tmpdir(tmp_path: Path) -> LEGACY_PATH: - """Return a temporary directory path object which is unique to each test - function invocation, created as a sub directory of the base temporary - directory. - - 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:`temporary directory location and retention`. - - The returned object is a `legacy_path`_ object. + """Return a temporary directory (as `legacy_path`_ object) + which is unique to each test function invocation. + The temporary directory is created as a subdirectory + of the base temporary directory, with configurable retention, + as discussed in :ref:`temporary directory location and retention`. .. note:: These days, it is preferred to use ``tmp_path``. diff --git a/src/_pytest/tmpdir.py b/src/_pytest/tmpdir.py index de0cbcfeb1c..1731a4b8d0d 100644 --- a/src/_pytest/tmpdir.py +++ b/src/_pytest/tmpdir.py @@ -41,9 +41,8 @@ @final @dataclasses.dataclass class TempPathFactory: - """Factory for temporary directories under the common base temp directory. - - The base directory can be configured using the ``--basetemp`` option. + """Factory for temporary directories under the common base temp directory, + as discussed at :ref:`temporary directory location and retention`. """ _given_basetemp: Path | None @@ -257,18 +256,11 @@ def _mk_tmp(request: FixtureRequest, factory: TempPathFactory) -> Path: def tmp_path( request: FixtureRequest, tmp_path_factory: TempPathFactory ) -> Generator[Path]: - """Return a temporary directory path object which is unique to each test - function invocation, created as a sub directory of the base temporary - directory. - - By default, a new base temporary directory is created each test session, - 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:`temporary directory location and retention`. - - The returned object is a :class:`pathlib.Path` object. + """Return a temporary directory (as :class:`pathlib.Path` object) + which is unique to each test function invocation. + The temporary directory is created as a subdirectory + of the base temporary directory, with configurable retention, + as discussed in :ref:`temporary directory location and retention`. """ path = _mk_tmp(request, tmp_path_factory) yield path From 6728ec5606dd7e2eb70ef64972f97eab061f95e2 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Thu, 31 Oct 2024 16:48:11 +0100 Subject: [PATCH 112/445] Raise error if sync test relies on async fixture, and warn if the fixture is autouse. --- src/_pytest/fixtures.py | 36 +++++++++++++++- testing/acceptance_test.py | 87 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 1 deletion(-) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 6b882fa3515..499d065c4a9 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -73,6 +73,7 @@ from _pytest.scope import _ScopeName from _pytest.scope import HIGH_SCOPES from _pytest.scope import Scope +from _pytest.warning_types import PytestRemovedIn9Warning if sys.version_info < (3, 11): @@ -575,6 +576,7 @@ def _get_active_fixturedef( # The are no fixtures with this name applicable for the function. if not fixturedefs: raise FixtureLookupError(argname, self) + # A fixture may override another fixture with the same name, e.g. a # fixture in a module can override a fixture in a conftest, a fixture in # a class can override a fixture in the module, and so on. @@ -593,6 +595,32 @@ def _get_active_fixturedef( raise FixtureLookupError(argname, self) fixturedef = fixturedefs[index] + if not inspect.iscoroutinefunction(self.function) and ( + inspect.iscoroutinefunction(fixturedef.func) + or inspect.isasyncgenfunction(fixturedef.func) + ): + if fixturedef._autouse: + warnings.warn( + PytestRemovedIn9Warning( + "Sync test requested an async fixture with autouse=True. " + "If you intended to use the fixture you may want to make the " + "test asynchronous. If you did not intend to use it you should " + "restructure your test setup. " + "This will turn into an error in pytest 9." + ), + stacklevel=3, + ) + else: + raise FixtureLookupError( + argname, + self, + ( + "ERROR: Sync test requested async fixture. " + "You may want to make the test asynchronous and run it with " + "a suitable async framework test plugin." + ), + ) + # Prepare a SubRequest object for calling the fixture. try: callspec = self._pyfuncitem.callspec @@ -805,7 +833,7 @@ def formatrepr(self) -> FixtureLookupErrorRepr: stack = [self.request._pyfuncitem.obj] stack.extend(map(lambda x: x.func, self.fixturestack)) msg = self.msg - if msg is not None: + if msg is not None and len(stack) > 1: # The last fixture raise an error, let's present # it at the requesting side. stack = stack[:-1] @@ -959,6 +987,8 @@ def __init__( ids: tuple[object | None, ...] | Callable[[Any], object | None] | None = None, *, _ispytest: bool = False, + # only used to emit a deprecationwarning, can be removed in pytest9 + _autouse: bool = False, ) -> None: check_ispytest(_ispytest) # The "base" node ID for the fixture. @@ -1005,6 +1035,9 @@ def __init__( self.cached_result: _FixtureCachedResult[FixtureValue] | None = None self._finalizers: Final[list[Callable[[], object]]] = [] + # only used to emit a deprecationwarning, can be removed in pytest9 + self._autouse = _autouse + @property def scope(self) -> _ScopeName: """Scope string, one of "function", "class", "module", "package", "session".""" @@ -1666,6 +1699,7 @@ def _register_fixture( params=params, ids=ids, _ispytest=True, + _autouse=autouse, ) faclist = self._arg2fixturedefs.setdefault(name, []) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 7a8d871144a..0437cae4047 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1286,6 +1286,93 @@ def test_3(): result.assert_outcomes(failed=3) +def test_error_on_sync_test_async_fixture(pytester: Pytester) -> None: + pytester.makepyfile( + test_sync=""" + import pytest + + @pytest.fixture + async def async_fixture(): + ... + + def test_foo(async_fixture): + ... + """ + ) + result = pytester.runpytest() + result.stdout.fnmatch_lines( + [ + ( + "*ERROR: Sync test requested async fixture. " + "You may want to make the test asynchronous and run it with " + "a suitable async framework test plugin.*" + ), + "*ERROR test_sync.py::test_foo*", + ] + ) + result.assert_outcomes(errors=1) + + +def test_error_on_sync_test_async_fixture_gen(pytester: Pytester) -> None: + pytester.makepyfile( + test_sync=""" + import pytest + + @pytest.fixture + async def async_fixture(): + yield + + def test_foo(async_fixture): + ... + """ + ) + result = pytester.runpytest() + result.stdout.fnmatch_lines( + [ + ( + "*ERROR: Sync test requested async fixture. " + "You may want to make the test asynchronous and run it with " + "a suitable async framework test plugin.*" + ), + "*ERROR test_sync.py::test_foo*", + ] + ) + result.assert_outcomes(errors=1) + + +def test_warning_on_sync_test_async_autouse_fixture(pytester: Pytester) -> None: + pytester.makepyfile( + test_sync=""" + import pytest + + @pytest.fixture(autouse=True) + async def async_fixture(): + ... + + # We explicitly request the fixture to be able to + # suppress the RuntimeWarning for unawaited coroutine. + def test_foo(async_fixture): + try: + async_fixture.send(None) + except StopIteration: + pass + """ + ) + result = pytester.runpytest() + result.stdout.fnmatch_lines( + [ + ( + "*Sync test requested an async fixture with autouse=True. " + "If you intended to use the fixture you may want to make the " + "test asynchronous. If you did not intend to use it you should " + "restructure your test setup. " + "This will turn into an error in pytest 9.*" + ), + ] + ) + result.assert_outcomes(passed=1) + + def test_pdb_can_be_rewritten(pytester: Pytester) -> None: pytester.makepyfile( **{ From 8e100ea2c70ea7252141902af819a7aae44a53c1 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Fri, 1 Nov 2024 11:56:59 +0100 Subject: [PATCH 113/445] fix tests --- src/_pytest/fixtures.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 499d065c4a9..da6625fb7e1 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -595,9 +595,16 @@ def _get_active_fixturedef( raise FixtureLookupError(argname, self) fixturedef = fixturedefs[index] - if not inspect.iscoroutinefunction(self.function) and ( - inspect.iscoroutinefunction(fixturedef.func) - or inspect.isasyncgenfunction(fixturedef.func) + # Check for attempted use of an async fixture by a sync test + # `self.scope` here is not the scope of the requested fixture, but the scope of + # the requester. + if ( + self.scope == "function" + and not inspect.iscoroutinefunction(self._pyfuncitem.obj) + and ( + inspect.iscoroutinefunction(fixturedef.func) + or inspect.isasyncgenfunction(fixturedef.func) + ) ): if fixturedef._autouse: warnings.warn( From 283db4ed9f803c6b1f19b8920ed8b01cfda20b59 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Fri, 1 Nov 2024 12:15:23 +0100 Subject: [PATCH 114/445] add changelog --- changelog/10839.deprecation.rst | 1 + changelog/10839.improvement.rst | 1 + 2 files changed, 2 insertions(+) create mode 100644 changelog/10839.deprecation.rst create mode 100644 changelog/10839.improvement.rst diff --git a/changelog/10839.deprecation.rst b/changelog/10839.deprecation.rst new file mode 100644 index 00000000000..c0628191663 --- /dev/null +++ b/changelog/10839.deprecation.rst @@ -0,0 +1 @@ +Synchronous tests that request an asynchronous fixture with ``autouse=True`` will now give a DeprecationWarning. diff --git a/changelog/10839.improvement.rst b/changelog/10839.improvement.rst new file mode 100644 index 00000000000..0a382053c85 --- /dev/null +++ b/changelog/10839.improvement.rst @@ -0,0 +1 @@ +Synchronous tests that request asynchronous fixtures will now error, instead of silently accepting an unawaited coroutine object as the fixture value. From 935c06de09df95c48e867fa70851b9a2acd9fcf7 Mon Sep 17 00:00:00 2001 From: sven <42868792+FreerGit@users.noreply.github.com> Date: Mon, 4 Nov 2024 02:02:18 +0100 Subject: [PATCH 115/445] WIP: don't collect instead of filtering out --- doc/en/reference/reference.rst | 25 +++++---- src/_pytest/main.py | 25 --------- src/_pytest/python.py | 19 +++++++ testing/test_collect_imports.py | 99 +++++++++++++++++++++++++++------ 4 files changed, 115 insertions(+), 53 deletions(-) diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 99b1a19c3a4..53f9470f756 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1301,6 +1301,20 @@ passed multiple times. The expected format is ``name=value``. For example:: variables, that will be expanded. For more information about cache plugin please refer to :ref:`cache_provider`. +.. confval:: collect_imported_tests + + .. versionadded:: 8.4 + + Setting this to ``false`` will make pytest collect classes/functions from test + files only if they are defined in that file (as opposed to imported there). + + .. code-block:: ini + + [pytest] + collect_imported_tests = false + + Default: ``true`` + .. confval:: consider_namespace_packages Controls if pytest should attempt to identify `namespace packages `__ @@ -1838,17 +1852,6 @@ passed multiple times. The expected format is ``name=value``. For example:: pytest testing doc - -.. confval:: collect_imported_tests - - Setting this to `false` will make pytest collect classes/functions from test - files only if they are defined in that file (as opposed to imported there). - - .. code-block:: ini - - [pytest] - collect_imported_tests = false - .. confval:: tmp_path_retention_count How many sessions should we keep the `tmp_path` directories, diff --git a/src/_pytest/main.py b/src/_pytest/main.py index e40f09a9acb..41063a9bc18 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -964,22 +964,9 @@ def collect(self) -> Iterator[nodes.Item | nodes.Collector]: self.trace.root.indent -= 1 def genitems(self, node: nodes.Item | nodes.Collector) -> Iterator[nodes.Item]: - import inspect - - from _pytest.python import Class - from _pytest.python import Function - from _pytest.python import Module - self.trace("genitems", node) if isinstance(node, nodes.Item): node.ihook.pytest_itemcollected(item=node) - if not self.config.getini("collect_imported_tests"): - if isinstance(node.parent, Module) and isinstance(node, Function): - if inspect.isfunction(node._getobj()): - fn_defined_at = node._getobj().__module__ - in_module = node.parent._getobj().__name__ - if fn_defined_at != in_module: - return yield node else: assert isinstance(node, nodes.Collector) @@ -987,18 +974,6 @@ def genitems(self, node: nodes.Item | nodes.Collector) -> Iterator[nodes.Item]: # For backward compat, dedup only applies to files. handle_dupes = not (keepduplicates and isinstance(node, nodes.File)) rep, duplicate = self._collect_one_node(node, handle_dupes) - - if not self.config.getini("collect_imported_tests"): - for subnode in rep.result: - if isinstance(subnode, Class) and isinstance( - subnode.parent, Module - ): - if inspect.isclass(subnode._getobj()): - class_defined_at = subnode._getobj().__module__ - in_module = subnode.parent._getobj().__name__ - if class_defined_at != in_module: - rep.result.remove(subnode) - if duplicate and not keepduplicates: return if rep.passed: diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 9c54dd20f80..9c00252c5f8 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -416,6 +416,15 @@ def collect(self) -> Iterable[nodes.Item | nodes.Collector]: if name in seen: continue seen.add(name) + + if not self.session.config.getini("collect_imported_tests"): + # Do not collect imported functions + if inspect.isfunction(obj) and isinstance(self, Module): + fn_defined_at = obj.__module__ + in_module = self._getobj().__name__ + if fn_defined_at != in_module: + continue + res = ihook.pytest_pycollect_makeitem( collector=self, name=name, obj=obj ) @@ -741,6 +750,16 @@ def newinstance(self): return self.obj() def collect(self) -> Iterable[nodes.Item | nodes.Collector]: + if not self.config.getini("collect_imported_tests"): + # This entire branch will discard (not collect) a class + # if it is imported (defined in a different module) + if isinstance(self, Class) and isinstance(self.parent, Module): + if inspect.isclass(self._getobj()): + class_defined_at = self._getobj().__module__ + in_module = self.parent._getobj().__name__ + if class_defined_at != in_module: + return [] + if not safe_getattr(self.obj, "__test__", True): return [] if hasinit(self.obj): diff --git a/testing/test_collect_imports.py b/testing/test_collect_imports.py index 7922058721c..fe1e6b3e863 100644 --- a/testing/test_collect_imports.py +++ b/testing/test_collect_imports.py @@ -5,6 +5,9 @@ from _pytest.pytester import Pytester +# Start of tests for classes + + def run_import_class_test(pytester: Pytester, passed: int = 0, errors: int = 0) -> None: src_dir = pytester.mkdir("src") tests_dir = pytester.mkdir("tests") @@ -57,26 +60,37 @@ def test_collect_imports_disabled(pytester: Pytester) -> None: run_import_class_test(pytester, passed=1) + # Verify that the state of hooks + reprec = pytester.inline_run() + items_collected = reprec.getcalls("pytest_itemcollected") + assert len(items_collected) == 1 + for x in items_collected: + assert x.item._getobj().__name__ == "test_testament" -def test_collect_imports_default(pytester: Pytester) -> None: - pytester.makeini(""" - [pytest] - testpaths = "tests" - """) +def test_collect_imports_default(pytester: Pytester) -> None: run_import_class_test(pytester, errors=1) + # TODO, hooks + def test_collect_imports_enabled(pytester: Pytester) -> None: pytester.makeini(""" [pytest] - testpaths = "tests" collect_imported_tests = true """) run_import_class_test(pytester, errors=1) +# # TODO, hooks + + +# End of tests for classes +################################# +# Start of tests for functions + + def run_import_functions_test( pytester: Pytester, passed: int, errors: int, failed: int ) -> None: @@ -85,8 +99,8 @@ def run_import_functions_test( src_file = src_dir / "foo.py" - # Note that these "tests" are should _not_ be treated as tests. - # They are normal functions that happens to have test_* or *_test in the name. + # Note that these "tests" should _not_ be treated as tests if `collect_imported_tests = false` + # They are normal functions in that case, that happens to have test_* or *_test in the name. # Thus should _not_ be collected! src_file.write_text( textwrap.dedent("""\ @@ -121,7 +135,6 @@ def test_important(self): res = test_function() if res == 5: pass - """), encoding="utf-8", ) @@ -138,31 +151,83 @@ def test_collect_function_imports_enabled(pytester: Pytester) -> None: """) run_import_functions_test(pytester, passed=2, errors=0, failed=1) + reprec = pytester.inline_run() + items_collected = reprec.getcalls("pytest_itemcollected") + # Recall that the default is `collect_imported_tests = true`. + # Which means that the normal functions are now interpreted as + # valid tests and `test_function()` will fail. + assert len(items_collected) == 3 + for x in items_collected: + assert x.item._getobj().__name__ in [ + "test_important", + "test_bar", + "test_function", + ] -def test_collect_function_imports_disabled(pytester: Pytester) -> None: +def test_behaviour_without_testpaths_set_and_false(pytester: Pytester) -> None: + # Make sure `collect_imported_tests` has no dependence on `testpaths` pytester.makeini(""" [pytest] - # testpaths = "tests" collect_imported_tests = false """) run_import_functions_test(pytester, passed=1, errors=0, failed=0) + reprec = pytester.inline_run() + items_collected = reprec.getcalls("pytest_itemcollected") + assert len(items_collected) == 1 + for x in items_collected: + assert x.item._getobj().__name__ == "test_important" -def test_behaviour_without_testpaths_set_and_false(pytester: Pytester) -> None: +def test_behaviour_without_testpaths_set_and_true(pytester: Pytester) -> None: + # Make sure `collect_imported_tests` has no dependence on `testpaths` pytester.makeini(""" [pytest] - collect_imported_tests = false + collect_imported_tests = true """) - run_import_functions_test(pytester, passed=1, errors=0, failed=0) + run_import_functions_test(pytester, passed=2, errors=0, failed=1) + reprec = pytester.inline_run() + items_collected = reprec.getcalls("pytest_itemcollected") + assert len(items_collected) == 3 -def test_behaviour_without_testpaths_set_and_true(pytester: Pytester) -> None: +def test_hook_behaviour_when_collect_off(pytester: Pytester) -> None: pytester.makeini(""" [pytest] - collect_imported_tests = true + collect_imported_tests = false """) - run_import_functions_test(pytester, passed=2, errors=0, failed=1) + run_import_functions_test(pytester, passed=1, errors=0, failed=0) + reprec = pytester.inline_run() + + # reports = reprec.getreports("pytest_collectreport") + items_collected = reprec.getcalls("pytest_itemcollected") + modified = reprec.getcalls("pytest_collection_modifyitems") + + # print("Reports: ----------------") + # print(reports) + # for r in reports: + # print(r) + + # TODO this is want I want, I think.... + # + # + # + # + # + + # TODO + # assert(reports.outcome == "passed") + # assert(len(reports.result) == 1) + + # print("Items collected: ----------------") + # print(items_collected) + # print("Modified : ----------------") + + assert len(items_collected) == 1 + for x in items_collected: + assert x.item._getobj().__name__ == "test_important" + + assert len(modified) == 1 From 3ef3c2d83498f550e8e678e209c6739dccfabe55 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 06:15:25 +0100 Subject: [PATCH 116/445] build(deps): Bump hynek/build-and-inspect-python-package (#12936) Bumps [hynek/build-and-inspect-python-package](https://github.com/hynek/build-and-inspect-python-package) from 2.9.0 to 2.10.0. - [Release notes](https://github.com/hynek/build-and-inspect-python-package/releases) - [Changelog](https://github.com/hynek/build-and-inspect-python-package/blob/main/CHANGELOG.md) - [Commits](https://github.com/hynek/build-and-inspect-python-package/compare/v2.9.0...v2.10.0) --- updated-dependencies: - dependency-name: hynek/build-and-inspect-python-package dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/deploy.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 998a2839dc2..974fe4947db 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,7 +31,7 @@ jobs: persist-credentials: false - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v2.9.0 + uses: hynek/build-and-inspect-python-package@v2.10.0 with: attest-build-provenance-github: 'true' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ff5b18e2fca..52faca6ddef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,7 +40,7 @@ jobs: fetch-depth: 0 persist-credentials: false - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v2.9.0 + uses: hynek/build-and-inspect-python-package@v2.10.0 build: needs: [package] From 3ce9be96a11aad3f148c6ab11709cfa940cadea2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:42:16 +0100 Subject: [PATCH 117/445] build(deps): Bump pytest-cov in /testing/plugins_integration (#12937) Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 5.0.0 to 6.0.0. - [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest-cov/compare/v5.0.0...v6.0.0) --- updated-dependencies: - dependency-name: pytest-cov dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index c465041d64d..ef01747f2fd 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -2,7 +2,7 @@ anyio[curio,trio]==4.6.2.post1 django==5.1.2 pytest-asyncio==0.24.0 pytest-bdd==7.3.0 -pytest-cov==5.0.0 +pytest-cov==6.0.0 pytest-django==4.9.0 pytest-flakes==4.0.5 pytest-html==4.1.1 From 8889e9b7f4fa6e0acf3088c7049330137903af85 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 6 Nov 2024 08:16:16 -0300 Subject: [PATCH 118/445] [automated] Update plugin list (#12933) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 176 +++++++++++++++++-------------- 1 file changed, 96 insertions(+), 80 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 1cd265578eb..50206c34150 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =3.5.0) :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest - :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Aug 08, 2024 N/A pytest + :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Oct 22, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A - :pypi:`pytest-benchmark` A \`\`pytest\`\` fixture for benchmarking code. It will group the tests into rounds that are calibrated to the chosen timer. Oct 25, 2022 5 - Production/Stable pytest (>=3.8) + :pypi:`pytest-benchmark` A \`\`pytest\`\` fixture for benchmarking code. It will group the tests into rounds that are calibrated to the chosen timer. Oct 30, 2024 5 - Production/Stable pytest>=8.1 :pypi:`pytest-better-datadir` A small example package Mar 13, 2023 N/A N/A :pypi:`pytest-better-parametrize` Better description of parametrized test cases Mar 05, 2024 4 - Beta pytest >=6.2.0 :pypi:`pytest-bg-process` Pytest plugin to initialize background process Jan 24, 2022 4 - Beta pytest (>=3.5.0) @@ -234,7 +234,7 @@ This list contains 1536 plugins. :pypi:`pytest-check-mk` pytest plugin to test Check_MK checks Nov 19, 2015 4 - Beta pytest :pypi:`pytest-check-requirements` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A :pypi:`pytest-ch-framework` My pytest framework Apr 17, 2024 N/A pytest==8.0.1 - :pypi:`pytest-chic-report` A pytest plugin to send a report and printing summary of tests. Jan 31, 2023 5 - Production/Stable N/A + :pypi:`pytest-chic-report` Simple pytest plugin for generating and sending report to messengers. Nov 01, 2024 N/A pytest>=6.0 :pypi:`pytest-choose` Provide the pytest with the ability to collect use cases based on rules in text files Feb 04, 2024 N/A pytest >=7.0.0 :pypi:`pytest-chunks` Run only a chunk of your test suite Jul 05, 2022 N/A pytest (>=6.0.0) :pypi:`pytest_cid` Compare data structures containing matching CIDs of different versions and encoding Sep 01, 2023 4 - Beta pytest >= 5.0, < 7.0 @@ -254,7 +254,7 @@ This list contains 1536 plugins. :pypi:`pytest-cloud` Distributed tests planner plugin for pytest testing framework. Oct 05, 2020 6 - Mature N/A :pypi:`pytest-cloudflare-worker` pytest plugin for testing cloudflare workers Mar 30, 2021 4 - Beta pytest (>=6.0.0) :pypi:`pytest-cloudist` Distribute tests to cloud machines without fuss Sep 02, 2022 4 - Beta pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-cmake` Provide CMake module for Pytest Oct 16, 2024 N/A pytest<9,>=4 + :pypi:`pytest-cmake` Provide CMake module for Pytest Oct 27, 2024 N/A pytest<9,>=4 :pypi:`pytest-cmake-presets` Execute CMake Presets via pytest Dec 26, 2022 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-cmdline-add-args` Pytest plugin for custom argument handling and Allure reporting. This plugin allows you to add arguments before running a test. Sep 01, 2024 N/A N/A :pypi:`pytest-cobra` PyTest plugin for testing Smart Contracts for Ethereum blockchain. Jun 29, 2019 3 - Alpha pytest (<4.0.0,>=3.7.1) @@ -265,7 +265,7 @@ This list contains 1536 plugins. :pypi:`pytest-codegen` Automatically create pytest test signatures Aug 23, 2020 2 - Pre-Alpha N/A :pypi:`pytest-codeowners` Pytest plugin for selecting tests by GitHub CODEOWNERS. Mar 30, 2022 4 - Beta pytest (>=6.0.0) :pypi:`pytest-codestyle` pytest plugin to run pycodestyle Mar 23, 2020 3 - Alpha N/A - :pypi:`pytest-codspeed` Pytest plugin to create CodSpeed benchmarks Sep 27, 2024 5 - Production/Stable pytest>=3.8 + :pypi:`pytest-codspeed` Pytest plugin to create CodSpeed benchmarks Oct 29, 2024 5 - Production/Stable pytest>=3.8 :pypi:`pytest-collect-appoint-info` set your encoding Aug 03, 2023 N/A pytest :pypi:`pytest-collect-formatter` Formatter for pytest collect output Mar 29, 2021 5 - Production/Stable N/A :pypi:`pytest-collect-formatter2` Formatter for pytest collect output May 31, 2021 5 - Production/Stable N/A @@ -290,7 +290,7 @@ This list contains 1536 plugins. :pypi:`pytest-copier` A pytest plugin to help testing Copier templates Dec 11, 2023 4 - Beta pytest>=7.3.2 :pypi:`pytest-couchdbkit` py.test extension for per-test couchdb databases using couchdbkit Apr 17, 2012 N/A N/A :pypi:`pytest-count` count erros and send email Jan 12, 2018 4 - Beta N/A - :pypi:`pytest-cov` Pytest plugin for measuring coverage. Mar 24, 2024 5 - Production/Stable pytest>=4.6 + :pypi:`pytest-cov` Pytest plugin for measuring coverage. Oct 29, 2024 5 - Production/Stable pytest>=4.6 :pypi:`pytest-cover` Pytest plugin for measuring coverage. Forked from \`pytest-cov\`. Aug 01, 2015 5 - Production/Stable N/A :pypi:`pytest-coverage` Jun 17, 2015 N/A N/A :pypi:`pytest-coverage-context` Coverage dynamic context support for PyTest, including sub-processes Jun 28, 2023 4 - Beta N/A @@ -465,14 +465,14 @@ This list contains 1536 plugins. :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Oct 25, 2024 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Oct 25, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Oct 25, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Oct 25, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Oct 25, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Oct 25, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Oct 25, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Oct 25, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Oct 29, 2024 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Oct 29, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Oct 29, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Oct 29, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Oct 29, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Oct 29, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Oct 29, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Oct 29, 2024 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -500,11 +500,11 @@ This list contains 1536 plugins. :pypi:`pytest_evm` The testing package containing tools to test Web3-based projects Sep 23, 2024 4 - Beta pytest<9.0.0,>=8.1.1 :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Aug 13, 2024 4 - Beta pytest>=7 - :pypi:`pytest-exasol-backend` Sep 18, 2024 N/A pytest<9,>=7 + :pypi:`pytest-exasol-backend` Oct 31, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-extension` Oct 10, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-itde` Jul 01, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-saas` Aug 06, 2024 N/A pytest<9,>=7 - :pypi:`pytest-exasol-slc` Sep 24, 2024 N/A pytest<9,>=7 + :pypi:`pytest-exasol-slc` Nov 01, 2024 N/A pytest<9,>=7 :pypi:`pytest-excel` pytest plugin for generating excel reports Jun 18, 2024 5 - Production/Stable pytest>3.6 :pypi:`pytest-exceptional` Better exceptions Mar 16, 2017 4 - Beta N/A :pypi:`pytest-exception-script` Walk your code through exception script to check it's resiliency to failures. Aug 04, 2020 3 - Alpha pytest @@ -647,7 +647,7 @@ This list contains 1536 plugins. :pypi:`pytest-hardware-test-report` A simple plugin to use with pytest Apr 01, 2024 4 - Beta pytest<9.0.0,>=8.0.0 :pypi:`pytest-harmony` Chain tests and data with pytest Jan 17, 2023 N/A pytest (>=7.2.1,<8.0.0) :pypi:`pytest-harvest` Store data created during your pytest tests execution, and retrieve it at the end of the session, e.g. for applicative benchmarking purposes. Mar 16, 2024 5 - Production/Stable N/A - :pypi:`pytest-helm-charts` A plugin to provide different types and configs of Kubernetes clusters that can be used for testing. Oct 23, 2024 4 - Beta pytest<9.0.0,>=8.0.0 + :pypi:`pytest-helm-charts` A plugin to provide different types and configs of Kubernetes clusters that can be used for testing. Oct 31, 2024 4 - Beta pytest<9.0.0,>=8.0.0 :pypi:`pytest-helm-templates` Pytest fixtures for unit testing the output of helm templates Aug 07, 2024 N/A pytest~=7.4.0; extra == "dev" :pypi:`pytest-helper` Functions to help in using the pytest testing framework May 31, 2019 5 - Production/Stable N/A :pypi:`pytest-helpers` pytest helpers May 17, 2020 N/A pytest @@ -660,7 +660,7 @@ This list contains 1536 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Oct 26, 2024 3 - Alpha pytest==8.3.3 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Nov 01, 2024 3 - Alpha pytest==8.3.3 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -685,7 +685,7 @@ This list contains 1536 plugins. :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Aug 11, 2024 3 - Alpha N/A :pypi:`pytest-httptesting` http_testing framework on top of pytest Aug 10, 2024 N/A pytest<9.0.0,>=8.2.0 - :pypi:`pytest-httpx` Send responses to httpx. Sep 27, 2024 5 - Production/Stable pytest==8.* + :pypi:`pytest-httpx` Send responses to httpx. Oct 28, 2024 5 - Production/Stable pytest==8.* :pypi:`pytest-httpx-blockage` Disable httpx requests during a test run Feb 16, 2023 N/A pytest (>=7.2.1) :pypi:`pytest-httpx-recorder` Recorder feature based on pytest_httpx, like recorder feature in responses. Jan 04, 2024 5 - Production/Stable pytest :pypi:`pytest-hue` Visualise PyTest status via your Phillips Hue lights May 09, 2019 N/A N/A @@ -715,7 +715,7 @@ This list contains 1536 plugins. :pypi:`pytest-inline` A pytest plugin for writing inline tests Oct 24, 2024 4 - Beta pytest<9.0,>=7.0 :pypi:`pytest-inmanta` A py.test plugin providing fixtures to simplify inmanta modules testing. Oct 10, 2024 5 - Production/Stable pytest :pypi:`pytest-inmanta-extensions` Inmanta tests package Oct 10, 2024 5 - Production/Stable N/A - :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Aug 20, 2024 5 - Production/Stable N/A + :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Oct 29, 2024 5 - Production/Stable N/A :pypi:`pytest-inmanta-yang` Common fixtures used in inmanta yang related modules Feb 22, 2024 4 - Beta pytest :pypi:`pytest-Inomaly` A simple image diff plugin for pytest Feb 13, 2018 4 - Beta N/A :pypi:`pytest-in-robotframework` The extension enables easy execution of pytest tests within the Robot Framework environment. Mar 02, 2024 N/A pytest @@ -732,11 +732,12 @@ This list contains 1536 plugins. :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A - :pypi:`pytest-ipywidgets` Oct 15, 2024 N/A pytest + :pypi:`pytest-ipywidgets` Oct 28, 2024 N/A pytest :pypi:`pytest-isolate` Feb 20, 2023 4 - Beta pytest :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Sep 18, 2024 4 - Beta pytest>=5 :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-it` Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it. Jan 29, 2024 4 - Beta N/A + :pypi:`pytest-item-dict` Get a hierarchical dict of session.items Oct 30, 2024 4 - Beta pytest>=8.3.0 :pypi:`pytest-iterassert` Nicer list and iterable assertion messages for pytest May 11, 2020 3 - Alpha N/A :pypi:`pytest-iteration` Add iteration mark for tests Aug 22, 2024 N/A pytest :pypi:`pytest-iters` A contextmanager pytest fixture for handling multiple mock iters May 24, 2022 N/A N/A @@ -747,7 +748,7 @@ This list contains 1536 plugins. :pypi:`pytest-jinja` A plugin to generate customizable jinja-based HTML reports in pytest Oct 04, 2022 3 - Alpha pytest (>=6.2.5,<7.0.0) :pypi:`pytest-jira` py.test JIRA integration plugin, using markers Apr 30, 2024 3 - Alpha N/A :pypi:`pytest-jira-xfail` Plugin skips (xfail) tests if unresolved Jira issue(s) linked Jul 09, 2024 N/A pytest>=7.2.0 - :pypi:`pytest-jira-xray` pytest plugin to integrate tests with JIRA XRAY Jul 19, 2024 4 - Beta pytest>=6.2.4 + :pypi:`pytest-jira-xray` pytest plugin to integrate tests with JIRA XRAY Oct 27, 2024 4 - Beta pytest>=6.2.4 :pypi:`pytest-job-selection` A pytest plugin for load balancing test suites Jan 30, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-jobserver` Limit parallel tests with posix jobserver. May 15, 2019 5 - Production/Stable pytest :pypi:`pytest-joke` Test failures are better served with humor. Oct 08, 2019 4 - Beta pytest (>=4.2.1) @@ -775,7 +776,7 @@ This list contains 1536 plugins. :pypi:`pytest-kookit` Your simple but kooky integration testing with pytest Sep 10, 2024 N/A N/A :pypi:`pytest-koopmans` A plugin for testing the koopmans package Nov 21, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-krtech-common` pytest krtech common library Nov 28, 2016 4 - Beta N/A - :pypi:`pytest-kubernetes` Sep 14, 2023 N/A pytest (>=7.2.1,<8.0.0) + :pypi:`pytest-kubernetes` Oct 28, 2024 N/A pytest<9.0.0,>=8.3.0 :pypi:`pytest-kuunda` pytest plugin to help with test data setup for PySpark tests Feb 25, 2024 4 - Beta pytest >=6.2.0 :pypi:`pytest-kwparametrize` Alternate syntax for @pytest.mark.parametrize with test cases as dictionaries and default value fallbacks Jan 22, 2021 N/A pytest (>=6) :pypi:`pytest-lambda` Define pytest fixtures with lambda functions. May 27, 2024 5 - Production/Stable pytest<9,>=3.6 @@ -817,7 +818,7 @@ This list contains 1536 plugins. :pypi:`pytest-logger` Plugin configuring handlers for loggers from Python logging module. Mar 10, 2024 5 - Production/Stable pytest (>=3.2) :pypi:`pytest-logging` Configures logging and allows tweaking the log level with a py.test flag Nov 04, 2015 4 - Beta N/A :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-logikal` Common testing environment Aug 30, 2024 5 - Production/Stable pytest==8.3.2 + :pypi:`pytest-logikal` Common testing environment Oct 28, 2024 5 - Production/Stable pytest==8.3.3 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Sep 30, 2024 4 - Beta pytest>=8.2.2 :pypi:`pytest-loguru` Pytest Loguru Mar 20, 2024 5 - Production/Stable pytest; extra == "test" @@ -829,7 +830,7 @@ This list contains 1536 plugins. :pypi:`pytest-markdown` Test your markdown docs with pytest Jan 15, 2021 4 - Beta pytest (>=6.0.1,<7.0.0) :pypi:`pytest-markdown-docs` Run markdown code fences through pytest Oct 22, 2024 N/A pytest>=7.0.0 :pypi:`pytest-marker-bugzilla` py.test bugzilla integration plugin, using markers Jan 09, 2020 N/A N/A - :pypi:`pytest-markers-presence` A simple plugin to detect missed pytest tags and markers" Feb 04, 2021 4 - Beta pytest (>=6.0) + :pypi:`pytest-markers-presence` A simple plugin to detect missed pytest tags and markers" Oct 30, 2024 4 - Beta pytest>=6.0 :pypi:`pytest-markfiltration` UNKNOWN Nov 08, 2011 3 - Alpha N/A :pypi:`pytest-mark-manage` 用例标签化管理 Aug 15, 2024 N/A pytest :pypi:`pytest-mark-no-py3` pytest plugin and bowler codemod to help migrate tests to Python 3 May 17, 2019 N/A pytest @@ -977,7 +978,7 @@ This list contains 1536 plugins. :pypi:`pytest-param` pytest plugin to test all, first, last or random params Sep 11, 2016 4 - Beta pytest (>=2.6.0) :pypi:`pytest-paramark` Configure pytest fixtures using a combination of"parametrize" and markers Jan 10, 2020 4 - Beta pytest (>=4.5.0) :pypi:`pytest-parametrization` Simpler PyTest parametrization May 22, 2022 5 - Production/Stable N/A - :pypi:`pytest-parametrize` pytest decorator for parametrizing test cases in a dict-way Sep 23, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.0 + :pypi:`pytest-parametrize` pytest decorator for parametrizing test cases in a dict-way Oct 30, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.0 :pypi:`pytest-parametrize-cases` A more user-friendly way to write parametrized tests. Mar 13, 2022 N/A pytest (>=6.1.2) :pypi:`pytest-parametrized` Pytest decorator for parametrizing tests with default iterables. Oct 22, 2024 5 - Production/Stable pytest :pypi:`pytest-parametrize-suite` A simple pytest extension for creating a named test suite. Jan 19, 2023 5 - Production/Stable pytest @@ -1096,7 +1097,7 @@ This list contains 1536 plugins. :pypi:`pytest-pyvenv` A package for create venv in tests Feb 27, 2024 N/A pytest ; extra == 'test' :pypi:`pytest-pyvista` Pytest-pyvista package Sep 29, 2023 4 - Beta pytest>=3.5.0 :pypi:`pytest-qanova` A pytest plugin to collect test information Sep 05, 2024 3 - Alpha pytest - :pypi:`pytest-qaseio` Pytest plugin for Qase.io integration May 30, 2024 4 - Beta pytest<9.0.0,>=7.2.2 + :pypi:`pytest-qaseio` Pytest plugin for Qase.io integration Oct 28, 2024 5 - Production/Stable pytest<9.0.0,>=7.2.2 :pypi:`pytest-qasync` Pytest support for qasync. Jul 12, 2021 4 - Beta pytest (>=5.4.0) :pypi:`pytest-qatouch` Pytest plugin for uploading test results to your QA Touch Testrun. Feb 14, 2023 4 - Beta pytest (>=6.2.0) :pypi:`pytest-qgis` A pytest plugin for testing QGIS python plugins Jun 14, 2024 5 - Production/Stable pytest>=6.0 @@ -1126,7 +1127,7 @@ This list contains 1536 plugins. :pypi:`pytest-recorder` Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. Jun 27, 2024 N/A N/A :pypi:`pytest-recording` A pytest plugin that allows you recording of network interactions via VCR.py Jul 09, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-recordings` Provides pytest plugins for reporting request/response traffic, screenshots, and more to ReportPortal Aug 13, 2020 N/A N/A - :pypi:`pytest-record-video` 用例执行过程中录制视频 Aug 15, 2024 N/A N/A + :pypi:`pytest-record-video` 用例执行过程中录制视频 Oct 31, 2024 N/A N/A :pypi:`pytest-redis` Redis fixtures and fixture factories for Pytest. Jun 19, 2024 5 - Production/Stable pytest>=6.2 :pypi:`pytest-redislite` Pytest plugin for testing code using Redis Apr 05, 2022 4 - Beta pytest :pypi:`pytest-redmine` Pytest plugin for redmine Mar 19, 2018 1 - Planning N/A @@ -1157,7 +1158,7 @@ This list contains 1536 plugins. :pypi:`pytest-reportlog` Replacement for the --resultlog option, focused in simplicity and extensibility May 22, 2023 3 - Alpha pytest :pypi:`pytest-report-me` A pytest plugin to generate report. Dec 31, 2020 N/A pytest :pypi:`pytest-report-parameters` pytest plugin for adding tests' parameters to junit report Jun 18, 2020 3 - Alpha pytest (>=2.4.2) - :pypi:`pytest-reportportal` Agent for Reporting results of tests to the Report Portal Oct 22, 2024 N/A pytest>=3.8.0 + :pypi:`pytest-reportportal` Agent for Reporting results of tests to the Report Portal Oct 31, 2024 N/A pytest>=3.8.0 :pypi:`pytest-report-stream` A pytest plugin which allows to stream test reports at runtime Oct 22, 2023 4 - Beta N/A :pypi:`pytest-repo-structure` Pytest Repo Structure Mar 18, 2024 1 - Planning N/A :pypi:`pytest-req` pytest requests plugin Aug 31, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.2 @@ -1223,10 +1224,10 @@ This list contains 1536 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Oct 26, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Nov 01, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 - :pypi:`pytest-schedule` The job of test scheduling for humans. Jan 07, 2023 5 - Production/Stable N/A + :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A :pypi:`pytest-schema` 👍 Validate return values against a schema-like object in testing Feb 16, 2024 5 - Production/Stable pytest >=3.5.0 :pypi:`pytest-screenshot-on-failure` Saves a screenshot when a test case from a pytest execution fails Jul 21, 2023 4 - Beta N/A :pypi:`pytest-scrutinize` Scrutinize your pytest test suites for slow fixtures, tests and more. Aug 19, 2024 4 - Beta pytest>=6 @@ -1234,7 +1235,7 @@ This list contains 1536 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Oct 26, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Nov 01, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1313,7 +1314,7 @@ This list contains 1536 plugins. :pypi:`pytest-splitio` Split.io SDK integration for e2e tests Sep 22, 2020 N/A pytest (<7,>=5.0) :pypi:`pytest-split-tests` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Forked from Mark Adams' original project pytest-test-groups. Jul 30, 2021 5 - Production/Stable pytest (>=2.5) :pypi:`pytest-split-tests-tresorit` Feb 22, 2021 1 - Planning N/A - :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Sep 04, 2024 N/A pytest<8,>5.4.0 + :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Oct 28, 2024 N/A pytest<8,>5.4.0 :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Sep 26, 2024 N/A N/A :pypi:`pytest-splunk-env` pytest fixtures for interaction with Splunk Enterprise and Splunk Cloud Oct 22, 2020 N/A pytest (>=6.1.1,<7.0.0) :pypi:`pytest-sqitch` sqitch for pytest Apr 06, 2020 4 - Beta N/A @@ -1335,6 +1336,7 @@ This list contains 1536 plugins. :pypi:`pytest-steps` Create step-wise / incremental tests in pytest. Sep 23, 2021 5 - Production/Stable N/A :pypi:`pytest-stepwise` Run a test suite one failing test at a time. Dec 01, 2015 4 - Beta N/A :pypi:`pytest-stf` pytest plugin for openSTF Sep 24, 2024 N/A pytest>=5.0 + :pypi:`pytest-stochastics` pytest plugin that allows selectively running tests several times and accepting \*some\* failures. Oct 31, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-stoq` A plugin to pytest stoq Feb 09, 2021 4 - Beta N/A :pypi:`pytest-store` Pytest plugin to store values from test runs Sep 04, 2024 3 - Alpha pytest>=7.0.0 :pypi:`pytest-stress` A Pytest plugin that allows you to loop tests for a user defined amount of time. Dec 07, 2019 4 - Beta pytest (>=3.6.0) @@ -1467,7 +1469,7 @@ This list contains 1536 plugins. :pypi:`pytest-typhoon-config` A Typhoon HIL plugin that facilitates test parameter configuration at runtime Apr 07, 2022 5 - Production/Stable N/A :pypi:`pytest-typhoon-polarion` Typhoontest plugin for Siemens Polarion Feb 01, 2024 4 - Beta N/A :pypi:`pytest-typhoon-xray` Typhoon HIL plugin for pytest Aug 15, 2023 4 - Beta N/A - :pypi:`pytest-typing-runner` Pytest plugin to make it easier to run and check python code against static type checkers Sep 09, 2024 N/A pytest==8.2.2; extra == "tests" + :pypi:`pytest-typing-runner` Pytest plugin to make it easier to run and check python code against static type checkers Oct 27, 2024 N/A N/A :pypi:`pytest-tytest` Typhoon HIL plugin for pytest May 25, 2020 4 - Beta pytest (>=5.4.2) :pypi:`pytest-ubersmith` Easily mock calls to ubersmith at the \`requests\` level. Apr 13, 2015 N/A N/A :pypi:`pytest-ui` Text User Interface for running python tests Jul 05, 2021 4 - Beta pytest @@ -2430,7 +2432,7 @@ This list contains 1536 plugins. A pytest plugin that reports test results to the BeakerLib framework :pypi:`pytest-beartype` - *last release*: Aug 08, 2024, + *last release*: Oct 31, 2024, *status*: N/A, *requires*: pytest @@ -2465,9 +2467,9 @@ This list contains 1536 plugins. Benchmark utility that plugs into pytest. :pypi:`pytest-benchmark` - *last release*: Oct 25, 2022, + *last release*: Oct 30, 2024, *status*: 5 - Production/Stable, - *requires*: pytest (>=3.8) + *requires*: pytest>=8.1 A \`\`pytest\`\` fixture for benchmarking code. It will group the tests into rounds that are calibrated to the chosen timer. @@ -2976,11 +2978,11 @@ This list contains 1536 plugins. My pytest framework :pypi:`pytest-chic-report` - *last release*: Jan 31, 2023, - *status*: 5 - Production/Stable, - *requires*: N/A + *last release*: Nov 01, 2024, + *status*: N/A, + *requires*: pytest>=6.0 - A pytest plugin to send a report and printing summary of tests. + Simple pytest plugin for generating and sending report to messengers. :pypi:`pytest-choose` *last release*: Feb 04, 2024, @@ -3116,7 +3118,7 @@ This list contains 1536 plugins. Distribute tests to cloud machines without fuss :pypi:`pytest-cmake` - *last release*: Oct 16, 2024, + *last release*: Oct 27, 2024, *status*: N/A, *requires*: pytest<9,>=4 @@ -3193,7 +3195,7 @@ This list contains 1536 plugins. pytest plugin to run pycodestyle :pypi:`pytest-codspeed` - *last release*: Sep 27, 2024, + *last release*: Oct 29, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=3.8 @@ -3368,7 +3370,7 @@ This list contains 1536 plugins. count erros and send email :pypi:`pytest-cov` - *last release*: Mar 24, 2024, + *last release*: Oct 29, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=4.6 @@ -4593,56 +4595,56 @@ This list contains 1536 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: Oct 25, 2024, + *last release*: Oct 29, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: Oct 25, 2024, + *last release*: Oct 29, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: Oct 25, 2024, + *last release*: Oct 29, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: Oct 25, 2024, + *last release*: Oct 29, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. :pypi:`pytest-embedded-qemu` - *last release*: Oct 25, 2024, + *last release*: Oct 29, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: Oct 25, 2024, + *last release*: Oct 29, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: Oct 25, 2024, + *last release*: Oct 29, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: Oct 25, 2024, + *last release*: Oct 29, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -4838,7 +4840,7 @@ This list contains 1536 plugins. Pytest plugin for testing examples in docstrings and markdown files. :pypi:`pytest-exasol-backend` - *last release*: Sep 18, 2024, + *last release*: Oct 31, 2024, *status*: N/A, *requires*: pytest<9,>=7 @@ -4866,7 +4868,7 @@ This list contains 1536 plugins. :pypi:`pytest-exasol-slc` - *last release*: Sep 24, 2024, + *last release*: Nov 01, 2024, *status*: N/A, *requires*: pytest<9,>=7 @@ -5867,7 +5869,7 @@ This list contains 1536 plugins. Store data created during your pytest tests execution, and retrieve it at the end of the session, e.g. for applicative benchmarking purposes. :pypi:`pytest-helm-charts` - *last release*: Oct 23, 2024, + *last release*: Oct 31, 2024, *status*: 4 - Beta, *requires*: pytest<9.0.0,>=8.0.0 @@ -5958,7 +5960,7 @@ This list contains 1536 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Oct 26, 2024, + *last release*: Nov 01, 2024, *status*: 3 - Alpha, *requires*: pytest==8.3.3 @@ -6133,7 +6135,7 @@ This list contains 1536 plugins. http_testing framework on top of pytest :pypi:`pytest-httpx` - *last release*: Sep 27, 2024, + *last release*: Oct 28, 2024, *status*: 5 - Production/Stable, *requires*: pytest==8.* @@ -6343,7 +6345,7 @@ This list contains 1536 plugins. Inmanta tests package :pypi:`pytest-inmanta-lsm` - *last release*: Aug 20, 2024, + *last release*: Oct 29, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -6462,7 +6464,7 @@ This list contains 1536 plugins. THIS PROJECT IS ABANDONED :pypi:`pytest-ipywidgets` - *last release*: Oct 15, 2024, + *last release*: Oct 28, 2024, *status*: N/A, *requires*: pytest @@ -6496,6 +6498,13 @@ This list contains 1536 plugins. Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it. + :pypi:`pytest-item-dict` + *last release*: Oct 30, 2024, + *status*: 4 - Beta, + *requires*: pytest>=8.3.0 + + Get a hierarchical dict of session.items + :pypi:`pytest-iterassert` *last release*: May 11, 2020, *status*: 3 - Alpha, @@ -6567,7 +6576,7 @@ This list contains 1536 plugins. Plugin skips (xfail) tests if unresolved Jira issue(s) linked :pypi:`pytest-jira-xray` - *last release*: Jul 19, 2024, + *last release*: Oct 27, 2024, *status*: 4 - Beta, *requires*: pytest>=6.2.4 @@ -6763,9 +6772,9 @@ This list contains 1536 plugins. pytest krtech common library :pypi:`pytest-kubernetes` - *last release*: Sep 14, 2023, + *last release*: Oct 28, 2024, *status*: N/A, - *requires*: pytest (>=7.2.1,<8.0.0) + *requires*: pytest<9.0.0,>=8.3.0 @@ -7057,9 +7066,9 @@ This list contains 1536 plugins. :pypi:`pytest-logikal` - *last release*: Aug 30, 2024, + *last release*: Oct 28, 2024, *status*: 5 - Production/Stable, - *requires*: pytest==8.3.2 + *requires*: pytest==8.3.3 Common testing environment @@ -7141,9 +7150,9 @@ This list contains 1536 plugins. py.test bugzilla integration plugin, using markers :pypi:`pytest-markers-presence` - *last release*: Feb 04, 2021, + *last release*: Oct 30, 2024, *status*: 4 - Beta, - *requires*: pytest (>=6.0) + *requires*: pytest>=6.0 A simple plugin to detect missed pytest tags and markers" @@ -8177,7 +8186,7 @@ This list contains 1536 plugins. Simpler PyTest parametrization :pypi:`pytest-parametrize` - *last release*: Sep 23, 2024, + *last release*: Oct 30, 2024, *status*: 5 - Production/Stable, *requires*: pytest<9.0.0,>=8.3.0 @@ -9010,8 +9019,8 @@ This list contains 1536 plugins. A pytest plugin to collect test information :pypi:`pytest-qaseio` - *last release*: May 30, 2024, - *status*: 4 - Beta, + *last release*: Oct 28, 2024, + *status*: 5 - Production/Stable, *requires*: pytest<9.0.0,>=7.2.2 Pytest plugin for Qase.io integration @@ -9220,7 +9229,7 @@ This list contains 1536 plugins. Provides pytest plugins for reporting request/response traffic, screenshots, and more to ReportPortal :pypi:`pytest-record-video` - *last release*: Aug 15, 2024, + *last release*: Oct 31, 2024, *status*: N/A, *requires*: N/A @@ -9437,7 +9446,7 @@ This list contains 1536 plugins. pytest plugin for adding tests' parameters to junit report :pypi:`pytest-reportportal` - *last release*: Oct 22, 2024, + *last release*: Oct 31, 2024, *status*: N/A, *requires*: pytest>=3.8.0 @@ -9899,7 +9908,7 @@ This list contains 1536 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Oct 26, 2024, + *last release*: Nov 01, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9920,11 +9929,11 @@ This list contains 1536 plugins. A pytest plugin that generates unit test scenarios from data files. :pypi:`pytest-schedule` - *last release*: Jan 07, 2023, - *status*: 5 - Production/Stable, + *last release*: Oct 31, 2024, + *status*: N/A, *requires*: N/A - The job of test scheduling for humans. + Automate and customize test scheduling effortlessly on local machines. :pypi:`pytest-schema` *last release*: Feb 16, 2024, @@ -9976,7 +9985,7 @@ This list contains 1536 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Oct 26, 2024, + *last release*: Nov 01, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10529,7 +10538,7 @@ This list contains 1536 plugins. :pypi:`pytest-splunk-addon` - *last release*: Sep 04, 2024, + *last release*: Oct 28, 2024, *status*: N/A, *requires*: pytest<8,>5.4.0 @@ -10682,6 +10691,13 @@ This list contains 1536 plugins. pytest plugin for openSTF + :pypi:`pytest-stochastics` + *last release*: Oct 31, 2024, + *status*: N/A, + *requires*: pytest<9.0.0,>=8.0.0 + + pytest plugin that allows selectively running tests several times and accepting \*some\* failures. + :pypi:`pytest-stoq` *last release*: Feb 09, 2021, *status*: 4 - Beta, @@ -11607,9 +11623,9 @@ This list contains 1536 plugins. Typhoon HIL plugin for pytest :pypi:`pytest-typing-runner` - *last release*: Sep 09, 2024, + *last release*: Oct 27, 2024, *status*: N/A, - *requires*: pytest==8.2.2; extra == "tests" + *requires*: N/A Pytest plugin to make it easier to run and check python code against static type checkers From 5beab07de39dc4dd8a8db289f934288ae5be6bfc Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 6 Nov 2024 14:02:25 +0100 Subject: [PATCH 119/445] improve warning message. Make it warn regardless of autouse or not. Add section to deprecations.rst --- changelog/10839.deprecation.rst | 2 +- changelog/10839.improvement.rst | 1 - doc/en/deprecations.rst | 55 +++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- src/_pytest/fixtures.py | 19 +++++++----- testing/acceptance_test.py | 40 +++++++++++++++--------- 6 files changed, 93 insertions(+), 26 deletions(-) delete mode 100644 changelog/10839.improvement.rst diff --git a/changelog/10839.deprecation.rst b/changelog/10839.deprecation.rst index c0628191663..78ad4e118e4 100644 --- a/changelog/10839.deprecation.rst +++ b/changelog/10839.deprecation.rst @@ -1 +1 @@ -Synchronous tests that request an asynchronous fixture with ``autouse=True`` will now give a DeprecationWarning. +Synchronous tests that request an asynchronous fixture will now give a DeprecationWarning. This will introduce warnings in several pytest plugins that handle async tests/fixtures and for some users with custom setups. For guidance on how to manage this see :ref:`sync-test-async-fixture`. diff --git a/changelog/10839.improvement.rst b/changelog/10839.improvement.rst deleted file mode 100644 index 0a382053c85..00000000000 --- a/changelog/10839.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Synchronous tests that request asynchronous fixtures will now error, instead of silently accepting an unawaited coroutine object as the fixture value. diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index e55f0d71c2e..b384f01dfab 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -15,6 +15,61 @@ Below is a complete list of all pytest features which are considered deprecated. :class:`~pytest.PytestWarning` or subclasses, which can be filtered using :ref:`standard warning filters `. +.. _sync-test-async-fixture: + +sync test depending on async fixture +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. deprecated:: 8.4 + +Pytest has for a long time given an error when encountering an asynchronous test function, prompting the user to install +a plugin that can handle it. It has not given any errors if you have an asynchronous fixture that's depended on by a +synchronous test. This is a problem even if you do have a plugin installed for handling async tests, as they may require +special decorators for async fixtures to be handled, and some may not robustly handle if a user accidentally requests an +async fixture from their sync tests. Fixture values being cached can make this even more unintuitive, where everything will +"work" if the fixture is first requested by an async test, and then requested by a synchronous test. + +Unfortunately there is no 100% reliable method of identifying when a user has made a mistake, versus when they expect an +unawaited object from their fixture that they will handle - either on their own, or by a plugin. To suppress this warning +when you in fact did intend to handle this you can wrap your async fixture in a synchronous fixture: + +.. code-block:: python + + import asyncio + import pytest + + + @pytest.fixture + async def unawaited_fixture(): + return 1 + + + def test_foo(unawaited_fixture): + assert 1 == asyncio.run(unawaited_fixture) + +should be changed to + + +.. code-block:: python + + import asyncio + import pytest + + + @pytest.fixture + def unawaited_fixture(): + async def inner_fixture(): + return 1 + + return inner_fixture() + + + def test_foo(unawaited_fixture): + assert 1 == asyncio.run(unawaited_fixture) + +If a user has an async fixture with ``autouse=True`` in their ``conftest.py``, or in a file where they also have synchronous tests, they will also get this warning. We strongly recommend against this practice, and they should restructure their testing infrastructure so the fixture is synchronous or to separate the fixture from their synchronous tests. Plugins that handle async may want to introduce helpers to make that easier in scenarios where that might be wanted, e.g. if setting up a database in an asynchronous way, or the user may opt to make their test async even though it might not strictly need to be. + + .. _import-or-skip-import-error: ``pytest.importorskip`` default behavior regarding :class:`ImportError` diff --git a/pyproject.toml b/pyproject.toml index caeb4bf7f83..b023f788563 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -308,7 +308,7 @@ disable = [ ] [tool.codespell] -ignore-words-list = "afile,asser,assertio,feld,hove,ned,noes,notin,paramete,parth,socio-economic,tesults,varius,wil" +ignore-words-list = "afile,asend,asser,assertio,feld,hove,ned,noes,notin,paramete,parth,socio-economic,tesults,varius,wil" skip = "*/plugin_list.rst" write-changes = true diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index da6625fb7e1..4b45489cd96 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -609,23 +609,26 @@ def _get_active_fixturedef( if fixturedef._autouse: warnings.warn( PytestRemovedIn9Warning( - "Sync test requested an async fixture with autouse=True. " + f"Sync test {self._pyfuncitem.name!r} requested async fixture " + f"{argname!r} with autouse=True. " "If you intended to use the fixture you may want to make the " - "test asynchronous. If you did not intend to use it you should " + "test asynchronous or the fixture synchronous. " + "If you did not intend to use it you should " "restructure your test setup. " "This will turn into an error in pytest 9." ), stacklevel=3, ) else: - raise FixtureLookupError( - argname, - self, - ( - "ERROR: Sync test requested async fixture. " + warnings.warn( + PytestRemovedIn9Warning( + f"Sync test {self._pyfuncitem.name!r} requested async fixture " + f"{argname!r}. " "You may want to make the test asynchronous and run it with " - "a suitable async framework test plugin." + "a suitable async framework test plugin, or make the fixture synchronous. " + "This will turn into an error in pytest 9." ), + stacklevel=3, ) # Prepare a SubRequest object for calling the fixture. diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 0437cae4047..699ad4797b9 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1296,21 +1296,26 @@ async def async_fixture(): ... def test_foo(async_fixture): - ... + # suppress unawaited coroutine warning + try: + async_fixture.send(None) + except StopIteration: + pass """ ) result = pytester.runpytest() result.stdout.fnmatch_lines( [ ( - "*ERROR: Sync test requested async fixture. " + "*Sync test 'test_foo' requested async fixture " + "'async_fixture'. " "You may want to make the test asynchronous and run it with " - "a suitable async framework test plugin.*" + "a suitable async framework test plugin, or make the fixture synchronous. " + "This will turn into an error in pytest 9." ), - "*ERROR test_sync.py::test_foo*", ] ) - result.assert_outcomes(errors=1) + result.assert_outcomes(passed=1, warnings=1) def test_error_on_sync_test_async_fixture_gen(pytester: Pytester) -> None: @@ -1323,21 +1328,26 @@ async def async_fixture(): yield def test_foo(async_fixture): - ... + # suppress unawaited coroutine warning + try: + async_fixture.asend(None) + except StopIteration: + pass """ ) result = pytester.runpytest() result.stdout.fnmatch_lines( [ ( - "*ERROR: Sync test requested async fixture. " + "*Sync test 'test_foo' requested async fixture " + "'async_fixture'. " "You may want to make the test asynchronous and run it with " - "a suitable async framework test plugin.*" + "a suitable async framework test plugin, or make the fixture synchronous. " + "This will turn into an error in pytest 9." ), - "*ERROR test_sync.py::test_foo*", ] ) - result.assert_outcomes(errors=1) + result.assert_outcomes(passed=1, warnings=1) def test_warning_on_sync_test_async_autouse_fixture(pytester: Pytester) -> None: @@ -1362,11 +1372,11 @@ def test_foo(async_fixture): result.stdout.fnmatch_lines( [ ( - "*Sync test requested an async fixture with autouse=True. " - "If you intended to use the fixture you may want to make the " - "test asynchronous. If you did not intend to use it you should " - "restructure your test setup. " - "This will turn into an error in pytest 9.*" + "*Sync test 'test_foo' requested async fixture " + "'async_fixture' with autouse=True. " + "You may want to make the test asynchronous and run it with " + "a suitable async framework test plugin, or make the fixture synchronous. " + "This will turn into an error in pytest 9." ), ] ) From 0de5302bfde78747ca6b4d468d7d60658f43307c Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 6 Nov 2024 14:12:12 +0100 Subject: [PATCH 120/445] fix test --- testing/acceptance_test.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 699ad4797b9..a7a9afedbc0 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1286,7 +1286,7 @@ def test_3(): result.assert_outcomes(failed=3) -def test_error_on_sync_test_async_fixture(pytester: Pytester) -> None: +def test_warning_on_sync_test_async_fixture(pytester: Pytester) -> None: pytester.makepyfile( test_sync=""" import pytest @@ -1318,7 +1318,7 @@ def test_foo(async_fixture): result.assert_outcomes(passed=1, warnings=1) -def test_error_on_sync_test_async_fixture_gen(pytester: Pytester) -> None: +def test_warning_on_sync_test_async_fixture_gen(pytester: Pytester) -> None: pytester.makepyfile( test_sync=""" import pytest @@ -1374,13 +1374,15 @@ def test_foo(async_fixture): ( "*Sync test 'test_foo' requested async fixture " "'async_fixture' with autouse=True. " - "You may want to make the test asynchronous and run it with " - "a suitable async framework test plugin, or make the fixture synchronous. " + "If you intended to use the fixture you may want to make the " + "test asynchronous or the fixture synchronous. " + "If you did not intend to use it you should " + "restructure your test setup. " "This will turn into an error in pytest 9." ), ] ) - result.assert_outcomes(passed=1) + result.assert_outcomes(passed=1, warnings=1) def test_pdb_can_be_rewritten(pytester: Pytester) -> None: From c85faf05d9db7c4bc2c24cd855b058d856efe8a2 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 6 Nov 2024 13:30:49 -0300 Subject: [PATCH 121/445] Rename changelog entries to 'breaking' (#12942) Follow up to https://github.com/pytest-dev/pytest/pull/12346. --- changelog/{11372.improvement.rst => 11372.breaking.rst} | 0 changelog/{12346.misc.rst => 12346.breaking.rst} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename changelog/{11372.improvement.rst => 11372.breaking.rst} (100%) rename changelog/{12346.misc.rst => 12346.breaking.rst} (100%) diff --git a/changelog/11372.improvement.rst b/changelog/11372.breaking.rst similarity index 100% rename from changelog/11372.improvement.rst rename to changelog/11372.breaking.rst diff --git a/changelog/12346.misc.rst b/changelog/12346.breaking.rst similarity index 100% rename from changelog/12346.misc.rst rename to changelog/12346.breaking.rst From 48bcb05e1d87e5128b94285b4a00ecff8e00f778 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 23:01:37 +0000 Subject: [PATCH 122/445] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.9 → v0.7.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.9...v0.7.2) - [github.com/adamchainz/blacken-docs: 1.19.0 → 1.19.1](https://github.com/adamchainz/blacken-docs/compare/1.19.0...1.19.1) - [github.com/pre-commit/mirrors-mypy: v1.11.2 → v1.13.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.11.2...v1.13.0) - [github.com/tox-dev/pyproject-fmt: 2.3.1 → v2.5.0](https://github.com/tox-dev/pyproject-fmt/compare/2.3.1...v2.5.0) - [github.com/asottile/pyupgrade: v3.18.0 → v3.19.0](https://github.com/asottile/pyupgrade/compare/v3.18.0...v3.19.0) [mypy] Remove useless noqa, add noqa for new false positives Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) --- .pre-commit-config.yaml | 11 ++++++----- pyproject.toml | 3 ++- src/_pytest/_io/pprint.py | 6 +++--- src/_pytest/capture.py | 6 ++++-- testing/test_runner.py | 4 ++-- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 096228acf9f..04971cf9fb2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.9" + rev: "v0.7.2" hooks: - id: ruff args: ["--fix"] @@ -12,7 +12,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/adamchainz/blacken-docs - rev: 1.19.0 + rev: 1.19.1 hooks: - id: blacken-docs additional_dependencies: [black==24.1.1] @@ -28,7 +28,7 @@ repos: hooks: - id: python-use-type-annotations - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.2 + rev: v1.13.0 hooks: - id: mypy files: ^(src/|testing/|scripts/) @@ -44,13 +44,13 @@ repos: # on <3.11 - exceptiongroup>=1.0.0rc8 - repo: https://github.com/tox-dev/pyproject-fmt - rev: "2.3.1" + rev: "v2.5.0" hooks: - id: pyproject-fmt # https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version additional_dependencies: ["tox>=4.9"] - repo: https://github.com/asottile/pyupgrade - rev: v3.18.0 + rev: v3.19.0 hooks: - id: pyupgrade stages: [manual] @@ -62,6 +62,7 @@ repos: language: system types: [python] args: ["-rn", "-sn", "--fail-on=I"] + require_serial: true stages: [manual] - id: rst name: rst diff --git a/pyproject.toml b/pyproject.toml index caeb4bf7f83..2f3a17e04b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ dependencies = [ "exceptiongroup>=1.0.0rc8; python_version<'3.11'", "iniconfig", "packaging", - "pluggy<2,>=1.5", + "pluggy>=1.5,<2", "tomli>=1; python_version<'3.11'", ] optional-dependencies.dev = [ @@ -275,6 +275,7 @@ disable = [ "too-many-lines", "too-many-locals", "too-many-nested-blocks", + "too-many-positional-arguments", "too-many-public-methods", "too-many-return-statements", # disabled in ruff "too-many-statements", # disabled in ruff diff --git a/src/_pytest/_io/pprint.py b/src/_pytest/_io/pprint.py index fc29989be0b..7a6433d9128 100644 --- a/src/_pytest/_io/pprint.py +++ b/src/_pytest/_io/pprint.py @@ -111,15 +111,15 @@ def _format( p(self, object, stream, indent, allowance, context, level + 1) context.remove(objid) elif ( - _dataclasses.is_dataclass(object) # type:ignore[unreachable] + _dataclasses.is_dataclass(object) and not isinstance(object, type) - and object.__dataclass_params__.repr + and object.__dataclass_params__.repr # type:ignore[attr-defined] and # Check dataclass has generated repr method. hasattr(object.__repr__, "__wrapped__") and "__create_fn__" in object.__repr__.__wrapped__.__qualname__ ): - context.add(objid) # type:ignore[unreachable] + context.add(objid) self._pprint_dataclass( object, stream, indent, allowance, context, level + 1 ) diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index 506c0b3d287..2ac3b6bbc7f 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -15,6 +15,7 @@ from typing import Any from typing import AnyStr from typing import BinaryIO +from typing import cast from typing import Final from typing import final from typing import Generator @@ -177,7 +178,8 @@ def name(self) -> str: def mode(self) -> str: # TextIOWrapper doesn't expose a mode, but at least some of our # tests check it. - return self.buffer.mode.replace("b", "") + assert hasattr(self.buffer, "mode") + return cast(str, self.buffer.mode.replace("b", "")) class CaptureIO(io.TextIOWrapper): @@ -550,7 +552,7 @@ def snap(self) -> bytes: res = self.tmpfile.buffer.read() self.tmpfile.seek(0) self.tmpfile.truncate() - return res + return res # type: ignore[return-value] def writeorg(self, data: bytes) -> None: """Write to original file descriptor.""" diff --git a/testing/test_runner.py b/testing/test_runner.py index 0d9facdcd71..0245438a47d 100644 --- a/testing/test_runner.py +++ b/testing/test_runner.py @@ -137,8 +137,8 @@ def raiser(exc): ss.teardown_exact(None) mod, func = e.value.exceptions assert isinstance(mod, KeyError) - assert isinstance(func.exceptions[0], TypeError) # type: ignore - assert isinstance(func.exceptions[1], ValueError) # type: ignore + assert isinstance(func.exceptions[0], TypeError) + assert isinstance(func.exceptions[1], ValueError) def test_cached_exception_doesnt_get_longer(self, pytester: Pytester) -> None: """Regression test for #12204 (the "BTW" case).""" From 227b4602eedc9988557c83a3ebcf01b08d79f2fb Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 29 Oct 2024 10:08:27 +0100 Subject: [PATCH 123/445] Upgrade pylint version, activate all extensions --- .pre-commit-config.yaml | 2 +- pyproject.toml | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 04971cf9fb2..b8e7053e1c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -61,7 +61,7 @@ repos: entry: pylint language: system types: [python] - args: ["-rn", "-sn", "--fail-on=I"] + args: ["-rn", "-sn", "--fail-on=I", "--enable-all-extentions"] require_serial: true stages: [manual] - id: rst diff --git a/pyproject.toml b/pyproject.toml index 2f3a17e04b8..020997e7869 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -200,7 +200,9 @@ disable = [ "arguments-renamed", "assigning-non-slot", "attribute-defined-outside-init", + "bad-builtin", "bad-classmethod-argument", + "bad-dunder-name", "bad-mcs-method-argument", "broad-exception-caught", "broad-exception-raised", @@ -209,25 +211,41 @@ disable = [ "comparison-with-callable", "comparison-with-itself", # PLR0124 from ruff "condition-evals-to-constant", + "consider-alternative-union-syntax", + "confusing-consecutive-elif", + "consider-using-any-or-all", + "consider-using-assignment-expr", "consider-using-dict-items", "consider-using-from-import", "consider-using-f-string", "consider-using-in", + "consider-using-namedtuple-or-dataclass", "consider-using-ternary", + "consider-using-tuple", "consider-using-with", "consider-using-from-import", # not activated by default, PLR0402 disabled in ruff + "consider-ternary-expression", "cyclic-import", + "differing-param-doc", + "docstring-first-line-empty", + "deprecated-argument", + "deprecated-attribute", + "deprecated-class", + "deprecated-typing-alias", + "dict-init-mutate", "disallowed-name", # foo / bar are used often in tests "duplicate-code", "else-if-used", # not activated by default, PLR5501 disabled in ruff "empty-comment", # not activated by default, PLR2044 disabled in ruff "eval-used", + "eq-without-hash", "exec-used", "expression-not-assigned", "fixme", "global-statement", # PLW0603 disabled in ruff "import-error", "import-outside-toplevel", + "import-private-name", "inconsistent-return-statements", "invalid-bool-returned", "invalid-name", @@ -238,8 +256,12 @@ disable = [ "magic-value-comparison", # not activated by default, PLR2004 disabled in ruff "method-hidden", "missing-docstring", + "missing-param-doc", + "missing-raises-doc", "missing-timeout", + "missing-type-doc", "misplaced-bare-raise", # PLE0704 from ruff + "misplaced-comparison-constant", "multiple-statements", # multiple-statements-on-one-line-colon (E701) from ruff "no-else-break", "no-else-continue", @@ -248,6 +270,7 @@ disable = [ "no-member", "no-name-in-module", "no-self-argument", + "no-self-use", "not-an-iterable", "not-callable", "pointless-exception-statement", # https://github.com/pytest-dev/pytest/pull/12379 @@ -260,12 +283,14 @@ disable = [ "redefined-builtin", "redefined-loop-name", # PLW2901 disabled in ruff "redefined-outer-name", + "redefined-variable-type", "reimported", "simplifiable-condition", "simplifiable-if-expression", "singleton-comparison", "superfluous-parens", "super-init-not-called", + "too-complex", "too-few-public-methods", "too-many-ancestors", "too-many-arguments", # disabled in ruff @@ -279,6 +304,7 @@ disable = [ "too-many-public-methods", "too-many-return-statements", # disabled in ruff "too-many-statements", # disabled in ruff + "too-many-try-statements", "try-except-raise", "typevar-name-incorrect-variance", # PLC0105 disabled in ruff "unbalanced-tuple-unpacking", @@ -300,10 +326,12 @@ disable = [ "use-dict-literal", "use-implicit-booleaness-not-comparison", "use-implicit-booleaness-not-len", + "use-set-for-membership", "useless-else-on-loop", # PLC0414 disabled in ruff "useless-import-alias", "useless-return", "using-constant-test", + "while-used", "wrong-import-order", # handled by isort / ruff "wrong-import-position", # handled by isort / ruff ] From 607b9f71bb666f0f748b09b70dc2b496c706edd2 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 29 Oct 2024 10:09:09 +0100 Subject: [PATCH 124/445] [pylint dict-init-mutate] Initialize a dict right off for speed --- pyproject.toml | 1 - src/_pytest/junitxml.py | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 020997e7869..ad0bca4374b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -232,7 +232,6 @@ disable = [ "deprecated-attribute", "deprecated-class", "deprecated-typing-alias", - "dict-init-mutate", "disallowed-name", # foo / bar are used often in tests "duplicate-code", "else-if-used", # not activated by default, PLR5501 disabled in ruff diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py index 3a2cb59a6c1..efe6f489b48 100644 --- a/src/_pytest/junitxml.py +++ b/src/_pytest/junitxml.py @@ -74,10 +74,10 @@ def merge_family(left, right) -> None: left.update(result) -families = {} -families["_base"] = {"testcase": ["classname", "name"]} -families["_base_legacy"] = {"testcase": ["file", "line", "url"]} - +families = { # pylint: disable=dict-init-mutate + "_base": {"testcase": ["classname", "name"]}, + "_base_legacy": {"testcase": ["file", "line", "url"]}, +} # xUnit 1.x inherits legacy attributes. families["xunit1"] = families["_base"].copy() merge_family(families["xunit1"], families["_base_legacy"]) From de56152bf57d5b450593b8f01c231428dec6e23c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 10 Nov 2024 08:39:36 +0000 Subject: [PATCH 125/445] [automated] Update plugin list (#12950) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 78 +++++++++++++++++++------------- 1 file changed, 47 insertions(+), 31 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 50206c34150..ecd96b89967 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,15 +27,15 @@ please refer to `the update script =8.3 - :pypi:`logassert` Simple but powerful assertion and verification of logged lines. May 20, 2022 5 - Production/Stable N/A + :pypi:`databricks-labs-pytester` Python Testing for Databricks Nov 04, 2024 4 - Beta pytest>=8.3 + :pypi:`logassert` Simple but powerful assertion and verification of logged lines. Nov 08, 2024 5 - Production/Stable N/A :pypi:`logot` Test whether your code is logging correctly 🪵 Mar 23, 2024 5 - Production/Stable pytest<9,>=7; extra == "pytest" :pypi:`nuts` Network Unit Testing System Jul 19, 2024 N/A pytest<8,>=7 :pypi:`pytest-abq` Pytest integration for the ABQ universal test runner. Apr 07, 2023 N/A N/A @@ -157,7 +157,7 @@ This list contains 1538 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Oct 22, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Nov 05, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -246,7 +246,7 @@ This list contains 1538 plugins. :pypi:`pytest-cldf` Easy quality control for CLDF datasets using pytest Nov 07, 2022 N/A pytest (>=3.6) :pypi:`pytest-cleanslate` Collects and executes pytest tests separately Sep 04, 2024 N/A pytest :pypi:`pytest_cleanup` Automated, comprehensive and well-organised pytest test cases. Jan 28, 2020 N/A N/A - :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Sep 14, 2024 5 - Production/Stable N/A + :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Nov 08, 2024 5 - Production/Stable N/A :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Oct 08, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-click` Pytest plugin for Click Feb 11, 2022 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-cli-fixtures` Automatically register fixtures for custom CLI arguments Jul 28, 2022 N/A pytest (~=7.0) @@ -571,7 +571,7 @@ This list contains 1538 plugins. :pypi:`pytest-fixtures` Common fixtures for pytest May 01, 2019 5 - Production/Stable N/A :pypi:`pytest-fixture-tools` Plugin for pytest which provides tools for fixtures Aug 15, 2024 6 - Mature pytest :pypi:`pytest-fixture-typecheck` A pytest plugin to assert type annotations at runtime. Aug 24, 2021 N/A pytest - :pypi:`pytest-flake8` pytest plugin to check FLAKE8 requirements Jul 21, 2024 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-flake8` pytest plugin to check FLAKE8 requirements Nov 09, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-flake8-path` A pytest fixture for testing flake8 plugins. Oct 25, 2024 5 - Production/Stable pytest :pypi:`pytest-flake8-v2` pytest plugin to check FLAKE8 requirements Mar 01, 2022 5 - Production/Stable pytest (>=7.0) :pypi:`pytest-flakefinder` Runs tests multiple times to expose flakiness. Oct 26, 2022 4 - Beta pytest (>=2.7.1) @@ -601,7 +601,7 @@ This list contains 1538 plugins. :pypi:`pytest-frozen-uuids` Deterministically frozen UUID's for your tests Apr 17, 2022 N/A pytest (>=3.0) :pypi:`pytest-func-cov` Pytest plugin for measuring function coverage Apr 15, 2021 3 - Alpha pytest (>=5) :pypi:`pytest-funparam` An alternative way to parametrize test cases. Dec 02, 2021 4 - Beta pytest >=4.6.0 - :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Oct 11, 2024 N/A pytest + :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Nov 07, 2024 N/A pytest :pypi:`pytest-fxa` pytest plugin for Firefox Accounts Aug 28, 2018 5 - Production/Stable N/A :pypi:`pytest-fxa-mte` pytest plugin for Firefox Accounts Oct 02, 2024 5 - Production/Stable N/A :pypi:`pytest-fxtest` Oct 27, 2020 N/A N/A @@ -616,7 +616,7 @@ This list contains 1538 plugins. :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Jul 08, 2024 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Nov 07, 2024 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -660,7 +660,7 @@ This list contains 1538 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Nov 01, 2024 3 - Alpha pytest==8.3.3 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Nov 09, 2024 3 - Alpha pytest==8.3.3 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -730,6 +730,7 @@ This list contains 1538 plugins. :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Sep 25, 2024 4 - Beta pytest :pypi:`pytest-invenio` Pytest fixtures for Invenio. Jun 27, 2024 5 - Production/Stable pytest<7.2.0,>=6 :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) + :pypi:`pytest-iovis` A Pytest plugin to enable Jupyter Notebook testing with Papermill Nov 06, 2024 4 - Beta pytest>=7.1.0 :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A :pypi:`pytest-ipywidgets` Oct 28, 2024 N/A pytest @@ -818,7 +819,7 @@ This list contains 1538 plugins. :pypi:`pytest-logger` Plugin configuring handlers for loggers from Python logging module. Mar 10, 2024 5 - Production/Stable pytest (>=3.2) :pypi:`pytest-logging` Configures logging and allows tweaking the log level with a py.test flag Nov 04, 2015 4 - Beta N/A :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-logikal` Common testing environment Oct 28, 2024 5 - Production/Stable pytest==8.3.3 + :pypi:`pytest-logikal` Common testing environment Nov 09, 2024 5 - Production/Stable pytest==8.3.3 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Sep 30, 2024 4 - Beta pytest>=8.2.2 :pypi:`pytest-loguru` Pytest Loguru Mar 20, 2024 5 - Production/Stable pytest; extra == "test" @@ -859,7 +860,7 @@ This list contains 1538 plugins. :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A :pypi:`pytest-metadata` pytest plugin for test session metadata Feb 12, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-metrics` Custom metrics report for pytest Apr 04, 2020 N/A pytest - :pypi:`pytest-mh` Pytest multihost plugin Sep 19, 2024 N/A pytest + :pypi:`pytest-mh` Pytest multihost plugin Nov 04, 2024 N/A pytest :pypi:`pytest-mimesis` Mimesis integration with the pytest test runner Mar 21, 2020 5 - Production/Stable pytest (>=4.2) :pypi:`pytest-minecraft` A pytest plugin for running tests against Minecraft releases Apr 06, 2022 N/A pytest (>=6.0.1) :pypi:`pytest-mini` A plugin to test mp Feb 06, 2023 N/A pytest (>=7.2.0,<8.0.0) @@ -1006,7 +1007,7 @@ This list contains 1538 plugins. :pypi:`pytest-pg` A tiny plugin for pytest which runs PostgreSQL in Docker May 21, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-pgsql` Pytest plugins and helpers for tests using a Postgres database. May 13, 2020 5 - Production/Stable pytest (>=3.0.0) :pypi:`pytest-phmdoctest` pytest plugin to test Python examples in Markdown using phmdoctest. Apr 15, 2022 4 - Beta pytest (>=5.4.3) - :pypi:`pytest-picked` Run the tests related to the changed files Jul 27, 2023 N/A pytest (>=3.7.0) + :pypi:`pytest-picked` Run the tests related to the changed files Nov 06, 2024 N/A pytest>=3.7.0 :pypi:`pytest-pigeonhole` Jun 25, 2018 5 - Production/Stable pytest (>=3.4) :pypi:`pytest-pikachu` Show surprise when tests are passing Aug 05, 2021 5 - Production/Stable pytest :pypi:`pytest-pilot` Slice in your test base thanks to powerful markers. Oct 09, 2020 5 - Production/Stable N/A @@ -1224,7 +1225,7 @@ This list contains 1538 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Nov 01, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Nov 09, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1235,7 +1236,7 @@ This list contains 1538 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Nov 01, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Nov 09, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1281,6 +1282,7 @@ This list contains 1538 plugins. :pypi:`pytest-smartcollect` A plugin for collecting tests that touch changed code Oct 04, 2018 N/A pytest (>=3.5.0) :pypi:`pytest-smartcov` Smart coverage plugin for pytest. Sep 30, 2017 3 - Alpha N/A :pypi:`pytest-smell` Automated bad smell detection tool for Pytest Jun 26, 2022 N/A N/A + :pypi:`pytest-smoke` pytest plugin for supporting smoke testing Nov 07, 2024 4 - Beta pytest<9,>=7.0.0 :pypi:`pytest-smtp` Send email with pytest execution result Feb 20, 2021 N/A pytest :pypi:`pytest-smtp4dev` Plugin for smtp4dev API Jun 27, 2023 5 - Production/Stable N/A :pypi:`pytest-smtpd` An SMTP server for testing built on aiosmtpd May 15, 2023 N/A pytest @@ -1358,7 +1360,7 @@ This list contains 1538 plugins. :pypi:`pytest-symbols` pytest-symbols is a pytest plugin that adds support for passing test environment symbols into pytest tests. Nov 20, 2017 3 - Alpha N/A :pypi:`pytest-system-statistics` Pytest plugin to track and report system usage statistics Feb 16, 2022 5 - Production/Stable pytest (>=6.0.0) :pypi:`pytest-system-test-plugin` Pyst - Pytest System-Test Plugin Feb 03, 2022 N/A N/A - :pypi:`pytest_tagging` a pytest plugin to tag tests Aug 31, 2024 N/A pytest<8.0.0,>=7.1.3 + :pypi:`pytest_tagging` a pytest plugin to tag tests Nov 08, 2024 N/A pytest>=7.1.3 :pypi:`pytest-takeltest` Fixtures for ansible, testinfra and molecule Sep 07, 2024 N/A N/A :pypi:`pytest-talisker` Nov 28, 2021 N/A N/A :pypi:`pytest-tally` A Pytest plugin to generate realtime summary stats, and display them in-console using a text-based dashboard. May 22, 2023 4 - Beta pytest (>=6.2.5) @@ -1578,14 +1580,14 @@ This list contains 1538 plugins. :pypi:`databricks-labs-pytester` - *last release*: Oct 11, 2024, + *last release*: Nov 04, 2024, *status*: 4 - Beta, *requires*: pytest>=8.3 Python Testing for Databricks :pypi:`logassert` - *last release*: May 20, 2022, + *last release*: Nov 08, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -2439,7 +2441,7 @@ This list contains 1538 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Oct 22, 2024, + *last release*: Nov 05, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -3062,7 +3064,7 @@ This list contains 1538 plugins. Automated, comprehensive and well-organised pytest test cases. :pypi:`pytest-cleanuptotal` - *last release*: Sep 14, 2024, + *last release*: Nov 08, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -5337,7 +5339,7 @@ This list contains 1538 plugins. A pytest plugin to assert type annotations at runtime. :pypi:`pytest-flake8` - *last release*: Jul 21, 2024, + *last release*: Nov 09, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 @@ -5547,7 +5549,7 @@ This list contains 1538 plugins. An alternative way to parametrize test cases. :pypi:`pytest-fv` - *last release*: Oct 11, 2024, + *last release*: Nov 07, 2024, *status*: N/A, *requires*: pytest @@ -5652,7 +5654,7 @@ This list contains 1538 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Jul 08, 2024, + *last release*: Nov 07, 2024, *status*: N/A, *requires*: pytest>=3.6 @@ -5960,7 +5962,7 @@ This list contains 1538 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Nov 01, 2024, + *last release*: Nov 09, 2024, *status*: 3 - Alpha, *requires*: pytest==8.3.3 @@ -6449,6 +6451,13 @@ This list contains 1538 plugins. Run tests covering a specific file or changeset + :pypi:`pytest-iovis` + *last release*: Nov 06, 2024, + *status*: 4 - Beta, + *requires*: pytest>=7.1.0 + + A Pytest plugin to enable Jupyter Notebook testing with Papermill + :pypi:`pytest-ipdb` *last release*: Mar 20, 2013, *status*: 2 - Pre-Alpha, @@ -7066,7 +7075,7 @@ This list contains 1538 plugins. :pypi:`pytest-logikal` - *last release*: Oct 28, 2024, + *last release*: Nov 09, 2024, *status*: 5 - Production/Stable, *requires*: pytest==8.3.3 @@ -7353,7 +7362,7 @@ This list contains 1538 plugins. Custom metrics report for pytest :pypi:`pytest-mh` - *last release*: Sep 19, 2024, + *last release*: Nov 04, 2024, *status*: N/A, *requires*: pytest @@ -8382,9 +8391,9 @@ This list contains 1538 plugins. pytest plugin to test Python examples in Markdown using phmdoctest. :pypi:`pytest-picked` - *last release*: Jul 27, 2023, + *last release*: Nov 06, 2024, *status*: N/A, - *requires*: pytest (>=3.7.0) + *requires*: pytest>=3.7.0 Run the tests related to the changed files @@ -9908,7 +9917,7 @@ This list contains 1538 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Nov 01, 2024, + *last release*: Nov 09, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9985,7 +9994,7 @@ This list contains 1538 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Nov 01, 2024, + *last release*: Nov 09, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10306,6 +10315,13 @@ This list contains 1538 plugins. Automated bad smell detection tool for Pytest + :pypi:`pytest-smoke` + *last release*: Nov 07, 2024, + *status*: 4 - Beta, + *requires*: pytest<9,>=7.0.0 + + pytest plugin for supporting smoke testing + :pypi:`pytest-smtp` *last release*: Feb 20, 2021, *status*: N/A, @@ -10846,9 +10862,9 @@ This list contains 1538 plugins. Pyst - Pytest System-Test Plugin :pypi:`pytest_tagging` - *last release*: Aug 31, 2024, + *last release*: Nov 08, 2024, *status*: N/A, - *requires*: pytest<8.0.0,>=7.1.3 + *requires*: pytest>=7.1.3 a pytest plugin to tag tests From 5f29c3e272557d3fc5c1c0eb68b76cfc41bded0b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 07:39:17 +0100 Subject: [PATCH 126/445] build(deps): Bump django in /testing/plugins_integration (#12951) Bumps [django](https://github.com/django/django) from 5.1.2 to 5.1.3. - [Commits](https://github.com/django/django/compare/5.1.2...5.1.3) --- updated-dependencies: - dependency-name: django dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index ef01747f2fd..32992dc2589 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,5 +1,5 @@ anyio[curio,trio]==4.6.2.post1 -django==5.1.2 +django==5.1.3 pytest-asyncio==0.24.0 pytest-bdd==7.3.0 pytest-cov==6.0.0 From ea0fa639445ae08616edd2c15189a1a76168f018 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 08:39:14 +0100 Subject: [PATCH 127/445] build(deps): Bump pypa/gh-action-pypi-publish from 1.10.3 to 1.12.2 (#12953) Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.3 to 1.12.2. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.10.3...v1.12.2) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 974fe4947db..3d3cb7534a4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -54,7 +54,7 @@ jobs: path: dist - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@v1.10.3 + uses: pypa/gh-action-pypi-publish@v1.12.2 with: attestations: true From 1891fedbb1e37c9e61cbdcdaf2d05f5493a24d2c Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 6 Nov 2024 13:30:49 -0300 Subject: [PATCH 128/445] Rename changelog entries to 'breaking' (#12942) Follow up to https://github.com/pytest-dev/pytest/pull/12346. --- changelog/{11372.improvement.rst => 11372.breaking.rst} | 0 changelog/{12346.misc.rst => 12346.breaking.rst} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename changelog/{11372.improvement.rst => 11372.breaking.rst} (100%) rename changelog/{12346.misc.rst => 12346.breaking.rst} (100%) diff --git a/changelog/11372.improvement.rst b/changelog/11372.breaking.rst similarity index 100% rename from changelog/11372.improvement.rst rename to changelog/11372.breaking.rst diff --git a/changelog/12346.misc.rst b/changelog/12346.breaking.rst similarity index 100% rename from changelog/12346.misc.rst rename to changelog/12346.breaking.rst From 6b9de2ab2e52181102bdaf9acbaf7815eb078ed2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 23:01:37 +0000 Subject: [PATCH 129/445] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.6.9 → v0.7.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.9...v0.7.2) - [github.com/adamchainz/blacken-docs: 1.19.0 → 1.19.1](https://github.com/adamchainz/blacken-docs/compare/1.19.0...1.19.1) - [github.com/pre-commit/mirrors-mypy: v1.11.2 → v1.13.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.11.2...v1.13.0) - [github.com/tox-dev/pyproject-fmt: 2.3.1 → v2.5.0](https://github.com/tox-dev/pyproject-fmt/compare/2.3.1...v2.5.0) - [github.com/asottile/pyupgrade: v3.18.0 → v3.19.0](https://github.com/asottile/pyupgrade/compare/v3.18.0...v3.19.0) [mypy] Remove useless noqa, add noqa for new false positives Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) --- .pre-commit-config.yaml | 11 ++++++----- pyproject.toml | 3 ++- src/_pytest/_io/pprint.py | 6 +++--- src/_pytest/capture.py | 6 ++++-- testing/test_runner.py | 4 ++-- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 096228acf9f..04971cf9fb2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.9" + rev: "v0.7.2" hooks: - id: ruff args: ["--fix"] @@ -12,7 +12,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/adamchainz/blacken-docs - rev: 1.19.0 + rev: 1.19.1 hooks: - id: blacken-docs additional_dependencies: [black==24.1.1] @@ -28,7 +28,7 @@ repos: hooks: - id: python-use-type-annotations - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.2 + rev: v1.13.0 hooks: - id: mypy files: ^(src/|testing/|scripts/) @@ -44,13 +44,13 @@ repos: # on <3.11 - exceptiongroup>=1.0.0rc8 - repo: https://github.com/tox-dev/pyproject-fmt - rev: "2.3.1" + rev: "v2.5.0" hooks: - id: pyproject-fmt # https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version additional_dependencies: ["tox>=4.9"] - repo: https://github.com/asottile/pyupgrade - rev: v3.18.0 + rev: v3.19.0 hooks: - id: pyupgrade stages: [manual] @@ -62,6 +62,7 @@ repos: language: system types: [python] args: ["-rn", "-sn", "--fail-on=I"] + require_serial: true stages: [manual] - id: rst name: rst diff --git a/pyproject.toml b/pyproject.toml index b023f788563..da47e4b045e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ dependencies = [ "exceptiongroup>=1.0.0rc8; python_version<'3.11'", "iniconfig", "packaging", - "pluggy<2,>=1.5", + "pluggy>=1.5,<2", "tomli>=1; python_version<'3.11'", ] optional-dependencies.dev = [ @@ -275,6 +275,7 @@ disable = [ "too-many-lines", "too-many-locals", "too-many-nested-blocks", + "too-many-positional-arguments", "too-many-public-methods", "too-many-return-statements", # disabled in ruff "too-many-statements", # disabled in ruff diff --git a/src/_pytest/_io/pprint.py b/src/_pytest/_io/pprint.py index fc29989be0b..7a6433d9128 100644 --- a/src/_pytest/_io/pprint.py +++ b/src/_pytest/_io/pprint.py @@ -111,15 +111,15 @@ def _format( p(self, object, stream, indent, allowance, context, level + 1) context.remove(objid) elif ( - _dataclasses.is_dataclass(object) # type:ignore[unreachable] + _dataclasses.is_dataclass(object) and not isinstance(object, type) - and object.__dataclass_params__.repr + and object.__dataclass_params__.repr # type:ignore[attr-defined] and # Check dataclass has generated repr method. hasattr(object.__repr__, "__wrapped__") and "__create_fn__" in object.__repr__.__wrapped__.__qualname__ ): - context.add(objid) # type:ignore[unreachable] + context.add(objid) self._pprint_dataclass( object, stream, indent, allowance, context, level + 1 ) diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index 506c0b3d287..2ac3b6bbc7f 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -15,6 +15,7 @@ from typing import Any from typing import AnyStr from typing import BinaryIO +from typing import cast from typing import Final from typing import final from typing import Generator @@ -177,7 +178,8 @@ def name(self) -> str: def mode(self) -> str: # TextIOWrapper doesn't expose a mode, but at least some of our # tests check it. - return self.buffer.mode.replace("b", "") + assert hasattr(self.buffer, "mode") + return cast(str, self.buffer.mode.replace("b", "")) class CaptureIO(io.TextIOWrapper): @@ -550,7 +552,7 @@ def snap(self) -> bytes: res = self.tmpfile.buffer.read() self.tmpfile.seek(0) self.tmpfile.truncate() - return res + return res # type: ignore[return-value] def writeorg(self, data: bytes) -> None: """Write to original file descriptor.""" diff --git a/testing/test_runner.py b/testing/test_runner.py index 0d9facdcd71..0245438a47d 100644 --- a/testing/test_runner.py +++ b/testing/test_runner.py @@ -137,8 +137,8 @@ def raiser(exc): ss.teardown_exact(None) mod, func = e.value.exceptions assert isinstance(mod, KeyError) - assert isinstance(func.exceptions[0], TypeError) # type: ignore - assert isinstance(func.exceptions[1], ValueError) # type: ignore + assert isinstance(func.exceptions[0], TypeError) + assert isinstance(func.exceptions[1], ValueError) def test_cached_exception_doesnt_get_longer(self, pytester: Pytester) -> None: """Regression test for #12204 (the "BTW" case).""" From 94dd15341a036b0a464992c2be0e48d4a8b9d23c Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 29 Oct 2024 10:08:27 +0100 Subject: [PATCH 130/445] Upgrade pylint version, activate all extensions --- .pre-commit-config.yaml | 2 +- pyproject.toml | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 04971cf9fb2..b8e7053e1c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -61,7 +61,7 @@ repos: entry: pylint language: system types: [python] - args: ["-rn", "-sn", "--fail-on=I"] + args: ["-rn", "-sn", "--fail-on=I", "--enable-all-extentions"] require_serial: true stages: [manual] - id: rst diff --git a/pyproject.toml b/pyproject.toml index da47e4b045e..c968b826554 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -200,7 +200,9 @@ disable = [ "arguments-renamed", "assigning-non-slot", "attribute-defined-outside-init", + "bad-builtin", "bad-classmethod-argument", + "bad-dunder-name", "bad-mcs-method-argument", "broad-exception-caught", "broad-exception-raised", @@ -209,25 +211,41 @@ disable = [ "comparison-with-callable", "comparison-with-itself", # PLR0124 from ruff "condition-evals-to-constant", + "consider-alternative-union-syntax", + "confusing-consecutive-elif", + "consider-using-any-or-all", + "consider-using-assignment-expr", "consider-using-dict-items", "consider-using-from-import", "consider-using-f-string", "consider-using-in", + "consider-using-namedtuple-or-dataclass", "consider-using-ternary", + "consider-using-tuple", "consider-using-with", "consider-using-from-import", # not activated by default, PLR0402 disabled in ruff + "consider-ternary-expression", "cyclic-import", + "differing-param-doc", + "docstring-first-line-empty", + "deprecated-argument", + "deprecated-attribute", + "deprecated-class", + "deprecated-typing-alias", + "dict-init-mutate", "disallowed-name", # foo / bar are used often in tests "duplicate-code", "else-if-used", # not activated by default, PLR5501 disabled in ruff "empty-comment", # not activated by default, PLR2044 disabled in ruff "eval-used", + "eq-without-hash", "exec-used", "expression-not-assigned", "fixme", "global-statement", # PLW0603 disabled in ruff "import-error", "import-outside-toplevel", + "import-private-name", "inconsistent-return-statements", "invalid-bool-returned", "invalid-name", @@ -238,8 +256,12 @@ disable = [ "magic-value-comparison", # not activated by default, PLR2004 disabled in ruff "method-hidden", "missing-docstring", + "missing-param-doc", + "missing-raises-doc", "missing-timeout", + "missing-type-doc", "misplaced-bare-raise", # PLE0704 from ruff + "misplaced-comparison-constant", "multiple-statements", # multiple-statements-on-one-line-colon (E701) from ruff "no-else-break", "no-else-continue", @@ -248,6 +270,7 @@ disable = [ "no-member", "no-name-in-module", "no-self-argument", + "no-self-use", "not-an-iterable", "not-callable", "pointless-exception-statement", # https://github.com/pytest-dev/pytest/pull/12379 @@ -260,12 +283,14 @@ disable = [ "redefined-builtin", "redefined-loop-name", # PLW2901 disabled in ruff "redefined-outer-name", + "redefined-variable-type", "reimported", "simplifiable-condition", "simplifiable-if-expression", "singleton-comparison", "superfluous-parens", "super-init-not-called", + "too-complex", "too-few-public-methods", "too-many-ancestors", "too-many-arguments", # disabled in ruff @@ -279,6 +304,7 @@ disable = [ "too-many-public-methods", "too-many-return-statements", # disabled in ruff "too-many-statements", # disabled in ruff + "too-many-try-statements", "try-except-raise", "typevar-name-incorrect-variance", # PLC0105 disabled in ruff "unbalanced-tuple-unpacking", @@ -300,10 +326,12 @@ disable = [ "use-dict-literal", "use-implicit-booleaness-not-comparison", "use-implicit-booleaness-not-len", + "use-set-for-membership", "useless-else-on-loop", # PLC0414 disabled in ruff "useless-import-alias", "useless-return", "using-constant-test", + "while-used", "wrong-import-order", # handled by isort / ruff "wrong-import-position", # handled by isort / ruff ] From b19fd523e18a35dd17bc3ae61a251b73cb940551 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 29 Oct 2024 10:09:09 +0100 Subject: [PATCH 131/445] [pylint dict-init-mutate] Initialize a dict right off for speed --- pyproject.toml | 1 - src/_pytest/junitxml.py | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c968b826554..3636ee455ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -232,7 +232,6 @@ disable = [ "deprecated-attribute", "deprecated-class", "deprecated-typing-alias", - "dict-init-mutate", "disallowed-name", # foo / bar are used often in tests "duplicate-code", "else-if-used", # not activated by default, PLR5501 disabled in ruff diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py index 3a2cb59a6c1..efe6f489b48 100644 --- a/src/_pytest/junitxml.py +++ b/src/_pytest/junitxml.py @@ -74,10 +74,10 @@ def merge_family(left, right) -> None: left.update(result) -families = {} -families["_base"] = {"testcase": ["classname", "name"]} -families["_base_legacy"] = {"testcase": ["file", "line", "url"]} - +families = { # pylint: disable=dict-init-mutate + "_base": {"testcase": ["classname", "name"]}, + "_base_legacy": {"testcase": ["file", "line", "url"]}, +} # xUnit 1.x inherits legacy attributes. families["xunit1"] = families["_base"].copy() merge_family(families["xunit1"], families["_base_legacy"]) From 987904c13cdd03fd49f46a88738e13f808db99bd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 10 Nov 2024 08:39:36 +0000 Subject: [PATCH 132/445] [automated] Update plugin list (#12950) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 78 +++++++++++++++++++------------- 1 file changed, 47 insertions(+), 31 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 50206c34150..ecd96b89967 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,15 +27,15 @@ please refer to `the update script =8.3 - :pypi:`logassert` Simple but powerful assertion and verification of logged lines. May 20, 2022 5 - Production/Stable N/A + :pypi:`databricks-labs-pytester` Python Testing for Databricks Nov 04, 2024 4 - Beta pytest>=8.3 + :pypi:`logassert` Simple but powerful assertion and verification of logged lines. Nov 08, 2024 5 - Production/Stable N/A :pypi:`logot` Test whether your code is logging correctly 🪵 Mar 23, 2024 5 - Production/Stable pytest<9,>=7; extra == "pytest" :pypi:`nuts` Network Unit Testing System Jul 19, 2024 N/A pytest<8,>=7 :pypi:`pytest-abq` Pytest integration for the ABQ universal test runner. Apr 07, 2023 N/A N/A @@ -157,7 +157,7 @@ This list contains 1538 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Oct 22, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Nov 05, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -246,7 +246,7 @@ This list contains 1538 plugins. :pypi:`pytest-cldf` Easy quality control for CLDF datasets using pytest Nov 07, 2022 N/A pytest (>=3.6) :pypi:`pytest-cleanslate` Collects and executes pytest tests separately Sep 04, 2024 N/A pytest :pypi:`pytest_cleanup` Automated, comprehensive and well-organised pytest test cases. Jan 28, 2020 N/A N/A - :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Sep 14, 2024 5 - Production/Stable N/A + :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Nov 08, 2024 5 - Production/Stable N/A :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Oct 08, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-click` Pytest plugin for Click Feb 11, 2022 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-cli-fixtures` Automatically register fixtures for custom CLI arguments Jul 28, 2022 N/A pytest (~=7.0) @@ -571,7 +571,7 @@ This list contains 1538 plugins. :pypi:`pytest-fixtures` Common fixtures for pytest May 01, 2019 5 - Production/Stable N/A :pypi:`pytest-fixture-tools` Plugin for pytest which provides tools for fixtures Aug 15, 2024 6 - Mature pytest :pypi:`pytest-fixture-typecheck` A pytest plugin to assert type annotations at runtime. Aug 24, 2021 N/A pytest - :pypi:`pytest-flake8` pytest plugin to check FLAKE8 requirements Jul 21, 2024 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-flake8` pytest plugin to check FLAKE8 requirements Nov 09, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-flake8-path` A pytest fixture for testing flake8 plugins. Oct 25, 2024 5 - Production/Stable pytest :pypi:`pytest-flake8-v2` pytest plugin to check FLAKE8 requirements Mar 01, 2022 5 - Production/Stable pytest (>=7.0) :pypi:`pytest-flakefinder` Runs tests multiple times to expose flakiness. Oct 26, 2022 4 - Beta pytest (>=2.7.1) @@ -601,7 +601,7 @@ This list contains 1538 plugins. :pypi:`pytest-frozen-uuids` Deterministically frozen UUID's for your tests Apr 17, 2022 N/A pytest (>=3.0) :pypi:`pytest-func-cov` Pytest plugin for measuring function coverage Apr 15, 2021 3 - Alpha pytest (>=5) :pypi:`pytest-funparam` An alternative way to parametrize test cases. Dec 02, 2021 4 - Beta pytest >=4.6.0 - :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Oct 11, 2024 N/A pytest + :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Nov 07, 2024 N/A pytest :pypi:`pytest-fxa` pytest plugin for Firefox Accounts Aug 28, 2018 5 - Production/Stable N/A :pypi:`pytest-fxa-mte` pytest plugin for Firefox Accounts Oct 02, 2024 5 - Production/Stable N/A :pypi:`pytest-fxtest` Oct 27, 2020 N/A N/A @@ -616,7 +616,7 @@ This list contains 1538 plugins. :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Jul 08, 2024 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Nov 07, 2024 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -660,7 +660,7 @@ This list contains 1538 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Nov 01, 2024 3 - Alpha pytest==8.3.3 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Nov 09, 2024 3 - Alpha pytest==8.3.3 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -730,6 +730,7 @@ This list contains 1538 plugins. :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Sep 25, 2024 4 - Beta pytest :pypi:`pytest-invenio` Pytest fixtures for Invenio. Jun 27, 2024 5 - Production/Stable pytest<7.2.0,>=6 :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) + :pypi:`pytest-iovis` A Pytest plugin to enable Jupyter Notebook testing with Papermill Nov 06, 2024 4 - Beta pytest>=7.1.0 :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A :pypi:`pytest-ipywidgets` Oct 28, 2024 N/A pytest @@ -818,7 +819,7 @@ This list contains 1538 plugins. :pypi:`pytest-logger` Plugin configuring handlers for loggers from Python logging module. Mar 10, 2024 5 - Production/Stable pytest (>=3.2) :pypi:`pytest-logging` Configures logging and allows tweaking the log level with a py.test flag Nov 04, 2015 4 - Beta N/A :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-logikal` Common testing environment Oct 28, 2024 5 - Production/Stable pytest==8.3.3 + :pypi:`pytest-logikal` Common testing environment Nov 09, 2024 5 - Production/Stable pytest==8.3.3 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Sep 30, 2024 4 - Beta pytest>=8.2.2 :pypi:`pytest-loguru` Pytest Loguru Mar 20, 2024 5 - Production/Stable pytest; extra == "test" @@ -859,7 +860,7 @@ This list contains 1538 plugins. :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A :pypi:`pytest-metadata` pytest plugin for test session metadata Feb 12, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-metrics` Custom metrics report for pytest Apr 04, 2020 N/A pytest - :pypi:`pytest-mh` Pytest multihost plugin Sep 19, 2024 N/A pytest + :pypi:`pytest-mh` Pytest multihost plugin Nov 04, 2024 N/A pytest :pypi:`pytest-mimesis` Mimesis integration with the pytest test runner Mar 21, 2020 5 - Production/Stable pytest (>=4.2) :pypi:`pytest-minecraft` A pytest plugin for running tests against Minecraft releases Apr 06, 2022 N/A pytest (>=6.0.1) :pypi:`pytest-mini` A plugin to test mp Feb 06, 2023 N/A pytest (>=7.2.0,<8.0.0) @@ -1006,7 +1007,7 @@ This list contains 1538 plugins. :pypi:`pytest-pg` A tiny plugin for pytest which runs PostgreSQL in Docker May 21, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-pgsql` Pytest plugins and helpers for tests using a Postgres database. May 13, 2020 5 - Production/Stable pytest (>=3.0.0) :pypi:`pytest-phmdoctest` pytest plugin to test Python examples in Markdown using phmdoctest. Apr 15, 2022 4 - Beta pytest (>=5.4.3) - :pypi:`pytest-picked` Run the tests related to the changed files Jul 27, 2023 N/A pytest (>=3.7.0) + :pypi:`pytest-picked` Run the tests related to the changed files Nov 06, 2024 N/A pytest>=3.7.0 :pypi:`pytest-pigeonhole` Jun 25, 2018 5 - Production/Stable pytest (>=3.4) :pypi:`pytest-pikachu` Show surprise when tests are passing Aug 05, 2021 5 - Production/Stable pytest :pypi:`pytest-pilot` Slice in your test base thanks to powerful markers. Oct 09, 2020 5 - Production/Stable N/A @@ -1224,7 +1225,7 @@ This list contains 1538 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Nov 01, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Nov 09, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1235,7 +1236,7 @@ This list contains 1538 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Nov 01, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Nov 09, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1281,6 +1282,7 @@ This list contains 1538 plugins. :pypi:`pytest-smartcollect` A plugin for collecting tests that touch changed code Oct 04, 2018 N/A pytest (>=3.5.0) :pypi:`pytest-smartcov` Smart coverage plugin for pytest. Sep 30, 2017 3 - Alpha N/A :pypi:`pytest-smell` Automated bad smell detection tool for Pytest Jun 26, 2022 N/A N/A + :pypi:`pytest-smoke` pytest plugin for supporting smoke testing Nov 07, 2024 4 - Beta pytest<9,>=7.0.0 :pypi:`pytest-smtp` Send email with pytest execution result Feb 20, 2021 N/A pytest :pypi:`pytest-smtp4dev` Plugin for smtp4dev API Jun 27, 2023 5 - Production/Stable N/A :pypi:`pytest-smtpd` An SMTP server for testing built on aiosmtpd May 15, 2023 N/A pytest @@ -1358,7 +1360,7 @@ This list contains 1538 plugins. :pypi:`pytest-symbols` pytest-symbols is a pytest plugin that adds support for passing test environment symbols into pytest tests. Nov 20, 2017 3 - Alpha N/A :pypi:`pytest-system-statistics` Pytest plugin to track and report system usage statistics Feb 16, 2022 5 - Production/Stable pytest (>=6.0.0) :pypi:`pytest-system-test-plugin` Pyst - Pytest System-Test Plugin Feb 03, 2022 N/A N/A - :pypi:`pytest_tagging` a pytest plugin to tag tests Aug 31, 2024 N/A pytest<8.0.0,>=7.1.3 + :pypi:`pytest_tagging` a pytest plugin to tag tests Nov 08, 2024 N/A pytest>=7.1.3 :pypi:`pytest-takeltest` Fixtures for ansible, testinfra and molecule Sep 07, 2024 N/A N/A :pypi:`pytest-talisker` Nov 28, 2021 N/A N/A :pypi:`pytest-tally` A Pytest plugin to generate realtime summary stats, and display them in-console using a text-based dashboard. May 22, 2023 4 - Beta pytest (>=6.2.5) @@ -1578,14 +1580,14 @@ This list contains 1538 plugins. :pypi:`databricks-labs-pytester` - *last release*: Oct 11, 2024, + *last release*: Nov 04, 2024, *status*: 4 - Beta, *requires*: pytest>=8.3 Python Testing for Databricks :pypi:`logassert` - *last release*: May 20, 2022, + *last release*: Nov 08, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -2439,7 +2441,7 @@ This list contains 1538 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Oct 22, 2024, + *last release*: Nov 05, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -3062,7 +3064,7 @@ This list contains 1538 plugins. Automated, comprehensive and well-organised pytest test cases. :pypi:`pytest-cleanuptotal` - *last release*: Sep 14, 2024, + *last release*: Nov 08, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -5337,7 +5339,7 @@ This list contains 1538 plugins. A pytest plugin to assert type annotations at runtime. :pypi:`pytest-flake8` - *last release*: Jul 21, 2024, + *last release*: Nov 09, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 @@ -5547,7 +5549,7 @@ This list contains 1538 plugins. An alternative way to parametrize test cases. :pypi:`pytest-fv` - *last release*: Oct 11, 2024, + *last release*: Nov 07, 2024, *status*: N/A, *requires*: pytest @@ -5652,7 +5654,7 @@ This list contains 1538 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Jul 08, 2024, + *last release*: Nov 07, 2024, *status*: N/A, *requires*: pytest>=3.6 @@ -5960,7 +5962,7 @@ This list contains 1538 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Nov 01, 2024, + *last release*: Nov 09, 2024, *status*: 3 - Alpha, *requires*: pytest==8.3.3 @@ -6449,6 +6451,13 @@ This list contains 1538 plugins. Run tests covering a specific file or changeset + :pypi:`pytest-iovis` + *last release*: Nov 06, 2024, + *status*: 4 - Beta, + *requires*: pytest>=7.1.0 + + A Pytest plugin to enable Jupyter Notebook testing with Papermill + :pypi:`pytest-ipdb` *last release*: Mar 20, 2013, *status*: 2 - Pre-Alpha, @@ -7066,7 +7075,7 @@ This list contains 1538 plugins. :pypi:`pytest-logikal` - *last release*: Oct 28, 2024, + *last release*: Nov 09, 2024, *status*: 5 - Production/Stable, *requires*: pytest==8.3.3 @@ -7353,7 +7362,7 @@ This list contains 1538 plugins. Custom metrics report for pytest :pypi:`pytest-mh` - *last release*: Sep 19, 2024, + *last release*: Nov 04, 2024, *status*: N/A, *requires*: pytest @@ -8382,9 +8391,9 @@ This list contains 1538 plugins. pytest plugin to test Python examples in Markdown using phmdoctest. :pypi:`pytest-picked` - *last release*: Jul 27, 2023, + *last release*: Nov 06, 2024, *status*: N/A, - *requires*: pytest (>=3.7.0) + *requires*: pytest>=3.7.0 Run the tests related to the changed files @@ -9908,7 +9917,7 @@ This list contains 1538 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Nov 01, 2024, + *last release*: Nov 09, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9985,7 +9994,7 @@ This list contains 1538 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Nov 01, 2024, + *last release*: Nov 09, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10306,6 +10315,13 @@ This list contains 1538 plugins. Automated bad smell detection tool for Pytest + :pypi:`pytest-smoke` + *last release*: Nov 07, 2024, + *status*: 4 - Beta, + *requires*: pytest<9,>=7.0.0 + + pytest plugin for supporting smoke testing + :pypi:`pytest-smtp` *last release*: Feb 20, 2021, *status*: N/A, @@ -10846,9 +10862,9 @@ This list contains 1538 plugins. Pyst - Pytest System-Test Plugin :pypi:`pytest_tagging` - *last release*: Aug 31, 2024, + *last release*: Nov 08, 2024, *status*: N/A, - *requires*: pytest<8.0.0,>=7.1.3 + *requires*: pytest>=7.1.3 a pytest plugin to tag tests From 70639efe8d33cdbf2590742b70da59efe09c977f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 07:39:17 +0100 Subject: [PATCH 133/445] build(deps): Bump django in /testing/plugins_integration (#12951) Bumps [django](https://github.com/django/django) from 5.1.2 to 5.1.3. - [Commits](https://github.com/django/django/compare/5.1.2...5.1.3) --- updated-dependencies: - dependency-name: django dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index ef01747f2fd..32992dc2589 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,5 +1,5 @@ anyio[curio,trio]==4.6.2.post1 -django==5.1.2 +django==5.1.3 pytest-asyncio==0.24.0 pytest-bdd==7.3.0 pytest-cov==6.0.0 From 7256c0c226b0eea2453cc532e6786366aa2400c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 08:39:14 +0100 Subject: [PATCH 134/445] build(deps): Bump pypa/gh-action-pypi-publish from 1.10.3 to 1.12.2 (#12953) Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.10.3 to 1.12.2. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.10.3...v1.12.2) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 974fe4947db..3d3cb7534a4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -54,7 +54,7 @@ jobs: path: dist - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@v1.10.3 + uses: pypa/gh-action-pypi-publish@v1.12.2 with: attestations: true From c98ef2bdcaf4f0478c77c38534bce788e6581967 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Mon, 11 Nov 2024 15:09:18 +0100 Subject: [PATCH 135/445] change implementation so the check happens in pytest_fixture_setup after any hooks (from async plugins) has had a chance to resolve the awaitable --- src/_pytest/compat.py | 1 + src/_pytest/fixtures.py | 57 ++++++++++++++------------------------ testing/acceptance_test.py | 40 +++++++++++++------------- 3 files changed, 43 insertions(+), 55 deletions(-) diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 614848e0dba..64240135313 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -44,6 +44,7 @@ class NotSetType(enum.Enum): def is_generator(func: object) -> bool: + # note: this also returns true for async generator functions genfunc = inspect.isgeneratorfunction(func) return genfunc and not iscoroutinefunction(func) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 4b45489cd96..0737773f047 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -595,42 +595,6 @@ def _get_active_fixturedef( raise FixtureLookupError(argname, self) fixturedef = fixturedefs[index] - # Check for attempted use of an async fixture by a sync test - # `self.scope` here is not the scope of the requested fixture, but the scope of - # the requester. - if ( - self.scope == "function" - and not inspect.iscoroutinefunction(self._pyfuncitem.obj) - and ( - inspect.iscoroutinefunction(fixturedef.func) - or inspect.isasyncgenfunction(fixturedef.func) - ) - ): - if fixturedef._autouse: - warnings.warn( - PytestRemovedIn9Warning( - f"Sync test {self._pyfuncitem.name!r} requested async fixture " - f"{argname!r} with autouse=True. " - "If you intended to use the fixture you may want to make the " - "test asynchronous or the fixture synchronous. " - "If you did not intend to use it you should " - "restructure your test setup. " - "This will turn into an error in pytest 9." - ), - stacklevel=3, - ) - else: - warnings.warn( - PytestRemovedIn9Warning( - f"Sync test {self._pyfuncitem.name!r} requested async fixture " - f"{argname!r}. " - "You may want to make the test asynchronous and run it with " - "a suitable async framework test plugin, or make the fixture synchronous. " - "This will turn into an error in pytest 9." - ), - stacklevel=3, - ) - # Prepare a SubRequest object for calling the fixture. try: callspec = self._pyfuncitem.callspec @@ -921,6 +885,8 @@ def call_fixture_func( fixturefunc: _FixtureFunc[FixtureValue], request: FixtureRequest, kwargs ) -> FixtureValue: if is_generator(fixturefunc): + # note: this also triggers on async generators, suppressing 'unawaited coroutine' + # warning. fixturefunc = cast( Callable[..., Generator[FixtureValue, None, None]], fixturefunc ) @@ -1179,6 +1145,25 @@ def pytest_fixture_setup( fixturefunc = resolve_fixture_function(fixturedef, request) my_cache_key = fixturedef.cache_key(request) + + if inspect.isasyncgenfunction(fixturefunc) or inspect.iscoroutinefunction( + fixturefunc + ): + auto_str = " with autouse=True" if fixturedef._autouse else "" + + warnings.warn( + PytestRemovedIn9Warning( + f"{request.node.name!r} requested an async fixture " + f"{request.fixturename!r}{auto_str}, with no plugin or hook that " + "handled it. This is usually an error, as pytest does not natively " + "support it. If this is intentional, consider making the fixture " + "sync and return a coroutine/asyncgen. " + "This will turn into an error in pytest 9." + ), + # no stacklevel will point at users code, so we just point here + stacklevel=1, + ) + try: result = call_fixture_func(fixturefunc, request, kwargs) except TEST_OUTCOME as e: diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index a7a9afedbc0..ffea0dbf46b 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1306,11 +1306,13 @@ def test_foo(async_fixture): result = pytester.runpytest() result.stdout.fnmatch_lines( [ + "*== warnings summary ==*", ( - "*Sync test 'test_foo' requested async fixture " - "'async_fixture'. " - "You may want to make the test asynchronous and run it with " - "a suitable async framework test plugin, or make the fixture synchronous. " + "*PytestRemovedIn9Warning: 'test_foo' requested an async " + "fixture 'async_fixture', with no plugin or hook that handled it. " + "This is usually an error, as pytest does not natively support it. " + "If this is intentional, consider making the fixture sync and return " + "a coroutine/asyncgen. " "This will turn into an error in pytest 9." ), ] @@ -1328,21 +1330,21 @@ async def async_fixture(): yield def test_foo(async_fixture): - # suppress unawaited coroutine warning - try: - async_fixture.asend(None) - except StopIteration: - pass + # we don't need to suppress RuntimeWarning for unawaited coroutine + # as pytest internals accidentally do so already for async gens + ... """ ) result = pytester.runpytest() result.stdout.fnmatch_lines( [ + "*== warnings summary ==*", ( - "*Sync test 'test_foo' requested async fixture " - "'async_fixture'. " - "You may want to make the test asynchronous and run it with " - "a suitable async framework test plugin, or make the fixture synchronous. " + "*PytestRemovedIn9Warning: 'test_foo' requested an async " + "fixture 'async_fixture', with no plugin or hook that handled it. " + "This is usually an error, as pytest does not natively support it. " + "If this is intentional, consider making the fixture sync and return " + "a coroutine/asyncgen. " "This will turn into an error in pytest 9." ), ] @@ -1371,13 +1373,13 @@ def test_foo(async_fixture): result = pytester.runpytest() result.stdout.fnmatch_lines( [ + "*== warnings summary ==*", ( - "*Sync test 'test_foo' requested async fixture " - "'async_fixture' with autouse=True. " - "If you intended to use the fixture you may want to make the " - "test asynchronous or the fixture synchronous. " - "If you did not intend to use it you should " - "restructure your test setup. " + "*PytestRemovedIn9Warning: Sync test 'test_foo' requested an async " + "fixture 'async_fixture' with autouse=True, with no plugin or hook " + "that handled it. This is usually an error, as pytest does not " + "natively support it. If this is intentional, consider making the " + "fixture sync and return a coroutine/asyncgen. " "This will turn into an error in pytest 9." ), ] From cd3eb9800b8f36c257cfe4deb40ea275bb72e4e9 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Mon, 11 Nov 2024 15:20:25 +0100 Subject: [PATCH 136/445] fix test --- testing/acceptance_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index ffea0dbf46b..ca6df943afa 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1375,7 +1375,7 @@ def test_foo(async_fixture): [ "*== warnings summary ==*", ( - "*PytestRemovedIn9Warning: Sync test 'test_foo' requested an async " + "*PytestRemovedIn9Warning: 'test_foo' requested an async " "fixture 'async_fixture' with autouse=True, with no plugin or hook " "that handled it. This is usually an error, as pytest does not " "natively support it. If this is intentional, consider making the " From 876cc2a2b184bb68b0398ce7f9b7bbb3a731e787 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Mon, 11 Nov 2024 15:37:22 +0100 Subject: [PATCH 137/445] update docs/changelog --- changelog/10839.deprecation.rst | 2 +- doc/en/deprecations.rst | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/changelog/10839.deprecation.rst b/changelog/10839.deprecation.rst index 78ad4e118e4..01464ca0ba2 100644 --- a/changelog/10839.deprecation.rst +++ b/changelog/10839.deprecation.rst @@ -1 +1 @@ -Synchronous tests that request an asynchronous fixture will now give a DeprecationWarning. This will introduce warnings in several pytest plugins that handle async tests/fixtures and for some users with custom setups. For guidance on how to manage this see :ref:`sync-test-async-fixture`. +Requesting an asynchronous fixture without a `pytest_fixture_setup` to handle it will now give a DeprecationWarning. This most commonly happens if a sync test requests an async fixture. This should have no effect on a majority of users with async tests or fixtures, but may affect non-standard hook setups or ``autouse=True``. For guidance on how to work around this warning see :ref:`sync-test-async-fixture`. diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index b384f01dfab..494bd88d282 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -24,13 +24,14 @@ sync test depending on async fixture Pytest has for a long time given an error when encountering an asynchronous test function, prompting the user to install a plugin that can handle it. It has not given any errors if you have an asynchronous fixture that's depended on by a -synchronous test. This is a problem even if you do have a plugin installed for handling async tests, as they may require +synchronous test. If the fixture was an async function you did get an "unawaited coroutine" warning, but for async yield fixtures you didn't even get that. +This is a problem even if you do have a plugin installed for handling async tests, as they may require special decorators for async fixtures to be handled, and some may not robustly handle if a user accidentally requests an async fixture from their sync tests. Fixture values being cached can make this even more unintuitive, where everything will "work" if the fixture is first requested by an async test, and then requested by a synchronous test. Unfortunately there is no 100% reliable method of identifying when a user has made a mistake, versus when they expect an -unawaited object from their fixture that they will handle - either on their own, or by a plugin. To suppress this warning +unawaited object from their fixture that they will handle on their own. To suppress this warning when you in fact did intend to handle this you can wrap your async fixture in a synchronous fixture: .. code-block:: python @@ -67,7 +68,10 @@ should be changed to def test_foo(unawaited_fixture): assert 1 == asyncio.run(unawaited_fixture) -If a user has an async fixture with ``autouse=True`` in their ``conftest.py``, or in a file where they also have synchronous tests, they will also get this warning. We strongly recommend against this practice, and they should restructure their testing infrastructure so the fixture is synchronous or to separate the fixture from their synchronous tests. Plugins that handle async may want to introduce helpers to make that easier in scenarios where that might be wanted, e.g. if setting up a database in an asynchronous way, or the user may opt to make their test async even though it might not strictly need to be. + +You can also make use of `pytest_fixture_setup` to handle the coroutine/asyncgen before pytest sees it - this is the way current async pytest plugins handle it. + +If a user has an async fixture with ``autouse=True`` in their ``conftest.py``, or in a file where they also have synchronous tests, they will also get this warning. We strongly recommend against this practice, and they should restructure their testing infrastructure so the fixture is synchronous or to separate the fixture from their synchronous tests. Note that the anyio pytest plugin has some support for sync test + async fixtures currently. .. _import-or-skip-import-error: From 473452035ac3d2c3828b3dc9ac18d8d82d2c0215 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Nov 2024 06:58:31 +0100 Subject: [PATCH 138/445] [pre-commit.ci] pre-commit autoupdate (#12955) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.7.2 → v0.7.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.7.2...v0.7.3) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b8e7053e1c8..218a69e2cbc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.7.2" + rev: "v0.7.3" hooks: - id: ruff args: ["--fix"] From 76b8870f6cf04db8b405c766fc25021d3fc8602a Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 12 Nov 2024 12:42:07 +0100 Subject: [PATCH 139/445] [pylint consider-using-any-or-all] Fix or disable all detected issues (#12954) * Avoid constructing a list of names * noqa a a suggestion in already nested for --- pyproject.toml | 1 - src/_pytest/mark/__init__.py | 10 ++-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ad0bca4374b..be99392a85f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -213,7 +213,6 @@ disable = [ "condition-evals-to-constant", "consider-alternative-union-syntax", "confusing-consecutive-elif", - "consider-using-any-or-all", "consider-using-assignment-expr", "consider-using-dict-items", "consider-using-from-import", diff --git a/src/_pytest/mark/__init__.py b/src/_pytest/mark/__init__.py index f76e5212057..a6f0155751a 100644 --- a/src/_pytest/mark/__init__.py +++ b/src/_pytest/mark/__init__.py @@ -193,12 +193,7 @@ def __call__(self, subname: str, /, **kwargs: str | int | bool | None) -> bool: if kwargs: raise UsageError("Keyword expressions do not support call parameters.") subname = subname.lower() - names = (name.lower() for name in self._names) - - for name in names: - if subname in name: - return True - return False + return any(subname in name.lower() for name in self._names) def deselect_by_keyword(items: list[Item], config: Config) -> None: @@ -243,10 +238,9 @@ def __call__(self, name: str, /, **kwargs: str | int | bool | None) -> bool: if not (matches := self.own_mark_name_mapping.get(name, [])): return False - for mark in matches: + for mark in matches: # pylint: disable=consider-using-any-or-all if all(mark.kwargs.get(k, NOT_SET) == v for k, v in kwargs.items()): return True - return False From 191456e00d89c2c814f8659070eb8863298996be Mon Sep 17 00:00:00 2001 From: sven <42868792+FreerGit@users.noreply.github.com> Date: Tue, 12 Nov 2024 20:00:47 +0100 Subject: [PATCH 140/445] WIP: modified items, reports and items collected - pytest_collectreport hook currently gets more reports (TODO) - `pytest_collection_modifyitems` and `pytest_itemcollected` is correct. --- testing/test_collect_imports.py | 477 +++++++++++++++++++------------- 1 file changed, 278 insertions(+), 199 deletions(-) diff --git a/testing/test_collect_imports.py b/testing/test_collect_imports.py index fe1e6b3e863..cf8ff9cb983 100644 --- a/testing/test_collect_imports.py +++ b/testing/test_collect_imports.py @@ -1,88 +1,89 @@ from __future__ import annotations import textwrap +from typing import Any +from _pytest.fixtures import FixtureRequest +from _pytest.main import Session from _pytest.pytester import Pytester +from _pytest.pytester import RecordedHookCall +from _pytest.pytester import RunResult +import pytest # Start of tests for classes +# def run_import_class_test(pytester: Pytester, passed: int = 0, errors: int = 0) -> None: +# src_dir = pytester.mkdir("src") +# tests_dir = pytester.mkdir("tests") +# src_file = src_dir / "foo.py" + +# src_file.write_text( +# textwrap.dedent("""\ +# class Testament(object): +# def __init__(self): +# super().__init__() +# self.collections = ["stamp", "coin"] + +# def personal_property(self): +# return [f"my {x} collection" for x in self.collections] +# """), +# encoding="utf-8", +# ) + +# test_file = tests_dir / "foo_test.py" +# test_file.write_text( +# textwrap.dedent("""\ +# import sys +# import os + +# current_file = os.path.abspath(__file__) +# current_dir = os.path.dirname(current_file) +# parent_dir = os.path.abspath(os.path.join(current_dir, '..')) +# sys.path.append(parent_dir) + +# from src.foo import Testament + +# class TestDomain: +# def test_testament(self): +# testament = Testament() +# assert testament.personal_property() +# """), +# encoding="utf-8", +# ) + +# result = pytester.runpytest() +# result.assert_outcomes(passed=passed, errors=errors) + +# def test_collect_imports_disabled(pytester: Pytester) -> None: +# pytester.makeini(""" +# [pytest] +# testpaths = "tests" +# collect_imported_tests = false +# """) + +# run_import_class_test(pytester, passed=1) + +# # Verify that the state of hooks +# reprec = pytester.inline_run() +# items_collected = reprec.getcalls("pytest_itemcollected") +# assert len(items_collected) == 1 +# for x in items_collected: +# assert x.item._getobj().__name__ == "test_testament" + +# def test_collect_imports_default(pytester: Pytester) -> None: +# run_import_class_test(pytester, errors=1) -def run_import_class_test(pytester: Pytester, passed: int = 0, errors: int = 0) -> None: - src_dir = pytester.mkdir("src") - tests_dir = pytester.mkdir("tests") - src_file = src_dir / "foo.py" - - src_file.write_text( - textwrap.dedent("""\ - class Testament(object): - def __init__(self): - super().__init__() - self.collections = ["stamp", "coin"] - - def personal_property(self): - return [f"my {x} collection" for x in self.collections] - """), - encoding="utf-8", - ) - - test_file = tests_dir / "foo_test.py" - test_file.write_text( - textwrap.dedent("""\ - import sys - import os - - current_file = os.path.abspath(__file__) - current_dir = os.path.dirname(current_file) - parent_dir = os.path.abspath(os.path.join(current_dir, '..')) - sys.path.append(parent_dir) - - from src.foo import Testament - - class TestDomain: - def test_testament(self): - testament = Testament() - assert testament.personal_property() - """), - encoding="utf-8", - ) - - result = pytester.runpytest() - result.assert_outcomes(passed=passed, errors=errors) - - -def test_collect_imports_disabled(pytester: Pytester) -> None: - pytester.makeini(""" - [pytest] - testpaths = "tests" - collect_imported_tests = false - """) - - run_import_class_test(pytester, passed=1) - - # Verify that the state of hooks - reprec = pytester.inline_run() - items_collected = reprec.getcalls("pytest_itemcollected") - assert len(items_collected) == 1 - for x in items_collected: - assert x.item._getobj().__name__ == "test_testament" - - -def test_collect_imports_default(pytester: Pytester) -> None: - run_import_class_test(pytester, errors=1) - - # TODO, hooks - - -def test_collect_imports_enabled(pytester: Pytester) -> None: - pytester.makeini(""" - [pytest] - collect_imported_tests = true - """) +# # TODO, hooks - run_import_class_test(pytester, errors=1) +# def test_collect_imports_enabled(pytester: Pytester) -> None: +# pytester.makeini(""" +# [pytest] +# collect_imported_tests = true +# """) +# run_import_class_test(pytester, errors=1) # # TODO, hooks @@ -93,141 +94,219 @@ def test_collect_imports_enabled(pytester: Pytester) -> None: def run_import_functions_test( pytester: Pytester, passed: int, errors: int, failed: int -) -> None: - src_dir = pytester.mkdir("src") - tests_dir = pytester.mkdir("tests") - - src_file = src_dir / "foo.py" - +) -> RunResult: # Note that these "tests" should _not_ be treated as tests if `collect_imported_tests = false` # They are normal functions in that case, that happens to have test_* or *_test in the name. # Thus should _not_ be collected! - src_file.write_text( - textwrap.dedent("""\ - def test_function(): - some_random_computation = 5 - return some_random_computation - - def test_bar(): - pass - """), - encoding="utf-8", + pytester.makepyfile( + **{ + "src/foo.py": textwrap.dedent( + """\ + def test_function(): + some_random_computation = 5 + return some_random_computation + + def test_bar(): + pass + """ + ) + } ) - test_file = tests_dir / "foo_test.py" - # Inferred from the comment above, this means that there is _only_ one actual test # which should result in only 1 passing test being ran. - test_file.write_text( - textwrap.dedent("""\ - import sys - import os - - current_file = os.path.abspath(__file__) - current_dir = os.path.dirname(current_file) - parent_dir = os.path.abspath(os.path.join(current_dir, '..')) - sys.path.append(parent_dir) - - from src.foo import * - - class TestDomain: - def test_important(self): - res = test_function() - if res == 5: - pass - """), - encoding="utf-8", + pytester.makepyfile( + **{ + "tests/foo_test.py": textwrap.dedent( + """\ + import sys + import os + + current_file = os.path.abspath(__file__) + current_dir = os.path.dirname(current_file) + parent_dir = os.path.abspath(os.path.join(current_dir, '..')) + sys.path.append(parent_dir) + + from src.foo import * + + class TestDomain: + def test_important(self): + res = test_function() + if res == 5: + pass + """ + ) + } ) result = pytester.runpytest() result.assert_outcomes(passed=passed, errors=errors, failed=failed) - - -def test_collect_function_imports_enabled(pytester: Pytester) -> None: - pytester.makeini(""" - [pytest] - testpaths = "tests" - collect_imported_tests = true - """) - - run_import_functions_test(pytester, passed=2, errors=0, failed=1) - reprec = pytester.inline_run() - items_collected = reprec.getcalls("pytest_itemcollected") - # Recall that the default is `collect_imported_tests = true`. - # Which means that the normal functions are now interpreted as - # valid tests and `test_function()` will fail. - assert len(items_collected) == 3 - for x in items_collected: - assert x.item._getobj().__name__ in [ - "test_important", - "test_bar", - "test_function", - ] - - -def test_behaviour_without_testpaths_set_and_false(pytester: Pytester) -> None: - # Make sure `collect_imported_tests` has no dependence on `testpaths` - pytester.makeini(""" - [pytest] - collect_imported_tests = false - """) - - run_import_functions_test(pytester, passed=1, errors=0, failed=0) - reprec = pytester.inline_run() - items_collected = reprec.getcalls("pytest_itemcollected") - assert len(items_collected) == 1 - for x in items_collected: - assert x.item._getobj().__name__ == "test_important" - - -def test_behaviour_without_testpaths_set_and_true(pytester: Pytester) -> None: - # Make sure `collect_imported_tests` has no dependence on `testpaths` - pytester.makeini(""" - [pytest] - collect_imported_tests = true - """) - - run_import_functions_test(pytester, passed=2, errors=0, failed=1) - reprec = pytester.inline_run() - items_collected = reprec.getcalls("pytest_itemcollected") - assert len(items_collected) == 3 - - -def test_hook_behaviour_when_collect_off(pytester: Pytester) -> None: - pytester.makeini(""" - [pytest] - collect_imported_tests = false - """) - - run_import_functions_test(pytester, passed=1, errors=0, failed=0) - reprec = pytester.inline_run() - - # reports = reprec.getreports("pytest_collectreport") - items_collected = reprec.getcalls("pytest_itemcollected") - modified = reprec.getcalls("pytest_collection_modifyitems") - - # print("Reports: ----------------") - # print(reports) - # for r in reports: - # print(r) - - # TODO this is want I want, I think.... - # - # - # - # - # - - # TODO - # assert(reports.outcome == "passed") - # assert(len(reports.result) == 1) - - # print("Items collected: ----------------") - # print(items_collected) - # print("Modified : ----------------") - - assert len(items_collected) == 1 - for x in items_collected: - assert x.item._getobj().__name__ == "test_important" - - assert len(modified) == 1 + return result + + +# def test_collect_function_imports_enabled(pytester: Pytester) -> None: +# pytester.makeini(""" +# [pytest] +# testpaths = "tests" +# collect_imported_tests = true +# """) + +# run_import_functions_test(pytester, passed=2, errors=0, failed=1) +# reprec = pytester.inline_run() +# items_collected = reprec.getcalls("pytest_itemcollected") +# # Recall that the default is `collect_imported_tests = true`. +# # Which means that the normal functions are now interpreted as +# # valid tests and `test_function()` will fail. +# assert len(items_collected) == 3 +# for x in items_collected: +# assert x.item._getobj().__name__ in [ +# "test_important", +# "test_bar", +# "test_function", +# ] + + +# def test_behaviour_without_testpaths_set_and_false(pytester: Pytester) -> None: +# # Make sure `collect_imported_tests` has no dependence on `testpaths` +# pytester.makeini(""" +# [pytest] +# collect_imported_tests = false +# """) + +# run_import_functions_test(pytester, passed=1, errors=0, failed=0) +# reprec = pytester.inline_run() +# items_collected = reprec.getcalls("pytest_itemcollected") +# assert len(items_collected) == 1 +# for x in items_collected: +# assert x.item._getobj().__name__ == "test_important" + + +# def test_behaviour_without_testpaths_set_and_true(pytester: Pytester) -> None: +# # Make sure `collect_imported_tests` has no dependence on `testpaths` +# pytester.makeini(""" +# [pytest] +# collect_imported_tests = true +# """) + +# run_import_functions_test(pytester, passed=2, errors=0, failed=1) +# reprec = pytester.inline_run() +# items_collected = reprec.getcalls("pytest_itemcollected") +# assert len(items_collected) == 3 + + +class TestHookBehaviour: + collect_outcomes: dict[str, Any] = {} + + @pytest.mark.parametrize("step", [1, 2, 3]) + def test_hook_behaviour(self, pytester: Pytester, step: int) -> None: + if step == 1: + self._test_hook_default_behaviour(pytester) + elif step == 2: + self._test_hook_behaviour_when_collect_off(pytester) + elif step == 3: + self._test_hook_behaviour() + + @pytest.fixture(scope="class", autouse=True) + def setup_collect_outcomes(self, request: FixtureRequest) -> None: + request.cls.collect_outcomes = {} + + def _test_hook_default_behaviour(self, pytester: Pytester) -> None: + pytester.makepyfile( + **{ + "tests/foo_test.py": textwrap.dedent( + """\ + class TestDomain: + def test_important(self): + pass + """ + ) + } + ) + + result = pytester.runpytest() + result.assert_outcomes(passed=1) + reprec = pytester.inline_run() + reports = reprec.getreports("pytest_collectreport") + modified = reprec.getcalls("pytest_collection_modifyitems") + items_collected = reprec.getcalls("pytest_itemcollected") + + self.collect_outcomes["default"] = { + "result": result.parseoutcomes(), + "modified": modified, + "items_collected": items_collected, + "reports": reports, + } + + def _test_hook_behaviour_when_collect_off(self, pytester: Pytester) -> None: + pytester.makeini(""" + [pytest] + collect_imported_tests = false + """) + res = run_import_functions_test(pytester, passed=1, errors=0, failed=0) + reprec = pytester.inline_run() + reports = reprec.getreports("pytest_collectreport") + modified = reprec.getcalls("pytest_collection_modifyitems") + items_collected = reprec.getcalls("pytest_itemcollected") + + self.collect_outcomes["collect_off"] = { + "result": res.parseoutcomes(), + "modified": modified, + "items_collected": items_collected, + "reports": reports, + } + + # Now check that the two tests above did indeed result in the same outcome. + def _test_hook_behaviour(self) -> None: + print("ABCD", self.collect_outcomes) + default = self.collect_outcomes["default"] + collect_off = self.collect_outcomes["collect_off"] + assert default["result"] == collect_off["result"] + + assert len(default["modified"]) == len(collect_off["modified"]) == 1 + + def_modified_record: RecordedHookCall = default["modified"][0] + off_modified_record: RecordedHookCall = collect_off["modified"][0] + def_sess: Session = def_modified_record.__dict__["session"] + off_sess: Session = off_modified_record.__dict__["session"] + + assert def_sess.exitstatus == off_sess.exitstatus + assert def_sess.testsfailed == off_sess.testsfailed + assert def_sess.testscollected == off_sess.testscollected + + def_items = def_modified_record.__dict__["items"] + off_items = off_modified_record.__dict__["items"] + assert len(def_items) == len(off_items) == 1 + assert def_items[0].name == off_items[0].name + + assert ( + len(default["items_collected"]) == len(collect_off["items_collected"]) == 1 + ) + + def_items_record: RecordedHookCall = default["items_collected"][0] + off_items_record: RecordedHookCall = collect_off["items_collected"][0] + def_items = def_items_record.__dict__["item"] + off_items = off_items_record.__dict__["item"] + assert def_items.name == off_items.name + + # TODO: fix diff: + # [ + # , + # - , + # , + # , + # , + # - , + # ? ^ + # + , + # ? ^ + # ] + + # assert len(default['reports']) == len(collect_off['reports']) + # for i in range(len(default['reports'])): + # print("def",default['reports'][i].__dict__) + # print("off",collect_off['reports'][i].__dict__) + + # from pprint import pprint + # pprint(default['reports']) + # pprint(collect_off['reports']) + # assert default['reports'] == collect_off['reports'] From 1a4dfbb593fa63bbb3eeed2f79e730395f86b41a Mon Sep 17 00:00:00 2001 From: jakkdl Date: Thu, 14 Nov 2024 15:13:32 +0100 Subject: [PATCH 141/445] remove incorrect comments, add link --- doc/en/deprecations.rst | 2 +- src/_pytest/compat.py | 1 - src/_pytest/fixtures.py | 2 -- testing/acceptance_test.py | 3 +-- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index 494bd88d282..88cf3eccbf3 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -71,7 +71,7 @@ should be changed to You can also make use of `pytest_fixture_setup` to handle the coroutine/asyncgen before pytest sees it - this is the way current async pytest plugins handle it. -If a user has an async fixture with ``autouse=True`` in their ``conftest.py``, or in a file where they also have synchronous tests, they will also get this warning. We strongly recommend against this practice, and they should restructure their testing infrastructure so the fixture is synchronous or to separate the fixture from their synchronous tests. Note that the anyio pytest plugin has some support for sync test + async fixtures currently. +If a user has an async fixture with ``autouse=True`` in their ``conftest.py``, or in a file where they also have synchronous tests, they will also get this warning. We strongly recommend against this practice, and they should restructure their testing infrastructure so the fixture is synchronous or to separate the fixture from their synchronous tests. Note that the `anyio pytest plugin `_ has some support for sync test + async fixtures currently. .. _import-or-skip-import-error: diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 64240135313..614848e0dba 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -44,7 +44,6 @@ class NotSetType(enum.Enum): def is_generator(func: object) -> bool: - # note: this also returns true for async generator functions genfunc = inspect.isgeneratorfunction(func) return genfunc and not iscoroutinefunction(func) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 0737773f047..95e4557fc8e 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -885,8 +885,6 @@ def call_fixture_func( fixturefunc: _FixtureFunc[FixtureValue], request: FixtureRequest, kwargs ) -> FixtureValue: if is_generator(fixturefunc): - # note: this also triggers on async generators, suppressing 'unawaited coroutine' - # warning. fixturefunc = cast( Callable[..., Generator[FixtureValue, None, None]], fixturefunc ) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index ca6df943afa..624a313ca8d 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1330,8 +1330,7 @@ async def async_fixture(): yield def test_foo(async_fixture): - # we don't need to suppress RuntimeWarning for unawaited coroutine - # as pytest internals accidentally do so already for async gens + # async gens don't emit unawaited-coroutine ... """ ) From d35e4ebad03a6f542304573b12e90848d2169c77 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Thu, 14 Nov 2024 15:16:28 +0100 Subject: [PATCH 142/445] revert now unrelated fix --- src/_pytest/fixtures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 95e4557fc8e..011dc8e6e3d 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -807,7 +807,7 @@ def formatrepr(self) -> FixtureLookupErrorRepr: stack = [self.request._pyfuncitem.obj] stack.extend(map(lambda x: x.func, self.fixturestack)) msg = self.msg - if msg is not None and len(stack) > 1: + if msg is not None: # The last fixture raise an error, let's present # it at the requesting side. stack = stack[:-1] From ef096cda884d9f001916336e7e8c543badeb191f Mon Sep 17 00:00:00 2001 From: jakkdl Date: Thu, 14 Nov 2024 15:19:38 +0100 Subject: [PATCH 143/445] small wording changes --- changelog/10839.deprecation.rst | 2 +- src/_pytest/fixtures.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog/10839.deprecation.rst b/changelog/10839.deprecation.rst index 01464ca0ba2..a3e2cbf51d0 100644 --- a/changelog/10839.deprecation.rst +++ b/changelog/10839.deprecation.rst @@ -1 +1 @@ -Requesting an asynchronous fixture without a `pytest_fixture_setup` to handle it will now give a DeprecationWarning. This most commonly happens if a sync test requests an async fixture. This should have no effect on a majority of users with async tests or fixtures, but may affect non-standard hook setups or ``autouse=True``. For guidance on how to work around this warning see :ref:`sync-test-async-fixture`. +Requesting an asynchronous fixture without a `pytest_fixture_setup` hook that resolves it will now give a DeprecationWarning. This most commonly happens if a sync test requests an async fixture. This should have no effect on a majority of users with async tests or fixtures using async pytest plugins, but may affect non-standard hook setups or ``autouse=True``. For guidance on how to work around this warning see :ref:`sync-test-async-fixture`. diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 011dc8e6e3d..b5c64856e12 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -961,7 +961,7 @@ def __init__( ids: tuple[object | None, ...] | Callable[[Any], object | None] | None = None, *, _ispytest: bool = False, - # only used to emit a deprecationwarning, can be removed in pytest9 + # only used in a deprecationwarning msg, can be removed in pytest9 _autouse: bool = False, ) -> None: check_ispytest(_ispytest) From 225d910cb68d109eabb6f6bc66ddd4946d9710a1 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Thu, 14 Nov 2024 15:28:42 +0100 Subject: [PATCH 144/445] add assertion to FixtureLookupError.formatrepr --- src/_pytest/fixtures.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 6b882fa3515..8f275e4d622 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -805,6 +805,15 @@ def formatrepr(self) -> FixtureLookupErrorRepr: stack = [self.request._pyfuncitem.obj] stack.extend(map(lambda x: x.func, self.fixturestack)) msg = self.msg + # This function currently makes an assumption that a non-None msg means we + # have a non-empty `self.fixturestack`. This is currently true, but if + # somebody at some point want to extend the use of FixtureLookupError to + # new cases it might break. + # Add the assert to make it clearer to developer that this will fail, otherwise + # it crashes because `fspath` does not get set due to `stack` being empty. + assert ( + self.msg is None or self.fixturestack + ), "formatrepr assumptions broken, rewrite it to handle it" if msg is not None: # The last fixture raise an error, let's present # it at the requesting side. From 52ee148b098a5e3f4cba6e4e5aac878c008f195c Mon Sep 17 00:00:00 2001 From: Gupta Arpit Date: Sat, 16 Nov 2024 22:26:53 +0530 Subject: [PATCH 145/445] Remove _pytest.compat.is_generator() fix #12960 --- changelog/12960.improvement.rst | 1 + src/_pytest/compat.py | 5 ----- src/_pytest/fixtures.py | 3 +-- src/_pytest/python.py | 3 +-- testing/test_compat.py | 23 ++++++++++++----------- 5 files changed, 15 insertions(+), 20 deletions(-) create mode 100644 changelog/12960.improvement.rst diff --git a/changelog/12960.improvement.rst b/changelog/12960.improvement.rst new file mode 100644 index 00000000000..11767e022db --- /dev/null +++ b/changelog/12960.improvement.rst @@ -0,0 +1 @@ +Removed _pytest.compat.is_generator() and just using inspect.isgeneratorfunction() directly \ No newline at end of file diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 614848e0dba..82aea5e635e 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -43,11 +43,6 @@ class NotSetType(enum.Enum): # fmt: on -def is_generator(func: object) -> bool: - genfunc = inspect.isgeneratorfunction(func) - return genfunc and not iscoroutinefunction(func) - - def iscoroutinefunction(func: object) -> bool: """Return True if func is a coroutine function (a function defined with async def syntax, and doesn't contain yield), or a function decorated with diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 8f275e4d622..6407ae0c48f 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -49,7 +49,6 @@ from _pytest.compat import getfuncargnames from _pytest.compat import getimfunc from _pytest.compat import getlocation -from _pytest.compat import is_generator from _pytest.compat import NOTSET from _pytest.compat import NotSetType from _pytest.compat import safe_getattr @@ -891,7 +890,7 @@ def toterminal(self, tw: TerminalWriter) -> None: def call_fixture_func( fixturefunc: _FixtureFunc[FixtureValue], request: FixtureRequest, kwargs ) -> FixtureValue: - if is_generator(fixturefunc): + if inspect.isgeneratorfunction(fixturefunc): fixturefunc = cast( Callable[..., Generator[FixtureValue, None, None]], fixturefunc ) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index d48a6c4a9fb..63d638e8a8c 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -43,7 +43,6 @@ from _pytest.compat import get_real_func from _pytest.compat import getimfunc from _pytest.compat import is_async_function -from _pytest.compat import is_generator from _pytest.compat import LEGACY_PATH from _pytest.compat import NOTSET from _pytest.compat import safe_getattr @@ -231,7 +230,7 @@ def pytest_pycollect_makeitem( lineno=lineno + 1, ) elif getattr(obj, "__test__", True): - if is_generator(obj): + if inspect.isgeneratorfunction(obj): res = Function.from_parent(collector, name=name) reason = ( f"yield tests were removed in pytest 4.0 - {name} will be ignored" diff --git a/testing/test_compat.py b/testing/test_compat.py index 2c6b0269c27..32a8b771e08 100644 --- a/testing/test_compat.py +++ b/testing/test_compat.py @@ -6,12 +6,12 @@ from functools import partial from functools import wraps import sys +import inspect from typing import TYPE_CHECKING from _pytest.compat import _PytestWrapper from _pytest.compat import assert_never from _pytest.compat import get_real_func -from _pytest.compat import is_generator from _pytest.compat import safe_getattr from _pytest.compat import safe_isclass from _pytest.outcomes import OutcomeException @@ -30,8 +30,8 @@ def zap(): def foo(): pass # pragma: no cover - assert is_generator(zap) - assert not is_generator(foo) + assert inspect.isgeneratorfunction(zap) + assert not inspect.isgeneratorfunction(foo) def test_real_func_loop_limit() -> None: @@ -99,14 +99,15 @@ def foo(x): def test_is_generator_asyncio(pytester: Pytester) -> None: pytester.makepyfile( """ - from _pytest.compat import is_generator import asyncio + import inspect + @asyncio.coroutine def baz(): yield from [1,2,3] def test_is_generator_asyncio(): - assert not is_generator(baz) + assert not inspect.isgeneratorfunction(baz) """ ) # avoid importing asyncio into pytest's own process, @@ -118,7 +119,7 @@ def test_is_generator_asyncio(): def test_is_generator_async_syntax(pytester: Pytester) -> None: pytester.makepyfile( """ - from _pytest.compat import is_generator + import inspect def test_is_generator_py35(): async def foo(): await foo() @@ -126,8 +127,8 @@ async def foo(): async def bar(): pass - assert not is_generator(foo) - assert not is_generator(bar) + assert not inspect.isgeneratorfunction(foo) + assert not inspect.isgeneratorfunction(bar) """ ) result = pytester.runpytest() @@ -137,7 +138,7 @@ async def bar(): def test_is_generator_async_gen_syntax(pytester: Pytester) -> None: pytester.makepyfile( """ - from _pytest.compat import is_generator + import inspect def test_is_generator(): async def foo(): yield @@ -146,8 +147,8 @@ async def foo(): async def bar(): yield - assert not is_generator(foo) - assert not is_generator(bar) + assert not inspect.isgeneratorfunction(foo) + assert not inspect.isgeneratorfunction(bar) """ ) result = pytester.runpytest() From 16cab96de4d1aed54cc4aefc120f7747942b6587 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 16 Nov 2024 16:57:24 +0000 Subject: [PATCH 146/445] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- changelog/12960.improvement.rst | 2 +- testing/test_compat.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog/12960.improvement.rst b/changelog/12960.improvement.rst index 11767e022db..ac9c9e431b1 100644 --- a/changelog/12960.improvement.rst +++ b/changelog/12960.improvement.rst @@ -1 +1 @@ -Removed _pytest.compat.is_generator() and just using inspect.isgeneratorfunction() directly \ No newline at end of file +Removed _pytest.compat.is_generator() and just using inspect.isgeneratorfunction() directly diff --git a/testing/test_compat.py b/testing/test_compat.py index 32a8b771e08..17f343ab5d2 100644 --- a/testing/test_compat.py +++ b/testing/test_compat.py @@ -5,8 +5,8 @@ from functools import cached_property from functools import partial from functools import wraps -import sys import inspect +import sys from typing import TYPE_CHECKING from _pytest.compat import _PytestWrapper From 71a35d4a3c8bf626cb73be0cb900ede18b1b123d Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Sat, 16 Nov 2024 19:57:06 +0100 Subject: [PATCH 147/445] Issue #12966 Clarify filterwarnings docs on precedence when using multiple marks (#12967) --- changelog/12966.doc.rst | 1 + doc/en/how-to/capture-warnings.rst | 33 +++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 changelog/12966.doc.rst diff --git a/changelog/12966.doc.rst b/changelog/12966.doc.rst new file mode 100644 index 00000000000..8a440c2ec0f --- /dev/null +++ b/changelog/12966.doc.rst @@ -0,0 +1 @@ +Clarify :ref:`filterwarnings` docs on filter precedence/order when using multiple :ref:`@pytest.mark.filterwarnings ` marks. diff --git a/doc/en/how-to/capture-warnings.rst b/doc/en/how-to/capture-warnings.rst index 44ed87508a3..65a43cec6e8 100644 --- a/doc/en/how-to/capture-warnings.rst +++ b/doc/en/how-to/capture-warnings.rst @@ -128,7 +128,7 @@ is performed. -You can use the ``@pytest.mark.filterwarnings`` to add warning filters to specific test items, +You can use the :ref:`@pytest.mark.filterwarnings ` mark to add warning filters to specific test items, allowing you to have finer control of which warnings should be captured at test, class or even module level: @@ -147,10 +147,30 @@ even module level: assert api_v1() == 1 +You can specify multiple filters with separate decorators: + +.. code-block:: python + + # Ignore "api v1" warnings, but fail on all other warnings + @pytest.mark.filterwarnings("ignore:api v1") + @pytest.mark.filterwarnings("error") + def test_one(): + assert api_v1() == 1 + +.. important:: + + Regarding decorator order and filter precedence: + it's important to remember that decorators are evaluated in reverse order, + so you have to list the warning filters in the reverse order + compared to traditional :py:func:`warnings.filterwarnings` and :option:`-W option ` usage. + This means in practice that filters from earlier :ref:`@pytest.mark.filterwarnings ` decorators + take precedence over filters from later decorators, as illustrated in the example above. + + Filters applied using a mark take precedence over filters passed on the command line or configured -by the ``filterwarnings`` ini option. +by the :confval:`filterwarnings` ini option. -You may apply a filter to all tests of a class by using the ``filterwarnings`` mark as a class +You may apply a filter to all tests of a class by using the :ref:`filterwarnings ` mark as a class decorator or to all tests in a module by setting the :globalvar:`pytestmark` variable: .. code-block:: python @@ -159,6 +179,13 @@ decorator or to all tests in a module by setting the :globalvar:`pytestmark` var pytestmark = pytest.mark.filterwarnings("error") +.. note:: + + If you want to apply multiple filters + (by assigning a list of :ref:`filterwarnings ` mark to :globalvar:`pytestmark`), + you must use the traditional :py:func:`warnings.filterwarnings` ordering approach (later filters take precedence), + which is the reverse of the decorator approach mentioned above. + *Credits go to Florian Schulze for the reference implementation in the* `pytest-warnings`_ *plugin.* From a44da2d1282baa8c8687cb2325d81693eee6c777 Mon Sep 17 00:00:00 2001 From: Gupta Arpit Date: Sun, 17 Nov 2024 01:33:53 +0530 Subject: [PATCH 148/445] Added suggested changes --- src/_pytest/python.py | 6 ++---- testing/test_compat.py | 39 --------------------------------------- 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 63d638e8a8c..bae770e2062 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -231,15 +231,13 @@ def pytest_pycollect_makeitem( ) elif getattr(obj, "__test__", True): if inspect.isgeneratorfunction(obj): - res = Function.from_parent(collector, name=name) reason = ( f"yield tests were removed in pytest 4.0 - {name} will be ignored" ) - res.add_marker(MARK_GEN.xfail(run=False, reason=reason)) - res.warn(PytestCollectionWarning(reason)) - return res + raise RuntimeError(reason) # Raise a hard error instead of xfail else: return list(collector._genfunctions(name, obj)) + return None return None diff --git a/testing/test_compat.py b/testing/test_compat.py index 17f343ab5d2..65c4b10ff7f 100644 --- a/testing/test_compat.py +++ b/testing/test_compat.py @@ -116,45 +116,6 @@ def test_is_generator_asyncio(): result.stdout.fnmatch_lines(["*1 passed*"]) -def test_is_generator_async_syntax(pytester: Pytester) -> None: - pytester.makepyfile( - """ - import inspect - def test_is_generator_py35(): - async def foo(): - await foo() - - async def bar(): - pass - - assert not inspect.isgeneratorfunction(foo) - assert not inspect.isgeneratorfunction(bar) - """ - ) - result = pytester.runpytest() - result.stdout.fnmatch_lines(["*1 passed*"]) - - -def test_is_generator_async_gen_syntax(pytester: Pytester) -> None: - pytester.makepyfile( - """ - import inspect - def test_is_generator(): - async def foo(): - yield - await foo() - - async def bar(): - yield - - assert not inspect.isgeneratorfunction(foo) - assert not inspect.isgeneratorfunction(bar) - """ - ) - result = pytester.runpytest() - result.stdout.fnmatch_lines(["*1 passed*"]) - - class ErrorsHelper: @property def raise_baseexception(self): From 526529a85fbee376de740c76a1397ac43f0a6ab2 Mon Sep 17 00:00:00 2001 From: Gupta Arpit Date: Sat, 16 Nov 2024 22:26:53 +0530 Subject: [PATCH 149/445] Remove _pytest.compat.is_generator() fix #12960 --- changelog/12960.improvement.rst | 1 + src/_pytest/compat.py | 5 ----- src/_pytest/fixtures.py | 3 +-- src/_pytest/python.py | 3 +-- testing/test_compat.py | 23 ++++++++++++----------- 5 files changed, 15 insertions(+), 20 deletions(-) create mode 100644 changelog/12960.improvement.rst diff --git a/changelog/12960.improvement.rst b/changelog/12960.improvement.rst new file mode 100644 index 00000000000..11767e022db --- /dev/null +++ b/changelog/12960.improvement.rst @@ -0,0 +1 @@ +Removed _pytest.compat.is_generator() and just using inspect.isgeneratorfunction() directly \ No newline at end of file diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 614848e0dba..82aea5e635e 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -43,11 +43,6 @@ class NotSetType(enum.Enum): # fmt: on -def is_generator(func: object) -> bool: - genfunc = inspect.isgeneratorfunction(func) - return genfunc and not iscoroutinefunction(func) - - def iscoroutinefunction(func: object) -> bool: """Return True if func is a coroutine function (a function defined with async def syntax, and doesn't contain yield), or a function decorated with diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 8f275e4d622..6407ae0c48f 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -49,7 +49,6 @@ from _pytest.compat import getfuncargnames from _pytest.compat import getimfunc from _pytest.compat import getlocation -from _pytest.compat import is_generator from _pytest.compat import NOTSET from _pytest.compat import NotSetType from _pytest.compat import safe_getattr @@ -891,7 +890,7 @@ def toterminal(self, tw: TerminalWriter) -> None: def call_fixture_func( fixturefunc: _FixtureFunc[FixtureValue], request: FixtureRequest, kwargs ) -> FixtureValue: - if is_generator(fixturefunc): + if inspect.isgeneratorfunction(fixturefunc): fixturefunc = cast( Callable[..., Generator[FixtureValue, None, None]], fixturefunc ) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index d48a6c4a9fb..63d638e8a8c 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -43,7 +43,6 @@ from _pytest.compat import get_real_func from _pytest.compat import getimfunc from _pytest.compat import is_async_function -from _pytest.compat import is_generator from _pytest.compat import LEGACY_PATH from _pytest.compat import NOTSET from _pytest.compat import safe_getattr @@ -231,7 +230,7 @@ def pytest_pycollect_makeitem( lineno=lineno + 1, ) elif getattr(obj, "__test__", True): - if is_generator(obj): + if inspect.isgeneratorfunction(obj): res = Function.from_parent(collector, name=name) reason = ( f"yield tests were removed in pytest 4.0 - {name} will be ignored" diff --git a/testing/test_compat.py b/testing/test_compat.py index 2c6b0269c27..32a8b771e08 100644 --- a/testing/test_compat.py +++ b/testing/test_compat.py @@ -6,12 +6,12 @@ from functools import partial from functools import wraps import sys +import inspect from typing import TYPE_CHECKING from _pytest.compat import _PytestWrapper from _pytest.compat import assert_never from _pytest.compat import get_real_func -from _pytest.compat import is_generator from _pytest.compat import safe_getattr from _pytest.compat import safe_isclass from _pytest.outcomes import OutcomeException @@ -30,8 +30,8 @@ def zap(): def foo(): pass # pragma: no cover - assert is_generator(zap) - assert not is_generator(foo) + assert inspect.isgeneratorfunction(zap) + assert not inspect.isgeneratorfunction(foo) def test_real_func_loop_limit() -> None: @@ -99,14 +99,15 @@ def foo(x): def test_is_generator_asyncio(pytester: Pytester) -> None: pytester.makepyfile( """ - from _pytest.compat import is_generator import asyncio + import inspect + @asyncio.coroutine def baz(): yield from [1,2,3] def test_is_generator_asyncio(): - assert not is_generator(baz) + assert not inspect.isgeneratorfunction(baz) """ ) # avoid importing asyncio into pytest's own process, @@ -118,7 +119,7 @@ def test_is_generator_asyncio(): def test_is_generator_async_syntax(pytester: Pytester) -> None: pytester.makepyfile( """ - from _pytest.compat import is_generator + import inspect def test_is_generator_py35(): async def foo(): await foo() @@ -126,8 +127,8 @@ async def foo(): async def bar(): pass - assert not is_generator(foo) - assert not is_generator(bar) + assert not inspect.isgeneratorfunction(foo) + assert not inspect.isgeneratorfunction(bar) """ ) result = pytester.runpytest() @@ -137,7 +138,7 @@ async def bar(): def test_is_generator_async_gen_syntax(pytester: Pytester) -> None: pytester.makepyfile( """ - from _pytest.compat import is_generator + import inspect def test_is_generator(): async def foo(): yield @@ -146,8 +147,8 @@ async def foo(): async def bar(): yield - assert not is_generator(foo) - assert not is_generator(bar) + assert not inspect.isgeneratorfunction(foo) + assert not inspect.isgeneratorfunction(bar) """ ) result = pytester.runpytest() From 42cd2965e59b110419e2f6ac91e35bcdfdb3e6a8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 16 Nov 2024 16:57:24 +0000 Subject: [PATCH 150/445] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- changelog/12960.improvement.rst | 2 +- testing/test_compat.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog/12960.improvement.rst b/changelog/12960.improvement.rst index 11767e022db..ac9c9e431b1 100644 --- a/changelog/12960.improvement.rst +++ b/changelog/12960.improvement.rst @@ -1 +1 @@ -Removed _pytest.compat.is_generator() and just using inspect.isgeneratorfunction() directly \ No newline at end of file +Removed _pytest.compat.is_generator() and just using inspect.isgeneratorfunction() directly diff --git a/testing/test_compat.py b/testing/test_compat.py index 32a8b771e08..17f343ab5d2 100644 --- a/testing/test_compat.py +++ b/testing/test_compat.py @@ -5,8 +5,8 @@ from functools import cached_property from functools import partial from functools import wraps -import sys import inspect +import sys from typing import TYPE_CHECKING from _pytest.compat import _PytestWrapper From 38a241671ccd56e6c6ff131f8e85bb5ef82fc701 Mon Sep 17 00:00:00 2001 From: Gupta Arpit Date: Sun, 17 Nov 2024 01:33:53 +0530 Subject: [PATCH 151/445] Added suggested changes --- src/_pytest/python.py | 6 ++---- testing/test_compat.py | 39 --------------------------------------- 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 63d638e8a8c..bae770e2062 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -231,15 +231,13 @@ def pytest_pycollect_makeitem( ) elif getattr(obj, "__test__", True): if inspect.isgeneratorfunction(obj): - res = Function.from_parent(collector, name=name) reason = ( f"yield tests were removed in pytest 4.0 - {name} will be ignored" ) - res.add_marker(MARK_GEN.xfail(run=False, reason=reason)) - res.warn(PytestCollectionWarning(reason)) - return res + raise RuntimeError(reason) # Raise a hard error instead of xfail else: return list(collector._genfunctions(name, obj)) + return None return None diff --git a/testing/test_compat.py b/testing/test_compat.py index 17f343ab5d2..65c4b10ff7f 100644 --- a/testing/test_compat.py +++ b/testing/test_compat.py @@ -116,45 +116,6 @@ def test_is_generator_asyncio(): result.stdout.fnmatch_lines(["*1 passed*"]) -def test_is_generator_async_syntax(pytester: Pytester) -> None: - pytester.makepyfile( - """ - import inspect - def test_is_generator_py35(): - async def foo(): - await foo() - - async def bar(): - pass - - assert not inspect.isgeneratorfunction(foo) - assert not inspect.isgeneratorfunction(bar) - """ - ) - result = pytester.runpytest() - result.stdout.fnmatch_lines(["*1 passed*"]) - - -def test_is_generator_async_gen_syntax(pytester: Pytester) -> None: - pytester.makepyfile( - """ - import inspect - def test_is_generator(): - async def foo(): - yield - await foo() - - async def bar(): - yield - - assert not inspect.isgeneratorfunction(foo) - assert not inspect.isgeneratorfunction(bar) - """ - ) - result = pytester.runpytest() - result.stdout.fnmatch_lines(["*1 passed*"]) - - class ErrorsHelper: @property def raise_baseexception(self): From ecc26e04f41d9c60f94cc80d0b2f0c6cd77117dd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 16 Nov 2024 20:04:32 +0000 Subject: [PATCH 152/445] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/_pytest/python.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index bae770e2062..23b65765a53 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -56,7 +56,6 @@ from _pytest.fixtures import FuncFixtureInfo from _pytest.fixtures import get_scope_node from _pytest.main import Session -from _pytest.mark import MARK_GEN from _pytest.mark import ParameterSet from _pytest.mark.structures import get_unpacked_marks from _pytest.mark.structures import Mark From 3ab4a77606652a4aa11f2ffba8dedf84b3474d99 Mon Sep 17 00:00:00 2001 From: Arpit Gupta <113178590+arpitgupta-it@users.noreply.github.com> Date: Sun, 17 Nov 2024 01:50:30 +0530 Subject: [PATCH 153/445] Removed stdlib tests as per review --- testing/test_compat.py | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/testing/test_compat.py b/testing/test_compat.py index 65c4b10ff7f..07c28cebdd1 100644 --- a/testing/test_compat.py +++ b/testing/test_compat.py @@ -23,17 +23,6 @@ from typing_extensions import Literal -def test_is_generator() -> None: - def zap(): - yield # pragma: no cover - - def foo(): - pass # pragma: no cover - - assert inspect.isgeneratorfunction(zap) - assert not inspect.isgeneratorfunction(foo) - - def test_real_func_loop_limit() -> None: class Evil: def __init__(self): @@ -95,27 +84,6 @@ def foo(x): assert get_real_func(partial(foo)) is foo -@pytest.mark.skipif(sys.version_info >= (3, 11), reason="coroutine removed") -def test_is_generator_asyncio(pytester: Pytester) -> None: - pytester.makepyfile( - """ - import asyncio - import inspect - - @asyncio.coroutine - def baz(): - yield from [1,2,3] - - def test_is_generator_asyncio(): - assert not inspect.isgeneratorfunction(baz) - """ - ) - # avoid importing asyncio into pytest's own process, - # which in turn imports logging (#8) - result = pytester.runpytest_subprocess() - result.stdout.fnmatch_lines(["*1 passed*"]) - - class ErrorsHelper: @property def raise_baseexception(self): From 362a2179305139b3c877f0c2b2ed004a2f8ecf09 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 16 Nov 2024 20:20:49 +0000 Subject: [PATCH 154/445] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- testing/test_compat.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/testing/test_compat.py b/testing/test_compat.py index 07c28cebdd1..86868858956 100644 --- a/testing/test_compat.py +++ b/testing/test_compat.py @@ -5,8 +5,6 @@ from functools import cached_property from functools import partial from functools import wraps -import inspect -import sys from typing import TYPE_CHECKING from _pytest.compat import _PytestWrapper @@ -15,7 +13,6 @@ from _pytest.compat import safe_getattr from _pytest.compat import safe_isclass from _pytest.outcomes import OutcomeException -from _pytest.pytester import Pytester import pytest From 8691ff1f368620c112983a5ef7c5ad82b46d9d34 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 17 Nov 2024 03:25:38 +0000 Subject: [PATCH 155/445] [automated] Update plugin list (#12970) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 166 +++++++++++++++++++------------ 1 file changed, 103 insertions(+), 63 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index ecd96b89967..ee0981e3694 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,14 +27,14 @@ please refer to `the update script =8.3 + :pypi:`databricks-labs-pytester` Python Testing for Databricks Nov 15, 2024 4 - Beta pytest>=8.3 :pypi:`logassert` Simple but powerful assertion and verification of logged lines. Nov 08, 2024 5 - Production/Stable N/A :pypi:`logot` Test whether your code is logging correctly 🪵 Mar 23, 2024 5 - Production/Stable pytest<9,>=7; extra == "pytest" :pypi:`nuts` Network Unit Testing System Jul 19, 2024 N/A pytest<8,>=7 @@ -148,7 +148,7 @@ This list contains 1540 plugins. :pypi:`pytest-base-url` pytest plugin for URL based testing Jan 31, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-batch-regression` A pytest plugin to repeat the entire test suite in batches. May 08, 2024 N/A pytest>=6.0.0 :pypi:`pytest-bazel` A pytest runner with bazel support Sep 27, 2024 4 - Beta pytest - :pypi:`pytest-bdd` BDD for pytest Oct 15, 2024 6 - Mature pytest>=6.2.0 + :pypi:`pytest-bdd` BDD for pytest Nov 14, 2024 6 - Mature pytest>=7.0.0 :pypi:`pytest-bdd-html` pytest plugin to display BDD info in HTML test report Nov 22, 2022 3 - Alpha pytest (!=6.0.0,>=5.0) :pypi:`pytest-bdd-ng` BDD for pytest Oct 07, 2024 4 - Beta pytest>=5.0 :pypi:`pytest-bdd-report` A pytest-bdd plugin for generating useful and informative BDD test reports Aug 26, 2024 N/A pytest>=7.1.3 @@ -157,7 +157,7 @@ This list contains 1540 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Nov 05, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Nov 11, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -243,6 +243,7 @@ This list contains 1540 plugins. :pypi:`pytest-circleci-parallelized-rjp` Parallelize pytest across CircleCI workers. Jun 21, 2022 N/A pytest :pypi:`pytest-ckan` Backport of CKAN 2.9 pytest plugin and fixtures to CAKN 2.8 Apr 28, 2020 4 - Beta pytest :pypi:`pytest-clarity` A plugin providing an alternative, colourful diff output for failing assertions. Jun 11, 2021 N/A N/A + :pypi:`pytest-class-fixtures` Class as PyTest fixtures (and BDD steps) Nov 15, 2024 N/A pytest<9.0.0,>=8.3.3 :pypi:`pytest-cldf` Easy quality control for CLDF datasets using pytest Nov 07, 2022 N/A pytest (>=3.6) :pypi:`pytest-cleanslate` Collects and executes pytest tests separately Sep 04, 2024 N/A pytest :pypi:`pytest_cleanup` Automated, comprehensive and well-organised pytest test cases. Jan 28, 2020 N/A N/A @@ -352,11 +353,12 @@ This list contains 1540 plugins. :pypi:`pytest-deadfixtures` A simple plugin to list unused fixtures in pytest Jul 23, 2020 5 - Production/Stable N/A :pypi:`pytest-deduplicate` Identifies duplicate unit tests Aug 12, 2023 4 - Beta pytest :pypi:`pytest-deepcov` deepcov Mar 30, 2021 N/A N/A - :pypi:`pytest-defer` Aug 24, 2021 N/A N/A + :pypi:`pytest_defer` A 'defer' fixture for pytest Nov 13, 2024 N/A pytest>=8.3 :pypi:`pytest-demo-plugin` pytest示例插件 May 15, 2021 N/A N/A :pypi:`pytest-dependency` Manage dependencies of tests Dec 31, 2023 4 - Beta N/A :pypi:`pytest-depends` Tests that depend on other tests Apr 05, 2020 5 - Production/Stable pytest (>=3) :pypi:`pytest-deprecate` Mark tests as testing a deprecated feature with a warning note. Jul 01, 2019 N/A N/A + :pypi:`pytest-deprecator` A simple plugin to use with pytest Nov 14, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-describe` Describe-style plugin for pytest Feb 10, 2024 5 - Production/Stable pytest <9,>=4.6 :pypi:`pytest-describe-it` plugin for rich text descriptions Jul 19, 2019 4 - Beta pytest :pypi:`pytest-deselect-if` A plugin to deselect pytests tests rather than using skipif Mar 24, 2024 4 - Beta pytest>=6.2.0 @@ -465,14 +467,15 @@ This list contains 1540 plugins. :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Oct 29, 2024 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Oct 29, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Oct 29, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Oct 29, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Oct 29, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Oct 29, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Oct 29, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Oct 29, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Nov 14, 2024 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Nov 14, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Nov 14, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Nov 14, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Nov 14, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Nov 14, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Nov 14, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Nov 14, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Nov 14, 2024 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -499,7 +502,7 @@ This list contains 1540 plugins. :pypi:`pytest-eventlet` Applies eventlet monkey-patch as a pytest plugin. Oct 04, 2021 N/A pytest ; extra == 'dev' :pypi:`pytest_evm` The testing package containing tools to test Web3-based projects Sep 23, 2024 4 - Beta pytest<9.0.0,>=8.1.1 :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A - :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Aug 13, 2024 4 - Beta pytest>=7 + :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Nov 15, 2024 N/A pytest>=7 :pypi:`pytest-exasol-backend` Oct 31, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-extension` Oct 10, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-itde` Jul 01, 2024 N/A pytest<9,>=7 @@ -601,7 +604,7 @@ This list contains 1540 plugins. :pypi:`pytest-frozen-uuids` Deterministically frozen UUID's for your tests Apr 17, 2022 N/A pytest (>=3.0) :pypi:`pytest-func-cov` Pytest plugin for measuring function coverage Apr 15, 2021 3 - Alpha pytest (>=5) :pypi:`pytest-funparam` An alternative way to parametrize test cases. Dec 02, 2021 4 - Beta pytest >=4.6.0 - :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Nov 07, 2024 N/A pytest + :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Nov 16, 2024 N/A pytest :pypi:`pytest-fxa` pytest plugin for Firefox Accounts Aug 28, 2018 5 - Production/Stable N/A :pypi:`pytest-fxa-mte` pytest plugin for Firefox Accounts Oct 02, 2024 5 - Production/Stable N/A :pypi:`pytest-fxtest` Oct 27, 2020 N/A N/A @@ -611,7 +614,7 @@ This list contains 1540 plugins. :pypi:`pytest-gc` The garbage collector plugin for py.test Feb 01, 2018 N/A N/A :pypi:`pytest-gcov` Uses gcov to measure test coverage of a C library Feb 01, 2018 3 - Alpha N/A :pypi:`pytest-gcs` GCS fixtures and fixture factories for Pytest. Mar 01, 2024 5 - Production/Stable pytest >=6.2 - :pypi:`pytest-gee` The Python plugin for your GEE based packages. Jun 30, 2024 3 - Alpha pytest + :pypi:`pytest-gee` The Python plugin for your GEE based packages. Nov 14, 2024 3 - Alpha pytest :pypi:`pytest-gevent` Ensure that gevent is properly patched when invoking pytest Feb 25, 2020 N/A pytest :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest @@ -660,7 +663,7 @@ This list contains 1540 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Nov 09, 2024 3 - Alpha pytest==8.3.3 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Nov 16, 2024 3 - Alpha pytest==8.3.3 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -738,7 +741,7 @@ This list contains 1540 plugins. :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Sep 18, 2024 4 - Beta pytest>=5 :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-it` Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it. Jan 29, 2024 4 - Beta N/A - :pypi:`pytest-item-dict` Get a hierarchical dict of session.items Oct 30, 2024 4 - Beta pytest>=8.3.0 + :pypi:`pytest-item-dict` Get a hierarchical dict of session.items Nov 14, 2024 4 - Beta pytest>=8.3.0 :pypi:`pytest-iterassert` Nicer list and iterable assertion messages for pytest May 11, 2020 3 - Alpha N/A :pypi:`pytest-iteration` Add iteration mark for tests Aug 22, 2024 N/A pytest :pypi:`pytest-iters` A contextmanager pytest fixture for handling multiple mock iters May 24, 2022 N/A N/A @@ -826,7 +829,7 @@ This list contains 1540 plugins. :pypi:`pytest-loop` pytest plugin for looping tests Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-lsp` A pytest plugin for end-to-end testing of language servers Sep 04, 2024 3 - Alpha pytest :pypi:`pytest-manual-marker` pytest marker for marking manual tests Aug 04, 2022 3 - Alpha pytest>=7 - :pypi:`pytest-mark-count` Get a count of the number of tests marked, unmarked, and unique tests if tests have multiple markers Oct 18, 2024 4 - Beta pytest>=8.0.0 + :pypi:`pytest-mark-count` Get a count of the number of tests marked, unmarked, and unique tests if tests have multiple markers Nov 13, 2024 4 - Beta pytest>=8.0.0 :pypi:`pytest-markdoctest` A pytest plugin to doctest your markdown files Jul 22, 2022 4 - Beta pytest (>=6) :pypi:`pytest-markdown` Test your markdown docs with pytest Jan 15, 2021 4 - Beta pytest (>=6.0.1,<7.0.0) :pypi:`pytest-markdown-docs` Run markdown code fences through pytest Oct 22, 2024 N/A pytest>=7.0.0 @@ -867,7 +870,7 @@ This list contains 1540 plugins. :pypi:`pytest-minio-mock` A pytest plugin for mocking Minio S3 interactions Aug 27, 2024 N/A pytest>=5.0.0 :pypi:`pytest-missing-fixtures` Pytest plugin that creates missing fixtures Oct 14, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-missing-modules` Pytest plugin to easily fake missing modules Sep 03, 2024 N/A pytest>=8.3.2 - :pypi:`pytest-mitmproxy` pytest plugin for mitmproxy tests Sep 12, 2024 N/A pytest>=7.0 + :pypi:`pytest-mitmproxy` pytest plugin for mitmproxy tests Nov 13, 2024 N/A pytest>=7.0 :pypi:`pytest-ml` Test your machine learning! May 04, 2019 4 - Beta N/A :pypi:`pytest-mocha` pytest plugin to display test execution output like a mochajs Apr 02, 2020 4 - Beta pytest (>=5.4.0) :pypi:`pytest-mock` Thin-wrapper around the mock package for easier use with pytest Mar 21, 2024 5 - Production/Stable pytest>=6.2.5 @@ -979,7 +982,7 @@ This list contains 1540 plugins. :pypi:`pytest-param` pytest plugin to test all, first, last or random params Sep 11, 2016 4 - Beta pytest (>=2.6.0) :pypi:`pytest-paramark` Configure pytest fixtures using a combination of"parametrize" and markers Jan 10, 2020 4 - Beta pytest (>=4.5.0) :pypi:`pytest-parametrization` Simpler PyTest parametrization May 22, 2022 5 - Production/Stable N/A - :pypi:`pytest-parametrize` pytest decorator for parametrizing test cases in a dict-way Oct 30, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.0 + :pypi:`pytest-parametrize` pytest decorator for parametrizing test cases in a dict-way Nov 10, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.0 :pypi:`pytest-parametrize-cases` A more user-friendly way to write parametrized tests. Mar 13, 2022 N/A pytest (>=6.1.2) :pypi:`pytest-parametrized` Pytest decorator for parametrizing tests with default iterables. Oct 22, 2024 5 - Production/Stable pytest :pypi:`pytest-parametrize-suite` A simple pytest extension for creating a named test suite. Jan 19, 2023 5 - Production/Stable pytest @@ -1098,7 +1101,7 @@ This list contains 1540 plugins. :pypi:`pytest-pyvenv` A package for create venv in tests Feb 27, 2024 N/A pytest ; extra == 'test' :pypi:`pytest-pyvista` Pytest-pyvista package Sep 29, 2023 4 - Beta pytest>=3.5.0 :pypi:`pytest-qanova` A pytest plugin to collect test information Sep 05, 2024 3 - Alpha pytest - :pypi:`pytest-qaseio` Pytest plugin for Qase.io integration Oct 28, 2024 5 - Production/Stable pytest<9.0.0,>=7.2.2 + :pypi:`pytest-qaseio` Pytest plugin for Qase.io integration Nov 15, 2024 5 - Production/Stable pytest<9.0.0,>=7.2.2 :pypi:`pytest-qasync` Pytest support for qasync. Jul 12, 2021 4 - Beta pytest (>=5.4.0) :pypi:`pytest-qatouch` Pytest plugin for uploading test results to your QA Touch Testrun. Feb 14, 2023 4 - Beta pytest (>=6.2.0) :pypi:`pytest-qgis` A pytest plugin for testing QGIS python plugins Jun 14, 2024 5 - Production/Stable pytest>=6.0 @@ -1137,7 +1140,7 @@ This list contains 1540 plugins. :pypi:`pytest-regex` Select pytest tests with regular expressions May 29, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-regex-dependency` Management of Pytest dependencies via regex patterns Jun 12, 2022 N/A pytest :pypi:`pytest-regressions` Easy to use fixtures to write regression tests. Aug 31, 2023 5 - Production/Stable pytest >=6.2.0 - :pypi:`pytest-regtest` pytest plugin for snapshot regression testing Oct 17, 2024 N/A pytest>7.2 + :pypi:`pytest-regtest` pytest plugin for snapshot regression testing Nov 12, 2024 N/A pytest>7.2 :pypi:`pytest-relative-order` a pytest plugin that sorts tests using "before" and "after" markers May 17, 2021 4 - Beta N/A :pypi:`pytest-relative-path` Handle relative path in pytest options or ini configs Aug 30, 2024 N/A pytest :pypi:`pytest-relaxed` Relaxed test discovery/organization for pytest Mar 29, 2024 5 - Production/Stable pytest>=7 @@ -1209,7 +1212,7 @@ This list contains 1540 plugins. :pypi:`pytest-ruff` pytest plugin to check ruff requirements. Jul 21, 2024 4 - Beta pytest>=5 :pypi:`pytest-run-changed` Pytest plugin that runs changed tests only Apr 02, 2021 3 - Alpha pytest :pypi:`pytest-runfailed` implement a --failed option for pytest Mar 24, 2016 N/A N/A - :pypi:`pytest-run-parallel` A simple pytest plugin to run tests concurrently Sep 30, 2024 4 - Beta pytest>=6.2.0 + :pypi:`pytest-run-parallel` A simple pytest plugin to run tests concurrently Nov 13, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-run-subprocess` Pytest Plugin for running and testing subprocesses. Nov 12, 2022 5 - Production/Stable pytest :pypi:`pytest-runtime-types` Checks type annotations on runtime while running tests. Feb 09, 2023 N/A pytest :pypi:`pytest-runtime-xfail` Call runtime_xfail() to mark running test as xfail. Aug 26, 2021 N/A pytest>=5.0.0 @@ -1225,7 +1228,7 @@ This list contains 1540 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Nov 09, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Nov 15, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1236,7 +1239,7 @@ This list contains 1540 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Nov 09, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Nov 15, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1246,7 +1249,7 @@ This list contains 1540 plugins. :pypi:`pytest-server` test server exec cmd Sep 09, 2024 N/A N/A :pypi:`pytest-server-fixtures` Extensible server fixtures for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-serverless` Automatically mocks resources from serverless.yml in pytest using moto. May 09, 2022 4 - Beta N/A - :pypi:`pytest-servers` pytest servers Sep 17, 2024 3 - Alpha pytest>=6.2 + :pypi:`pytest-servers` pytest servers Nov 14, 2024 3 - Alpha pytest>=6.2 :pypi:`pytest-service` Aug 06, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-services` Services plugin for pytest testing framework Oct 30, 2020 6 - Mature N/A :pypi:`pytest-session2file` pytest-session2file (aka: pytest-session_to_file for v0.1.0 - v0.1.2) is a py.test plugin for capturing and saving to file the stdout of py.test. Jan 26, 2021 3 - Alpha pytest @@ -1289,6 +1292,7 @@ This list contains 1540 plugins. :pypi:`pytest-smtp-test-server` pytest plugin for using \`smtp-test-server\` as a fixture Dec 03, 2023 2 - Pre-Alpha pytest (>=7.4.3,<8.0.0) :pypi:`pytest-snail` Plugin for adding a marker to slow running tests. 🐌 Nov 04, 2019 3 - Alpha pytest (>=5.0.1) :pypi:`pytest-snapci` py.test plugin for Snap-CI Nov 12, 2015 N/A N/A + :pypi:`pytest-snapmock` Snapshots for your mocks. Nov 15, 2024 N/A N/A :pypi:`pytest-snapshot` A plugin for snapshot testing with pytest. Apr 23, 2022 4 - Beta pytest (>=3.0.0) :pypi:`pytest-snapshot-with-message-generator` A plugin for snapshot testing with pytest. Jul 25, 2023 4 - Beta pytest (>=3.0.0) :pypi:`pytest-snmpserver` May 12, 2021 N/A N/A @@ -1383,7 +1387,7 @@ This list contains 1540 plugins. :pypi:`pytest-testdirectory` A py.test plugin providing temporary directories in unit tests. May 02, 2023 5 - Production/Stable pytest :pypi:`pytest-testdox` A testdox format reporter for pytest Jul 22, 2023 5 - Production/Stable pytest (>=4.6.0) :pypi:`pytest-test-grouping` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Feb 01, 2023 5 - Production/Stable pytest (>=2.5) - :pypi:`pytest-test-groups` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Oct 25, 2016 5 - Production/Stable N/A + :pypi:`pytest-test-groups` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Nov 14, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-testinfra` Test infrastructures May 26, 2024 5 - Production/Stable pytest>=6 :pypi:`pytest-testinfra-jpic` Test infrastructures Sep 21, 2023 5 - Production/Stable N/A :pypi:`pytest-testinfra-winrm-transport` Test infrastructures Sep 21, 2023 5 - Production/Stable N/A @@ -1412,7 +1416,7 @@ This list contains 1540 plugins. :pypi:`pytest-test-tracer-for-pytest` A plugin that allows coll test data for use on Test Tracer Jun 28, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-test-tracer-for-pytest-bdd` A plugin that allows coll test data for use on Test Tracer Aug 20, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-test-utils` Feb 08, 2024 N/A pytest >=3.9 - :pypi:`pytest-tesults` Tesults plugin for pytest Sep 09, 2024 5 - Production/Stable pytest>=3.5.0 + :pypi:`pytest-tesults` Tesults plugin for pytest Nov 12, 2024 5 - Production/Stable pytest>=3.5.0 :pypi:`pytest-textual-snapshot` Snapshot testing for Textual apps Jul 22, 2024 4 - Beta pytest>=8.0.0 :pypi:`pytest-tezos` pytest-ligo Jan 16, 2020 4 - Beta N/A :pypi:`pytest-tf` Test your OpenTofu and Terraform config using a PyTest plugin May 29, 2024 N/A pytest<9.0.0,>=8.2.1 @@ -1542,6 +1546,7 @@ This list contains 1540 plugins. :pypi:`pytest-xiuyu` This is a pytest plugin Jul 25, 2023 5 - Production/Stable N/A :pypi:`pytest-xlog` Extended logging for test and decorators May 31, 2020 4 - Beta N/A :pypi:`pytest-xlsx` pytest plugin for generating test cases by xlsx(excel) Aug 07, 2024 N/A pytest~=8.2.2 + :pypi:`pytest-xml` Create simple XML results for parsing Nov 14, 2024 4 - Beta pytest>=8.0.0 :pypi:`pytest-xpara` An extended parametrizing plugin of pytest. Aug 07, 2024 3 - Alpha pytest :pypi:`pytest-xprocess` A pytest plugin for managing processes across test runs. May 19, 2024 4 - Beta pytest>=2.8 :pypi:`pytest-xray` May 30, 2019 3 - Alpha N/A @@ -1580,7 +1585,7 @@ This list contains 1540 plugins. :pypi:`databricks-labs-pytester` - *last release*: Nov 04, 2024, + *last release*: Nov 15, 2024, *status*: 4 - Beta, *requires*: pytest>=8.3 @@ -2378,9 +2383,9 @@ This list contains 1540 plugins. A pytest runner with bazel support :pypi:`pytest-bdd` - *last release*: Oct 15, 2024, + *last release*: Nov 14, 2024, *status*: 6 - Mature, - *requires*: pytest>=6.2.0 + *requires*: pytest>=7.0.0 BDD for pytest @@ -2441,7 +2446,7 @@ This list contains 1540 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Nov 05, 2024, + *last release*: Nov 11, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -3042,6 +3047,13 @@ This list contains 1540 plugins. A plugin providing an alternative, colourful diff output for failing assertions. + :pypi:`pytest-class-fixtures` + *last release*: Nov 15, 2024, + *status*: N/A, + *requires*: pytest<9.0.0,>=8.3.3 + + Class as PyTest fixtures (and BDD steps) + :pypi:`pytest-cldf` *last release*: Nov 07, 2022, *status*: N/A, @@ -3805,12 +3817,12 @@ This list contains 1540 plugins. deepcov - :pypi:`pytest-defer` - *last release*: Aug 24, 2021, + :pypi:`pytest_defer` + *last release*: Nov 13, 2024, *status*: N/A, - *requires*: N/A - + *requires*: pytest>=8.3 + A 'defer' fixture for pytest :pypi:`pytest-demo-plugin` *last release*: May 15, 2021, @@ -3840,6 +3852,13 @@ This list contains 1540 plugins. Mark tests as testing a deprecated feature with a warning note. + :pypi:`pytest-deprecator` + *last release*: Nov 14, 2024, + *status*: 4 - Beta, + *requires*: pytest>=6.2.0 + + A simple plugin to use with pytest + :pypi:`pytest-describe` *last release*: Feb 10, 2024, *status*: 5 - Production/Stable, @@ -4597,56 +4616,63 @@ This list contains 1540 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: Oct 29, 2024, + *last release*: Nov 14, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: Oct 29, 2024, + *last release*: Nov 14, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: Oct 29, 2024, + *last release*: Nov 14, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: Oct 29, 2024, + *last release*: Nov 14, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. + :pypi:`pytest-embedded-nuttx` + *last release*: Nov 14, 2024, + *status*: 5 - Production/Stable, + *requires*: N/A + + Make pytest-embedded plugin work with NuttX. + :pypi:`pytest-embedded-qemu` - *last release*: Oct 29, 2024, + *last release*: Nov 14, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: Oct 29, 2024, + *last release*: Nov 14, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: Oct 29, 2024, + *last release*: Nov 14, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: Oct 29, 2024, + *last release*: Nov 14, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -4835,8 +4861,8 @@ This list contains 1540 plugins. Parse queries in Lucene and Elasticsearch syntaxes :pypi:`pytest-examples` - *last release*: Aug 13, 2024, - *status*: 4 - Beta, + *last release*: Nov 15, 2024, + *status*: N/A, *requires*: pytest>=7 Pytest plugin for testing examples in docstrings and markdown files. @@ -5549,7 +5575,7 @@ This list contains 1540 plugins. An alternative way to parametrize test cases. :pypi:`pytest-fv` - *last release*: Nov 07, 2024, + *last release*: Nov 16, 2024, *status*: N/A, *requires*: pytest @@ -5619,7 +5645,7 @@ This list contains 1540 plugins. GCS fixtures and fixture factories for Pytest. :pypi:`pytest-gee` - *last release*: Jun 30, 2024, + *last release*: Nov 14, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -5962,7 +5988,7 @@ This list contains 1540 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Nov 09, 2024, + *last release*: Nov 16, 2024, *status*: 3 - Alpha, *requires*: pytest==8.3.3 @@ -6508,7 +6534,7 @@ This list contains 1540 plugins. Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it. :pypi:`pytest-item-dict` - *last release*: Oct 30, 2024, + *last release*: Nov 14, 2024, *status*: 4 - Beta, *requires*: pytest>=8.3.0 @@ -7124,7 +7150,7 @@ This list contains 1540 plugins. pytest marker for marking manual tests :pypi:`pytest-mark-count` - *last release*: Oct 18, 2024, + *last release*: Nov 13, 2024, *status*: 4 - Beta, *requires*: pytest>=8.0.0 @@ -7411,7 +7437,7 @@ This list contains 1540 plugins. Pytest plugin to easily fake missing modules :pypi:`pytest-mitmproxy` - *last release*: Sep 12, 2024, + *last release*: Nov 13, 2024, *status*: N/A, *requires*: pytest>=7.0 @@ -8195,7 +8221,7 @@ This list contains 1540 plugins. Simpler PyTest parametrization :pypi:`pytest-parametrize` - *last release*: Oct 30, 2024, + *last release*: Nov 10, 2024, *status*: 5 - Production/Stable, *requires*: pytest<9.0.0,>=8.3.0 @@ -9028,7 +9054,7 @@ This list contains 1540 plugins. A pytest plugin to collect test information :pypi:`pytest-qaseio` - *last release*: Oct 28, 2024, + *last release*: Nov 15, 2024, *status*: 5 - Production/Stable, *requires*: pytest<9.0.0,>=7.2.2 @@ -9301,7 +9327,7 @@ This list contains 1540 plugins. Easy to use fixtures to write regression tests. :pypi:`pytest-regtest` - *last release*: Oct 17, 2024, + *last release*: Nov 12, 2024, *status*: N/A, *requires*: pytest>7.2 @@ -9805,7 +9831,7 @@ This list contains 1540 plugins. implement a --failed option for pytest :pypi:`pytest-run-parallel` - *last release*: Sep 30, 2024, + *last release*: Nov 13, 2024, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -9917,7 +9943,7 @@ This list contains 1540 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Nov 09, 2024, + *last release*: Nov 15, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9994,7 +10020,7 @@ This list contains 1540 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Nov 09, 2024, + *last release*: Nov 15, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10064,7 +10090,7 @@ This list contains 1540 plugins. Automatically mocks resources from serverless.yml in pytest using moto. :pypi:`pytest-servers` - *last release*: Sep 17, 2024, + *last release*: Nov 14, 2024, *status*: 3 - Alpha, *requires*: pytest>=6.2 @@ -10364,6 +10390,13 @@ This list contains 1540 plugins. py.test plugin for Snap-CI + :pypi:`pytest-snapmock` + *last release*: Nov 15, 2024, + *status*: N/A, + *requires*: N/A + + Snapshots for your mocks. + :pypi:`pytest-snapshot` *last release*: Apr 23, 2022, *status*: 4 - Beta, @@ -11023,9 +11056,9 @@ This list contains 1540 plugins. A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. :pypi:`pytest-test-groups` - *last release*: Oct 25, 2016, + *last release*: Nov 14, 2024, *status*: 5 - Production/Stable, - *requires*: N/A + *requires*: pytest>=7.0.0 A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. @@ -11226,7 +11259,7 @@ This list contains 1540 plugins. :pypi:`pytest-tesults` - *last release*: Sep 09, 2024, + *last release*: Nov 12, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=3.5.0 @@ -12135,6 +12168,13 @@ This list contains 1540 plugins. pytest plugin for generating test cases by xlsx(excel) + :pypi:`pytest-xml` + *last release*: Nov 14, 2024, + *status*: 4 - Beta, + *requires*: pytest>=8.0.0 + + Create simple XML results for parsing + :pypi:`pytest-xpara` *last release*: Aug 07, 2024, *status*: 3 - Alpha, From 78017f41313f5135f0afe00d9ad57937b4e41045 Mon Sep 17 00:00:00 2001 From: Gupta Arpit Date: Sun, 17 Nov 2024 13:45:51 +0530 Subject: [PATCH 156/445] Pushed review changes --- changelog/12960.improvement.rst | 2 +- src/_pytest/python.py | 8 ++------ testing/test_terminal.py | 5 ----- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/changelog/12960.improvement.rst b/changelog/12960.improvement.rst index ac9c9e431b1..e935f90704b 100644 --- a/changelog/12960.improvement.rst +++ b/changelog/12960.improvement.rst @@ -1 +1 @@ -Removed _pytest.compat.is_generator() and just using inspect.isgeneratorfunction() directly +Test functions containing a yield now cause an explicit error. They have not been run since Pytest 4.0, and were previously marked as an expected failure and deprecation warning. \ No newline at end of file diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 23b65765a53..d1e8d369e7c 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -230,12 +230,8 @@ def pytest_pycollect_makeitem( ) elif getattr(obj, "__test__", True): if inspect.isgeneratorfunction(obj): - reason = ( - f"yield tests were removed in pytest 4.0 - {name} will be ignored" - ) - raise RuntimeError(reason) # Raise a hard error instead of xfail - else: - return list(collector._genfunctions(name, obj)) + raise RuntimeError("'yield' keyword is allowed in fixtures, but not in tests ({name})") + return list(collector._genfunctions(name, obj)) return None return None diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 14c152d6123..872703900cd 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -1042,10 +1042,6 @@ def test_pass(): class TestClass(object): def test_skip(self): pytest.skip("hello") - def test_gen(): - def check(x): - assert x == 1 - yield check, 0 """ ) @@ -1058,7 +1054,6 @@ def test_verbose_reporting(self, verbose_testfile, pytester: Pytester) -> None: "*test_verbose_reporting.py::test_fail *FAIL*", "*test_verbose_reporting.py::test_pass *PASS*", "*test_verbose_reporting.py::TestClass::test_skip *SKIP*", - "*test_verbose_reporting.py::test_gen *XFAIL*", ] ) assert result.ret == 1 From a074630394daa767ea2bc700f3626a2533288268 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 17 Nov 2024 08:16:14 +0000 Subject: [PATCH 157/445] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- changelog/12960.improvement.rst | 2 +- src/_pytest/python.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/changelog/12960.improvement.rst b/changelog/12960.improvement.rst index e935f90704b..43e981dc648 100644 --- a/changelog/12960.improvement.rst +++ b/changelog/12960.improvement.rst @@ -1 +1 @@ -Test functions containing a yield now cause an explicit error. They have not been run since Pytest 4.0, and were previously marked as an expected failure and deprecation warning. \ No newline at end of file +Test functions containing a yield now cause an explicit error. They have not been run since Pytest 4.0, and were previously marked as an expected failure and deprecation warning. diff --git a/src/_pytest/python.py b/src/_pytest/python.py index d1e8d369e7c..d117fa58d01 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -230,7 +230,9 @@ def pytest_pycollect_makeitem( ) elif getattr(obj, "__test__", True): if inspect.isgeneratorfunction(obj): - raise RuntimeError("'yield' keyword is allowed in fixtures, but not in tests ({name})") + raise RuntimeError( + "'yield' keyword is allowed in fixtures, but not in tests ({name})" + ) return list(collector._genfunctions(name, obj)) return None return None From 49c140d286155f91969ce9e4cf6e3b15aee621d2 Mon Sep 17 00:00:00 2001 From: John Litborn <11260241+jakkdl@users.noreply.github.com> Date: Sun, 17 Nov 2024 11:29:02 +0100 Subject: [PATCH 158/445] Apply suggestions from code review Co-authored-by: Bruno Oliveira --- src/_pytest/fixtures.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index b5c64856e12..8122d7fe2a8 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1154,9 +1154,9 @@ def pytest_fixture_setup( f"{request.node.name!r} requested an async fixture " f"{request.fixturename!r}{auto_str}, with no plugin or hook that " "handled it. This is usually an error, as pytest does not natively " - "support it. If this is intentional, consider making the fixture " - "sync and return a coroutine/asyncgen. " - "This will turn into an error in pytest 9." + "support it. " + "This will turn into an error in pytest 9.\n" + "See: https://docs.pytest.org/en/stable/deprecations.html#sync-test-depending-on-async-fixture" ), # no stacklevel will point at users code, so we just point here stacklevel=1, From f434c278e45092e2091cd9358251c58ca9e0bce8 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Sun, 17 Nov 2024 11:44:07 +0100 Subject: [PATCH 159/445] be more explicit about the downside of async autouse fixtures --- doc/en/deprecations.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index 88cf3eccbf3..59f9d83451b 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -71,7 +71,18 @@ should be changed to You can also make use of `pytest_fixture_setup` to handle the coroutine/asyncgen before pytest sees it - this is the way current async pytest plugins handle it. -If a user has an async fixture with ``autouse=True`` in their ``conftest.py``, or in a file where they also have synchronous tests, they will also get this warning. We strongly recommend against this practice, and they should restructure their testing infrastructure so the fixture is synchronous or to separate the fixture from their synchronous tests. Note that the `anyio pytest plugin `_ has some support for sync test + async fixtures currently. +If a user has an async fixture with ``autouse=True`` in their ``conftest.py``, or in a file +containing both synchronous tests and the fixture, they will receive this warning. +Unless you're using a plugin that specifically handles async fixtures +with synchronous tests, we strongly recommend against this practice. +It can lead to unpredictable behavior (with larger scopes, it may appear to "work" if an async +test is the first to request the fixture, due to value caching) and will generate +unawaited-coroutine runtime warnings (but only for non-yield fixtures). +Additionally, it creates ambiguity for other developers about whether the fixture is intended to perform +setup for synchronous tests. + +The `anyio pytest plugin `_ supports +synchronous tests with async fixtures, though certain limitations apply. .. _import-or-skip-import-error: From 708494008b3976feefeb54f141eeb0ca2e6738a3 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Sun, 17 Nov 2024 11:51:37 +0100 Subject: [PATCH 160/445] fix tests after message change --- testing/acceptance_test.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 624a313ca8d..ba1f86f02d9 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1311,10 +1311,9 @@ def test_foo(async_fixture): "*PytestRemovedIn9Warning: 'test_foo' requested an async " "fixture 'async_fixture', with no plugin or hook that handled it. " "This is usually an error, as pytest does not natively support it. " - "If this is intentional, consider making the fixture sync and return " - "a coroutine/asyncgen. " "This will turn into an error in pytest 9." ), + " See: https://docs.pytest.org/en/stable/deprecations.html#sync-test-depending-on-async-fixture", ] ) result.assert_outcomes(passed=1, warnings=1) @@ -1342,10 +1341,9 @@ def test_foo(async_fixture): "*PytestRemovedIn9Warning: 'test_foo' requested an async " "fixture 'async_fixture', with no plugin or hook that handled it. " "This is usually an error, as pytest does not natively support it. " - "If this is intentional, consider making the fixture sync and return " - "a coroutine/asyncgen. " "This will turn into an error in pytest 9." ), + " See: https://docs.pytest.org/en/stable/deprecations.html#sync-test-depending-on-async-fixture", ] ) result.assert_outcomes(passed=1, warnings=1) @@ -1376,11 +1374,11 @@ def test_foo(async_fixture): ( "*PytestRemovedIn9Warning: 'test_foo' requested an async " "fixture 'async_fixture' with autouse=True, with no plugin or hook " - "that handled it. This is usually an error, as pytest does not " - "natively support it. If this is intentional, consider making the " - "fixture sync and return a coroutine/asyncgen. " + "that handled it. " + "This is usually an error, as pytest does not natively support it. " "This will turn into an error in pytest 9." ), + " See: https://docs.pytest.org/en/stable/deprecations.html#sync-test-depending-on-async-fixture", ] ) result.assert_outcomes(passed=1, warnings=1) From 5398d7c15aeb1de7595e5ed4fad0d787feb3d0f2 Mon Sep 17 00:00:00 2001 From: Gupta Arpit Date: Sun, 17 Nov 2024 17:26:00 +0530 Subject: [PATCH 161/445] Add test for RuntimeError on 'yield' in tests --- testing/test_collection.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/testing/test_collection.py b/testing/test_collection.py index aba8f8ea48d..80c250027c6 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -1878,3 +1878,21 @@ def test_respect_system_exceptions( result.stdout.fnmatch_lines([f"*{head}*"]) result.stdout.fnmatch_lines([msg]) result.stdout.no_fnmatch_line(f"*{tail}*") + + +def test_yield_disallowed_in_tests(pytester: Pytester): + """Ensure generator test functions with 'yield' raise a RuntimeError.""" + pytester.makepyfile( + """ + def test_with_yield(): + yield 1 + """ + ) + result = pytester.runpytest() + assert result.ret == 2 + result.stdout.fnmatch_lines( + ["*RuntimeError: 'yield' keyword is allowed in fixtures, but not in tests (*)*"] + ) + result.stdout.fnmatch_lines( + ["*collected 0 items*"] + ) \ No newline at end of file From bad14eec09c40370270d7fb428deb929c6e2718f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 17 Nov 2024 11:56:25 +0000 Subject: [PATCH 162/445] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- testing/test_collection.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/testing/test_collection.py b/testing/test_collection.py index 80c250027c6..53463d81866 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -1893,6 +1893,4 @@ def test_with_yield(): result.stdout.fnmatch_lines( ["*RuntimeError: 'yield' keyword is allowed in fixtures, but not in tests (*)*"] ) - result.stdout.fnmatch_lines( - ["*collected 0 items*"] - ) \ No newline at end of file + result.stdout.fnmatch_lines(["*collected 0 items*"]) From 1bcaf2c58d44e4426dd1ef6989206e9790710285 Mon Sep 17 00:00:00 2001 From: Gupta Arpit Date: Mon, 18 Nov 2024 00:37:00 +0530 Subject: [PATCH 163/445] Rename changelog/12960.breaking.rst --- changelog/{12960.improvement.rst => 12960.breaking.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{12960.improvement.rst => 12960.breaking.rst} (100%) diff --git a/changelog/12960.improvement.rst b/changelog/12960.breaking.rst similarity index 100% rename from changelog/12960.improvement.rst rename to changelog/12960.breaking.rst From f1821eaa13867864ab9048b217ccbaa77e8e781b Mon Sep 17 00:00:00 2001 From: sven <42868792+FreerGit@users.noreply.github.com> Date: Sun, 17 Nov 2024 20:57:38 +0100 Subject: [PATCH 164/445] WIP - report collection needs triage --- testing/test_collect_imports.py | 278 +++++++++++++++++--------------- 1 file changed, 148 insertions(+), 130 deletions(-) diff --git a/testing/test_collect_imports.py b/testing/test_collect_imports.py index cf8ff9cb983..cc1c5a80015 100644 --- a/testing/test_collect_imports.py +++ b/testing/test_collect_imports.py @@ -13,78 +13,82 @@ # Start of tests for classes -# def run_import_class_test(pytester: Pytester, passed: int = 0, errors: int = 0) -> None: -# src_dir = pytester.mkdir("src") -# tests_dir = pytester.mkdir("tests") -# src_file = src_dir / "foo.py" - -# src_file.write_text( -# textwrap.dedent("""\ -# class Testament(object): -# def __init__(self): -# super().__init__() -# self.collections = ["stamp", "coin"] - -# def personal_property(self): -# return [f"my {x} collection" for x in self.collections] -# """), -# encoding="utf-8", -# ) - -# test_file = tests_dir / "foo_test.py" -# test_file.write_text( -# textwrap.dedent("""\ -# import sys -# import os - -# current_file = os.path.abspath(__file__) -# current_dir = os.path.dirname(current_file) -# parent_dir = os.path.abspath(os.path.join(current_dir, '..')) -# sys.path.append(parent_dir) - -# from src.foo import Testament - -# class TestDomain: -# def test_testament(self): -# testament = Testament() -# assert testament.personal_property() -# """), -# encoding="utf-8", -# ) - -# result = pytester.runpytest() -# result.assert_outcomes(passed=passed, errors=errors) - -# def test_collect_imports_disabled(pytester: Pytester) -> None: -# pytester.makeini(""" -# [pytest] -# testpaths = "tests" -# collect_imported_tests = false -# """) - -# run_import_class_test(pytester, passed=1) - -# # Verify that the state of hooks -# reprec = pytester.inline_run() -# items_collected = reprec.getcalls("pytest_itemcollected") -# assert len(items_collected) == 1 -# for x in items_collected: -# assert x.item._getobj().__name__ == "test_testament" - -# def test_collect_imports_default(pytester: Pytester) -> None: -# run_import_class_test(pytester, errors=1) - -# # TODO, hooks - - -# def test_collect_imports_enabled(pytester: Pytester) -> None: -# pytester.makeini(""" -# [pytest] -# collect_imported_tests = true -# """) - -# run_import_class_test(pytester, errors=1) -# # TODO, hooks + +def run_import_class_test( + pytester: Pytester, passed: int = 0, errors: int = 0 +) -> RunResult: + src_dir = pytester.mkdir("src") + tests_dir = pytester.mkdir("tests") + src_file = src_dir / "foo.py" + + src_file.write_text( + textwrap.dedent("""\ + class Testament(object): + def __init__(self): + super().__init__() + self.collections = ["stamp", "coin"] + + def personal_property(self): + return [f"my {x} collection" for x in self.collections] + """), + encoding="utf-8", + ) + + test_file = tests_dir / "foo_test.py" + test_file.write_text( + textwrap.dedent("""\ + import sys + import os + + current_file = os.path.abspath(__file__) + current_dir = os.path.dirname(current_file) + parent_dir = os.path.abspath(os.path.join(current_dir, '..')) + sys.path.append(parent_dir) + + from src.foo import Testament + + class TestDomain: + def test_testament(self): + testament = Testament() + assert testament.personal_property() + """), + encoding="utf-8", + ) + + result = pytester.runpytest() + result.assert_outcomes(passed=passed, errors=errors) + return result + + +def test_collect_imports_disabled(pytester: Pytester) -> None: + pytester.makeini(""" + [pytest] + testpaths = "tests" + collect_imported_tests = false + """) + + run_import_class_test(pytester, passed=1) + + # Verify that the state of hooks + reprec = pytester.inline_run() + items_collected = reprec.getcalls("pytest_itemcollected") + assert len(items_collected) == 1 + for x in items_collected: + assert x.item._getobj().__name__ == "test_testament" + + +def test_collect_imports_default(pytester: Pytester) -> None: + run_import_class_test(pytester, errors=1) + # TODO + + +def test_collect_imports_enabled(pytester: Pytester) -> None: + pytester.makeini(""" + [pytest] + collect_imported_tests = true + """) + + run_import_class_test(pytester, errors=1) # End of tests for classes @@ -144,54 +148,54 @@ def test_important(self): return result -# def test_collect_function_imports_enabled(pytester: Pytester) -> None: -# pytester.makeini(""" -# [pytest] -# testpaths = "tests" -# collect_imported_tests = true -# """) - -# run_import_functions_test(pytester, passed=2, errors=0, failed=1) -# reprec = pytester.inline_run() -# items_collected = reprec.getcalls("pytest_itemcollected") -# # Recall that the default is `collect_imported_tests = true`. -# # Which means that the normal functions are now interpreted as -# # valid tests and `test_function()` will fail. -# assert len(items_collected) == 3 -# for x in items_collected: -# assert x.item._getobj().__name__ in [ -# "test_important", -# "test_bar", -# "test_function", -# ] - - -# def test_behaviour_without_testpaths_set_and_false(pytester: Pytester) -> None: -# # Make sure `collect_imported_tests` has no dependence on `testpaths` -# pytester.makeini(""" -# [pytest] -# collect_imported_tests = false -# """) - -# run_import_functions_test(pytester, passed=1, errors=0, failed=0) -# reprec = pytester.inline_run() -# items_collected = reprec.getcalls("pytest_itemcollected") -# assert len(items_collected) == 1 -# for x in items_collected: -# assert x.item._getobj().__name__ == "test_important" - - -# def test_behaviour_without_testpaths_set_and_true(pytester: Pytester) -> None: -# # Make sure `collect_imported_tests` has no dependence on `testpaths` -# pytester.makeini(""" -# [pytest] -# collect_imported_tests = true -# """) - -# run_import_functions_test(pytester, passed=2, errors=0, failed=1) -# reprec = pytester.inline_run() -# items_collected = reprec.getcalls("pytest_itemcollected") -# assert len(items_collected) == 3 +def test_collect_function_imports_enabled(pytester: Pytester) -> None: + pytester.makeini(""" + [pytest] + testpaths = "tests" + collect_imported_tests = true + """) + + run_import_functions_test(pytester, passed=2, errors=0, failed=1) + reprec = pytester.inline_run() + items_collected = reprec.getcalls("pytest_itemcollected") + # Recall that the default is `collect_imported_tests = true`. + # Which means that the normal functions are now interpreted as + # valid tests and `test_function()` will fail. + assert len(items_collected) == 3 + for x in items_collected: + assert x.item._getobj().__name__ in [ + "test_important", + "test_bar", + "test_function", + ] + + +def test_behaviour_without_testpaths_set_and_false(pytester: Pytester) -> None: + # Make sure `collect_imported_tests` has no dependence on `testpaths` + pytester.makeini(""" + [pytest] + collect_imported_tests = false + """) + + run_import_functions_test(pytester, passed=1, errors=0, failed=0) + reprec = pytester.inline_run() + items_collected = reprec.getcalls("pytest_itemcollected") + assert len(items_collected) == 1 + for x in items_collected: + assert x.item._getobj().__name__ == "test_important" + + +def test_behaviour_without_testpaths_set_and_true(pytester: Pytester) -> None: + # Make sure `collect_imported_tests` has no dependence on `testpaths` + pytester.makeini(""" + [pytest] + collect_imported_tests = true + """) + + run_import_functions_test(pytester, passed=2, errors=0, failed=1) + reprec = pytester.inline_run() + items_collected = reprec.getcalls("pytest_itemcollected") + assert len(items_collected) == 3 class TestHookBehaviour: @@ -255,11 +259,12 @@ def _test_hook_behaviour_when_collect_off(self, pytester: Pytester) -> None: "reports": reports, } - # Now check that the two tests above did indeed result in the same outcome. def _test_hook_behaviour(self) -> None: print("ABCD", self.collect_outcomes) default = self.collect_outcomes["default"] collect_off = self.collect_outcomes["collect_off"] + + # Check that the two tests above did indeed result in the same outcome. assert default["result"] == collect_off["result"] assert len(default["modified"]) == len(collect_off["modified"]) == 1 @@ -282,13 +287,14 @@ def _test_hook_behaviour(self) -> None: len(default["items_collected"]) == len(collect_off["items_collected"]) == 1 ) + # Check if the same tests got collected def_items_record: RecordedHookCall = default["items_collected"][0] off_items_record: RecordedHookCall = collect_off["items_collected"][0] def_items = def_items_record.__dict__["item"] off_items = off_items_record.__dict__["item"] assert def_items.name == off_items.name - # TODO: fix diff: + # TODO: fix diff: (This will get cleaned up) # [ # , # - , @@ -301,12 +307,24 @@ def _test_hook_behaviour(self) -> None: # ? ^ # ] - # assert len(default['reports']) == len(collect_off['reports']) - # for i in range(len(default['reports'])): - # print("def",default['reports'][i].__dict__) - # print("off",collect_off['reports'][i].__dict__) + for x in default["reports"]: + print("def", x.__dict__) + + for x in collect_off["reports"]: + print("off", x.__dict__) + + # The two above loops prints: + + # def {'nodeid': '', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 + # def {'nodeid': 'tests/foo_test.py::TestDomain', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 + # def {'nodeid': 'tests/foo_test.py', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 + # def {'nodeid': 'tests', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 + # def {'nodeid': '.', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 + # off {'nodeid': '', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 + # off {'nodeid': 'src', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} + # off {'nodeid': 'tests/foo_test.py::TestDomain', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 + # off {'nodeid': 'tests/foo_test.py', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 + # off {'nodeid': 'tests', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 + # off {'nodeid': '.', 'outcome': 'passed', 'longrepr': None, 'result': [, ], 'sections': []} # noqa: E501 - # from pprint import pprint - # pprint(default['reports']) - # pprint(collect_off['reports']) - # assert default['reports'] == collect_off['reports'] + assert len(default["reports"]) == len(collect_off["reports"]) From 6cba4e6c1af24fd5940cc0ebdddabdbb1a0b8906 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 09:03:41 +0100 Subject: [PATCH 165/445] build(deps): Bump pytest-bdd in /testing/plugins_integration (#12971) Bumps [pytest-bdd](https://github.com/pytest-dev/pytest-bdd) from 7.3.0 to 8.0.0. - [Changelog](https://github.com/pytest-dev/pytest-bdd/blob/master/CHANGES.rst) - [Commits](https://github.com/pytest-dev/pytest-bdd/compare/7.3.0...8.0.0) --- updated-dependencies: - dependency-name: pytest-bdd dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 32992dc2589..9ca5d1cfde0 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,7 +1,7 @@ anyio[curio,trio]==4.6.2.post1 django==5.1.3 pytest-asyncio==0.24.0 -pytest-bdd==7.3.0 +pytest-bdd==8.0.0 pytest-cov==6.0.0 pytest-django==4.9.0 pytest-flakes==4.0.5 From 3de3d0d79ed2efe23a6e73d386a54b75a712fcf1 Mon Sep 17 00:00:00 2001 From: Gupta Arpit Date: Mon, 18 Nov 2024 15:54:42 +0530 Subject: [PATCH 166/445] Added final review requested changes --- changelog/12960.breaking.rst | 2 +- doc/en/deprecations.rst | 60 ++++++++++++++++++------------------ src/_pytest/python.py | 5 +-- testing/test_collection.py | 7 +++-- 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/changelog/12960.breaking.rst b/changelog/12960.breaking.rst index 43e981dc648..942348d8245 100644 --- a/changelog/12960.breaking.rst +++ b/changelog/12960.breaking.rst @@ -1 +1 @@ -Test functions containing a yield now cause an explicit error. They have not been run since Pytest 4.0, and were previously marked as an expected failure and deprecation warning. +Test functions containing a yield now cause an explicit error. They have not been run since pytest 4.0, and were previously marked as an expected failure and deprecation warning. diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index 59f9d83451b..689ba96b615 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -374,6 +374,36 @@ an appropriate period of deprecation has passed. Some breaking changes which could not be deprecated are also listed. +.. _yield tests deprecated: + +``yield`` tests +~~~~~~~~~~~~~~~ + +.. versionremoved:: 8.4 + +pytest no longer supports ``yield``-style tests, where a test function actually ``yield`` functions and values +that are then turned into proper test methods. Example: + +.. code-block:: python + + def check(x, y): + assert x**x == y + + + def test_squared(): + yield check, 2, 4 + yield check, 3, 9 + +This would result in two actual test functions being generated. + +This form of test function doesn't support fixtures properly, and users should switch to ``pytest.mark.parametrize``: + +.. code-block:: python + + @pytest.mark.parametrize("x, y", [(2, 4), (3, 9)]) + def test_squared(x, y): + assert x**x == y + .. _nose-deprecation: Support for tests written for nose @@ -1270,36 +1300,6 @@ with the ``name`` parameter: return cell() -.. _yield tests deprecated: - -``yield`` tests -~~~~~~~~~~~~~~~ - -.. versionremoved:: 4.0 - -pytest supported ``yield``-style tests, where a test function actually ``yield`` functions and values -that are then turned into proper test methods. Example: - -.. code-block:: python - - def check(x, y): - assert x**x == y - - - def test_squared(): - yield check, 2, 4 - yield check, 3, 9 - -This would result into two actual test functions being generated. - -This form of test function doesn't support fixtures properly, and users should switch to ``pytest.mark.parametrize``: - -.. code-block:: python - - @pytest.mark.parametrize("x, y", [(2, 4), (3, 9)]) - def test_squared(x, y): - assert x**x == y - .. _internal classes accessed through node deprecated: Internal classes accessed through ``Node`` diff --git a/src/_pytest/python.py b/src/_pytest/python.py index d117fa58d01..1456b5212d4 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -230,8 +230,9 @@ def pytest_pycollect_makeitem( ) elif getattr(obj, "__test__", True): if inspect.isgeneratorfunction(obj): - raise RuntimeError( - "'yield' keyword is allowed in fixtures, but not in tests ({name})" + fail( + f"'yield' keyword is allowed in fixtures, but not in tests ({name})", + pytrace=False, ) return list(collector._genfunctions(name, obj)) return None diff --git a/testing/test_collection.py b/testing/test_collection.py index 53463d81866..aed0c34091d 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -1881,7 +1881,7 @@ def test_respect_system_exceptions( def test_yield_disallowed_in_tests(pytester: Pytester): - """Ensure generator test functions with 'yield' raise a RuntimeError.""" + """Ensure generator test functions with 'yield' fail collection (#12960).""" pytester.makepyfile( """ def test_with_yield(): @@ -1891,6 +1891,7 @@ def test_with_yield(): result = pytester.runpytest() assert result.ret == 2 result.stdout.fnmatch_lines( - ["*RuntimeError: 'yield' keyword is allowed in fixtures, but not in tests (*)*"] + ["*'yield' keyword is allowed in fixtures, but not in tests (test_with_yield)*"] ) - result.stdout.fnmatch_lines(["*collected 0 items*"]) + # Assert that no tests were collected + result.stdout.fnmatch_lines(["*collected 0 items*"]) \ No newline at end of file From 7c24a0ba1919c43e0f4ac8c48bd2126c8a4d64b2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 10:26:40 +0000 Subject: [PATCH 167/445] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/en/deprecations.rst | 2 +- testing/test_collection.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index 689ba96b615..a6b7ed4beab 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -403,7 +403,7 @@ This form of test function doesn't support fixtures properly, and users should s @pytest.mark.parametrize("x, y", [(2, 4), (3, 9)]) def test_squared(x, y): assert x**x == y - + .. _nose-deprecation: Support for tests written for nose diff --git a/testing/test_collection.py b/testing/test_collection.py index aed0c34091d..7d28610e015 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -1894,4 +1894,4 @@ def test_with_yield(): ["*'yield' keyword is allowed in fixtures, but not in tests (test_with_yield)*"] ) # Assert that no tests were collected - result.stdout.fnmatch_lines(["*collected 0 items*"]) \ No newline at end of file + result.stdout.fnmatch_lines(["*collected 0 items*"]) From 1a5dbcb04d2677f46175d5b03dfd63f0debbf43e Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 18 Nov 2024 09:30:53 -0300 Subject: [PATCH 168/445] Update changelog/12960.breaking.rst --- changelog/12960.breaking.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog/12960.breaking.rst b/changelog/12960.breaking.rst index 942348d8245..3ab87e6fe23 100644 --- a/changelog/12960.breaking.rst +++ b/changelog/12960.breaking.rst @@ -1 +1,3 @@ Test functions containing a yield now cause an explicit error. They have not been run since pytest 4.0, and were previously marked as an expected failure and deprecation warning. + +See :ref:`the docs ` for more information. From 831d061a84c86c2d5ba99a7b3efde65862d8ea58 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Mon, 18 Nov 2024 13:33:56 +0100 Subject: [PATCH 169/445] Docs: be more precise about TestReport outcome in example (#12535) * Testing only for "failed" should not be reported as "or skipped" * Test for "skipped" explicitly instead Signed-off-by: Yann Dirson --- changelog/12535.doc.rst | 4 ++++ doc/en/example/simple.rst | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelog/12535.doc.rst diff --git a/changelog/12535.doc.rst b/changelog/12535.doc.rst new file mode 100644 index 00000000000..d43c1c822ea --- /dev/null +++ b/changelog/12535.doc.rst @@ -0,0 +1,4 @@ +`This +example` +showed ``print`` statements that do not exactly reflect what the +different branches actually do. The fix makes the example more precise. diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index a14c34c19c3..b50fbfed397 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -904,7 +904,9 @@ here is a little example implemented via a local plugin: # "function" scope report = request.node.stash[phase_report_key] if report["setup"].failed: - print("setting up a test failed or skipped", request.node.nodeid) + print("setting up a test failed", request.node.nodeid) + elif report["setup"].skipped: + print("setting up a test skipped", request.node.nodeid) elif ("call" not in report) or report["call"].failed: print("executing test failed or skipped", request.node.nodeid) From fe60ceb06d996965de140ccfc61cede4afe2a389 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 09:39:04 -0300 Subject: [PATCH 170/445] build(deps): Bump codecov/codecov-action from 4 to 5 (#12972) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4 to 5. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4...v5) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 52faca6ddef..c1ea62f6c8b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -246,7 +246,7 @@ jobs: - name: Upload coverage to Codecov if: "matrix.use_coverage" - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 with: fail_ci_if_error: false files: ./coverage.xml From 47996bdc3870f9eed82951a15e07f430eb27a665 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Mon, 18 Nov 2024 15:05:04 +0100 Subject: [PATCH 171/445] display single contained exception in excgroups in short test summary info --- changelog/12943.improvement.rst | 1 + src/_pytest/_code/code.py | 25 ++++++++++++++- testing/code/test_excinfo.py | 57 +++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 changelog/12943.improvement.rst diff --git a/changelog/12943.improvement.rst b/changelog/12943.improvement.rst new file mode 100644 index 00000000000..eb8ac63650a --- /dev/null +++ b/changelog/12943.improvement.rst @@ -0,0 +1 @@ +If a test fails with an exceptiongroup with a single exception, the contained exception will now be displayed in the short test summary info. diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 8fac39ea298..79adc196aea 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -1033,6 +1033,24 @@ def _truncate_recursive_traceback( def repr_excinfo(self, excinfo: ExceptionInfo[BaseException]) -> ExceptionChainRepr: repr_chain: list[tuple[ReprTraceback, ReprFileLocation | None, str | None]] = [] + + def _get_single_subexc( + eg: BaseExceptionGroup[BaseException], + ) -> BaseException | None: + res: BaseException | None = None + for subexc in eg.exceptions: + if res is not None: + return None + + if isinstance(subexc, BaseExceptionGroup): + res = _get_single_subexc(subexc) + if res is None: + # there were multiple exceptions in the subgroup + return None + else: + res = subexc + return res + e: BaseException | None = excinfo.value excinfo_: ExceptionInfo[BaseException] | None = excinfo descr = None @@ -1041,6 +1059,7 @@ def repr_excinfo(self, excinfo: ExceptionInfo[BaseException]) -> ExceptionChainR seen.add(id(e)) if excinfo_: + reprcrash = excinfo_._getreprcrash() # Fall back to native traceback as a temporary workaround until # full support for exception groups added to ExceptionInfo. # See https://github.com/pytest-dev/pytest/issues/9159 @@ -1054,9 +1073,13 @@ def repr_excinfo(self, excinfo: ExceptionInfo[BaseException]) -> ExceptionChainR ) ) ) + if ( + reprcrash is not None + and (subexc := _get_single_subexc(e)) is not None + ): + reprcrash.message = f"[in {type(e).__name__}] {subexc!r}" else: reprtraceback = self.repr_traceback(excinfo_) - reprcrash = excinfo_._getreprcrash() else: # Fallback to native repr if the exception doesn't have a traceback: # ExceptionInfo objects require a full traceback to work. diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index fc60ae9ac99..5bb65bf30af 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -1703,6 +1703,63 @@ def test_exceptiongroup(pytester: Pytester, outer_chain, inner_chain) -> None: _exceptiongroup_common(pytester, outer_chain, inner_chain, native=False) +def test_exceptiongroup_short_summary_info(pytester: Pytester): + pytester.makepyfile( + """ + import sys + + if sys.version_info < (3, 11): + from exceptiongroup import BaseExceptionGroup, ExceptionGroup + + def test_base() -> None: + raise BaseExceptionGroup("NOT IN SUMMARY", [SystemExit("a" * 10)]) + + def test_nonbase() -> None: + raise ExceptionGroup("NOT IN SUMMARY", [ValueError("a" * 10)]) + + def test_nested() -> None: + raise ExceptionGroup( + "NOT DISPLAYED", [ + ExceptionGroup("NOT IN SUMMARY", [ValueError("a" * 10)]) + ] + ) + + def test_multiple() -> None: + raise ExceptionGroup( + "b" * 10, + [ + ValueError("NOT IN SUMMARY"), + TypeError("NOT IN SUMMARY"), + ] + ) + """ + ) + result = pytester.runpytest("-vv") + assert result.ret == 1 + result.stdout.fnmatch_lines( + [ + "*= short test summary info =*", + ( + "FAILED test_exceptiongroup_short_summary_info.py::test_base - " + "[in BaseExceptionGroup] SystemExit('aaaaaaaaaa')" + ), + ( + "FAILED test_exceptiongroup_short_summary_info.py::test_nonbase - " + "[in ExceptionGroup] ValueError('aaaaaaaaaa')" + ), + ( + "FAILED test_exceptiongroup_short_summary_info.py::test_nested - " + "[in ExceptionGroup] ValueError('aaaaaaaaaa')" + ), + ( + "FAILED test_exceptiongroup_short_summary_info.py::test_multiple - " + "ExceptionGroup: bbbbbbbbbb (2 sub-exceptions)" + ), + "*= 4 failed in *", + ] + ) + + @pytest.mark.parametrize("tbstyle", ("long", "short", "auto", "line", "native")) def test_all_entries_hidden(pytester: Pytester, tbstyle: str) -> None: """Regression test for #10903.""" From 70e41cb2de00d19761033537574b318c9728fb45 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 18 Nov 2024 15:30:34 -0300 Subject: [PATCH 172/445] Update doc/en/deprecations.rst --- doc/en/deprecations.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index a6b7ed4beab..18df64c9204 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -379,8 +379,14 @@ Some breaking changes which could not be deprecated are also listed. ``yield`` tests ~~~~~~~~~~~~~~~ +.. versionremoved:: 4.0 + + ``yield`` tests ``xfail``. + .. versionremoved:: 8.4 + ``yield`` tests raise a collection error. + pytest no longer supports ``yield``-style tests, where a test function actually ``yield`` functions and values that are then turned into proper test methods. Example: From 72f17d10d76e5260906c17f279c5fa6bd29b5a8d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 07:31:40 +0100 Subject: [PATCH 173/445] [pre-commit.ci] pre-commit autoupdate (#12976) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.7.3 → v0.7.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.7.3...v0.7.4) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 218a69e2cbc..9e7be8cf6db 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.7.3" + rev: "v0.7.4" hooks: - id: ruff args: ["--fix"] From f59a8d18c5e7071e4af06b7f0571cfa22c1b1544 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Tue, 19 Nov 2024 17:03:34 +0100 Subject: [PATCH 174/445] fix test --- testing/code/test_excinfo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 5bb65bf30af..3418c433541 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -1736,6 +1736,7 @@ def test_multiple() -> None: ) result = pytester.runpytest("-vv") assert result.ret == 1 + backport_str = "exceptiongroup." if sys.version_info < (3, 11) else "" result.stdout.fnmatch_lines( [ "*= short test summary info =*", @@ -1753,7 +1754,7 @@ def test_multiple() -> None: ), ( "FAILED test_exceptiongroup_short_summary_info.py::test_multiple - " - "ExceptionGroup: bbbbbbbbbb (2 sub-exceptions)" + f"{backport_str}ExceptionGroup: bbbbbbbbbb (2 sub-exceptions)" ), "*= 4 failed in *", ] From 3311c180c75b99ab58d4b0b114953db2e80c1ff4 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Tue, 19 Nov 2024 17:16:29 +0100 Subject: [PATCH 175/445] move logic to ExceptionInfo --- src/_pytest/_code/code.py | 50 ++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 79adc196aea..0d635db132b 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -589,6 +589,31 @@ def exconly(self, tryshort: bool = False) -> str: representation is returned (so 'AssertionError: ' is removed from the beginning). """ + + def _get_single_subexc( + eg: BaseExceptionGroup[BaseException], + ) -> BaseException | None: + res: BaseException | None = None + for subexc in eg.exceptions: + if res is not None: + return None + + if isinstance(subexc, BaseExceptionGroup): + res = _get_single_subexc(subexc) + if res is None: + # there were multiple exceptions in the subgroup + return None + else: + res = subexc + return res + + if ( + tryshort + and isinstance(self.value, BaseExceptionGroup) + and (subexc := _get_single_subexc(self.value)) is not None + ): + return f"[in {type(self.value).__name__}] {subexc!r}" + lines = format_exception_only(self.type, self.value) text = "".join(lines) text = text.rstrip() @@ -1033,24 +1058,6 @@ def _truncate_recursive_traceback( def repr_excinfo(self, excinfo: ExceptionInfo[BaseException]) -> ExceptionChainRepr: repr_chain: list[tuple[ReprTraceback, ReprFileLocation | None, str | None]] = [] - - def _get_single_subexc( - eg: BaseExceptionGroup[BaseException], - ) -> BaseException | None: - res: BaseException | None = None - for subexc in eg.exceptions: - if res is not None: - return None - - if isinstance(subexc, BaseExceptionGroup): - res = _get_single_subexc(subexc) - if res is None: - # there were multiple exceptions in the subgroup - return None - else: - res = subexc - return res - e: BaseException | None = excinfo.value excinfo_: ExceptionInfo[BaseException] | None = excinfo descr = None @@ -1059,7 +1066,6 @@ def _get_single_subexc( seen.add(id(e)) if excinfo_: - reprcrash = excinfo_._getreprcrash() # Fall back to native traceback as a temporary workaround until # full support for exception groups added to ExceptionInfo. # See https://github.com/pytest-dev/pytest/issues/9159 @@ -1073,13 +1079,9 @@ def _get_single_subexc( ) ) ) - if ( - reprcrash is not None - and (subexc := _get_single_subexc(e)) is not None - ): - reprcrash.message = f"[in {type(e).__name__}] {subexc!r}" else: reprtraceback = self.repr_traceback(excinfo_) + reprcrash = excinfo_._getreprcrash() else: # Fallback to native repr if the exception doesn't have a traceback: # ExceptionInfo objects require a full traceback to work. From 033120b6546955b8b430a1f547879dd50a32775c Mon Sep 17 00:00:00 2001 From: jakkdl Date: Tue, 19 Nov 2024 17:25:07 +0100 Subject: [PATCH 176/445] add test case for codecov --- testing/code/test_excinfo.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 3418c433541..d23382c898c 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -1732,8 +1732,23 @@ def test_multiple() -> None: TypeError("NOT IN SUMMARY"), ] ) + + def test_nested_multiple() -> None: + raise ExceptionGroup( + "b" * 10, + [ + ExceptionGroup( + "c" * 10, + [ + ValueError("NOT IN SUMMARY"), + TypeError("NOT IN SUMMARY"), + ] + ) + ] + ) """ ) + # run with -vv to not truncate summary info, default width in tests is very low result = pytester.runpytest("-vv") assert result.ret == 1 backport_str = "exceptiongroup." if sys.version_info < (3, 11) else "" @@ -1756,7 +1771,11 @@ def test_multiple() -> None: "FAILED test_exceptiongroup_short_summary_info.py::test_multiple - " f"{backport_str}ExceptionGroup: bbbbbbbbbb (2 sub-exceptions)" ), - "*= 4 failed in *", + ( + "FAILED test_exceptiongroup_short_summary_info.py::test_nested_multiple - " + f"{backport_str}ExceptionGroup: bbbbbbbbbb (1 sub-exception)" + ), + "*= 5 failed in *", ] ) From 6f61360a2b195ad15aba0e09354d662647865846 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Fri, 22 Nov 2024 15:50:12 +0100 Subject: [PATCH 177/445] fixes after review --- src/_pytest/_code/code.py | 20 ++++++-------------- testing/code/test_excinfo.py | 6 +++--- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 0d635db132b..85ed3145e66 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -593,26 +593,18 @@ def exconly(self, tryshort: bool = False) -> str: def _get_single_subexc( eg: BaseExceptionGroup[BaseException], ) -> BaseException | None: - res: BaseException | None = None - for subexc in eg.exceptions: - if res is not None: - return None - - if isinstance(subexc, BaseExceptionGroup): - res = _get_single_subexc(subexc) - if res is None: - # there were multiple exceptions in the subgroup - return None - else: - res = subexc - return res + if len(eg.exceptions) != 1: + return None + if isinstance(e := eg.exceptions[0], BaseExceptionGroup): + return _get_single_subexc(e) + return e if ( tryshort and isinstance(self.value, BaseExceptionGroup) and (subexc := _get_single_subexc(self.value)) is not None ): - return f"[in {type(self.value).__name__}] {subexc!r}" + return f"{subexc!r} [single exception in {type(self.value).__name__}]" lines = format_exception_only(self.type, self.value) text = "".join(lines) diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index d23382c898c..b049e0cf188 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -1757,15 +1757,15 @@ def test_nested_multiple() -> None: "*= short test summary info =*", ( "FAILED test_exceptiongroup_short_summary_info.py::test_base - " - "[in BaseExceptionGroup] SystemExit('aaaaaaaaaa')" + "SystemExit('aaaaaaaaaa') [single exception in BaseExceptionGroup]" ), ( "FAILED test_exceptiongroup_short_summary_info.py::test_nonbase - " - "[in ExceptionGroup] ValueError('aaaaaaaaaa')" + "ValueError('aaaaaaaaaa') [single exception in ExceptionGroup]" ), ( "FAILED test_exceptiongroup_short_summary_info.py::test_nested - " - "[in ExceptionGroup] ValueError('aaaaaaaaaa')" + "ValueError('aaaaaaaaaa') [single exception in ExceptionGroup]" ), ( "FAILED test_exceptiongroup_short_summary_info.py::test_multiple - " From 4f777ff5c83273deba23832dd7e3768ba122fe39 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sun, 24 Nov 2024 00:34:59 +0000 Subject: [PATCH 178/445] Prevent Config.add_cleanup callbacks preventing other cleanups running (#12982) Ensure all callbacks registered via Config.add_cleanup will be called, regardless if any of them raises an error. --------- Co-authored-by: Bruno Oliveira --- changelog/12981.bugfix.rst | 1 + src/_pytest/config/__init__.py | 28 +++++++++++++++++----------- testing/test_config.py | 31 +++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 changelog/12981.bugfix.rst diff --git a/changelog/12981.bugfix.rst b/changelog/12981.bugfix.rst new file mode 100644 index 00000000000..5fc8e29656f --- /dev/null +++ b/changelog/12981.bugfix.rst @@ -0,0 +1 @@ +Prevent exceptions in :func:`pytest.Config.add_cleanup` callbacks preventing further cleanups. diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 35ab622de31..92cf565e85f 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -5,6 +5,7 @@ import argparse import collections.abc +import contextlib import copy import dataclasses import enum @@ -73,7 +74,6 @@ from _pytest.cacheprovider import Cache from _pytest.terminal import TerminalReporter - _PluggyPlugin = object """A type to represent plugin objects. @@ -1077,7 +1077,7 @@ def __init__( self._inicache: dict[str, Any] = {} self._override_ini: Sequence[str] = () self._opt2dest: dict[str, str] = {} - self._cleanup: list[Callable[[], None]] = [] + self._cleanup_stack = contextlib.ExitStack() self.pluginmanager.register(self, "pytestconfig") self._configured = False self.hook.pytest_addoption.call_historic( @@ -1106,8 +1106,9 @@ def inipath(self) -> pathlib.Path | None: def add_cleanup(self, func: Callable[[], None]) -> None: """Add a function to be called when the config object gets out of - use (usually coinciding with pytest_unconfigure).""" - self._cleanup.append(func) + use (usually coinciding with pytest_unconfigure). + """ + self._cleanup_stack.callback(func) def _do_configure(self) -> None: assert not self._configured @@ -1117,13 +1118,18 @@ def _do_configure(self) -> None: self.hook.pytest_configure.call_historic(kwargs=dict(config=self)) def _ensure_unconfigure(self) -> None: - if self._configured: - self._configured = False - self.hook.pytest_unconfigure(config=self) - self.hook.pytest_configure._call_history = [] - while self._cleanup: - fin = self._cleanup.pop() - fin() + try: + if self._configured: + self._configured = False + try: + self.hook.pytest_unconfigure(config=self) + finally: + self.hook.pytest_configure._call_history = [] + finally: + try: + self._cleanup_stack.close() + finally: + self._cleanup_stack = contextlib.ExitStack() def get_terminal_writer(self) -> TerminalWriter: terminalreporter: TerminalReporter | None = self.pluginmanager.get_plugin( diff --git a/testing/test_config.py b/testing/test_config.py index 13ba66e8f9d..b2825678b46 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -983,6 +983,37 @@ def test_confcutdir_check_isdir(self, pytester: Pytester) -> None: def test_iter_rewritable_modules(self, names, expected) -> None: assert list(_iter_rewritable_modules(names)) == expected + def test_add_cleanup(self, pytester: Pytester) -> None: + config = Config.fromdictargs({}, []) + config._do_configure() + report = [] + + class MyError(BaseException): + pass + + @config.add_cleanup + def cleanup_last(): + report.append("cleanup_last") + + @config.add_cleanup + def raise_2(): + report.append("raise_2") + raise MyError("raise_2") + + @config.add_cleanup + def raise_1(): + report.append("raise_1") + raise MyError("raise_1") + + @config.add_cleanup + def cleanup_first(): + report.append("cleanup_first") + + with pytest.raises(MyError, match=r"raise_2"): + config._ensure_unconfigure() + + assert report == ["cleanup_first", "raise_1", "raise_2", "cleanup_last"] + class TestConfigFromdictargs: def test_basic_behavior(self, _sys_snapshot) -> None: From 258f76eccb4101717f03747e3384d0c97e4c8138 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 24 Nov 2024 08:09:29 +0000 Subject: [PATCH 179/445] [automated] Update plugin list (#12986) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 86 +++++++++++++++++--------------- 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index ee0981e3694..3ac9b0b4c13 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =8.3.3 :pypi:`pytest-cases` Separate test code from test cases in pytest. Sep 26, 2024 5 - Production/Stable N/A :pypi:`pytest-cassandra` Cassandra CCM Test Fixtures for pytest Nov 04, 2017 1 - Planning N/A :pypi:`pytest-catchlog` py.test plugin to catch log messages. This is a fork of pytest-capturelog. Jan 24, 2016 4 - Beta pytest (>=2.6) @@ -459,7 +460,7 @@ This list contains 1545 plugins. :pypi:`pytest-ebics-sandbox` A pytest plugin for testing against an EBICS sandbox server. Requires docker. Aug 15, 2022 N/A N/A :pypi:`pytest-ec2` Pytest execution on EC2 instance Oct 22, 2019 3 - Alpha N/A :pypi:`pytest-echo` pytest plugin with mechanisms for echoing environment variables, package version and generic attributes Dec 05, 2023 5 - Production/Stable pytest >=2.2 - :pypi:`pytest-edit` Edit the source code of a failed test with \`pytest --edit\`. Jun 09, 2024 N/A pytest + :pypi:`pytest-edit` Edit the source code of a failed test with \`pytest --edit\`. Nov 17, 2024 N/A pytest :pypi:`pytest-ekstazi` Pytest plugin to select test using Ekstazi algorithm Sep 10, 2022 N/A pytest :pypi:`pytest-elasticsearch` Elasticsearch fixtures and fixture factories for Pytest. Mar 15, 2024 5 - Production/Stable pytest >=7.0 :pypi:`pytest-elasticsearch-test` Elasticsearch fixtures and fixture factories for Pytest. Aug 21, 2024 5 - Production/Stable pytest>=7.0 @@ -502,11 +503,11 @@ This list contains 1545 plugins. :pypi:`pytest-eventlet` Applies eventlet monkey-patch as a pytest plugin. Oct 04, 2021 N/A pytest ; extra == 'dev' :pypi:`pytest_evm` The testing package containing tools to test Web3-based projects Sep 23, 2024 4 - Beta pytest<9.0.0,>=8.1.1 :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A - :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Nov 15, 2024 N/A pytest>=7 - :pypi:`pytest-exasol-backend` Oct 31, 2024 N/A pytest<9,>=7 + :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Nov 20, 2024 N/A pytest>=7 + :pypi:`pytest-exasol-backend` Nov 22, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-extension` Oct 10, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-itde` Jul 01, 2024 N/A pytest<9,>=7 - :pypi:`pytest-exasol-saas` Aug 06, 2024 N/A pytest<9,>=7 + :pypi:`pytest-exasol-saas` Nov 22, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-slc` Nov 01, 2024 N/A pytest<9,>=7 :pypi:`pytest-excel` pytest plugin for generating excel reports Jun 18, 2024 5 - Production/Stable pytest>3.6 :pypi:`pytest-exceptional` Better exceptions Mar 16, 2017 4 - Beta N/A @@ -619,7 +620,7 @@ This list contains 1545 plugins. :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Nov 07, 2024 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Nov 19, 2024 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -688,7 +689,7 @@ This list contains 1545 plugins. :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Aug 11, 2024 3 - Alpha N/A :pypi:`pytest-httptesting` http_testing framework on top of pytest Aug 10, 2024 N/A pytest<9.0.0,>=8.2.0 - :pypi:`pytest-httpx` Send responses to httpx. Oct 28, 2024 5 - Production/Stable pytest==8.* + :pypi:`pytest-httpx` Send responses to httpx. Nov 18, 2024 5 - Production/Stable pytest==8.* :pypi:`pytest-httpx-blockage` Disable httpx requests during a test run Feb 16, 2023 N/A pytest (>=7.2.1) :pypi:`pytest-httpx-recorder` Recorder feature based on pytest_httpx, like recorder feature in responses. Jan 04, 2024 5 - Production/Stable pytest :pypi:`pytest-hue` Visualise PyTest status via your Phillips Hue lights May 09, 2019 N/A N/A @@ -730,7 +731,7 @@ This list contains 1545 plugins. :pypi:`pytest-integration-mark` Automatic integration test marking and excluding plugin for pytest May 22, 2023 N/A pytest (>=5.2) :pypi:`pytest-interactive` A pytest plugin for console based interactive test selection just after the collection phase Nov 30, 2017 3 - Alpha N/A :pypi:`pytest-intercept-remote` Pytest plugin for intercepting outgoing connection requests during pytest run. May 24, 2021 4 - Beta pytest (>=4.6) - :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Sep 25, 2024 4 - Beta pytest + :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Nov 19, 2024 4 - Beta pytest :pypi:`pytest-invenio` Pytest fixtures for Invenio. Jun 27, 2024 5 - Production/Stable pytest<7.2.0,>=6 :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-iovis` A Pytest plugin to enable Jupyter Notebook testing with Papermill Nov 06, 2024 4 - Beta pytest>=7.1.0 @@ -1092,7 +1093,7 @@ This list contains 1545 plugins. :pypi:`pytest-pyreport` PyReport is a lightweight reporting plugin for Pytest that provides concise HTML report May 05, 2024 N/A pytest :pypi:`pytest-pyright` Pytest plugin for type checking code with Pyright Jan 26, 2024 4 - Beta pytest >=7.0.0 :pypi:`pytest-pyspec` A plugin that transforms the pytest output into a result similar to the RSpec. It enables the use of docstrings to display results and also enables the use of the prefixes "describe", "with" and "it". Aug 17, 2024 N/A pytest<9.0.0,>=8.3.2 - :pypi:`pytest-pystack` Plugin to run pystack after a timeout for a test suite. Jan 04, 2024 N/A pytest >=3.5.0 + :pypi:`pytest-pystack` Plugin to run pystack after a timeout for a test suite. Nov 16, 2024 N/A pytest>=3.5.0 :pypi:`pytest-pytestrail` Pytest plugin for interaction with TestRail Aug 27, 2020 4 - Beta pytest (>=3.8.0) :pypi:`pytest-pythonhashseed` Pytest plugin to set PYTHONHASHSEED env var. Feb 25, 2024 4 - Beta pytest>=3.0.0 :pypi:`pytest-pythonpath` pytest plugin for adding to the PYTHONPATH from command line or configs. Feb 10, 2022 5 - Production/Stable pytest (<7,>=2.5.2) @@ -1101,7 +1102,7 @@ This list contains 1545 plugins. :pypi:`pytest-pyvenv` A package for create venv in tests Feb 27, 2024 N/A pytest ; extra == 'test' :pypi:`pytest-pyvista` Pytest-pyvista package Sep 29, 2023 4 - Beta pytest>=3.5.0 :pypi:`pytest-qanova` A pytest plugin to collect test information Sep 05, 2024 3 - Alpha pytest - :pypi:`pytest-qaseio` Pytest plugin for Qase.io integration Nov 15, 2024 5 - Production/Stable pytest<9.0.0,>=7.2.2 + :pypi:`pytest-qaseio` Pytest plugin for Qase.io integration Nov 18, 2024 5 - Production/Stable pytest<9.0.0,>=7.2.2 :pypi:`pytest-qasync` Pytest support for qasync. Jul 12, 2021 4 - Beta pytest (>=5.4.0) :pypi:`pytest-qatouch` Pytest plugin for uploading test results to your QA Touch Testrun. Feb 14, 2023 4 - Beta pytest (>=6.2.0) :pypi:`pytest-qgis` A pytest plugin for testing QGIS python plugins Jun 14, 2024 5 - Production/Stable pytest>=6.0 @@ -1175,7 +1176,7 @@ This list contains 1545 plugins. :pypi:`pytest-rerun` Re-run only changed files in specified branch Jul 08, 2019 N/A pytest (>=3.6) :pypi:`pytest-rerun-all` Rerun testsuite for a certain time or iterations Nov 16, 2023 3 - Alpha pytest (>=7.0.0) :pypi:`pytest-rerunclassfailures` pytest rerun class failures plugin Apr 24, 2024 5 - Production/Stable pytest>=7.2 - :pypi:`pytest-rerunfailures` pytest plugin to re-run tests to eliminate flaky failures Mar 13, 2024 5 - Production/Stable pytest >=7.2 + :pypi:`pytest-rerunfailures` pytest plugin to re-run tests to eliminate flaky failures Nov 20, 2024 5 - Production/Stable pytest!=8.2.2,>=7.4 :pypi:`pytest-rerunfailures-all-logs` pytest plugin to re-run tests to eliminate flaky failures Mar 07, 2022 5 - Production/Stable N/A :pypi:`pytest-reserial` Pytest fixture for recording and replaying serial port traffic. Jul 23, 2024 4 - Beta pytest :pypi:`pytest-resilient-circuits` Resilient Circuits fixtures for PyTest Jul 16, 2024 N/A pytest~=7.0 @@ -1228,9 +1229,9 @@ This list contains 1545 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Nov 15, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Nov 19, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A - :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 19, 2024 5 - Production/Stable pytest>=7.2.0 + :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A :pypi:`pytest-schema` 👍 Validate return values against a schema-like object in testing Feb 16, 2024 5 - Production/Stable pytest >=3.5.0 :pypi:`pytest-screenshot-on-failure` Saves a screenshot when a test case from a pytest execution fails Jul 21, 2023 4 - Beta N/A @@ -1239,7 +1240,7 @@ This list contains 1545 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Nov 15, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Nov 19, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1512,11 +1513,11 @@ This list contains 1545 plugins. :pypi:`pytest-vscode-pycharm-cls` A PyTest helper to enable start remote debugger on test start or failure or when pytest.set_trace is used. Feb 01, 2023 N/A pytest :pypi:`pytest-vtestify` A pytest plugin for visual assertion using SSIM and image comparison. Oct 10, 2024 N/A pytest :pypi:`pytest-vts` pytest plugin for automatic recording of http stubbed tests Jun 05, 2019 N/A pytest (>=2.3) - :pypi:`pytest-vulture` A pytest plugin to checks dead code with vulture Jun 01, 2023 N/A pytest (>=7.0.0) + :pypi:`pytest-vulture` A pytest plugin to checks dead code with vulture Nov 22, 2024 N/A pytest>=7.0.0 :pypi:`pytest-vw` pytest-vw makes your failing test cases succeed under CI tools scrutiny Oct 07, 2015 4 - Beta N/A :pypi:`pytest-vyper` Plugin for the vyper smart contract language. May 28, 2020 2 - Pre-Alpha N/A :pypi:`pytest-wa-e2e-plugin` Pytest plugin for testing whatsapp bots with end to end tests Feb 18, 2020 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-wake` Mar 20, 2024 N/A pytest + :pypi:`pytest-wake` Nov 19, 2024 N/A pytest :pypi:`pytest-watch` Local continuous test runner with pytest and watchdog. May 20, 2018 N/A N/A :pypi:`pytest-watcher` Automatically rerun your tests on file modifications Aug 28, 2024 4 - Beta N/A :pypi:`pytest-watch-plugin` Placeholder for internal package Sep 12, 2024 N/A N/A @@ -1557,7 +1558,7 @@ This list contains 1545 plugins. :pypi:`pytest-xvfb` A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. May 29, 2023 4 - Beta pytest (>=2.8.1) :pypi:`pytest-xvirt` A pytest plugin to virtualize test. For example to transparently running them on a remote box. Oct 01, 2024 4 - Beta pytest>=7.2.2 :pypi:`pytest-yaml` This plugin is used to load yaml output to your test using pytest framework. Oct 05, 2018 N/A pytest - :pypi:`pytest-yaml-sanmu` Pytest plugin for generating test cases with YAML. In test cases, you can use markers, fixtures, variables, and even call Python functions. Aug 16, 2024 N/A pytest~=8.2.2 + :pypi:`pytest-yaml-sanmu` Pytest plugin for generating test cases with YAML. In test cases, you can use markers, fixtures, variables, and even call Python functions. Nov 20, 2024 N/A pytest~=8.2.2 :pypi:`pytest-yamltree` Create or check file/directory trees described by YAML Mar 02, 2020 4 - Beta pytest (>=3.1.1) :pypi:`pytest-yamlwsgi` Run tests against wsgi apps defined in yaml May 11, 2010 N/A N/A :pypi:`pytest-yaml-yoyo` http/https API run by yaml Jun 19, 2023 N/A pytest (>=7.2.0) @@ -2446,7 +2447,7 @@ This list contains 1545 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Nov 11, 2024, + *last release*: Nov 18, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -2823,6 +2824,13 @@ This list contains 1545 plugins. pytest plugin to capture all warnings and put them in one file of your choice + :pypi:`pytest-case` + *last release*: Nov 22, 2024, + *status*: N/A, + *requires*: pytest<9.0.0,>=8.3.3 + + A clean, modern, wrapper for pytest.mark.parametrize + :pypi:`pytest-cases` *last release*: Sep 26, 2024, *status*: 5 - Production/Stable, @@ -4560,7 +4568,7 @@ This list contains 1545 plugins. pytest plugin with mechanisms for echoing environment variables, package version and generic attributes :pypi:`pytest-edit` - *last release*: Jun 09, 2024, + *last release*: Nov 17, 2024, *status*: N/A, *requires*: pytest @@ -4861,14 +4869,14 @@ This list contains 1545 plugins. Parse queries in Lucene and Elasticsearch syntaxes :pypi:`pytest-examples` - *last release*: Nov 15, 2024, + *last release*: Nov 20, 2024, *status*: N/A, *requires*: pytest>=7 Pytest plugin for testing examples in docstrings and markdown files. :pypi:`pytest-exasol-backend` - *last release*: Oct 31, 2024, + *last release*: Nov 22, 2024, *status*: N/A, *requires*: pytest<9,>=7 @@ -4889,7 +4897,7 @@ This list contains 1545 plugins. :pypi:`pytest-exasol-saas` - *last release*: Aug 06, 2024, + *last release*: Nov 22, 2024, *status*: N/A, *requires*: pytest<9,>=7 @@ -5680,7 +5688,7 @@ This list contains 1545 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Nov 07, 2024, + *last release*: Nov 19, 2024, *status*: N/A, *requires*: pytest>=3.6 @@ -6163,7 +6171,7 @@ This list contains 1545 plugins. http_testing framework on top of pytest :pypi:`pytest-httpx` - *last release*: Oct 28, 2024, + *last release*: Nov 18, 2024, *status*: 5 - Production/Stable, *requires*: pytest==8.* @@ -6457,7 +6465,7 @@ This list contains 1545 plugins. Pytest plugin for intercepting outgoing connection requests during pytest run. :pypi:`pytest-interface-tester` - *last release*: Sep 25, 2024, + *last release*: Nov 19, 2024, *status*: 4 - Beta, *requires*: pytest @@ -8991,9 +8999,9 @@ This list contains 1545 plugins. A plugin that transforms the pytest output into a result similar to the RSpec. It enables the use of docstrings to display results and also enables the use of the prefixes "describe", "with" and "it". :pypi:`pytest-pystack` - *last release*: Jan 04, 2024, + *last release*: Nov 16, 2024, *status*: N/A, - *requires*: pytest >=3.5.0 + *requires*: pytest>=3.5.0 Plugin to run pystack after a timeout for a test suite. @@ -9054,7 +9062,7 @@ This list contains 1545 plugins. A pytest plugin to collect test information :pypi:`pytest-qaseio` - *last release*: Nov 15, 2024, + *last release*: Nov 18, 2024, *status*: 5 - Production/Stable, *requires*: pytest<9.0.0,>=7.2.2 @@ -9572,9 +9580,9 @@ This list contains 1545 plugins. pytest rerun class failures plugin :pypi:`pytest-rerunfailures` - *last release*: Mar 13, 2024, + *last release*: Nov 20, 2024, *status*: 5 - Production/Stable, - *requires*: pytest >=7.2 + *requires*: pytest!=8.2.2,>=7.4 pytest plugin to re-run tests to eliminate flaky failures @@ -9943,7 +9951,7 @@ This list contains 1545 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Nov 15, 2024, + *last release*: Nov 19, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -9957,9 +9965,9 @@ This list contains 1545 plugins. pytest plugin for test scenarios :pypi:`pytest-scenario-files` - *last release*: May 19, 2024, + *last release*: Nov 21, 2024, *status*: 5 - Production/Stable, - *requires*: pytest>=7.2.0 + *requires*: pytest>=7.0 A pytest plugin that generates unit test scenarios from data files. @@ -10020,7 +10028,7 @@ This list contains 1545 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Nov 15, 2024, + *last release*: Nov 19, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -11931,9 +11939,9 @@ This list contains 1545 plugins. pytest plugin for automatic recording of http stubbed tests :pypi:`pytest-vulture` - *last release*: Jun 01, 2023, + *last release*: Nov 22, 2024, *status*: N/A, - *requires*: pytest (>=7.0.0) + *requires*: pytest>=7.0.0 A pytest plugin to checks dead code with vulture @@ -11959,7 +11967,7 @@ This list contains 1545 plugins. Pytest plugin for testing whatsapp bots with end to end tests :pypi:`pytest-wake` - *last release*: Mar 20, 2024, + *last release*: Nov 19, 2024, *status*: N/A, *requires*: pytest @@ -12246,7 +12254,7 @@ This list contains 1545 plugins. This plugin is used to load yaml output to your test using pytest framework. :pypi:`pytest-yaml-sanmu` - *last release*: Aug 16, 2024, + *last release*: Nov 20, 2024, *status*: N/A, *requires*: pytest~=8.2.2 From 022d316addadbe407e813cc902f2439431605cbc Mon Sep 17 00:00:00 2001 From: sven <42868792+FreerGit@users.noreply.github.com> Date: Sun, 24 Nov 2024 23:20:10 +0100 Subject: [PATCH 180/445] Ensure correct collection of reports --- testing/test_collect_imports.py | 59 +++++++++++++-------------------- 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/testing/test_collect_imports.py b/testing/test_collect_imports.py index cc1c5a80015..1c56c9155e5 100644 --- a/testing/test_collect_imports.py +++ b/testing/test_collect_imports.py @@ -8,6 +8,7 @@ from _pytest.pytester import Pytester from _pytest.pytester import RecordedHookCall from _pytest.pytester import RunResult +from _pytest.reports import CollectReport import pytest @@ -71,7 +72,12 @@ def test_collect_imports_disabled(pytester: Pytester) -> None: # Verify that the state of hooks reprec = pytester.inline_run() + reports = reprec.getreports("pytest_collectreport") + modified = reprec.getcalls("pytest_collection_modifyitems") items_collected = reprec.getcalls("pytest_itemcollected") + + assert len(reports) == 5 + assert len(modified) == 1 assert len(items_collected) == 1 for x in items_collected: assert x.item._getobj().__name__ == "test_testament" @@ -79,7 +85,6 @@ def test_collect_imports_disabled(pytester: Pytester) -> None: def test_collect_imports_default(pytester: Pytester) -> None: run_import_class_test(pytester, errors=1) - # TODO def test_collect_imports_enabled(pytester: Pytester) -> None: @@ -260,7 +265,6 @@ def _test_hook_behaviour_when_collect_off(self, pytester: Pytester) -> None: } def _test_hook_behaviour(self) -> None: - print("ABCD", self.collect_outcomes) default = self.collect_outcomes["default"] collect_off = self.collect_outcomes["collect_off"] @@ -294,37 +298,20 @@ def _test_hook_behaviour(self) -> None: off_items = off_items_record.__dict__["item"] assert def_items.name == off_items.name - # TODO: fix diff: (This will get cleaned up) - # [ - # , - # - , - # , - # , - # , - # - , - # ? ^ - # + , - # ? ^ - # ] - - for x in default["reports"]: - print("def", x.__dict__) - - for x in collect_off["reports"]: - print("off", x.__dict__) - - # The two above loops prints: - - # def {'nodeid': '', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 - # def {'nodeid': 'tests/foo_test.py::TestDomain', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 - # def {'nodeid': 'tests/foo_test.py', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 - # def {'nodeid': 'tests', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 - # def {'nodeid': '.', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 - # off {'nodeid': '', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 - # off {'nodeid': 'src', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} - # off {'nodeid': 'tests/foo_test.py::TestDomain', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 - # off {'nodeid': 'tests/foo_test.py', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 - # off {'nodeid': 'tests', 'outcome': 'passed', 'longrepr': None, 'result': [], 'sections': []} # noqa: E501 - # off {'nodeid': '.', 'outcome': 'passed', 'longrepr': None, 'result': [, ], 'sections': []} # noqa: E501 - - assert len(default["reports"]) == len(collect_off["reports"]) + def compare_report(r1: CollectReport, r2: CollectReport) -> None: + assert r1.result[0].name == r2.result[0].name + assert len(r1.result) == len(r2.result) + assert r1.outcome == r2.outcome + + # Function test_important + compare_report(default["reports"][1], collect_off["reports"][2]) + # Class TestDomain + compare_report(default["reports"][2], collect_off["reports"][3]) + # Module foo_test.py + compare_report(default["reports"][3], collect_off["reports"][4]) + + # + 1 since src dir is collected + assert len(default["reports"]) + 1 == len(collect_off["reports"]) + + # Two Dirs will be collected, src and test. + assert len(collect_off["reports"][5].result) == 2 From 3b230e06dbcc6a3472fc7cfecdc33e420b7cdb11 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 07:02:43 +0100 Subject: [PATCH 181/445] build(deps): Bump pytest-rerunfailures in /testing/plugins_integration (#12988) Bumps [pytest-rerunfailures](https://github.com/pytest-dev/pytest-rerunfailures) from 14.0 to 15.0. - [Changelog](https://github.com/pytest-dev/pytest-rerunfailures/blob/master/CHANGES.rst) - [Commits](https://github.com/pytest-dev/pytest-rerunfailures/compare/14.0...15.0) --- updated-dependencies: - dependency-name: pytest-rerunfailures dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 9ca5d1cfde0..ec6b9418c93 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -7,7 +7,7 @@ pytest-django==4.9.0 pytest-flakes==4.0.5 pytest-html==4.1.1 pytest-mock==3.14.0 -pytest-rerunfailures==14.0 +pytest-rerunfailures==15.0 pytest-sugar==1.0.0 pytest-trio==0.8.0 pytest-twisted==1.14.3 From 76e044477010dcc0e31d4a736b7130e044a01a7e Mon Sep 17 00:00:00 2001 From: Leonardus Chen Date: Mon, 25 Nov 2024 19:25:50 +0700 Subject: [PATCH 182/445] pytest.fail: fix ANSI escape codes for colored output (#12959) - When `ReprEntry.style == "value"` (happens when calling `pytest.fail(..., pytrace=False)`, the message should not be printed to terminal using `TerminalWriter._write_source` because then it'll try to highlight the message as source code - The message should be printed to terminal directly using `TerminalWriter.line` or `TerminalWriter.write`, I went with the later for testing purposes https://github.com/pytest-dev/pytest/pull/12959#discussion_r1842574618 Closes #12849 --- AUTHORS | 1 + changelog/12849.bugfix.rst | 1 + src/_pytest/_code/code.py | 16 +++++++++++----- testing/code/test_excinfo.py | 17 +++++++++++++++++ testing/conftest.py | 4 ++-- 5 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 changelog/12849.bugfix.rst diff --git a/AUTHORS b/AUTHORS index c38f74d9980..303d04133cb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -247,6 +247,7 @@ Kristoffer Nordström Kyle Altendorf Lawrence Mitchell Lee Kamentsky +Leonardus Chen Lev Maximov Levon Saldamli Lewis Cowles diff --git a/changelog/12849.bugfix.rst b/changelog/12849.bugfix.rst new file mode 100644 index 00000000000..fb72263aadd --- /dev/null +++ b/changelog/12849.bugfix.rst @@ -0,0 +1 @@ +ANSI escape codes for colored output now handled correctly in :func:`pytest.fail` with `pytrace=False`. diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 8fac39ea298..fec627b3a36 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -1221,6 +1221,15 @@ def _write_entry_lines(self, tw: TerminalWriter) -> None: if not self.lines: return + if self.style == "value": + # Using tw.write instead of tw.line for testing purposes due to TWMock implementation; + # lines written with TWMock.line and TWMock._write_source cannot be distinguished + # from each other, whereas lines written with TWMock.write are marked with TWMock.WRITE + for line in self.lines: + tw.write(line) + tw.write("\n") + return + # separate indents and source lines that are not failures: we want to # highlight the code but not the indentation, which may contain markers # such as "> assert 0" @@ -1236,11 +1245,8 @@ def _write_entry_lines(self, tw: TerminalWriter) -> None: failure_lines.extend(self.lines[index:]) break else: - if self.style == "value": - source_lines.append(line) - else: - indents.append(line[:indent_size]) - source_lines.append(line[indent_size:]) + indents.append(line[:indent_size]) + source_lines.append(line[indent_size:]) tw._write_source(source_lines, indents) diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index fc60ae9ac99..97c207e9795 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -1194,6 +1194,23 @@ def f(): line = tw_mock.lines[-1] assert line == ":3: ValueError" + def test_toterminal_value(self, importasmod, tw_mock): + mod = importasmod( + """ + def g(x): + raise ValueError(x) + def f(): + g('some_value') + """ + ) + excinfo = pytest.raises(ValueError, mod.f) + excinfo.traceback = excinfo.traceback.filter(excinfo) + repr = excinfo.getrepr(style="value") + repr.toterminal(tw_mock) + + assert tw_mock.get_write_msg(0) == "some_value" + assert tw_mock.get_write_msg(1) == "\n" + @pytest.mark.parametrize( "reproptions", [ diff --git a/testing/conftest.py b/testing/conftest.py index 046bb77a109..69af03324d6 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -119,8 +119,8 @@ def markup(self, text, **kw): return text def get_write_msg(self, idx): - flag, msg = self.lines[idx] - assert flag == TWMock.WRITE + assert self.lines[idx][0] == TWMock.WRITE + msg = self.lines[idx][1] return msg fullwidth = 80 From 2157caf87960d904c8547c9168c94a7d535f21e0 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 25 Nov 2024 12:29:01 +0000 Subject: [PATCH 183/445] docs: Fix wrong statement about sys.modules with importlib import mode (#12985) Follow-up to #7870, see #12983. --- doc/en/explanation/goodpractices.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/en/explanation/goodpractices.rst b/doc/en/explanation/goodpractices.rst index 1390ba4e8fe..51c0b960aed 100644 --- a/doc/en/explanation/goodpractices.rst +++ b/doc/en/explanation/goodpractices.rst @@ -210,8 +210,8 @@ Note that this layout also works in conjunction with the ``src`` layout mentione to avoid surprises such as a test module getting imported twice. With ``--import-mode=importlib`` things are less convoluted because - pytest doesn't need to change ``sys.path`` or ``sys.modules``, making things - much less surprising. + pytest doesn't need to change ``sys.path``, making things much less + surprising. .. _which-import-mode: From a4cb74e8646dc3cfaa1c4d5b36e0d21f177332e6 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Sun, 10 Nov 2024 19:25:05 +0100 Subject: [PATCH 184/445] Upgrade doc and CI after dropping python 3.8 --- .github/workflows/prepare-release-pr.yml | 2 +- .github/workflows/test.yml | 103 +++++++++++++---------- .pre-commit-config.yaml | 4 + CONTRIBUTING.rst | 2 +- README.rst | 2 +- changelog/12874.breaking.rst | 1 + doc/en/backwards-compatibility.rst | 1 + pyproject.toml | 7 +- scripts/generate-gh-release-notes.py | 2 +- scripts/update-plugin-list.py | 4 +- src/_pytest/_code/code.py | 15 ++-- src/_pytest/_code/source.py | 4 +- src/_pytest/_io/pprint.py | 2 +- src/_pytest/_io/terminalwriter.py | 2 +- src/_pytest/assertion/__init__.py | 2 +- src/_pytest/assertion/rewrite.py | 6 +- src/_pytest/assertion/util.py | 6 +- src/_pytest/cacheprovider.py | 4 +- src/_pytest/capture.py | 6 +- src/_pytest/config/__init__.py | 10 +-- src/_pytest/config/argparsing.py | 7 +- src/_pytest/config/compat.py | 2 +- src/_pytest/config/findpaths.py | 4 +- src/_pytest/debugging.py | 2 +- src/_pytest/doctest.py | 8 +- src/_pytest/faulthandler.py | 2 +- src/_pytest/fixtures.py | 24 +++--- src/_pytest/freeze_support.py | 2 +- src/_pytest/helpconfig.py | 2 +- src/_pytest/hookspec.py | 4 +- src/_pytest/junitxml.py | 2 +- src/_pytest/logging.py | 25 +++--- src/_pytest/main.py | 9 +- src/_pytest/mark/__init__.py | 4 +- src/_pytest/mark/expression.py | 6 +- src/_pytest/mark/structures.py | 12 +-- src/_pytest/monkeypatch.py | 6 +- src/_pytest/nodes.py | 6 +- src/_pytest/outcomes.py | 3 +- src/_pytest/pathlib.py | 4 +- src/_pytest/pytester.py | 6 +- src/_pytest/pytester_assertions.py | 2 +- src/_pytest/python.py | 15 ++-- src/_pytest/python_api.py | 10 +-- src/_pytest/recwarn.py | 6 +- src/_pytest/reports.py | 8 +- src/_pytest/setuponly.py | 2 +- src/_pytest/skipping.py | 2 +- src/_pytest/terminal.py | 6 +- src/_pytest/threadexception.py | 2 +- src/_pytest/tmpdir.py | 5 +- src/_pytest/unittest.py | 10 +-- src/_pytest/unraisableexception.py | 2 +- src/_pytest/warnings.py | 2 +- testing/code/test_excinfo.py | 4 +- testing/code/test_source.py | 2 +- testing/conftest.py | 2 +- testing/io/test_terminalwriter.py | 2 +- testing/logging/test_fixture.py | 2 +- testing/python/metafunc.py | 7 +- testing/test_assertion.py | 2 +- testing/test_assertrewrite.py | 4 +- testing/test_cacheprovider.py | 4 +- testing/test_capture.py | 2 +- testing/test_config.py | 2 +- testing/test_conftest.py | 7 +- testing/test_monkeypatch.py | 2 +- testing/test_pathlib.py | 6 +- testing/test_reports.py | 2 +- tox.ini | 9 +- 70 files changed, 230 insertions(+), 226 deletions(-) create mode 100644 changelog/12874.breaking.rst diff --git a/.github/workflows/prepare-release-pr.yml b/.github/workflows/prepare-release-pr.yml index 1bb23fab844..f46b5cecda5 100644 --- a/.github/workflows/prepare-release-pr.yml +++ b/.github/workflows/prepare-release-pr.yml @@ -34,7 +34,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: "3.x" - name: Install dependencies run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1ea62f6c8b..30536706afb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,25 +54,24 @@ jobs: fail-fast: false matrix: name: [ - "windows-py38", - "windows-py38-pluggy", - "windows-py39", + "windows-py39-unittestextras", + "windows-py39-pluggy", + "windows-py39-xdist", "windows-py310", "windows-py311", "windows-py312", "windows-py313", - "ubuntu-py38", - "ubuntu-py38-pluggy", - "ubuntu-py38-freeze", - "ubuntu-py39", - "ubuntu-py310", + "ubuntu-py39-lsof-numpy-pexpect", + "ubuntu-py39-pluggy", + "ubuntu-py39-freeze", + "ubuntu-py39-xdist", + "ubuntu-py310-xdist", "ubuntu-py311", "ubuntu-py312", - "ubuntu-py313", - "ubuntu-pypy3", + "ubuntu-py313-pexpect", + "ubuntu-pypy3-xdist", - "macos-py38", "macos-py39", "macos-py310", "macos-py312", @@ -83,106 +82,122 @@ jobs: ] include: - - name: "windows-py38" - python: "3.8" + - name: "windows-py39-unittestextras" + python: "3.9" os: windows-latest - tox_env: "py38-unittestextras" + tox_env: "py39-unittestextras" use_coverage: true - - name: "windows-py38-pluggy" - python: "3.8" + + - name: "windows-py39-pluggy" + python: "3.9" os: windows-latest - tox_env: "py38-pluggymain-pylib-xdist" - - name: "windows-py39" + tox_env: "py39-pluggymain-pylib-xdist" + + - name: "windows-py39-xdist" python: "3.9" os: windows-latest tox_env: "py39-xdist" + - name: "windows-py310" python: "3.10" os: windows-latest tox_env: "py310-xdist" + - name: "windows-py311" python: "3.11" os: windows-latest tox_env: "py311" + - name: "windows-py312" python: "3.12" os: windows-latest tox_env: "py312" + - name: "windows-py313" - python: "3.13-dev" + python: "3.13" os: windows-latest tox_env: "py313" - - name: "ubuntu-py38" - python: "3.8" + + - name: "ubuntu-py39-lsof-numpy-pexpect" + python: "3.9" os: ubuntu-latest - tox_env: "py38-lsof-numpy-pexpect" - use_coverage: true - - name: "ubuntu-py38-pluggy" - python: "3.8" + tox_env: "py39-lsof-numpy-pexpect" + + - name: "ubuntu-py39-pluggy" + python: "3.9" os: ubuntu-latest - tox_env: "py38-pluggymain-pylib-xdist" - - name: "ubuntu-py38-freeze" - python: "3.8" + tox_env: "py39-pluggymain-pylib-xdist" + + - name: "ubuntu-py39-freeze" + python: "3.9" os: ubuntu-latest - tox_env: "py38-freeze" - - name: "ubuntu-py39" + tox_env: "py39-freeze" + + - name: "ubuntu-py39-xdist" python: "3.9" os: ubuntu-latest tox_env: "py39-xdist" - - name: "ubuntu-py310" + + - name: "ubuntu-py310-xdist" python: "3.10" os: ubuntu-latest tox_env: "py310-xdist" + - name: "ubuntu-py311" python: "3.11" os: ubuntu-latest tox_env: "py311" use_coverage: true + - name: "ubuntu-py312" python: "3.12" os: ubuntu-latest tox_env: "py312" use_coverage: true - - name: "ubuntu-py313" - python: "3.13-dev" + + - name: "ubuntu-py313-pexpect" + python: "3.13" os: ubuntu-latest tox_env: "py313-pexpect" use_coverage: true - - name: "ubuntu-pypy3" + + - name: "ubuntu-pypy3-xdist" python: "pypy-3.9" os: ubuntu-latest tox_env: "pypy3-xdist" - - name: "macos-py38" - python: "3.8" - os: macos-latest - tox_env: "py38-xdist" + - name: "macos-py39" python: "3.9" os: macos-latest tox_env: "py39-xdist" use_coverage: true + - name: "macos-py310" python: "3.10" os: macos-latest tox_env: "py310-xdist" + - name: "macos-py312" python: "3.12" os: macos-latest tox_env: "py312-xdist" + - name: "macos-py313" - python: "3.13-dev" + python: "3.13" os: macos-latest tox_env: "py313-xdist" + - name: "plugins" python: "3.12" os: ubuntu-latest tox_env: "plugins" + - name: "doctesting" - python: "3.8" + python: "3.9" os: ubuntu-latest tox_env: "doctesting" use_coverage: true @@ -192,12 +207,12 @@ jobs: contains( fromJSON( '[ - "windows-py38-pluggy", + "windows-py39-pluggy", "windows-py313", - "ubuntu-py38-pluggy", - "ubuntu-py38-freeze", + "ubuntu-py39-pluggy", + "ubuntu-py39-freeze", "ubuntu-py313", - "macos-py38", + "macos-py39", "macos-py313" ]' ), diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9e7be8cf6db..cb02fd0f00f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -53,6 +53,10 @@ repos: rev: v3.19.0 hooks: - id: pyupgrade + args: + - "--py39-plus" + # Manual because ruff does what pyupgrade does and the two are not out of sync + # often enough to make launching pyupgrade everytime worth it stages: [manual] - repo: local hooks: diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index d615e5fb113..56824a43ff4 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -270,7 +270,7 @@ Here is a simple overview, with pytest-specific bits: #. Run all the tests - You need to have Python 3.8 or later available in your system. Now + You need to have Python 3.9 or later available in your system. Now running tests is as simple as issuing this command:: $ tox -e linting,py39 diff --git a/README.rst b/README.rst index a81e082cdd7..091afc363da 100644 --- a/README.rst +++ b/README.rst @@ -97,7 +97,7 @@ Features - Can run `unittest `_ (or trial) test suites out of the box -- Python 3.8+ or PyPy3 +- Python 3.9+ or PyPy3 - Rich plugin architecture, with over 1300+ `external plugins `_ and thriving community diff --git a/changelog/12874.breaking.rst b/changelog/12874.breaking.rst new file mode 100644 index 00000000000..a442586eeb5 --- /dev/null +++ b/changelog/12874.breaking.rst @@ -0,0 +1 @@ +We dropped support for Python 3.8 following its end of life (2024-10-07). diff --git a/doc/en/backwards-compatibility.rst b/doc/en/backwards-compatibility.rst index c0feb833ce1..82f678b4dea 100644 --- a/doc/en/backwards-compatibility.rst +++ b/doc/en/backwards-compatibility.rst @@ -83,6 +83,7 @@ Released pytest versions support all Python versions that are actively maintaine ============== =================== pytest version min. Python version ============== =================== +8.4+ 3.9+ 8.0+ 3.8+ 7.1+ 3.7+ 6.2 - 7.0 3.6+ diff --git a/pyproject.toml b/pyproject.toml index 50fcfc65353..0541da9906e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ authors = [ { name = "Florian Bruhin" }, { name = "Others (See AUTHORS)" }, ] -requires-python = ">=3.8" +requires-python = ">=3.9" classifiers = [ "Development Status :: 6 - Mature", "Intended Audience :: Developers", @@ -33,7 +33,6 @@ classifiers = [ "Operating System :: POSIX", "Operating System :: Unix", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -85,7 +84,7 @@ write_to = "src/_pytest/_version.py" [tool.black] target-version = [ - 'py38', + 'py39', ] [tool.ruff] @@ -508,7 +507,7 @@ files = [ mypy_path = [ "src", ] -python_version = "3.8" +python_version = "3.9" check_untyped_defs = true disallow_any_generics = true disallow_untyped_defs = true diff --git a/scripts/generate-gh-release-notes.py b/scripts/generate-gh-release-notes.py index 7f195ba1e0a..b6d92d085e1 100644 --- a/scripts/generate-gh-release-notes.py +++ b/scripts/generate-gh-release-notes.py @@ -11,10 +11,10 @@ from __future__ import annotations +from collections.abc import Sequence from pathlib import Path import re import sys -from typing import Sequence import pypandoc diff --git a/scripts/update-plugin-list.py b/scripts/update-plugin-list.py index 556004d9e98..693a25a00cc 100644 --- a/scripts/update-plugin-list.py +++ b/scripts/update-plugin-list.py @@ -1,14 +1,14 @@ # mypy: disallow-untyped-defs from __future__ import annotations +from collections.abc import Iterable +from collections.abc import Iterator import datetime import pathlib import re from textwrap import dedent from textwrap import indent from typing import Any -from typing import Iterable -from typing import Iterator from typing import TypedDict import packaging.version diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index dd3fd7addb6..ea7415be23e 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -2,6 +2,9 @@ from __future__ import annotations import ast +from collections.abc import Iterable +from collections.abc import Mapping +from collections.abc import Sequence import dataclasses import inspect from inspect import CO_VARARGS @@ -10,6 +13,7 @@ import os from pathlib import Path import re +from re import Pattern import sys import traceback from traceback import format_exception_only @@ -22,16 +26,9 @@ from typing import Final from typing import final from typing import Generic -from typing import Iterable -from typing import List from typing import Literal -from typing import Mapping from typing import overload -from typing import Pattern -from typing import Sequence from typing import SupportsIndex -from typing import Tuple -from typing import Type from typing import TypeVar from typing import Union @@ -56,7 +53,7 @@ TracebackStyle = Literal["long", "short", "line", "no", "native", "value", "auto"] -EXCEPTION_OR_MORE = Union[Type[BaseException], Tuple[Type[BaseException], ...]] +EXCEPTION_OR_MORE = Union[type[BaseException], tuple[type[BaseException], ...]] class Code: @@ -320,7 +317,7 @@ def name(self) -> str: return self.frame.code.raw.co_name -class Traceback(List[TracebackEntry]): +class Traceback(list[TracebackEntry]): """Traceback objects encapsulate and offer higher level access to Traceback entries.""" def __init__( diff --git a/src/_pytest/_code/source.py b/src/_pytest/_code/source.py index 604aff8ba19..e24ee3a260e 100644 --- a/src/_pytest/_code/source.py +++ b/src/_pytest/_code/source.py @@ -3,12 +3,12 @@ import ast from bisect import bisect_right +from collections.abc import Iterable +from collections.abc import Iterator import inspect import textwrap import tokenize import types -from typing import Iterable -from typing import Iterator from typing import overload import warnings diff --git a/src/_pytest/_io/pprint.py b/src/_pytest/_io/pprint.py index 7a6433d9128..d212b773166 100644 --- a/src/_pytest/_io/pprint.py +++ b/src/_pytest/_io/pprint.py @@ -16,6 +16,7 @@ from __future__ import annotations import collections as _collections +from collections.abc import Iterator import dataclasses as _dataclasses from io import StringIO as _StringIO import re @@ -23,7 +24,6 @@ from typing import Any from typing import Callable from typing import IO -from typing import Iterator class _safe_key: diff --git a/src/_pytest/_io/terminalwriter.py b/src/_pytest/_io/terminalwriter.py index 70ebd3d061b..50ce463f6b2 100644 --- a/src/_pytest/_io/terminalwriter.py +++ b/src/_pytest/_io/terminalwriter.py @@ -2,12 +2,12 @@ from __future__ import annotations +from collections.abc import Sequence import os import shutil import sys from typing import final from typing import Literal -from typing import Sequence from typing import TextIO from typing import TYPE_CHECKING diff --git a/src/_pytest/assertion/__init__.py b/src/_pytest/assertion/__init__.py index cbdf9fa0298..532b96fe431 100644 --- a/src/_pytest/assertion/__init__.py +++ b/src/_pytest/assertion/__init__.py @@ -3,9 +3,9 @@ from __future__ import annotations +from collections.abc import Generator import sys from typing import Any -from typing import Generator from typing import TYPE_CHECKING from _pytest.assertion import rewrite diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index 37c09b03467..05934797a14 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -4,6 +4,9 @@ import ast from collections import defaultdict +from collections.abc import Iterable +from collections.abc import Iterator +from collections.abc import Sequence import errno import functools import importlib.abc @@ -21,9 +24,6 @@ import types from typing import Callable from typing import IO -from typing import Iterable -from typing import Iterator -from typing import Sequence from typing import TYPE_CHECKING from _pytest._io.saferepr import DEFAULT_REPR_MAX_SIZE diff --git a/src/_pytest/assertion/util.py b/src/_pytest/assertion/util.py index 4dc1af4af03..3593f0ce036 100644 --- a/src/_pytest/assertion/util.py +++ b/src/_pytest/assertion/util.py @@ -4,16 +4,16 @@ from __future__ import annotations import collections.abc +from collections.abc import Iterable +from collections.abc import Mapping +from collections.abc import Sequence import os import pprint from typing import AbstractSet from typing import Any from typing import Callable -from typing import Iterable from typing import Literal -from typing import Mapping from typing import Protocol -from typing import Sequence from unicodedata import normalize from _pytest import outcomes diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index 1b236efdc9b..bf643d6f4dc 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -5,6 +5,8 @@ # pytest-cache version. from __future__ import annotations +from collections.abc import Generator +from collections.abc import Iterable import dataclasses import errno import json @@ -12,8 +14,6 @@ from pathlib import Path import tempfile from typing import final -from typing import Generator -from typing import Iterable from .pathlib import resolve_from_str from .pathlib import rm_rf diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index 2ac3b6bbc7f..93a3b04182e 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -5,6 +5,9 @@ import abc import collections +from collections.abc import Generator +from collections.abc import Iterable +from collections.abc import Iterator import contextlib import io from io import UnsupportedOperation @@ -18,10 +21,7 @@ from typing import cast from typing import Final from typing import final -from typing import Generator from typing import Generic -from typing import Iterable -from typing import Iterator from typing import Literal from typing import NamedTuple from typing import TextIO diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 92cf565e85f..5ec4d7b52ea 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -5,6 +5,10 @@ import argparse import collections.abc +from collections.abc import Generator +from collections.abc import Iterable +from collections.abc import Iterator +from collections.abc import Sequence import contextlib import copy import dataclasses @@ -26,11 +30,7 @@ from typing import cast from typing import Final from typing import final -from typing import Generator from typing import IO -from typing import Iterable -from typing import Iterator -from typing import Sequence from typing import TextIO from typing import Type from typing import TYPE_CHECKING @@ -1978,7 +1978,7 @@ def _resolve_warning_category(category: str) -> type[Warning]: cat = getattr(m, klass) if not issubclass(cat, Warning): raise UsageError(f"{cat} is not a Warning subclass") - return cast(Type[Warning], cat) + return cast(type[Warning], cat) def apply_warning_filters( diff --git a/src/_pytest/config/argparsing.py b/src/_pytest/config/argparsing.py index 85aa4632702..455d2d8db26 100644 --- a/src/_pytest/config/argparsing.py +++ b/src/_pytest/config/argparsing.py @@ -2,6 +2,8 @@ from __future__ import annotations import argparse +from collections.abc import Mapping +from collections.abc import Sequence from gettext import gettext import os import sys @@ -9,11 +11,8 @@ from typing import Callable from typing import cast from typing import final -from typing import List from typing import Literal -from typing import Mapping from typing import NoReturn -from typing import Sequence import _pytest._io from _pytest.config.exceptions import UsageError @@ -144,7 +143,7 @@ def parse_setoption( parsedoption = self.parse(args, namespace=namespace) for name, value in parsedoption.__dict__.items(): setattr(option, name, value) - return cast(List[str], getattr(parsedoption, FILE_OR_DIR)) + return cast(list[str], getattr(parsedoption, FILE_OR_DIR)) def parse_known_args( self, diff --git a/src/_pytest/config/compat.py b/src/_pytest/config/compat.py index 2856d85d195..21eab4c7e47 100644 --- a/src/_pytest/config/compat.py +++ b/src/_pytest/config/compat.py @@ -1,9 +1,9 @@ from __future__ import annotations +from collections.abc import Mapping import functools from pathlib import Path from typing import Any -from typing import Mapping import warnings import pluggy diff --git a/src/_pytest/config/findpaths.py b/src/_pytest/config/findpaths.py index ce4c990b810..a7f45bf593e 100644 --- a/src/_pytest/config/findpaths.py +++ b/src/_pytest/config/findpaths.py @@ -1,10 +1,10 @@ from __future__ import annotations +from collections.abc import Iterable +from collections.abc import Sequence import os from pathlib import Path import sys -from typing import Iterable -from typing import Sequence import iniconfig diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py index 763606cd60e..665d8536262 100644 --- a/src/_pytest/debugging.py +++ b/src/_pytest/debugging.py @@ -5,12 +5,12 @@ from __future__ import annotations import argparse +from collections.abc import Generator import functools import sys import types from typing import Any from typing import Callable -from typing import Generator import unittest from _pytest import outcomes diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index 384dea976ad..a1f680570d8 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -4,21 +4,21 @@ from __future__ import annotations import bdb +from collections.abc import Generator +from collections.abc import Iterable +from collections.abc import Sequence from contextlib import contextmanager import functools import inspect import os from pathlib import Path import platform +from re import Pattern import sys import traceback import types from typing import Any from typing import Callable -from typing import Generator -from typing import Iterable -from typing import Pattern -from typing import Sequence from typing import TYPE_CHECKING import warnings diff --git a/src/_pytest/faulthandler.py b/src/_pytest/faulthandler.py index d16aea1eb88..79efc1d1704 100644 --- a/src/_pytest/faulthandler.py +++ b/src/_pytest/faulthandler.py @@ -1,8 +1,8 @@ from __future__ import annotations +from collections.abc import Generator import os import sys -from typing import Generator from _pytest.config import Config from _pytest.config.argparsing import Parser diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 5817e88f47d..c4a8a09f84a 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -4,6 +4,13 @@ import abc from collections import defaultdict from collections import deque +from collections import OrderedDict +from collections.abc import Generator +from collections.abc import Iterable +from collections.abc import Iterator +from collections.abc import Mapping +from collections.abc import MutableMapping +from collections.abc import Sequence import dataclasses import functools import inspect @@ -15,21 +22,12 @@ from typing import Any from typing import Callable from typing import cast -from typing import Dict from typing import Final from typing import final -from typing import Generator from typing import Generic -from typing import Iterable -from typing import Iterator -from typing import Mapping -from typing import MutableMapping from typing import NoReturn from typing import Optional -from typing import OrderedDict from typing import overload -from typing import Sequence -from typing import Tuple from typing import TYPE_CHECKING from typing import TypeVar from typing import Union @@ -95,19 +93,19 @@ ] # The type of FixtureDef.cached_result (type alias generic in fixture value). _FixtureCachedResult = Union[ - Tuple[ + tuple[ # The result. FixtureValue, # Cache key. object, None, ], - Tuple[ + tuple[ None, # Cache key. object, # The exception and the original traceback. - Tuple[BaseException, Optional[types.TracebackType]], + tuple[BaseException, Optional[types.TracebackType]], ], ] @@ -177,7 +175,7 @@ class FixtureArgKey: _V = TypeVar("_V") -OrderedSet = Dict[_V, None] +OrderedSet = dict[_V, None] def get_parametrized_fixture_argkeys( diff --git a/src/_pytest/freeze_support.py b/src/_pytest/freeze_support.py index 2ba6f9b8bcc..959ff071d86 100644 --- a/src/_pytest/freeze_support.py +++ b/src/_pytest/freeze_support.py @@ -3,8 +3,8 @@ from __future__ import annotations +from collections.abc import Iterator import types -from typing import Iterator def freeze_includes() -> list[str]: diff --git a/src/_pytest/helpconfig.py b/src/_pytest/helpconfig.py index 1886d5c9342..3d607189dbe 100644 --- a/src/_pytest/helpconfig.py +++ b/src/_pytest/helpconfig.py @@ -4,9 +4,9 @@ from __future__ import annotations from argparse import Action +from collections.abc import Generator import os import sys -from typing import Generator from _pytest.config import Config from _pytest.config import ExitCode diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py index 0a41b0aca47..8b20061d6f0 100644 --- a/src/_pytest/hookspec.py +++ b/src/_pytest/hookspec.py @@ -5,10 +5,10 @@ from __future__ import annotations +from collections.abc import Mapping +from collections.abc import Sequence from pathlib import Path from typing import Any -from typing import Mapping -from typing import Sequence from typing import TYPE_CHECKING from pluggy import HookspecMarker diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py index efe6f489b48..46c456a5b6e 100644 --- a/src/_pytest/junitxml.py +++ b/src/_pytest/junitxml.py @@ -16,8 +16,8 @@ import os import platform import re +from re import Match from typing import Callable -from typing import Match import xml.etree.ElementTree as ET from _pytest import nodes diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index 08c826ff6d4..00645dae2da 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -3,6 +3,8 @@ from __future__ import annotations +from collections.abc import Generator +from collections.abc import Mapping from contextlib import contextmanager from contextlib import nullcontext from datetime import datetime @@ -17,13 +19,9 @@ import re from types import TracebackType from typing import AbstractSet -from typing import Dict from typing import final -from typing import Generator from typing import Generic -from typing import List from typing import Literal -from typing import Mapping from typing import TYPE_CHECKING from typing import TypeVar @@ -53,7 +51,7 @@ DEFAULT_LOG_DATE_FORMAT = "%H:%M:%S" _ANSI_ESCAPE_SEQ = re.compile(r"\x1b\[[\d;]+m") caplog_handler_key = StashKey["LogCaptureHandler"]() -caplog_records_key = StashKey[Dict[str, List[logging.LogRecord]]]() +caplog_records_key = StashKey[dict[str, list[logging.LogRecord]]]() def _remove_ansi_escape_sequences(text: str) -> str: @@ -813,13 +811,16 @@ def pytest_runtest_logreport(self) -> None: def _runtest_for(self, item: nodes.Item, when: str) -> Generator[None]: """Implement the internals of the pytest_runtest_xxx() hooks.""" - with catching_logs( - self.caplog_handler, - level=self.log_level, - ) as caplog_handler, catching_logs( - self.report_handler, - level=self.log_level, - ) as report_handler: + with ( + catching_logs( + self.caplog_handler, + level=self.log_level, + ) as caplog_handler, + catching_logs( + self.report_handler, + level=self.log_level, + ) as report_handler, + ): caplog_handler.reset() report_handler.reset() item.stash[caplog_records_key][when] = caplog_handler.records diff --git a/src/_pytest/main.py b/src/_pytest/main.py index e5534e98d69..1e18a60141d 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -3,6 +3,9 @@ from __future__ import annotations import argparse +from collections.abc import Iterable +from collections.abc import Iterator +from collections.abc import Sequence import dataclasses import fnmatch import functools @@ -13,13 +16,9 @@ import sys from typing import AbstractSet from typing import Callable -from typing import Dict from typing import final -from typing import Iterable -from typing import Iterator from typing import Literal from typing import overload -from typing import Sequence from typing import TYPE_CHECKING import warnings @@ -476,7 +475,7 @@ class Failed(Exception): @dataclasses.dataclass -class _bestrelpath_cache(Dict[Path, str]): +class _bestrelpath_cache(dict[Path, str]): __slots__ = ("path",) path: Path diff --git a/src/_pytest/mark/__init__.py b/src/_pytest/mark/__init__.py index a6f0155751a..c8c51d19aa0 100644 --- a/src/_pytest/mark/__init__.py +++ b/src/_pytest/mark/__init__.py @@ -3,10 +3,10 @@ from __future__ import annotations import collections +from collections.abc import Collection +from collections.abc import Iterable import dataclasses from typing import AbstractSet -from typing import Collection -from typing import Iterable from typing import Optional from typing import TYPE_CHECKING diff --git a/src/_pytest/mark/expression.py b/src/_pytest/mark/expression.py index 89cc0e94d3b..d0ab190e3b6 100644 --- a/src/_pytest/mark/expression.py +++ b/src/_pytest/mark/expression.py @@ -23,18 +23,18 @@ from __future__ import annotations import ast +from collections.abc import Iterator +from collections.abc import Mapping +from collections.abc import Sequence import dataclasses import enum import keyword import re import types -from typing import Iterator from typing import Literal -from typing import Mapping from typing import NoReturn from typing import overload from typing import Protocol -from typing import Sequence __all__ = [ diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 14650a64759..09ef7d02cef 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -2,19 +2,19 @@ from __future__ import annotations import collections.abc +from collections.abc import Collection +from collections.abc import Iterable +from collections.abc import Iterator +from collections.abc import Mapping +from collections.abc import MutableMapping +from collections.abc import Sequence import dataclasses import inspect from typing import Any from typing import Callable -from typing import Collection from typing import final -from typing import Iterable -from typing import Iterator -from typing import Mapping -from typing import MutableMapping from typing import NamedTuple from typing import overload -from typing import Sequence from typing import TYPE_CHECKING from typing import TypeVar from typing import Union diff --git a/src/_pytest/monkeypatch.py b/src/_pytest/monkeypatch.py index 46eb1724e35..1285e571551 100644 --- a/src/_pytest/monkeypatch.py +++ b/src/_pytest/monkeypatch.py @@ -3,15 +3,15 @@ from __future__ import annotations +from collections.abc import Generator +from collections.abc import Mapping +from collections.abc import MutableMapping from contextlib import contextmanager import os import re import sys from typing import Any from typing import final -from typing import Generator -from typing import Mapping -from typing import MutableMapping from typing import overload from typing import TypeVar import warnings diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index 51bc5174628..e84fb37c9d0 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -2,6 +2,9 @@ from __future__ import annotations import abc +from collections.abc import Iterable +from collections.abc import Iterator +from collections.abc import MutableMapping from functools import cached_property from inspect import signature import os @@ -10,9 +13,6 @@ from typing import Any from typing import Callable from typing import cast -from typing import Iterable -from typing import Iterator -from typing import MutableMapping from typing import NoReturn from typing import overload from typing import TYPE_CHECKING diff --git a/src/_pytest/outcomes.py b/src/_pytest/outcomes.py index 5b20803e586..ab39bac61b9 100644 --- a/src/_pytest/outcomes.py +++ b/src/_pytest/outcomes.py @@ -9,7 +9,6 @@ from typing import cast from typing import NoReturn from typing import Protocol -from typing import Type from typing import TypeVar from .warning_types import PytestDeprecationWarning @@ -82,7 +81,7 @@ def __init__( # Ideally would just be `exit.Exception = Exit` etc. _F = TypeVar("_F", bound=Callable[..., object]) -_ET = TypeVar("_ET", bound=Type[BaseException]) +_ET = TypeVar("_ET", bound=type[BaseException]) class _WithException(Protocol[_F, _ET]): diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index dd36559ce1b..f6392561951 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -1,6 +1,8 @@ from __future__ import annotations import atexit +from collections.abc import Iterable +from collections.abc import Iterator import contextlib from enum import Enum from errno import EBADF @@ -27,8 +29,6 @@ from types import ModuleType from typing import Any from typing import Callable -from typing import Iterable -from typing import Iterator from typing import TypeVar import uuid import warnings diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 3f7520ee4ad..d19151391b0 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -7,6 +7,9 @@ from __future__ import annotations import collections.abc +from collections.abc import Generator +from collections.abc import Iterable +from collections.abc import Sequence import contextlib from fnmatch import fnmatch import gc @@ -25,12 +28,9 @@ from typing import Callable from typing import Final from typing import final -from typing import Generator from typing import IO -from typing import Iterable from typing import Literal from typing import overload -from typing import Sequence from typing import TextIO from typing import TYPE_CHECKING from weakref import WeakKeyDictionary diff --git a/src/_pytest/pytester_assertions.py b/src/_pytest/pytester_assertions.py index d543798f75a..915cc8a10ff 100644 --- a/src/_pytest/pytester_assertions.py +++ b/src/_pytest/pytester_assertions.py @@ -6,7 +6,7 @@ # module to not be already imported. from __future__ import annotations -from typing import Sequence +from collections.abc import Sequence from _pytest.reports import CollectReport from _pytest.reports import TestReport diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 1456b5212d4..153fbf8893b 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -6,6 +6,11 @@ import abc from collections import Counter from collections import defaultdict +from collections.abc import Generator +from collections.abc import Iterable +from collections.abc import Iterator +from collections.abc import Mapping +from collections.abc import Sequence import dataclasses import enum import fnmatch @@ -14,18 +19,12 @@ import itertools import os from pathlib import Path +from re import Pattern import types from typing import Any from typing import Callable -from typing import Dict from typing import final -from typing import Generator -from typing import Iterable -from typing import Iterator from typing import Literal -from typing import Mapping -from typing import Pattern -from typing import Sequence from typing import TYPE_CHECKING import warnings @@ -1078,7 +1077,7 @@ def get_direct_param_fixture_func(request: FixtureRequest) -> Any: # Used for storing pseudo fixturedefs for direct parametrization. -name2pseudofixturedef_key = StashKey[Dict[str, FixtureDef[Any]]]() +name2pseudofixturedef_key = StashKey[dict[str, FixtureDef[Any]]]() @final diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index d2107c2fc78..30a630c42ff 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -2,24 +2,22 @@ from __future__ import annotations from collections.abc import Collection +from collections.abc import Mapping +from collections.abc import Sequence from collections.abc import Sized from decimal import Decimal import math from numbers import Complex import pprint import re +from re import Pattern from types import TracebackType from typing import Any from typing import Callable from typing import cast from typing import ContextManager from typing import final -from typing import Mapping from typing import overload -from typing import Pattern -from typing import Sequence -from typing import Tuple -from typing import Type from typing import TYPE_CHECKING from typing import TypeVar @@ -1017,7 +1015,7 @@ def __exit__( if not issubclass(exc_type, self.expected_exception): return False # Cast to narrow the exception type now that it's verified. - exc_info = cast(Tuple[Type[E], E, TracebackType], (exc_type, exc_val, exc_tb)) + exc_info = cast(tuple[type[E], E, TracebackType], (exc_type, exc_val, exc_tb)) self.excinfo.fill_unfilled(exc_info) if self.match_expr is not None: self.excinfo.match(self.match_expr) diff --git a/src/_pytest/recwarn.py b/src/_pytest/recwarn.py index 0dc002edd94..fc26fcc78e4 100644 --- a/src/_pytest/recwarn.py +++ b/src/_pytest/recwarn.py @@ -3,16 +3,16 @@ from __future__ import annotations +from collections.abc import Generator +from collections.abc import Iterator from pprint import pformat import re +from re import Pattern from types import TracebackType from typing import Any from typing import Callable from typing import final -from typing import Generator -from typing import Iterator from typing import overload -from typing import Pattern from typing import TYPE_CHECKING from typing import TypeVar diff --git a/src/_pytest/reports.py b/src/_pytest/reports.py index 77cbf773e23..4d926ef6c9e 100644 --- a/src/_pytest/reports.py +++ b/src/_pytest/reports.py @@ -1,6 +1,10 @@ # mypy: allow-untyped-defs from __future__ import annotations +from collections.abc import Iterable +from collections.abc import Iterator +from collections.abc import Mapping +from collections.abc import Sequence import dataclasses from io import StringIO import os @@ -8,12 +12,8 @@ from typing import Any from typing import cast from typing import final -from typing import Iterable -from typing import Iterator from typing import Literal -from typing import Mapping from typing import NoReturn -from typing import Sequence from typing import TYPE_CHECKING from _pytest._code.code import ExceptionChainRepr diff --git a/src/_pytest/setuponly.py b/src/_pytest/setuponly.py index de297f408d3..1e887a896f5 100644 --- a/src/_pytest/setuponly.py +++ b/src/_pytest/setuponly.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Generator +from collections.abc import Generator from _pytest._io.saferepr import saferepr from _pytest.config import Config diff --git a/src/_pytest/skipping.py b/src/_pytest/skipping.py index 9818be2ab03..8fa17a01eb0 100644 --- a/src/_pytest/skipping.py +++ b/src/_pytest/skipping.py @@ -3,13 +3,13 @@ from __future__ import annotations +from collections.abc import Generator from collections.abc import Mapping import dataclasses import os import platform import sys import traceback -from typing import Generator from typing import Optional from _pytest.config import Config diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 55ef1ea8eee..d2baee40d9c 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -8,6 +8,9 @@ import argparse from collections import Counter +from collections.abc import Generator +from collections.abc import Mapping +from collections.abc import Sequence import dataclasses import datetime from functools import partial @@ -20,11 +23,8 @@ from typing import Callable from typing import ClassVar from typing import final -from typing import Generator from typing import Literal -from typing import Mapping from typing import NamedTuple -from typing import Sequence from typing import TextIO from typing import TYPE_CHECKING import warnings diff --git a/src/_pytest/threadexception.py b/src/_pytest/threadexception.py index c1ed80387aa..49560bf7d7f 100644 --- a/src/_pytest/threadexception.py +++ b/src/_pytest/threadexception.py @@ -1,11 +1,11 @@ from __future__ import annotations +from collections.abc import Generator import threading import traceback from types import TracebackType from typing import Any from typing import Callable -from typing import Generator from typing import TYPE_CHECKING import warnings diff --git a/src/_pytest/tmpdir.py b/src/_pytest/tmpdir.py index 1731a4b8d0d..c5b51c87741 100644 --- a/src/_pytest/tmpdir.py +++ b/src/_pytest/tmpdir.py @@ -3,6 +3,7 @@ from __future__ import annotations +from collections.abc import Generator import dataclasses import os from pathlib import Path @@ -10,9 +11,7 @@ from shutil import rmtree import tempfile from typing import Any -from typing import Dict from typing import final -from typing import Generator from typing import Literal from .pathlib import cleanup_dead_symlinks @@ -34,7 +33,7 @@ from _pytest.stash import StashKey -tmppath_result_key = StashKey[Dict[str, bool]]() +tmppath_result_key = StashKey[dict[str, bool]]() RetentionType = Literal["all", "failed", "none"] diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py index 8cecd4f9339..6d967b972ee 100644 --- a/src/_pytest/unittest.py +++ b/src/_pytest/unittest.py @@ -3,16 +3,14 @@ from __future__ import annotations +from collections.abc import Generator +from collections.abc import Iterable import inspect import sys import traceback import types from typing import Any from typing import Callable -from typing import Generator -from typing import Iterable -from typing import Tuple -from typing import Type from typing import TYPE_CHECKING from typing import Union @@ -43,8 +41,8 @@ _SysExcInfoType = Union[ - Tuple[Type[BaseException], BaseException, types.TracebackType], - Tuple[None, None, None], + tuple[type[BaseException], BaseException, types.TracebackType], + tuple[None, None, None], ] diff --git a/src/_pytest/unraisableexception.py b/src/_pytest/unraisableexception.py index 77a2de20041..9ef583137e1 100644 --- a/src/_pytest/unraisableexception.py +++ b/src/_pytest/unraisableexception.py @@ -1,11 +1,11 @@ from __future__ import annotations +from collections.abc import Generator import sys import traceback from types import TracebackType from typing import Any from typing import Callable -from typing import Generator from typing import TYPE_CHECKING import warnings diff --git a/src/_pytest/warnings.py b/src/_pytest/warnings.py index eeb4772649d..87cdbda288f 100644 --- a/src/_pytest/warnings.py +++ b/src/_pytest/warnings.py @@ -1,9 +1,9 @@ # mypy: allow-untyped-defs from __future__ import annotations +from collections.abc import Generator from contextlib import contextmanager import sys -from typing import Generator from typing import Literal import warnings diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index ab56904d040..22e695977e1 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -964,8 +964,8 @@ def raiseos(): upframe = sys._getframe().f_back assert upframe is not None if upframe.f_code.co_name == "_makepath": - # Only raise with expected calls, but not via e.g. inspect for - # py38-windows. + # Only raise with expected calls, and not accidentally via 'inspect' + # See 79ae86cc3f76d69460e1c7beca4ce95e68ab80a6 raised += 1 raise OSError(2, "custom_oserror") return orig_path_cwd() diff --git a/testing/code/test_source.py b/testing/code/test_source.py index a00259976c4..d78d9e7025a 100644 --- a/testing/code/test_source.py +++ b/testing/code/test_source.py @@ -336,7 +336,7 @@ def test_findsource(monkeypatch) -> None: assert src is not None assert "if 1:" in str(src) - d: Dict[str, Any] = {} + d: dict[str, Any] = {} eval(co, d) src, lineno = findsource(d["x"]) assert src is not None diff --git a/testing/conftest.py b/testing/conftest.py index 69af03324d6..110ad0d9b35 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -1,10 +1,10 @@ # mypy: allow-untyped-defs from __future__ import annotations +from collections.abc import Generator import dataclasses import re import sys -from typing import Generator from _pytest.monkeypatch import MonkeyPatch from _pytest.pytester import Pytester diff --git a/testing/io/test_terminalwriter.py b/testing/io/test_terminalwriter.py index 92cde240a11..f14e884b1f0 100644 --- a/testing/io/test_terminalwriter.py +++ b/testing/io/test_terminalwriter.py @@ -1,13 +1,13 @@ # mypy: allow-untyped-defs from __future__ import annotations +from collections.abc import Generator import io import os from pathlib import Path import re import shutil import sys -from typing import Generator from unittest import mock from _pytest._io import terminalwriter diff --git a/testing/logging/test_fixture.py b/testing/logging/test_fixture.py index 0603eaba218..5f94cb8508a 100644 --- a/testing/logging/test_fixture.py +++ b/testing/logging/test_fixture.py @@ -2,8 +2,8 @@ # mypy: disallow-untyped-defs from __future__ import annotations +from collections.abc import Iterator import logging -from typing import Iterator from _pytest.logging import caplog_records_key from _pytest.pytester import Pytester diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 0a4ebf2c9af..df6dbaee0fd 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -1,6 +1,8 @@ # mypy: allow-untyped-defs from __future__ import annotations +from collections.abc import Iterator +from collections.abc import Sequence import dataclasses import itertools import re @@ -8,9 +10,6 @@ import textwrap from typing import Any from typing import cast -from typing import Dict -from typing import Iterator -from typing import Sequence import hypothesis from hypothesis import strategies @@ -154,7 +153,7 @@ class DummyFixtureDef: _scope: Scope fixtures_defs = cast( - Dict[str, Sequence[fixtures.FixtureDef[object]]], + dict[str, Sequence[fixtures.FixtureDef[object]]], dict( session_fix=[DummyFixtureDef(Scope.Session)], package_fix=[DummyFixtureDef(Scope.Package)], diff --git a/testing/test_assertion.py b/testing/test_assertion.py index b10ca1c91f4..a14c4125cf6 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -1,10 +1,10 @@ # mypy: allow-untyped-defs from __future__ import annotations +from collections.abc import MutableSequence import sys import textwrap from typing import Any -from typing import MutableSequence from typing import NamedTuple import attr diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index 7be473d897a..2a988149daf 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -2,6 +2,8 @@ from __future__ import annotations import ast +from collections.abc import Generator +from collections.abc import Mapping import dis import errno from functools import partial @@ -17,8 +19,6 @@ import sys import textwrap from typing import cast -from typing import Generator -from typing import Mapping from unittest import mock import zipfile diff --git a/testing/test_cacheprovider.py b/testing/test_cacheprovider.py index 94bc55d3047..1ba4659d84e 100644 --- a/testing/test_cacheprovider.py +++ b/testing/test_cacheprovider.py @@ -1,13 +1,13 @@ from __future__ import annotations +from collections.abc import Generator +from collections.abc import Sequence from enum import auto from enum import Enum import os from pathlib import Path import shutil from typing import Any -from typing import Generator -from typing import Sequence from _pytest.compat import assert_never from _pytest.config import ExitCode diff --git a/testing/test_capture.py b/testing/test_capture.py index 328de740e8a..98986af6f1f 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -1,6 +1,7 @@ # mypy: allow-untyped-defs from __future__ import annotations +from collections.abc import Generator import contextlib import io from io import UnsupportedOperation @@ -10,7 +11,6 @@ import textwrap from typing import BinaryIO from typing import cast -from typing import Generator from typing import TextIO from _pytest import capture diff --git a/testing/test_config.py b/testing/test_config.py index b2825678b46..53f26269f09 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -1,6 +1,7 @@ # mypy: allow-untyped-defs from __future__ import annotations +from collections.abc import Sequence import dataclasses import importlib.metadata import os @@ -9,7 +10,6 @@ import sys import textwrap from typing import Any -from typing import Sequence import _pytest._code from _pytest.config import _get_plugin_specs_as_list diff --git a/testing/test_conftest.py b/testing/test_conftest.py index ea60c1909c2..bbb1d301ebe 100644 --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -1,13 +1,12 @@ # mypy: allow-untyped-defs from __future__ import annotations +from collections.abc import Generator +from collections.abc import Sequence import os from pathlib import Path import textwrap from typing import cast -from typing import Generator -from typing import List -from typing import Sequence from _pytest.config import ExitCode from _pytest.config import PytestPluginManager @@ -459,7 +458,7 @@ def impct(p, importmode, root, consider_namespace_packages): rootpath=pytester.path, consider_namespace_packages=False, ) - mods = cast(List[Path], conftest._getconftestmodules(sub)) + mods = cast(list[Path], conftest._getconftestmodules(sub)) expected = [ct1, ct2] assert mods == expected diff --git a/testing/test_monkeypatch.py b/testing/test_monkeypatch.py index 7c62d90f2b9..ad75273d703 100644 --- a/testing/test_monkeypatch.py +++ b/testing/test_monkeypatch.py @@ -1,12 +1,12 @@ # mypy: allow-untyped-defs from __future__ import annotations +from collections.abc import Generator import os from pathlib import Path import re import sys import textwrap -from typing import Generator from _pytest.monkeypatch import MonkeyPatch from _pytest.pytester import Pytester diff --git a/testing/test_pathlib.py b/testing/test_pathlib.py index 62359303f3b..436a6b9cae3 100644 --- a/testing/test_pathlib.py +++ b/testing/test_pathlib.py @@ -1,6 +1,9 @@ # mypy: allow-untyped-defs from __future__ import annotations +from collections.abc import Generator +from collections.abc import Iterator +from collections.abc import Sequence import errno import importlib.abc import importlib.machinery @@ -12,9 +15,6 @@ from textwrap import dedent from types import ModuleType from typing import Any -from typing import Generator -from typing import Iterator -from typing import Sequence import unittest.mock from _pytest.config import ExitCode diff --git a/testing/test_reports.py b/testing/test_reports.py index 3e314d2aade..7a893981838 100644 --- a/testing/test_reports.py +++ b/testing/test_reports.py @@ -1,7 +1,7 @@ # mypy: allow-untyped-defs from __future__ import annotations -from typing import Sequence +from collections.abc import Sequence from _pytest._code.code import ExceptionChainRepr from _pytest._code.code import ExceptionRepr diff --git a/tox.ini b/tox.ini index 61563ca2c5f..80fae513142 100644 --- a/tox.ini +++ b/tox.ini @@ -4,18 +4,17 @@ minversion = 3.20.0 distshare = {homedir}/.tox/distshare envlist = linting - py38 py39 py310 py311 py312 py313 pypy3 - py38-{pexpect,xdist,unittestextras,numpy,pluggymain,pylib} + py39-{pexpect,xdist,unittestextras,numpy,pluggymain,pylib} doctesting doctesting-coverage plugins - py38-freeze + py39-freeze docs docs-checklinks @@ -58,7 +57,7 @@ setenv = PYTHONWARNDEFAULTENCODING=1 # Configuration to run with coverage similar to CI, e.g. - # "tox -e py38-coverage". + # "tox -e py39-coverage". coverage: _PYTEST_TOX_COVERAGE_RUN=coverage run -m coverage: _PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess coverage: COVERAGE_FILE={toxinidir}/.coverage @@ -178,7 +177,7 @@ commands = pytest pytest_twisted_integration.py pytest simple_integration.py --force-sugar --flakes -[testenv:py38-freeze] +[testenv:py39-freeze] description = test pytest frozen with `pyinstaller` under `{basepython}` changedir = testing/freeze From 05ed0d0f943ce25b635e92e4e166524435386018 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Sun, 10 Nov 2024 15:43:08 +0100 Subject: [PATCH 185/445] Enable pylint's python 3.8 typing checks (deprecated-typing-alias) --- pyproject.toml | 1 - src/_pytest/_code/code.py | 2 +- src/_pytest/_io/pprint.py | 2 +- src/_pytest/_py/error.py | 2 +- src/_pytest/_py/path.py | 2 +- src/_pytest/assertion/rewrite.py | 2 +- src/_pytest/assertion/util.py | 2 +- src/_pytest/compat.py | 2 +- src/_pytest/config/__init__.py | 2 +- src/_pytest/config/argparsing.py | 2 +- src/_pytest/debugging.py | 2 +- src/_pytest/doctest.py | 2 +- src/_pytest/fixtures.py | 8 +++----- src/_pytest/junitxml.py | 2 +- src/_pytest/main.py | 2 +- src/_pytest/mark/structures.py | 2 +- src/_pytest/nodes.py | 2 +- src/_pytest/outcomes.py | 2 +- src/_pytest/pathlib.py | 2 +- src/_pytest/pytester.py | 2 +- src/_pytest/python.py | 2 +- src/_pytest/python_api.py | 2 +- src/_pytest/recwarn.py | 2 +- src/_pytest/runner.py | 2 +- src/_pytest/terminal.py | 2 +- src/_pytest/threadexception.py | 2 +- src/_pytest/unittest.py | 2 +- src/_pytest/unraisableexception.py | 2 +- testing/test_doctest.py | 2 +- testing/test_mark_expression.py | 2 +- testing/test_tmpdir.py | 2 +- 31 files changed, 32 insertions(+), 35 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0541da9906e..6856e652829 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -229,7 +229,6 @@ disable = [ "deprecated-argument", "deprecated-attribute", "deprecated-class", - "deprecated-typing-alias", "disallowed-name", # foo / bar are used often in tests "duplicate-code", "else-if-used", # not activated by default, PLR5501 disabled in ruff diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index ea7415be23e..14ac545490f 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -2,6 +2,7 @@ from __future__ import annotations import ast +from collections.abc import Callable from collections.abc import Iterable from collections.abc import Mapping from collections.abc import Sequence @@ -21,7 +22,6 @@ from types import FrameType from types import TracebackType from typing import Any -from typing import Callable from typing import ClassVar from typing import Final from typing import final diff --git a/src/_pytest/_io/pprint.py b/src/_pytest/_io/pprint.py index d212b773166..ca780c41344 100644 --- a/src/_pytest/_io/pprint.py +++ b/src/_pytest/_io/pprint.py @@ -16,13 +16,13 @@ from __future__ import annotations import collections as _collections +from collections.abc import Callable from collections.abc import Iterator import dataclasses as _dataclasses from io import StringIO as _StringIO import re import types as _types from typing import Any -from typing import Callable from typing import IO diff --git a/src/_pytest/_py/error.py b/src/_pytest/_py/error.py index ab3a4ed318e..3a63304008a 100644 --- a/src/_pytest/_py/error.py +++ b/src/_pytest/_py/error.py @@ -2,10 +2,10 @@ from __future__ import annotations +from collections.abc import Callable import errno import os import sys -from typing import Callable from typing import TYPE_CHECKING from typing import TypeVar diff --git a/src/_pytest/_py/path.py b/src/_pytest/_py/path.py index c7ab1182f4a..e353c1a9b52 100644 --- a/src/_pytest/_py/path.py +++ b/src/_pytest/_py/path.py @@ -4,6 +4,7 @@ from __future__ import annotations import atexit +from collections.abc import Callable from contextlib import contextmanager import fnmatch import importlib.util @@ -23,7 +24,6 @@ from stat import S_ISREG import sys from typing import Any -from typing import Callable from typing import cast from typing import Literal from typing import overload diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index 05934797a14..93a08a4e69f 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -4,6 +4,7 @@ import ast from collections import defaultdict +from collections.abc import Callable from collections.abc import Iterable from collections.abc import Iterator from collections.abc import Sequence @@ -22,7 +23,6 @@ import sys import tokenize import types -from typing import Callable from typing import IO from typing import TYPE_CHECKING diff --git a/src/_pytest/assertion/util.py b/src/_pytest/assertion/util.py index 3593f0ce036..49e977171b9 100644 --- a/src/_pytest/assertion/util.py +++ b/src/_pytest/assertion/util.py @@ -4,6 +4,7 @@ from __future__ import annotations import collections.abc +from collections.abc import Callable from collections.abc import Iterable from collections.abc import Mapping from collections.abc import Sequence @@ -11,7 +12,6 @@ import pprint from typing import AbstractSet from typing import Any -from typing import Callable from typing import Literal from typing import Protocol from unicodedata import normalize diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 82aea5e635e..2f7413d466a 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -3,6 +3,7 @@ from __future__ import annotations +from collections.abc import Callable import dataclasses import enum import functools @@ -13,7 +14,6 @@ from pathlib import Path import sys from typing import Any -from typing import Callable from typing import Final from typing import NoReturn diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 5ec4d7b52ea..fb012d081e1 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -5,6 +5,7 @@ import argparse import collections.abc +from collections.abc import Callable from collections.abc import Generator from collections.abc import Iterable from collections.abc import Iterator @@ -26,7 +27,6 @@ import types from types import FunctionType from typing import Any -from typing import Callable from typing import cast from typing import Final from typing import final diff --git a/src/_pytest/config/argparsing.py b/src/_pytest/config/argparsing.py index 455d2d8db26..5a4e2e7993e 100644 --- a/src/_pytest/config/argparsing.py +++ b/src/_pytest/config/argparsing.py @@ -2,13 +2,13 @@ from __future__ import annotations import argparse +from collections.abc import Callable from collections.abc import Mapping from collections.abc import Sequence from gettext import gettext import os import sys from typing import Any -from typing import Callable from typing import cast from typing import final from typing import Literal diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py index 665d8536262..a9886c29d3c 100644 --- a/src/_pytest/debugging.py +++ b/src/_pytest/debugging.py @@ -5,12 +5,12 @@ from __future__ import annotations import argparse +from collections.abc import Callable from collections.abc import Generator import functools import sys import types from typing import Any -from typing import Callable import unittest from _pytest import outcomes diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index a1f680570d8..94868d06106 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -4,6 +4,7 @@ from __future__ import annotations import bdb +from collections.abc import Callable from collections.abc import Generator from collections.abc import Iterable from collections.abc import Sequence @@ -18,7 +19,6 @@ import traceback import types from typing import Any -from typing import Callable from typing import TYPE_CHECKING import warnings diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index c4a8a09f84a..80c4ec962b8 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -5,6 +5,7 @@ from collections import defaultdict from collections import deque from collections import OrderedDict +from collections.abc import Callable from collections.abc import Generator from collections.abc import Iterable from collections.abc import Iterator @@ -20,7 +21,6 @@ import types from typing import AbstractSet from typing import Any -from typing import Callable from typing import cast from typing import Final from typing import final @@ -89,7 +89,7 @@ FixtureFunction = TypeVar("FixtureFunction", bound=Callable[..., object]) # The type of a fixture function (type alias generic in fixture value). _FixtureFunc = Union[ - Callable[..., FixtureValue], Callable[..., Generator[FixtureValue, None, None]] + Callable[..., FixtureValue], Callable[..., Generator[FixtureValue]] ] # The type of FixtureDef.cached_result (type alias generic in fixture value). _FixtureCachedResult = Union[ @@ -891,9 +891,7 @@ def call_fixture_func( fixturefunc: _FixtureFunc[FixtureValue], request: FixtureRequest, kwargs ) -> FixtureValue: if inspect.isgeneratorfunction(fixturefunc): - fixturefunc = cast( - Callable[..., Generator[FixtureValue, None, None]], fixturefunc - ) + fixturefunc = cast(Callable[..., Generator[FixtureValue]], fixturefunc) generator = fixturefunc(**kwargs) try: fixture_result = next(generator) diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py index 46c456a5b6e..af072f0d1a4 100644 --- a/src/_pytest/junitxml.py +++ b/src/_pytest/junitxml.py @@ -10,6 +10,7 @@ from __future__ import annotations +from collections.abc import Callable from datetime import datetime from datetime import timezone import functools @@ -17,7 +18,6 @@ import platform import re from re import Match -from typing import Callable import xml.etree.ElementTree as ET from _pytest import nodes diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 1e18a60141d..ebd94c84c76 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -3,6 +3,7 @@ from __future__ import annotations import argparse +from collections.abc import Callable from collections.abc import Iterable from collections.abc import Iterator from collections.abc import Sequence @@ -15,7 +16,6 @@ from pathlib import Path import sys from typing import AbstractSet -from typing import Callable from typing import final from typing import Literal from typing import overload diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 09ef7d02cef..d1e0a49b62d 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -2,6 +2,7 @@ from __future__ import annotations import collections.abc +from collections.abc import Callable from collections.abc import Collection from collections.abc import Iterable from collections.abc import Iterator @@ -11,7 +12,6 @@ import dataclasses import inspect from typing import Any -from typing import Callable from typing import final from typing import NamedTuple from typing import overload diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index e84fb37c9d0..5b50fbc92cb 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -2,6 +2,7 @@ from __future__ import annotations import abc +from collections.abc import Callable from collections.abc import Iterable from collections.abc import Iterator from collections.abc import MutableMapping @@ -11,7 +12,6 @@ import pathlib from pathlib import Path from typing import Any -from typing import Callable from typing import cast from typing import NoReturn from typing import overload diff --git a/src/_pytest/outcomes.py b/src/_pytest/outcomes.py index ab39bac61b9..d792382a9c1 100644 --- a/src/_pytest/outcomes.py +++ b/src/_pytest/outcomes.py @@ -3,9 +3,9 @@ from __future__ import annotations +from collections.abc import Callable import sys from typing import Any -from typing import Callable from typing import cast from typing import NoReturn from typing import Protocol diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index f6392561951..55b27985d31 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -1,6 +1,7 @@ from __future__ import annotations import atexit +from collections.abc import Callable from collections.abc import Iterable from collections.abc import Iterator import contextlib @@ -28,7 +29,6 @@ import types from types import ModuleType from typing import Any -from typing import Callable from typing import TypeVar import uuid import warnings diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index d19151391b0..056be52a4ed 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -7,6 +7,7 @@ from __future__ import annotations import collections.abc +from collections.abc import Callable from collections.abc import Generator from collections.abc import Iterable from collections.abc import Sequence @@ -25,7 +26,6 @@ import sys import traceback from typing import Any -from typing import Callable from typing import Final from typing import final from typing import IO diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 153fbf8893b..3a42b43d0a1 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -6,6 +6,7 @@ import abc from collections import Counter from collections import defaultdict +from collections.abc import Callable from collections.abc import Generator from collections.abc import Iterable from collections.abc import Iterator @@ -22,7 +23,6 @@ from re import Pattern import types from typing import Any -from typing import Callable from typing import final from typing import Literal from typing import TYPE_CHECKING diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 30a630c42ff..aae0bd50ce0 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -1,6 +1,7 @@ # mypy: allow-untyped-defs from __future__ import annotations +from collections.abc import Callable from collections.abc import Collection from collections.abc import Mapping from collections.abc import Sequence @@ -13,7 +14,6 @@ from re import Pattern from types import TracebackType from typing import Any -from typing import Callable from typing import cast from typing import ContextManager from typing import final diff --git a/src/_pytest/recwarn.py b/src/_pytest/recwarn.py index fc26fcc78e4..b168bbe746d 100644 --- a/src/_pytest/recwarn.py +++ b/src/_pytest/recwarn.py @@ -3,6 +3,7 @@ from __future__ import annotations +from collections.abc import Callable from collections.abc import Generator from collections.abc import Iterator from pprint import pformat @@ -10,7 +11,6 @@ from re import Pattern from types import TracebackType from typing import Any -from typing import Callable from typing import final from typing import overload from typing import TYPE_CHECKING diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index 0b60301bf5f..5189efce538 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -4,11 +4,11 @@ from __future__ import annotations import bdb +from collections.abc import Callable import dataclasses import os import sys import types -from typing import Callable from typing import cast from typing import final from typing import Generic diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index d2baee40d9c..a74f73bff17 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -8,6 +8,7 @@ import argparse from collections import Counter +from collections.abc import Callable from collections.abc import Generator from collections.abc import Mapping from collections.abc import Sequence @@ -20,7 +21,6 @@ import sys import textwrap from typing import Any -from typing import Callable from typing import ClassVar from typing import final from typing import Literal diff --git a/src/_pytest/threadexception.py b/src/_pytest/threadexception.py index 49560bf7d7f..4a76a9d9000 100644 --- a/src/_pytest/threadexception.py +++ b/src/_pytest/threadexception.py @@ -1,11 +1,11 @@ from __future__ import annotations +from collections.abc import Callable from collections.abc import Generator import threading import traceback from types import TracebackType from typing import Any -from typing import Callable from typing import TYPE_CHECKING import warnings diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py index 6d967b972ee..04d50b53090 100644 --- a/src/_pytest/unittest.py +++ b/src/_pytest/unittest.py @@ -3,6 +3,7 @@ from __future__ import annotations +from collections.abc import Callable from collections.abc import Generator from collections.abc import Iterable import inspect @@ -10,7 +11,6 @@ import traceback import types from typing import Any -from typing import Callable from typing import TYPE_CHECKING from typing import Union diff --git a/src/_pytest/unraisableexception.py b/src/_pytest/unraisableexception.py index 9ef583137e1..5796b37715d 100644 --- a/src/_pytest/unraisableexception.py +++ b/src/_pytest/unraisableexception.py @@ -1,11 +1,11 @@ from __future__ import annotations +from collections.abc import Callable from collections.abc import Generator import sys import traceback from types import TracebackType from typing import Any -from typing import Callable from typing import TYPE_CHECKING import warnings diff --git a/testing/test_doctest.py b/testing/test_doctest.py index 4aa4876c711..d3ad09da871 100644 --- a/testing/test_doctest.py +++ b/testing/test_doctest.py @@ -1,11 +1,11 @@ # mypy: allow-untyped-defs from __future__ import annotations +from collections.abc import Callable import inspect from pathlib import Path import sys import textwrap -from typing import Callable from _pytest.doctest import _get_checker from _pytest.doctest import _is_main_py diff --git a/testing/test_mark_expression.py b/testing/test_mark_expression.py index a61a9f21560..884c4b5af88 100644 --- a/testing/test_mark_expression.py +++ b/testing/test_mark_expression.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Callable +from collections.abc import Callable from typing import cast from _pytest.mark import MarkMatcher diff --git a/testing/test_tmpdir.py b/testing/test_tmpdir.py index 865d8e0b05c..016588a143d 100644 --- a/testing/test_tmpdir.py +++ b/testing/test_tmpdir.py @@ -1,12 +1,12 @@ # mypy: allow-untyped-defs from __future__ import annotations +from collections.abc import Callable import dataclasses import os from pathlib import Path import stat import sys -from typing import Callable from typing import cast import warnings From f57b26b76c064535f54f5d9cd612ae888254be8f Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Thu, 10 Oct 2024 18:22:48 +0200 Subject: [PATCH 186/445] Remove code that is impossible to reach on python 3.9+ --- src/_pytest/config/argparsing.py | 40 -------------------------------- testing/test_assertrewrite.py | 4 ---- 2 files changed, 44 deletions(-) diff --git a/src/_pytest/config/argparsing.py b/src/_pytest/config/argparsing.py index 5a4e2e7993e..d535fe1096a 100644 --- a/src/_pytest/config/argparsing.py +++ b/src/_pytest/config/argparsing.py @@ -5,9 +5,7 @@ from collections.abc import Callable from collections.abc import Mapping from collections.abc import Sequence -from gettext import gettext import os -import sys from typing import Any from typing import cast from typing import final @@ -446,44 +444,6 @@ def parse_args( # type: ignore getattr(parsed, FILE_OR_DIR).extend(unrecognized) return parsed - if sys.version_info < (3, 9): # pragma: no cover - # Backport of https://github.com/python/cpython/pull/14316 so we can - # disable long --argument abbreviations without breaking short flags. - def _parse_optional( - self, arg_string: str - ) -> tuple[argparse.Action | None, str, str | None] | None: - if not arg_string: - return None - if arg_string[0] not in self.prefix_chars: - return None - if arg_string in self._option_string_actions: - action = self._option_string_actions[arg_string] - return action, arg_string, None - if len(arg_string) == 1: - return None - if "=" in arg_string: - option_string, explicit_arg = arg_string.split("=", 1) - if option_string in self._option_string_actions: - action = self._option_string_actions[option_string] - return action, option_string, explicit_arg - if self.allow_abbrev or not arg_string.startswith("--"): - option_tuples = self._get_option_tuples(arg_string) - if len(option_tuples) > 1: - msg = gettext( - "ambiguous option: %(option)s could match %(matches)s" - ) - options = ", ".join(option for _, option, _ in option_tuples) - self.error(msg % {"option": arg_string, "matches": options}) - elif len(option_tuples) == 1: - (option_tuple,) = option_tuples - return option_tuple - if self._negative_number_matcher.match(arg_string): - if not self._has_negative_number_optionals: - return None - if " " in arg_string: - return None - return None, arg_string, None - class DropShorterLongHelpFormatter(argparse.HelpFormatter): """Shorten help for long options that differ only in extra hyphens. diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index 2a988149daf..eed59a2dce7 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -1018,10 +1018,6 @@ def test_zipfile(self, pytester: Pytester) -> None: ) assert pytester.runpytest().ret == ExitCode.NO_TESTS_COLLECTED - @pytest.mark.skipif( - sys.version_info < (3, 9), - reason="importlib.resources.files was introduced in 3.9", - ) def test_load_resource_via_files_with_rewrite(self, pytester: Pytester) -> None: example = pytester.path.joinpath("demo") / "example" init = pytester.path.joinpath("demo") / "__init__.py" From 66fc31f05f02914c190fd9120653143f0bcb5105 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Sun, 10 Nov 2024 22:03:44 +0100 Subject: [PATCH 187/445] Fix 'typing.AbstractSet' is deprecated, use 'collections.abc.Set' --- src/_pytest/assertion/util.py | 2 +- src/_pytest/fixtures.py | 2 +- src/_pytest/logging.py | 2 +- src/_pytest/main.py | 2 +- src/_pytest/mark/__init__.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/_pytest/assertion/util.py b/src/_pytest/assertion/util.py index 49e977171b9..0db846ce204 100644 --- a/src/_pytest/assertion/util.py +++ b/src/_pytest/assertion/util.py @@ -8,9 +8,9 @@ from collections.abc import Iterable from collections.abc import Mapping from collections.abc import Sequence +from collections.abc import Set as AbstractSet import os import pprint -from typing import AbstractSet from typing import Any from typing import Literal from typing import Protocol diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 80c4ec962b8..01707418755 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -12,6 +12,7 @@ from collections.abc import Mapping from collections.abc import MutableMapping from collections.abc import Sequence +from collections.abc import Set as AbstractSet import dataclasses import functools import inspect @@ -19,7 +20,6 @@ from pathlib import Path import sys import types -from typing import AbstractSet from typing import Any from typing import cast from typing import Final diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index 00645dae2da..ca5fbda6fcc 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -5,6 +5,7 @@ from collections.abc import Generator from collections.abc import Mapping +from collections.abc import Set as AbstractSet from contextlib import contextmanager from contextlib import nullcontext from datetime import datetime @@ -18,7 +19,6 @@ from pathlib import Path import re from types import TracebackType -from typing import AbstractSet from typing import final from typing import Generic from typing import Literal diff --git a/src/_pytest/main.py b/src/_pytest/main.py index ebd94c84c76..d7086537f39 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -7,6 +7,7 @@ from collections.abc import Iterable from collections.abc import Iterator from collections.abc import Sequence +from collections.abc import Set as AbstractSet import dataclasses import fnmatch import functools @@ -15,7 +16,6 @@ import os from pathlib import Path import sys -from typing import AbstractSet from typing import final from typing import Literal from typing import overload diff --git a/src/_pytest/mark/__init__.py b/src/_pytest/mark/__init__.py index c8c51d19aa0..efb966c09aa 100644 --- a/src/_pytest/mark/__init__.py +++ b/src/_pytest/mark/__init__.py @@ -5,8 +5,8 @@ import collections from collections.abc import Collection from collections.abc import Iterable +from collections.abc import Set as AbstractSet import dataclasses -from typing import AbstractSet from typing import Optional from typing import TYPE_CHECKING From e684e64dd04967c94d34b7cab651640512b67fa6 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Sun, 10 Nov 2024 22:04:32 +0100 Subject: [PATCH 188/445] Fix 'typing.Type' is deprecated, use 'type' instead --- src/_pytest/config/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index fb012d081e1..6160f780b1b 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -32,7 +32,6 @@ from typing import final from typing import IO from typing import TextIO -from typing import Type from typing import TYPE_CHECKING import warnings From a6ef97b65bea694f179ed026e988cf7535ba8d2e Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Sun, 10 Nov 2024 22:05:05 +0100 Subject: [PATCH 189/445] Fix 'typing.ContextManager' is deprecated, use 'contextlib.AbstractContextManager' --- src/_pytest/python_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index aae0bd50ce0..fb00f1dd749 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -6,6 +6,7 @@ from collections.abc import Mapping from collections.abc import Sequence from collections.abc import Sized +from contextlib import AbstractContextManager from decimal import Decimal import math from numbers import Complex @@ -15,7 +16,6 @@ from types import TracebackType from typing import Any from typing import cast -from typing import ContextManager from typing import final from typing import overload from typing import TYPE_CHECKING @@ -978,7 +978,7 @@ def raises( @final -class RaisesContext(ContextManager[_pytest._code.ExceptionInfo[E]]): +class RaisesContext(AbstractContextManager[_pytest._code.ExceptionInfo[E]]): def __init__( self, expected_exception: type[E] | tuple[type[E], ...], From 1bacc000779e46e55925533eeb97465e8c857254 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 20 Nov 2024 22:24:45 +0100 Subject: [PATCH 190/445] [typing] Use the re namespace in 're' typing everywhere --- src/_pytest/_code/code.py | 9 ++++----- src/_pytest/doctest.py | 5 ++--- src/_pytest/junitxml.py | 3 +-- src/_pytest/python.py | 4 ++-- src/_pytest/python_api.py | 7 +++---- src/_pytest/recwarn.py | 11 ++++++----- 6 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 14ac545490f..b98ce013b6e 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -14,7 +14,6 @@ import os from pathlib import Path import re -from re import Pattern import sys import traceback from traceback import format_exception_only @@ -722,7 +721,7 @@ def _stringify_exception(self, exc: BaseException) -> str: ] ) - def match(self, regexp: str | Pattern[str]) -> Literal[True]: + def match(self, regexp: str | re.Pattern[str]) -> Literal[True]: """Check whether the regular expression `regexp` matches the string representation of the exception using :func:`python:re.search`. @@ -741,7 +740,7 @@ def _group_contains( self, exc_group: BaseExceptionGroup[BaseException], expected_exception: EXCEPTION_OR_MORE, - match: str | Pattern[str] | None, + match: str | re.Pattern[str] | None, target_depth: int | None = None, current_depth: int = 1, ) -> bool: @@ -771,7 +770,7 @@ def group_contains( self, expected_exception: EXCEPTION_OR_MORE, *, - match: str | Pattern[str] | None = None, + match: str | re.Pattern[str] | None = None, depth: int | None = None, ) -> bool: """Check whether a captured exception group contains a matching exception. @@ -780,7 +779,7 @@ def group_contains( The expected exception type, or a tuple if one of multiple possible exception types are expected. - :param str | Pattern[str] | None match: + :param str | re.Pattern[str] | None match: If specified, a string containing a regular expression, or a regular expression object, that is tested against the string representation of the exception and its `PEP-678 ` `__notes__` diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index 94868d06106..598df84d70e 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -14,7 +14,7 @@ import os from pathlib import Path import platform -from re import Pattern +import re import sys import traceback import types @@ -593,7 +593,6 @@ def _from_module(self, module, object): def _init_checker_class() -> type[doctest.OutputChecker]: import doctest - import re class LiteralsOutputChecker(doctest.OutputChecker): # Based on doctest_nose_plugin.py from the nltk project @@ -636,7 +635,7 @@ def check_output(self, want: str, got: str, optionflags: int) -> bool: if not allow_unicode and not allow_bytes and not allow_number: return False - def remove_prefixes(regex: Pattern[str], txt: str) -> str: + def remove_prefixes(regex: re.Pattern[str], txt: str) -> str: return re.sub(regex, r"\1\2", txt) if allow_unicode: diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py index af072f0d1a4..d129cd295e7 100644 --- a/src/_pytest/junitxml.py +++ b/src/_pytest/junitxml.py @@ -17,7 +17,6 @@ import os import platform import re -from re import Match import xml.etree.ElementTree as ET from _pytest import nodes @@ -48,7 +47,7 @@ def bin_xml_escape(arg: object) -> str: The idea is to escape visually for the user rather than for XML itself. """ - def repl(matchobj: Match[str]) -> str: + def repl(matchobj: re.Match[str]) -> str: i = ord(matchobj.group()) if i <= 0xFF: return f"#x{i:02X}" diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 3a42b43d0a1..f75bb5b432e 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -20,7 +20,7 @@ import itertools import os from pathlib import Path -from re import Pattern +import re import types from typing import Any from typing import final @@ -973,7 +973,7 @@ def _idval_from_value(self, val: object) -> str | None: return _ascii_escaped_by_config(val, self.config) elif val is None or isinstance(val, (float, int, bool, complex)): return str(val) - elif isinstance(val, Pattern): + elif isinstance(val, re.Pattern): return ascii_escaped(val.pattern) elif val is NOTSET: # Fallback to default. Note that NOTSET is an enum.Enum. diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index fb00f1dd749..af13c3dc981 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -12,7 +12,6 @@ from numbers import Complex import pprint import re -from re import Pattern from types import TracebackType from typing import Any from typing import cast @@ -780,7 +779,7 @@ def _as_numpy_array(obj: object) -> ndarray | None: def raises( expected_exception: type[E] | tuple[type[E], ...], *, - match: str | Pattern[str] | None = ..., + match: str | re.Pattern[str] | None = ..., ) -> RaisesContext[E]: ... @@ -955,7 +954,7 @@ def raises( message = f"DID NOT RAISE {expected_exception}" if not args: - match: str | Pattern[str] | None = kwargs.pop("match", None) + match: str | re.Pattern[str] | None = kwargs.pop("match", None) if kwargs: msg = "Unexpected keyword arguments passed to pytest.raises: " msg += ", ".join(sorted(kwargs)) @@ -983,7 +982,7 @@ def __init__( self, expected_exception: type[E] | tuple[type[E], ...], message: str, - match_expr: str | Pattern[str] | None = None, + match_expr: str | re.Pattern[str] | None = None, ) -> None: self.expected_exception = expected_exception self.message = message diff --git a/src/_pytest/recwarn.py b/src/_pytest/recwarn.py index b168bbe746d..440e3efac8a 100644 --- a/src/_pytest/recwarn.py +++ b/src/_pytest/recwarn.py @@ -8,7 +8,6 @@ from collections.abc import Iterator from pprint import pformat import re -from re import Pattern from types import TracebackType from typing import Any from typing import final @@ -44,7 +43,9 @@ def recwarn() -> Generator[WarningsRecorder]: @overload -def deprecated_call(*, match: str | Pattern[str] | None = ...) -> WarningsRecorder: ... +def deprecated_call( + *, match: str | re.Pattern[str] | None = ... +) -> WarningsRecorder: ... @overload @@ -89,7 +90,7 @@ def deprecated_call( def warns( expected_warning: type[Warning] | tuple[type[Warning], ...] = ..., *, - match: str | Pattern[str] | None = ..., + match: str | re.Pattern[str] | None = ..., ) -> WarningsChecker: ... @@ -105,7 +106,7 @@ def warns( def warns( expected_warning: type[Warning] | tuple[type[Warning], ...] = Warning, *args: Any, - match: str | Pattern[str] | None = None, + match: str | re.Pattern[str] | None = None, **kwargs: Any, ) -> WarningsChecker | Any: r"""Assert that code raises a particular class of warning. @@ -258,7 +259,7 @@ class WarningsChecker(WarningsRecorder): def __init__( self, expected_warning: type[Warning] | tuple[type[Warning], ...] = Warning, - match_expr: str | Pattern[str] | None = None, + match_expr: str | re.Pattern[str] | None = None, *, _ispytest: bool = False, ) -> None: From 58e25811b6d8a481c15004c2f0c097db6b24d5ad Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 20 Nov 2024 22:29:13 +0100 Subject: [PATCH 191/445] [black] Fix the target-version configuration --- pyproject.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6856e652829..c13da163259 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,9 +83,8 @@ scripts.pytest = "pytest:console_main" write_to = "src/_pytest/_version.py" [tool.black] -target-version = [ - 'py39', -] +# See https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#t-target-version +target-version = [ "py39", "py310", "py311", "py312", "py313" ] [tool.ruff] line-length = 88 From 10c0c6271604e339042bbf5dd4f271fe6bfd0f5b Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Thu, 28 Nov 2024 21:12:53 +0100 Subject: [PATCH 192/445] [ruff] Set the target version to python 3.9 --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index c13da163259..dce6a0870e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,6 +87,7 @@ write_to = "src/_pytest/_version.py" target-version = [ "py39", "py310", "py311", "py312", "py313" ] [tool.ruff] +target-version = "py39" line-length = 88 src = [ "src", From a16e8eac8c91b8d0f91c461a4de39adbf8a75b0f Mon Sep 17 00:00:00 2001 From: Jakob van Santen Date: Fri, 29 Nov 2024 18:30:48 +0100 Subject: [PATCH 193/445] approx: use exact comparison for bool Fixes #9353 --- changelog/9353.bugfix.rst | 1 + src/_pytest/python_api.py | 44 +++++++++++++++++++++++---------------- testing/python/approx.py | 23 +++++++++++++++++++- 3 files changed, 49 insertions(+), 19 deletions(-) create mode 100644 changelog/9353.bugfix.rst diff --git a/changelog/9353.bugfix.rst b/changelog/9353.bugfix.rst new file mode 100644 index 00000000000..414f5a007b6 --- /dev/null +++ b/changelog/9353.bugfix.rst @@ -0,0 +1 @@ +:func:`pytest.approx` now uses strict equality when given booleans. diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index af13c3dc981..4563b997246 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -259,19 +259,22 @@ def _repr_compare(self, other_side: Mapping[object, float]) -> list[str]: ): if approx_value != other_value: if approx_value.expected is not None and other_value is not None: - max_abs_diff = max( - max_abs_diff, abs(approx_value.expected - other_value) - ) - if approx_value.expected == 0.0: - max_rel_diff = math.inf - else: - max_rel_diff = max( - max_rel_diff, - abs( - (approx_value.expected - other_value) - / approx_value.expected - ), + try: + max_abs_diff = max( + max_abs_diff, abs(approx_value.expected - other_value) ) + if approx_value.expected == 0.0: + max_rel_diff = math.inf + else: + max_rel_diff = max( + max_rel_diff, + abs( + (approx_value.expected - other_value) + / approx_value.expected + ), + ) + except ZeroDivisionError: + pass different_ids.append(approx_key) message_data = [ @@ -395,8 +398,10 @@ def __repr__(self) -> str: # Don't show a tolerance for values that aren't compared using # tolerances, i.e. non-numerics and infinities. Need to call abs to # handle complex numbers, e.g. (inf + 1j). - if (not isinstance(self.expected, (Complex, Decimal))) or math.isinf( - abs(self.expected) + if ( + isinstance(self.expected, bool) + or (not isinstance(self.expected, (Complex, Decimal))) + or math.isinf(abs(self.expected) or isinstance(self.expected, bool)) ): return str(self.expected) @@ -428,14 +433,17 @@ def __eq__(self, actual) -> bool: # numpy<1.13. See #3748. return all(self.__eq__(a) for a in asarray.flat) - # Short-circuit exact equality. - if actual == self.expected: + # Short-circuit exact equality, except for bool + if isinstance(self.expected, bool) and not isinstance(actual, bool): + return False + elif actual == self.expected: return True # If either type is non-numeric, fall back to strict equality. # NB: we need Complex, rather than just Number, to ensure that __abs__, - # __sub__, and __float__ are defined. - if not ( + # __sub__, and __float__ are defined. Also, consider bool to be + # nonnumeric, even though it has the required arithmetic. + if isinstance(self.expected, bool) or not ( isinstance(self.expected, (Complex, Decimal)) and isinstance(actual, (Complex, Decimal)) ): diff --git a/testing/python/approx.py b/testing/python/approx.py index 21932059cc6..6de66d4f35e 100644 --- a/testing/python/approx.py +++ b/testing/python/approx.py @@ -90,13 +90,26 @@ def do_assert(lhs, rhs, expected_message, verbosity_level=0): return do_assert -SOME_FLOAT = r"[+-]?([0-9]*[.])?[0-9]+\s*" +SOME_FLOAT = r"[+-]?((?:([0-9]*[.])?[0-9]+(e-?[0-9]+)?)|inf|nan)\s*" SOME_INT = r"[0-9]+\s*" SOME_TOLERANCE = rf"({SOME_FLOAT}|[+-]?[0-9]+(\.[0-9]+)?[eE][+-]?[0-9]+\s*)" class TestApprox: def test_error_messages_native_dtypes(self, assert_approx_raises_regex): + # Treat bool exactly. + assert_approx_raises_regex( + {"a": 1.0, "b": True}, + {"a": 1.0, "b": False}, + [ + "", + " comparison failed. Mismatched elements: 1 / 2:", + f" Max absolute difference: {SOME_FLOAT}", + f" Max relative difference: {SOME_FLOAT}", + r" Index\s+\| Obtained\s+\| Expected", + r".*(True|False)\s+", + ], + ) assert_approx_raises_regex( 2.0, 1.0, @@ -596,6 +609,13 @@ def test_complex(self): assert approx(x, rel=5e-6, abs=0) == a assert approx(x, rel=5e-7, abs=0) != a + def test_expecting_bool(self) -> None: + assert True == approx(True) # noqa: E712 + assert False == approx(False) # noqa: E712 + assert True != approx(False) # noqa: E712 + assert True != approx(False, abs=2) # noqa: E712 + assert 1 != approx(True) + def test_list(self): actual = [1 + 1e-7, 2 + 1e-8] expected = [1, 2] @@ -661,6 +681,7 @@ def test_dict_wrong_len(self): def test_dict_nonnumeric(self): assert {"a": 1.0, "b": None} == pytest.approx({"a": 1.0, "b": None}) assert {"a": 1.0, "b": 1} != pytest.approx({"a": 1.0, "b": None}) + assert {"a": 1.0, "b": True} != pytest.approx({"a": 1.0, "b": False}, abs=2) def test_dict_vs_other(self): assert 1 != approx({"a": 0}) From d65d99177628b87a46cec85e5d83ae0ea9cbdb2a Mon Sep 17 00:00:00 2001 From: Marcelo Duarte Trevisani Date: Sat, 30 Nov 2024 12:31:52 +0000 Subject: [PATCH 194/445] approx: do not raise error in mixed sequence/collections Previously `approx` would show an internal error when passed a collection with numbers and non-numbers mixed: ``` E (pytest_assertion plugin: representation of details failed: /tmp/test_a/.venv/lib/python3.12/site-packages/_pytest/python_api.py:343: TypeError: unsupported operand type(s) for -: 'str' and 'str'. E Probably an object has a faulty __repr__.) ``` The problem was that it was unconditionally computing the diff for every element. This change introduces a try/except catch around the code related to computing the diff, and ignores it instead of letting the error be raised. Fixes #13010 Co-authored-by: Bruno Oliveira --- changelog/13010.improvement.rst | 1 + src/_pytest/python_api.py | 16 ++++++++++------ testing/python/approx.py | 31 +++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 changelog/13010.improvement.rst diff --git a/changelog/13010.improvement.rst b/changelog/13010.improvement.rst new file mode 100644 index 00000000000..d6b814f090e --- /dev/null +++ b/changelog/13010.improvement.rst @@ -0,0 +1 @@ +:func:`pytest.approx` now can compare collections that contain numbers and non-numbers mixed. diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 4563b997246..cbb2ff2b80a 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -340,14 +340,18 @@ def _repr_compare(self, other_side: Sequence[float]) -> list[str]: zip(approx_side_as_map, other_side) ): if approx_value != other_value: - abs_diff = abs(approx_value.expected - other_value) - max_abs_diff = max(max_abs_diff, abs_diff) - if other_value == 0.0: - max_rel_diff = math.inf + try: + abs_diff = abs(approx_value.expected - other_value) + max_abs_diff = max(max_abs_diff, abs_diff) + # Ignore non-numbers for the diff calculations (#13012). + except TypeError: + pass else: - max_rel_diff = max(max_rel_diff, abs_diff / abs(other_value)) + if other_value == 0.0: + max_rel_diff = math.inf + else: + max_rel_diff = max(max_rel_diff, abs_diff / abs(other_value)) different_ids.append(i) - message_data = [ (str(i), str(other_side[i]), str(approx_side_as_map[i])) for i in different_ids diff --git a/testing/python/approx.py b/testing/python/approx.py index 6de66d4f35e..7eba4755c01 100644 --- a/testing/python/approx.py +++ b/testing/python/approx.py @@ -390,6 +390,37 @@ def test_bool(self): assert err.match(r"approx\(\) is not supported in a boolean context") + def test_mixed_sequence(self, assert_approx_raises_regex) -> None: + """Approx should work on sequences that also contain non-numbers (#13010).""" + assert_approx_raises_regex( + [1.1, 2, "word"], + [1.0, 2, "different"], + [ + "", + r" comparison failed. Mismatched elements: 2 / 3:", + rf" Max absolute difference: {SOME_FLOAT}", + rf" Max relative difference: {SOME_FLOAT}", + r" Index \| Obtained\s+\| Expected\s+", + r"\s*0\s*\|\s*1\.1\s*\|\s*1\.0\s*±\s*1\.0e\-06\s*", + r"\s*2\s*\|\s*word\s*\|\s*different\s*", + ], + verbosity_level=2, + ) + assert_approx_raises_regex( + [1.1, 2, "word"], + [1.0, 2, "word"], + [ + "", + r" comparison failed. Mismatched elements: 1 / 3:", + rf" Max absolute difference: {SOME_FLOAT}", + rf" Max relative difference: {SOME_FLOAT}", + r" Index \| Obtained\s+\| Expected\s+", + r"\s*0\s*\|\s*1\.1\s*\|\s*1\.0\s*±\s*1\.0e\-06\s*", + ], + verbosity_level=2, + ) + assert [1.1, 2, "word"] == pytest.approx([1.1, 2, "word"]) + def test_operator_overloading(self): assert 1 == approx(1, rel=1e-6, abs=1e-12) assert not (1 != approx(1, rel=1e-6, abs=1e-12)) From 10bcc70ad6f5eff8af023d662682e643f0dda4aa Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Fri, 29 Nov 2024 19:59:40 +0100 Subject: [PATCH 195/445] [pre-commit] Upgrade ruff to 0.8.1 --- .pre-commit-config.yaml | 2 +- pyproject.toml | 2 ++ src/_pytest/_code/__init__.py | 8 ++--- src/_pytest/_code/code.py | 10 +++---- src/_pytest/assertion/rewrite.py | 4 +-- src/_pytest/capture.py | 4 +-- src/_pytest/fixtures.py | 2 +- src/_pytest/mark/expression.py | 10 +++---- src/_pytest/mark/structures.py | 8 ++--- src/_pytest/nodes.py | 10 +++---- src/_pytest/python.py | 8 ++--- src/_pytest/runner.py | 2 +- src/_pytest/skipping.py | 2 +- src/pytest/__init__.py | 50 ++++++++++++++++---------------- testing/_py/test_local.py | 4 +-- 15 files changed, 61 insertions(+), 65 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cb02fd0f00f..8a5418350d7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.7.4" + rev: "v0.8.1" hooks: - id: ruff args: ["--fix"] diff --git a/pyproject.toml b/pyproject.toml index dce6a0870e1..b10c1289b80 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -156,8 +156,10 @@ lint.ignore = [ "PLW0120", # remove the else and dedent its contents "PLW0603", # Using the global statement "PLW2901", # for loop variable overwritten by assignment target + "PYI063", # ruff ignore "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` + "UP031", ] lint.per-file-ignores."src/_pytest/_py/**/*.py" = [ "B", diff --git a/src/_pytest/_code/__init__.py b/src/_pytest/_code/__init__.py index 0bfde42604d..7f67a2e3e0a 100644 --- a/src/_pytest/_code/__init__.py +++ b/src/_pytest/_code/__init__.py @@ -16,11 +16,11 @@ __all__ = [ "Code", "ExceptionInfo", - "filter_traceback", "Frame", - "getfslineno", - "getrawcode", + "Source", "Traceback", "TracebackEntry", - "Source", + "filter_traceback", + "getfslineno", + "getrawcode", ] diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index b98ce013b6e..bb09c01c11d 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -953,7 +953,7 @@ def repr_traceback_entry( if short: message = f"in {entry.name}" else: - message = excinfo and excinfo.typename or "" + message = (excinfo and excinfo.typename) or "" entry_path = entry.path path = self._makepath(entry_path) reprfileloc = ReprFileLocation(path, entry.lineno + 1, message) @@ -1182,10 +1182,8 @@ def toterminal(self, tw: TerminalWriter) -> None: entry.toterminal(tw) if i < len(self.reprentries) - 1: next_entry = self.reprentries[i + 1] - if ( - entry.style == "long" - or entry.style == "short" - and next_entry.style == "long" + if entry.style == "long" or ( + entry.style == "short" and next_entry.style == "long" ): tw.sep(self.entrysep) @@ -1369,7 +1367,7 @@ def getfslineno(obj: object) -> tuple[str | Path, int]: except TypeError: return "", -1 - fspath = fn and absolutepath(fn) or "" + fspath = (fn and absolutepath(fn)) or "" lineno = -1 if fspath: try: diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index 93a08a4e69f..c414b30a4a8 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -53,7 +53,7 @@ class Sentinel: # pytest caches rewritten pycs in pycache dirs PYTEST_TAG = f"{sys.implementation.cache_tag}-pytest-{version}" -PYC_EXT = ".py" + (__debug__ and "c" or "o") +PYC_EXT = ".py" + ((__debug__ and "c") or "o") PYC_TAIL = "." + PYTEST_TAG + PYC_EXT # Special marker that denotes we have just left a scope definition @@ -481,7 +481,7 @@ def _should_repr_global_name(obj: object) -> bool: def _format_boolop(explanations: Iterable[str], is_or: bool) -> str: - explanation = "(" + (is_or and " or " or " and ").join(explanations) + ")" + explanation = "(" + ((is_or and " or ") or " and ").join(explanations) + ")" return explanation.replace("%", "%%") diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index 93a3b04182e..de2ee9c8dbd 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -360,7 +360,7 @@ def repr(self, class_name: str) -> str: return "<{} {} _old={} _state={!r} tmpfile={!r}>".format( class_name, self.name, - hasattr(self, "_old") and repr(self._old) or "", + (hasattr(self, "_old") and repr(self._old)) or "", self._state, self.tmpfile, ) @@ -369,7 +369,7 @@ def __repr__(self) -> str: return "<{} {} _old={} _state={!r} tmpfile={!r}>".format( self.__class__.__name__, self.name, - hasattr(self, "_old") and repr(self._old) or "", + (hasattr(self, "_old") and repr(self._old)) or "", self._state, self.tmpfile, ) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 01707418755..95fa1336169 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -305,7 +305,7 @@ class FuncFixtureInfo: these are not reflected here. """ - __slots__ = ("argnames", "initialnames", "names_closure", "name2fixturedefs") + __slots__ = ("argnames", "initialnames", "name2fixturedefs", "names_closure") # Fixture names that the item requests directly by function parameters. argnames: tuple[str, ...] diff --git a/src/_pytest/mark/expression.py b/src/_pytest/mark/expression.py index d0ab190e3b6..b71ed29c62f 100644 --- a/src/_pytest/mark/expression.py +++ b/src/_pytest/mark/expression.py @@ -58,7 +58,7 @@ class TokenType(enum.Enum): @dataclasses.dataclass(frozen=True) class Token: - __slots__ = ("type", "value", "pos") + __slots__ = ("pos", "type", "value") type: TokenType value: str pos: int @@ -80,7 +80,7 @@ def __str__(self) -> str: class Scanner: - __slots__ = ("tokens", "current") + __slots__ = ("current", "tokens") def __init__(self, input: str) -> None: self.tokens = self.lex(input) @@ -238,10 +238,8 @@ def single_kwarg(s: Scanner) -> ast.keyword: value: str | int | bool | None = value_token.value[1:-1] # strip quotes else: value_token = s.accept(TokenType.IDENT, reject=True) - if ( - (number := value_token.value).isdigit() - or number.startswith("-") - and number[1:].isdigit() + if (number := value_token.value).isdigit() or ( + number.startswith("-") and number[1:].isdigit() ): value = int(number) elif value_token.value in BUILTIN_MATCHERS: diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index d1e0a49b62d..e7e32555ba4 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -562,7 +562,7 @@ def __getattr__(self, name: str) -> MarkDecorator: @final class NodeKeywords(MutableMapping[str, Any]): - __slots__ = ("node", "parent", "_markers") + __slots__ = ("_markers", "node", "parent") def __init__(self, node: Node) -> None: self.node = node @@ -584,10 +584,8 @@ def __setitem__(self, key: str, value: Any) -> None: # below and use the collections.abc fallback, but that would be slow. def __contains__(self, key: object) -> bool: - return ( - key in self._markers - or self.parent is not None - and key in self.parent.keywords + return key in self._markers or ( + self.parent is not None and key in self.parent.keywords ) def update( # type: ignore[override] diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index 5b50fbc92cb..0d1f3d2352b 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -143,14 +143,14 @@ class Node(abc.ABC, metaclass=NodeMeta): # Use __slots__ to make attribute access faster. # Note that __dict__ is still available. __slots__ = ( + "__dict__", + "_nodeid", + "_store", + "config", "name", "parent", - "config", - "session", "path", - "_nodeid", - "_store", - "__dict__", + "session", ) def __init__( diff --git a/src/_pytest/python.py b/src/_pytest/python.py index f75bb5b432e..0b33133c1f2 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -431,7 +431,7 @@ def _genfunctions(self, name: str, funcobj) -> Iterator[Function]: assert modulecol is not None module = modulecol.obj clscol = self.getparent(Class) - cls = clscol and clscol.obj or None + cls = (clscol and clscol.obj) or None definition = FunctionDefinition.from_parent(self, name=name, callobj=funcobj) fixtureinfo = definition._fixtureinfo @@ -848,12 +848,12 @@ class IdMaker: __slots__ = ( "argnames", - "parametersets", + "config", + "func_name", "idfn", "ids", - "config", "nodeid", - "func_name", + "parametersets", ) # The argnames of the parametrization. diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index 5189efce538..d2b7fda8c2a 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -533,7 +533,7 @@ def teardown_exact(self, nextitem: Item | None) -> None: When nextitem is None (meaning we're at the last item), the entire stack is torn down. """ - needed_collectors = nextitem and nextitem.listchain() or [] + needed_collectors = (nextitem and nextitem.listchain()) or [] exceptions: list[BaseException] = [] while self.stack: if list(self.stack.keys()) == needed_collectors[: len(self.stack)]: diff --git a/src/_pytest/skipping.py b/src/_pytest/skipping.py index 8fa17a01eb0..d21be181955 100644 --- a/src/_pytest/skipping.py +++ b/src/_pytest/skipping.py @@ -196,7 +196,7 @@ def evaluate_skip_marks(item: Item) -> Skip | None: class Xfail: """The result of evaluate_xfail_marks().""" - __slots__ = ("reason", "run", "strict", "raises") + __slots__ = ("raises", "reason", "run", "strict") reason: str run: bool diff --git a/src/pytest/__init__.py b/src/pytest/__init__.py index 5ab2a22b0c0..f0c3516f4cc 100644 --- a/src/pytest/__init__.py +++ b/src/pytest/__init__.py @@ -88,41 +88,27 @@ __all__ = [ - "__version__", - "approx", "Cache", "CallInfo", "CaptureFixture", "Class", - "cmdline", - "Collector", "CollectReport", + "Collector", "Config", - "console_main", - "deprecated_call", "Dir", "Directory", "DoctestItem", - "exit", "ExceptionInfo", "ExitCode", - "fail", "File", - "fixture", "FixtureDef", "FixtureLookupError", "FixtureRequest", - "freeze_includes", "Function", - "hookimpl", "HookRecorder", - "hookspec", - "importorskip", "Item", "LineMatcher", "LogCaptureFixture", - "main", - "mark", "Mark", "MarkDecorator", "MarkGenerator", @@ -131,7 +117,6 @@ "MonkeyPatch", "OptionGroup", "Package", - "param", "Parser", "PytestAssertRewriteWarning", "PytestCacheWarning", @@ -139,31 +124,46 @@ "PytestConfigWarning", "PytestDeprecationWarning", "PytestExperimentalApiWarning", - "PytestRemovedIn9Warning", - "Pytester", "PytestPluginManager", + "PytestRemovedIn9Warning", "PytestUnhandledThreadExceptionWarning", "PytestUnknownMarkWarning", "PytestUnraisableExceptionWarning", "PytestWarning", - "raises", + "Pytester", "RecordedHookCall", - "register_assert_rewrite", "RunResult", "Session", - "set_trace", - "skip", "Stash", "StashKey", - "version_tuple", - "TempdirFactory", "TempPathFactory", + "TempdirFactory", "TerminalReporter", - "Testdir", "TestReport", "TestShortLogReport", + "Testdir", "UsageError", "WarningsRecorder", + "__version__", + "approx", + "cmdline", + "console_main", + "deprecated_call", + "exit", + "fail", + "fixture", + "freeze_includes", + "hookimpl", + "hookspec", + "importorskip", + "main", + "mark", + "param", + "raises", + "register_assert_rewrite", + "set_trace", + "skip", + "version_tuple", "warns", "xfail", "yield_fixture", diff --git a/testing/_py/test_local.py b/testing/_py/test_local.py index 21fbfb3e3ad..b6d49c5425e 100644 --- a/testing/_py/test_local.py +++ b/testing/_py/test_local.py @@ -855,7 +855,7 @@ def test_fnmatch_file_abspath(self, tmpdir): assert b.fnmatch(pattern) def test_sysfind(self): - name = sys.platform == "win32" and "cmd" or "test" + name = (sys.platform == "win32" and "cmd") or "test" x = local.sysfind(name) assert x.check(file=1) assert local.sysfind("jaksdkasldqwe") is None @@ -1250,7 +1250,7 @@ def test_owner_group_not_implemented(self, path1): def test_chmod_simple_int(self, path1): mode = path1.stat().mode # Ensure that we actually change the mode to something different. - path1.chmod(mode == 0 and 1 or 0) + path1.chmod((mode == 0 and 1) or 0) try: print(path1.stat().mode) print(mode) From 049bb29d8a7fce42bcb4825c23bacffb56b68e55 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Thu, 28 Nov 2024 22:17:12 +0100 Subject: [PATCH 196/445] [Fix PYI063] Use PEP 570 syntax for positional-only parameters --- pyproject.toml | 1 - .../dataclasses/test_compare_dataclasses_with_custom_eq.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b10c1289b80..c5833f73851 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -156,7 +156,6 @@ lint.ignore = [ "PLW0120", # remove the else and dedent its contents "PLW0603", # Using the global statement "PLW2901", # for loop variable overwritten by assignment target - "PYI063", # ruff ignore "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` "UP031", diff --git a/testing/example_scripts/dataclasses/test_compare_dataclasses_with_custom_eq.py b/testing/example_scripts/dataclasses/test_compare_dataclasses_with_custom_eq.py index b787cb39ee2..e25bebf74dd 100644 --- a/testing/example_scripts/dataclasses/test_compare_dataclasses_with_custom_eq.py +++ b/testing/example_scripts/dataclasses/test_compare_dataclasses_with_custom_eq.py @@ -10,7 +10,7 @@ class SimpleDataObject: field_a: int = field() field_b: str = field() - def __eq__(self, __o: object) -> bool: + def __eq__(self, __o: object, /) -> bool: return super().__eq__(__o) left = SimpleDataObject(1, "b") From 17c5bbbdaee125f7d574ae390d4807724efa871a Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Fri, 29 Nov 2024 20:30:17 +0100 Subject: [PATCH 197/445] [Fix UP031] Manually, keeping some required %r specifiers Co-authored-by: Bruno Oliveira --- bench/empty.py | 2 +- pyproject.toml | 1 - src/_pytest/_code/code.py | 9 ++------ src/_pytest/_io/pprint.py | 2 +- src/_pytest/_py/error.py | 2 +- src/_pytest/assertion/util.py | 9 +++----- src/_pytest/cacheprovider.py | 6 ++--- src/_pytest/compat.py | 4 ++-- src/_pytest/doctest.py | 2 +- src/_pytest/fixtures.py | 2 +- src/_pytest/main.py | 18 +++++++-------- src/_pytest/mark/structures.py | 10 ++------- src/_pytest/pytester.py | 6 +++-- src/_pytest/terminal.py | 22 +++++++++---------- testing/_py/test_local.py | 4 ++-- ...test_compare_dataclasses_with_custom_eq.py | 4 ++-- testing/python/metafunc.py | 7 +++--- testing/test_assertion.py | 7 +++--- testing/test_conftest.py | 4 ++-- testing/test_doctest.py | 2 +- testing/test_terminal.py | 2 +- 21 files changed, 53 insertions(+), 72 deletions(-) diff --git a/bench/empty.py b/bench/empty.py index 35abeef4140..346b79d5e33 100644 --- a/bench/empty.py +++ b/bench/empty.py @@ -2,4 +2,4 @@ for i in range(1000): - exec("def test_func_%d(): pass" % i) + exec(f"def test_func_{i}(): pass") diff --git a/pyproject.toml b/pyproject.toml index c5833f73851..dce6a0870e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -158,7 +158,6 @@ lint.ignore = [ "PLW2901", # for loop variable overwritten by assignment target # ruff ignore "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` - "UP031", ] lint.per-file-ignores."src/_pytest/_py/**/*.py" = [ "B", diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index bb09c01c11d..bba8896076e 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -217,7 +217,7 @@ def relline(self) -> int: return self.lineno - self.frame.code.firstlineno def __repr__(self) -> str: - return "" % (self.frame.code.path, self.lineno + 1) + return f"" @property def statement(self) -> Source: @@ -303,12 +303,7 @@ def __str__(self) -> str: # This output does not quite match Python's repr for traceback entries, # but changing it to do so would break certain plugins. See # https://github.com/pytest-dev/pytest/pull/7535/ for details. - return " File %r:%d in %s\n %s\n" % ( - str(self.path), - self.lineno + 1, - name, - line, - ) + return f" File '{self.path}':{self.lineno+1} in {name}\n {line}\n" @property def name(self) -> str: diff --git a/src/_pytest/_io/pprint.py b/src/_pytest/_io/pprint.py index ca780c41344..28f06909206 100644 --- a/src/_pytest/_io/pprint.py +++ b/src/_pytest/_io/pprint.py @@ -540,7 +540,7 @@ def _pprint_deque( ) -> None: stream.write(object.__class__.__name__ + "(") if object.maxlen is not None: - stream.write("maxlen=%d, " % object.maxlen) + stream.write(f"maxlen={object.maxlen}, ") stream.write("[") self._format_items(object, stream, indent, allowance + 1, context, level) diff --git a/src/_pytest/_py/error.py b/src/_pytest/_py/error.py index 3a63304008a..de0c04a4838 100644 --- a/src/_pytest/_py/error.py +++ b/src/_pytest/_py/error.py @@ -69,7 +69,7 @@ def _geterrnoclass(self, eno: int) -> type[Error]: try: return self._errno2class[eno] except KeyError: - clsname = errno.errorcode.get(eno, "UnknownErrno%d" % (eno,)) + clsname = errno.errorcode.get(eno, f"UnknownErrno{eno}") errorcls = type( clsname, (Error,), diff --git a/src/_pytest/assertion/util.py b/src/_pytest/assertion/util.py index 0db846ce204..3fe7eb9d862 100644 --- a/src/_pytest/assertion/util.py +++ b/src/_pytest/assertion/util.py @@ -406,8 +406,7 @@ def _compare_eq_sequence( ] else: explanation += [ - "%s contains %d more items, first extra item: %s" - % (dir_with_more, len_diff, highlighter(extra)) + f"{dir_with_more} contains {len_diff} more items, first extra item: {highlighter(extra)}" ] return explanation @@ -510,8 +509,7 @@ def _compare_eq_dict( len_extra_left = len(extra_left) if len_extra_left: explanation.append( - "Left contains %d more item%s:" - % (len_extra_left, "" if len_extra_left == 1 else "s") + f"Left contains {len_extra_left} more item{'' if len_extra_left == 1 else 's'}:" ) explanation.extend( highlighter(pprint.pformat({k: left[k] for k in extra_left})).splitlines() @@ -520,8 +518,7 @@ def _compare_eq_dict( len_extra_right = len(extra_right) if len_extra_right: explanation.append( - "Right contains %d more item%s:" - % (len_extra_right, "" if len_extra_right == 1 else "s") + f"Right contains {len_extra_right} more item{'' if len_extra_right == 1 else 's'}:" ) explanation.extend( highlighter(pprint.pformat({k: right[k] for k in extra_right})).splitlines() diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index bf643d6f4dc..facb98f09e0 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -388,8 +388,8 @@ def pytest_collection_modifyitems( if not previously_failed: # Running a subset of all tests with recorded failures # only outside of it. - self._report_status = "%d known failures not in selected tests" % ( - len(self.lastfailed), + self._report_status = ( + f"{len(self.lastfailed)} known failures not in selected tests" ) else: if self.config.getoption("lf"): @@ -622,5 +622,5 @@ def cacheshow(config: Config, session: Session) -> int: # print("%s/" % p.relative_to(basedir)) if p.is_file(): key = str(p.relative_to(basedir)) - tw.line(f"{key} is a file of length {p.stat().st_size:d}") + tw.line(f"{key} is a file of length {p.stat().st_size}") return 0 diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 2f7413d466a..1aa7495bddb 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -71,8 +71,8 @@ def getlocation(function, curdir: str | os.PathLike[str] | None = None) -> str: except ValueError: pass else: - return "%s:%d" % (relfn, lineno + 1) - return "%s:%d" % (fn, lineno + 1) + return f"{relfn}:{lineno+1}" + return f"{fn}:{lineno+1}" def num_mock_patch_args(function) -> int: diff --git a/src/_pytest/doctest.py b/src/_pytest/doctest.py index 598df84d70e..0dbef6056d7 100644 --- a/src/_pytest/doctest.py +++ b/src/_pytest/doctest.py @@ -353,7 +353,7 @@ def repr_failure( # type: ignore[override] # add line numbers to the left of the error message assert test.lineno is not None lines = [ - "%03d %s" % (i + test.lineno + 1, x) for (i, x) in enumerate(lines) + f"{i + test.lineno + 1:03d} {x}" for (i, x) in enumerate(lines) ] # trim docstring error lines to 10 lines = lines[max(example.lineno - 9, 0) : example.lineno + 1] diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 95fa1336169..76c4b919aff 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -884,7 +884,7 @@ def toterminal(self, tw: TerminalWriter) -> None: red=True, ) tw.line() - tw.line("%s:%d" % (os.fspath(self.filename), self.firstlineno + 1)) + tw.line(f"{os.fspath(self.filename)}:{self.firstlineno + 1}") def call_fixture_func( diff --git a/src/_pytest/main.py b/src/_pytest/main.py index d7086537f39..c97f746e1d6 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -349,8 +349,7 @@ def pytest_collection(session: Session) -> None: def pytest_runtestloop(session: Session) -> bool: if session.testsfailed and not session.config.option.continue_on_collection_errors: raise session.Interrupted( - "%d error%s during collection" - % (session.testsfailed, "s" if session.testsfailed != 1 else "") + f"{session.testsfailed} error{'s' if session.testsfailed != 1 else ''} during collection" ) if session.config.option.collectonly: @@ -585,13 +584,12 @@ def from_config(cls, config: Config) -> Session: return session def __repr__(self) -> str: - return "<%s %s exitstatus=%r testsfailed=%d testscollected=%d>" % ( - self.__class__.__name__, - self.name, - getattr(self, "exitstatus", ""), - self.testsfailed, - self.testscollected, - ) + return ( + f"<{self.__class__.__name__} {self.name} " + f"exitstatus=%r " + f"testsfailed={self.testsfailed} " + f"testscollected={self.testscollected}>" + ) % getattr(self, "exitstatus", "") @property def shouldstop(self) -> bool | str: @@ -654,7 +652,7 @@ def pytest_runtest_logreport(self, report: TestReport | CollectReport) -> None: self.testsfailed += 1 maxfail = self.config.getvalue("maxfail") if maxfail and self.testsfailed >= maxfail: - self.shouldfail = "stopping after %d failures" % (self.testsfailed) + self.shouldfail = f"stopping after {self.testsfailed} failures" pytest_collectreport = pytest_runtest_logreport diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index e7e32555ba4..ac64ef2d606 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -48,13 +48,7 @@ def get_empty_parameterset_mark( from ..nodes import Collector fs, lineno = getfslineno(func) - reason = "got empty parameter set %r, function %s at %s:%d" % ( - argnames, - func.__name__, - fs, - lineno, - ) - + reason = f"got empty parameter set {argnames!r}, function {func.__name__} at {fs}:{lineno}" requested_mark = config.getini(EMPTY_PARAMETERSET_OPTION) if requested_mark in ("", None, "skip"): mark = MARK_GEN.skip(reason=reason) @@ -64,7 +58,7 @@ def get_empty_parameterset_mark( f_name = func.__name__ _, lineno = getfslineno(func) raise Collector.CollectError( - "Empty parameter set in '%s' at line %d" % (f_name, lineno + 1) + f"Empty parameter set in '{f_name}' at line {lineno + 1}" ) else: raise LookupError(requested_mark) diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 056be52a4ed..412d850d2da 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -547,8 +547,10 @@ def __init__( def __repr__(self) -> str: return ( - "" - % (self.ret, len(self.stdout.lines), len(self.stderr.lines), self.duration) + f"" ) def parseoutcomes(self) -> dict[str, int]: diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index a74f73bff17..348a78af9f5 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -766,13 +766,13 @@ def report_collect(self, final: bool = False) -> None: str(self._numcollected) + " item" + ("" if self._numcollected == 1 else "s") ) if errors: - line += " / %d error%s" % (errors, "s" if errors != 1 else "") + line += f" / {errors} error{'s' if errors != 1 else ''}" if deselected: - line += " / %d deselected" % deselected + line += f" / {deselected} deselected" if skipped: - line += " / %d skipped" % skipped + line += f" / {skipped} skipped" if self._numcollected > selected: - line += " / %d selected" % selected + line += f" / {selected} selected" if self.isatty: self.rewrite(line, bold=True, erase=True) if final: @@ -862,7 +862,7 @@ def _printcollecteditems(self, items: Sequence[Item]) -> None: if test_cases_verbosity < -1: counts = Counter(item.nodeid.split("::", 1)[0] for item in items) for name, count in sorted(counts.items()): - self._tw.line("%s: %d" % (name, count)) + self._tw.line(f"{name}: {count}") else: for item in items: self._tw.line(item.nodeid) @@ -1254,11 +1254,9 @@ def show_skipped_folded(lines: list[str]) -> None: if reason.startswith(prefix): reason = reason[len(prefix) :] if lineno is not None: - lines.append( - "%s [%d] %s:%d: %s" % (markup_word, num, fspath, lineno, reason) - ) + lines.append(f"{markup_word} [{num}] {fspath}:{lineno}: {reason}") else: - lines.append("%s [%d] %s: %s" % (markup_word, num, fspath, reason)) + lines.append(f"{markup_word} [{num}] {fspath}: {reason}") def show_skipped_unfolded(lines: list[str]) -> None: skipped: list[CollectReport] = self.stats.get("skipped", []) @@ -1375,7 +1373,7 @@ def _build_normal_summary_stats_line( count = len(reports) color = _color_for_type.get(key, _color_for_type_default) markup = {color: True, "bold": color == main_color} - parts.append(("%d %s" % pluralize(count, key), markup)) + parts.append(("%d %s" % pluralize(count, key), markup)) # noqa: UP031 if not parts: parts = [("no tests ran", {_color_for_type_default: True})] @@ -1394,7 +1392,7 @@ def _build_collect_only_summary_stats_line( elif deselected == 0: main_color = "green" - collected_output = "%d %s collected" % pluralize(self._numcollected, "test") + collected_output = "%d %s collected" % pluralize(self._numcollected, "test") # noqa: UP031 parts = [(collected_output, {main_color: True})] else: all_tests_were_deselected = self._numcollected == deselected @@ -1410,7 +1408,7 @@ def _build_collect_only_summary_stats_line( if errors: main_color = _color_for_type["error"] - parts += [("%d %s" % pluralize(errors, "error"), {main_color: True})] + parts += [("%d %s" % pluralize(errors, "error"), {main_color: True})] # noqa: UP031 return parts, main_color diff --git a/testing/_py/test_local.py b/testing/_py/test_local.py index b6d49c5425e..cd8752fb79b 100644 --- a/testing/_py/test_local.py +++ b/testing/_py/test_local.py @@ -948,7 +948,7 @@ def test_make_numbered_dir(self, tmpdir): prefix="base.", rootdir=tmpdir, keep=2, lock_timeout=0 ) assert numdir.check() - assert numdir.basename == "base.%d" % i + assert numdir.basename == f"base.{i}" if i >= 1: assert numdir.new(ext=str(i - 1)).check() if i >= 2: @@ -993,7 +993,7 @@ def test_locked_make_numbered_dir(self, tmpdir): for i in range(10): numdir = local.make_numbered_dir(prefix="base2.", rootdir=tmpdir, keep=2) assert numdir.check() - assert numdir.basename == "base2.%d" % i + assert numdir.basename == f"base2.{i}" for j in range(i): assert numdir.new(ext=str(j)).check() diff --git a/testing/example_scripts/dataclasses/test_compare_dataclasses_with_custom_eq.py b/testing/example_scripts/dataclasses/test_compare_dataclasses_with_custom_eq.py index e25bebf74dd..5ae9a02f99b 100644 --- a/testing/example_scripts/dataclasses/test_compare_dataclasses_with_custom_eq.py +++ b/testing/example_scripts/dataclasses/test_compare_dataclasses_with_custom_eq.py @@ -10,8 +10,8 @@ class SimpleDataObject: field_a: int = field() field_b: str = field() - def __eq__(self, __o: object, /) -> bool: - return super().__eq__(__o) + def __eq__(self, o: object, /) -> bool: + return super().__eq__(o) left = SimpleDataObject(1, "b") right = SimpleDataObject(1, "c") diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index df6dbaee0fd..4e7e441768c 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -1438,13 +1438,13 @@ def test_parametrize_scope_overrides( self, pytester: Pytester, scope: str, length: int ) -> None: pytester.makepyfile( - """ + f""" import pytest values = [] def pytest_generate_tests(metafunc): if "arg" in metafunc.fixturenames: metafunc.parametrize("arg", [1,2], indirect=True, - scope=%r) + scope={scope!r}) @pytest.fixture def arg(request): values.append(request.param) @@ -1454,9 +1454,8 @@ def test_hello(arg): def test_world(arg): assert arg in (1,2) def test_checklength(): - assert len(values) == %d + assert len(values) == {length} """ - % (scope, length) ) reprec = pytester.inline_run() reprec.assertoutcome(passed=5) diff --git a/testing/test_assertion.py b/testing/test_assertion.py index a14c4125cf6..a2e2304d342 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -1406,15 +1406,14 @@ def test_full_output_truncated(self, monkeypatch, pytester: Pytester) -> None: line_len = 100 expected_truncated_lines = 2 pytester.makepyfile( - r""" + rf""" def test_many_lines(): - a = list([str(i)[0] * %d for i in range(%d)]) + a = list([str(i)[0] * {line_len} for i in range({line_count})]) b = a[::2] a = '\n'.join(map(str, a)) b = '\n'.join(map(str, b)) assert a == b """ - % (line_len, line_count) ) monkeypatch.delenv("CI", raising=False) @@ -1424,7 +1423,7 @@ def test_many_lines(): [ "*+ 1*", "*+ 3*", - "*truncated (%d lines hidden)*use*-vv*" % expected_truncated_lines, + f"*truncated ({expected_truncated_lines} lines hidden)*use*-vv*", ] ) diff --git a/testing/test_conftest.py b/testing/test_conftest.py index bbb1d301ebe..bd083574ffc 100644 --- a/testing/test_conftest.py +++ b/testing/test_conftest.py @@ -699,9 +699,9 @@ def out_of_reach(): pass result = pytester.runpytest(*args) match = "" if passed: - match += "*%d passed*" % passed + match += f"*{passed} passed*" if error: - match += "*%d error*" % error + match += f"*{error} error*" result.stdout.fnmatch_lines(match) diff --git a/testing/test_doctest.py b/testing/test_doctest.py index d3ad09da871..1a852ebc82a 100644 --- a/testing/test_doctest.py +++ b/testing/test_doctest.py @@ -1328,7 +1328,7 @@ def test_bar(): params = ("--doctest-modules",) if enable_doctest else () passes = 3 if enable_doctest else 2 result = pytester.runpytest(*params) - result.stdout.fnmatch_lines(["*=== %d passed in *" % passes]) + result.stdout.fnmatch_lines([f"*=== {passes} passed in *"]) @pytest.mark.parametrize("scope", SCOPES) @pytest.mark.parametrize("autouse", [True, False]) diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 872703900cd..6fa04be28b1 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -49,7 +49,7 @@ def __init__(self, verbosity=0): @property def args(self): values = [] - values.append("--verbosity=%d" % self.verbosity) + values.append(f"--verbosity={self.verbosity}") return values From 4b32e7cc33f2972417436fbc86d915944f6c906a Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sat, 30 Nov 2024 21:17:32 +0000 Subject: [PATCH 198/445] Enhancements to unraisable plugin (#12958) A number of `unraisable` plugin enhancements: * Set the unraisablehook as early as possible and unset it as late as possible, to collect the most possible unraisable exceptions (please let me know if there's an earlier or later hook I can use). * Call the garbage collector just before unsetting the unraisablehook, to collect any straggling exceptions * Collect multiple unraisable exceptions per test phase. * Report the tracemalloc allocation traceback, if available. * Avoid using a generator based hook to allow handling StopIteration in test failures * Report the unraisable exception as the cause of the PytestUnraisableExceptionWarning exception if raised. * Compute the repr of the unraisable.object in the unraisablehook so you get the latest information if available, and should help with resurrection of the object. Co-authored-by: Ran Benita Co-authored-by: Bruno Oliveira --- changelog/12958.improvement.rst | 9 ++ src/_pytest/tracemalloc.py | 24 +++ src/_pytest/unraisableexception.py | 222 ++++++++++++++++++---------- src/_pytest/warnings.py | 26 +--- testing/test_unraisableexception.py | 106 ++++++++++++- 5 files changed, 279 insertions(+), 108 deletions(-) create mode 100644 changelog/12958.improvement.rst create mode 100644 src/_pytest/tracemalloc.py diff --git a/changelog/12958.improvement.rst b/changelog/12958.improvement.rst new file mode 100644 index 00000000000..ee8dc8c0710 --- /dev/null +++ b/changelog/12958.improvement.rst @@ -0,0 +1,9 @@ +A number of :ref:`unraisable ` enhancements: + +* Set the unraisable hook as early as possible and unset it as late as possible, to collect the most possible number of unraisable exceptions. +* Call the garbage collector just before unsetting the unraisable hook, to collect any straggling exceptions. +* Collect multiple unraisable exceptions per test phase. +* Report the :mod:`tracemalloc` allocation traceback (if available). +* Avoid using a generator based hook to allow handling :class:`StopIteration` in test failures. +* Report the unraisable exception as the cause of the :class:`pytest.PytestUnraisableExceptionWarning` exception if raised. +* Compute the ``repr`` of the unraisable object in the unraisable hook so you get the latest information if available, and should help with resurrection of the object. diff --git a/src/_pytest/tracemalloc.py b/src/_pytest/tracemalloc.py new file mode 100644 index 00000000000..5d0b19855c7 --- /dev/null +++ b/src/_pytest/tracemalloc.py @@ -0,0 +1,24 @@ +from __future__ import annotations + + +def tracemalloc_message(source: object) -> str: + if source is None: + return "" + + try: + import tracemalloc + except ImportError: + return "" + + tb = tracemalloc.get_object_traceback(source) + if tb is not None: + formatted_tb = "\n".join(tb.format()) + # Use a leading new line to better separate the (large) output + # from the traceback to the previous warning text. + return f"\nObject allocated at:\n{formatted_tb}" + # No need for a leading new line. + url = "https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings" + return ( + "Enable tracemalloc to get traceback where the object was allocated.\n" + f"See {url} for more info." + ) diff --git a/src/_pytest/unraisableexception.py b/src/_pytest/unraisableexception.py index 5796b37715d..2bd7f07e862 100644 --- a/src/_pytest/unraisableexception.py +++ b/src/_pytest/unraisableexception.py @@ -1,100 +1,158 @@ from __future__ import annotations +import collections from collections.abc import Callable -from collections.abc import Generator +import functools +import gc import sys import traceback -from types import TracebackType -from typing import Any +from typing import NamedTuple from typing import TYPE_CHECKING import warnings +from _pytest.config import Config +from _pytest.nodes import Item +from _pytest.stash import StashKey +from _pytest.tracemalloc import tracemalloc_message import pytest if TYPE_CHECKING: - from typing_extensions import Self - - -# Copied from cpython/Lib/test/support/__init__.py, with modifications. -class catch_unraisable_exception: - """Context manager catching unraisable exception using sys.unraisablehook. - - Storing the exception value (cm.unraisable.exc_value) creates a reference - cycle. The reference cycle is broken explicitly when the context manager - exits. - - Storing the object (cm.unraisable.object) can resurrect it if it is set to - an object which is being finalized. Exiting the context manager clears the - stored object. - - Usage: - with catch_unraisable_exception() as cm: - # code creating an "unraisable exception" - ... - # check the unraisable exception: use cm.unraisable - ... - # cm.unraisable attribute no longer exists at this point - # (to break a reference cycle) - """ - - def __init__(self) -> None: - self.unraisable: sys.UnraisableHookArgs | None = None - self._old_hook: Callable[[sys.UnraisableHookArgs], Any] | None = None - - def _hook(self, unraisable: sys.UnraisableHookArgs) -> None: - # Storing unraisable.object can resurrect an object which is being - # finalized. Storing unraisable.exc_value creates a reference cycle. - self.unraisable = unraisable - - def __enter__(self) -> Self: - self._old_hook = sys.unraisablehook - sys.unraisablehook = self._hook - return self - - def __exit__( - self, - exc_type: type[BaseException] | None, - exc_val: BaseException | None, - exc_tb: TracebackType | None, - ) -> None: - assert self._old_hook is not None - sys.unraisablehook = self._old_hook - self._old_hook = None - del self.unraisable - - -def unraisable_exception_runtest_hook() -> Generator[None]: - with catch_unraisable_exception() as cm: - try: - yield - finally: - if cm.unraisable: - if cm.unraisable.err_msg is not None: - err_msg = cm.unraisable.err_msg - else: - err_msg = "Exception ignored in" - msg = f"{err_msg}: {cm.unraisable.object!r}\n\n" - msg += "".join( - traceback.format_exception( - cm.unraisable.exc_type, - cm.unraisable.exc_value, - cm.unraisable.exc_traceback, - ) - ) - warnings.warn(pytest.PytestUnraisableExceptionWarning(msg)) + pass + +if sys.version_info < (3, 11): + from exceptiongroup import ExceptionGroup + + +def gc_collect_harder() -> None: + # A single collection doesn't necessarily collect everything. + # Constant determined experimentally by the Trio project. + for _ in range(5): + gc.collect() -@pytest.hookimpl(wrapper=True, tryfirst=True) -def pytest_runtest_setup() -> Generator[None]: - yield from unraisable_exception_runtest_hook() +class UnraisableMeta(NamedTuple): + msg: str + cause_msg: str + exc_value: BaseException | None -@pytest.hookimpl(wrapper=True, tryfirst=True) -def pytest_runtest_call() -> Generator[None]: - yield from unraisable_exception_runtest_hook() +unraisable_exceptions: StashKey[collections.deque[UnraisableMeta | BaseException]] = ( + StashKey() +) -@pytest.hookimpl(wrapper=True, tryfirst=True) -def pytest_runtest_teardown() -> Generator[None]: - yield from unraisable_exception_runtest_hook() +def collect_unraisable(config: Config) -> None: + pop_unraisable = config.stash[unraisable_exceptions].pop + errors: list[pytest.PytestUnraisableExceptionWarning | RuntimeError] = [] + meta = None + hook_error = None + try: + while True: + try: + meta = pop_unraisable() + except IndexError: + break + + if isinstance(meta, BaseException): + hook_error = RuntimeError("Failed to process unraisable exception") + hook_error.__cause__ = meta + errors.append(hook_error) + continue + + msg = meta.msg + try: + warnings.warn(pytest.PytestUnraisableExceptionWarning(msg)) + except pytest.PytestUnraisableExceptionWarning as e: + # This except happens when the warning is treated as an error (e.g. `-Werror`). + if meta.exc_value is not None: + # Exceptions have a better way to show the traceback, but + # warnings do not, so hide the traceback from the msg and + # set the cause so the traceback shows up in the right place. + e.args = (meta.cause_msg,) + e.__cause__ = meta.exc_value + errors.append(e) + + if len(errors) == 1: + raise errors[0] + if errors: + raise ExceptionGroup("multiple unraisable exception warnings", errors) + finally: + del errors, meta, hook_error + + +def cleanup( + *, config: Config, prev_hook: Callable[[sys.UnraisableHookArgs], object] +) -> None: + try: + try: + gc_collect_harder() + collect_unraisable(config) + finally: + sys.unraisablehook = prev_hook + finally: + del config.stash[unraisable_exceptions] + + +def unraisable_hook( + unraisable: sys.UnraisableHookArgs, + /, + *, + append: Callable[[UnraisableMeta | BaseException], object], +) -> None: + try: + err_msg = ( + "Exception ignored in" if unraisable.err_msg is None else unraisable.err_msg + ) + summary = f"{err_msg}: {unraisable.object!r}" + traceback_message = "\n\n" + "".join( + traceback.format_exception( + unraisable.exc_type, + unraisable.exc_value, + unraisable.exc_traceback, + ) + ) + tracemalloc_tb = "\n" + tracemalloc_message(unraisable.object) + msg = summary + traceback_message + tracemalloc_tb + cause_msg = summary + tracemalloc_tb + + append( + UnraisableMeta( + # we need to compute these strings here as they might change after + # the unraisablehook finishes and before the unraisable object is + # collected by a hook + msg=msg, + cause_msg=cause_msg, + exc_value=unraisable.exc_value, + ) + ) + except BaseException as e: + append(e) + # Raising this will cause the exception to be logged twice, once in our + # collect_unraisable and once by the unraisablehook calling machinery + # which is fine - this should never happen anyway and if it does + # it should probably be reported as a pytest bug. + raise + + +def pytest_configure(config: Config) -> None: + prev_hook = sys.unraisablehook + deque: collections.deque[UnraisableMeta | BaseException] = collections.deque() + config.stash[unraisable_exceptions] = deque + config.add_cleanup(functools.partial(cleanup, config=config, prev_hook=prev_hook)) + sys.unraisablehook = functools.partial(unraisable_hook, append=deque.append) + + +@pytest.hookimpl(trylast=True) +def pytest_runtest_setup(item: Item) -> None: + collect_unraisable(item.config) + + +@pytest.hookimpl(trylast=True) +def pytest_runtest_call(item: Item) -> None: + collect_unraisable(item.config) + + +@pytest.hookimpl(trylast=True) +def pytest_runtest_teardown(item: Item) -> None: + collect_unraisable(item.config) diff --git a/src/_pytest/warnings.py b/src/_pytest/warnings.py index 87cdbda288f..64ea3ff222d 100644 --- a/src/_pytest/warnings.py +++ b/src/_pytest/warnings.py @@ -13,6 +13,7 @@ from _pytest.main import Session from _pytest.nodes import Item from _pytest.terminal import TerminalReporter +from _pytest.tracemalloc import tracemalloc_message import pytest @@ -76,32 +77,13 @@ def catch_warnings_for_item( def warning_record_to_str(warning_message: warnings.WarningMessage) -> str: """Convert a warnings.WarningMessage to a string.""" - warn_msg = warning_message.message - msg = warnings.formatwarning( - str(warn_msg), + return warnings.formatwarning( + str(warning_message.message), warning_message.category, warning_message.filename, warning_message.lineno, warning_message.line, - ) - if warning_message.source is not None: - try: - import tracemalloc - except ImportError: - pass - else: - tb = tracemalloc.get_object_traceback(warning_message.source) - if tb is not None: - formatted_tb = "\n".join(tb.format()) - # Use a leading new line to better separate the (large) output - # from the traceback to the previous warning text. - msg += f"\nObject allocated at:\n{formatted_tb}" - else: - # No need for a leading new line. - url = "https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings" - msg += "Enable tracemalloc to get traceback where the object was allocated.\n" - msg += f"See {url} for more info." - return msg + ) + tracemalloc_message(warning_message.source) @pytest.hookimpl(wrapper=True, tryfirst=True) diff --git a/testing/test_unraisableexception.py b/testing/test_unraisableexception.py index a15c754d067..70248e1c122 100644 --- a/testing/test_unraisableexception.py +++ b/testing/test_unraisableexception.py @@ -1,6 +1,8 @@ from __future__ import annotations +import gc import sys +from unittest import mock from _pytest.pytester import Pytester import pytest @@ -27,7 +29,7 @@ def test_2(): pass ) result = pytester.runpytest() assert result.ret == 0 - assert result.parseoutcomes() == {"passed": 2, "warnings": 1} + result.assert_outcomes(passed=2, warnings=1) result.stdout.fnmatch_lines( [ "*= warnings summary =*", @@ -37,6 +39,8 @@ def test_2(): pass " Traceback (most recent call last):", " ValueError: del is broken", " ", + " Enable tracemalloc to get traceback where the object was allocated.", + " See https* for more info.", " warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))", ] ) @@ -64,7 +68,7 @@ def test_2(): pass ) result = pytester.runpytest() assert result.ret == 0 - assert result.parseoutcomes() == {"passed": 2, "warnings": 1} + result.assert_outcomes(passed=2, warnings=1) result.stdout.fnmatch_lines( [ "*= warnings summary =*", @@ -74,6 +78,8 @@ def test_2(): pass " Traceback (most recent call last):", " ValueError: del is broken", " ", + " Enable tracemalloc to get traceback where the object was allocated.", + " See https* for more info.", " warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))", ] ) @@ -102,7 +108,7 @@ def test_2(): pass ) result = pytester.runpytest() assert result.ret == 0 - assert result.parseoutcomes() == {"passed": 2, "warnings": 1} + result.assert_outcomes(passed=2, warnings=1) result.stdout.fnmatch_lines( [ "*= warnings summary =*", @@ -112,6 +118,8 @@ def test_2(): pass " Traceback (most recent call last):", " ValueError: del is broken", " ", + " Enable tracemalloc to get traceback where the object was allocated.", + " See https* for more info.", " warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))", ] ) @@ -135,4 +143,94 @@ def test_2(): pass ) result = pytester.runpytest() assert result.ret == pytest.ExitCode.TESTS_FAILED - assert result.parseoutcomes() == {"passed": 1, "failed": 1} + result.assert_outcomes(passed=1, failed=1) + + +@pytest.mark.filterwarnings("error::pytest.PytestUnraisableExceptionWarning") +def test_unraisable_warning_multiple_errors(pytester: Pytester) -> None: + pytester.makepyfile( + test_it=f""" + class BrokenDel: + def __init__(self, msg: str): + self.msg = msg + + def __del__(self) -> None: + raise ValueError(self.msg) + + def test_it() -> None: + BrokenDel("del is broken 1") + BrokenDel("del is broken 2") + {"import gc; gc.collect()" * PYPY} + + def test_2(): pass + """ + ) + result = pytester.runpytest() + assert result.ret == pytest.ExitCode.TESTS_FAILED + result.assert_outcomes(passed=1, failed=1) + result.stdout.fnmatch_lines( + [ + " | *ExceptionGroup: multiple unraisable exception warnings (2 sub-exceptions)" + ] + ) + + +def test_unraisable_collection_failure(pytester: Pytester) -> None: + pytester.makepyfile( + test_it=f""" + class BrokenDel: + def __del__(self): + raise ValueError("del is broken") + + def test_it(): + obj = BrokenDel() + del obj + {"import gc; gc.collect()" * PYPY} + + def test_2(): pass + """ + ) + + class MyError(BaseException): + pass + + with mock.patch("traceback.format_exception", side_effect=MyError): + result = pytester.runpytest() + assert result.ret == 1 + result.assert_outcomes(passed=1, failed=1) + result.stdout.fnmatch_lines( + ["E RuntimeError: Failed to process unraisable exception"] + ) + + +def test_create_task_unraisable(pytester: Pytester) -> None: + # see: https://github.com/pytest-dev/pytest/issues/10404 + pytester.makepyfile( + test_it=""" + import pytest + + class BrokenDel: + def __init__(self): + self.self = self # make a reference cycle + + def __del__(self): + raise ValueError("del is broken") + + def test_it(): + BrokenDel() + """ + ) + + was_enabled = gc.isenabled() + gc.disable() + try: + result = pytester.runpytest() + finally: + if was_enabled: + gc.enable() + + # TODO: should be a test failure or error + assert result.ret == pytest.ExitCode.INTERNAL_ERROR + + result.assert_outcomes(passed=1) + result.stderr.fnmatch_lines("ValueError: del is broken") From 68b5938f057c5fc748e362befd18e3812b59b3e7 Mon Sep 17 00:00:00 2001 From: pytest bot Date: Sun, 1 Dec 2024 00:30:58 +0000 Subject: [PATCH 199/445] [automated] Update plugin list --- doc/en/reference/plugin_list.rst | 220 ++++++++++++++++++------------- 1 file changed, 130 insertions(+), 90 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 3ac9b0b4c13..62535d2d366 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =6.2.2) :pypi:`pytest-ai1899` pytest plugin for connecting to ai1899 smart system stack Mar 13, 2024 5 - Production/Stable N/A :pypi:`pytest-aio` Pytest plugin for testing async python code Jul 31, 2024 5 - Production/Stable pytest + :pypi:`pytest-aioboto3` Aioboto3 Pytest with Moto Nov 26, 2024 N/A N/A :pypi:`pytest-aiofiles` pytest fixtures for writing aiofiles tests with pyfakefs May 14, 2017 5 - Production/Stable N/A :pypi:`pytest-aiogram` May 06, 2023 N/A N/A :pypi:`pytest-aiohttp` Pytest plugin for aiohttp support Sep 06, 2023 4 - Beta pytest >=6.1.0 @@ -150,14 +151,14 @@ This list contains 1546 plugins. :pypi:`pytest-bazel` A pytest runner with bazel support Sep 27, 2024 4 - Beta pytest :pypi:`pytest-bdd` BDD for pytest Nov 14, 2024 6 - Mature pytest>=7.0.0 :pypi:`pytest-bdd-html` pytest plugin to display BDD info in HTML test report Nov 22, 2022 3 - Alpha pytest (!=6.0.0,>=5.0) - :pypi:`pytest-bdd-ng` BDD for pytest Oct 07, 2024 4 - Beta pytest>=5.0 - :pypi:`pytest-bdd-report` A pytest-bdd plugin for generating useful and informative BDD test reports Aug 26, 2024 N/A pytest>=7.1.3 + :pypi:`pytest-bdd-ng` BDD for pytest Nov 26, 2024 4 - Beta pytest>=5.2 + :pypi:`pytest-bdd-report` A pytest-bdd plugin for generating useful and informative BDD test reports Nov 27, 2024 N/A pytest>=7.1.3 :pypi:`pytest-bdd-splinter` Common steps for pytest bdd and splinter integration Aug 12, 2019 5 - Production/Stable pytest (>=4.0.0) :pypi:`pytest-bdd-web` A simple plugin to use with pytest Jan 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Nov 18, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Nov 27, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -211,7 +212,7 @@ This list contains 1546 plugins. :pypi:`pytest-caprng` A plugin that replays pRNG state on failure. May 02, 2018 4 - Beta N/A :pypi:`pytest-capture-deprecatedwarnings` pytest plugin to capture all deprecatedwarnings and put them in one file Apr 30, 2019 N/A N/A :pypi:`pytest-capture-warnings` pytest plugin to capture all warnings and put them in one file of your choice May 03, 2022 N/A pytest - :pypi:`pytest-case` A clean, modern, wrapper for pytest.mark.parametrize Nov 22, 2024 N/A pytest<9.0.0,>=8.3.3 + :pypi:`pytest-case` A clean, modern, wrapper for pytest.mark.parametrize Nov 25, 2024 N/A pytest<9.0.0,>=8.3.3 :pypi:`pytest-cases` Separate test code from test cases in pytest. Sep 26, 2024 5 - Production/Stable N/A :pypi:`pytest-cassandra` Cassandra CCM Test Fixtures for pytest Nov 04, 2017 1 - Planning N/A :pypi:`pytest-catchlog` py.test plugin to catch log messages. This is a fork of pytest-capturelog. Jan 24, 2016 4 - Beta pytest (>=2.6) @@ -249,7 +250,7 @@ This list contains 1546 plugins. :pypi:`pytest-cleanslate` Collects and executes pytest tests separately Sep 04, 2024 N/A pytest :pypi:`pytest_cleanup` Automated, comprehensive and well-organised pytest test cases. Jan 28, 2020 N/A N/A :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Nov 08, 2024 5 - Production/Stable N/A - :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Oct 08, 2024 N/A pytest<9.0.0,>=8.0.0 + :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Nov 29, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-click` Pytest plugin for Click Feb 11, 2022 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-cli-fixtures` Automatically register fixtures for custom CLI arguments Jul 28, 2022 N/A pytest (~=7.0) :pypi:`pytest-clld` Oct 23, 2024 N/A pytest>=3.9 @@ -429,7 +430,7 @@ This list contains 1546 plugins. :pypi:`pytest-doctest-ellipsis-markers` Setup additional values for ELLIPSIS_MARKER for doctests Jan 12, 2018 4 - Beta N/A :pypi:`pytest-doctest-import` A simple pytest plugin to import names and add them to the doctest namespace. Nov 13, 2018 4 - Beta pytest (>=3.3.0) :pypi:`pytest-doctest-mkdocstrings` Run pytest --doctest-modules with markdown docstrings in code blocks (\`\`\`) Mar 02, 2024 N/A pytest - :pypi:`pytest-doctestplus` Pytest plugin with advanced doctest features. Mar 10, 2024 5 - Production/Stable pytest >=4.6 + :pypi:`pytest-doctestplus` Pytest plugin with advanced doctest features. Nov 25, 2024 5 - Production/Stable pytest>=4.6 :pypi:`pytest-documentary` A simple pytest plugin to generate test documentation Jul 11, 2024 N/A pytest :pypi:`pytest-dogu-report` pytest plugin for dogu report Jul 07, 2023 N/A N/A :pypi:`pytest-dogu-sdk` pytest plugin for the Dogu Dec 14, 2023 N/A N/A @@ -506,7 +507,7 @@ This list contains 1546 plugins. :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Nov 20, 2024 N/A pytest>=7 :pypi:`pytest-exasol-backend` Nov 22, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-extension` Oct 10, 2024 N/A pytest<9,>=7 - :pypi:`pytest-exasol-itde` Jul 01, 2024 N/A pytest<9,>=7 + :pypi:`pytest-exasol-itde` Nov 22, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-saas` Nov 22, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-slc` Nov 01, 2024 N/A pytest<9,>=7 :pypi:`pytest-excel` pytest plugin for generating excel reports Jun 18, 2024 5 - Production/Stable pytest>3.6 @@ -578,6 +579,7 @@ This list contains 1546 plugins. :pypi:`pytest-flake8` pytest plugin to check FLAKE8 requirements Nov 09, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-flake8-path` A pytest fixture for testing flake8 plugins. Oct 25, 2024 5 - Production/Stable pytest :pypi:`pytest-flake8-v2` pytest plugin to check FLAKE8 requirements Mar 01, 2022 5 - Production/Stable pytest (>=7.0) + :pypi:`pytest-flake-detection` Continuously runs your tests to detect flaky tests Nov 29, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-flakefinder` Runs tests multiple times to expose flakiness. Oct 26, 2022 4 - Beta pytest (>=2.7.1) :pypi:`pytest-flakes` pytest plugin to check source code with pyflakes Dec 02, 2021 5 - Production/Stable pytest (>=5) :pypi:`pytest-flaptastic` Flaptastic py.test plugin Mar 17, 2019 N/A N/A @@ -664,7 +666,7 @@ This list contains 1546 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Nov 16, 2024 3 - Alpha pytest==8.3.3 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Nov 29, 2024 3 - Alpha pytest==8.3.3 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -684,12 +686,12 @@ This list contains 1546 plugins. :pypi:`pytest-html-thread` pytest plugin for generating HTML reports Dec 29, 2020 5 - Production/Stable N/A :pypi:`pytest-http` Fixture "http" for http requests Aug 22, 2024 N/A pytest :pypi:`pytest-httpbin` Easily test your HTTP library against a local copy of httpbin Sep 18, 2024 5 - Production/Stable pytest; extra == "test" - :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace Oct 21, 2024 4 - Beta pytest>=7.0.0 + :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace Nov 23, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-http-mocker` Pytest plugin for http mocking (via https://github.com/vilus/mocker) Oct 20, 2019 N/A N/A :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Aug 11, 2024 3 - Alpha N/A :pypi:`pytest-httptesting` http_testing framework on top of pytest Aug 10, 2024 N/A pytest<9.0.0,>=8.2.0 - :pypi:`pytest-httpx` Send responses to httpx. Nov 18, 2024 5 - Production/Stable pytest==8.* + :pypi:`pytest-httpx` Send responses to httpx. Nov 28, 2024 5 - Production/Stable pytest==8.* :pypi:`pytest-httpx-blockage` Disable httpx requests during a test run Feb 16, 2023 N/A pytest (>=7.2.1) :pypi:`pytest-httpx-recorder` Recorder feature based on pytest_httpx, like recorder feature in responses. Jan 04, 2024 5 - Production/Stable pytest :pypi:`pytest-hue` Visualise PyTest status via your Phillips Hue lights May 09, 2019 N/A N/A @@ -719,10 +721,10 @@ This list contains 1546 plugins. :pypi:`pytest-inline` A pytest plugin for writing inline tests Oct 24, 2024 4 - Beta pytest<9.0,>=7.0 :pypi:`pytest-inmanta` A py.test plugin providing fixtures to simplify inmanta modules testing. Oct 10, 2024 5 - Production/Stable pytest :pypi:`pytest-inmanta-extensions` Inmanta tests package Oct 10, 2024 5 - Production/Stable N/A - :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Oct 29, 2024 5 - Production/Stable N/A + :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Nov 26, 2024 5 - Production/Stable N/A :pypi:`pytest-inmanta-yang` Common fixtures used in inmanta yang related modules Feb 22, 2024 4 - Beta pytest :pypi:`pytest-Inomaly` A simple image diff plugin for pytest Feb 13, 2018 4 - Beta N/A - :pypi:`pytest-in-robotframework` The extension enables easy execution of pytest tests within the Robot Framework environment. Mar 02, 2024 N/A pytest + :pypi:`pytest-in-robotframework` The extension enables easy execution of pytest tests within the Robot Framework environment. Nov 23, 2024 N/A pytest :pypi:`pytest-insper` Pytest plugin for courses at Insper Mar 21, 2024 N/A pytest :pypi:`pytest-insta` A practical snapshot testing plugin for pytest Feb 19, 2024 N/A pytest (>=7.2.0,<9.0.0) :pypi:`pytest-instafail` pytest plugin to show failures instantly Mar 31, 2023 4 - Beta pytest (>=5) @@ -738,7 +740,7 @@ This list contains 1546 plugins. :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A :pypi:`pytest-ipywidgets` Oct 28, 2024 N/A pytest - :pypi:`pytest-isolate` Feb 20, 2023 4 - Beta pytest + :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Nov 24, 2024 4 - Beta pytest :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Sep 18, 2024 4 - Beta pytest>=5 :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-it` Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it. Jan 29, 2024 4 - Beta N/A @@ -805,7 +807,7 @@ This list contains 1546 plugins. :pypi:`pytest-line-profiler` Profile code executed by pytest Aug 10, 2023 4 - Beta pytest >=3.5.0 :pypi:`pytest-line-profiler-apn` Profile code executed by pytest Dec 05, 2022 N/A pytest (>=3.5.0) :pypi:`pytest-lisa` Pytest plugin for organizing tests. Jan 21, 2021 3 - Alpha pytest (>=6.1.2,<7.0.0) - :pypi:`pytest-listener` A simple network listener Oct 17, 2024 5 - Production/Stable pytest + :pypi:`pytest-listener` A simple network listener Nov 29, 2024 5 - Production/Stable pytest :pypi:`pytest-litf` A pytest plugin that stream output in LITF format Jan 18, 2021 4 - Beta pytest (>=3.1.1) :pypi:`pytest-litter` Pytest plugin which verifies that tests do not modify file trees. Nov 23, 2023 4 - Beta pytest >=6.1 :pypi:`pytest-live` Live results for pytest Mar 08, 2020 N/A pytest @@ -823,17 +825,17 @@ This list contains 1546 plugins. :pypi:`pytest-logger` Plugin configuring handlers for loggers from Python logging module. Mar 10, 2024 5 - Production/Stable pytest (>=3.2) :pypi:`pytest-logging` Configures logging and allows tweaking the log level with a py.test flag Nov 04, 2015 4 - Beta N/A :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-logikal` Common testing environment Nov 09, 2024 5 - Production/Stable pytest==8.3.3 + :pypi:`pytest-logikal` Common testing environment Nov 27, 2024 5 - Production/Stable pytest==8.3.3 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Sep 30, 2024 4 - Beta pytest>=8.2.2 :pypi:`pytest-loguru` Pytest Loguru Mar 20, 2024 5 - Production/Stable pytest; extra == "test" :pypi:`pytest-loop` pytest plugin for looping tests Oct 17, 2024 5 - Production/Stable pytest - :pypi:`pytest-lsp` A pytest plugin for end-to-end testing of language servers Sep 04, 2024 3 - Alpha pytest + :pypi:`pytest-lsp` A pytest plugin for end-to-end testing of language servers Nov 23, 2024 3 - Alpha pytest :pypi:`pytest-manual-marker` pytest marker for marking manual tests Aug 04, 2022 3 - Alpha pytest>=7 :pypi:`pytest-mark-count` Get a count of the number of tests marked, unmarked, and unique tests if tests have multiple markers Nov 13, 2024 4 - Beta pytest>=8.0.0 :pypi:`pytest-markdoctest` A pytest plugin to doctest your markdown files Jul 22, 2022 4 - Beta pytest (>=6) :pypi:`pytest-markdown` Test your markdown docs with pytest Jan 15, 2021 4 - Beta pytest (>=6.0.1,<7.0.0) - :pypi:`pytest-markdown-docs` Run markdown code fences through pytest Oct 22, 2024 N/A pytest>=7.0.0 + :pypi:`pytest-markdown-docs` Run markdown code fences through pytest Nov 28, 2024 N/A pytest>=7.0.0 :pypi:`pytest-marker-bugzilla` py.test bugzilla integration plugin, using markers Jan 09, 2020 N/A N/A :pypi:`pytest-markers-presence` A simple plugin to detect missed pytest tags and markers" Oct 30, 2024 4 - Beta pytest>=6.0 :pypi:`pytest-markfiltration` UNKNOWN Nov 08, 2011 3 - Alpha N/A @@ -864,7 +866,7 @@ This list contains 1546 plugins. :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A :pypi:`pytest-metadata` pytest plugin for test session metadata Feb 12, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-metrics` Custom metrics report for pytest Apr 04, 2020 N/A pytest - :pypi:`pytest-mh` Pytest multihost plugin Nov 04, 2024 N/A pytest + :pypi:`pytest-mh` Pytest multihost plugin Nov 28, 2024 N/A pytest :pypi:`pytest-mimesis` Mimesis integration with the pytest test runner Mar 21, 2020 5 - Production/Stable pytest (>=4.2) :pypi:`pytest-minecraft` A pytest plugin for running tests against Minecraft releases Apr 06, 2022 N/A pytest (>=6.0.1) :pypi:`pytest-mini` A plugin to test mp Feb 06, 2023 N/A pytest (>=7.2.0,<8.0.0) @@ -929,7 +931,7 @@ This list contains 1546 plugins. :pypi:`pytest-nginx-iplweb` nginx fixture for pytest - iplweb temporary fork Mar 01, 2019 5 - Production/Stable N/A :pypi:`pytest-ngrok` Jan 20, 2022 3 - Alpha pytest :pypi:`pytest-ngsfixtures` pytest ngs fixtures Sep 06, 2019 2 - Pre-Alpha pytest (>=5.0.0) - :pypi:`pytest-nhsd-apim` Pytest plugin accessing NHSDigital's APIM proxies Sep 06, 2024 N/A pytest<9.0.0,>=8.2.0 + :pypi:`pytest-nhsd-apim` Pytest plugin accessing NHSDigital's APIM proxies Nov 28, 2024 N/A pytest<9.0.0,>=8.2.0 :pypi:`pytest-nice` A pytest plugin that alerts user of failed test cases with screen notifications May 04, 2019 4 - Beta pytest :pypi:`pytest-nice-parametrize` A small snippet for nicer PyTest's Parametrize Apr 17, 2021 5 - Production/Stable N/A :pypi:`pytest_nlcov` Pytest plugin to get the coverage of the new lines (based on git diff) only Aug 05, 2024 N/A N/A @@ -960,7 +962,7 @@ This list contains 1546 plugins. :pypi:`pytest-oof` A Pytest plugin providing structured, programmatic access to a test run's results Dec 11, 2023 4 - Beta N/A :pypi:`pytest-oot` Run object-oriented tests in a simple format Sep 18, 2016 4 - Beta N/A :pypi:`pytest-openfiles` Pytest plugin for detecting inadvertent open file handles Jun 05, 2024 3 - Alpha pytest>=4.6 - :pypi:`pytest-opentelemetry` A pytest plugin for instrumenting test runs via OpenTelemetry Oct 01, 2023 N/A pytest + :pypi:`pytest-opentelemetry` A pytest plugin for instrumenting test runs via OpenTelemetry Nov 22, 2024 N/A pytest :pypi:`pytest-opentmi` pytest plugin for publish results to opentmi Sep 05, 2024 5 - Production/Stable pytest>=5.0 :pypi:`pytest-operator` Fixtures for Operators Sep 28, 2022 N/A pytest :pypi:`pytest-optional` include/exclude values of fixtures in pytest Oct 07, 2015 N/A N/A @@ -1024,9 +1026,9 @@ This list contains 1546 plugins. :pypi:`pytest-platform-markers` Markers for pytest to skip tests on specific platforms Sep 09, 2019 4 - Beta pytest (>=3.6.0) :pypi:`pytest-play` pytest plugin that let you automate actions and assertions with test metrics reporting executing plain YAML files Jun 12, 2019 5 - Production/Stable N/A :pypi:`pytest-playbook` Pytest plugin for reading playbooks. Jan 21, 2021 3 - Alpha pytest (>=6.1.2,<7.0.0) - :pypi:`pytest-playwright` A pytest wrapper with fixtures for Playwright to automate web browsers Sep 06, 2024 N/A pytest<9.0.0,>=6.2.4 + :pypi:`pytest-playwright` A pytest wrapper with fixtures for Playwright to automate web browsers Nov 26, 2024 N/A pytest<9.0.0,>=6.2.4 :pypi:`pytest_playwright_async` ASYNC Pytest plugin for Playwright Sep 28, 2024 N/A N/A - :pypi:`pytest-playwright-asyncio` Aug 29, 2023 N/A N/A + :pypi:`pytest-playwright-asyncio` A pytest wrapper with fixtures for Playwright to automate web browsers Nov 26, 2024 N/A pytest<9.0.0,>=6.2.4 :pypi:`pytest-playwright-enhanced` A pytest plugin for playwright python Mar 24, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-playwrights` A pytest wrapper with fixtures for Playwright to automate web browsers Dec 02, 2021 N/A N/A :pypi:`pytest-playwright-snapshot` A pytest wrapper for snapshot testing with playwright Aug 19, 2021 N/A N/A @@ -1047,6 +1049,7 @@ This list contains 1546 plugins. :pypi:`pytest-poo-fail` Visualize your failed tests with poo Feb 12, 2015 5 - Production/Stable N/A :pypi:`pytest-pook` Pytest plugin for pook Feb 15, 2024 4 - Beta pytest :pypi:`pytest-pop` A pytest plugin to help with testing pop projects May 09, 2023 5 - Production/Stable pytest + :pypi:`pytest-porcochu` Show surprise when tests are passing Nov 28, 2024 5 - Production/Stable N/A :pypi:`pytest-portion` Select a portion of the collected tests Jan 28, 2021 4 - Beta pytest (>=3.5.0) :pypi:`pytest-postgres` Run PostgreSQL in Docker container in Pytest. Mar 22, 2020 N/A pytest :pypi:`pytest-postgresql` Postgresql fixtures and fixture factories for Pytest. Sep 05, 2024 5 - Production/Stable pytest>=6.2 @@ -1060,7 +1063,7 @@ This list contains 1546 plugins. :pypi:`pytest-priority` pytest plugin for add priority for tests Aug 19, 2024 N/A pytest :pypi:`pytest-proceed` Oct 01, 2024 N/A pytest :pypi:`pytest-profiles` pytest plugin for configuration profiles Dec 09, 2021 4 - Beta pytest (>=3.7.0) - :pypi:`pytest-profiling` Profiling plugin for py.test Oct 17, 2024 5 - Production/Stable pytest + :pypi:`pytest-profiling` Profiling plugin for py.test Nov 29, 2024 5 - Production/Stable pytest :pypi:`pytest-progress` pytest plugin for instant test progress status Jun 18, 2024 5 - Production/Stable pytest>=2.7 :pypi:`pytest-prometheus` Report test pass / failures to a Prometheus PushGateway Oct 03, 2017 N/A N/A :pypi:`pytest-prometheus-pushgateway` Pytest report plugin for Zulip Sep 27, 2022 5 - Production/Stable pytest @@ -1083,7 +1086,7 @@ This list contains 1546 plugins. :pypi:`pytest-pydocstyle` pytest plugin to run pydocstyle Oct 09, 2024 3 - Alpha pytest>=7.0 :pypi:`pytest-pylint` pytest plugin to check source code with pylint Oct 06, 2023 5 - Production/Stable pytest >=7.0 :pypi:`pytest-pymysql-autorecord` Record PyMySQL queries and mock with the stored data. Sep 02, 2022 N/A N/A - :pypi:`pytest-pyodide` Pytest plugin for testing applications that use Pyodide Jul 23, 2024 N/A pytest + :pypi:`pytest-pyodide` Pytest plugin for testing applications that use Pyodide Nov 23, 2024 N/A pytest :pypi:`pytest-pypi` Easily test your HTTP library against a local copy of pypi Mar 04, 2018 3 - Alpha N/A :pypi:`pytest-pypom-navigation` Core engine for cookiecutter-qa and pytest-play packages Feb 18, 2019 4 - Beta pytest (>=3.0.7) :pypi:`pytest-pyppeteer` A plugin to run pyppeteer in pytest Apr 28, 2022 N/A pytest (>=6.2.5,<7.0.0) @@ -1133,7 +1136,7 @@ This list contains 1546 plugins. :pypi:`pytest-recording` A pytest plugin that allows you recording of network interactions via VCR.py Jul 09, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-recordings` Provides pytest plugins for reporting request/response traffic, screenshots, and more to ReportPortal Aug 13, 2020 N/A N/A :pypi:`pytest-record-video` 用例执行过程中录制视频 Oct 31, 2024 N/A N/A - :pypi:`pytest-redis` Redis fixtures and fixture factories for Pytest. Jun 19, 2024 5 - Production/Stable pytest>=6.2 + :pypi:`pytest-redis` Redis fixtures and fixture factories for Pytest. Nov 27, 2024 5 - Production/Stable pytest>=6.2 :pypi:`pytest-redislite` Pytest plugin for testing code using Redis Apr 05, 2022 4 - Beta pytest :pypi:`pytest-redmine` Pytest plugin for redmine Mar 19, 2018 1 - Planning N/A :pypi:`pytest-ref` A plugin to store reference files to ease regression testing Nov 23, 2019 4 - Beta pytest (>=3.5.0) @@ -1152,7 +1155,7 @@ This list contains 1546 plugins. :pypi:`pytest-reorder` Reorder tests depending on their paths and names. May 31, 2018 4 - Beta pytest :pypi:`pytest-repeat` pytest plugin for repeating tests Oct 09, 2023 5 - Production/Stable pytest :pypi:`pytest_repeater` py.test plugin for repeating single test multiple times. Feb 09, 2018 1 - Planning N/A - :pypi:`pytest-replay` Saves previous test runs and allow re-execute previous pytest runs to reproduce crashes or flaky tests Sep 03, 2024 5 - Production/Stable pytest + :pypi:`pytest-replay` Saves previous test runs and allow re-execute previous pytest runs to reproduce crashes or flaky tests Nov 29, 2024 5 - Production/Stable pytest :pypi:`pytest-repo-health` A pytest plugin to report on repository standards conformance Apr 17, 2023 3 - Alpha pytest :pypi:`pytest-report` Creates json report that is compatible with atom.io's linter message format May 11, 2016 4 - Beta N/A :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest @@ -1171,6 +1174,7 @@ This list contains 1546 plugins. :pypi:`pytest-requests` A simple plugin to use with pytest Jun 24, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-requestselapsed` collect and show http requests elapsed time Aug 14, 2022 N/A N/A :pypi:`pytest-requests-futures` Pytest Plugin to Mock Requests Futures Jul 06, 2022 5 - Production/Stable pytest + :pypi:`pytest-requirements` pytest plugin for using custom markers to relate tests to requirements and usecases Nov 29, 2024 N/A pytest :pypi:`pytest-requires` A pytest plugin to elegantly skip tests with optional requirements Dec 21, 2021 4 - Beta pytest (>=3.5.0) :pypi:`pytest-reraise` Make multi-threaded pytest test cases fail when they should Sep 20, 2022 5 - Production/Stable pytest (>=4.6) :pypi:`pytest-rerun` Re-run only changed files in specified branch Jul 08, 2019 N/A pytest (>=3.6) @@ -1192,7 +1196,7 @@ This list contains 1546 plugins. :pypi:`pytest-resume` A Pytest plugin to resuming from the last run test Apr 22, 2023 4 - Beta pytest (>=7.0) :pypi:`pytest-rethinkdb` A RethinkDB plugin for pytest. Jul 24, 2016 4 - Beta N/A :pypi:`pytest-retry` Adds the ability to retry flaky tests in CI environments May 14, 2024 N/A pytest>=7.0.0 - :pypi:`pytest-retry-class` A pytest plugin to rerun entire class on failure Mar 25, 2023 N/A pytest (>=5.3) + :pypi:`pytest-retry-class` A pytest plugin to rerun entire class on failure Nov 24, 2024 N/A pytest>=5.3 :pypi:`pytest-reusable-testcases` Apr 28, 2023 N/A N/A :pypi:`pytest-reverse` Pytest plugin to reverse test order. Oct 25, 2024 5 - Production/Stable pytest :pypi:`pytest-rich` Leverage rich for richer test session output Mar 03, 2022 4 - Beta pytest (>=7.0) @@ -1229,7 +1233,7 @@ This list contains 1546 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Nov 19, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Nov 30, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1240,15 +1244,15 @@ This list contains 1546 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Nov 19, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Nov 30, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-send-email` Send pytest execution result email Sep 02, 2024 N/A pytest - :pypi:`pytest-sentry` A pytest plugin to send testrun information to Sentry.io Apr 25, 2024 N/A pytest + :pypi:`pytest-sentry` A pytest plugin to send testrun information to Sentry.io Nov 25, 2024 N/A pytest :pypi:`pytest-sequence-markers` Pytest plugin for sequencing markers for execution of tests May 23, 2023 5 - Production/Stable N/A :pypi:`pytest-server` test server exec cmd Sep 09, 2024 N/A N/A - :pypi:`pytest-server-fixtures` Extensible server fixtures for py.test Oct 17, 2024 5 - Production/Stable pytest + :pypi:`pytest-server-fixtures` Extensible server fixtures for py.test Nov 29, 2024 5 - Production/Stable pytest :pypi:`pytest-serverless` Automatically mocks resources from serverless.yml in pytest using moto. May 09, 2022 4 - Beta N/A :pypi:`pytest-servers` pytest servers Nov 14, 2024 3 - Alpha pytest>=6.2 :pypi:`pytest-service` Aug 06, 2024 5 - Production/Stable pytest>=6.0.0 @@ -1267,7 +1271,7 @@ This list contains 1546 plugins. :pypi:`pytest-sheraf` Versatile ZODB abstraction layer - pytest fixtures Feb 11, 2020 N/A pytest :pypi:`pytest-sherlock` pytest plugin help to find coupled tests Aug 14, 2023 5 - Production/Stable pytest >=3.5.1 :pypi:`pytest-shortcuts` Expand command-line shortcuts listed in pytest configuration Oct 29, 2020 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-shutil` A goodie-bag of unix shell and environment tools for py.test Oct 17, 2024 5 - Production/Stable pytest + :pypi:`pytest-shutil` A goodie-bag of unix shell and environment tools for py.test Nov 29, 2024 5 - Production/Stable pytest :pypi:`pytest-simbind` Pytest plugin to operate with objects generated by Simbind tool. Mar 28, 2024 N/A pytest>=7.0.0 :pypi:`pytest-simplehttpserver` Simple pytest fixture to spin up an HTTP server Jun 24, 2021 4 - Beta N/A :pypi:`pytest-simple-plugin` Simple pytest plugin Nov 27, 2019 N/A N/A @@ -1286,7 +1290,7 @@ This list contains 1546 plugins. :pypi:`pytest-smartcollect` A plugin for collecting tests that touch changed code Oct 04, 2018 N/A pytest (>=3.5.0) :pypi:`pytest-smartcov` Smart coverage plugin for pytest. Sep 30, 2017 3 - Alpha N/A :pypi:`pytest-smell` Automated bad smell detection tool for Pytest Jun 26, 2022 N/A N/A - :pypi:`pytest-smoke` pytest plugin for supporting smoke testing Nov 07, 2024 4 - Beta pytest<9,>=7.0.0 + :pypi:`pytest-smoke` Pytest plugin for smoke testing Nov 27, 2024 4 - Beta pytest<9,>=7.0.0 :pypi:`pytest-smtp` Send email with pytest execution result Feb 20, 2021 N/A pytest :pypi:`pytest-smtp4dev` Plugin for smtp4dev API Jun 27, 2023 5 - Production/Stable N/A :pypi:`pytest-smtpd` An SMTP server for testing built on aiosmtpd May 15, 2023 N/A pytest @@ -1322,7 +1326,7 @@ This list contains 1546 plugins. :pypi:`pytest-split-tests` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Forked from Mark Adams' original project pytest-test-groups. Jul 30, 2021 5 - Production/Stable pytest (>=2.5) :pypi:`pytest-split-tests-tresorit` Feb 22, 2021 1 - Planning N/A :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Oct 28, 2024 N/A pytest<8,>5.4.0 - :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Sep 26, 2024 N/A N/A + :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Nov 24, 2024 N/A N/A :pypi:`pytest-splunk-env` pytest fixtures for interaction with Splunk Enterprise and Splunk Cloud Oct 22, 2020 N/A pytest (>=6.1.1,<7.0.0) :pypi:`pytest-sqitch` sqitch for pytest Apr 06, 2020 4 - Beta N/A :pypi:`pytest-sqlalchemy` pytest plugin with sqlalchemy related fixtures Mar 13, 2018 3 - Alpha N/A @@ -1343,7 +1347,7 @@ This list contains 1546 plugins. :pypi:`pytest-steps` Create step-wise / incremental tests in pytest. Sep 23, 2021 5 - Production/Stable N/A :pypi:`pytest-stepwise` Run a test suite one failing test at a time. Dec 01, 2015 4 - Beta N/A :pypi:`pytest-stf` pytest plugin for openSTF Sep 24, 2024 N/A pytest>=5.0 - :pypi:`pytest-stochastics` pytest plugin that allows selectively running tests several times and accepting \*some\* failures. Oct 31, 2024 N/A pytest<9.0.0,>=8.0.0 + :pypi:`pytest-stochastics` pytest plugin that allows selectively running tests several times and accepting \*some\* failures. Nov 30, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-stoq` A plugin to pytest stoq Feb 09, 2021 4 - Beta N/A :pypi:`pytest-store` Pytest plugin to store values from test runs Sep 04, 2024 3 - Alpha pytest>=7.0.0 :pypi:`pytest-stress` A Pytest plugin that allows you to loop tests for a user defined amount of time. Dec 07, 2019 4 - Beta pytest (>=3.6.0) @@ -1468,6 +1472,7 @@ This list contains 1546 plugins. :pypi:`pytest-tspwplib` A simple plugin to use with tspwplib Jan 08, 2021 4 - Beta pytest (>=3.5.0) :pypi:`pytest-tst` Customize pytest options, output and exit code to make it compatible with tst Apr 27, 2022 N/A pytest (>=5.0.0) :pypi:`pytest-tstcls` Test Class Base Mar 23, 2020 5 - Production/Stable N/A + :pypi:`pytest-tt-ddriven` A simple project that act as a placeholder for project name Nov 29, 2024 N/A N/A :pypi:`pytest-tui` Text User Interface (TUI) and HTML report for Pytest test runs Dec 08, 2023 4 - Beta N/A :pypi:`pytest-tutorials` Mar 11, 2023 N/A N/A :pypi:`pytest-twilio-conversations-client-mock` Aug 02, 2022 N/A N/A @@ -1503,17 +1508,17 @@ This list contains 1546 plugins. :pypi:`pytest-vcrpandas` Test from HTTP interactions to dataframe processed. Jan 12, 2019 4 - Beta pytest :pypi:`pytest-vcs` Sep 22, 2022 4 - Beta N/A :pypi:`pytest-venv` py.test fixture for creating a virtual environment Nov 23, 2023 4 - Beta pytest - :pypi:`pytest-verbose-parametrize` More descriptive output for parametrized py.test tests Oct 17, 2024 5 - Production/Stable pytest + :pypi:`pytest-verbose-parametrize` More descriptive output for parametrized py.test tests Nov 29, 2024 5 - Production/Stable pytest :pypi:`pytest-vimqf` A simple pytest plugin that will shrink pytest output when specified, to fit vim quickfix window. Feb 08, 2021 4 - Beta pytest (>=6.2.2,<7.0.0) - :pypi:`pytest-virtualenv` Virtualenv fixture for py.test Oct 17, 2024 5 - Production/Stable pytest - :pypi:`pytest-visual` Nov 01, 2023 3 - Alpha pytest >=7.0.0 + :pypi:`pytest-virtualenv` Virtualenv fixture for py.test Nov 29, 2024 5 - Production/Stable pytest + :pypi:`pytest-visual` Nov 28, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-vnc` VNC client for Pytest Nov 06, 2023 N/A pytest :pypi:`pytest-voluptuous` Pytest plugin for asserting data against voluptuous schema. Jun 09, 2020 N/A pytest :pypi:`pytest-vscodedebug` A pytest plugin to easily enable debugging tests within Visual Studio Code Dec 04, 2020 4 - Beta N/A :pypi:`pytest-vscode-pycharm-cls` A PyTest helper to enable start remote debugger on test start or failure or when pytest.set_trace is used. Feb 01, 2023 N/A pytest :pypi:`pytest-vtestify` A pytest plugin for visual assertion using SSIM and image comparison. Oct 10, 2024 N/A pytest :pypi:`pytest-vts` pytest plugin for automatic recording of http stubbed tests Jun 05, 2019 N/A pytest (>=2.3) - :pypi:`pytest-vulture` A pytest plugin to checks dead code with vulture Nov 22, 2024 N/A pytest>=7.0.0 + :pypi:`pytest-vulture` A pytest plugin to checks dead code with vulture Nov 25, 2024 N/A pytest>=7.0.0 :pypi:`pytest-vw` pytest-vw makes your failing test cases succeed under CI tools scrutiny Oct 07, 2015 4 - Beta N/A :pypi:`pytest-vyper` Plugin for the vyper smart contract language. May 28, 2020 2 - Pre-Alpha N/A :pypi:`pytest-wa-e2e-plugin` Pytest plugin for testing whatsapp bots with end to end tests Feb 18, 2020 4 - Beta pytest (>=3.5.0) @@ -1528,7 +1533,7 @@ This list contains 1546 plugins. :pypi:`pytest-webstage` Test web apps with pytest Sep 20, 2024 N/A pytest<9.0,>=7.0 :pypi:`pytest-webtest-extras` Pytest plugin to enhance pytest-html and allure reports of webtest projects by adding screenshots, comments and webpage sources. Oct 03, 2024 N/A pytest>=7.0.0 :pypi:`pytest-wetest` Welian API Automation test framework pytest plugin Nov 10, 2018 4 - Beta N/A - :pypi:`pytest-when` Utility which makes mocking more readable and controllable May 28, 2024 N/A pytest>=7.3.1 + :pypi:`pytest-when` Utility which makes mocking more readable and controllable Nov 29, 2024 N/A pytest>=7.3.1 :pypi:`pytest-whirlwind` Testing Tornado. Jun 12, 2020 N/A N/A :pypi:`pytest-wholenodeid` pytest addon for displaying the whole node id for failures Aug 26, 2015 4 - Beta pytest (>=2.0) :pypi:`pytest-win32consoletitle` Pytest progress in console title (Win32 only) Aug 08, 2021 N/A N/A @@ -1711,6 +1716,13 @@ This list contains 1546 plugins. Pytest plugin for testing async python code + :pypi:`pytest-aioboto3` + *last release*: Nov 26, 2024, + *status*: N/A, + *requires*: N/A + + Aioboto3 Pytest with Moto + :pypi:`pytest-aiofiles` *last release*: May 14, 2017, *status*: 5 - Production/Stable, @@ -2398,14 +2410,14 @@ This list contains 1546 plugins. pytest plugin to display BDD info in HTML test report :pypi:`pytest-bdd-ng` - *last release*: Oct 07, 2024, + *last release*: Nov 26, 2024, *status*: 4 - Beta, - *requires*: pytest>=5.0 + *requires*: pytest>=5.2 BDD for pytest :pypi:`pytest-bdd-report` - *last release*: Aug 26, 2024, + *last release*: Nov 27, 2024, *status*: N/A, *requires*: pytest>=7.1.3 @@ -2447,7 +2459,7 @@ This list contains 1546 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Nov 18, 2024, + *last release*: Nov 27, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -2825,7 +2837,7 @@ This list contains 1546 plugins. pytest plugin to capture all warnings and put them in one file of your choice :pypi:`pytest-case` - *last release*: Nov 22, 2024, + *last release*: Nov 25, 2024, *status*: N/A, *requires*: pytest<9.0.0,>=8.3.3 @@ -3091,7 +3103,7 @@ This list contains 1546 plugins. A cleanup plugin for pytest :pypi:`pytest-clerk` - *last release*: Oct 08, 2024, + *last release*: Nov 29, 2024, *status*: N/A, *requires*: pytest<9.0.0,>=8.0.0 @@ -4351,9 +4363,9 @@ This list contains 1546 plugins. Run pytest --doctest-modules with markdown docstrings in code blocks (\`\`\`) :pypi:`pytest-doctestplus` - *last release*: Mar 10, 2024, + *last release*: Nov 25, 2024, *status*: 5 - Production/Stable, - *requires*: pytest >=4.6 + *requires*: pytest>=4.6 Pytest plugin with advanced doctest features. @@ -4890,7 +4902,7 @@ This list contains 1546 plugins. :pypi:`pytest-exasol-itde` - *last release*: Jul 01, 2024, + *last release*: Nov 22, 2024, *status*: N/A, *requires*: pytest<9,>=7 @@ -5393,6 +5405,13 @@ This list contains 1546 plugins. pytest plugin to check FLAKE8 requirements + :pypi:`pytest-flake-detection` + *last release*: Nov 29, 2024, + *status*: 4 - Beta, + *requires*: pytest>=6.2.0 + + Continuously runs your tests to detect flaky tests + :pypi:`pytest-flakefinder` *last release*: Oct 26, 2022, *status*: 4 - Beta, @@ -5996,7 +6015,7 @@ This list contains 1546 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Nov 16, 2024, + *last release*: Nov 29, 2024, *status*: 3 - Alpha, *requires*: pytest==8.3.3 @@ -6136,7 +6155,7 @@ This list contains 1546 plugins. Easily test your HTTP library against a local copy of httpbin :pypi:`pytest-httpdbg` - *last release*: Oct 21, 2024, + *last release*: Nov 23, 2024, *status*: 4 - Beta, *requires*: pytest>=7.0.0 @@ -6171,7 +6190,7 @@ This list contains 1546 plugins. http_testing framework on top of pytest :pypi:`pytest-httpx` - *last release*: Nov 18, 2024, + *last release*: Nov 28, 2024, *status*: 5 - Production/Stable, *requires*: pytest==8.* @@ -6381,7 +6400,7 @@ This list contains 1546 plugins. Inmanta tests package :pypi:`pytest-inmanta-lsm` - *last release*: Oct 29, 2024, + *last release*: Nov 26, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -6402,7 +6421,7 @@ This list contains 1546 plugins. A simple image diff plugin for pytest :pypi:`pytest-in-robotframework` - *last release*: Mar 02, 2024, + *last release*: Nov 23, 2024, *status*: N/A, *requires*: pytest @@ -6514,11 +6533,11 @@ This list contains 1546 plugins. :pypi:`pytest-isolate` - *last release*: Feb 20, 2023, + *last release*: Nov 24, 2024, *status*: 4 - Beta, *requires*: pytest - + Run pytest tests in isolated subprocesses :pypi:`pytest-isolate-mpi` *last release*: Sep 18, 2024, @@ -6983,7 +7002,7 @@ This list contains 1546 plugins. Pytest plugin for organizing tests. :pypi:`pytest-listener` - *last release*: Oct 17, 2024, + *last release*: Nov 29, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -7109,7 +7128,7 @@ This list contains 1546 plugins. :pypi:`pytest-logikal` - *last release*: Nov 09, 2024, + *last release*: Nov 27, 2024, *status*: 5 - Production/Stable, *requires*: pytest==8.3.3 @@ -7144,7 +7163,7 @@ This list contains 1546 plugins. pytest plugin for looping tests :pypi:`pytest-lsp` - *last release*: Sep 04, 2024, + *last release*: Nov 23, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -7179,7 +7198,7 @@ This list contains 1546 plugins. Test your markdown docs with pytest :pypi:`pytest-markdown-docs` - *last release*: Oct 22, 2024, + *last release*: Nov 28, 2024, *status*: N/A, *requires*: pytest>=7.0.0 @@ -7396,7 +7415,7 @@ This list contains 1546 plugins. Custom metrics report for pytest :pypi:`pytest-mh` - *last release*: Nov 04, 2024, + *last release*: Nov 28, 2024, *status*: N/A, *requires*: pytest @@ -7851,7 +7870,7 @@ This list contains 1546 plugins. pytest ngs fixtures :pypi:`pytest-nhsd-apim` - *last release*: Sep 06, 2024, + *last release*: Nov 28, 2024, *status*: N/A, *requires*: pytest<9.0.0,>=8.2.0 @@ -8068,7 +8087,7 @@ This list contains 1546 plugins. Pytest plugin for detecting inadvertent open file handles :pypi:`pytest-opentelemetry` - *last release*: Oct 01, 2023, + *last release*: Nov 22, 2024, *status*: N/A, *requires*: pytest @@ -8516,7 +8535,7 @@ This list contains 1546 plugins. Pytest plugin for reading playbooks. :pypi:`pytest-playwright` - *last release*: Sep 06, 2024, + *last release*: Nov 26, 2024, *status*: N/A, *requires*: pytest<9.0.0,>=6.2.4 @@ -8530,11 +8549,11 @@ This list contains 1546 plugins. ASYNC Pytest plugin for Playwright :pypi:`pytest-playwright-asyncio` - *last release*: Aug 29, 2023, + *last release*: Nov 26, 2024, *status*: N/A, - *requires*: N/A - + *requires*: pytest<9.0.0,>=6.2.4 + A pytest wrapper with fixtures for Playwright to automate web browsers :pypi:`pytest-playwright-enhanced` *last release*: Mar 24, 2024, @@ -8676,6 +8695,13 @@ This list contains 1546 plugins. A pytest plugin to help with testing pop projects + :pypi:`pytest-porcochu` + *last release*: Nov 28, 2024, + *status*: 5 - Production/Stable, + *requires*: N/A + + Show surprise when tests are passing + :pypi:`pytest-portion` *last release*: Jan 28, 2021, *status*: 4 - Beta, @@ -8768,7 +8794,7 @@ This list contains 1546 plugins. pytest plugin for configuration profiles :pypi:`pytest-profiling` - *last release*: Oct 17, 2024, + *last release*: Nov 29, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -8929,7 +8955,7 @@ This list contains 1546 plugins. Record PyMySQL queries and mock with the stored data. :pypi:`pytest-pyodide` - *last release*: Jul 23, 2024, + *last release*: Nov 23, 2024, *status*: N/A, *requires*: pytest @@ -9279,7 +9305,7 @@ This list contains 1546 plugins. 用例执行过程中录制视频 :pypi:`pytest-redis` - *last release*: Jun 19, 2024, + *last release*: Nov 27, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=6.2 @@ -9412,7 +9438,7 @@ This list contains 1546 plugins. py.test plugin for repeating single test multiple times. :pypi:`pytest-replay` - *last release*: Sep 03, 2024, + *last release*: Nov 29, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -9544,6 +9570,13 @@ This list contains 1546 plugins. Pytest Plugin to Mock Requests Futures + :pypi:`pytest-requirements` + *last release*: Nov 29, 2024, + *status*: N/A, + *requires*: pytest + + pytest plugin for using custom markers to relate tests to requirements and usecases + :pypi:`pytest-requires` *last release*: Dec 21, 2021, *status*: 4 - Beta, @@ -9692,9 +9725,9 @@ This list contains 1546 plugins. Adds the ability to retry flaky tests in CI environments :pypi:`pytest-retry-class` - *last release*: Mar 25, 2023, + *last release*: Nov 24, 2024, *status*: N/A, - *requires*: pytest (>=5.3) + *requires*: pytest>=5.3 A pytest plugin to rerun entire class on failure @@ -9951,7 +9984,7 @@ This list contains 1546 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Nov 19, 2024, + *last release*: Nov 30, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10028,7 +10061,7 @@ This list contains 1546 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Nov 19, 2024, + *last release*: Nov 30, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10063,7 +10096,7 @@ This list contains 1546 plugins. Send pytest execution result email :pypi:`pytest-sentry` - *last release*: Apr 25, 2024, + *last release*: Nov 25, 2024, *status*: N/A, *requires*: pytest @@ -10084,7 +10117,7 @@ This list contains 1546 plugins. test server exec cmd :pypi:`pytest-server-fixtures` - *last release*: Oct 17, 2024, + *last release*: Nov 29, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -10217,7 +10250,7 @@ This list contains 1546 plugins. Expand command-line shortcuts listed in pytest configuration :pypi:`pytest-shutil` - *last release*: Oct 17, 2024, + *last release*: Nov 29, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -10350,11 +10383,11 @@ This list contains 1546 plugins. Automated bad smell detection tool for Pytest :pypi:`pytest-smoke` - *last release*: Nov 07, 2024, + *last release*: Nov 27, 2024, *status*: 4 - Beta, *requires*: pytest<9,>=7.0.0 - pytest plugin for supporting smoke testing + Pytest plugin for smoke testing :pypi:`pytest-smtp` *last release*: Feb 20, 2021, @@ -10602,7 +10635,7 @@ This list contains 1546 plugins. A Dynamic test tool for Splunk Apps and Add-ons :pypi:`pytest-splunk-addon-ui-smartx` - *last release*: Sep 26, 2024, + *last release*: Nov 24, 2024, *status*: N/A, *requires*: N/A @@ -10749,7 +10782,7 @@ This list contains 1546 plugins. pytest plugin for openSTF :pypi:`pytest-stochastics` - *last release*: Oct 31, 2024, + *last release*: Nov 30, 2024, *status*: N/A, *requires*: pytest<9.0.0,>=8.0.0 @@ -11623,6 +11656,13 @@ This list contains 1546 plugins. Test Class Base + :pypi:`pytest-tt-ddriven` + *last release*: Nov 29, 2024, + *status*: N/A, + *requires*: N/A + + A simple project that act as a placeholder for project name + :pypi:`pytest-tui` *last release*: Dec 08, 2023, *status*: 4 - Beta, @@ -11869,7 +11909,7 @@ This list contains 1546 plugins. py.test fixture for creating a virtual environment :pypi:`pytest-verbose-parametrize` - *last release*: Oct 17, 2024, + *last release*: Nov 29, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -11883,16 +11923,16 @@ This list contains 1546 plugins. A simple pytest plugin that will shrink pytest output when specified, to fit vim quickfix window. :pypi:`pytest-virtualenv` - *last release*: Oct 17, 2024, + *last release*: Nov 29, 2024, *status*: 5 - Production/Stable, *requires*: pytest Virtualenv fixture for py.test :pypi:`pytest-visual` - *last release*: Nov 01, 2023, - *status*: 3 - Alpha, - *requires*: pytest >=7.0.0 + *last release*: Nov 28, 2024, + *status*: 4 - Beta, + *requires*: pytest>=7.0.0 @@ -11939,7 +11979,7 @@ This list contains 1546 plugins. pytest plugin for automatic recording of http stubbed tests :pypi:`pytest-vulture` - *last release*: Nov 22, 2024, + *last release*: Nov 25, 2024, *status*: N/A, *requires*: pytest>=7.0.0 @@ -12044,7 +12084,7 @@ This list contains 1546 plugins. Welian API Automation test framework pytest plugin :pypi:`pytest-when` - *last release*: May 28, 2024, + *last release*: Nov 29, 2024, *status*: N/A, *requires*: pytest>=7.3.1 From 9892455da544e1d444000b39214578facf95ca37 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 1 Dec 2024 07:52:29 -0300 Subject: [PATCH 200/445] Remove 'pip' command hint from release announcement While of course `pip` is still the most used tool to install packages, currently there are a lot of alternatives (`poetry`, `uv`, etc), so it feels a bit dated to suggest `pip install --upgrade` directly on the release announcement. Also, all the other release notes do not mention `pip` too, so it makes sense to remove it from the patch release announcement. --- scripts/release.patch.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/release.patch.rst b/scripts/release.patch.rst index 59fbe50ce0e..120cae51702 100644 --- a/scripts/release.patch.rst +++ b/scripts/release.patch.rst @@ -3,9 +3,7 @@ pytest-{version} pytest {version} has just been released to PyPI. -This is a bug-fix release, being a drop-in replacement. To upgrade:: - - pip install --upgrade pytest +This is a bug-fix release, being a drop-in replacement. The full changelog is available at https://docs.pytest.org/en/stable/changelog.html. From b2dce69664759943b77ab0926ab5ab7f4f605136 Mon Sep 17 00:00:00 2001 From: Daara <3807987+daara-s@users.noreply.github.com> Date: Sun, 1 Dec 2024 11:08:33 +0000 Subject: [PATCH 201/445] Warn `pytest.mark.usefixtures()` is used without arguments (#13008) Closes #12426 Closes #12439 --------- Co-authored-by: Jiajun Xu Co-authored-by: Bruno Oliveira --- AUTHORS | 2 ++ changelog/12426.improvement.rst | 1 + src/_pytest/fixtures.py | 9 ++++++++- testing/plugins_integration/pytest.ini | 1 + testing/python/fixtures.py | 17 +++++++++++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 changelog/12426.improvement.rst diff --git a/AUTHORS b/AUTHORS index 303d04133cb..6399461ee59 100644 --- a/AUTHORS +++ b/AUTHORS @@ -103,6 +103,7 @@ Cornelius Riemenschneider CrazyMerlyn Cristian Vera Cyrus Maden +Daara Shaw Damian Skrzypczak Daniel Grana Daniel Hahler @@ -209,6 +210,7 @@ Jeff Rackauckas Jeff Widman Jenni Rinker Jens Tröger +Jiajun Xu John Eddie Ayson John Litborn John Towler diff --git a/changelog/12426.improvement.rst b/changelog/12426.improvement.rst new file mode 100644 index 00000000000..0da1f838aea --- /dev/null +++ b/changelog/12426.improvement.rst @@ -0,0 +1 @@ +A warning is now issued when :ref:`pytest.mark.usefixtures ref` is used without specifying any fixtures. Previously, empty usefixtures markers were silently ignored. diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 76c4b919aff..fc6541c1404 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -71,6 +71,7 @@ from _pytest.scope import HIGH_SCOPES from _pytest.scope import Scope from _pytest.warning_types import PytestRemovedIn9Warning +from _pytest.warning_types import PytestWarning if sys.version_info < (3, 11): @@ -1562,7 +1563,13 @@ def _getautousenames(self, node: nodes.Node) -> Iterator[str]: def _getusefixturesnames(self, node: nodes.Item) -> Iterator[str]: """Return the names of usefixtures fixtures applicable to node.""" - for mark in node.iter_markers(name="usefixtures"): + for marker_node, mark in node.iter_markers_with_node(name="usefixtures"): + if not mark.args: + marker_node.warn( + PytestWarning( + f"usefixtures() in {node.nodeid} without arguments has no effect" + ) + ) yield from mark.args def getfixtureclosure( diff --git a/testing/plugins_integration/pytest.ini b/testing/plugins_integration/pytest.ini index 3bacdef62ab..86058fbbac8 100644 --- a/testing/plugins_integration/pytest.ini +++ b/testing/plugins_integration/pytest.ini @@ -3,4 +3,5 @@ addopts = --strict-markers asyncio_mode = strict filterwarnings = error::pytest.PytestWarning + ignore:usefixtures.* without arguments has no effect:pytest.PytestWarning ignore:.*.fspath is deprecated and will be replaced by .*.path.*:pytest.PytestDeprecationWarning diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index c939b221f22..cac00ab5401 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -1435,6 +1435,23 @@ def test_two(self): reprec = pytester.inline_run() reprec.assertoutcome(passed=2) + def test_empty_usefixtures_marker(self, pytester: Pytester) -> None: + """Empty usefixtures() marker issues a warning (#12439).""" + pytester.makepyfile( + """ + import pytest + + @pytest.mark.usefixtures() + def test_one(): + assert 1 == 1 + """ + ) + result = pytester.runpytest() + result.stdout.fnmatch_lines( + "*PytestWarning: usefixtures() in test_empty_usefixtures_marker.py::test_one" + " without arguments has no effect" + ) + def test_usefixtures_ini(self, pytester: Pytester) -> None: pytester.makeini( """ From df7bfde99bb998912159d274367b816fbfe5cfec Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 1 Dec 2024 08:11:21 -0300 Subject: [PATCH 202/445] Also mention to announce releases on BlueSky --- RELEASING.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASING.rst b/RELEASING.rst index 030a5c8652f..52910de0002 100644 --- a/RELEASING.rst +++ b/RELEASING.rst @@ -168,4 +168,4 @@ Both automatic and manual processes described above follow the same steps from t * python-announce-list@python.org (all releases) * testing-in-python@lists.idyll.org (only major/minor releases) - And announce it on `Twitter `_ with the ``#pytest`` hashtag. + And announce it on `Twitter `_ and `BlueSky `_ with the ``#pytest`` hashtag. From 6ccb5e75d6dd5494e6ef725cd7a41d3b81116585 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 1 Dec 2024 09:03:24 -0300 Subject: [PATCH 203/445] Fix collection and simplify tests We should not collect classes at the module level when the config is set. Doing so is not only the correct thing, as we will not collect the class, but also lets us avoid having the same logic at the Class collector (as it will not be collected at all now). --- src/_pytest/python.py | 21 +- testing/test_collect_imported_tests.py | 103 ++++++++ testing/test_collect_imports.py | 317 ------------------------- 3 files changed, 108 insertions(+), 333 deletions(-) create mode 100644 testing/test_collect_imported_tests.py delete mode 100644 testing/test_collect_imports.py diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 9c00252c5f8..6e7360c5b7d 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -405,6 +405,7 @@ def collect(self) -> Iterable[nodes.Item | nodes.Collector]: # __dict__ is definition ordered. seen: set[str] = set() dict_values: list[list[nodes.Item | nodes.Collector]] = [] + collect_imported_tests = self.session.config.getini("collect_imported_tests") ihook = self.ihook for dic in dicts: values: list[nodes.Item | nodes.Collector] = [] @@ -417,12 +418,10 @@ def collect(self) -> Iterable[nodes.Item | nodes.Collector]: continue seen.add(name) - if not self.session.config.getini("collect_imported_tests"): - # Do not collect imported functions - if inspect.isfunction(obj) and isinstance(self, Module): - fn_defined_at = obj.__module__ - in_module = self._getobj().__name__ - if fn_defined_at != in_module: + if not collect_imported_tests and isinstance(self, Module): + # Do not collect functions and classes from other modules. + if inspect.isfunction(obj) or inspect.isclass(obj): + if obj.__module__ != self._getobj().__name__: continue res = ihook.pytest_pycollect_makeitem( @@ -750,16 +749,6 @@ def newinstance(self): return self.obj() def collect(self) -> Iterable[nodes.Item | nodes.Collector]: - if not self.config.getini("collect_imported_tests"): - # This entire branch will discard (not collect) a class - # if it is imported (defined in a different module) - if isinstance(self, Class) and isinstance(self.parent, Module): - if inspect.isclass(self._getobj()): - class_defined_at = self._getobj().__module__ - in_module = self.parent._getobj().__name__ - if class_defined_at != in_module: - return [] - if not safe_getattr(self.obj, "__test__", True): return [] if hasinit(self.obj): diff --git a/testing/test_collect_imported_tests.py b/testing/test_collect_imported_tests.py new file mode 100644 index 00000000000..4b264ce6069 --- /dev/null +++ b/testing/test_collect_imported_tests.py @@ -0,0 +1,103 @@ +"""Tests for the `collect_imported_tests` configuration value.""" + +from __future__ import annotations + +import textwrap + +from _pytest.pytester import Pytester +import pytest + + +def setup_import_class_test(pytester: Pytester) -> None: + src_dir = pytester.mkdir("src") + tests_dir = pytester.mkdir("tests") + src_file = src_dir / "foo.py" + + src_file.write_text( + textwrap.dedent("""\ + class Testament: + def test_collections(self): + pass + + def test_testament(): pass + """), + encoding="utf-8", + ) + + test_file = tests_dir / "foo_test.py" + test_file.write_text( + textwrap.dedent("""\ + from foo import Testament, test_testament + + class TestDomain: + def test(self): + testament = Testament() + assert testament + """), + encoding="utf-8", + ) + + pytester.syspathinsert(src_dir) + + +def test_collect_imports_disabled(pytester: Pytester) -> None: + """ + When collect_imported_tests is disabled, only objects in the + test modules are collected as tests, so the imported names (`Testament` and `test_testament`) + are not collected. + """ + pytester.makeini( + """ + [pytest] + testpaths = "tests" + collect_imported_tests = false + """ + ) + + setup_import_class_test(pytester) + result = pytester.runpytest("-v") + result.stdout.fnmatch_lines( + [ + "tests/foo_test.py::TestDomain::test PASSED*", + ] + ) + + # Ensure that the hooks were only called for the collected item. + reprec = result.reprec # type:ignore[attr-defined] + reports = reprec.getreports("pytest_collectreport") + [modified] = reprec.getcalls("pytest_collection_modifyitems") + [item_collected] = reprec.getcalls("pytest_itemcollected") + + assert [x.nodeid for x in reports] == [ + "", + "tests/foo_test.py::TestDomain", + "tests/foo_test.py", + "tests", + ] + assert [x.nodeid for x in modified.items] == ["tests/foo_test.py::TestDomain::test"] + assert item_collected.item.nodeid == "tests/foo_test.py::TestDomain::test" + + +@pytest.mark.parametrize("configure_ini", [False, True]) +def test_collect_imports_enabled(pytester: Pytester, configure_ini: bool) -> None: + """ + When collect_imported_tests is enabled (the default), all names in the + test modules are collected as tests. + """ + if configure_ini: + pytester.makeini( + """ + [pytest] + collect_imported_tests = true + """ + ) + + setup_import_class_test(pytester) + result = pytester.runpytest("-v") + result.stdout.fnmatch_lines( + [ + "tests/foo_test.py::Testament::test_collections PASSED*", + "tests/foo_test.py::test_testament PASSED*", + "tests/foo_test.py::TestDomain::test PASSED*", + ] + ) diff --git a/testing/test_collect_imports.py b/testing/test_collect_imports.py deleted file mode 100644 index 1c56c9155e5..00000000000 --- a/testing/test_collect_imports.py +++ /dev/null @@ -1,317 +0,0 @@ -from __future__ import annotations - -import textwrap -from typing import Any - -from _pytest.fixtures import FixtureRequest -from _pytest.main import Session -from _pytest.pytester import Pytester -from _pytest.pytester import RecordedHookCall -from _pytest.pytester import RunResult -from _pytest.reports import CollectReport -import pytest - - -# Start of tests for classes - - -def run_import_class_test( - pytester: Pytester, passed: int = 0, errors: int = 0 -) -> RunResult: - src_dir = pytester.mkdir("src") - tests_dir = pytester.mkdir("tests") - src_file = src_dir / "foo.py" - - src_file.write_text( - textwrap.dedent("""\ - class Testament(object): - def __init__(self): - super().__init__() - self.collections = ["stamp", "coin"] - - def personal_property(self): - return [f"my {x} collection" for x in self.collections] - """), - encoding="utf-8", - ) - - test_file = tests_dir / "foo_test.py" - test_file.write_text( - textwrap.dedent("""\ - import sys - import os - - current_file = os.path.abspath(__file__) - current_dir = os.path.dirname(current_file) - parent_dir = os.path.abspath(os.path.join(current_dir, '..')) - sys.path.append(parent_dir) - - from src.foo import Testament - - class TestDomain: - def test_testament(self): - testament = Testament() - assert testament.personal_property() - """), - encoding="utf-8", - ) - - result = pytester.runpytest() - result.assert_outcomes(passed=passed, errors=errors) - return result - - -def test_collect_imports_disabled(pytester: Pytester) -> None: - pytester.makeini(""" - [pytest] - testpaths = "tests" - collect_imported_tests = false - """) - - run_import_class_test(pytester, passed=1) - - # Verify that the state of hooks - reprec = pytester.inline_run() - reports = reprec.getreports("pytest_collectreport") - modified = reprec.getcalls("pytest_collection_modifyitems") - items_collected = reprec.getcalls("pytest_itemcollected") - - assert len(reports) == 5 - assert len(modified) == 1 - assert len(items_collected) == 1 - for x in items_collected: - assert x.item._getobj().__name__ == "test_testament" - - -def test_collect_imports_default(pytester: Pytester) -> None: - run_import_class_test(pytester, errors=1) - - -def test_collect_imports_enabled(pytester: Pytester) -> None: - pytester.makeini(""" - [pytest] - collect_imported_tests = true - """) - - run_import_class_test(pytester, errors=1) - - -# End of tests for classes -################################# -# Start of tests for functions - - -def run_import_functions_test( - pytester: Pytester, passed: int, errors: int, failed: int -) -> RunResult: - # Note that these "tests" should _not_ be treated as tests if `collect_imported_tests = false` - # They are normal functions in that case, that happens to have test_* or *_test in the name. - # Thus should _not_ be collected! - pytester.makepyfile( - **{ - "src/foo.py": textwrap.dedent( - """\ - def test_function(): - some_random_computation = 5 - return some_random_computation - - def test_bar(): - pass - """ - ) - } - ) - - # Inferred from the comment above, this means that there is _only_ one actual test - # which should result in only 1 passing test being ran. - pytester.makepyfile( - **{ - "tests/foo_test.py": textwrap.dedent( - """\ - import sys - import os - - current_file = os.path.abspath(__file__) - current_dir = os.path.dirname(current_file) - parent_dir = os.path.abspath(os.path.join(current_dir, '..')) - sys.path.append(parent_dir) - - from src.foo import * - - class TestDomain: - def test_important(self): - res = test_function() - if res == 5: - pass - """ - ) - } - ) - - result = pytester.runpytest() - result.assert_outcomes(passed=passed, errors=errors, failed=failed) - return result - - -def test_collect_function_imports_enabled(pytester: Pytester) -> None: - pytester.makeini(""" - [pytest] - testpaths = "tests" - collect_imported_tests = true - """) - - run_import_functions_test(pytester, passed=2, errors=0, failed=1) - reprec = pytester.inline_run() - items_collected = reprec.getcalls("pytest_itemcollected") - # Recall that the default is `collect_imported_tests = true`. - # Which means that the normal functions are now interpreted as - # valid tests and `test_function()` will fail. - assert len(items_collected) == 3 - for x in items_collected: - assert x.item._getobj().__name__ in [ - "test_important", - "test_bar", - "test_function", - ] - - -def test_behaviour_without_testpaths_set_and_false(pytester: Pytester) -> None: - # Make sure `collect_imported_tests` has no dependence on `testpaths` - pytester.makeini(""" - [pytest] - collect_imported_tests = false - """) - - run_import_functions_test(pytester, passed=1, errors=0, failed=0) - reprec = pytester.inline_run() - items_collected = reprec.getcalls("pytest_itemcollected") - assert len(items_collected) == 1 - for x in items_collected: - assert x.item._getobj().__name__ == "test_important" - - -def test_behaviour_without_testpaths_set_and_true(pytester: Pytester) -> None: - # Make sure `collect_imported_tests` has no dependence on `testpaths` - pytester.makeini(""" - [pytest] - collect_imported_tests = true - """) - - run_import_functions_test(pytester, passed=2, errors=0, failed=1) - reprec = pytester.inline_run() - items_collected = reprec.getcalls("pytest_itemcollected") - assert len(items_collected) == 3 - - -class TestHookBehaviour: - collect_outcomes: dict[str, Any] = {} - - @pytest.mark.parametrize("step", [1, 2, 3]) - def test_hook_behaviour(self, pytester: Pytester, step: int) -> None: - if step == 1: - self._test_hook_default_behaviour(pytester) - elif step == 2: - self._test_hook_behaviour_when_collect_off(pytester) - elif step == 3: - self._test_hook_behaviour() - - @pytest.fixture(scope="class", autouse=True) - def setup_collect_outcomes(self, request: FixtureRequest) -> None: - request.cls.collect_outcomes = {} - - def _test_hook_default_behaviour(self, pytester: Pytester) -> None: - pytester.makepyfile( - **{ - "tests/foo_test.py": textwrap.dedent( - """\ - class TestDomain: - def test_important(self): - pass - """ - ) - } - ) - - result = pytester.runpytest() - result.assert_outcomes(passed=1) - reprec = pytester.inline_run() - reports = reprec.getreports("pytest_collectreport") - modified = reprec.getcalls("pytest_collection_modifyitems") - items_collected = reprec.getcalls("pytest_itemcollected") - - self.collect_outcomes["default"] = { - "result": result.parseoutcomes(), - "modified": modified, - "items_collected": items_collected, - "reports": reports, - } - - def _test_hook_behaviour_when_collect_off(self, pytester: Pytester) -> None: - pytester.makeini(""" - [pytest] - collect_imported_tests = false - """) - res = run_import_functions_test(pytester, passed=1, errors=0, failed=0) - reprec = pytester.inline_run() - reports = reprec.getreports("pytest_collectreport") - modified = reprec.getcalls("pytest_collection_modifyitems") - items_collected = reprec.getcalls("pytest_itemcollected") - - self.collect_outcomes["collect_off"] = { - "result": res.parseoutcomes(), - "modified": modified, - "items_collected": items_collected, - "reports": reports, - } - - def _test_hook_behaviour(self) -> None: - default = self.collect_outcomes["default"] - collect_off = self.collect_outcomes["collect_off"] - - # Check that the two tests above did indeed result in the same outcome. - assert default["result"] == collect_off["result"] - - assert len(default["modified"]) == len(collect_off["modified"]) == 1 - - def_modified_record: RecordedHookCall = default["modified"][0] - off_modified_record: RecordedHookCall = collect_off["modified"][0] - def_sess: Session = def_modified_record.__dict__["session"] - off_sess: Session = off_modified_record.__dict__["session"] - - assert def_sess.exitstatus == off_sess.exitstatus - assert def_sess.testsfailed == off_sess.testsfailed - assert def_sess.testscollected == off_sess.testscollected - - def_items = def_modified_record.__dict__["items"] - off_items = off_modified_record.__dict__["items"] - assert len(def_items) == len(off_items) == 1 - assert def_items[0].name == off_items[0].name - - assert ( - len(default["items_collected"]) == len(collect_off["items_collected"]) == 1 - ) - - # Check if the same tests got collected - def_items_record: RecordedHookCall = default["items_collected"][0] - off_items_record: RecordedHookCall = collect_off["items_collected"][0] - def_items = def_items_record.__dict__["item"] - off_items = off_items_record.__dict__["item"] - assert def_items.name == off_items.name - - def compare_report(r1: CollectReport, r2: CollectReport) -> None: - assert r1.result[0].name == r2.result[0].name - assert len(r1.result) == len(r2.result) - assert r1.outcome == r2.outcome - - # Function test_important - compare_report(default["reports"][1], collect_off["reports"][2]) - # Class TestDomain - compare_report(default["reports"][2], collect_off["reports"][3]) - # Module foo_test.py - compare_report(default["reports"][3], collect_off["reports"][4]) - - # + 1 since src dir is collected - assert len(default["reports"]) + 1 == len(collect_off["reports"]) - - # Two Dirs will be collected, src and test. - assert len(collect_off["reports"][5].result) == 2 From e2ec64e0374d31e64a59a2b12e4d35de062f07a2 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 1 Dec 2024 09:24:40 -0300 Subject: [PATCH 204/445] Improve docs --- changelog/12749.feature.rst | 20 ++++++++++++++++++-- doc/en/reference/reference.rst | 22 +++++++++++++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/changelog/12749.feature.rst b/changelog/12749.feature.rst index cda0db6c930..c3b7ca5d321 100644 --- a/changelog/12749.feature.rst +++ b/changelog/12749.feature.rst @@ -1,5 +1,21 @@ -New :confval:`collect_imported_tests`: when enabled (the default) pytest will collect classes/functions in test modules even if they are imported from another file. +pytest traditionally collects classes/functions in the test module namespace even if they are imported from another file. -Setting this to False will make pytest collect classes/functions from test files only if they are defined in that file (as opposed to imported there). +For example: + +.. code-block:: python + + # contents of src/domain.py + class Testament: ... + + + # contents of tests/test_testament.py + from domain import Testament + + + def test_testament(): ... + +In this scenario with the default options, pytest will collect the class `Testament` from `tests/test_testament.py` because it starts with `Test`, even though in this case it is a production class being imported in the test module namespace. + +This behavior can now be prevented by setting the new :confval:`collect_imported_tests` configuration option to ``false``, which will make pytest collect classes/functions from test files **only** if they are defined in that file. -- by :user:`FreerGit` diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 53f9470f756..1e550a115c8 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1306,7 +1306,7 @@ passed multiple times. The expected format is ``name=value``. For example:: .. versionadded:: 8.4 Setting this to ``false`` will make pytest collect classes/functions from test - files only if they are defined in that file (as opposed to imported there). + files **only** if they are defined in that file (as opposed to imported there). .. code-block:: ini @@ -1315,6 +1315,26 @@ passed multiple times. The expected format is ``name=value``. For example:: Default: ``true`` + pytest traditionally collects classes/functions in the test module namespace even if they are imported from another file. + + For example: + + .. code-block:: python + + # contents of src/domain.py + class Testament: ... + + + # contents of tests/test_testament.py + from domain import Testament + + + def test_testament(): ... + + In this scenario, with the default options, pytest will collect the class `Testament` from `tests/test_testament.py` because it starts with `Test`, even though in this case it is a production class being imported in the test module namespace. + + Set ``collected_imported_tests`` to ``false`` in the configuration file prevents that. + .. confval:: consider_namespace_packages Controls if pytest should attempt to identify `namespace packages `__ From 43865ed1a9642596007c382d212da460e4cdfedb Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 1 Dec 2024 09:30:33 -0300 Subject: [PATCH 205/445] Pass tests directory explicitly --- testing/test_collect_imported_tests.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/testing/test_collect_imported_tests.py b/testing/test_collect_imported_tests.py index 4b264ce6069..158d9342b41 100644 --- a/testing/test_collect_imported_tests.py +++ b/testing/test_collect_imported_tests.py @@ -49,13 +49,12 @@ def test_collect_imports_disabled(pytester: Pytester) -> None: pytester.makeini( """ [pytest] - testpaths = "tests" collect_imported_tests = false """ ) setup_import_class_test(pytester) - result = pytester.runpytest("-v") + result = pytester.runpytest("-v", "tests") result.stdout.fnmatch_lines( [ "tests/foo_test.py::TestDomain::test PASSED*", @@ -93,7 +92,7 @@ def test_collect_imports_enabled(pytester: Pytester, configure_ini: bool) -> Non ) setup_import_class_test(pytester) - result = pytester.runpytest("-v") + result = pytester.runpytest("-v", "tests") result.stdout.fnmatch_lines( [ "tests/foo_test.py::Testament::test_collections PASSED*", From d2327d9deb4b6f54104039817540951b5deced7b Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 1 Dec 2024 09:31:11 -0300 Subject: [PATCH 206/445] Rename test helper --- testing/test_collect_imported_tests.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testing/test_collect_imported_tests.py b/testing/test_collect_imported_tests.py index 158d9342b41..28b92e17f6f 100644 --- a/testing/test_collect_imported_tests.py +++ b/testing/test_collect_imported_tests.py @@ -8,7 +8,7 @@ import pytest -def setup_import_class_test(pytester: Pytester) -> None: +def setup_files(pytester: Pytester) -> None: src_dir = pytester.mkdir("src") tests_dir = pytester.mkdir("tests") src_file = src_dir / "foo.py" @@ -53,7 +53,7 @@ def test_collect_imports_disabled(pytester: Pytester) -> None: """ ) - setup_import_class_test(pytester) + setup_files(pytester) result = pytester.runpytest("-v", "tests") result.stdout.fnmatch_lines( [ @@ -91,7 +91,7 @@ def test_collect_imports_enabled(pytester: Pytester, configure_ini: bool) -> Non """ ) - setup_import_class_test(pytester) + setup_files(pytester) result = pytester.runpytest("-v", "tests") result.stdout.fnmatch_lines( [ From ea1a79a93a353223cd8dcb039e45d10ae20bc168 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 4 Dec 2024 21:19:49 +0000 Subject: [PATCH 207/445] threadexception enhancements (#13016) --- changelog/13016.improvement.rst | 9 ++ src/_pytest/threadexception.py | 236 ++++++++++++++++++---------- src/_pytest/unraisableexception.py | 6 +- testing/test_threadexception.py | 131 ++++++++++++++- testing/test_unraisableexception.py | 36 +++++ 5 files changed, 328 insertions(+), 90 deletions(-) create mode 100644 changelog/13016.improvement.rst diff --git a/changelog/13016.improvement.rst b/changelog/13016.improvement.rst new file mode 100644 index 00000000000..22642fc6f4f --- /dev/null +++ b/changelog/13016.improvement.rst @@ -0,0 +1,9 @@ +A number of :ref:`threadexception ` enhancements: + +* Set the excepthook as early as possible and unset it as late as possible, to collect the most possible number of unhandled exceptions from threads. +* join threads for 1 second just before unsetting the excepthook, to collect any straggling exceptions +* Collect multiple thread exceptions per test phase. +* Report the :mod:`tracemalloc` allocation traceback (if available). +* Avoid using a generator based hook to allow handling :class:`StopIteration` in test failures. +* Report the thread exception as the cause of the :class:`pytest.PytestUnhandledThreadExceptionWarning` exception if raised. +* Extract the ``name`` of the thread object in the excepthook which should help with resurrection of the thread. diff --git a/src/_pytest/threadexception.py b/src/_pytest/threadexception.py index 4a76a9d9000..38665d2731f 100644 --- a/src/_pytest/threadexception.py +++ b/src/_pytest/threadexception.py @@ -1,97 +1,167 @@ from __future__ import annotations +import collections from collections.abc import Callable -from collections.abc import Generator +import functools +import sys import threading +import time import traceback -from types import TracebackType -from typing import Any +from typing import NamedTuple from typing import TYPE_CHECKING import warnings +from _pytest.config import Config +from _pytest.nodes import Item +from _pytest.stash import StashKey +from _pytest.tracemalloc import tracemalloc_message import pytest if TYPE_CHECKING: - from typing_extensions import Self - - -# Copied from cpython/Lib/test/support/threading_helper.py, with modifications. -class catch_threading_exception: - """Context manager catching threading.Thread exception using - threading.excepthook. - - Storing exc_value using a custom hook can create a reference cycle. The - reference cycle is broken explicitly when the context manager exits. - - Storing thread using a custom hook can resurrect it if it is set to an - object which is being finalized. Exiting the context manager clears the - stored object. - - Usage: - with threading_helper.catch_threading_exception() as cm: - # code spawning a thread which raises an exception - ... - # check the thread exception: use cm.args - ... - # cm.args attribute no longer exists at this point - # (to break a reference cycle) - """ - - def __init__(self) -> None: - self.args: threading.ExceptHookArgs | None = None - self._old_hook: Callable[[threading.ExceptHookArgs], Any] | None = None - - def _hook(self, args: threading.ExceptHookArgs) -> None: - self.args = args - - def __enter__(self) -> Self: - self._old_hook = threading.excepthook - threading.excepthook = self._hook - return self - - def __exit__( - self, - exc_type: type[BaseException] | None, - exc_val: BaseException | None, - exc_tb: TracebackType | None, - ) -> None: - assert self._old_hook is not None - threading.excepthook = self._old_hook - self._old_hook = None - del self.args - - -def thread_exception_runtest_hook() -> Generator[None]: - with catch_threading_exception() as cm: + pass + +if sys.version_info < (3, 11): + from exceptiongroup import ExceptionGroup + + +def join_threads() -> None: + start = time.monotonic() + current_thread = threading.current_thread() + # This function is executed right at the end of the pytest run, just + # before we return an exit code, which is where the interpreter joins + # any remaining non-daemonic threads anyway, so it's ok to join all the + # threads. However there might be threads that depend on some shutdown + # signal that happens after pytest finishes, so we want to limit the + # join time somewhat. A one second timeout seems reasonable. + timeout = 1 + for thread in threading.enumerate(): + if thread is not current_thread and not thread.daemon: + # TODO: raise an error/warning if there's dangling threads. + thread.join(timeout - (time.monotonic() - start)) + + +class ThreadExceptionMeta(NamedTuple): + msg: str + cause_msg: str + exc_value: BaseException | None + + +thread_exceptions: StashKey[collections.deque[ThreadExceptionMeta | BaseException]] = ( + StashKey() +) + + +def collect_thread_exception(config: Config) -> None: + pop_thread_exception = config.stash[thread_exceptions].pop + errors: list[pytest.PytestUnhandledThreadExceptionWarning | RuntimeError] = [] + meta = None + hook_error = None + try: + while True: + try: + meta = pop_thread_exception() + except IndexError: + break + + if isinstance(meta, BaseException): + hook_error = RuntimeError("Failed to process thread exception") + hook_error.__cause__ = meta + errors.append(hook_error) + continue + + msg = meta.msg + try: + warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg)) + except pytest.PytestUnhandledThreadExceptionWarning as e: + # This except happens when the warning is treated as an error (e.g. `-Werror`). + if meta.exc_value is not None: + # Exceptions have a better way to show the traceback, but + # warnings do not, so hide the traceback from the msg and + # set the cause so the traceback shows up in the right place. + e.args = (meta.cause_msg,) + e.__cause__ = meta.exc_value + errors.append(e) + + if len(errors) == 1: + raise errors[0] + if errors: + raise ExceptionGroup("multiple thread exception warnings", errors) + finally: + del errors, meta, hook_error + + +def cleanup( + *, config: Config, prev_hook: Callable[[threading.ExceptHookArgs], object] +) -> None: + try: try: - yield + join_threads() + collect_thread_exception(config) finally: - if cm.args: - thread_name = ( - "" if cm.args.thread is None else cm.args.thread.name - ) - msg = f"Exception in thread {thread_name}\n\n" - msg += "".join( - traceback.format_exception( - cm.args.exc_type, - cm.args.exc_value, - cm.args.exc_traceback, - ) - ) - warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg)) - - -@pytest.hookimpl(wrapper=True, trylast=True) -def pytest_runtest_setup() -> Generator[None]: - yield from thread_exception_runtest_hook() - - -@pytest.hookimpl(wrapper=True, tryfirst=True) -def pytest_runtest_call() -> Generator[None]: - yield from thread_exception_runtest_hook() - - -@pytest.hookimpl(wrapper=True, tryfirst=True) -def pytest_runtest_teardown() -> Generator[None]: - yield from thread_exception_runtest_hook() + threading.excepthook = prev_hook + finally: + del config.stash[thread_exceptions] + + +def thread_exception_hook( + args: threading.ExceptHookArgs, + /, + *, + append: Callable[[ThreadExceptionMeta | BaseException], object], +) -> None: + try: + # we need to compute these strings here as they might change after + # the excepthook finishes and before the metadata object is + # collected by a pytest hook + thread_name = "" if args.thread is None else args.thread.name + summary = f"Exception in thread {thread_name}" + traceback_message = "\n\n" + "".join( + traceback.format_exception( + args.exc_type, + args.exc_value, + args.exc_traceback, + ) + ) + tracemalloc_tb = "\n" + tracemalloc_message(args.thread) + msg = summary + traceback_message + tracemalloc_tb + cause_msg = summary + tracemalloc_tb + + append( + ThreadExceptionMeta( + # Compute these strings here as they might change later + msg=msg, + cause_msg=cause_msg, + exc_value=args.exc_value, + ) + ) + except BaseException as e: + append(e) + # Raising this will cause the exception to be logged twice, once in our + # collect_thread_exception and once by sys.excepthook + # which is fine - this should never happen anyway and if it does + # it should probably be reported as a pytest bug. + raise + + +def pytest_configure(config: Config) -> None: + prev_hook = threading.excepthook + deque: collections.deque[ThreadExceptionMeta | BaseException] = collections.deque() + config.stash[thread_exceptions] = deque + config.add_cleanup(functools.partial(cleanup, config=config, prev_hook=prev_hook)) + threading.excepthook = functools.partial(thread_exception_hook, append=deque.append) + + +@pytest.hookimpl(trylast=True) +def pytest_runtest_setup(item: Item) -> None: + collect_thread_exception(item.config) + + +@pytest.hookimpl(trylast=True) +def pytest_runtest_call(item: Item) -> None: + collect_thread_exception(item.config) + + +@pytest.hookimpl(trylast=True) +def pytest_runtest_teardown(item: Item) -> None: + collect_thread_exception(item.config) diff --git a/src/_pytest/unraisableexception.py b/src/_pytest/unraisableexception.py index 2bd7f07e862..7826aeccd12 100644 --- a/src/_pytest/unraisableexception.py +++ b/src/_pytest/unraisableexception.py @@ -101,6 +101,9 @@ def unraisable_hook( append: Callable[[UnraisableMeta | BaseException], object], ) -> None: try: + # we need to compute these strings here as they might change after + # the unraisablehook finishes and before the metadata object is + # collected by a pytest hook err_msg = ( "Exception ignored in" if unraisable.err_msg is None else unraisable.err_msg ) @@ -118,9 +121,6 @@ def unraisable_hook( append( UnraisableMeta( - # we need to compute these strings here as they might change after - # the unraisablehook finishes and before the unraisable object is - # collected by a hook msg=msg, cause_msg=cause_msg, exc_value=unraisable.exc_value, diff --git a/testing/test_threadexception.py b/testing/test_threadexception.py index abd30144914..6ee93ab9c22 100644 --- a/testing/test_threadexception.py +++ b/testing/test_threadexception.py @@ -23,7 +23,7 @@ def test_2(): pass ) result = pytester.runpytest() assert result.ret == 0 - assert result.parseoutcomes() == {"passed": 2, "warnings": 1} + result.assert_outcomes(passed=2, warnings=1) result.stdout.fnmatch_lines( [ "*= warnings summary =*", @@ -59,7 +59,7 @@ def test_2(): pass ) result = pytester.runpytest() assert result.ret == 0 - assert result.parseoutcomes() == {"passed": 2, "warnings": 1} + result.assert_outcomes(passed=2, warnings=1) result.stdout.fnmatch_lines( [ "*= warnings summary =*", @@ -96,7 +96,7 @@ def test_2(): pass ) result = pytester.runpytest() assert result.ret == 0 - assert result.parseoutcomes() == {"passed": 2, "warnings": 1} + result.assert_outcomes(passed=2, warnings=1) result.stdout.fnmatch_lines( [ "*= warnings summary =*", @@ -130,4 +130,127 @@ def test_2(): pass ) result = pytester.runpytest() assert result.ret == pytest.ExitCode.TESTS_FAILED - assert result.parseoutcomes() == {"passed": 1, "failed": 1} + result.assert_outcomes(passed=1, failed=1) + + +@pytest.mark.filterwarnings("error::pytest.PytestUnhandledThreadExceptionWarning") +def test_threadexception_warning_multiple_errors(pytester: Pytester) -> None: + pytester.makepyfile( + test_it=""" + import threading + + def test_it(): + def oops(): + raise ValueError("Oops") + + t = threading.Thread(target=oops, name="MyThread") + t.start() + t.join() + + t = threading.Thread(target=oops, name="MyThread2") + t.start() + t.join() + + def test_2(): pass + """ + ) + result = pytester.runpytest() + assert result.ret == pytest.ExitCode.TESTS_FAILED + result.assert_outcomes(passed=1, failed=1) + result.stdout.fnmatch_lines( + [" | *ExceptionGroup: multiple thread exception warnings (2 sub-exceptions)"] + ) + + +def test_unraisable_collection_failure(pytester: Pytester) -> None: + pytester.makepyfile( + test_it=""" + import threading + + class Thread(threading.Thread): + @property + def name(self): + raise RuntimeError("oops!") + + def test_it(): + def oops(): + raise ValueError("Oops") + + t = Thread(target=oops, name="MyThread") + t.start() + t.join() + + def test_2(): pass + """ + ) + + result = pytester.runpytest() + assert result.ret == 1 + result.assert_outcomes(passed=1, failed=1) + result.stdout.fnmatch_lines( + ["E RuntimeError: Failed to process thread exception"] + ) + + +def test_unhandled_thread_exception_after_teardown(pytester: Pytester) -> None: + pytester.makepyfile( + test_it=""" + import time + import threading + import pytest + + def thread(): + def oops(): + time.sleep(0.5) + raise ValueError("Oops") + + t = threading.Thread(target=oops, name="MyThread") + t.start() + + def test_it(request): + request.config.add_cleanup(thread) + """ + ) + + result = pytester.runpytest() + + # TODO: should be a test failure or error + assert result.ret == pytest.ExitCode.INTERNAL_ERROR + + result.assert_outcomes(passed=1) + result.stderr.fnmatch_lines("ValueError: Oops") + + +@pytest.mark.filterwarnings("error::pytest.PytestUnhandledThreadExceptionWarning") +def test_possibly_none_excinfo(pytester: Pytester) -> None: + pytester.makepyfile( + test_it=""" + import threading + import types + + def test_it(): + threading.excepthook( + types.SimpleNamespace( + exc_type=RuntimeError, + exc_value=None, + exc_traceback=None, + thread=None, + ) + ) + """ + ) + + result = pytester.runpytest() + + # TODO: should be a test failure or error + assert result.ret == pytest.ExitCode.TESTS_FAILED + + result.assert_outcomes(failed=1) + result.stdout.fnmatch_lines( + [ + "E pytest.PytestUnhandledThreadExceptionWarning:" + " Exception in thread ", + "E ", + "E NoneType: None", + ] + ) diff --git a/testing/test_unraisableexception.py b/testing/test_unraisableexception.py index 70248e1c122..5aa6aa773d9 100644 --- a/testing/test_unraisableexception.py +++ b/testing/test_unraisableexception.py @@ -234,3 +234,39 @@ def test_it(): result.assert_outcomes(passed=1) result.stderr.fnmatch_lines("ValueError: del is broken") + + +@pytest.mark.filterwarnings("error::pytest.PytestUnraisableExceptionWarning") +def test_possibly_none_excinfo(pytester: Pytester) -> None: + pytester.makepyfile( + test_it=""" + import sys + import types + + def test_it(): + sys.unraisablehook( + types.SimpleNamespace( + exc_type=RuntimeError, + exc_value=None, + exc_traceback=None, + err_msg=None, + object=None, + ) + ) + """ + ) + + result = pytester.runpytest() + + # TODO: should be a test failure or error + assert result.ret == pytest.ExitCode.TESTS_FAILED + + result.assert_outcomes(failed=1) + result.stdout.fnmatch_lines( + [ + "E pytest.PytestUnraisableExceptionWarning:" + " Exception ignored in: None", + "E ", + "E NoneType: None", + ] + ) From 80da4274398617274ff9e576339184ce77893d9b Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Thu, 5 Dec 2024 12:52:23 +0000 Subject: [PATCH 208/445] Remove thread join from threadexception plugin (#13027) As per review comment: https://github.com/pytest-dev/pytest/pull/13016#discussion_r1870340465. Closes #13028. --------- Co-authored-by: Bruno Oliveira --- changelog/13016.improvement.rst | 1 - src/_pytest/threadexception.py | 21 +++------------------ testing/test_threadexception.py | 3 +-- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/changelog/13016.improvement.rst b/changelog/13016.improvement.rst index 22642fc6f4f..634672ab69b 100644 --- a/changelog/13016.improvement.rst +++ b/changelog/13016.improvement.rst @@ -1,7 +1,6 @@ A number of :ref:`threadexception ` enhancements: * Set the excepthook as early as possible and unset it as late as possible, to collect the most possible number of unhandled exceptions from threads. -* join threads for 1 second just before unsetting the excepthook, to collect any straggling exceptions * Collect multiple thread exceptions per test phase. * Report the :mod:`tracemalloc` allocation traceback (if available). * Avoid using a generator based hook to allow handling :class:`StopIteration` in test failures. diff --git a/src/_pytest/threadexception.py b/src/_pytest/threadexception.py index 38665d2731f..eb57783be26 100644 --- a/src/_pytest/threadexception.py +++ b/src/_pytest/threadexception.py @@ -5,7 +5,6 @@ import functools import sys import threading -import time import traceback from typing import NamedTuple from typing import TYPE_CHECKING @@ -25,22 +24,6 @@ from exceptiongroup import ExceptionGroup -def join_threads() -> None: - start = time.monotonic() - current_thread = threading.current_thread() - # This function is executed right at the end of the pytest run, just - # before we return an exit code, which is where the interpreter joins - # any remaining non-daemonic threads anyway, so it's ok to join all the - # threads. However there might be threads that depend on some shutdown - # signal that happens after pytest finishes, so we want to limit the - # join time somewhat. A one second timeout seems reasonable. - timeout = 1 - for thread in threading.enumerate(): - if thread is not current_thread and not thread.daemon: - # TODO: raise an error/warning if there's dangling threads. - thread.join(timeout - (time.monotonic() - start)) - - class ThreadExceptionMeta(NamedTuple): msg: str cause_msg: str @@ -96,7 +79,9 @@ def cleanup( ) -> None: try: try: - join_threads() + # We don't join threads here, so exceptions raised from any + # threads still running by the time _threading_atexits joins them + # do not get captured (see #13027). collect_thread_exception(config) finally: threading.excepthook = prev_hook diff --git a/testing/test_threadexception.py b/testing/test_threadexception.py index 6ee93ab9c22..5dad07b8b85 100644 --- a/testing/test_threadexception.py +++ b/testing/test_threadexception.py @@ -195,17 +195,16 @@ def test_2(): pass def test_unhandled_thread_exception_after_teardown(pytester: Pytester) -> None: pytester.makepyfile( test_it=""" - import time import threading import pytest def thread(): def oops(): - time.sleep(0.5) raise ValueError("Oops") t = threading.Thread(target=oops, name="MyThread") t.start() + t.join() def test_it(request): request.config.add_cleanup(thread) From 9fc8a3ea74490c2801a111a76817bcd4a4030f6d Mon Sep 17 00:00:00 2001 From: Nathan Rousseau Date: Fri, 6 Dec 2024 20:35:35 +0100 Subject: [PATCH 209/445] Fix file name in comment of .git-blame-ignore-revs (closes #13033) (#13034) As explained in [issue 13033](https://github.com/pytest-dev/pytest/issues/13033), the file name on the comment explaining how to setup the *.git-blame-ignore-revs* file weren't up-to-date with the current name of the file. --- .git-blame-ignore-revs | 2 +- AUTHORS | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index d6aac5c425d..4f4cdb6c564 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -5,7 +5,7 @@ # # To "install" it: # -# git config --local blame.ignoreRevsFile .gitblameignore +# git config --local blame.ignoreRevsFile .git-blame-ignore-revs # run black 703e4b11ba76171eccd3f13e723c47b810ded7ef diff --git a/AUTHORS b/AUTHORS index 5c046ff5988..5aa9045208a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -305,6 +305,7 @@ Milan Lesnek Miro Hrončok mrbean-bremen Nathan Goldbaum +Nathan Rousseau Nathaniel Compton Nathaniel Waisbrot Nauman Ahmed From 44cb841e44d2aec29952f6aa586c2204cabe6b50 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Dec 2024 20:37:30 +0100 Subject: [PATCH 210/445] build(deps): Bump django in /testing/plugins_integration (#13032) Bumps [django](https://github.com/django/django) from 5.1.3 to 5.1.4. - [Commits](https://github.com/django/django/compare/5.1.3...5.1.4) --- updated-dependencies: - dependency-name: django dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index ec6b9418c93..a9b1e67ff7a 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,5 +1,5 @@ anyio[curio,trio]==4.6.2.post1 -django==5.1.3 +django==5.1.4 pytest-asyncio==0.24.0 pytest-bdd==8.0.0 pytest-cov==6.0.0 From ecde993e17efb3f34157642a111ba20f476aa80a Mon Sep 17 00:00:00 2001 From: Shaygan Hooshyari Date: Sat, 7 Dec 2024 12:51:26 +0100 Subject: [PATCH 211/445] fixtures: replace fixture representation with a class (#12473) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During the sprint we discussed fixing the above issue and thought maybe it's a better idea to add a better representation to fixtures. To do this without patching the object more, this PR refactors fixtures to have a class with attributes. The main rational behind that is: - Now we have a type for fixtures makes it easier to check for fixture types and no need to perform cast on objects. Removed monkey patching. - They are no longer functions that carry a class within them. - When you decorate a function with a fixture it's not possible to call it anymore. So it makes more sense for it to not be a function or method. Fixes #11525 --------- Co-authored-by: Sviatoslav Sydorenko (Святослав Сидоренко) Co-authored-by: Bruno Oliveira Co-authored-by: Ran Benita --- AUTHORS | 1 + changelog/11525.improvement.rst | 3 + doc/en/conf.py | 1 + src/_pytest/assertion/rewrite.py | 4 +- src/_pytest/compat.py | 48 +--------- src/_pytest/fixtures.py | 157 +++++++++++++++++-------------- testing/code/test_source.py | 12 +-- testing/python/fixtures.py | 72 ++++++++++++++ testing/test_assertrewrite.py | 17 ++++ testing/test_collection.py | 4 +- testing/test_compat.py | 17 ++-- 11 files changed, 203 insertions(+), 133 deletions(-) create mode 100644 changelog/11525.improvement.rst diff --git a/AUTHORS b/AUTHORS index 5aa9045208a..3419accfa6b 100644 --- a/AUTHORS +++ b/AUTHORS @@ -393,6 +393,7 @@ Serhii Mozghovyi Seth Junot Shantanu Jain Sharad Nair +Shaygan Hooshyari Shubham Adep Simon Blanchard Simon Gomizelj diff --git a/changelog/11525.improvement.rst b/changelog/11525.improvement.rst new file mode 100644 index 00000000000..1935ce59343 --- /dev/null +++ b/changelog/11525.improvement.rst @@ -0,0 +1,3 @@ +Fixtures are now clearly represented in the output as a "fixture object", not as a normal function as before, making it easy for beginners to catch mistakes such as referencing a fixture declared in the same module but not requested in the test function. + +-- by :user:`the-compiler` and :user:`glyphack` diff --git a/doc/en/conf.py b/doc/en/conf.py index 9558a75f927..47fc70dce85 100644 --- a/doc/en/conf.py +++ b/doc/en/conf.py @@ -75,6 +75,7 @@ ("py:class", "_pytest._code.code.TerminalRepr"), ("py:class", "TerminalRepr"), ("py:class", "_pytest.fixtures.FixtureFunctionMarker"), + ("py:class", "_pytest.fixtures.FixtureFunctionDefinition"), ("py:class", "_pytest.logging.LogCaptureHandler"), ("py:class", "_pytest.mark.structures.ParameterSet"), # Intentionally undocumented/private diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index c414b30a4a8..41e3d271396 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -31,6 +31,7 @@ from _pytest._version import version from _pytest.assertion import util from _pytest.config import Config +from _pytest.fixtures import FixtureFunctionDefinition from _pytest.main import Session from _pytest.pathlib import absolutepath from _pytest.pathlib import fnmatch_ex @@ -472,7 +473,8 @@ def _format_assertmsg(obj: object) -> str: def _should_repr_global_name(obj: object) -> bool: if callable(obj): - return False + # For pytest fixtures the __repr__ method provides more information than the function name. + return isinstance(obj, FixtureFunctionDefinition) try: return not hasattr(obj, "__name__") diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 1aa7495bddb..053ef1fd1fd 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -4,7 +4,6 @@ from __future__ import annotations from collections.abc import Callable -import dataclasses import enum import functools import inspect @@ -205,59 +204,16 @@ def ascii_escaped(val: bytes | str) -> str: return ret.translate(_non_printable_ascii_translate_table) -@dataclasses.dataclass -class _PytestWrapper: - """Dummy wrapper around a function object for internal use only. - - Used to correctly unwrap the underlying function object when we are - creating fixtures, because we wrap the function object ourselves with a - decorator to issue warnings when the fixture function is called directly. - """ - - obj: Any - - def get_real_func(obj): """Get the real function object of the (possibly) wrapped object by - functools.wraps or functools.partial.""" - start_obj = obj - for i in range(100): - # __pytest_wrapped__ is set by @pytest.fixture when wrapping the fixture function - # to trigger a warning if it gets called directly instead of by pytest: we don't - # want to unwrap further than this otherwise we lose useful wrappings like @mock.patch (#3774) - new_obj = getattr(obj, "__pytest_wrapped__", None) - if isinstance(new_obj, _PytestWrapper): - obj = new_obj.obj - break - new_obj = getattr(obj, "__wrapped__", None) - if new_obj is None: - break - obj = new_obj - else: - from _pytest._io.saferepr import saferepr + :func:`functools.wraps`, or :func:`functools.partial`.""" + obj = inspect.unwrap(obj) - raise ValueError( - f"could not find real function of {saferepr(start_obj)}\nstopped at {saferepr(obj)}" - ) if isinstance(obj, functools.partial): obj = obj.func return obj -def get_real_method(obj, holder): - """Attempt to obtain the real function object that might be wrapping - ``obj``, while at the same time returning a bound method to ``holder`` if - the original object was a bound method.""" - try: - is_method = hasattr(obj, "__func__") - obj = get_real_func(obj) - except Exception: # pragma: no cover - return obj - if is_method and hasattr(obj, "__get__") and callable(obj.__get__): - obj = obj.__get__(holder) - return obj - - def getimfunc(func): try: return func.__func__ diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index fc6541c1404..8b79dbcb932 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -40,10 +40,8 @@ from _pytest._code.code import FormattedExcinfo from _pytest._code.code import TerminalRepr from _pytest._io import TerminalWriter -from _pytest.compat import _PytestWrapper from _pytest.compat import assert_never from _pytest.compat import get_real_func -from _pytest.compat import get_real_method from _pytest.compat import getfuncargnames from _pytest.compat import getimfunc from _pytest.compat import getlocation @@ -152,13 +150,12 @@ def get_scope_node(node: nodes.Node, scope: Scope) -> nodes.Node | None: assert_never(scope) +# TODO: Try to use FixtureFunctionDefinition instead of the marker def getfixturemarker(obj: object) -> FixtureFunctionMarker | None: - """Return fixturemarker or None if it doesn't exist or raised - exceptions.""" - return cast( - Optional[FixtureFunctionMarker], - safe_getattr(obj, "_pytestfixturefunction", None), - ) + """Return fixturemarker or None if it doesn't exist""" + if isinstance(obj, FixtureFunctionDefinition): + return obj._fixture_function_marker + return None # Algorithm for sorting on a per-parametrized resource setup basis. @@ -1181,31 +1178,6 @@ def pytest_fixture_setup( return result -def wrap_function_to_error_out_if_called_directly( - function: FixtureFunction, - fixture_marker: FixtureFunctionMarker, -) -> FixtureFunction: - """Wrap the given fixture function so we can raise an error about it being called directly, - instead of used as an argument in a test function.""" - name = fixture_marker.name or function.__name__ - message = ( - f'Fixture "{name}" called directly. Fixtures are not meant to be called directly,\n' - "but are created automatically when test functions request them as parameters.\n" - "See https://docs.pytest.org/en/stable/explanation/fixtures.html for more information about fixtures, and\n" - "https://docs.pytest.org/en/stable/deprecations.html#calling-fixtures-directly about how to update your code." - ) - - @functools.wraps(function) - def result(*args, **kwargs): - fail(message, pytrace=False) - - # Keep reference to the original function in our own custom attribute so we don't unwrap - # further than this point and lose useful wrappings like @mock.patch (#3774). - result.__pytest_wrapped__ = _PytestWrapper(function) # type: ignore[attr-defined] - - return cast(FixtureFunction, result) - - @final @dataclasses.dataclass(frozen=True) class FixtureFunctionMarker: @@ -1220,11 +1192,11 @@ class FixtureFunctionMarker: def __post_init__(self, _ispytest: bool) -> None: check_ispytest(_ispytest) - def __call__(self, function: FixtureFunction) -> FixtureFunction: + def __call__(self, function: FixtureFunction) -> FixtureFunctionDefinition: if inspect.isclass(function): raise ValueError("class fixtures not supported (maybe in the future)") - if getattr(function, "_pytestfixturefunction", False): + if isinstance(function, FixtureFunctionDefinition): raise ValueError( f"@pytest.fixture is being applied more than once to the same function {function.__name__!r}" ) @@ -1232,7 +1204,9 @@ def __call__(self, function: FixtureFunction) -> FixtureFunction: if hasattr(function, "pytestmark"): warnings.warn(MARKED_FIXTURE, stacklevel=2) - function = wrap_function_to_error_out_if_called_directly(function, self) + fixture_definition = FixtureFunctionDefinition( + function=function, fixture_function_marker=self, _ispytest=True + ) name = self.name or function.__name__ if name == "request": @@ -1242,21 +1216,68 @@ def __call__(self, function: FixtureFunction) -> FixtureFunction: pytrace=False, ) - # Type ignored because https://github.com/python/mypy/issues/2087. - function._pytestfixturefunction = self # type: ignore[attr-defined] - return function + return fixture_definition + + +# TODO: paramspec/return type annotation tracking and storing +class FixtureFunctionDefinition: + def __init__( + self, + *, + function: Callable[..., Any], + fixture_function_marker: FixtureFunctionMarker, + instance: object | None = None, + _ispytest: bool = False, + ) -> None: + check_ispytest(_ispytest) + self.name = fixture_function_marker.name or function.__name__ + # In order to show the function that this fixture contains in messages. + # Set the __name__ to be same as the function __name__ or the given fixture name. + self.__name__ = self.name + self._fixture_function_marker = fixture_function_marker + if instance is not None: + self._fixture_function = cast( + Callable[..., Any], function.__get__(instance) + ) + else: + self._fixture_function = function + functools.update_wrapper(self, function) + + def __repr__(self) -> str: + return f"" + + def __get__(self, instance, owner=None): + """Behave like a method if the function it was applied to was a method.""" + return FixtureFunctionDefinition( + function=self._fixture_function, + fixture_function_marker=self._fixture_function_marker, + instance=instance, + _ispytest=True, + ) + + def __call__(self, *args: Any, **kwds: Any) -> Any: + message = ( + f'Fixture "{self.name}" called directly. Fixtures are not meant to be called directly,\n' + "but are created automatically when test functions request them as parameters.\n" + "See https://docs.pytest.org/en/stable/explanation/fixtures.html for more information about fixtures, and\n" + "https://docs.pytest.org/en/stable/deprecations.html#calling-fixtures-directly" + ) + fail(message, pytrace=False) + + def _get_wrapped_function(self) -> Callable[..., Any]: + return self._fixture_function @overload def fixture( - fixture_function: FixtureFunction, + fixture_function: Callable[..., object], *, scope: _ScopeName | Callable[[str, Config], _ScopeName] = ..., params: Iterable[object] | None = ..., autouse: bool = ..., ids: Sequence[object | None] | Callable[[Any], object | None] | None = ..., name: str | None = ..., -) -> FixtureFunction: ... +) -> FixtureFunctionDefinition: ... @overload @@ -1279,7 +1300,7 @@ def fixture( autouse: bool = False, ids: Sequence[object | None] | Callable[[Any], object | None] | None = None, name: str | None = None, -) -> FixtureFunctionMarker | FixtureFunction: +) -> FixtureFunctionMarker | FixtureFunctionDefinition: """Decorator to mark a fixture factory function. This decorator can be used, with or without parameters, to define a @@ -1774,33 +1795,31 @@ def parsefactories( # The attribute can be an arbitrary descriptor, so the attribute # access below can raise. safe_getattr() ignores such exceptions. obj_ub = safe_getattr(holderobj_tp, name, None) - marker = getfixturemarker(obj_ub) - if not isinstance(marker, FixtureFunctionMarker): - # Magic globals with __getattr__ might have got us a wrong - # fixture attribute. - continue - - # OK we know it is a fixture -- now safe to look up on the _instance_. - obj = getattr(holderobj, name) - - if marker.name: - name = marker.name - - # During fixture definition we wrap the original fixture function - # to issue a warning if called directly, so here we unwrap it in - # order to not emit the warning when pytest itself calls the - # fixture function. - func = get_real_method(obj, holderobj) - - self._register_fixture( - name=name, - nodeid=nodeid, - func=func, - scope=marker.scope, - params=marker.params, - ids=marker.ids, - autouse=marker.autouse, - ) + if type(obj_ub) is FixtureFunctionDefinition: + marker = obj_ub._fixture_function_marker + if marker.name: + fixture_name = marker.name + else: + fixture_name = name + + # OK we know it is a fixture -- now safe to look up on the _instance_. + try: + obj = getattr(holderobj, name) + # if the fixture is named in the decorator we cannot find it in the module + except AttributeError: + obj = obj_ub + + func = obj._get_wrapped_function() + + self._register_fixture( + name=fixture_name, + nodeid=nodeid, + func=func, + scope=marker.scope, + params=marker.params, + ids=marker.ids, + autouse=marker.autouse, + ) def getfixturedefs( self, argname: str, node: nodes.Node diff --git a/testing/code/test_source.py b/testing/code/test_source.py index d78d9e7025a..843233fe21e 100644 --- a/testing/code/test_source.py +++ b/testing/code/test_source.py @@ -478,14 +478,14 @@ def deco_mark(): def deco_fixture(): assert False - src = inspect.getsource(deco_fixture) + src = inspect.getsource(deco_fixture._get_wrapped_function()) assert src == " @pytest.fixture\n def deco_fixture():\n assert False\n" - # currently Source does not unwrap decorators, testing the - # existing behavior here for explicitness, but perhaps we should revisit/change this - # in the future - assert str(Source(deco_fixture)).startswith("@functools.wraps(function)") + # Make sure the decorator is not a wrapped function + assert not str(Source(deco_fixture)).startswith("@functools.wraps(function)") assert ( - textwrap.indent(str(Source(get_real_func(deco_fixture))), " ") + "\n" == src + textwrap.indent(str(Source(deco_fixture._get_wrapped_function())), " ") + + "\n" + == src ) diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index cac00ab5401..dc69781095b 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -1606,6 +1606,63 @@ def teardown_module(): result = pytester.runpytest() result.stdout.no_fnmatch_line("* ERROR at teardown *") + def test_unwrapping_pytest_fixture(self, pytester: Pytester) -> None: + """Ensure the unwrap method on `FixtureFunctionDefinition` correctly wraps and unwraps methods and functions""" + pytester.makepyfile( + """ + import pytest + import inspect + + class FixtureFunctionDefTestClass: + def __init__(self) -> None: + self.i = 10 + + @pytest.fixture + def fixture_function_def_test_method(self): + return self.i + + + @pytest.fixture + def fixture_function_def_test_func(): + return 9 + + + def test_get_wrapped_func_returns_method(): + obj = FixtureFunctionDefTestClass() + wrapped_function_result = ( + obj.fixture_function_def_test_method._get_wrapped_function() + ) + assert inspect.ismethod(wrapped_function_result) + assert wrapped_function_result() == 10 + + + def test_get_wrapped_func_returns_function(): + assert fixture_function_def_test_func._get_wrapped_function()() == 9 + """ + ) + result = pytester.runpytest() + result.assert_outcomes(passed=2) + + def test_fixture_wrapped_looks_liked_wrapped_function( + self, pytester: Pytester + ) -> None: + """Ensure that `FixtureFunctionDefinition` behaves like the function it wrapped.""" + pytester.makepyfile( + """ + import pytest + + @pytest.fixture + def fixture_function_def_test_func(): + return 9 + fixture_function_def_test_func.__doc__ = "documentation" + + def test_fixture_has_same_doc(): + assert fixture_function_def_test_func.__doc__ == "documentation" + """ + ) + result = pytester.runpytest() + result.assert_outcomes(passed=1) + class TestFixtureManagerParseFactories: @pytest.fixture @@ -4526,6 +4583,21 @@ def fixt(): ) +def test_fixture_class(pytester: Pytester) -> None: + """Check if an error is raised when using @pytest.fixture on a class.""" + pytester.makepyfile( + """ + import pytest + + @pytest.fixture + class A: + pass + """ + ) + result = pytester.runpytest() + result.assert_outcomes(errors=1) + + def test_fixture_param_shadowing(pytester: Pytester) -> None: """Parametrized arguments would be shadowed if a fixture with the same name also exists (#5036)""" pytester.makepyfile( diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index eed59a2dce7..02d1c3e52ff 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -975,6 +975,23 @@ def __repr__(self): assert "UnicodeDecodeError" not in msg assert "UnicodeEncodeError" not in msg + def test_assert_fixture(self, pytester: Pytester) -> None: + pytester.makepyfile( + """\ + import pytest + @pytest.fixture + def fixt(): + return 42 + + def test_something(): # missing "fixt" argument + assert fixt == 42 + """ + ) + result = pytester.runpytest() + result.stdout.fnmatch_lines( + ["*assert )> == 42*"] + ) + class TestRewriteOnImport: def test_pycache_is_a_file(self, pytester: Pytester) -> None: diff --git a/testing/test_collection.py b/testing/test_collection.py index 7d28610e015..ccd57eeef43 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -1284,7 +1284,7 @@ def test_1(): """ ) result = pytester.runpytest() - result.stdout.fnmatch_lines(["*1 passed in*"]) + result.assert_outcomes(passed=1) assert result.ret == 0 @@ -1348,7 +1348,7 @@ def test_collect_pyargs_with_testpaths( with monkeypatch.context() as mp: mp.chdir(root) result = pytester.runpytest_subprocess() - result.stdout.fnmatch_lines(["*1 passed in*"]) + result.assert_outcomes(passed=1) def test_initial_conftests_with_testpaths(pytester: Pytester) -> None: diff --git a/testing/test_compat.py b/testing/test_compat.py index 86868858956..3722bfcfb40 100644 --- a/testing/test_compat.py +++ b/testing/test_compat.py @@ -7,7 +7,6 @@ from functools import wraps from typing import TYPE_CHECKING -from _pytest.compat import _PytestWrapper from _pytest.compat import assert_never from _pytest.compat import get_real_func from _pytest.compat import safe_getattr @@ -38,10 +37,7 @@ def __getattr__(self, attr): with pytest.raises( ValueError, - match=( - "could not find real function of \n" - "stopped at " - ), + match=("wrapper loop when unwrapping "), ): get_real_func(evil) @@ -65,10 +61,13 @@ def func(): wrapped_func2 = decorator(decorator(wrapped_func)) assert get_real_func(wrapped_func2) is func - # special case for __pytest_wrapped__ attribute: used to obtain the function up until the point - # a function was wrapped by pytest itself - wrapped_func2.__pytest_wrapped__ = _PytestWrapper(wrapped_func) - assert get_real_func(wrapped_func2) is wrapped_func + # obtain the function up until the point a function was wrapped by pytest itself + @pytest.fixture + def wrapped_func3(): + pass # pragma: no cover + + wrapped_func4 = decorator(wrapped_func3) + assert get_real_func(wrapped_func4) is wrapped_func3._get_wrapped_function() def test_get_real_func_partial() -> None: From 8cff12865691b14b4bce70e0e304524619be385d Mon Sep 17 00:00:00 2001 From: dongfangtianyu <7629022+dongfangtianyu@users.noreply.github.com> Date: Sat, 7 Dec 2024 21:41:54 +0800 Subject: [PATCH 212/445] fix `AttributeError` crash when using `--import-mode=importlib` (#13029) Only parent modules with the `__path__` attribute can be used by the `find_spec` function, and most of the standard library does not meet this condition. Fixes #13026 . --- changelog/13026.bugfix.rst | 1 + src/_pytest/pathlib.py | 5 ++++- testing/test_pathlib.py | 31 +++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 changelog/13026.bugfix.rst diff --git a/changelog/13026.bugfix.rst b/changelog/13026.bugfix.rst new file mode 100644 index 00000000000..d10edbd111a --- /dev/null +++ b/changelog/13026.bugfix.rst @@ -0,0 +1 @@ +Fixed :class:`AttributeError` crash when using ``--import-mode=importlib`` when top-level directory same name as another module of the standard library. diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index 55b27985d31..7c368e0dcd0 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -668,7 +668,10 @@ def _import_module_using_spec( parent_module: ModuleType | None = None if parent_module_name: parent_module = sys.modules.get(parent_module_name) - if parent_module is None: + # If the parent_module lacks the `__path__` attribute, AttributeError when finding a submodule's spec, + # requiring re-import according to the path. + need_reimport = not hasattr(parent_module, "__path__") + if parent_module is None or need_reimport: # Get parent_location based on location, get parent_path based on path. if module_path.name == "__init__.py": # If the current module is in a package, diff --git a/testing/test_pathlib.py b/testing/test_pathlib.py index 436a6b9cae3..a21d1edf970 100644 --- a/testing/test_pathlib.py +++ b/testing/test_pathlib.py @@ -922,6 +922,37 @@ def test_my_test(): result = pytester.runpytest("--import-mode=importlib") result.stdout.fnmatch_lines("* 1 passed *") + @pytest.mark.parametrize("name", ["code", "time", "math"]) + def test_importlib_same_name_as_stl( + self, pytester, ns_param: bool, tmp_path: Path, name: str + ): + """Import a namespace package with the same name as the standard library (#13026).""" + file_path = pytester.path / f"{name}/foo/test_demo.py" + file_path.parent.mkdir(parents=True) + file_path.write_text( + dedent( + """ + def test_demo(): + pass + """ + ), + encoding="utf-8", + ) + + # unit test + __import__(name) # import standard library + + import_path( # import user files + file_path, + mode=ImportMode.importlib, + root=pytester.path, + consider_namespace_packages=ns_param, + ) + + # E2E test + result = pytester.runpytest("--import-mode=importlib") + result.stdout.fnmatch_lines("* 1 passed *") + def create_installed_doctests_and_tests_dir( self, path: Path, monkeypatch: MonkeyPatch ) -> tuple[Path, Path, Path]: From eacc65654b4a626d1543760b354bca773d2cca93 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 8 Dec 2024 06:08:15 +0000 Subject: [PATCH 213/445] [automated] Update plugin list (#13040) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 156 ++++++++++++++++++------------- 1 file changed, 90 insertions(+), 66 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 62535d2d366..f0e209008c6 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =7.0.0 :pypi:`pytest-batch-regression` A pytest plugin to repeat the entire test suite in batches. May 08, 2024 N/A pytest>=6.0.0 :pypi:`pytest-bazel` A pytest runner with bazel support Sep 27, 2024 4 - Beta pytest - :pypi:`pytest-bdd` BDD for pytest Nov 14, 2024 6 - Mature pytest>=7.0.0 + :pypi:`pytest-bdd` BDD for pytest Dec 05, 2024 6 - Mature pytest>=7.0.0 :pypi:`pytest-bdd-html` pytest plugin to display BDD info in HTML test report Nov 22, 2022 3 - Alpha pytest (!=6.0.0,>=5.0) :pypi:`pytest-bdd-ng` BDD for pytest Nov 26, 2024 4 - Beta pytest>=5.2 :pypi:`pytest-bdd-report` A pytest-bdd plugin for generating useful and informative BDD test reports Nov 27, 2024 N/A pytest>=7.1.3 @@ -158,7 +158,7 @@ This list contains 1551 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Nov 27, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Dec 06, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -268,7 +268,7 @@ This list contains 1551 plugins. :pypi:`pytest-codegen` Automatically create pytest test signatures Aug 23, 2020 2 - Pre-Alpha N/A :pypi:`pytest-codeowners` Pytest plugin for selecting tests by GitHub CODEOWNERS. Mar 30, 2022 4 - Beta pytest (>=6.0.0) :pypi:`pytest-codestyle` pytest plugin to run pycodestyle Mar 23, 2020 3 - Alpha N/A - :pypi:`pytest-codspeed` Pytest plugin to create CodSpeed benchmarks Oct 29, 2024 5 - Production/Stable pytest>=3.8 + :pypi:`pytest-codspeed` Pytest plugin to create CodSpeed benchmarks Dec 06, 2024 5 - Production/Stable pytest>=3.8 :pypi:`pytest-collect-appoint-info` set your encoding Aug 03, 2023 N/A pytest :pypi:`pytest-collect-formatter` Formatter for pytest collect output Mar 29, 2021 5 - Production/Stable N/A :pypi:`pytest-collect-formatter2` Formatter for pytest collect output May 31, 2021 5 - Production/Stable N/A @@ -284,7 +284,7 @@ This list contains 1551 plugins. :pypi:`pytest-confluence-report` Package stands for pytest plugin to upload results into Confluence page. Apr 17, 2022 N/A N/A :pypi:`pytest-console-scripts` Pytest plugin for testing console scripts May 31, 2023 4 - Beta pytest (>=4.0.0) :pypi:`pytest-consul` pytest plugin with fixtures for testing consul aware apps Nov 24, 2018 3 - Alpha pytest - :pypi:`pytest-container` Pytest fixtures for writing container based tests Apr 10, 2024 4 - Beta pytest>=3.10 + :pypi:`pytest-container` Pytest fixtures for writing container based tests Dec 04, 2024 4 - Beta pytest>=3.10 :pypi:`pytest-contextfixture` Define pytest fixtures as context managers. Mar 12, 2013 4 - Beta N/A :pypi:`pytest-contexts` A plugin to run tests written with the Contexts framework using pytest May 19, 2021 4 - Beta N/A :pypi:`pytest-continuous` A pytest plugin to run tests continuously until failure or interruption. Apr 23, 2024 N/A N/A @@ -360,7 +360,7 @@ This list contains 1551 plugins. :pypi:`pytest-dependency` Manage dependencies of tests Dec 31, 2023 4 - Beta N/A :pypi:`pytest-depends` Tests that depend on other tests Apr 05, 2020 5 - Production/Stable pytest (>=3) :pypi:`pytest-deprecate` Mark tests as testing a deprecated feature with a warning note. Jul 01, 2019 N/A N/A - :pypi:`pytest-deprecator` A simple plugin to use with pytest Nov 14, 2024 4 - Beta pytest>=6.2.0 + :pypi:`pytest-deprecator` A simple plugin to use with pytest Dec 02, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-describe` Describe-style plugin for pytest Feb 10, 2024 5 - Production/Stable pytest <9,>=4.6 :pypi:`pytest-describe-it` plugin for rich text descriptions Jul 19, 2019 4 - Beta pytest :pypi:`pytest-deselect-if` A plugin to deselect pytests tests rather than using skipif Mar 24, 2024 4 - Beta pytest>=6.2.0 @@ -463,21 +463,21 @@ This list contains 1551 plugins. :pypi:`pytest-echo` pytest plugin with mechanisms for echoing environment variables, package version and generic attributes Dec 05, 2023 5 - Production/Stable pytest >=2.2 :pypi:`pytest-edit` Edit the source code of a failed test with \`pytest --edit\`. Nov 17, 2024 N/A pytest :pypi:`pytest-ekstazi` Pytest plugin to select test using Ekstazi algorithm Sep 10, 2022 N/A pytest - :pypi:`pytest-elasticsearch` Elasticsearch fixtures and fixture factories for Pytest. Mar 15, 2024 5 - Production/Stable pytest >=7.0 + :pypi:`pytest-elasticsearch` Elasticsearch fixtures and fixture factories for Pytest. Dec 03, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-elasticsearch-test` Elasticsearch fixtures and fixture factories for Pytest. Aug 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-elements` Tool to help automate user interfaces Jan 13, 2021 N/A pytest (>=5.4,<6.0) :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Nov 14, 2024 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Nov 14, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Nov 14, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Nov 14, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Nov 14, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Nov 14, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Nov 14, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Nov 14, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Nov 14, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Dec 02, 2024 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Dec 02, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Dec 02, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Dec 02, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Dec 02, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Dec 02, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Dec 02, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Dec 02, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Dec 02, 2024 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -531,6 +531,7 @@ This list contains 1551 plugins. :pypi:`pytest_extra` Some helpers for writing tests with pytest. Aug 14, 2014 N/A N/A :pypi:`pytest-extra-durations` A pytest plugin to get durations on a per-function basis and per module basis. Apr 21, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-extra-markers` Additional pytest markers to dynamically enable/disable tests viia CLI flags Mar 05, 2023 4 - Beta pytest + :pypi:`pytest-f3ts` Pytest Plugin for communicating test results and information to a FixturFab Test Runner GUI Dec 03, 2024 N/A pytest<8.0.0,>=7.2.1 :pypi:`pytest-fabric` Provides test utilities to run fabric task tests by using docker containers Sep 12, 2018 5 - Production/Stable N/A :pypi:`pytest-factor` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A :pypi:`pytest-factory` Use factories for test setup with py.test Sep 06, 2020 3 - Alpha pytest (>4.3) @@ -567,6 +568,7 @@ This list contains 1551 plugins. :pypi:`pytest-fixture-classes` Fixtures as classes that work well with dependency injection, autocompletetion, type checkers, and language servers Sep 02, 2023 5 - Production/Stable pytest :pypi:`pytest-fixturecollection` A pytest plugin to collect tests based on fixtures being used by tests Feb 22, 2024 4 - Beta pytest >=3.5.0 :pypi:`pytest-fixture-config` Fixture configuration utils for py.test Oct 17, 2024 5 - Production/Stable pytest + :pypi:`pytest-fixture-forms` A pytest plugin for creating fixtures that holds different forms between tests. Dec 06, 2024 N/A pytest<9.0.0,>=7.0.0 :pypi:`pytest-fixture-maker` Pytest plugin to load fixtures from YAML files Sep 21, 2021 N/A N/A :pypi:`pytest-fixture-marker` A pytest plugin to add markers based on fixtures used. Oct 11, 2020 5 - Production/Stable N/A :pypi:`pytest-fixture-order` pytest plugin to control fixture evaluation order May 16, 2022 5 - Production/Stable pytest (>=3.0) @@ -590,7 +592,7 @@ This list contains 1551 plugins. :pypi:`pytest-flexreport` Apr 15, 2023 4 - Beta pytest :pypi:`pytest-fluent` A pytest plugin in order to provide logs via fluentd Aug 14, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-fluentbit` A pytest plugin in order to provide logs via fluentbit Jun 16, 2023 4 - Beta pytest (>=7.0.0) - :pypi:`pytest-fly` pytest observer Apr 14, 2024 3 - Alpha pytest + :pypi:`pytest-fly` pytest observer Dec 03, 2024 3 - Alpha pytest :pypi:`pytest-flyte` Pytest fixtures for simplifying Flyte integration testing May 03, 2021 N/A pytest :pypi:`pytest-focus` A pytest plugin that alerts user of failed test cases with screen notifications May 04, 2019 4 - Beta pytest :pypi:`pytest-forbid` Mar 07, 2023 N/A pytest (>=7.2.2,<8.0.0) @@ -617,12 +619,12 @@ This list contains 1551 plugins. :pypi:`pytest-gc` The garbage collector plugin for py.test Feb 01, 2018 N/A N/A :pypi:`pytest-gcov` Uses gcov to measure test coverage of a C library Feb 01, 2018 3 - Alpha N/A :pypi:`pytest-gcs` GCS fixtures and fixture factories for Pytest. Mar 01, 2024 5 - Production/Stable pytest >=6.2 - :pypi:`pytest-gee` The Python plugin for your GEE based packages. Nov 14, 2024 3 - Alpha pytest + :pypi:`pytest-gee` The Python plugin for your GEE based packages. Dec 06, 2024 3 - Alpha pytest :pypi:`pytest-gevent` Ensure that gevent is properly patched when invoking pytest Feb 25, 2020 N/A pytest :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Nov 19, 2024 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Dec 05, 2024 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -666,7 +668,7 @@ This list contains 1551 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Nov 29, 2024 3 - Alpha pytest==8.3.3 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Dec 07, 2024 3 - Alpha pytest==8.3.3 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -734,14 +736,14 @@ This list contains 1551 plugins. :pypi:`pytest-interactive` A pytest plugin for console based interactive test selection just after the collection phase Nov 30, 2017 3 - Alpha N/A :pypi:`pytest-intercept-remote` Pytest plugin for intercepting outgoing connection requests during pytest run. May 24, 2021 4 - Beta pytest (>=4.6) :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Nov 19, 2024 4 - Beta pytest - :pypi:`pytest-invenio` Pytest fixtures for Invenio. Jun 27, 2024 5 - Production/Stable pytest<7.2.0,>=6 + :pypi:`pytest-invenio` Pytest fixtures for Invenio. Dec 02, 2024 5 - Production/Stable pytest<9.0.0,>=6 :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-iovis` A Pytest plugin to enable Jupyter Notebook testing with Papermill Nov 06, 2024 4 - Beta pytest>=7.1.0 :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A - :pypi:`pytest-ipywidgets` Oct 28, 2024 N/A pytest + :pypi:`pytest-ipywidgets` Dec 04, 2024 N/A pytest :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Nov 24, 2024 4 - Beta pytest - :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Sep 18, 2024 4 - Beta pytest>=5 + :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Dec 05, 2024 4 - Beta pytest>=5 :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-it` Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it. Jan 29, 2024 4 - Beta N/A :pypi:`pytest-item-dict` Get a hierarchical dict of session.items Nov 14, 2024 4 - Beta pytest>=8.3.0 @@ -1166,7 +1168,7 @@ This list contains 1551 plugins. :pypi:`pytest-reportlog` Replacement for the --resultlog option, focused in simplicity and extensibility May 22, 2023 3 - Alpha pytest :pypi:`pytest-report-me` A pytest plugin to generate report. Dec 31, 2020 N/A pytest :pypi:`pytest-report-parameters` pytest plugin for adding tests' parameters to junit report Jun 18, 2020 3 - Alpha pytest (>=2.4.2) - :pypi:`pytest-reportportal` Agent for Reporting results of tests to the Report Portal Oct 31, 2024 N/A pytest>=3.8.0 + :pypi:`pytest-reportportal` Agent for Reporting results of tests to the Report Portal Dec 04, 2024 N/A pytest>=3.8.0 :pypi:`pytest-report-stream` A pytest plugin which allows to stream test reports at runtime Oct 22, 2023 4 - Beta N/A :pypi:`pytest-repo-structure` Pytest Repo Structure Mar 18, 2024 1 - Planning N/A :pypi:`pytest-req` pytest requests plugin Aug 31, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.2 @@ -1198,6 +1200,7 @@ This list contains 1551 plugins. :pypi:`pytest-retry` Adds the ability to retry flaky tests in CI environments May 14, 2024 N/A pytest>=7.0.0 :pypi:`pytest-retry-class` A pytest plugin to rerun entire class on failure Nov 24, 2024 N/A pytest>=5.3 :pypi:`pytest-reusable-testcases` Apr 28, 2023 N/A N/A + :pypi:`pytest-revealtype-injector` Pytest plugin for replacing reveal_type() calls inside test functions with static and runtime type checking result comparison, for confirming type annotation validity. Dec 03, 2024 4 - Beta pytest>=7.0 :pypi:`pytest-reverse` Pytest plugin to reverse test order. Oct 25, 2024 5 - Production/Stable pytest :pypi:`pytest-rich` Leverage rich for richer test session output Mar 03, 2022 4 - Beta pytest (>=7.0) :pypi:`pytest-richer` Pytest plugin providing a Rich based reporter. Oct 27, 2023 3 - Alpha pytest @@ -1233,7 +1236,7 @@ This list contains 1551 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Nov 30, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Dec 06, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1244,7 +1247,7 @@ This list contains 1551 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Nov 30, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Dec 06, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1347,7 +1350,7 @@ This list contains 1551 plugins. :pypi:`pytest-steps` Create step-wise / incremental tests in pytest. Sep 23, 2021 5 - Production/Stable N/A :pypi:`pytest-stepwise` Run a test suite one failing test at a time. Dec 01, 2015 4 - Beta N/A :pypi:`pytest-stf` pytest plugin for openSTF Sep 24, 2024 N/A pytest>=5.0 - :pypi:`pytest-stochastics` pytest plugin that allows selectively running tests several times and accepting \*some\* failures. Nov 30, 2024 N/A pytest<9.0.0,>=8.0.0 + :pypi:`pytest-stochastics` pytest plugin that allows selectively running tests several times and accepting \*some\* failures. Dec 01, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-stoq` A plugin to pytest stoq Feb 09, 2021 4 - Beta N/A :pypi:`pytest-store` Pytest plugin to store values from test runs Sep 04, 2024 3 - Alpha pytest>=7.0.0 :pypi:`pytest-stress` A Pytest plugin that allows you to loop tests for a user defined amount of time. Dec 07, 2019 4 - Beta pytest (>=3.6.0) @@ -1359,7 +1362,7 @@ This list contains 1551 plugins. :pypi:`pytest-subinterpreter` Run pytest in a subinterpreter Nov 25, 2023 N/A pytest>=7.0.0 :pypi:`pytest-subprocess` A plugin to fake subprocess for pytest Jul 24, 2024 5 - Production/Stable pytest>=4.0.0 :pypi:`pytest-subtesthack` A hack to explicitly set up and tear down fixtures. Jul 16, 2022 N/A N/A - :pypi:`pytest-subtests` unittest subTest() support and subtests fixture Jul 17, 2024 4 - Beta pytest>=7.0 + :pypi:`pytest-subtests` unittest subTest() support and subtests fixture Dec 07, 2024 4 - Beta pytest>=7.4 :pypi:`pytest-subunit` pytest-subunit is a plugin for py.test which outputs testsresult in subunit format. Sep 17, 2023 N/A pytest (>=2.3) :pypi:`pytest-sugar` pytest-sugar is a plugin for pytest that changes the default look and feel of pytest (e.g. progressbar, show tests that fail instantly). Feb 01, 2024 4 - Beta pytest >=6.2.0 :pypi:`pytest-suitemanager` A simple plugin to use with pytest Apr 28, 2023 4 - Beta N/A @@ -1396,6 +1399,7 @@ This list contains 1551 plugins. :pypi:`pytest-testinfra` Test infrastructures May 26, 2024 5 - Production/Stable pytest>=6 :pypi:`pytest-testinfra-jpic` Test infrastructures Sep 21, 2023 5 - Production/Stable N/A :pypi:`pytest-testinfra-winrm-transport` Test infrastructures Sep 21, 2023 5 - Production/Stable N/A + :pypi:`pytest-testit-parametrize` A pytest plugin for uploading parameterized tests parameters into TMS TestIT Dec 04, 2024 4 - Beta pytest>=8.3.3 :pypi:`pytest-testlink-adaptor` pytest reporting plugin for testlink Dec 20, 2018 4 - Beta pytest (>=2.6) :pypi:`pytest-testmon` selects tests affected by changed files and methods Feb 27, 2024 4 - Beta pytest <9,>=5 :pypi:`pytest-testmon-dev` selects tests affected by changed files and methods Mar 30, 2023 4 - Beta pytest (<8,>=5) @@ -1472,7 +1476,6 @@ This list contains 1551 plugins. :pypi:`pytest-tspwplib` A simple plugin to use with tspwplib Jan 08, 2021 4 - Beta pytest (>=3.5.0) :pypi:`pytest-tst` Customize pytest options, output and exit code to make it compatible with tst Apr 27, 2022 N/A pytest (>=5.0.0) :pypi:`pytest-tstcls` Test Class Base Mar 23, 2020 5 - Production/Stable N/A - :pypi:`pytest-tt-ddriven` A simple project that act as a placeholder for project name Nov 29, 2024 N/A N/A :pypi:`pytest-tui` Text User Interface (TUI) and HTML report for Pytest test runs Dec 08, 2023 4 - Beta N/A :pypi:`pytest-tutorials` Mar 11, 2023 N/A N/A :pypi:`pytest-twilio-conversations-client-mock` Aug 02, 2022 N/A N/A @@ -2396,7 +2399,7 @@ This list contains 1551 plugins. A pytest runner with bazel support :pypi:`pytest-bdd` - *last release*: Nov 14, 2024, + *last release*: Dec 05, 2024, *status*: 6 - Mature, *requires*: pytest>=7.0.0 @@ -2459,7 +2462,7 @@ This list contains 1551 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Nov 27, 2024, + *last release*: Dec 06, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -3229,7 +3232,7 @@ This list contains 1551 plugins. pytest plugin to run pycodestyle :pypi:`pytest-codspeed` - *last release*: Oct 29, 2024, + *last release*: Dec 06, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=3.8 @@ -3341,7 +3344,7 @@ This list contains 1551 plugins. pytest plugin with fixtures for testing consul aware apps :pypi:`pytest-container` - *last release*: Apr 10, 2024, + *last release*: Dec 04, 2024, *status*: 4 - Beta, *requires*: pytest>=3.10 @@ -3873,7 +3876,7 @@ This list contains 1551 plugins. Mark tests as testing a deprecated feature with a warning note. :pypi:`pytest-deprecator` - *last release*: Nov 14, 2024, + *last release*: Dec 02, 2024, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -4594,9 +4597,9 @@ This list contains 1551 plugins. Pytest plugin to select test using Ekstazi algorithm :pypi:`pytest-elasticsearch` - *last release*: Mar 15, 2024, + *last release*: Dec 03, 2024, *status*: 5 - Production/Stable, - *requires*: pytest >=7.0 + *requires*: pytest>=7.0 Elasticsearch fixtures and fixture factories for Pytest. @@ -4636,63 +4639,63 @@ This list contains 1551 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: Nov 14, 2024, + *last release*: Dec 02, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: Nov 14, 2024, + *last release*: Dec 02, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: Nov 14, 2024, + *last release*: Dec 02, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: Nov 14, 2024, + *last release*: Dec 02, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. :pypi:`pytest-embedded-nuttx` - *last release*: Nov 14, 2024, + *last release*: Dec 02, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with NuttX. :pypi:`pytest-embedded-qemu` - *last release*: Nov 14, 2024, + *last release*: Dec 02, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: Nov 14, 2024, + *last release*: Dec 02, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: Nov 14, 2024, + *last release*: Dec 02, 2024, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: Nov 14, 2024, + *last release*: Dec 02, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -5069,6 +5072,13 @@ This list contains 1551 plugins. Additional pytest markers to dynamically enable/disable tests viia CLI flags + :pypi:`pytest-f3ts` + *last release*: Dec 03, 2024, + *status*: N/A, + *requires*: pytest<8.0.0,>=7.2.1 + + Pytest Plugin for communicating test results and information to a FixturFab Test Runner GUI + :pypi:`pytest-fabric` *last release*: Sep 12, 2018, *status*: 5 - Production/Stable, @@ -5321,6 +5331,13 @@ This list contains 1551 plugins. Fixture configuration utils for py.test + :pypi:`pytest-fixture-forms` + *last release*: Dec 06, 2024, + *status*: N/A, + *requires*: pytest<9.0.0,>=7.0.0 + + A pytest plugin for creating fixtures that holds different forms between tests. + :pypi:`pytest-fixture-maker` *last release*: Sep 21, 2021, *status*: N/A, @@ -5483,7 +5500,7 @@ This list contains 1551 plugins. A pytest plugin in order to provide logs via fluentbit :pypi:`pytest-fly` - *last release*: Apr 14, 2024, + *last release*: Dec 03, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -5672,7 +5689,7 @@ This list contains 1551 plugins. GCS fixtures and fixture factories for Pytest. :pypi:`pytest-gee` - *last release*: Nov 14, 2024, + *last release*: Dec 06, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -5707,7 +5724,7 @@ This list contains 1551 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Nov 19, 2024, + *last release*: Dec 05, 2024, *status*: N/A, *requires*: pytest>=3.6 @@ -6015,7 +6032,7 @@ This list contains 1551 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Nov 29, 2024, + *last release*: Dec 07, 2024, *status*: 3 - Alpha, *requires*: pytest==8.3.3 @@ -6491,9 +6508,9 @@ This list contains 1551 plugins. Pytest plugin for checking charm relation interface protocol compliance. :pypi:`pytest-invenio` - *last release*: Jun 27, 2024, + *last release*: Dec 02, 2024, *status*: 5 - Production/Stable, - *requires*: pytest<7.2.0,>=6 + *requires*: pytest<9.0.0,>=6 Pytest fixtures for Invenio. @@ -6526,7 +6543,7 @@ This list contains 1551 plugins. THIS PROJECT IS ABANDONED :pypi:`pytest-ipywidgets` - *last release*: Oct 28, 2024, + *last release*: Dec 04, 2024, *status*: N/A, *requires*: pytest @@ -6540,7 +6557,7 @@ This list contains 1551 plugins. Run pytest tests in isolated subprocesses :pypi:`pytest-isolate-mpi` - *last release*: Sep 18, 2024, + *last release*: Dec 05, 2024, *status*: 4 - Beta, *requires*: pytest>=5 @@ -9515,7 +9532,7 @@ This list contains 1551 plugins. pytest plugin for adding tests' parameters to junit report :pypi:`pytest-reportportal` - *last release*: Oct 31, 2024, + *last release*: Dec 04, 2024, *status*: N/A, *requires*: pytest>=3.8.0 @@ -9738,6 +9755,13 @@ This list contains 1551 plugins. + :pypi:`pytest-revealtype-injector` + *last release*: Dec 03, 2024, + *status*: 4 - Beta, + *requires*: pytest>=7.0 + + Pytest plugin for replacing reveal_type() calls inside test functions with static and runtime type checking result comparison, for confirming type annotation validity. + :pypi:`pytest-reverse` *last release*: Oct 25, 2024, *status*: 5 - Production/Stable, @@ -9984,7 +10008,7 @@ This list contains 1551 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Nov 30, 2024, + *last release*: Dec 06, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10061,7 +10085,7 @@ This list contains 1551 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Nov 30, 2024, + *last release*: Dec 06, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10782,7 +10806,7 @@ This list contains 1551 plugins. pytest plugin for openSTF :pypi:`pytest-stochastics` - *last release*: Nov 30, 2024, + *last release*: Dec 01, 2024, *status*: N/A, *requires*: pytest<9.0.0,>=8.0.0 @@ -10866,9 +10890,9 @@ This list contains 1551 plugins. A hack to explicitly set up and tear down fixtures. :pypi:`pytest-subtests` - *last release*: Jul 17, 2024, + *last release*: Dec 07, 2024, *status*: 4 - Beta, - *requires*: pytest>=7.0 + *requires*: pytest>=7.4 unittest subTest() support and subtests fixture @@ -11124,6 +11148,13 @@ This list contains 1551 plugins. Test infrastructures + :pypi:`pytest-testit-parametrize` + *last release*: Dec 04, 2024, + *status*: 4 - Beta, + *requires*: pytest>=8.3.3 + + A pytest plugin for uploading parameterized tests parameters into TMS TestIT + :pypi:`pytest-testlink-adaptor` *last release*: Dec 20, 2018, *status*: 4 - Beta, @@ -11656,13 +11687,6 @@ This list contains 1551 plugins. Test Class Base - :pypi:`pytest-tt-ddriven` - *last release*: Nov 29, 2024, - *status*: N/A, - *requires*: N/A - - A simple project that act as a placeholder for project name - :pypi:`pytest-tui` *last release*: Dec 08, 2023, *status*: 4 - Beta, From ebba6fdec6efa30d1d2256109448b705877f01bf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 07:19:39 +0100 Subject: [PATCH 214/445] build(deps): Bump twisted in /testing/plugins_integration (#13043) Bumps [twisted](https://github.com/twisted/twisted) from 24.10.0 to 24.11.0. - [Release notes](https://github.com/twisted/twisted/releases) - [Changelog](https://github.com/twisted/twisted/blob/trunk/NEWS.rst) - [Commits](https://github.com/twisted/twisted/compare/twisted-24.10.0...twisted-24.11.0) --- updated-dependencies: - dependency-name: twisted dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index a9b1e67ff7a..b0c9774dd35 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -11,5 +11,5 @@ pytest-rerunfailures==15.0 pytest-sugar==1.0.0 pytest-trio==0.8.0 pytest-twisted==1.14.3 -twisted==24.10.0 +twisted==24.11.0 pytest-xvfb==3.0.0 From 0285c96337ec4ac64a338fbb81e14420ff676694 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 07:20:12 +0100 Subject: [PATCH 215/445] build(deps): Bump anyio[curio,trio] in /testing/plugins_integration (#13042) Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 4.6.2.post1 to 4.7.0. - [Release notes](https://github.com/agronholm/anyio/releases) - [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst) - [Commits](https://github.com/agronholm/anyio/compare/4.6.2.post1...4.7.0) --- updated-dependencies: - dependency-name: anyio[curio,trio] dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index b0c9774dd35..92935a2a72f 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,4 +1,4 @@ -anyio[curio,trio]==4.6.2.post1 +anyio[curio,trio]==4.7.0 django==5.1.4 pytest-asyncio==0.24.0 pytest-bdd==8.0.0 From cb66eeef46511d855b689e587a31faae92e24ccc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 06:57:17 +0000 Subject: [PATCH 216/445] build(deps): Bump pytest-bdd in /testing/plugins_integration (#13041) Bumps [pytest-bdd](https://github.com/pytest-dev/pytest-bdd) from 8.0.0 to 8.1.0. - [Changelog](https://github.com/pytest-dev/pytest-bdd/blob/master/CHANGES.rst) - [Commits](https://github.com/pytest-dev/pytest-bdd/compare/8.0.0...8.1.0) --- updated-dependencies: - dependency-name: pytest-bdd dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 92935a2a72f..4abe0bd6deb 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,7 +1,7 @@ anyio[curio,trio]==4.7.0 django==5.1.4 pytest-asyncio==0.24.0 -pytest-bdd==8.0.0 +pytest-bdd==8.1.0 pytest-cov==6.0.0 pytest-django==4.9.0 pytest-flakes==4.0.5 From 949c7711b3e22ab94110f1ae4fc307cda2f9e379 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 07:32:48 +0100 Subject: [PATCH 217/445] [pre-commit.ci] pre-commit autoupdate (#13048) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.1 → v0.8.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.1...v0.8.2) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8a5418350d7..d73ac5baee0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.8.1" + rev: "v0.8.2" hooks: - id: ruff args: ["--fix"] From 28e1e25a6782513db8a2963bd5ed5a9d66682f86 Mon Sep 17 00:00:00 2001 From: dongfangtianyu <7629022+dongfangtianyu@users.noreply.github.com> Date: Thu, 12 Dec 2024 22:47:05 +0800 Subject: [PATCH 218/445] Fix `ImportError` crash when using `--import-mode=importlib` (#13053) Regression in #12716 In short: `PathFinder.find_spec` received the argument `/cow/moo` but loaded `/cow/moo/moo.py` instead. **Trigger conditions:** 1. `/cow/moo/moo.py` exists (a file and directory with the same name). 2. `/cow/moo/test_moo.py` exists (test case resides in the directory). When pytest loads test files in `importlib` mode, it continues recursive loading upward: - When loading `cow.moo`, it should return a namespace but unexpectedly returns a module. - When loading `cow.moo.moo`, it should return a module but unexpectedly returns a namespace. **Complete example:** [[GitHub repository](https://github.com/dongfangtianyu/pytest_importlib_issue)](https://github.com/dongfangtianyu/pytest_importlib_issue) - `main.py`: Reproduces the error. - `debug.py`: Demonstrates the behavior of `PathFinder.find_spec`. **Context:** https://github.com/pytest-dev/pytest/issues/12592#issuecomment-2512039696 https://github.com/pytest-dev/pytest/issues/12592#issuecomment-2515100428 --------- Co-authored-by: Bruno Oliveira --- changelog/13053.bugfix.rst | 1 + src/_pytest/pathlib.py | 13 ++++++++++--- testing/test_pathlib.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 changelog/13053.bugfix.rst diff --git a/changelog/13053.bugfix.rst b/changelog/13053.bugfix.rst new file mode 100644 index 00000000000..b6744331394 --- /dev/null +++ b/changelog/13053.bugfix.rst @@ -0,0 +1 @@ +Fixed a regression in pytest 8.3.4 where, when using ``--import-mode=importlib``, a directory containing py file with the same name would cause an ``ImportError`` diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index 7c368e0dcd0..25dc69b6349 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -694,9 +694,16 @@ def _import_module_using_spec( # Checking with sys.meta_path first in case one of its hooks can import this module, # such as our own assertion-rewrite hook. for meta_importer in sys.meta_path: - spec = meta_importer.find_spec( - module_name, [str(module_location), str(module_path)] - ) + module_name_of_meta = getattr(meta_importer.__class__, "__module__", "") + if module_name_of_meta == "_pytest.assertion.rewrite" and module_path.is_file(): + # Import modules in subdirectories by module_path + # to ensure assertion rewrites are not missed (#12659). + find_spec_path = [str(module_location), str(module_path)] + else: + find_spec_path = [str(module_location)] + + spec = meta_importer.find_spec(module_name, find_spec_path) + if spec_matches_module_path(spec, module_path): break else: diff --git a/testing/test_pathlib.py b/testing/test_pathlib.py index a21d1edf970..5a13cd5a400 100644 --- a/testing/test_pathlib.py +++ b/testing/test_pathlib.py @@ -1498,6 +1498,34 @@ def test(): ] ) + def test_ns_multiple_levels_import_error( + self, + tmp_path: Path, + pytester: Pytester, + ) -> None: + # Trigger condition 1: ns and file with the same name + file = pytester.path / "cow/moo/moo.py" + file.parent.mkdir(parents=True) + file.write_text("data=123", encoding="utf-8") + + # Trigger condition 2: tests are located in ns + tests = pytester.path / "cow/moo/test_moo.py" + + tests.write_text( + dedent( + """ + from cow.moo.moo import data + + def test_moo(): + print(data) + """ + ), + encoding="utf-8", + ) + + result = pytester.runpytest("--import-mode=importlib") + assert result.ret == ExitCode.OK + @pytest.mark.parametrize("import_mode", ["prepend", "append", "importlib"]) def test_incorrect_namespace_package( self, From 495459dc880d1cb47cec30ae8a8be7111b3d9916 Mon Sep 17 00:00:00 2001 From: eitanwass Date: Mon, 2 Dec 2024 21:52:06 +0200 Subject: [PATCH 219/445] Fix parametrized mark over staticmethod decorator --- AUTHORS | 1 + changelog/12863.bugfix.rst | 1 + pyproject.toml | 2 +- src/_pytest/mark/structures.py | 6 +++++- testing/test_mark.py | 17 +++++++++++++++++ 5 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 changelog/12863.bugfix.rst diff --git a/AUTHORS b/AUTHORS index 3419accfa6b..9629e00bcfb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -150,6 +150,7 @@ Eric Yuan Erik Aronesty Erik Hasse Erik M. Bray +Ethan Wass Evan Kepner Evgeny Seliverstov Fabian Sturm diff --git a/changelog/12863.bugfix.rst b/changelog/12863.bugfix.rst new file mode 100644 index 00000000000..03b0c873ba3 --- /dev/null +++ b/changelog/12863.bugfix.rst @@ -0,0 +1 @@ +Fix :func:`pytest.mark.parametrize` marker placed above `@staticmethod` diff --git a/pyproject.toml b/pyproject.toml index dce6a0870e1..0a695e0247e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -334,7 +334,7 @@ disable = [ [tool.codespell] ignore-words-list = "afile,asend,asser,assertio,feld,hove,ned,noes,notin,paramete,parth,socio-economic,tesults,varius,wil" -skip = "*/plugin_list.rst" +skip = "AUTHORS,*/plugin_list.rst" write-changes = true [tool.check-wheel-contents] diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index ac64ef2d606..c07116655a8 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -350,7 +350,11 @@ def __call__(self, *args: object, **kwargs: object): func = args[0] is_class = inspect.isclass(func) if len(args) == 1 and (istestfunc(func) or is_class): - store_mark(func, self.mark, stacklevel=3) + if isinstance(func, staticmethod): + # If the marker decorates a staticmethod, store on the test func + store_mark(func.__func__, self.mark, stacklevel=3) + else: + store_mark(func, self.mark, stacklevel=3) return func return self.with_args(*args, **kwargs) diff --git a/testing/test_mark.py b/testing/test_mark.py index 89eef7920cf..9e9f87d5d31 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -1226,3 +1226,20 @@ def test_attrs(self): ) result = pytester.runpytest(foo) result.assert_outcomes(passed=1) + + +# @pytest.mark.issue("https://github.com/pytest-dev/pytest/issues/12863") +def test_mark_parametrize_over_staticmethod(pytester: Pytester) -> None: + foo = pytester.makepyfile( + """ + import pytest + + class TestClass: + @pytest.mark.parametrize("value", [1, 2]) + @staticmethod + def test_foo(value: int): + assert value in [1, 2] + """ + ) + result = pytester.runpytest(foo) + result.assert_outcomes(passed=2) From ec34f1c5b7a0878ce6cee1bdceab1e689f82a78e Mon Sep 17 00:00:00 2001 From: eitanwass Date: Tue, 3 Dec 2024 22:22:39 +0200 Subject: [PATCH 220/445] Fix compatibility with python pre-3.10 --- src/_pytest/mark/structures.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index c07116655a8..05208cf9b53 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -349,12 +349,9 @@ def __call__(self, *args: object, **kwargs: object): if args and not kwargs: func = args[0] is_class = inspect.isclass(func) - if len(args) == 1 and (istestfunc(func) or is_class): - if isinstance(func, staticmethod): - # If the marker decorates a staticmethod, store on the test func - store_mark(func.__func__, self.mark, stacklevel=3) - else: - store_mark(func, self.mark, stacklevel=3) + marking_func = func.__func__ if isinstance(func, staticmethod) else func + if len(args) == 1 and (istestfunc(marking_func) or is_class): + store_mark(marking_func, self.mark, stacklevel=3) return func return self.with_args(*args, **kwargs) From 27d1a2f7da5f642aca4a73ecd4662936e4b7ea28 Mon Sep 17 00:00:00 2001 From: eitanwass Date: Wed, 4 Dec 2024 19:37:29 +0200 Subject: [PATCH 221/445] Get any contained func when marking --- changelog/12863.bugfix.rst | 2 +- src/_pytest/mark/structures.py | 2 +- testing/test_mark.py | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/changelog/12863.bugfix.rst b/changelog/12863.bugfix.rst index 03b0c873ba3..ad4c6dbf4a3 100644 --- a/changelog/12863.bugfix.rst +++ b/changelog/12863.bugfix.rst @@ -1 +1 @@ -Fix :func:`pytest.mark.parametrize` marker placed above `@staticmethod` +Fix :func:`pytest.mark.parametrize ` marker placed above `@staticmethod` diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 05208cf9b53..bbdd4838610 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -349,7 +349,7 @@ def __call__(self, *args: object, **kwargs: object): if args and not kwargs: func = args[0] is_class = inspect.isclass(func) - marking_func = func.__func__ if isinstance(func, staticmethod) else func + marking_func = getattr(func, "__func__", func) if len(args) == 1 and (istestfunc(marking_func) or is_class): store_mark(marking_func, self.mark, stacklevel=3) return func diff --git a/testing/test_mark.py b/testing/test_mark.py index 9e9f87d5d31..dd132920217 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -1235,11 +1235,16 @@ def test_mark_parametrize_over_staticmethod(pytester: Pytester) -> None: import pytest class TestClass: + @pytest.mark.parametrize("value", [1, 2]) + @classmethod + def test_classmethod_wrapper(cls, value: int): + assert value in [1, 2] + @pytest.mark.parametrize("value", [1, 2]) @staticmethod - def test_foo(value: int): + def test_staticmethod_wrapper(value: int): assert value in [1, 2] """ ) result = pytester.runpytest(foo) - result.assert_outcomes(passed=2) + result.assert_outcomes(passed=4) From ec60713bfe223931abe7c049326e2d30d9efb21d Mon Sep 17 00:00:00 2001 From: eitanwass Date: Thu, 5 Dec 2024 19:05:42 +0200 Subject: [PATCH 222/445] Additional sanity tests, and fixes --- changelog/12863.bugfix.rst | 2 +- testing/test_mark.py | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/changelog/12863.bugfix.rst b/changelog/12863.bugfix.rst index ad4c6dbf4a3..97a26464bf3 100644 --- a/changelog/12863.bugfix.rst +++ b/changelog/12863.bugfix.rst @@ -1 +1 @@ -Fix :func:`pytest.mark.parametrize ` marker placed above `@staticmethod` +Fix :ref:`pytest.mark.parametrize ` marker placed above `@staticmethod` diff --git a/testing/test_mark.py b/testing/test_mark.py index dd132920217..c8109ae3a6c 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -1230,7 +1230,11 @@ def test_attrs(self): # @pytest.mark.issue("https://github.com/pytest-dev/pytest/issues/12863") def test_mark_parametrize_over_staticmethod(pytester: Pytester) -> None: - foo = pytester.makepyfile( + """Check that applying marks works as intended on classmethods and staticmethods. + + Regression test for #12863. + """ + pytester.makepyfile( """ import pytest @@ -1240,11 +1244,21 @@ class TestClass: def test_classmethod_wrapper(cls, value: int): assert value in [1, 2] + @classmethod + @pytest.mark.parametrize("value", [1, 2]) + def test_classmethod_wrapper_on_top(cls, value: int): + assert value in [1, 2] + @pytest.mark.parametrize("value", [1, 2]) @staticmethod def test_staticmethod_wrapper(value: int): assert value in [1, 2] + + @staticmethod + @pytest.mark.parametrize("value", [1, 2]) + def test_staticmethod_wrapper_on_top(value: int): + assert value in [1, 2] """ ) - result = pytester.runpytest(foo) - result.assert_outcomes(passed=4) + result = pytester.runpytest() + result.assert_outcomes(passed=8) From 37cf65912906b7402dbc7134ba4344f36243b931 Mon Sep 17 00:00:00 2001 From: eitanwass Date: Fri, 6 Dec 2024 08:38:44 +0200 Subject: [PATCH 223/445] More explicit edgecase of decorators --- changelog/12863.bugfix.rst | 2 +- src/_pytest/mark/structures.py | 10 +++++++--- testing/test_mark.py | 1 - 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/changelog/12863.bugfix.rst b/changelog/12863.bugfix.rst index 97a26464bf3..0b1c397a08e 100644 --- a/changelog/12863.bugfix.rst +++ b/changelog/12863.bugfix.rst @@ -1 +1 @@ -Fix :ref:`pytest.mark.parametrize ` marker placed above `@staticmethod` +Fix applying markers, including :ref:`pytest.mark.parametrize ` when placed above `@staticmethod` or `@classmethod`. diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index bbdd4838610..624b37cab94 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -349,9 +349,13 @@ def __call__(self, *args: object, **kwargs: object): if args and not kwargs: func = args[0] is_class = inspect.isclass(func) - marking_func = getattr(func, "__func__", func) - if len(args) == 1 and (istestfunc(marking_func) or is_class): - store_mark(marking_func, self.mark, stacklevel=3) + # For staticmethods/classmethods, the marks are eventually fetched from the + # function object, not the descriptor, so unwrap. + unwrapped_func = func + if isinstance(func, (staticmethod, classmethod)): + unwrapped_func = func.__func__ + if len(args) == 1 and (istestfunc(unwrapped_func) or is_class): + store_mark(unwrapped_func, self.mark, stacklevel=3) return func return self.with_args(*args, **kwargs) diff --git a/testing/test_mark.py b/testing/test_mark.py index c8109ae3a6c..60ee795cf43 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -1228,7 +1228,6 @@ def test_attrs(self): result.assert_outcomes(passed=1) -# @pytest.mark.issue("https://github.com/pytest-dev/pytest/issues/12863") def test_mark_parametrize_over_staticmethod(pytester: Pytester) -> None: """Check that applying marks works as intended on classmethods and staticmethods. From dd9b603f48a5294a46228d7f9b51de56aea97ef8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 15 Dec 2024 02:51:34 +0000 Subject: [PATCH 224/445] [automated] Update plugin list (#13060) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 158 +++++++++++++++++++------------ 1 file changed, 99 insertions(+), 59 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index f0e209008c6..63d91b6eb53 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =8.3 - :pypi:`logassert` Simple but powerful assertion and verification of logged lines. Nov 08, 2024 5 - Production/Stable N/A + :pypi:`logassert` Simple but powerful assertion and verification of logged lines. Dec 09, 2024 5 - Production/Stable N/A :pypi:`logot` Test whether your code is logging correctly 🪵 Mar 23, 2024 5 - Production/Stable pytest<9,>=7; extra == "pytest" :pypi:`nuts` Network Unit Testing System Jul 19, 2024 N/A pytest<8,>=7 :pypi:`pytest-abq` Pytest integration for the ABQ universal test runner. Apr 07, 2023 N/A N/A :pypi:`pytest-abstracts` A contextmanager pytest fixture for handling multiple mock abstracts May 25, 2022 N/A N/A - :pypi:`pytest-accept` A pytest-plugin for updating doctest outputs Sep 09, 2024 N/A pytest>=7 + :pypi:`pytest-accept` A pytest-plugin for updating doctest outputs Dec 08, 2024 N/A pytest>=7 :pypi:`pytest-adaptavist` pytest plugin for generating test execution results within Jira Test Management (tm4j) Oct 13, 2022 N/A pytest (>=5.4.0) :pypi:`pytest-adaptavist-fixed` pytest plugin for generating test execution results within Jira Test Management (tm4j) Nov 08, 2023 N/A pytest >=5.4.0 :pypi:`pytest-addons-test` 用于测试pytest的插件 Aug 02, 2021 N/A pytest (>=6.2.4,<7.0.0) @@ -78,7 +78,7 @@ This list contains 1554 plugins. :pypi:`pytest-anki` A pytest plugin for testing Anki add-ons Jul 31, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-annotate` pytest-annotate: Generate PyAnnotate annotations from your pytest tests. Jun 07, 2022 3 - Alpha pytest (<8.0.0,>=3.2.0) :pypi:`pytest-annotated` Pytest plugin to allow use of Annotated in tests to resolve fixtures Sep 30, 2024 N/A pytest>=8.3.3 - :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures Sep 11, 2024 5 - Production/Stable pytest>=6 + :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures Dec 12, 2024 5 - Production/Stable pytest>=6 :pypi:`pytest-ansible-playbook` Pytest fixture which runs given ansible playbook file. Mar 08, 2019 4 - Beta N/A :pypi:`pytest-ansible-playbook-runner` Pytest fixture which runs given ansible playbook file. Dec 02, 2020 4 - Beta pytest (>=3.1.0) :pypi:`pytest-ansible-units` A pytest plugin for running unit tests within an ansible collection Apr 14, 2022 N/A N/A @@ -115,7 +115,7 @@ This list contains 1554 plugins. :pypi:`pytest-ast-transformer` May 04, 2019 3 - Alpha pytest :pypi:`pytest_async` pytest-async - Run your coroutine in event loop without decorator Feb 26, 2020 N/A N/A :pypi:`pytest-async-generators` Pytest fixtures for async generators Jul 05, 2023 N/A N/A - :pypi:`pytest-asyncio` Pytest support for asyncio Aug 22, 2024 4 - Beta pytest<9,>=8.2 + :pypi:`pytest-asyncio` Pytest support for asyncio Dec 13, 2024 4 - Beta pytest<9,>=8.2 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Jul 04, 2024 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) :pypi:`pytest-async-mongodb` pytest plugin for async MongoDB Oct 18, 2017 5 - Production/Stable pytest (>=2.5.2) @@ -132,7 +132,6 @@ This list contains 1554 plugins. :pypi:`pytest-automock` Pytest plugin for automatical mocks creation May 16, 2023 N/A pytest ; extra == 'dev' :pypi:`pytest-auto-parametrize` pytest plugin: avoid repeating arguments in parametrize Oct 02, 2016 3 - Alpha N/A :pypi:`pytest-autotest` This fixture provides a configured "driver" for Android Automated Testing, using uiautomator2. Aug 25, 2021 N/A pytest - :pypi:`pytest-aux` all moved into module FUNCS_AUXt Oct 25, 2024 N/A N/A :pypi:`pytest-aviator` Aviator's Flakybot pytest plugin that automatically reruns flaky tests. Nov 04, 2022 4 - Beta pytest :pypi:`pytest-avoidance` Makes pytest skip tests that don not need rerunning May 23, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-aws` pytest plugin for testing AWS resource configurations Oct 04, 2017 4 - Beta N/A @@ -158,7 +157,7 @@ This list contains 1554 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Dec 06, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Dec 09, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -264,11 +263,11 @@ This list contains 1554 plugins. :pypi:`pytest_codeblocks` Test code blocks in your READMEs Sep 17, 2023 5 - Production/Stable pytest >= 7.0.0 :pypi:`pytest-codecarbon` Pytest plugin for measuring carbon emissions Jun 15, 2022 N/A pytest :pypi:`pytest-codecheckers` pytest plugin to add source code sanity checks (pep8 and friends) Feb 13, 2010 N/A N/A - :pypi:`pytest-codecov` Pytest plugin for uploading pytest-cov results to codecov.io Aug 21, 2024 4 - Beta pytest>=4.6.0 + :pypi:`pytest-codecov` Pytest plugin for uploading pytest-cov results to codecov.io Dec 11, 2024 4 - Beta pytest>=4.6.0 :pypi:`pytest-codegen` Automatically create pytest test signatures Aug 23, 2020 2 - Pre-Alpha N/A :pypi:`pytest-codeowners` Pytest plugin for selecting tests by GitHub CODEOWNERS. Mar 30, 2022 4 - Beta pytest (>=6.0.0) :pypi:`pytest-codestyle` pytest plugin to run pycodestyle Mar 23, 2020 3 - Alpha N/A - :pypi:`pytest-codspeed` Pytest plugin to create CodSpeed benchmarks Dec 06, 2024 5 - Production/Stable pytest>=3.8 + :pypi:`pytest-codspeed` Pytest plugin to create CodSpeed benchmarks Dec 09, 2024 5 - Production/Stable pytest>=3.8 :pypi:`pytest-collect-appoint-info` set your encoding Aug 03, 2023 N/A pytest :pypi:`pytest-collect-formatter` Formatter for pytest collect output Mar 29, 2021 5 - Production/Stable N/A :pypi:`pytest-collect-formatter2` Formatter for pytest collect output May 31, 2021 5 - Production/Stable N/A @@ -412,7 +411,7 @@ This list contains 1554 plugins. :pypi:`pytest-docker-butla` Jun 16, 2019 3 - Alpha N/A :pypi:`pytest-dockerc` Run, manage and stop Docker Compose project from Docker API Oct 09, 2020 5 - Production/Stable pytest (>=3.0) :pypi:`pytest-docker-compose` Manages Docker containers during your integration tests Jan 26, 2021 5 - Production/Stable pytest (>=3.3) - :pypi:`pytest-docker-compose-v2` Manages Docker containers during your integration tests Feb 28, 2024 4 - Beta pytest<8,>=7.2.2 + :pypi:`pytest-docker-compose-v2` Manages Docker containers during your integration tests Dec 11, 2024 4 - Beta pytest>=7.2.2 :pypi:`pytest-docker-db` A plugin to use docker databases for pytests Mar 20, 2021 5 - Production/Stable pytest (>=3.1.1) :pypi:`pytest-docker-fixtures` pytest docker fixtures Apr 03, 2024 3 - Alpha N/A :pypi:`pytest-docker-git-fixtures` Pytest fixtures for testing with git scm. Aug 12, 2024 4 - Beta pytest @@ -531,7 +530,7 @@ This list contains 1554 plugins. :pypi:`pytest_extra` Some helpers for writing tests with pytest. Aug 14, 2014 N/A N/A :pypi:`pytest-extra-durations` A pytest plugin to get durations on a per-function basis and per module basis. Apr 21, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-extra-markers` Additional pytest markers to dynamically enable/disable tests viia CLI flags Mar 05, 2023 4 - Beta pytest - :pypi:`pytest-f3ts` Pytest Plugin for communicating test results and information to a FixturFab Test Runner GUI Dec 03, 2024 N/A pytest<8.0.0,>=7.2.1 + :pypi:`pytest-f3ts` Pytest Plugin for communicating test results and information to a FixturFab Test Runner GUI Dec 11, 2024 N/A pytest<8.0.0,>=7.2.1 :pypi:`pytest-fabric` Provides test utilities to run fabric task tests by using docker containers Sep 12, 2018 5 - Production/Stable N/A :pypi:`pytest-factor` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A :pypi:`pytest-factory` Use factories for test setup with py.test Sep 06, 2020 3 - Alpha pytest (>4.3) @@ -604,12 +603,12 @@ This list contains 1554 plugins. :pypi:`pytest-freethreaded` pytest plugin for running parallel tests Oct 03, 2024 5 - Production/Stable pytest :pypi:`pytest-freezeblaster` Wrap tests with fixtures in freeze_time Jul 10, 2024 N/A pytest>=6.2.5 :pypi:`pytest-freezegun` Wrap tests with fixtures in freeze_time Jul 19, 2020 4 - Beta pytest (>=3.0.0) - :pypi:`pytest-freezer` Pytest plugin providing a fixture interface for spulec/freezegun Jun 21, 2023 N/A pytest >= 3.6 + :pypi:`pytest-freezer` Pytest plugin providing a fixture interface for spulec/freezegun Dec 12, 2024 N/A pytest>=3.6 :pypi:`pytest-freeze-reqs` Check if requirement files are frozen Apr 29, 2021 N/A N/A :pypi:`pytest-frozen-uuids` Deterministically frozen UUID's for your tests Apr 17, 2022 N/A pytest (>=3.0) :pypi:`pytest-func-cov` Pytest plugin for measuring function coverage Apr 15, 2021 3 - Alpha pytest (>=5) :pypi:`pytest-funparam` An alternative way to parametrize test cases. Dec 02, 2021 4 - Beta pytest >=4.6.0 - :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Nov 16, 2024 N/A pytest + :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Dec 12, 2024 N/A pytest :pypi:`pytest-fxa` pytest plugin for Firefox Accounts Aug 28, 2018 5 - Production/Stable N/A :pypi:`pytest-fxa-mte` pytest plugin for Firefox Accounts Oct 02, 2024 5 - Production/Stable N/A :pypi:`pytest-fxtest` Oct 27, 2020 N/A N/A @@ -619,7 +618,7 @@ This list contains 1554 plugins. :pypi:`pytest-gc` The garbage collector plugin for py.test Feb 01, 2018 N/A N/A :pypi:`pytest-gcov` Uses gcov to measure test coverage of a C library Feb 01, 2018 3 - Alpha N/A :pypi:`pytest-gcs` GCS fixtures and fixture factories for Pytest. Mar 01, 2024 5 - Production/Stable pytest >=6.2 - :pypi:`pytest-gee` The Python plugin for your GEE based packages. Dec 06, 2024 3 - Alpha pytest + :pypi:`pytest-gee` The Python plugin for your GEE based packages. Dec 12, 2024 3 - Alpha pytest :pypi:`pytest-gevent` Ensure that gevent is properly patched when invoking pytest Feb 25, 2020 N/A pytest :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest @@ -668,7 +667,7 @@ This list contains 1554 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Dec 07, 2024 3 - Alpha pytest==8.3.3 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Dec 14, 2024 3 - Alpha pytest==8.3.3 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -717,13 +716,14 @@ This list contains 1554 plugins. :pypi:`pytest-info-collector` pytest plugin to collect information from tests May 26, 2019 3 - Alpha N/A :pypi:`pytest-info-plugin` Get executed interface information in pytest interface automation framework Sep 14, 2023 N/A N/A :pypi:`pytest-informative-node` display more node ininformation. Apr 25, 2019 4 - Beta N/A + :pypi:`pytest-infrahouse` A set of fixtures to use with pytest Dec 12, 2024 4 - Beta pytest~=8.3 :pypi:`pytest-infrastructure` pytest stack validation prior to testing executing Apr 12, 2020 4 - Beta N/A :pypi:`pytest-ini` Reuse pytest.ini to store env variables Apr 26, 2022 N/A N/A :pypi:`pytest-initry` Plugin for sending automation test data from Pytest to the initry Apr 30, 2024 N/A pytest<9.0.0,>=8.1.1 :pypi:`pytest-inline` A pytest plugin for writing inline tests Oct 24, 2024 4 - Beta pytest<9.0,>=7.0 :pypi:`pytest-inmanta` A py.test plugin providing fixtures to simplify inmanta modules testing. Oct 10, 2024 5 - Production/Stable pytest :pypi:`pytest-inmanta-extensions` Inmanta tests package Oct 10, 2024 5 - Production/Stable N/A - :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Nov 26, 2024 5 - Production/Stable N/A + :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Dec 13, 2024 5 - Production/Stable N/A :pypi:`pytest-inmanta-yang` Common fixtures used in inmanta yang related modules Feb 22, 2024 4 - Beta pytest :pypi:`pytest-Inomaly` A simple image diff plugin for pytest Feb 13, 2018 4 - Beta N/A :pypi:`pytest-in-robotframework` The extension enables easy execution of pytest tests within the Robot Framework environment. Nov 23, 2024 N/A pytest @@ -777,7 +777,7 @@ This list contains 1554 plugins. :pypi:`pytest-kasima` Display horizontal lines above and below the captured standard output for easy viewing. Jan 26, 2023 5 - Production/Stable pytest (>=7.2.1,<8.0.0) :pypi:`pytest-keep-together` Pytest plugin to customize test ordering by running all 'related' tests together Dec 07, 2022 5 - Production/Stable pytest :pypi:`pytest-kexi` Apr 29, 2022 N/A pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-keyring` A Pytest plugin to access the system's keyring to provide credentials for tests Sep 05, 2024 N/A pytest>=8.0.2 + :pypi:`pytest-keyring` A Pytest plugin to access the system's keyring to provide credentials for tests Dec 08, 2024 N/A pytest>=8.0.2 :pypi:`pytest-kind` Kubernetes test support with KIND for pytest Nov 30, 2022 5 - Production/Stable N/A :pypi:`pytest-kivy` Kivy GUI tests fixtures using pytest Jul 06, 2021 4 - Beta pytest (>=3.6) :pypi:`pytest-knows` A pytest plugin that can automaticly skip test case based on dependence info calculated by trace Aug 22, 2014 N/A N/A @@ -863,6 +863,7 @@ This list contains 1554 plugins. :pypi:`pytest-memray` A simple plugin to use with pytest Jul 25, 2024 N/A pytest>=7.2 :pypi:`pytest-menu` A pytest plugin for console based interactive test selection just after the collection phase Oct 04, 2017 3 - Alpha pytest (>=2.4.2) :pypi:`pytest-mercurial` pytest plugin to write integration tests for projects using Mercurial Python internals Nov 21, 2020 1 - Planning N/A + :pypi:`pytest-mergify` Pytest plugin for Mergify Dec 11, 2024 N/A N/A :pypi:`pytest-mesh` pytest_mesh插件 Aug 05, 2022 N/A pytest (==7.1.2) :pypi:`pytest-message` Pytest plugin for sending report message of marked tests execution Aug 04, 2022 N/A pytest (>=6.2.5) :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A @@ -919,7 +920,7 @@ This list contains 1554 plugins. :pypi:`pytest-mypy-plugins-shim` Substitute for "pytest-mypy-plugins" for Python implementations which aren't supported by mypy. Apr 12, 2021 N/A pytest>=6.0.0 :pypi:`pytest-mypy-runner` Run the mypy static type checker as a pytest test case Apr 23, 2024 N/A pytest>=8.0 :pypi:`pytest-mypy-testing` Pytest plugin to check mypy output. Mar 04, 2024 N/A pytest>=7,<9 - :pypi:`pytest-mysql` MySQL process and client fixtures for pytest May 23, 2024 5 - Production/Stable pytest>=6.2 + :pypi:`pytest-mysql` MySQL process and client fixtures for pytest Dec 10, 2024 5 - Production/Stable pytest>=6.2 :pypi:`pytest-ndb` pytest notebook debugger Apr 28, 2024 N/A pytest :pypi:`pytest-needle` pytest plugin for visual testing websites using selenium Dec 10, 2018 4 - Beta pytest (<5.0.0,>=3.0.0) :pypi:`pytest-neo` pytest-neo is a plugin for pytest that shows tests like screen of Matrix. Jan 08, 2022 3 - Alpha pytest (>=6.2.0) @@ -987,6 +988,7 @@ This list contains 1554 plugins. :pypi:`pytest-param` pytest plugin to test all, first, last or random params Sep 11, 2016 4 - Beta pytest (>=2.6.0) :pypi:`pytest-paramark` Configure pytest fixtures using a combination of"parametrize" and markers Jan 10, 2020 4 - Beta pytest (>=4.5.0) :pypi:`pytest-parametrization` Simpler PyTest parametrization May 22, 2022 5 - Production/Stable N/A + :pypi:`pytest-parametrization-annotation` A pytest library for parametrizing tests using type hints. Dec 10, 2024 5 - Production/Stable pytest>=7 :pypi:`pytest-parametrize` pytest decorator for parametrizing test cases in a dict-way Nov 10, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.0 :pypi:`pytest-parametrize-cases` A more user-friendly way to write parametrized tests. Mar 13, 2022 N/A pytest (>=6.1.2) :pypi:`pytest-parametrized` Pytest decorator for parametrizing tests with default iterables. Oct 22, 2024 5 - Production/Stable pytest @@ -1070,7 +1072,7 @@ This list contains 1554 plugins. :pypi:`pytest-prometheus` Report test pass / failures to a Prometheus PushGateway Oct 03, 2017 N/A N/A :pypi:`pytest-prometheus-pushgateway` Pytest report plugin for Zulip Sep 27, 2022 5 - Production/Stable pytest :pypi:`pytest-prosper` Test helpers for Prosper projects Sep 24, 2018 N/A N/A - :pypi:`pytest-prysk` Pytest plugin for prysk Mar 12, 2024 4 - Beta pytest (>=7.3.2) + :pypi:`pytest-prysk` Pytest plugin for prysk Dec 10, 2024 4 - Beta pytest>=7.3.2 :pypi:`pytest-pspec` A rspec format reporter for Python ptest Jun 02, 2020 4 - Beta pytest (>=3.0.0) :pypi:`pytest-psqlgraph` pytest plugin for testing applications that use psqlgraph Oct 19, 2021 4 - Beta pytest (>=6.0) :pypi:`pytest-pt` pytest plugin to use \*.pt files as tests Sep 22, 2024 5 - Production/Stable pytest @@ -1163,6 +1165,7 @@ This list contains 1554 plugins. :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Oct 11, 2024 4 - Beta N/A :pypi:`pytest-reporter-html-dots` A basic HTML report for pytest using Jinja2 template engine. Jan 22, 2023 N/A N/A + :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports of webtest projects by adding screenshots, comments and webpage sources. Dec 14, 2024 N/A pytest>=7.0.0 :pypi:`pytest-reportinfra` Pytest plugin for reportinfra Aug 11, 2019 3 - Alpha N/A :pypi:`pytest-reporting` A plugin to report summarized results in a table format Oct 25, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-reportlog` Replacement for the --resultlog option, focused in simplicity and extensibility May 22, 2023 3 - Alpha pytest @@ -1195,14 +1198,15 @@ This list contains 1554 plugins. :pypi:`pytest-restrict` Pytest plugin to restrict the test types allowed Oct 24, 2024 5 - Production/Stable pytest :pypi:`pytest-result-log` A pytest plugin that records the start, end, and result information of each use case in a log file Jan 10, 2024 N/A pytest>=7.2.0 :pypi:`pytest-result-sender` Apr 20, 2023 N/A pytest>=7.3.1 + :pypi:`pytest-result-sender-lj` Default template for PDM package Dec 14, 2024 N/A pytest>=8.3.4 :pypi:`pytest-resume` A Pytest plugin to resuming from the last run test Apr 22, 2023 4 - Beta pytest (>=7.0) :pypi:`pytest-rethinkdb` A RethinkDB plugin for pytest. Jul 24, 2016 4 - Beta N/A :pypi:`pytest-retry` Adds the ability to retry flaky tests in CI environments May 14, 2024 N/A pytest>=7.0.0 :pypi:`pytest-retry-class` A pytest plugin to rerun entire class on failure Nov 24, 2024 N/A pytest>=5.3 :pypi:`pytest-reusable-testcases` Apr 28, 2023 N/A N/A - :pypi:`pytest-revealtype-injector` Pytest plugin for replacing reveal_type() calls inside test functions with static and runtime type checking result comparison, for confirming type annotation validity. Dec 03, 2024 4 - Beta pytest>=7.0 + :pypi:`pytest-revealtype-injector` Pytest plugin for replacing reveal_type() calls inside test functions with static and runtime type checking result comparison, for confirming type annotation validity. Dec 14, 2024 4 - Beta pytest>=7.0 :pypi:`pytest-reverse` Pytest plugin to reverse test order. Oct 25, 2024 5 - Production/Stable pytest - :pypi:`pytest-rich` Leverage rich for richer test session output Mar 03, 2022 4 - Beta pytest (>=7.0) + :pypi:`pytest-rich` Leverage rich for richer test session output Dec 12, 2024 4 - Beta pytest>=7.0 :pypi:`pytest-richer` Pytest plugin providing a Rich based reporter. Oct 27, 2023 3 - Alpha pytest :pypi:`pytest-rich-reporter` A pytest plugin using Rich for beautiful test result formatting. Feb 17, 2022 1 - Planning pytest (>=5.0.0) :pypi:`pytest-richtrace` A pytest plugin that displays the names and information of the pytest hook functions as they are executed. Jun 20, 2023 N/A N/A @@ -1236,7 +1240,7 @@ This list contains 1554 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Dec 06, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Dec 13, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1247,7 +1251,7 @@ This list contains 1554 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Dec 06, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Dec 13, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -1293,7 +1297,7 @@ This list contains 1554 plugins. :pypi:`pytest-smartcollect` A plugin for collecting tests that touch changed code Oct 04, 2018 N/A pytest (>=3.5.0) :pypi:`pytest-smartcov` Smart coverage plugin for pytest. Sep 30, 2017 3 - Alpha N/A :pypi:`pytest-smell` Automated bad smell detection tool for Pytest Jun 26, 2022 N/A N/A - :pypi:`pytest-smoke` Pytest plugin for smoke testing Nov 27, 2024 4 - Beta pytest<9,>=7.0.0 + :pypi:`pytest-smoke` Pytest plugin for smoke testing Dec 13, 2024 4 - Beta pytest<9,>=7.0.0 :pypi:`pytest-smtp` Send email with pytest execution result Feb 20, 2021 N/A pytest :pypi:`pytest-smtp4dev` Plugin for smtp4dev API Jun 27, 2023 5 - Production/Stable N/A :pypi:`pytest-smtpd` An SMTP server for testing built on aiosmtpd May 15, 2023 N/A pytest @@ -1362,7 +1366,7 @@ This list contains 1554 plugins. :pypi:`pytest-subinterpreter` Run pytest in a subinterpreter Nov 25, 2023 N/A pytest>=7.0.0 :pypi:`pytest-subprocess` A plugin to fake subprocess for pytest Jul 24, 2024 5 - Production/Stable pytest>=4.0.0 :pypi:`pytest-subtesthack` A hack to explicitly set up and tear down fixtures. Jul 16, 2022 N/A N/A - :pypi:`pytest-subtests` unittest subTest() support and subtests fixture Dec 07, 2024 4 - Beta pytest>=7.4 + :pypi:`pytest-subtests` unittest subTest() support and subtests fixture Dec 10, 2024 4 - Beta pytest>=7.4 :pypi:`pytest-subunit` pytest-subunit is a plugin for py.test which outputs testsresult in subunit format. Sep 17, 2023 N/A pytest (>=2.3) :pypi:`pytest-sugar` pytest-sugar is a plugin for pytest that changes the default look and feel of pytest (e.g. progressbar, show tests that fail instantly). Feb 01, 2024 4 - Beta pytest >=6.2.0 :pypi:`pytest-suitemanager` A simple plugin to use with pytest Apr 28, 2023 4 - Beta N/A @@ -1379,6 +1383,7 @@ This list contains 1554 plugins. :pypi:`pytest-tap` Test Anything Protocol (TAP) reporting plugin for pytest Jul 15, 2023 5 - Production/Stable pytest (>=3.0) :pypi:`pytest-tape` easy assertion with expected results saved to yaml files Mar 17, 2021 4 - Beta N/A :pypi:`pytest-target` Pytest plugin for remote target orchestration. Jan 21, 2021 3 - Alpha pytest (>=6.1.2,<7.0.0) + :pypi:`pytest-taskgraph` Add your description here Dec 12, 2024 N/A pytest :pypi:`pytest-tblineinfo` tblineinfo is a py.test plugin that insert the node id in the final py.test report when --tb=line option is used Dec 01, 2015 3 - Alpha pytest (>=2.0) :pypi:`pytest-tcpclient` A pytest plugin for testing TCP clients Nov 16, 2022 N/A pytest (<8,>=7.1.3) :pypi:`pytest-tdd` run pytest on a python module Aug 18, 2023 4 - Beta N/A @@ -1601,7 +1606,7 @@ This list contains 1554 plugins. Python Testing for Databricks :pypi:`logassert` - *last release*: Nov 08, 2024, + *last release*: Dec 09, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -1636,7 +1641,7 @@ This list contains 1554 plugins. A contextmanager pytest fixture for handling multiple mock abstracts :pypi:`pytest-accept` - *last release*: Sep 09, 2024, + *last release*: Dec 08, 2024, *status*: N/A, *requires*: pytest>=7 @@ -1902,7 +1907,7 @@ This list contains 1554 plugins. Pytest plugin to allow use of Annotated in tests to resolve fixtures :pypi:`pytest-ansible` - *last release*: Sep 11, 2024, + *last release*: Dec 12, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=6 @@ -2161,7 +2166,7 @@ This list contains 1554 plugins. Pytest fixtures for async generators :pypi:`pytest-asyncio` - *last release*: Aug 22, 2024, + *last release*: Dec 13, 2024, *status*: 4 - Beta, *requires*: pytest<9,>=8.2 @@ -2279,13 +2284,6 @@ This list contains 1554 plugins. This fixture provides a configured "driver" for Android Automated Testing, using uiautomator2. - :pypi:`pytest-aux` - *last release*: Oct 25, 2024, - *status*: N/A, - *requires*: N/A - - all moved into module FUNCS_AUXt - :pypi:`pytest-aviator` *last release*: Nov 04, 2022, *status*: 4 - Beta, @@ -2462,7 +2460,7 @@ This list contains 1554 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Dec 06, 2024, + *last release*: Dec 09, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -3204,7 +3202,7 @@ This list contains 1554 plugins. pytest plugin to add source code sanity checks (pep8 and friends) :pypi:`pytest-codecov` - *last release*: Aug 21, 2024, + *last release*: Dec 11, 2024, *status*: 4 - Beta, *requires*: pytest>=4.6.0 @@ -3232,7 +3230,7 @@ This list contains 1554 plugins. pytest plugin to run pycodestyle :pypi:`pytest-codspeed` - *last release*: Dec 06, 2024, + *last release*: Dec 09, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=3.8 @@ -4240,9 +4238,9 @@ This list contains 1554 plugins. Manages Docker containers during your integration tests :pypi:`pytest-docker-compose-v2` - *last release*: Feb 28, 2024, + *last release*: Dec 11, 2024, *status*: 4 - Beta, - *requires*: pytest<8,>=7.2.2 + *requires*: pytest>=7.2.2 Manages Docker containers during your integration tests @@ -5073,7 +5071,7 @@ This list contains 1554 plugins. Additional pytest markers to dynamically enable/disable tests viia CLI flags :pypi:`pytest-f3ts` - *last release*: Dec 03, 2024, + *last release*: Dec 11, 2024, *status*: N/A, *requires*: pytest<8.0.0,>=7.2.1 @@ -5584,9 +5582,9 @@ This list contains 1554 plugins. Wrap tests with fixtures in freeze_time :pypi:`pytest-freezer` - *last release*: Jun 21, 2023, + *last release*: Dec 12, 2024, *status*: N/A, - *requires*: pytest >= 3.6 + *requires*: pytest>=3.6 Pytest plugin providing a fixture interface for spulec/freezegun @@ -5619,7 +5617,7 @@ This list contains 1554 plugins. An alternative way to parametrize test cases. :pypi:`pytest-fv` - *last release*: Nov 16, 2024, + *last release*: Dec 12, 2024, *status*: N/A, *requires*: pytest @@ -5689,7 +5687,7 @@ This list contains 1554 plugins. GCS fixtures and fixture factories for Pytest. :pypi:`pytest-gee` - *last release*: Dec 06, 2024, + *last release*: Dec 12, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -6032,7 +6030,7 @@ This list contains 1554 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Dec 07, 2024, + *last release*: Dec 14, 2024, *status*: 3 - Alpha, *requires*: pytest==8.3.3 @@ -6374,6 +6372,13 @@ This list contains 1554 plugins. display more node ininformation. + :pypi:`pytest-infrahouse` + *last release*: Dec 12, 2024, + *status*: 4 - Beta, + *requires*: pytest~=8.3 + + A set of fixtures to use with pytest + :pypi:`pytest-infrastructure` *last release*: Apr 12, 2020, *status*: 4 - Beta, @@ -6417,7 +6422,7 @@ This list contains 1554 plugins. Inmanta tests package :pypi:`pytest-inmanta-lsm` - *last release*: Nov 26, 2024, + *last release*: Dec 13, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -6795,7 +6800,7 @@ This list contains 1554 plugins. :pypi:`pytest-keyring` - *last release*: Sep 05, 2024, + *last release*: Dec 08, 2024, *status*: N/A, *requires*: pytest>=8.0.2 @@ -7396,6 +7401,13 @@ This list contains 1554 plugins. pytest plugin to write integration tests for projects using Mercurial Python internals + :pypi:`pytest-mergify` + *last release*: Dec 11, 2024, + *status*: N/A, + *requires*: N/A + + Pytest plugin for Mergify + :pypi:`pytest-mesh` *last release*: Aug 05, 2022, *status*: N/A, @@ -7789,7 +7801,7 @@ This list contains 1554 plugins. Pytest plugin to check mypy output. :pypi:`pytest-mysql` - *last release*: May 23, 2024, + *last release*: Dec 10, 2024, *status*: 5 - Production/Stable, *requires*: pytest>=6.2 @@ -8264,6 +8276,13 @@ This list contains 1554 plugins. Simpler PyTest parametrization + :pypi:`pytest-parametrization-annotation` + *last release*: Dec 10, 2024, + *status*: 5 - Production/Stable, + *requires*: pytest>=7 + + A pytest library for parametrizing tests using type hints. + :pypi:`pytest-parametrize` *last release*: Nov 10, 2024, *status*: 5 - Production/Stable, @@ -8846,9 +8865,9 @@ This list contains 1554 plugins. Test helpers for Prosper projects :pypi:`pytest-prysk` - *last release*: Mar 12, 2024, + *last release*: Dec 10, 2024, *status*: 4 - Beta, - *requires*: pytest (>=7.3.2) + *requires*: pytest>=7.3.2 Pytest plugin for prysk @@ -9496,6 +9515,13 @@ This list contains 1554 plugins. A basic HTML report for pytest using Jinja2 template engine. + :pypi:`pytest-report-extras` + *last release*: Dec 14, 2024, + *status*: N/A, + *requires*: pytest>=7.0.0 + + Pytest plugin to enhance pytest-html and allure reports of webtest projects by adding screenshots, comments and webpage sources. + :pypi:`pytest-reportinfra` *last release*: Aug 11, 2019, *status*: 3 - Alpha, @@ -9720,6 +9746,13 @@ This list contains 1554 plugins. + :pypi:`pytest-result-sender-lj` + *last release*: Dec 14, 2024, + *status*: N/A, + *requires*: pytest>=8.3.4 + + Default template for PDM package + :pypi:`pytest-resume` *last release*: Apr 22, 2023, *status*: 4 - Beta, @@ -9756,7 +9789,7 @@ This list contains 1554 plugins. :pypi:`pytest-revealtype-injector` - *last release*: Dec 03, 2024, + *last release*: Dec 14, 2024, *status*: 4 - Beta, *requires*: pytest>=7.0 @@ -9770,9 +9803,9 @@ This list contains 1554 plugins. Pytest plugin to reverse test order. :pypi:`pytest-rich` - *last release*: Mar 03, 2022, + *last release*: Dec 12, 2024, *status*: 4 - Beta, - *requires*: pytest (>=7.0) + *requires*: pytest>=7.0 Leverage rich for richer test session output @@ -10008,7 +10041,7 @@ This list contains 1554 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Dec 06, 2024, + *last release*: Dec 13, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10085,7 +10118,7 @@ This list contains 1554 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Dec 06, 2024, + *last release*: Dec 13, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10407,7 +10440,7 @@ This list contains 1554 plugins. Automated bad smell detection tool for Pytest :pypi:`pytest-smoke` - *last release*: Nov 27, 2024, + *last release*: Dec 13, 2024, *status*: 4 - Beta, *requires*: pytest<9,>=7.0.0 @@ -10890,7 +10923,7 @@ This list contains 1554 plugins. A hack to explicitly set up and tear down fixtures. :pypi:`pytest-subtests` - *last release*: Dec 07, 2024, + *last release*: Dec 10, 2024, *status*: 4 - Beta, *requires*: pytest>=7.4 @@ -11008,6 +11041,13 @@ This list contains 1554 plugins. Pytest plugin for remote target orchestration. + :pypi:`pytest-taskgraph` + *last release*: Dec 12, 2024, + *status*: N/A, + *requires*: pytest + + Add your description here + :pypi:`pytest-tblineinfo` *last release*: Dec 01, 2015, *status*: 3 - Alpha, From 1d4f7309651fc62420a6f8a0ea6d3601e04ce110 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 03:36:19 +0000 Subject: [PATCH 225/445] build(deps): Bump hynek/build-and-inspect-python-package Bumps [hynek/build-and-inspect-python-package](https://github.com/hynek/build-and-inspect-python-package) from 2.10.0 to 2.11.0. - [Release notes](https://github.com/hynek/build-and-inspect-python-package/releases) - [Changelog](https://github.com/hynek/build-and-inspect-python-package/blob/main/CHANGELOG.md) - [Commits](https://github.com/hynek/build-and-inspect-python-package/compare/v2.10.0...v2.11.0) --- updated-dependencies: - dependency-name: hynek/build-and-inspect-python-package dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/deploy.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3d3cb7534a4..b111be9a572 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,7 +31,7 @@ jobs: persist-credentials: false - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v2.10.0 + uses: hynek/build-and-inspect-python-package@v2.11.0 with: attest-build-provenance-github: 'true' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 30536706afb..4058716b47d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,7 +40,7 @@ jobs: fetch-depth: 0 persist-credentials: false - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v2.10.0 + uses: hynek/build-and-inspect-python-package@v2.11.0 build: needs: [package] From 4da57defe06274fa73d9312ce49c242f704e4f25 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 03:36:21 +0000 Subject: [PATCH 226/445] build(deps): Bump pypa/gh-action-pypi-publish from 1.12.2 to 1.12.3 Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.12.2 to 1.12.3. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.12.2...v1.12.3) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3d3cb7534a4..c1f7013240a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -54,7 +54,7 @@ jobs: path: dist - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@v1.12.2 + uses: pypa/gh-action-pypi-publish@v1.12.3 with: attestations: true From ee8f98d2f976a1df17093eab12e00f0f3c4bee29 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Mon, 16 Dec 2024 07:48:05 +0200 Subject: [PATCH 227/445] ci: harden github actions according to "zizmor" recommendations (#13062) Fix all issues reported by zizmor 0.9.2 running locally. See: https://woodruffw.github.io/zizmor/ --- .github/workflows/deploy.yml | 12 +++++++++--- .github/workflows/prepare-release-pr.yml | 11 +++++++++-- .github/workflows/update-plugin-list.yml | 6 ++++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 53a0ad4c2af..32d55361e54 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -46,6 +46,8 @@ jobs: contents: write steps: - uses: actions/checkout@v4 + with: + persist-credentials: true - name: Download Package uses: actions/download-artifact@v4 @@ -59,11 +61,13 @@ jobs: attestations: true - name: Push tag + env: + VERSION: ${{ github.event.inputs.version }} run: | git config user.name "pytest bot" git config user.email "pytestbot@gmail.com" - git tag --annotate --message=v${{ github.event.inputs.version }} ${{ github.event.inputs.version }} ${{ github.sha }} - git push origin ${{ github.event.inputs.version }} + git tag --annotate --message=v"$VERSION" "$VERSION" ${{ github.sha }} + git push origin "$VERSION" release-notes: @@ -98,9 +102,11 @@ jobs: pip install --upgrade tox - name: Generate release notes + env: + VERSION: ${{ github.event.inputs.version }} run: | sudo apt-get install pandoc - tox -e generate-gh-release-notes -- ${{ github.event.inputs.version }} scripts/latest-release-notes.md + tox -e generate-gh-release-notes -- "$VERSION" scripts/latest-release-notes.md - name: Publish GitHub Release uses: softprops/action-gh-release@v2 diff --git a/.github/workflows/prepare-release-pr.yml b/.github/workflows/prepare-release-pr.yml index f46b5cecda5..b803ba8517b 100644 --- a/.github/workflows/prepare-release-pr.yml +++ b/.github/workflows/prepare-release-pr.yml @@ -30,6 +30,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 + persist-credentials: false - name: Set up Python uses: actions/setup-python@v5 @@ -43,10 +44,16 @@ jobs: - name: Prepare release PR (minor/patch release) if: github.event.inputs.major == 'no' + env: + BRANCH: ${{ github.event.inputs.branch }} + PRERELEASE: ${{ github.event.inputs.prerelease }} run: | - tox -e prepare-release-pr -- ${{ github.event.inputs.branch }} ${{ github.token }} --prerelease='${{ github.event.inputs.prerelease }}' + tox -e prepare-release-pr -- "$BRANCH" ${{ github.token }} --prerelease="$PRERELEASE" - name: Prepare release PR (major release) if: github.event.inputs.major == 'yes' + env: + BRANCH: ${{ github.event.inputs.branch }} + PRERELEASE: ${{ github.event.inputs.prerelease }} run: | - tox -e prepare-release-pr -- ${{ github.event.inputs.branch }} ${{ github.token }} --major --prerelease='${{ github.event.inputs.prerelease }}' + tox -e prepare-release-pr -- "$BRANCH" ${{ github.token }} --major --prerelease="$PRERELEASE" diff --git a/.github/workflows/update-plugin-list.yml b/.github/workflows/update-plugin-list.yml index 0c76b91843c..ce3e9fd5230 100644 --- a/.github/workflows/update-plugin-list.yml +++ b/.github/workflows/update-plugin-list.yml @@ -23,12 +23,14 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + persist-credentials: false - name: Setup Python uses: actions/setup-python@v5 with: python-version: "3.11" cache: pip + - name: requests-cache uses: actions/cache@v4 with: @@ -41,7 +43,6 @@ jobs: python -m pip install --upgrade pip pip install packaging requests tabulate[widechars] tqdm requests-cache platformdirs - - name: Update Plugin List run: python scripts/update-plugin-list.py @@ -61,8 +62,9 @@ jobs: - name: Instruct the maintainers to trigger CI by undrafting the PR env: GITHUB_TOKEN: ${{ github.token }} + PULL_REQUEST_NUMBER: ${{ steps.pr.outputs.pull-request-number }} run: >- gh pr comment --body 'Please mark the PR as ready for review to trigger PR checks.' --repo '${{ github.repository }}' - '${{ steps.pr.outputs.pull-request-number }}' + "$PULL_REQUEST_NUMBER" From 9b92c41bc6b83c18509b6e86cbf69daeb003bf7c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 07:23:31 +0100 Subject: [PATCH 228/445] build(deps): Bump pytest-asyncio in /testing/plugins_integration (#13065) Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.24.0 to 0.25.0. - [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases) - [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.24.0...v0.25.0) --- updated-dependencies: - dependency-name: pytest-asyncio dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 4abe0bd6deb..74be0367cdc 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,6 +1,6 @@ anyio[curio,trio]==4.7.0 django==5.1.4 -pytest-asyncio==0.24.0 +pytest-asyncio==0.25.0 pytest-bdd==8.1.0 pytest-cov==6.0.0 pytest-django==4.9.0 From 6b3dadc9cce0d63e62dd72193d7ef8a7ae8dd38b Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Mon, 16 Dec 2024 13:21:31 +0200 Subject: [PATCH 229/445] pre-commit: add zizmor hook Ensure we don't regress. --- .pre-commit-config.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d73ac5baee0..8937a1ff9ac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,6 +11,10 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml +- repo: https://github.com/woodruffw/zizmor-pre-commit + rev: v0.9.2 + hooks: + - id: zizmor - repo: https://github.com/adamchainz/blacken-docs rev: 1.19.1 hooks: From b39b871e79868fd1966d181dfc9c115caabc1ec5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Dec 2024 07:04:38 +0100 Subject: [PATCH 230/445] [pre-commit.ci] pre-commit autoupdate (#13071) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.2 → v0.8.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.2...v0.8.3) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8937a1ff9ac..d7a4efabe98 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.8.2" + rev: "v0.8.3" hooks: - id: ruff args: ["--fix"] From 868e1d225e443984a6aa29cfde2d1231eb03ed41 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 18 Dec 2024 11:09:33 +0000 Subject: [PATCH 231/445] apply warnings filter as soon as possible, and remove it as late as possible (#13057) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 1 + changelog/10404.bugfix.rst | 7 ++ pyproject.toml | 3 + src/_pytest/config/__init__.py | 8 +- src/_pytest/pytester.py | 4 +- src/_pytest/warning_types.py | 7 ++ src/_pytest/warnings.py | 59 ++++++++----- src/pytest/__init__.py | 2 + testing/test_unraisableexception.py | 124 ++++++++++++++++++++++++++-- 9 files changed, 181 insertions(+), 34 deletions(-) create mode 100644 changelog/10404.bugfix.rst diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4058716b47d..5814c81fb30 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -123,6 +123,7 @@ jobs: python: "3.9" os: ubuntu-latest tox_env: "py39-lsof-numpy-pexpect" + use_coverage: true - name: "ubuntu-py39-pluggy" python: "3.9" diff --git a/changelog/10404.bugfix.rst b/changelog/10404.bugfix.rst new file mode 100644 index 00000000000..4c98ea03d64 --- /dev/null +++ b/changelog/10404.bugfix.rst @@ -0,0 +1,7 @@ +Apply filterwarnings from config/cli as soon as possible, and revert them as late as possible +so that warnings as errors are collected throughout the pytest run and before the +unraisable and threadexcept hooks are removed. + +This allows very late warnings and unraisable/threadexcept exceptions to fail the test suite. + +This also changes the warning that the lsof plugin issues from PytestWarning to the new warning PytestFDWarning so it can be more easily filtered. diff --git a/pyproject.toml b/pyproject.toml index 0a695e0247e..df633e0a092 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -403,6 +403,9 @@ filterwarnings = [ "ignore:VendorImporter\\.find_spec\\(\\) not found; falling back to find_module\\(\\):ImportWarning", # https://github.com/pytest-dev/execnet/pull/127 "ignore:isSet\\(\\) is deprecated, use is_set\\(\\) instead:DeprecationWarning", + # https://github.com/pytest-dev/pytest/issues/2366 + # https://github.com/pytest-dev/pytest/pull/13057 + "default::pytest.PytestFDWarning", ] pytester_example_dir = "testing/example_scripts" markers = [ diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 6160f780b1b..0161f5952b8 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -264,11 +264,11 @@ def directory_arg(path: str, optname: str) -> str: "setuponly", "setupplan", "stepwise", + "unraisableexception", + "threadexception", "warnings", "logging", "reports", - "unraisableexception", - "threadexception", "faulthandler", ) @@ -1112,9 +1112,7 @@ def add_cleanup(self, func: Callable[[], None]) -> None: def _do_configure(self) -> None: assert not self._configured self._configured = True - with warnings.catch_warnings(): - warnings.simplefilter("default") - self.hook.pytest_configure.call_historic(kwargs=dict(config=self)) + self.hook.pytest_configure.call_historic(kwargs=dict(config=self)) def _ensure_unconfigure(self) -> None: try: diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 412d850d2da..59839562031 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -65,7 +65,7 @@ from _pytest.reports import CollectReport from _pytest.reports import TestReport from _pytest.tmpdir import TempPathFactory -from _pytest.warning_types import PytestWarning +from _pytest.warning_types import PytestFDWarning if TYPE_CHECKING: @@ -188,7 +188,7 @@ def pytest_runtest_protocol(self, item: Item) -> Generator[None, object, object] "*** function {}:{}: {} ".format(*item.location), "See issue #2366", ] - item.warn(PytestWarning("\n".join(error))) + item.warn(PytestFDWarning("\n".join(error))) # used at least by pytest-xdist plugin diff --git a/src/_pytest/warning_types.py b/src/_pytest/warning_types.py index b8e9998cd2e..8c9ff2d9a36 100644 --- a/src/_pytest/warning_types.py +++ b/src/_pytest/warning_types.py @@ -123,6 +123,13 @@ def format(self, **kwargs: Any) -> _W: return self.category(self.template.format(**kwargs)) +@final +class PytestFDWarning(PytestWarning): + """When the lsof plugin finds leaked fds.""" + + __module__ = "pytest" + + def warn_explicit_for(method: FunctionType, message: PytestWarning) -> None: """ Issue the warning :param:`message` for the definition of the given :param:`method` diff --git a/src/_pytest/warnings.py b/src/_pytest/warnings.py index 64ea3ff222d..806681a5020 100644 --- a/src/_pytest/warnings.py +++ b/src/_pytest/warnings.py @@ -3,6 +3,7 @@ from collections.abc import Generator from contextlib import contextmanager +from contextlib import ExitStack import sys from typing import Literal import warnings @@ -17,20 +18,14 @@ import pytest -def pytest_configure(config: Config) -> None: - config.addinivalue_line( - "markers", - "filterwarnings(warning): add a warning filter to the given test. " - "see https://docs.pytest.org/en/stable/how-to/capture-warnings.html#pytest-mark-filterwarnings ", - ) - - @contextmanager def catch_warnings_for_item( config: Config, ihook, when: Literal["config", "collect", "runtest"], item: Item | None, + *, + record: bool = True, ) -> Generator[None]: """Context manager that catches warnings generated in the contained execution block. @@ -40,10 +35,7 @@ def catch_warnings_for_item( """ config_filters = config.getini("filterwarnings") cmdline_filters = config.known_args_namespace.pythonwarnings or [] - with warnings.catch_warnings(record=True) as log: - # mypy can't infer that record=True means log is not None; help it. - assert log is not None - + with warnings.catch_warnings(record=record) as log: if not sys.warnoptions: # If user is not explicitly configuring warning filters, show deprecation warnings by default (#2908). warnings.filterwarnings("always", category=DeprecationWarning) @@ -64,15 +56,19 @@ def catch_warnings_for_item( try: yield finally: - for warning_message in log: - ihook.pytest_warning_recorded.call_historic( - kwargs=dict( - warning_message=warning_message, - nodeid=nodeid, - when=when, - location=None, + if record: + # mypy can't infer that record=True means log is not None; help it. + assert log is not None + + for warning_message in log: + ihook.pytest_warning_recorded.call_historic( + kwargs=dict( + warning_message=warning_message, + nodeid=nodeid, + when=when, + location=None, + ) ) - ) def warning_record_to_str(warning_message: warnings.WarningMessage) -> str: @@ -131,3 +127,26 @@ def pytest_load_initial_conftests( config=early_config, ihook=early_config.hook, when="config", item=None ): return (yield) + + +def pytest_configure(config: Config) -> None: + with ExitStack() as stack: + stack.enter_context( + catch_warnings_for_item( + config=config, + ihook=config.hook, + when="config", + item=None, + # this disables recording because the terminalreporter has + # finished by the time it comes to reporting logged warnings + # from the end of config cleanup. So for now, this is only + # useful for setting a warning filter with an 'error' action. + record=False, + ) + ) + config.addinivalue_line( + "markers", + "filterwarnings(warning): add a warning filter to the given test. " + "see https://docs.pytest.org/en/stable/how-to/capture-warnings.html#pytest-mark-filterwarnings ", + ) + config.add_cleanup(stack.pop_all().close) diff --git a/src/pytest/__init__.py b/src/pytest/__init__.py index f0c3516f4cc..70096d6593e 100644 --- a/src/pytest/__init__.py +++ b/src/pytest/__init__.py @@ -77,6 +77,7 @@ from _pytest.warning_types import PytestConfigWarning from _pytest.warning_types import PytestDeprecationWarning from _pytest.warning_types import PytestExperimentalApiWarning +from _pytest.warning_types import PytestFDWarning from _pytest.warning_types import PytestRemovedIn9Warning from _pytest.warning_types import PytestUnhandledThreadExceptionWarning from _pytest.warning_types import PytestUnknownMarkWarning @@ -124,6 +125,7 @@ "PytestConfigWarning", "PytestDeprecationWarning", "PytestExperimentalApiWarning", + "PytestFDWarning", "PytestPluginManager", "PytestRemovedIn9Warning", "PytestUnhandledThreadExceptionWarning", diff --git a/testing/test_unraisableexception.py b/testing/test_unraisableexception.py index 5aa6aa773d9..3f191073e2b 100644 --- a/testing/test_unraisableexception.py +++ b/testing/test_unraisableexception.py @@ -1,5 +1,7 @@ from __future__ import annotations +from collections.abc import Generator +import contextlib import gc import sys from unittest import mock @@ -203,7 +205,25 @@ class MyError(BaseException): ) -def test_create_task_unraisable(pytester: Pytester) -> None: +def _set_gc_state(enabled: bool) -> bool: + was_enabled = gc.isenabled() + if enabled: + gc.enable() + else: + gc.disable() + return was_enabled + + +@contextlib.contextmanager +def _disable_gc() -> Generator[None]: + was_enabled = _set_gc_state(enabled=False) + try: + yield + finally: + _set_gc_state(enabled=was_enabled) + + +def test_refcycle_unraisable(pytester: Pytester) -> None: # see: https://github.com/pytest-dev/pytest/issues/10404 pytester.makepyfile( test_it=""" @@ -221,13 +241,8 @@ def test_it(): """ ) - was_enabled = gc.isenabled() - gc.disable() - try: + with _disable_gc(): result = pytester.runpytest() - finally: - if was_enabled: - gc.enable() # TODO: should be a test failure or error assert result.ret == pytest.ExitCode.INTERNAL_ERROR @@ -236,6 +251,101 @@ def test_it(): result.stderr.fnmatch_lines("ValueError: del is broken") +@pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning") +def test_refcycle_unraisable_warning_filter(pytester: Pytester) -> None: + # note that the host pytest warning filter is disabled and the pytester + # warning filter applies during config teardown of unraisablehook. + # see: https://github.com/pytest-dev/pytest/issues/10404 + pytester.makepyfile( + test_it=""" + import pytest + + class BrokenDel: + def __init__(self): + self.self = self # make a reference cycle + + def __del__(self): + raise ValueError("del is broken") + + def test_it(): + BrokenDel() + """ + ) + + with _disable_gc(): + result = pytester.runpytest("-Werror") + + # TODO: should be a test failure or error + assert result.ret == pytest.ExitCode.INTERNAL_ERROR + + result.assert_outcomes(passed=1) + result.stderr.fnmatch_lines("ValueError: del is broken") + + +@pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning") +def test_create_task_raises_unraisable_warning_filter(pytester: Pytester) -> None: + # note that the host pytest warning filter is disabled and the pytester + # warning filter applies during config teardown of unraisablehook. + # see: https://github.com/pytest-dev/pytest/issues/10404 + # This is a dupe of the above test, but using the exact reproducer from + # the issue + pytester.makepyfile( + test_it=""" + import asyncio + import pytest + + async def my_task(): + pass + + def test_scheduler_must_be_created_within_running_loop() -> None: + with pytest.raises(RuntimeError) as _: + asyncio.create_task(my_task()) + """ + ) + + with _disable_gc(): + result = pytester.runpytest("-Werror") + + # TODO: should be a test failure or error + assert result.ret == pytest.ExitCode.INTERNAL_ERROR + + result.assert_outcomes(passed=1) + result.stderr.fnmatch_lines("RuntimeWarning: coroutine 'my_task' was never awaited") + + +def test_refcycle_unraisable_warning_filter_default(pytester: Pytester) -> None: + # note this time we use a default warning filter for pytester + # and run it in a subprocess, because the warning can only go to the + # sys.stdout rather than the terminal reporter, which has already + # finished. + # see: https://github.com/pytest-dev/pytest/pull/13057#discussion_r1888396126 + pytester.makepyfile( + test_it=""" + import pytest + + class BrokenDel: + def __init__(self): + self.self = self # make a reference cycle + + def __del__(self): + raise ValueError("del is broken") + + def test_it(): + BrokenDel() + """ + ) + + with _disable_gc(): + result = pytester.runpytest_subprocess("-Wdefault") + + assert result.ret == pytest.ExitCode.OK + + # TODO: should be warnings=1, but the outcome has already come out + # by the time the warning triggers + result.assert_outcomes(passed=1) + result.stderr.fnmatch_lines("ValueError: del is broken") + + @pytest.mark.filterwarnings("error::pytest.PytestUnraisableExceptionWarning") def test_possibly_none_excinfo(pytester: Pytester) -> None: pytester.makepyfile( From 7d585acd1123a6bf6df6ff3279757bb5a69a9417 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Sat, 21 Dec 2024 14:28:17 +0100 Subject: [PATCH 232/445] fix #13031: use the concrete id NOTSET for the empty parameter list (#13073) * fix #13031: use the concrete id NOTSET for the empty parameter list stand-in this ensures we dont invoke idfunc with the internal NOTSET enum token * Apply suggestions from code review Co-authored-by: Bruno Oliveira --------- Co-authored-by: Bruno Oliveira --- changelog/13031.improvement.rst | 1 + src/_pytest/mark/structures.py | 12 +++++++----- testing/test_mark.py | 26 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 changelog/13031.improvement.rst diff --git a/changelog/13031.improvement.rst b/changelog/13031.improvement.rst new file mode 100644 index 00000000000..c6c64c4673a --- /dev/null +++ b/changelog/13031.improvement.rst @@ -0,0 +1 @@ +An empty parameter set as in ``pytest.mark.parametrize([], ids=idfunc)`` will no longer trigger a call to ``idfunc`` with internal objects. diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 624b37cab94..1a0b3c5b5b8 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -47,18 +47,18 @@ def get_empty_parameterset_mark( ) -> MarkDecorator: from ..nodes import Collector + argslisting = ", ".join(argnames) + fs, lineno = getfslineno(func) - reason = f"got empty parameter set {argnames!r}, function {func.__name__} at {fs}:{lineno}" + reason = f"got empty parameter set for ({argslisting})" requested_mark = config.getini(EMPTY_PARAMETERSET_OPTION) if requested_mark in ("", None, "skip"): mark = MARK_GEN.skip(reason=reason) elif requested_mark == "xfail": mark = MARK_GEN.xfail(reason=reason, run=False) elif requested_mark == "fail_at_collect": - f_name = func.__name__ - _, lineno = getfslineno(func) raise Collector.CollectError( - f"Empty parameter set in '{f_name}' at line {lineno + 1}" + f"Empty parameter set in '{func.__name__}' at line {lineno + 1}" ) else: raise LookupError(requested_mark) @@ -181,7 +181,9 @@ def _for_parametrize( # parameter set with NOTSET values, with the "empty parameter set" mark applied to it. mark = get_empty_parameterset_mark(config, argnames, func) parameters.append( - ParameterSet(values=(NOTSET,) * len(argnames), marks=[mark], id=None) + ParameterSet( + values=(NOTSET,) * len(argnames), marks=[mark], id="NOTSET" + ) ) return argnames, parameters diff --git a/testing/test_mark.py b/testing/test_mark.py index 60ee795cf43..7b76acf9990 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -1048,6 +1048,32 @@ def test(): assert result.ret == ExitCode.INTERRUPTED +def test_paramset_empty_no_idfunc( + pytester: Pytester, monkeypatch: pytest.MonkeyPatch +) -> None: + """An empty parameter set should not call the user provided id function (#13031).""" + p1 = pytester.makepyfile( + """ + import pytest + + def idfunc(value): + raise ValueError() + @pytest.mark.parametrize("param", [], ids=idfunc) + def test(param): + pass + """ + ) + result = pytester.runpytest(p1, "-v", "-rs") + result.stdout.fnmatch_lines( + [ + "* collected 1 item", + "test_paramset_empty_no_idfunc* SKIPPED *", + "SKIPPED [1] test_paramset_empty_no_idfunc.py:5: got empty parameter set for (param)", + "*= 1 skipped in *", + ] + ) + + def test_parameterset_for_parametrize_bad_markname(pytester: Pytester) -> None: with pytest.raises(pytest.UsageError): test_parameterset_for_parametrize_marks(pytester, "bad") From 24e84f08f43216f95620135305cbebe9f646e433 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 22 Dec 2024 08:34:13 +0100 Subject: [PATCH 233/445] [automated] Update plugin list (#13080) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 88 ++++++++++++++++---------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 63d91b6eb53..ddda5448232 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -157,7 +157,7 @@ This list contains 1559 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Dec 09, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Dec 16, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -168,7 +168,7 @@ This list contains 1559 plugins. :pypi:`pytest-bigchaindb` A BigchainDB plugin for pytest. Jan 24, 2022 4 - Beta N/A :pypi:`pytest-bigquery-mock` Provides a mock fixture for python bigquery client Dec 28, 2022 N/A pytest (>=5.0) :pypi:`pytest-bisect-tests` Find tests leaking state and affecting other Jun 09, 2024 N/A N/A - :pypi:`pytest-black` A pytest plugin to enable format checking with black Oct 05, 2020 4 - Beta N/A + :pypi:`pytest-black` A pytest plugin to enable format checking with black Dec 15, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-black-multipy` Allow '--black' on older Pythons Jan 14, 2021 5 - Production/Stable pytest (!=3.7.3,>=3.5) ; extra == 'testing' :pypi:`pytest-black-ng` A pytest plugin to enable format checking with black Oct 20, 2022 4 - Beta pytest (>=7.0.0) :pypi:`pytest-blame` A pytest plugin helps developers to debug by providing useful commits history. May 04, 2019 N/A pytest (>=4.4.0) @@ -667,7 +667,7 @@ This list contains 1559 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Dec 14, 2024 3 - Alpha pytest==8.3.3 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Dec 21, 2024 3 - Alpha pytest==8.3.3 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -691,7 +691,7 @@ This list contains 1559 plugins. :pypi:`pytest-http-mocker` Pytest plugin for http mocking (via https://github.com/vilus/mocker) Oct 20, 2019 N/A N/A :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Aug 11, 2024 3 - Alpha N/A - :pypi:`pytest-httptesting` http_testing framework on top of pytest Aug 10, 2024 N/A pytest<9.0.0,>=8.2.0 + :pypi:`pytest-httptesting` http_testing framework on top of pytest Dec 19, 2024 N/A pytest>=8.2.0 :pypi:`pytest-httpx` Send responses to httpx. Nov 28, 2024 5 - Production/Stable pytest==8.* :pypi:`pytest-httpx-blockage` Disable httpx requests during a test run Feb 16, 2023 N/A pytest (>=7.2.1) :pypi:`pytest-httpx-recorder` Recorder feature based on pytest_httpx, like recorder feature in responses. Jan 04, 2024 5 - Production/Stable pytest @@ -716,7 +716,7 @@ This list contains 1559 plugins. :pypi:`pytest-info-collector` pytest plugin to collect information from tests May 26, 2019 3 - Alpha N/A :pypi:`pytest-info-plugin` Get executed interface information in pytest interface automation framework Sep 14, 2023 N/A N/A :pypi:`pytest-informative-node` display more node ininformation. Apr 25, 2019 4 - Beta N/A - :pypi:`pytest-infrahouse` A set of fixtures to use with pytest Dec 12, 2024 4 - Beta pytest~=8.3 + :pypi:`pytest-infrahouse` A set of fixtures to use with pytest Dec 19, 2024 4 - Beta pytest~=8.3 :pypi:`pytest-infrastructure` pytest stack validation prior to testing executing Apr 12, 2020 4 - Beta N/A :pypi:`pytest-ini` Reuse pytest.ini to store env variables Apr 26, 2022 N/A N/A :pypi:`pytest-initry` Plugin for sending automation test data from Pytest to the initry Apr 30, 2024 N/A pytest<9.0.0,>=8.1.1 @@ -741,7 +741,7 @@ This list contains 1559 plugins. :pypi:`pytest-iovis` A Pytest plugin to enable Jupyter Notebook testing with Papermill Nov 06, 2024 4 - Beta pytest>=7.1.0 :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A - :pypi:`pytest-ipywidgets` Dec 04, 2024 N/A pytest + :pypi:`pytest-ipywidgets` Dec 19, 2024 N/A pytest :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Nov 24, 2024 4 - Beta pytest :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Dec 05, 2024 4 - Beta pytest>=5 :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) @@ -819,7 +819,7 @@ This list contains 1559 plugins. :pypi:`pytest-localstack` Pytest plugin for AWS integration tests Jun 07, 2023 4 - Beta pytest (>=6.0.0,<7.0.0) :pypi:`pytest-lock` pytest-lock is a pytest plugin that allows you to "lock" the results of unit tests, storing them in a local cache. This is particularly useful for tests that are resource-intensive or don't need to be run every time. When the tests are run subsequently, pytest-lock will compare the current results with the locked results and issue a warning if there are any discrepancies. Feb 03, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-lockable` lockable resource plugin for pytest Jan 24, 2024 5 - Production/Stable pytest - :pypi:`pytest-locker` Used to lock object during testing. Essentially changing assertions from being hard coded to asserting that nothing changed Oct 29, 2021 N/A pytest (>=5.4) + :pypi:`pytest-locker` Used to lock object during testing. Essentially changing assertions from being hard coded to asserting that nothing changed Dec 20, 2024 N/A pytest>=5.4 :pypi:`pytest-log` print log Aug 15, 2021 N/A pytest (>=3.8) :pypi:`pytest-logbook` py.test plugin to capture logbook log messages Nov 23, 2015 5 - Production/Stable pytest (>=2.8) :pypi:`pytest-logdog` Pytest plugin to test logging Jun 15, 2021 1 - Planning pytest (>=6.2.0) @@ -863,7 +863,7 @@ This list contains 1559 plugins. :pypi:`pytest-memray` A simple plugin to use with pytest Jul 25, 2024 N/A pytest>=7.2 :pypi:`pytest-menu` A pytest plugin for console based interactive test selection just after the collection phase Oct 04, 2017 3 - Alpha pytest (>=2.4.2) :pypi:`pytest-mercurial` pytest plugin to write integration tests for projects using Mercurial Python internals Nov 21, 2020 1 - Planning N/A - :pypi:`pytest-mergify` Pytest plugin for Mergify Dec 11, 2024 N/A N/A + :pypi:`pytest-mergify` Pytest plugin for Mergify Dec 20, 2024 N/A N/A :pypi:`pytest-mesh` pytest_mesh插件 Aug 05, 2022 N/A pytest (==7.1.2) :pypi:`pytest-message` Pytest plugin for sending report message of marked tests execution Aug 04, 2022 N/A pytest (>=6.2.5) :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A @@ -1058,7 +1058,7 @@ This list contains 1559 plugins. :pypi:`pytest-postgres` Run PostgreSQL in Docker container in Pytest. Mar 22, 2020 N/A pytest :pypi:`pytest-postgresql` Postgresql fixtures and fixture factories for Pytest. Sep 05, 2024 5 - Production/Stable pytest>=6.2 :pypi:`pytest-power` pytest plugin with powerful fixtures Dec 31, 2020 N/A pytest (>=5.4) - :pypi:`pytest-powerpack` A plugin containing extra batteries for pytest Oct 01, 2024 N/A pytest<9.0.0,>=8.1.1 + :pypi:`pytest-powerpack` A plugin containing extra batteries for pytest Dec 17, 2024 N/A pytest<9.0.0,>=8.1.1 :pypi:`pytest-prefer-nested-dup-tests` A Pytest plugin to drop duplicated tests during collection, but will prefer keeping nested packages. Apr 27, 2022 4 - Beta pytest (>=7.1.1,<8.0.0) :pypi:`pytest-pretty` pytest plugin for printing summary data as I want it Apr 05, 2023 5 - Production/Stable pytest>=7 :pypi:`pytest-pretty-terminal` pytest plugin for generating prettier terminal output Jan 31, 2022 N/A pytest (>=3.4.1) @@ -1136,7 +1136,7 @@ This list contains 1559 plugins. :pypi:`pytest-ranking` A Pytest plugin for automatically prioritizing/ranking tests to speed up failure detection Jun 07, 2024 4 - Beta pytest>=7.4.3 :pypi:`pytest-readme` Test your README.md file Sep 02, 2022 5 - Production/Stable N/A :pypi:`pytest-reana` Pytest fixtures for REANA. Sep 04, 2024 3 - Alpha N/A - :pypi:`pytest-recorder` Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. Jun 27, 2024 N/A N/A + :pypi:`pytest-recorder` Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. Dec 19, 2024 N/A N/A :pypi:`pytest-recording` A pytest plugin that allows you recording of network interactions via VCR.py Jul 09, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-recordings` Provides pytest plugins for reporting request/response traffic, screenshots, and more to ReportPortal Aug 13, 2020 N/A N/A :pypi:`pytest-record-video` 用例执行过程中录制视频 Oct 31, 2024 N/A N/A @@ -1147,7 +1147,7 @@ This list contains 1559 plugins. :pypi:`pytest-reference-formatter` Conveniently run pytest with a dot-formatted test reference. Oct 01, 2019 4 - Beta N/A :pypi:`pytest-regex` Select pytest tests with regular expressions May 29, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-regex-dependency` Management of Pytest dependencies via regex patterns Jun 12, 2022 N/A pytest - :pypi:`pytest-regressions` Easy to use fixtures to write regression tests. Aug 31, 2023 5 - Production/Stable pytest >=6.2.0 + :pypi:`pytest-regressions` Easy to use fixtures to write regression tests. Dec 17, 2024 5 - Production/Stable pytest>=6.2.0 :pypi:`pytest-regtest` pytest plugin for snapshot regression testing Nov 12, 2024 N/A pytest>7.2 :pypi:`pytest-relative-order` a pytest plugin that sorts tests using "before" and "after" markers May 17, 2021 4 - Beta N/A :pypi:`pytest-relative-path` Handle relative path in pytest options or ini configs Aug 30, 2024 N/A pytest @@ -1165,7 +1165,7 @@ This list contains 1559 plugins. :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Oct 11, 2024 4 - Beta N/A :pypi:`pytest-reporter-html-dots` A basic HTML report for pytest using Jinja2 template engine. Jan 22, 2023 N/A N/A - :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports of webtest projects by adding screenshots, comments and webpage sources. Dec 14, 2024 N/A pytest>=7.0.0 + :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots and webpage sources. Dec 15, 2024 N/A pytest>=7.0.0 :pypi:`pytest-reportinfra` Pytest plugin for reportinfra Aug 11, 2019 3 - Alpha N/A :pypi:`pytest-reporting` A plugin to report summarized results in a table format Oct 25, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-reportlog` Replacement for the --resultlog option, focused in simplicity and extensibility May 22, 2023 3 - Alpha pytest @@ -1188,7 +1188,7 @@ This list contains 1559 plugins. :pypi:`pytest-rerunfailures` pytest plugin to re-run tests to eliminate flaky failures Nov 20, 2024 5 - Production/Stable pytest!=8.2.2,>=7.4 :pypi:`pytest-rerunfailures-all-logs` pytest plugin to re-run tests to eliminate flaky failures Mar 07, 2022 5 - Production/Stable N/A :pypi:`pytest-reserial` Pytest fixture for recording and replaying serial port traffic. Jul 23, 2024 4 - Beta pytest - :pypi:`pytest-resilient-circuits` Resilient Circuits fixtures for PyTest Jul 16, 2024 N/A pytest~=7.0 + :pypi:`pytest-resilient-circuits` Resilient Circuits fixtures for PyTest Dec 16, 2024 N/A pytest~=7.0 :pypi:`pytest-resource` Load resource fixture plugin to use with pytest Nov 14, 2018 4 - Beta N/A :pypi:`pytest-resource-path` Provides path for uniform access to test resources in isolated directory May 01, 2021 5 - Production/Stable pytest (>=3.5.0) :pypi:`pytest-resource-usage` Pytest plugin for reporting running time and peak memory usage Nov 06, 2022 5 - Production/Stable pytest>=7.0.0 @@ -1198,13 +1198,13 @@ This list contains 1559 plugins. :pypi:`pytest-restrict` Pytest plugin to restrict the test types allowed Oct 24, 2024 5 - Production/Stable pytest :pypi:`pytest-result-log` A pytest plugin that records the start, end, and result information of each use case in a log file Jan 10, 2024 N/A pytest>=7.2.0 :pypi:`pytest-result-sender` Apr 20, 2023 N/A pytest>=7.3.1 - :pypi:`pytest-result-sender-lj` Default template for PDM package Dec 14, 2024 N/A pytest>=8.3.4 + :pypi:`pytest-result-sender-lj` Default template for PDM package Dec 17, 2024 N/A pytest>=8.3.4 :pypi:`pytest-resume` A Pytest plugin to resuming from the last run test Apr 22, 2023 4 - Beta pytest (>=7.0) :pypi:`pytest-rethinkdb` A RethinkDB plugin for pytest. Jul 24, 2016 4 - Beta N/A :pypi:`pytest-retry` Adds the ability to retry flaky tests in CI environments May 14, 2024 N/A pytest>=7.0.0 :pypi:`pytest-retry-class` A pytest plugin to rerun entire class on failure Nov 24, 2024 N/A pytest>=5.3 :pypi:`pytest-reusable-testcases` Apr 28, 2023 N/A N/A - :pypi:`pytest-revealtype-injector` Pytest plugin for replacing reveal_type() calls inside test functions with static and runtime type checking result comparison, for confirming type annotation validity. Dec 14, 2024 4 - Beta pytest>=7.0 + :pypi:`pytest-revealtype-injector` Pytest plugin for replacing reveal_type() calls inside test functions with static and runtime type checking result comparison, for confirming type annotation validity. Dec 19, 2024 4 - Beta pytest>=7.0 :pypi:`pytest-reverse` Pytest plugin to reverse test order. Oct 25, 2024 5 - Production/Stable pytest :pypi:`pytest-rich` Leverage rich for richer test session output Dec 12, 2024 4 - Beta pytest>=7.0 :pypi:`pytest-richer` Pytest plugin providing a Rich based reporter. Oct 27, 2023 3 - Alpha pytest @@ -1240,7 +1240,7 @@ This list contains 1559 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Dec 13, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Dec 15, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1251,10 +1251,10 @@ This list contains 1559 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Dec 13, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Dec 15, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A - :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Apr 05, 2024 N/A pytest<9.0.0,>=8.0.0 + :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 :pypi:`pytest-send-email` Send pytest execution result email Sep 02, 2024 N/A pytest :pypi:`pytest-sentry` A pytest plugin to send testrun information to Sentry.io Nov 25, 2024 N/A pytest :pypi:`pytest-sequence-markers` Pytest plugin for sequencing markers for execution of tests May 23, 2023 5 - Production/Stable N/A @@ -1569,7 +1569,7 @@ This list contains 1559 plugins. :pypi:`pytest-xskynet` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A :pypi:`pytest-xstress` Jun 01, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-xvfb` A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. May 29, 2023 4 - Beta pytest (>=2.8.1) - :pypi:`pytest-xvirt` A pytest plugin to virtualize test. For example to transparently running them on a remote box. Oct 01, 2024 4 - Beta pytest>=7.2.2 + :pypi:`pytest-xvirt` A pytest plugin to virtualize test. For example to transparently running them on a remote box. Dec 15, 2024 4 - Beta pytest>=7.2.2 :pypi:`pytest-yaml` This plugin is used to load yaml output to your test using pytest framework. Oct 05, 2018 N/A pytest :pypi:`pytest-yaml-sanmu` Pytest plugin for generating test cases with YAML. In test cases, you can use markers, fixtures, variables, and even call Python functions. Nov 20, 2024 N/A pytest~=8.2.2 :pypi:`pytest-yamltree` Create or check file/directory trees described by YAML Mar 02, 2020 4 - Beta pytest (>=3.1.1) @@ -2460,7 +2460,7 @@ This list contains 1559 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Dec 09, 2024, + *last release*: Dec 16, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -2537,9 +2537,9 @@ This list contains 1559 plugins. Find tests leaking state and affecting other :pypi:`pytest-black` - *last release*: Oct 05, 2020, + *last release*: Dec 15, 2024, *status*: 4 - Beta, - *requires*: N/A + *requires*: pytest>=7.0.0 A pytest plugin to enable format checking with black @@ -6030,7 +6030,7 @@ This list contains 1559 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Dec 14, 2024, + *last release*: Dec 21, 2024, *status*: 3 - Alpha, *requires*: pytest==8.3.3 @@ -6198,9 +6198,9 @@ This list contains 1559 plugins. pytest-httpserver is a httpserver for pytest :pypi:`pytest-httptesting` - *last release*: Aug 10, 2024, + *last release*: Dec 19, 2024, *status*: N/A, - *requires*: pytest<9.0.0,>=8.2.0 + *requires*: pytest>=8.2.0 http_testing framework on top of pytest @@ -6373,7 +6373,7 @@ This list contains 1559 plugins. display more node ininformation. :pypi:`pytest-infrahouse` - *last release*: Dec 12, 2024, + *last release*: Dec 19, 2024, *status*: 4 - Beta, *requires*: pytest~=8.3 @@ -6548,7 +6548,7 @@ This list contains 1559 plugins. THIS PROJECT IS ABANDONED :pypi:`pytest-ipywidgets` - *last release*: Dec 04, 2024, + *last release*: Dec 19, 2024, *status*: N/A, *requires*: pytest @@ -7094,9 +7094,9 @@ This list contains 1559 plugins. lockable resource plugin for pytest :pypi:`pytest-locker` - *last release*: Oct 29, 2021, + *last release*: Dec 20, 2024, *status*: N/A, - *requires*: pytest (>=5.4) + *requires*: pytest>=5.4 Used to lock object during testing. Essentially changing assertions from being hard coded to asserting that nothing changed @@ -7402,7 +7402,7 @@ This list contains 1559 plugins. pytest plugin to write integration tests for projects using Mercurial Python internals :pypi:`pytest-mergify` - *last release*: Dec 11, 2024, + *last release*: Dec 20, 2024, *status*: N/A, *requires*: N/A @@ -8767,7 +8767,7 @@ This list contains 1559 plugins. pytest plugin with powerful fixtures :pypi:`pytest-powerpack` - *last release*: Oct 01, 2024, + *last release*: Dec 17, 2024, *status*: N/A, *requires*: pytest<9.0.0,>=8.1.1 @@ -9313,7 +9313,7 @@ This list contains 1559 plugins. Pytest fixtures for REANA. :pypi:`pytest-recorder` - *last release*: Jun 27, 2024, + *last release*: Dec 19, 2024, *status*: N/A, *requires*: N/A @@ -9390,9 +9390,9 @@ This list contains 1559 plugins. Management of Pytest dependencies via regex patterns :pypi:`pytest-regressions` - *last release*: Aug 31, 2023, + *last release*: Dec 17, 2024, *status*: 5 - Production/Stable, - *requires*: pytest >=6.2.0 + *requires*: pytest>=6.2.0 Easy to use fixtures to write regression tests. @@ -9516,11 +9516,11 @@ This list contains 1559 plugins. A basic HTML report for pytest using Jinja2 template engine. :pypi:`pytest-report-extras` - *last release*: Dec 14, 2024, + *last release*: Dec 15, 2024, *status*: N/A, *requires*: pytest>=7.0.0 - Pytest plugin to enhance pytest-html and allure reports of webtest projects by adding screenshots, comments and webpage sources. + Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots and webpage sources. :pypi:`pytest-reportinfra` *last release*: Aug 11, 2019, @@ -9677,7 +9677,7 @@ This list contains 1559 plugins. Pytest fixture for recording and replaying serial port traffic. :pypi:`pytest-resilient-circuits` - *last release*: Jul 16, 2024, + *last release*: Dec 16, 2024, *status*: N/A, *requires*: pytest~=7.0 @@ -9747,7 +9747,7 @@ This list contains 1559 plugins. :pypi:`pytest-result-sender-lj` - *last release*: Dec 14, 2024, + *last release*: Dec 17, 2024, *status*: N/A, *requires*: pytest>=8.3.4 @@ -9789,7 +9789,7 @@ This list contains 1559 plugins. :pypi:`pytest-revealtype-injector` - *last release*: Dec 14, 2024, + *last release*: Dec 19, 2024, *status*: 4 - Beta, *requires*: pytest>=7.0 @@ -10041,7 +10041,7 @@ This list contains 1559 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Dec 13, 2024, + *last release*: Dec 15, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10118,7 +10118,7 @@ This list contains 1559 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Dec 13, 2024, + *last release*: Dec 15, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10139,9 +10139,9 @@ This list contains 1559 plugins. A pytest package implementing perceptualdiff for Selenium tests. :pypi:`pytest-selfie` - *last release*: Apr 05, 2024, + *last release*: Dec 16, 2024, *status*: N/A, - *requires*: pytest<9.0.0,>=8.0.0 + *requires*: pytest>=8.0.0 A pytest plugin for selfie snapshot testing. @@ -12344,7 +12344,7 @@ This list contains 1559 plugins. A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. :pypi:`pytest-xvirt` - *last release*: Oct 01, 2024, + *last release*: Dec 15, 2024, *status*: 4 - Beta, *requires*: pytest>=7.2.2 From 9c02a3f6ed59215a06fb146ccb573182e9481e06 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 29 Dec 2024 06:33:15 +0000 Subject: [PATCH 234/445] [automated] Update plugin list (#13088) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 90 +++++++++++++++++++------------- 1 file changed, 53 insertions(+), 37 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index ddda5448232..6b2a1898203 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =7.2.0,<8.0.0) :pypi:`pytest-aiomoto` pytest-aiomoto Jun 24, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-aioresponses` py.test integration for aioresponses Jul 29, 2021 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-aioworkers` A plugin to test aioworkers project with pytest May 01, 2023 5 - Production/Stable pytest>=6.1.0 + :pypi:`pytest-aioworkers` A plugin to test aioworkers project with pytest Dec 26, 2024 5 - Production/Stable pytest>=8.3.4 :pypi:`pytest-airflow` pytest support for airflow. Apr 03, 2019 3 - Alpha pytest (>=4.4.0) :pypi:`pytest-airflow-utils` Nov 15, 2021 N/A N/A :pypi:`pytest-alembic` A pytest plugin for verifying alembic migrations. Jul 29, 2024 N/A pytest>=6.0 @@ -116,12 +116,14 @@ This list contains 1559 plugins. :pypi:`pytest_async` pytest-async - Run your coroutine in event loop without decorator Feb 26, 2020 N/A N/A :pypi:`pytest-async-generators` Pytest fixtures for async generators Jul 05, 2023 N/A N/A :pypi:`pytest-asyncio` Pytest support for asyncio Dec 13, 2024 4 - Beta pytest<9,>=8.2 + :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Dec 26, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Jul 04, 2024 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) :pypi:`pytest-async-mongodb` pytest plugin for async MongoDB Oct 18, 2017 5 - Production/Stable pytest (>=2.5.2) :pypi:`pytest-async-sqlalchemy` Database testing fixtures using the SQLAlchemy asyncio API Oct 07, 2021 4 - Beta pytest (>=6.0.0) :pypi:`pytest-atf-allure` 基于allure-pytest进行自定义 Nov 29, 2023 N/A pytest (>=7.4.2,<8.0.0) :pypi:`pytest-atomic` Skip rest of tests if previous test failed. Nov 24, 2018 4 - Beta N/A + :pypi:`pytest-atstack` A simple plugin to use with pytest Dec 28, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-attrib` pytest plugin to select tests based on attributes similar to the nose-attrib plugin May 24, 2016 4 - Beta N/A :pypi:`pytest-attributes` A plugin that allows users to add attributes to their tests. These attributes can then be referenced by fixtures or the test itself. Jun 24, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-austin` Austin plugin for pytest Oct 11, 2020 4 - Beta N/A @@ -157,7 +159,7 @@ This list contains 1559 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Dec 16, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Dec 23, 2024 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -362,7 +364,7 @@ This list contains 1559 plugins. :pypi:`pytest-deprecator` A simple plugin to use with pytest Dec 02, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-describe` Describe-style plugin for pytest Feb 10, 2024 5 - Production/Stable pytest <9,>=4.6 :pypi:`pytest-describe-it` plugin for rich text descriptions Jul 19, 2019 4 - Beta pytest - :pypi:`pytest-deselect-if` A plugin to deselect pytests tests rather than using skipif Mar 24, 2024 4 - Beta pytest>=6.2.0 + :pypi:`pytest-deselect-if` A plugin to deselect pytests tests rather than using skipif Dec 26, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-devpi-server` DevPI server fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-dhos` Common fixtures for pytest in DHOS services and libraries Sep 07, 2022 N/A N/A :pypi:`pytest-diamond` pytest plugin for diamond Aug 31, 2015 4 - Beta N/A @@ -623,7 +625,7 @@ This list contains 1559 plugins. :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Dec 05, 2024 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Dec 23, 2024 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -667,7 +669,7 @@ This list contains 1559 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Dec 21, 2024 3 - Alpha pytest==8.3.3 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Dec 26, 2024 3 - Alpha pytest==8.3.4 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -863,7 +865,7 @@ This list contains 1559 plugins. :pypi:`pytest-memray` A simple plugin to use with pytest Jul 25, 2024 N/A pytest>=7.2 :pypi:`pytest-menu` A pytest plugin for console based interactive test selection just after the collection phase Oct 04, 2017 3 - Alpha pytest (>=2.4.2) :pypi:`pytest-mercurial` pytest plugin to write integration tests for projects using Mercurial Python internals Nov 21, 2020 1 - Planning N/A - :pypi:`pytest-mergify` Pytest plugin for Mergify Dec 20, 2024 N/A N/A + :pypi:`pytest-mergify` Pytest plugin for Mergify Dec 27, 2024 N/A N/A :pypi:`pytest-mesh` pytest_mesh插件 Aug 05, 2022 N/A pytest (==7.1.2) :pypi:`pytest-message` Pytest plugin for sending report message of marked tests execution Aug 04, 2022 N/A pytest (>=6.2.5) :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A @@ -916,7 +918,7 @@ This list contains 1559 plugins. :pypi:`pytest-my-cool-lib` Nov 02, 2023 N/A pytest (>=7.1.3,<8.0.0) :pypi:`pytest-mypy` Mypy static type checker plugin for Pytest Dec 18, 2022 4 - Beta pytest (>=6.2) ; python_version >= "3.10" :pypi:`pytest-mypyd` Mypy static type checker plugin for Pytest Aug 20, 2019 4 - Beta pytest (<4.7,>=2.8) ; python_version < "3.5" - :pypi:`pytest-mypy-plugins` pytest plugin for writing tests for mypy plugins Mar 31, 2024 4 - Beta pytest>=7.0.0 + :pypi:`pytest-mypy-plugins` pytest plugin for writing tests for mypy plugins Dec 21, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-mypy-plugins-shim` Substitute for "pytest-mypy-plugins" for Python implementations which aren't supported by mypy. Apr 12, 2021 N/A pytest>=6.0.0 :pypi:`pytest-mypy-runner` Run the mypy static type checker as a pytest test case Apr 23, 2024 N/A pytest>=8.0 :pypi:`pytest-mypy-testing` Pytest plugin to check mypy output. Mar 04, 2024 N/A pytest>=7,<9 @@ -991,7 +993,7 @@ This list contains 1559 plugins. :pypi:`pytest-parametrization-annotation` A pytest library for parametrizing tests using type hints. Dec 10, 2024 5 - Production/Stable pytest>=7 :pypi:`pytest-parametrize` pytest decorator for parametrizing test cases in a dict-way Nov 10, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.0 :pypi:`pytest-parametrize-cases` A more user-friendly way to write parametrized tests. Mar 13, 2022 N/A pytest (>=6.1.2) - :pypi:`pytest-parametrized` Pytest decorator for parametrizing tests with default iterables. Oct 22, 2024 5 - Production/Stable pytest + :pypi:`pytest-parametrized` Pytest decorator for parametrizing tests with default iterables. Dec 21, 2024 5 - Production/Stable pytest :pypi:`pytest-parametrize-suite` A simple pytest extension for creating a named test suite. Jan 19, 2023 5 - Production/Stable pytest :pypi:`pytest_param_files` Create pytest parametrize decorators from external files. Jul 29, 2023 N/A pytest :pypi:`pytest-params` Simplified pytest test case parameters. Aug 05, 2024 N/A pytest>=7.0.0 @@ -1133,7 +1135,7 @@ This list contains 1559 plugins. :pypi:`pytest-randomness` Pytest plugin about random seed management May 30, 2019 3 - Alpha N/A :pypi:`pytest-random-num` Randomise the order in which pytest tests are run with some control over the randomness Oct 19, 2020 5 - Production/Stable N/A :pypi:`pytest-random-order` Randomise the order in which pytest tests are run with some control over the randomness Jan 20, 2024 5 - Production/Stable pytest >=3.0.0 - :pypi:`pytest-ranking` A Pytest plugin for automatically prioritizing/ranking tests to speed up failure detection Jun 07, 2024 4 - Beta pytest>=7.4.3 + :pypi:`pytest-ranking` A Pytest plugin for automatically prioritizing/ranking tests to speed up failure detection Dec 23, 2024 4 - Beta pytest>=7.4.3 :pypi:`pytest-readme` Test your README.md file Sep 02, 2022 5 - Production/Stable N/A :pypi:`pytest-reana` Pytest fixtures for REANA. Sep 04, 2024 3 - Alpha N/A :pypi:`pytest-recorder` Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. Dec 19, 2024 N/A N/A @@ -1165,7 +1167,7 @@ This list contains 1559 plugins. :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Oct 11, 2024 4 - Beta N/A :pypi:`pytest-reporter-html-dots` A basic HTML report for pytest using Jinja2 template engine. Jan 22, 2023 N/A N/A - :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots and webpage sources. Dec 15, 2024 N/A pytest>=7.0.0 + :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots and webpage sources. Dec 28, 2024 N/A pytest>=8.0.0 :pypi:`pytest-reportinfra` Pytest plugin for reportinfra Aug 11, 2019 3 - Alpha N/A :pypi:`pytest-reporting` A plugin to report summarized results in a table format Oct 25, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-reportlog` Replacement for the --resultlog option, focused in simplicity and extensibility May 22, 2023 3 - Alpha pytest @@ -1187,7 +1189,7 @@ This list contains 1559 plugins. :pypi:`pytest-rerunclassfailures` pytest rerun class failures plugin Apr 24, 2024 5 - Production/Stable pytest>=7.2 :pypi:`pytest-rerunfailures` pytest plugin to re-run tests to eliminate flaky failures Nov 20, 2024 5 - Production/Stable pytest!=8.2.2,>=7.4 :pypi:`pytest-rerunfailures-all-logs` pytest plugin to re-run tests to eliminate flaky failures Mar 07, 2022 5 - Production/Stable N/A - :pypi:`pytest-reserial` Pytest fixture for recording and replaying serial port traffic. Jul 23, 2024 4 - Beta pytest + :pypi:`pytest-reserial` Pytest fixture for recording and replaying serial port traffic. Dec 22, 2024 4 - Beta pytest :pypi:`pytest-resilient-circuits` Resilient Circuits fixtures for PyTest Dec 16, 2024 N/A pytest~=7.0 :pypi:`pytest-resource` Load resource fixture plugin to use with pytest Nov 14, 2018 4 - Beta N/A :pypi:`pytest-resource-path` Provides path for uniform access to test resources in isolated directory May 01, 2021 5 - Production/Stable pytest (>=3.5.0) @@ -1240,7 +1242,7 @@ This list contains 1559 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Dec 15, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Dec 25, 2024 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1251,7 +1253,7 @@ This list contains 1559 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Dec 15, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Dec 25, 2024 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1406,7 +1408,7 @@ This list contains 1559 plugins. :pypi:`pytest-testinfra-winrm-transport` Test infrastructures Sep 21, 2023 5 - Production/Stable N/A :pypi:`pytest-testit-parametrize` A pytest plugin for uploading parameterized tests parameters into TMS TestIT Dec 04, 2024 4 - Beta pytest>=8.3.3 :pypi:`pytest-testlink-adaptor` pytest reporting plugin for testlink Dec 20, 2018 4 - Beta pytest (>=2.6) - :pypi:`pytest-testmon` selects tests affected by changed files and methods Feb 27, 2024 4 - Beta pytest <9,>=5 + :pypi:`pytest-testmon` selects tests affected by changed files and methods Dec 22, 2024 4 - Beta pytest<9,>=5 :pypi:`pytest-testmon-dev` selects tests affected by changed files and methods Mar 30, 2023 4 - Beta pytest (<8,>=5) :pypi:`pytest-testmon-oc` nOly selects tests affected by changed files and methods Jun 01, 2022 4 - Beta pytest (<8,>=5) :pypi:`pytest-testmon-skip-libraries` selects tests affected by changed files and methods Mar 03, 2023 4 - Beta pytest (<8,>=5) @@ -1495,7 +1497,7 @@ This list contains 1559 plugins. :pypi:`pytest-ui` Text User Interface for running python tests Jul 05, 2021 4 - Beta pytest :pypi:`pytest-ui-failed-screenshot` UI自动测试失败时自动截图,并将截图加入到测试报告中 Dec 06, 2022 N/A N/A :pypi:`pytest-ui-failed-screenshot-allure` UI自动测试失败时自动截图,并将截图加入到Allure测试报告中 Dec 06, 2022 N/A N/A - :pypi:`pytest-uncollect-if` A plugin to uncollect pytests tests rather than using skipif Mar 24, 2024 4 - Beta pytest>=6.2.0 + :pypi:`pytest-uncollect-if` A plugin to uncollect pytests tests rather than using skipif Dec 26, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-unflakable` Unflakable plugin for PyTest Apr 30, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-unhandled-exception-exit-code` Plugin for py.test set a different exit code on uncaught exceptions Jun 22, 2020 5 - Production/Stable pytest (>=2.3) :pypi:`pytest-unique` Pytest fixture to generate unique values. Oct 21, 2024 N/A pytest<8.0.0,>=7.4.2 @@ -1539,7 +1541,7 @@ This list contains 1559 plugins. :pypi:`pytest-web3-data` A pytest plugin to fetch test data from IPFS HTTP gateways during pytest execution. Oct 04, 2023 4 - Beta pytest :pypi:`pytest-webdriver` Selenium webdriver fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-webstage` Test web apps with pytest Sep 20, 2024 N/A pytest<9.0,>=7.0 - :pypi:`pytest-webtest-extras` Pytest plugin to enhance pytest-html and allure reports of webtest projects by adding screenshots, comments and webpage sources. Oct 03, 2024 N/A pytest>=7.0.0 + :pypi:`pytest-webtest-extras` Pytest plugin to enhance pytest-html and allure reports of webtest projects by adding screenshots, comments and webpage sources. Dec 28, 2024 N/A pytest>=7.0.0 :pypi:`pytest-wetest` Welian API Automation test framework pytest plugin Nov 10, 2018 4 - Beta N/A :pypi:`pytest-when` Utility which makes mocking more readable and controllable Nov 29, 2024 N/A pytest>=7.3.1 :pypi:`pytest-whirlwind` Testing Tornado. Jun 12, 2020 N/A N/A @@ -1774,9 +1776,9 @@ This list contains 1559 plugins. py.test integration for aioresponses :pypi:`pytest-aioworkers` - *last release*: May 01, 2023, + *last release*: Dec 26, 2024, *status*: 5 - Production/Stable, - *requires*: pytest>=6.1.0 + *requires*: pytest>=8.3.4 A plugin to test aioworkers project with pytest @@ -2172,6 +2174,13 @@ This list contains 1559 plugins. Pytest support for asyncio + :pypi:`pytest-asyncio-concurrent` + *last release*: Dec 26, 2024, + *status*: 4 - Beta, + *requires*: pytest>=6.2.0 + + Pytest plugin to execute python async tests concurrently. + :pypi:`pytest-asyncio-cooperative` *last release*: Jul 04, 2024, *status*: N/A, @@ -2214,6 +2223,13 @@ This list contains 1559 plugins. Skip rest of tests if previous test failed. + :pypi:`pytest-atstack` + *last release*: Dec 28, 2024, + *status*: 4 - Beta, + *requires*: pytest>=6.2.0 + + A simple plugin to use with pytest + :pypi:`pytest-attrib` *last release*: May 24, 2016, *status*: 4 - Beta, @@ -2460,7 +2476,7 @@ This list contains 1559 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Dec 16, 2024, + *last release*: Dec 23, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -3895,7 +3911,7 @@ This list contains 1559 plugins. plugin for rich text descriptions :pypi:`pytest-deselect-if` - *last release*: Mar 24, 2024, + *last release*: Dec 26, 2024, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -5722,7 +5738,7 @@ This list contains 1559 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Dec 05, 2024, + *last release*: Dec 23, 2024, *status*: N/A, *requires*: pytest>=3.6 @@ -6030,9 +6046,9 @@ This list contains 1559 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Dec 21, 2024, + *last release*: Dec 26, 2024, *status*: 3 - Alpha, - *requires*: pytest==8.3.3 + *requires*: pytest==8.3.4 Experimental package to automatically extract test plugins for Home Assistant custom components @@ -7402,7 +7418,7 @@ This list contains 1559 plugins. pytest plugin to write integration tests for projects using Mercurial Python internals :pypi:`pytest-mergify` - *last release*: Dec 20, 2024, + *last release*: Dec 27, 2024, *status*: N/A, *requires*: N/A @@ -7773,7 +7789,7 @@ This list contains 1559 plugins. Mypy static type checker plugin for Pytest :pypi:`pytest-mypy-plugins` - *last release*: Mar 31, 2024, + *last release*: Dec 21, 2024, *status*: 4 - Beta, *requires*: pytest>=7.0.0 @@ -8298,7 +8314,7 @@ This list contains 1559 plugins. A more user-friendly way to write parametrized tests. :pypi:`pytest-parametrized` - *last release*: Oct 22, 2024, + *last release*: Dec 21, 2024, *status*: 5 - Production/Stable, *requires*: pytest @@ -9292,7 +9308,7 @@ This list contains 1559 plugins. Randomise the order in which pytest tests are run with some control over the randomness :pypi:`pytest-ranking` - *last release*: Jun 07, 2024, + *last release*: Dec 23, 2024, *status*: 4 - Beta, *requires*: pytest>=7.4.3 @@ -9516,9 +9532,9 @@ This list contains 1559 plugins. A basic HTML report for pytest using Jinja2 template engine. :pypi:`pytest-report-extras` - *last release*: Dec 15, 2024, + *last release*: Dec 28, 2024, *status*: N/A, - *requires*: pytest>=7.0.0 + *requires*: pytest>=8.0.0 Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots and webpage sources. @@ -9670,7 +9686,7 @@ This list contains 1559 plugins. pytest plugin to re-run tests to eliminate flaky failures :pypi:`pytest-reserial` - *last release*: Jul 23, 2024, + *last release*: Dec 22, 2024, *status*: 4 - Beta, *requires*: pytest @@ -10041,7 +10057,7 @@ This list contains 1559 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Dec 15, 2024, + *last release*: Dec 25, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -10118,7 +10134,7 @@ This list contains 1559 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Dec 15, 2024, + *last release*: Dec 25, 2024, *status*: 5 - Production/Stable, *requires*: N/A @@ -11203,9 +11219,9 @@ This list contains 1559 plugins. pytest reporting plugin for testlink :pypi:`pytest-testmon` - *last release*: Feb 27, 2024, + *last release*: Dec 22, 2024, *status*: 4 - Beta, - *requires*: pytest <9,>=5 + *requires*: pytest<9,>=5 selects tests affected by changed files and methods @@ -11826,7 +11842,7 @@ This list contains 1559 plugins. UI自动测试失败时自动截图,并将截图加入到Allure测试报告中 :pypi:`pytest-uncollect-if` - *last release*: Mar 24, 2024, + *last release*: Dec 26, 2024, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -12134,7 +12150,7 @@ This list contains 1559 plugins. Test web apps with pytest :pypi:`pytest-webtest-extras` - *last release*: Oct 03, 2024, + *last release*: Dec 28, 2024, *status*: N/A, *requires*: pytest>=7.0.0 From f2c3237f51518715db455b33d53bc1fa3c831a04 Mon Sep 17 00:00:00 2001 From: "Jason N. White" Date: Wed, 1 Jan 2025 03:58:27 -0500 Subject: [PATCH 235/445] Update LICENSE, fix license year (#13097) Signed-off-by: JasonnnW3000 --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index c3f1657fce9..b591972a049 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2004 Holger Krekel and others +Copyright (c) 2025 Holger Krekel and others Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in From 0d90a31d4a647fa7ba0d53a05b9266c2d4aaa05a Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 1 Jan 2025 16:40:40 +0100 Subject: [PATCH 236/445] Revert "Update LICENSE, fix license year (#13097)" This reverts commit f2c3237f51518715db455b33d53bc1fa3c831a04. --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index b591972a049..c3f1657fce9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2025 Holger Krekel and others +Copyright (c) 2004 Holger Krekel and others Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in From 7e5c1b631df47629b62171f856bdcd1c684eae81 Mon Sep 17 00:00:00 2001 From: Julian Valentin <128477611+JulianJvn@users.noreply.github.com> Date: Thu, 2 Jan 2025 08:31:08 +0100 Subject: [PATCH 237/445] Fix -vv overriding --durations-min (#12938) --- AUTHORS | 1 + changelog/12938.bugfix.rst | 1 + src/_pytest/runner.py | 14 +++++++++--- testing/acceptance_test.py | 44 ++++++++++++++++++++++++-------------- 4 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 changelog/12938.bugfix.rst diff --git a/AUTHORS b/AUTHORS index 9629e00bcfb..f9bade5f0fa 100644 --- a/AUTHORS +++ b/AUTHORS @@ -225,6 +225,7 @@ Joseph Hunkeler Joseph Sawaya Josh Karpel Joshua Bronson +Julian Valentin Jurko Gospodnetić Justice Ndou Justyna Janczyszyn diff --git a/changelog/12938.bugfix.rst b/changelog/12938.bugfix.rst new file mode 100644 index 00000000000..d54d73bdbf5 --- /dev/null +++ b/changelog/12938.bugfix.rst @@ -0,0 +1 @@ +Fixed ``--durations-min`` argument not respected if ``-vv`` is used. diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index d2b7fda8c2a..973892f2c92 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -61,7 +61,7 @@ def pytest_addoption(parser: Parser) -> None: "--durations-min", action="store", type=float, - default=0.005, + default=None, metavar="N", help="Minimal duration in seconds for inclusion in slowest list. " "Default: 0.005.", @@ -74,6 +74,8 @@ def pytest_terminal_summary(terminalreporter: TerminalReporter) -> None: verbose = terminalreporter.config.get_verbosity() if durations is None: return + if durations_min is None: + durations_min = 0.005 if verbose < 2 else 0.0 tr = terminalreporter dlist = [] for replist in tr.stats.values(): @@ -90,10 +92,16 @@ def pytest_terminal_summary(terminalreporter: TerminalReporter) -> None: dlist = dlist[:durations] for i, rep in enumerate(dlist): - if verbose < 2 and rep.duration < durations_min: + if rep.duration < durations_min: tr.write_line("") tr.write_line( - f"({len(dlist) - i} durations < {durations_min:g}s hidden. Use -vv to show these durations.)" + f"({len(dlist) - i} durations < {durations_min:g}s hidden." + + ( + " Use -vv to show these durations." + if terminalreporter.config.option.durations_min is None + else "" + ) + + ")" ) break tr.write_line(f"{rep.duration:02.2f}s {rep.when:<8} {rep.nodeid}") diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index ba1f86f02d9..a42940c9f6a 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1,6 +1,7 @@ # mypy: allow-untyped-defs from __future__ import annotations +from collections.abc import Sequence import dataclasses import importlib.metadata import os @@ -970,28 +971,39 @@ def test_calls_showall(self, pytester: Pytester, mock_timing) -> None: pytester.makepyfile(self.source) result = pytester.runpytest_inprocess("--durations=0") assert result.ret == 0 - - tested = "3" - for x in tested: - for y in ("call",): # 'setup', 'call', 'teardown': - for line in result.stdout.lines: - if (f"test_{x}") in line and y in line: - break - else: - raise AssertionError(f"not found {x} {y}") + print(result.stdout) + TestDurations.check_tests_in_output(result.stdout.lines, "23") def test_calls_showall_verbose(self, pytester: Pytester, mock_timing) -> None: pytester.makepyfile(self.source) result = pytester.runpytest_inprocess("--durations=0", "-vv") assert result.ret == 0 + TestDurations.check_tests_in_output(result.stdout.lines, "123") - for x in "123": - for y in ("call",): # 'setup', 'call', 'teardown': - for line in result.stdout.lines: - if (f"test_{x}") in line and y in line: - break - else: - raise AssertionError(f"not found {x} {y}") + def test_calls_showall_durationsmin(self, pytester: Pytester, mock_timing) -> None: + pytester.makepyfile(self.source) + result = pytester.runpytest_inprocess("--durations=0", "--durations-min=0.015") + assert result.ret == 0 + TestDurations.check_tests_in_output(result.stdout.lines, "3") + + def test_calls_showall_durationsmin_verbose( + self, pytester: Pytester, mock_timing + ) -> None: + pytester.makepyfile(self.source) + result = pytester.runpytest_inprocess( + "--durations=0", "--durations-min=0.015", "-vv" + ) + assert result.ret == 0 + TestDurations.check_tests_in_output(result.stdout.lines, "3") + + @staticmethod + def check_tests_in_output(lines: Sequence[str], expected_test_numbers: str) -> None: + found_test_numbers = "".join( + test_number + for test_number in "123" + if any(f"test_{test_number}" in line and " call " in line for line in lines) + ) + assert found_test_numbers == expected_test_numbers def test_with_deselected(self, pytester: Pytester, mock_timing) -> None: pytester.makepyfile(self.source) From 30e7ad9aed0989a1047f1beeec198ba12eda51a4 Mon Sep 17 00:00:00 2001 From: Julian Valentin <128477611+JulianJvn@users.noreply.github.com> Date: Thu, 2 Jan 2025 18:39:52 +0100 Subject: [PATCH 238/445] Remove leftover debug print in acceptance_test --- testing/acceptance_test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index a42940c9f6a..4fed0f015d1 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -971,7 +971,6 @@ def test_calls_showall(self, pytester: Pytester, mock_timing) -> None: pytester.makepyfile(self.source) result = pytester.runpytest_inprocess("--durations=0") assert result.ret == 0 - print(result.stdout) TestDurations.check_tests_in_output(result.stdout.lines, "23") def test_calls_showall_verbose(self, pytester: Pytester, mock_timing) -> None: From 61b4f7a157cab3da8e444bd3b5c81a9413a39b7b Mon Sep 17 00:00:00 2001 From: Julian Valentin <128477611+JulianJvn@users.noreply.github.com> Date: Thu, 2 Jan 2025 18:39:52 +0100 Subject: [PATCH 239/445] Clarify --durations-min default in help text --- src/_pytest/runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index 973892f2c92..98090f3b4c6 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -64,7 +64,7 @@ def pytest_addoption(parser: Parser) -> None: default=None, metavar="N", help="Minimal duration in seconds for inclusion in slowest list. " - "Default: 0.005.", + "Default: 0.005 (or 0.0 if -vv is given).", ) From a811765b21bc428273fc054f553d8be5b19da2b0 Mon Sep 17 00:00:00 2001 From: Julian Valentin <128477611+JulianJvn@users.noreply.github.com> Date: Thu, 2 Jan 2025 18:39:52 +0100 Subject: [PATCH 240/445] Simplify message formatting --- src/_pytest/runner.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index 98090f3b4c6..f0543289267 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -94,15 +94,11 @@ def pytest_terminal_summary(terminalreporter: TerminalReporter) -> None: for i, rep in enumerate(dlist): if rep.duration < durations_min: tr.write_line("") - tr.write_line( - f"({len(dlist) - i} durations < {durations_min:g}s hidden." - + ( - " Use -vv to show these durations." - if terminalreporter.config.option.durations_min is None - else "" - ) - + ")" - ) + message = f"({len(dlist) - i} durations < {durations_min:g}s hidden." + if terminalreporter.config.option.durations_min is None: + message += " Use -vv to show these durations." + message += ")" + tr.write_line(message) break tr.write_line(f"{rep.duration:02.2f}s {rep.when:<8} {rep.nodeid}") From 6f98c96cbf80756b1b360dc5f4860ac7d7dc9427 Mon Sep 17 00:00:00 2001 From: pytest bot Date: Sun, 5 Jan 2025 00:26:35 +0000 Subject: [PATCH 241/445] [automated] Update plugin list --- doc/en/reference/plugin_list.rst | 120 ++++++++++++++++++++----------- 1 file changed, 80 insertions(+), 40 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 6b2a1898203..2ccaa87b5e6 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =6.1.0 :pypi:`pytest-aiohttp-client` Pytest \`client\` fixture for the Aiohttp Jan 10, 2023 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-aiomoto` pytest-aiomoto Jun 24, 2023 N/A pytest (>=7.0,<8.0) - :pypi:`pytest-aioresponses` py.test integration for aioresponses Jul 29, 2021 4 - Beta pytest (>=3.5.0) + :pypi:`pytest-aioresponses` py.test integration for aioresponses Jan 02, 2025 4 - Beta pytest>=3.5.0 :pypi:`pytest-aioworkers` A plugin to test aioworkers project with pytest Dec 26, 2024 5 - Production/Stable pytest>=8.3.4 :pypi:`pytest-airflow` pytest support for airflow. Apr 03, 2019 3 - Alpha pytest (>=4.4.0) :pypi:`pytest-airflow-utils` Nov 15, 2021 N/A N/A @@ -115,15 +115,15 @@ This list contains 1561 plugins. :pypi:`pytest-ast-transformer` May 04, 2019 3 - Alpha pytest :pypi:`pytest_async` pytest-async - Run your coroutine in event loop without decorator Feb 26, 2020 N/A N/A :pypi:`pytest-async-generators` Pytest fixtures for async generators Jul 05, 2023 N/A N/A - :pypi:`pytest-asyncio` Pytest support for asyncio Dec 13, 2024 4 - Beta pytest<9,>=8.2 - :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Dec 26, 2024 4 - Beta pytest>=6.2.0 + :pypi:`pytest-asyncio` Pytest support for asyncio Jan 02, 2025 4 - Beta pytest<9,>=8.2 + :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Jan 03, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Jul 04, 2024 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) :pypi:`pytest-async-mongodb` pytest plugin for async MongoDB Oct 18, 2017 5 - Production/Stable pytest (>=2.5.2) :pypi:`pytest-async-sqlalchemy` Database testing fixtures using the SQLAlchemy asyncio API Oct 07, 2021 4 - Beta pytest (>=6.0.0) :pypi:`pytest-atf-allure` 基于allure-pytest进行自定义 Nov 29, 2023 N/A pytest (>=7.4.2,<8.0.0) :pypi:`pytest-atomic` Skip rest of tests if previous test failed. Nov 24, 2018 4 - Beta N/A - :pypi:`pytest-atstack` A simple plugin to use with pytest Dec 28, 2024 4 - Beta pytest>=6.2.0 + :pypi:`pytest-atstack` A simple plugin to use with pytest Jan 02, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-attrib` pytest plugin to select tests based on attributes similar to the nose-attrib plugin May 24, 2016 4 - Beta N/A :pypi:`pytest-attributes` A plugin that allows users to add attributes to their tests. These attributes can then be referenced by fixtures or the test itself. Jun 24, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-austin` Austin plugin for pytest Oct 11, 2020 4 - Beta N/A @@ -218,6 +218,7 @@ This list contains 1561 plugins. :pypi:`pytest-cassandra` Cassandra CCM Test Fixtures for pytest Nov 04, 2017 1 - Planning N/A :pypi:`pytest-catchlog` py.test plugin to catch log messages. This is a fork of pytest-capturelog. Jan 24, 2016 4 - Beta pytest (>=2.6) :pypi:`pytest-catch-server` Pytest plugin with server for catching HTTP requests. Dec 12, 2019 5 - Production/Stable N/A + :pypi:`pytest-cdist` Add your description here Dec 31, 2024 N/A pytest>=7 :pypi:`pytest-celery` Pytest plugin for Celery Sep 20, 2024 4 - Beta N/A :pypi:`pytest-cfg-fetcher` Pass config options to your unit tests. Feb 26, 2024 N/A N/A :pypi:`pytest-chainmaker` pytest plugin for chainmaker Oct 15, 2021 N/A N/A @@ -553,7 +554,7 @@ This list contains 1561 plugins. :pypi:`pytest-fastest` Use SCM and coverage to run only needed tests Oct 04, 2023 4 - Beta pytest (>=4.4) :pypi:`pytest-fast-first` Pytest plugin that runs fast tests first Jan 19, 2023 3 - Alpha pytest :pypi:`pytest-faulthandler` py.test plugin that activates the fault handler module for tests (dummy package) Jul 04, 2019 6 - Mature pytest (>=5.0) - :pypi:`pytest-fauna` A collection of helpful test fixtures for Fauna DB. Oct 17, 2024 N/A N/A + :pypi:`pytest-fauna` A collection of helpful test fixtures for Fauna DB. Jan 03, 2025 N/A N/A :pypi:`pytest-fauxfactory` Integration of fauxfactory into pytest. Dec 06, 2017 5 - Production/Stable pytest (>=3.2) :pypi:`pytest-figleaf` py.test figleaf coverage plugin Jan 18, 2010 5 - Production/Stable N/A :pypi:`pytest-file` Pytest File Mar 18, 2024 1 - Planning N/A @@ -669,7 +670,7 @@ This list contains 1561 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Dec 26, 2024 3 - Alpha pytest==8.3.4 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Jan 04, 2025 3 - Alpha pytest==8.3.4 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -689,7 +690,7 @@ This list contains 1561 plugins. :pypi:`pytest-html-thread` pytest plugin for generating HTML reports Dec 29, 2020 5 - Production/Stable N/A :pypi:`pytest-http` Fixture "http" for http requests Aug 22, 2024 N/A pytest :pypi:`pytest-httpbin` Easily test your HTTP library against a local copy of httpbin Sep 18, 2024 5 - Production/Stable pytest; extra == "test" - :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace Nov 23, 2024 4 - Beta pytest>=7.0.0 + :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace Dec 29, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-http-mocker` Pytest plugin for http mocking (via https://github.com/vilus/mocker) Oct 20, 2019 N/A N/A :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Aug 11, 2024 3 - Alpha N/A @@ -708,7 +709,7 @@ This list contains 1561 plugins. :pypi:`pytest-idempotent` Pytest plugin for testing function idempotence. Jul 25, 2022 N/A N/A :pypi:`pytest-ignore-flaky` ignore failures from flaky tests (pytest plugin) Apr 20, 2024 5 - Production/Stable pytest>=6.0 :pypi:`pytest-ignore-test-results` A pytest plugin to ignore test results. Aug 17, 2023 2 - Pre-Alpha pytest>=7.0 - :pypi:`pytest-image-diff` Mar 09, 2023 3 - Alpha pytest + :pypi:`pytest-image-diff` Dec 31, 2024 3 - Alpha pytest :pypi:`pytest-image-snapshot` A pytest plugin for image snapshot management and comparison. Jul 01, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-import-check` pytest plugin to check whether Python modules can be imported Jul 19, 2024 3 - Alpha pytest>=8.1 :pypi:`pytest-incremental` an incremental test runner (pytest plugin) Apr 24, 2021 5 - Production/Stable N/A @@ -771,6 +772,7 @@ This list contains 1561 plugins. :pypi:`pytest-json-report-wip` A pytest plugin to report test results as JSON files Oct 28, 2023 4 - Beta pytest >=3.8.0 :pypi:`pytest-jsonschema` A pytest plugin to perform JSONSchema validations Mar 27, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-jtr` pytest plugin supporting json test report output Jul 21, 2024 N/A pytest<8.0.0,>=7.1.2 + :pypi:`pytest-junit-xray-xml` Export test results in an augmented JUnit format for usage with Xray () Jan 01, 2025 4 - Beta pytest :pypi:`pytest-jupyter` A pytest plugin for testing Jupyter libraries and extensions. Apr 04, 2024 4 - Beta pytest>=7.0 :pypi:`pytest-jupyterhub` A reusable JupyterHub pytest plugin Apr 25, 2023 5 - Production/Stable pytest :pypi:`pytest-kafka` Zookeeper, Kafka server, and Kafka consumer fixtures for Pytest Aug 14, 2024 N/A pytest @@ -829,6 +831,7 @@ This list contains 1561 plugins. :pypi:`pytest-logger` Plugin configuring handlers for loggers from Python logging module. Mar 10, 2024 5 - Production/Stable pytest (>=3.2) :pypi:`pytest-logging` Configures logging and allows tweaking the log level with a py.test flag Nov 04, 2015 4 - Beta N/A :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) + :pypi:`pytest-logging-strict` pytest fixture logging configured from packaged YAML Jan 03, 2025 3 - Alpha pytest :pypi:`pytest-logikal` Common testing environment Nov 27, 2024 5 - Production/Stable pytest==8.3.3 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Sep 30, 2024 4 - Beta pytest>=8.2.2 @@ -858,7 +861,7 @@ This list contains 1561 plugins. :pypi:`pytest-maybe-raises` Pytest fixture for optional exception testing. May 27, 2022 N/A pytest ; extra == 'dev' :pypi:`pytest-mccabe` pytest plugin to run the mccabe code complexity checker. Jul 22, 2020 3 - Alpha pytest (>=5.4.0) :pypi:`pytest-md` Plugin for generating Markdown reports for pytest results Jul 11, 2019 3 - Alpha pytest (>=4.2.1) - :pypi:`pytest-md-report` A pytest plugin to generate test outcomes reports with markdown table format. May 18, 2024 4 - Beta pytest!=6.0.0,<9,>=3.3.2 + :pypi:`pytest-md-report` A pytest plugin to generate test outcomes reports with markdown table format. Jan 02, 2025 4 - Beta pytest!=6.0.0,<9,>=3.3.2 :pypi:`pytest-meilisearch` Pytest helpers for testing projects using Meilisearch Oct 08, 2024 N/A pytest>=7.4.3 :pypi:`pytest-memlog` Log memory usage during tests May 03, 2023 N/A pytest (>=7.3.0,<8.0.0) :pypi:`pytest-memprof` Estimates memory consumption of test functions Mar 29, 2019 4 - Beta N/A @@ -898,6 +901,7 @@ This list contains 1561 plugins. :pypi:`pytest-molecule-JC` PyTest Molecule Plugin :: discover and run molecule tests Jul 18, 2023 5 - Production/Stable pytest (>=7.0.0) :pypi:`pytest-mongo` MongoDB process and client fixtures plugin for Pytest. Mar 13, 2024 5 - Production/Stable pytest >=6.2 :pypi:`pytest-mongodb` pytest plugin for MongoDB fixtures May 16, 2023 5 - Production/Stable N/A + :pypi:`pytest-mongodb-ry` pytest plugin for MongoDB Dec 31, 2024 N/A N/A :pypi:`pytest-monitor` Pytest plugin for analyzing resource usage. Jun 25, 2023 5 - Production/Stable pytest :pypi:`pytest-monkeyplus` pytest's monkeypatch subclass with extra functionalities Sep 18, 2012 5 - Production/Stable N/A :pypi:`pytest-monkeytype` pytest-monkeytype: Generate Monkeytype annotations from your pytest tests. Jul 29, 2020 4 - Beta N/A @@ -1013,7 +1017,7 @@ This list contains 1561 plugins. :pypi:`pytest-percents` Mar 16, 2024 N/A N/A :pypi:`pytest-perf` Run performance tests against the mainline code. May 20, 2024 5 - Production/Stable pytest!=8.1.*,>=6; extra == "testing" :pypi:`pytest-performance` A simple plugin to ensure the execution of critical sections of code has not been impacted Sep 11, 2020 5 - Production/Stable pytest (>=3.7.0) - :pypi:`pytest-performancetotal` A performance plugin for pytest Mar 19, 2024 4 - Beta N/A + :pypi:`pytest-performancetotal` A performance plugin for pytest Dec 31, 2024 5 - Production/Stable N/A :pypi:`pytest-persistence` Pytest tool for persistent objects Aug 21, 2024 N/A N/A :pypi:`pytest-pexpect` Pytest pexpect plugin. Aug 13, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-pg` A tiny plugin for pytest which runs PostgreSQL in Docker May 21, 2024 5 - Production/Stable pytest>=6.0.0 @@ -1060,7 +1064,7 @@ This list contains 1561 plugins. :pypi:`pytest-postgres` Run PostgreSQL in Docker container in Pytest. Mar 22, 2020 N/A pytest :pypi:`pytest-postgresql` Postgresql fixtures and fixture factories for Pytest. Sep 05, 2024 5 - Production/Stable pytest>=6.2 :pypi:`pytest-power` pytest plugin with powerful fixtures Dec 31, 2020 N/A pytest (>=5.4) - :pypi:`pytest-powerpack` A plugin containing extra batteries for pytest Dec 17, 2024 N/A pytest<9.0.0,>=8.1.1 + :pypi:`pytest-powerpack` A plugin containing extra batteries for pytest Jan 04, 2025 N/A pytest<9.0.0,>=8.1.1 :pypi:`pytest-prefer-nested-dup-tests` A Pytest plugin to drop duplicated tests during collection, but will prefer keeping nested packages. Apr 27, 2022 4 - Beta pytest (>=7.1.1,<8.0.0) :pypi:`pytest-pretty` pytest plugin for printing summary data as I want it Apr 05, 2023 5 - Production/Stable pytest>=7 :pypi:`pytest-pretty-terminal` pytest plugin for generating prettier terminal output Jan 31, 2022 N/A pytest (>=3.4.1) @@ -1167,7 +1171,7 @@ This list contains 1561 plugins. :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Oct 11, 2024 4 - Beta N/A :pypi:`pytest-reporter-html-dots` A basic HTML report for pytest using Jinja2 template engine. Jan 22, 2023 N/A N/A - :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots and webpage sources. Dec 28, 2024 N/A pytest>=8.0.0 + :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots and webpage sources. Jan 04, 2025 N/A pytest>=8.0.0 :pypi:`pytest-reportinfra` Pytest plugin for reportinfra Aug 11, 2019 3 - Alpha N/A :pypi:`pytest-reporting` A plugin to report summarized results in a table format Oct 25, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-reportlog` Replacement for the --resultlog option, focused in simplicity and extensibility May 22, 2023 3 - Alpha pytest @@ -1263,7 +1267,7 @@ This list contains 1561 plugins. :pypi:`pytest-server` test server exec cmd Sep 09, 2024 N/A N/A :pypi:`pytest-server-fixtures` Extensible server fixtures for py.test Nov 29, 2024 5 - Production/Stable pytest :pypi:`pytest-serverless` Automatically mocks resources from serverless.yml in pytest using moto. May 09, 2022 4 - Beta N/A - :pypi:`pytest-servers` pytest servers Nov 14, 2024 3 - Alpha pytest>=6.2 + :pypi:`pytest-servers` pytest servers Dec 29, 2024 3 - Alpha pytest>=6.2 :pypi:`pytest-service` Aug 06, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-services` Services plugin for pytest testing framework Oct 30, 2020 6 - Mature N/A :pypi:`pytest-session2file` pytest-session2file (aka: pytest-session_to_file for v0.1.0 - v0.1.2) is a py.test plugin for capturing and saving to file the stdout of py.test. Jan 26, 2021 3 - Alpha pytest @@ -1299,7 +1303,7 @@ This list contains 1561 plugins. :pypi:`pytest-smartcollect` A plugin for collecting tests that touch changed code Oct 04, 2018 N/A pytest (>=3.5.0) :pypi:`pytest-smartcov` Smart coverage plugin for pytest. Sep 30, 2017 3 - Alpha N/A :pypi:`pytest-smell` Automated bad smell detection tool for Pytest Jun 26, 2022 N/A N/A - :pypi:`pytest-smoke` Pytest plugin for smoke testing Dec 13, 2024 4 - Beta pytest<9,>=7.0.0 + :pypi:`pytest-smoke` Pytest plugin for smoke testing Dec 30, 2024 4 - Beta pytest<9,>=7.0.0 :pypi:`pytest-smtp` Send email with pytest execution result Feb 20, 2021 N/A pytest :pypi:`pytest-smtp4dev` Plugin for smtp4dev API Jun 27, 2023 5 - Production/Stable N/A :pypi:`pytest-smtpd` An SMTP server for testing built on aiosmtpd May 15, 2023 N/A pytest @@ -1335,7 +1339,7 @@ This list contains 1561 plugins. :pypi:`pytest-split-tests` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Forked from Mark Adams' original project pytest-test-groups. Jul 30, 2021 5 - Production/Stable pytest (>=2.5) :pypi:`pytest-split-tests-tresorit` Feb 22, 2021 1 - Planning N/A :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Oct 28, 2024 N/A pytest<8,>5.4.0 - :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Nov 24, 2024 N/A N/A + :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Jan 03, 2025 N/A N/A :pypi:`pytest-splunk-env` pytest fixtures for interaction with Splunk Enterprise and Splunk Cloud Oct 22, 2020 N/A pytest (>=6.1.1,<7.0.0) :pypi:`pytest-sqitch` sqitch for pytest Apr 06, 2020 4 - Beta N/A :pypi:`pytest-sqlalchemy` pytest plugin with sqlalchemy related fixtures Mar 13, 2018 3 - Alpha N/A @@ -1366,7 +1370,7 @@ This list contains 1561 plugins. :pypi:`pytest-stubprocess` Provide stub implementations for subprocesses in Python tests Sep 17, 2018 3 - Alpha pytest (>=3.5.0) :pypi:`pytest-study` A pytest plugin to organize long run tests (named studies) without interfering the regular tests Sep 26, 2017 3 - Alpha pytest (>=2.0) :pypi:`pytest-subinterpreter` Run pytest in a subinterpreter Nov 25, 2023 N/A pytest>=7.0.0 - :pypi:`pytest-subprocess` A plugin to fake subprocess for pytest Jul 24, 2024 5 - Production/Stable pytest>=4.0.0 + :pypi:`pytest-subprocess` A plugin to fake subprocess for pytest Jan 04, 2025 5 - Production/Stable pytest>=4.0.0 :pypi:`pytest-subtesthack` A hack to explicitly set up and tear down fixtures. Jul 16, 2022 N/A N/A :pypi:`pytest-subtests` unittest subTest() support and subtests fixture Dec 10, 2024 4 - Beta pytest>=7.4 :pypi:`pytest-subunit` pytest-subunit is a plugin for py.test which outputs testsresult in subunit format. Sep 17, 2023 N/A pytest (>=2.3) @@ -1500,7 +1504,7 @@ This list contains 1561 plugins. :pypi:`pytest-uncollect-if` A plugin to uncollect pytests tests rather than using skipif Dec 26, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-unflakable` Unflakable plugin for PyTest Apr 30, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-unhandled-exception-exit-code` Plugin for py.test set a different exit code on uncaught exceptions Jun 22, 2020 5 - Production/Stable pytest (>=2.3) - :pypi:`pytest-unique` Pytest fixture to generate unique values. Oct 21, 2024 N/A pytest<8.0.0,>=7.4.2 + :pypi:`pytest-unique` Pytest fixture to generate unique values. Jan 03, 2025 N/A pytest<8.0.0,>=7.4.2 :pypi:`pytest-unittest-filter` A pytest plugin for filtering unittest-based test classes Jan 12, 2019 4 - Beta pytest (>=3.1.0) :pypi:`pytest-unmagic` Pytest fixtures with conventional import semantics Oct 22, 2024 5 - Production/Stable pytest :pypi:`pytest-unmarked` Run only unmarked tests Aug 27, 2019 5 - Production/Stable N/A @@ -1556,6 +1560,7 @@ This list contains 1561 plugins. :pypi:`pytest-xdist-forked` forked from pytest-xdist Feb 10, 2020 5 - Production/Stable pytest (>=4.4.0) :pypi:`pytest-xdist-tracker` pytest plugin helps to reproduce failures for particular xdist node Nov 18, 2021 3 - Alpha pytest (>=3.5.1) :pypi:`pytest-xdist-worker-stats` A pytest plugin to list worker statistics after a xdist run. Apr 16, 2024 4 - Beta pytest>=7.0.0 + :pypi:`pytest-xdocker` Pytest fixture to run docker across test runs. Jan 04, 2025 N/A pytest<8.0.0,>=7.4.2 :pypi:`pytest-xfaillist` Maintain a xfaillist in an additional file to avoid merge-conflicts. Sep 17, 2021 N/A pytest (>=6.2.2,<7.0.0) :pypi:`pytest-xfiles` Pytest fixtures providing data read from function, module or package related (x)files. Feb 27, 2018 N/A N/A :pypi:`pytest-xflaky` A simple plugin to use with pytest Oct 14, 2024 4 - Beta pytest>=8.2.1 @@ -1573,7 +1578,7 @@ This list contains 1561 plugins. :pypi:`pytest-xvfb` A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. May 29, 2023 4 - Beta pytest (>=2.8.1) :pypi:`pytest-xvirt` A pytest plugin to virtualize test. For example to transparently running them on a remote box. Dec 15, 2024 4 - Beta pytest>=7.2.2 :pypi:`pytest-yaml` This plugin is used to load yaml output to your test using pytest framework. Oct 05, 2018 N/A pytest - :pypi:`pytest-yaml-sanmu` Pytest plugin for generating test cases with YAML. In test cases, you can use markers, fixtures, variables, and even call Python functions. Nov 20, 2024 N/A pytest~=8.2.2 + :pypi:`pytest-yaml-sanmu` Pytest plugin for generating test cases with YAML. In test cases, you can use markers, fixtures, variables, and even call Python functions. Jan 03, 2025 N/A pytest>=8.2.2 :pypi:`pytest-yamltree` Create or check file/directory trees described by YAML Mar 02, 2020 4 - Beta pytest (>=3.1.1) :pypi:`pytest-yamlwsgi` Run tests against wsgi apps defined in yaml May 11, 2010 N/A N/A :pypi:`pytest-yaml-yoyo` http/https API run by yaml Jun 19, 2023 N/A pytest (>=7.2.0) @@ -1769,9 +1774,9 @@ This list contains 1561 plugins. pytest-aiomoto :pypi:`pytest-aioresponses` - *last release*: Jul 29, 2021, + *last release*: Jan 02, 2025, *status*: 4 - Beta, - *requires*: pytest (>=3.5.0) + *requires*: pytest>=3.5.0 py.test integration for aioresponses @@ -2168,14 +2173,14 @@ This list contains 1561 plugins. Pytest fixtures for async generators :pypi:`pytest-asyncio` - *last release*: Dec 13, 2024, + *last release*: Jan 02, 2025, *status*: 4 - Beta, *requires*: pytest<9,>=8.2 Pytest support for asyncio :pypi:`pytest-asyncio-concurrent` - *last release*: Dec 26, 2024, + *last release*: Jan 03, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -2224,7 +2229,7 @@ This list contains 1561 plugins. Skip rest of tests if previous test failed. :pypi:`pytest-atstack` - *last release*: Dec 28, 2024, + *last release*: Jan 02, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -2888,6 +2893,13 @@ This list contains 1561 plugins. Pytest plugin with server for catching HTTP requests. + :pypi:`pytest-cdist` + *last release*: Dec 31, 2024, + *status*: N/A, + *requires*: pytest>=7 + + Add your description here + :pypi:`pytest-celery` *last release*: Sep 20, 2024, *status*: 4 - Beta, @@ -5234,7 +5246,7 @@ This list contains 1561 plugins. py.test plugin that activates the fault handler module for tests (dummy package) :pypi:`pytest-fauna` - *last release*: Oct 17, 2024, + *last release*: Jan 03, 2025, *status*: N/A, *requires*: N/A @@ -6046,7 +6058,7 @@ This list contains 1561 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Dec 26, 2024, + *last release*: Jan 04, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.4 @@ -6186,7 +6198,7 @@ This list contains 1561 plugins. Easily test your HTTP library against a local copy of httpbin :pypi:`pytest-httpdbg` - *last release*: Nov 23, 2024, + *last release*: Dec 29, 2024, *status*: 4 - Beta, *requires*: pytest>=7.0.0 @@ -6319,7 +6331,7 @@ This list contains 1561 plugins. A pytest plugin to ignore test results. :pypi:`pytest-image-diff` - *last release*: Mar 09, 2023, + *last release*: Dec 31, 2024, *status*: 3 - Alpha, *requires*: pytest @@ -6759,6 +6771,13 @@ This list contains 1561 plugins. pytest plugin supporting json test report output + :pypi:`pytest-junit-xray-xml` + *last release*: Jan 01, 2025, + *status*: 4 - Beta, + *requires*: pytest + + Export test results in an augmented JUnit format for usage with Xray () + :pypi:`pytest-jupyter` *last release*: Apr 04, 2024, *status*: 4 - Beta, @@ -7165,6 +7184,13 @@ This list contains 1561 plugins. + :pypi:`pytest-logging-strict` + *last release*: Jan 03, 2025, + *status*: 3 - Alpha, + *requires*: pytest + + pytest fixture logging configured from packaged YAML + :pypi:`pytest-logikal` *last release*: Nov 27, 2024, *status*: 5 - Production/Stable, @@ -7369,7 +7395,7 @@ This list contains 1561 plugins. Plugin for generating Markdown reports for pytest results :pypi:`pytest-md-report` - *last release*: May 18, 2024, + *last release*: Jan 02, 2025, *status*: 4 - Beta, *requires*: pytest!=6.0.0,<9,>=3.3.2 @@ -7648,6 +7674,13 @@ This list contains 1561 plugins. pytest plugin for MongoDB fixtures + :pypi:`pytest-mongodb-ry` + *last release*: Dec 31, 2024, + *status*: N/A, + *requires*: N/A + + pytest plugin for MongoDB + :pypi:`pytest-monitor` *last release*: Jun 25, 2023, *status*: 5 - Production/Stable, @@ -8454,8 +8487,8 @@ This list contains 1561 plugins. A simple plugin to ensure the execution of critical sections of code has not been impacted :pypi:`pytest-performancetotal` - *last release*: Mar 19, 2024, - *status*: 4 - Beta, + *last release*: Dec 31, 2024, + *status*: 5 - Production/Stable, *requires*: N/A A performance plugin for pytest @@ -8783,7 +8816,7 @@ This list contains 1561 plugins. pytest plugin with powerful fixtures :pypi:`pytest-powerpack` - *last release*: Dec 17, 2024, + *last release*: Jan 04, 2025, *status*: N/A, *requires*: pytest<9.0.0,>=8.1.1 @@ -9532,7 +9565,7 @@ This list contains 1561 plugins. A basic HTML report for pytest using Jinja2 template engine. :pypi:`pytest-report-extras` - *last release*: Dec 28, 2024, + *last release*: Jan 04, 2025, *status*: N/A, *requires*: pytest>=8.0.0 @@ -10204,7 +10237,7 @@ This list contains 1561 plugins. Automatically mocks resources from serverless.yml in pytest using moto. :pypi:`pytest-servers` - *last release*: Nov 14, 2024, + *last release*: Dec 29, 2024, *status*: 3 - Alpha, *requires*: pytest>=6.2 @@ -10456,7 +10489,7 @@ This list contains 1561 plugins. Automated bad smell detection tool for Pytest :pypi:`pytest-smoke` - *last release*: Dec 13, 2024, + *last release*: Dec 30, 2024, *status*: 4 - Beta, *requires*: pytest<9,>=7.0.0 @@ -10708,7 +10741,7 @@ This list contains 1561 plugins. A Dynamic test tool for Splunk Apps and Add-ons :pypi:`pytest-splunk-addon-ui-smartx` - *last release*: Nov 24, 2024, + *last release*: Jan 03, 2025, *status*: N/A, *requires*: N/A @@ -10925,7 +10958,7 @@ This list contains 1561 plugins. Run pytest in a subinterpreter :pypi:`pytest-subprocess` - *last release*: Jul 24, 2024, + *last release*: Jan 04, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=4.0.0 @@ -11863,7 +11896,7 @@ This list contains 1561 plugins. Plugin for py.test set a different exit code on uncaught exceptions :pypi:`pytest-unique` - *last release*: Oct 21, 2024, + *last release*: Jan 03, 2025, *status*: N/A, *requires*: pytest<8.0.0,>=7.4.2 @@ -12254,6 +12287,13 @@ This list contains 1561 plugins. A pytest plugin to list worker statistics after a xdist run. + :pypi:`pytest-xdocker` + *last release*: Jan 04, 2025, + *status*: N/A, + *requires*: pytest<8.0.0,>=7.4.2 + + Pytest fixture to run docker across test runs. + :pypi:`pytest-xfaillist` *last release*: Sep 17, 2021, *status*: N/A, @@ -12374,9 +12414,9 @@ This list contains 1561 plugins. This plugin is used to load yaml output to your test using pytest framework. :pypi:`pytest-yaml-sanmu` - *last release*: Nov 20, 2024, + *last release*: Jan 03, 2025, *status*: N/A, - *requires*: pytest~=8.2.2 + *requires*: pytest>=8.2.2 Pytest plugin for generating test cases with YAML. In test cases, you can use markers, fixtures, variables, and even call Python functions. From 071bfb3d04408d2ccb9c7966347eda061b3a8762 Mon Sep 17 00:00:00 2001 From: Julian Valentin <128477611+JulianJvn@users.noreply.github.com> Date: Tue, 7 Jan 2025 08:39:40 +0100 Subject: [PATCH 242/445] Supply test numbers instead of string Use `endswith()` because the code would break for `number_of_tests >= 10` (as `test_10` also contains `test_1`). --- testing/acceptance_test.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 4fed0f015d1..06b97c34707 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -971,19 +971,19 @@ def test_calls_showall(self, pytester: Pytester, mock_timing) -> None: pytester.makepyfile(self.source) result = pytester.runpytest_inprocess("--durations=0") assert result.ret == 0 - TestDurations.check_tests_in_output(result.stdout.lines, "23") + TestDurations.check_tests_in_output(result.stdout.lines, 2, 3) def test_calls_showall_verbose(self, pytester: Pytester, mock_timing) -> None: pytester.makepyfile(self.source) result = pytester.runpytest_inprocess("--durations=0", "-vv") assert result.ret == 0 - TestDurations.check_tests_in_output(result.stdout.lines, "123") + TestDurations.check_tests_in_output(result.stdout.lines, 1, 2, 3) def test_calls_showall_durationsmin(self, pytester: Pytester, mock_timing) -> None: pytester.makepyfile(self.source) result = pytester.runpytest_inprocess("--durations=0", "--durations-min=0.015") assert result.ret == 0 - TestDurations.check_tests_in_output(result.stdout.lines, "3") + TestDurations.check_tests_in_output(result.stdout.lines, 3) def test_calls_showall_durationsmin_verbose( self, pytester: Pytester, mock_timing @@ -993,16 +993,22 @@ def test_calls_showall_durationsmin_verbose( "--durations=0", "--durations-min=0.015", "-vv" ) assert result.ret == 0 - TestDurations.check_tests_in_output(result.stdout.lines, "3") + TestDurations.check_tests_in_output(result.stdout.lines, 3) @staticmethod - def check_tests_in_output(lines: Sequence[str], expected_test_numbers: str) -> None: - found_test_numbers = "".join( + def check_tests_in_output( + lines: Sequence[str], *expected_test_numbers: int + ) -> None: + number_of_tests = 3 + found_test_numbers = set( test_number - for test_number in "123" - if any(f"test_{test_number}" in line and " call " in line for line in lines) + for test_number in range(1, number_of_tests + 1) + if any( + line.endswith(f"test_{test_number}") and " call " in line + for line in lines + ) ) - assert found_test_numbers == expected_test_numbers + assert found_test_numbers == set(expected_test_numbers) def test_with_deselected(self, pytester: Pytester, mock_timing) -> None: pytester.makepyfile(self.source) From 0d077e640cb7d347f63c44026659b2ec46ab3e59 Mon Sep 17 00:00:00 2001 From: Julian Valentin <128477611+JulianJvn@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:22:27 +0100 Subject: [PATCH 243/445] Move number_of_tests to parameters --- testing/acceptance_test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 06b97c34707..ffd1dcce219 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -997,9 +997,8 @@ def test_calls_showall_durationsmin_verbose( @staticmethod def check_tests_in_output( - lines: Sequence[str], *expected_test_numbers: int + lines: Sequence[str], *expected_test_numbers: int, number_of_tests: int = 3 ) -> None: - number_of_tests = 3 found_test_numbers = set( test_number for test_number in range(1, number_of_tests + 1) From 888cf3fd76adf5a9bfabc04736b96f9be3f55dbc Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 7 Jan 2025 11:25:55 +0100 Subject: [PATCH 244/445] Fix selftests with Pygments >= 2.19.0 With Pygments 2.19, the Python lexer now emits Text.Whitespace (rather than Text) tokens after "def", which get highlighted as "bright black". See https://github.com/pygments/pygments/issues/1905 Fixes #13112 --- changelog/13112.contrib.rst | 1 + testing/conftest.py | 8 ++++++++ testing/test_terminal.py | 10 +++++----- 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 changelog/13112.contrib.rst diff --git a/changelog/13112.contrib.rst b/changelog/13112.contrib.rst new file mode 100644 index 00000000000..5e59a736edb --- /dev/null +++ b/changelog/13112.contrib.rst @@ -0,0 +1 @@ +Fixed selftest failures in ``test_terminal.py`` with Pygments >= 2.19.0 diff --git a/testing/conftest.py b/testing/conftest.py index 110ad0d9b35..c9ffd33835b 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -2,10 +2,14 @@ from __future__ import annotations from collections.abc import Generator +import importlib.metadata import dataclasses import re import sys +import pygments +from packaging.version import Version + from _pytest.monkeypatch import MonkeyPatch from _pytest.pytester import Pytester import pytest @@ -168,6 +172,9 @@ def color_mapping(): Used by tests which check the actual colors output by pytest. """ + # https://github.com/pygments/pygments/commit/d24e272894a56a98b1b718d9ac5fabc20124882a + pygments_version = Version(importlib.metadata.version("pygments")) + pygments_has_kwspace_hl = pygments_version >= Version("2.19") class ColorMapping: COLORS = { @@ -180,6 +187,7 @@ class ColorMapping: "bold": "\x1b[1m", "reset": "\x1b[0m", "kw": "\x1b[94m", + "kwspace": "\x1b[90m \x1b[39;49;00m" if pygments_has_kwspace_hl else " ", "hl-reset": "\x1b[39;49;00m", "function": "\x1b[92m", "number": "\x1b[94m", diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 6fa04be28b1..32206364125 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -1294,13 +1294,13 @@ def test_this(): "=*= FAILURES =*=", "{red}{bold}_*_ test_this _*_{reset}", "", - " {reset}{kw}def{hl-reset} {function}test_this{hl-reset}():{endline}", + " {reset}{kw}def{hl-reset}{kwspace}{function}test_this{hl-reset}():{endline}", "> fail(){endline}", "", "{bold}{red}test_color_yes.py{reset}:5: ", "_ _ * _ _*", "", - " {reset}{kw}def{hl-reset} {function}fail{hl-reset}():{endline}", + " {reset}{kw}def{hl-reset}{kwspace}{function}fail{hl-reset}():{endline}", "> {kw}assert{hl-reset} {number}0{hl-reset}{endline}", "{bold}{red}E assert 0{reset}", "", @@ -2580,7 +2580,7 @@ def test_foo(): result.stdout.fnmatch_lines( color_mapping.format_for_fnmatch( [ - " {reset}{kw}def{hl-reset} {function}test_foo{hl-reset}():{endline}", + " {reset}{kw}def{hl-reset}{kwspace}{function}test_foo{hl-reset}():{endline}", "> {kw}assert{hl-reset} {number}1{hl-reset} == {number}10{hl-reset}{endline}", "{bold}{red}E assert 1 == 10{reset}", ] @@ -2602,7 +2602,7 @@ def test_foo(): result.stdout.fnmatch_lines( color_mapping.format_for_fnmatch( [ - " {reset}{kw}def{hl-reset} {function}test_foo{hl-reset}():{endline}", + " {reset}{kw}def{hl-reset}{kwspace}{function}test_foo{hl-reset}():{endline}", " {print}print{hl-reset}({str}'''{hl-reset}{str}{hl-reset}", "> {str} {hl-reset}{str}'''{hl-reset}); {kw}assert{hl-reset} {number}0{hl-reset}{endline}", "{bold}{red}E assert 0{reset}", @@ -2625,7 +2625,7 @@ def test_foo(): result.stdout.fnmatch_lines( color_mapping.format_for_fnmatch( [ - " {reset}{kw}def{hl-reset} {function}test_foo{hl-reset}():{endline}", + " {reset}{kw}def{hl-reset}{kwspace}{function}test_foo{hl-reset}():{endline}", "> {kw}assert{hl-reset} {number}1{hl-reset} == {number}10{hl-reset}{endline}", "{bold}{red}E assert 1 == 10{reset}", ] From ecf05486c8e72b7e49e547bf1124ddd02f7aacb3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 8 Jan 2025 14:02:19 +0000 Subject: [PATCH 245/445] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- testing/conftest.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/testing/conftest.py b/testing/conftest.py index c9ffd33835b..45a47cbdbaa 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -2,12 +2,11 @@ from __future__ import annotations from collections.abc import Generator -import importlib.metadata import dataclasses +import importlib.metadata import re import sys -import pygments from packaging.version import Version from _pytest.monkeypatch import MonkeyPatch From 3214263b2f0d17b265c40cf5f87d70357b9a219d Mon Sep 17 00:00:00 2001 From: delta87 <124760624+delta87@users.noreply.github.com> Date: Thu, 9 Jan 2025 00:27:22 +0330 Subject: [PATCH 246/445] Fix crash when directory is removed during collection (#13086) Fixes #13083 --------- Co-authored-by: Bruno Oliveira --- AUTHORS | 1 + changelog/13083.bugfix.rst | 1 + src/_pytest/pathlib.py | 13 ++++++++++--- testing/test_pathlib.py | 24 ++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 changelog/13083.bugfix.rst diff --git a/AUTHORS b/AUTHORS index 9629e00bcfb..826556f1464 100644 --- a/AUTHORS +++ b/AUTHORS @@ -360,6 +360,7 @@ Ran Benita Raphael Castaneda Raphael Pierzina Rafal Semik +Reza Mousavi Raquel Alegre Ravi Chandra Reagan Lee diff --git a/changelog/13083.bugfix.rst b/changelog/13083.bugfix.rst new file mode 100644 index 00000000000..fc4564755ba --- /dev/null +++ b/changelog/13083.bugfix.rst @@ -0,0 +1 @@ +Fixed issue where pytest could crash if one of the collected directories got removed during collection. diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index 25dc69b6349..7c06e2df962 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -955,17 +955,24 @@ def scandir( The returned entries are sorted according to the given key. The default is to sort by name. + If the directory does not exist, return an empty list. """ entries = [] - with os.scandir(path) as s: - # Skip entries with symlink loops and other brokenness, so the caller - # doesn't have to deal with it. + # Attempt to create a scandir iterator for the given path. + try: + scandir_iter = os.scandir(path) + except FileNotFoundError: + # If the directory does not exist, return an empty list. + return [] + # Use the scandir iterator in a context manager to ensure it is properly closed. + with scandir_iter as s: for entry in s: try: entry.is_file() except OSError as err: if _ignore_error(err): continue + # Reraise non-ignorable errors to avoid hiding issues. raise entries.append(entry) entries.sort(key=sort_key) # type: ignore[arg-type] diff --git a/testing/test_pathlib.py b/testing/test_pathlib.py index 5a13cd5a400..65a4117812f 100644 --- a/testing/test_pathlib.py +++ b/testing/test_pathlib.py @@ -38,6 +38,7 @@ from _pytest.pathlib import resolve_package_path from _pytest.pathlib import resolve_pkg_root_and_module_name from _pytest.pathlib import safe_exists +from _pytest.pathlib import scandir from _pytest.pathlib import spec_matches_module_path from _pytest.pathlib import symlink_or_skip from _pytest.pathlib import visit @@ -569,6 +570,29 @@ def test_samefile_false_negatives(tmp_path: Path, monkeypatch: MonkeyPatch) -> N assert getattr(module, "foo")() == 42 +def test_scandir_with_non_existent_directory() -> None: + # Test with a directory that does not exist + non_existent_dir = "path_to_non_existent_dir" + result = scandir(non_existent_dir) + # Assert that the result is an empty list + assert result == [] + + +def test_scandir_handles_os_error() -> None: + # Create a mock entry that will raise an OSError when is_file is called + mock_entry = unittest.mock.MagicMock() + mock_entry.is_file.side_effect = OSError("some permission error") + # Mock os.scandir to return an iterator with our mock entry + with unittest.mock.patch("os.scandir") as mock_scandir: + mock_scandir.return_value.__enter__.return_value = [mock_entry] + # Call the scandir function with a path + # We expect an OSError to be raised here + with pytest.raises(OSError, match="some permission error"): + scandir("/fake/path") + # Verify that the is_file method was called on the mock entry + mock_entry.is_file.assert_called_once() + + class TestImportLibMode: def test_importmode_importlib_with_dataclass( self, tmp_path: Path, ns_param: bool From 2931fdb4227f2683d1ad6e6088bc8b839ada2c86 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 08:36:57 +0000 Subject: [PATCH 247/445] build(deps): Bump anyio[trio] from 4.7.0 to 4.8.0 in /testing/plugins_integration (#13109) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Pierre Sassoulas Co-authored-by: Thomas Grainger --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 74be0367cdc..d508bc525c1 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,4 +1,4 @@ -anyio[curio,trio]==4.7.0 +anyio[trio]==4.8.0 django==5.1.4 pytest-asyncio==0.25.0 pytest-bdd==8.1.0 From 7307a62ff4e92dc2694d5d924d875c10d329fd80 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 25 Dec 2024 20:45:51 +0100 Subject: [PATCH 248/445] [mypy] Fixes 'Enum members must be left unannotated' --- src/_pytest/scope.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/_pytest/scope.py b/src/_pytest/scope.py index 976a3ba242e..2b007e87893 100644 --- a/src/_pytest/scope.py +++ b/src/_pytest/scope.py @@ -33,11 +33,11 @@ class Scope(Enum): """ # Scopes need to be listed from lower to higher. - Function: _ScopeName = "function" - Class: _ScopeName = "class" - Module: _ScopeName = "module" - Package: _ScopeName = "package" - Session: _ScopeName = "session" + Function = "function" + Class = "class" + Module = "module" + Package = "package" + Session = "session" def next_lower(self) -> Scope: """Return the next lower scope.""" From f48a469eedf08f83355bd2d7f56784f0b72aead0 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 25 Dec 2024 20:56:30 +0100 Subject: [PATCH 249/445] [style] fix shadowed import name 'errno' from outer scope --- src/_pytest/_py/error.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/_pytest/_py/error.py b/src/_pytest/_py/error.py index de0c04a4838..8b7f63d6925 100644 --- a/src/_pytest/_py/error.py +++ b/src/_pytest/_py/error.py @@ -90,15 +90,14 @@ def checked_call( except OSError as value: if not hasattr(value, "errno"): raise - errno = value.errno if sys.platform == "win32": try: - cls = self._geterrnoclass(_winerrnomap[errno]) + cls = self._geterrnoclass(_winerrnomap[value.errno]) except KeyError: raise value else: # we are not on Windows, or we got a proper OSError - cls = self._geterrnoclass(errno) + cls = self._geterrnoclass(value.errno) raise cls(f"{func.__name__}{args!r}") From 0ca9eecf2ceafc259d4d0c393750273ba981b6f5 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 25 Dec 2024 21:27:47 +0100 Subject: [PATCH 250/445] [mypy] noqa false positive in NamespaceLoader --- src/_pytest/pathlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index 7c06e2df962..b69e85404e7 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -711,7 +711,7 @@ def _import_module_using_spec( if module_path.is_dir(): # The `spec_from_file_location` matches a loader based on the file extension by default. # For a namespace package, need to manually specify a loader. - loader = NamespaceLoader(name, module_path, PathFinder()) + loader = NamespaceLoader(name, module_path, PathFinder()) # type: ignore[arg-type] spec = importlib.util.spec_from_file_location( module_name, str(module_path), loader=loader From b509fce545623a26dcd90a906694a38c11825861 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 25 Dec 2024 21:28:46 +0100 Subject: [PATCH 251/445] [mypy] Proper typing of mixed type string wrapper --- testing/io/test_terminalwriter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/testing/io/test_terminalwriter.py b/testing/io/test_terminalwriter.py index f14e884b1f0..1f38d6f15d9 100644 --- a/testing/io/test_terminalwriter.py +++ b/testing/io/test_terminalwriter.py @@ -3,6 +3,7 @@ from collections.abc import Generator import io +from io import StringIO import os from pathlib import Path import re @@ -68,6 +69,7 @@ def test_terminalwriter_not_unicode() -> None: class TestTerminalWriter: @pytest.fixture(params=["path", "stringio"]) def tw(self, request, tmp_path: Path) -> Generator[terminalwriter.TerminalWriter]: + f: io.TextIOWrapper | StringIO if request.param == "path": p = tmp_path.joinpath("tmpfile") f = open(str(p), "w+", encoding="utf8") From 86464b4c3bb668f5df8e26bd56f5e8207d9e490a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 Jan 2025 00:27:33 +0000 Subject: [PATCH 252/445] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.3 → v0.8.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.3...v0.8.6) - [github.com/woodruffw/zizmor-pre-commit: v0.9.2 → v1.0.0](https://github.com/woodruffw/zizmor-pre-commit/compare/v0.9.2...v1.0.0) - [github.com/pre-commit/mirrors-mypy: v1.13.0 → v1.14.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.13.0...v1.14.1) - [github.com/asottile/pyupgrade: v3.19.0 → v3.19.1](https://github.com/asottile/pyupgrade/compare/v3.19.0...v3.19.1) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d7a4efabe98..06ced48d531 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.8.3" + rev: "v0.8.6" hooks: - id: ruff args: ["--fix"] @@ -12,7 +12,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/woodruffw/zizmor-pre-commit - rev: v0.9.2 + rev: v1.0.1 hooks: - id: zizmor - repo: https://github.com/adamchainz/blacken-docs @@ -32,7 +32,7 @@ repos: hooks: - id: python-use-type-annotations - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.13.0 + rev: v1.14.1 hooks: - id: mypy files: ^(src/|testing/|scripts/) @@ -54,7 +54,7 @@ repos: # https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version additional_dependencies: ["tox>=4.9"] - repo: https://github.com/asottile/pyupgrade - rev: v3.19.0 + rev: v3.19.1 hooks: - id: pyupgrade args: From 3432c20d18d3b0c6b6b4264c1e7299212e59414c Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Thu, 9 Jan 2025 15:07:36 +0100 Subject: [PATCH 253/445] [mypy] Fix "ErrorMaker._geterrnoclass" got "Optional[int] expected int --- src/_pytest/_py/error.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/_pytest/_py/error.py b/src/_pytest/_py/error.py index 8b7f63d6925..1c7984f5a8f 100644 --- a/src/_pytest/_py/error.py +++ b/src/_pytest/_py/error.py @@ -97,7 +97,14 @@ def checked_call( raise value else: # we are not on Windows, or we got a proper OSError - cls = self._geterrnoclass(value.errno) + if value.errno is None: + cls = type( + "UnknownErrnoNone", + (Error,), + {"__module__": "py.error", "__doc__": None}, + ) + else: + cls = self._geterrnoclass(value.errno) raise cls(f"{func.__name__}{args!r}") From 475b9c708ea83156bc4a65b377ea175659f31002 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Thu, 9 Jan 2025 22:24:07 +0100 Subject: [PATCH 254/445] [pre-commit] Upgrade ruff to 0.9.0 / 2025's style --- .pre-commit-config.yaml | 2 +- doc/en/example/assertion/failure_demo.py | 6 +- scripts/prepare-release-pr.py | 2 +- scripts/update-plugin-list.py | 4 +- src/_pytest/_code/code.py | 28 ++++---- src/_pytest/cacheprovider.py | 3 +- src/_pytest/capture.py | 16 ++--- src/_pytest/compat.py | 4 +- src/_pytest/config/__init__.py | 12 ++-- src/_pytest/fixtures.py | 10 +-- src/_pytest/python.py | 6 +- src/_pytest/python_api.py | 5 +- src/_pytest/reports.py | 6 +- testing/_py/test_local.py | 6 +- testing/test_junitxml.py | 90 ++++++++++++------------ testing/test_terminal.py | 4 +- 16 files changed, 103 insertions(+), 101 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 06ced48d531..0533a404c3d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.8.6" + rev: "v0.9.0" hooks: - id: ruff args: ["--fix"] diff --git a/doc/en/example/assertion/failure_demo.py b/doc/en/example/assertion/failure_demo.py index dd1485b0b21..16a578fda12 100644 --- a/doc/en/example/assertion/failure_demo.py +++ b/doc/en/example/assertion/failure_demo.py @@ -267,9 +267,9 @@ class A: a = 1 b = 2 - assert ( - A.a == b - ), "A.a appears not to be b\nor does not appear to be b\none of those" + assert A.a == b, ( + "A.a appears not to be b\nor does not appear to be b\none of those" + ) def test_custom_repr(self): class JSON: diff --git a/scripts/prepare-release-pr.py b/scripts/prepare-release-pr.py index 49cb2110639..49f8f8c431d 100644 --- a/scripts/prepare-release-pr.py +++ b/scripts/prepare-release-pr.py @@ -163,7 +163,7 @@ def find_next_version( last_version = valid_versions[-1] if is_major: - return f"{last_version[0]+1}.0.0{prerelease}" + return f"{last_version[0] + 1}.0.0{prerelease}" elif is_feature_release: return f"{last_version[0]}.{last_version[1] + 1}.0{prerelease}" else: diff --git a/scripts/update-plugin-list.py b/scripts/update-plugin-list.py index 693a25a00cc..347952cc7e4 100644 --- a/scripts/update-plugin-list.py +++ b/scripts/update-plugin-list.py @@ -176,7 +176,7 @@ def version_sort_key(version_string: str) -> Any: ) last_release = release_date.strftime("%b %d, %Y") break - name = f':pypi:`{info["name"]}`' + name = f":pypi:`{info['name']}`" summary = "" if info["summary"]: summary = escape_rst(info["summary"].replace("\n", "")) @@ -194,7 +194,7 @@ def plugin_definitions(plugins: Iterable[PluginInfo]) -> Iterator[str]: for plugin in plugins: yield dedent( f""" - {plugin['name']} + {plugin["name"]} *last release*: {plugin["last_release"]}, *status*: {plugin["status"]}, *requires*: {plugin["requires"]} diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index bba8896076e..5be200df9de 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -217,7 +217,7 @@ def relline(self) -> int: return self.lineno - self.frame.code.firstlineno def __repr__(self) -> str: - return f"" + return f"" @property def statement(self) -> Source: @@ -303,7 +303,7 @@ def __str__(self) -> str: # This output does not quite match Python's repr for traceback entries, # but changing it to do so would break certain plugins. See # https://github.com/pytest-dev/pytest/pull/7535/ for details. - return f" File '{self.path}':{self.lineno+1} in {name}\n {line}\n" + return f" File '{self.path}':{self.lineno + 1} in {name}\n {line}\n" @property def name(self) -> str: @@ -527,33 +527,33 @@ def fill_unfilled(self, exc_info: tuple[type[E], E, TracebackType]) -> None: @property def type(self) -> type[E]: """The exception class.""" - assert ( - self._excinfo is not None - ), ".type can only be used after the context manager exits" + assert self._excinfo is not None, ( + ".type can only be used after the context manager exits" + ) return self._excinfo[0] @property def value(self) -> E: """The exception value.""" - assert ( - self._excinfo is not None - ), ".value can only be used after the context manager exits" + assert self._excinfo is not None, ( + ".value can only be used after the context manager exits" + ) return self._excinfo[1] @property def tb(self) -> TracebackType: """The exception raw traceback.""" - assert ( - self._excinfo is not None - ), ".tb can only be used after the context manager exits" + assert self._excinfo is not None, ( + ".tb can only be used after the context manager exits" + ) return self._excinfo[2] @property def typename(self) -> str: """The type name of the exception.""" - assert ( - self._excinfo is not None - ), ".typename can only be used after the context manager exits" + assert self._excinfo is not None, ( + ".typename can only be used after the context manager exits" + ) return self.type.__name__ @property diff --git a/src/_pytest/cacheprovider.py b/src/_pytest/cacheprovider.py index facb98f09e0..dea60109b51 100755 --- a/src/_pytest/cacheprovider.py +++ b/src/_pytest/cacheprovider.py @@ -482,8 +482,7 @@ def pytest_addoption(parser: Parser) -> None: "--last-failed", action="store_true", dest="lf", - help="Rerun only the tests that failed " - "at the last run (or all if none failed)", + help="Rerun only the tests that failed at the last run (or all if none failed)", ) group.addoption( "--ff", diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index de2ee9c8dbd..5c21590c937 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -375,10 +375,10 @@ def __repr__(self) -> str: ) def _assert_state(self, op: str, states: tuple[str, ...]) -> None: - assert ( - self._state in states - ), "cannot {} in state {!r}: expected one of {}".format( - op, self._state, ", ".join(states) + assert self._state in states, ( + "cannot {} in state {!r}: expected one of {}".format( + op, self._state, ", ".join(states) + ) ) def start(self) -> None: @@ -492,10 +492,10 @@ def __repr__(self) -> str: ) def _assert_state(self, op: str, states: tuple[str, ...]) -> None: - assert ( - self._state in states - ), "cannot {} in state {!r}: expected one of {}".format( - op, self._state, ", ".join(states) + assert self._state in states, ( + "cannot {} in state {!r}: expected one of {}".format( + op, self._state, ", ".join(states) + ) ) def start(self) -> None: diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 053ef1fd1fd..2cbb17eca38 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -70,8 +70,8 @@ def getlocation(function, curdir: str | os.PathLike[str] | None = None) -> str: except ValueError: pass else: - return f"{relfn}:{lineno+1}" - return f"{fn}:{lineno+1}" + return f"{relfn}:{lineno + 1}" + return f"{fn}:{lineno + 1}" def num_mock_patch_args(function) -> int: diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 0161f5952b8..3db5e3da983 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -838,9 +838,9 @@ def import_plugin(self, modname: str, consider_entry_points: bool = False) -> No # "terminal" or "capture". Those plugins are registered under their # basename for historic purposes but must be imported with the # _pytest prefix. - assert isinstance( - modname, str - ), f"module name as text required, got {modname!r}" + assert isinstance(modname, str), ( + f"module name as text required, got {modname!r}" + ) if self.is_blocked(modname) or self.get_plugin(modname) is not None: return @@ -1503,9 +1503,9 @@ def _get_unknown_ini_keys(self) -> list[str]: def parse(self, args: list[str], addopts: bool = True) -> None: # Parse given cmdline arguments into this config object. - assert ( - self.args == [] - ), "can only parse cmdline args at most once per Config object" + assert self.args == [], ( + "can only parse cmdline args at most once per Config object" + ) self.hook.pytest_addhooks.call_historic( kwargs=dict(pluginmanager=self.pluginmanager) ) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 8b79dbcb932..dcd06c3b40a 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -746,7 +746,9 @@ def node(self): if node is None and scope is Scope.Class: # Fallback to function item itself. node = self._pyfuncitem - assert node, f'Could not obtain a node for scope "{scope}" for function {self._pyfuncitem!r}' + assert node, ( + f'Could not obtain a node for scope "{scope}" for function {self._pyfuncitem!r}' + ) return node def _check_scope( @@ -808,9 +810,9 @@ def formatrepr(self) -> FixtureLookupErrorRepr: # new cases it might break. # Add the assert to make it clearer to developer that this will fail, otherwise # it crashes because `fspath` does not get set due to `stack` being empty. - assert ( - self.msg is None or self.fixturestack - ), "formatrepr assumptions broken, rewrite it to handle it" + assert self.msg is None or self.fixturestack, ( + "formatrepr assumptions broken, rewrite it to handle it" + ) if msg is not None: # The last fixture raise an error, let's present # it at the requesting side. diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 85e3cb0ae71..ef8a5f02b53 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -914,9 +914,9 @@ def make_unique_parameterset_ids(self) -> list[str]: new_id = f"{id}{suffix}{id_suffixes[id]}" resolved_ids[index] = new_id id_suffixes[id] += 1 - assert len(resolved_ids) == len( - set(resolved_ids) - ), f"Internal error: {resolved_ids=}" + assert len(resolved_ids) == len(set(resolved_ids)), ( + f"Internal error: {resolved_ids=}" + ) return resolved_ids def _resolve_ids(self) -> Iterable[str]: diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index cbb2ff2b80a..25cf9f04d61 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -241,7 +241,7 @@ class ApproxMapping(ApproxBase): with numeric values (the keys can be anything).""" def __repr__(self) -> str: - return f"approx({({k: self._approx_scalar(v) for k, v in self.expected.items()})!r})" + return f"approx({ ({k: self._approx_scalar(v) for k, v in self.expected.items()})!r})" def _repr_compare(self, other_side: Mapping[object, float]) -> list[str]: import math @@ -867,7 +867,8 @@ def raises( Given that ``pytest.raises`` matches subclasses, be wary of using it to match :class:`Exception` like this:: - with pytest.raises(Exception): # Careful, this will catch ANY exception raised. + # Careful, this will catch ANY exception raised. + with pytest.raises(Exception): some_function() Because :class:`Exception` is the base class of almost all exceptions, it is easy for this to hide diff --git a/src/_pytest/reports.py b/src/_pytest/reports.py index 4d926ef6c9e..746512285b4 100644 --- a/src/_pytest/reports.py +++ b/src/_pytest/reports.py @@ -361,9 +361,9 @@ def from_item_and_call(cls, item: Item, call: CallInfo[None]) -> TestReport: elif isinstance(excinfo.value, skip.Exception): outcome = "skipped" r = excinfo._getreprcrash() - assert ( - r is not None - ), "There should always be a traceback entry for skipping a test." + assert r is not None, ( + "There should always be a traceback entry for skipping a test." + ) if excinfo.value._use_item_location: path, line = item.reportinfo()[:2] assert line is not None diff --git a/testing/_py/test_local.py b/testing/_py/test_local.py index cd8752fb79b..71594d10903 100644 --- a/testing/_py/test_local.py +++ b/testing/_py/test_local.py @@ -555,9 +555,9 @@ def batch_make_numbered_dirs(rootdir, repeats): file_ = dir_.join("foo") file_.write_text(f"{i}", encoding="utf-8") actual = int(file_.read_text(encoding="utf-8")) - assert ( - actual == i - ), f"int(file_.read_text(encoding='utf-8')) is {actual} instead of {i}" + assert actual == i, ( + f"int(file_.read_text(encoding='utf-8')) is {actual} instead of {i}" + ) dir_.join(".lock").remove(ignore_errors=True) return True diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index fd1fecb54f1..5de0e6a5d7a 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -541,28 +541,28 @@ def test_fail(): systemout_xml = systemout.toxml() assert systemout.tag == "system-out", "Expected tag: system-out" assert "info msg" not in systemout_xml, "INFO message found in system-out" - assert ( - "hello-stdout" in systemout_xml - ), "Missing 'hello-stdout' in system-out" + assert "hello-stdout" in systemout_xml, ( + "Missing 'hello-stdout' in system-out" + ) if junit_logging in ["system-err", "out-err", "all"]: systemerr = tnode.find_first_by_tag("system-err") systemerr_xml = systemerr.toxml() assert systemerr.tag == "system-err", "Expected tag: system-err" assert "info msg" not in systemerr_xml, "INFO message found in system-err" - assert ( - "hello-stderr" in systemerr_xml - ), "Missing 'hello-stderr' in system-err" - assert ( - "warning msg" not in systemerr_xml - ), "WARN message found in system-err" + assert "hello-stderr" in systemerr_xml, ( + "Missing 'hello-stderr' in system-err" + ) + assert "warning msg" not in systemerr_xml, ( + "WARN message found in system-err" + ) if junit_logging == "no": assert not tnode.find_by_tag("log"), "Found unexpected content: log" - assert not tnode.find_by_tag( - "system-out" - ), "Found unexpected content: system-out" - assert not tnode.find_by_tag( - "system-err" - ), "Found unexpected content: system-err" + assert not tnode.find_by_tag("system-out"), ( + "Found unexpected content: system-out" + ) + assert not tnode.find_by_tag("system-err"), ( + "Found unexpected content: system-err" + ) @parametrize_families def test_failure_verbose_message( @@ -807,14 +807,14 @@ def test_pass(): node = dom.find_first_by_tag("testsuite") pnode = node.find_first_by_tag("testcase") if junit_logging == "no": - assert not node.find_by_tag( - "system-out" - ), "system-out should not be generated" + assert not node.find_by_tag("system-out"), ( + "system-out should not be generated" + ) if junit_logging == "system-out": systemout = pnode.find_first_by_tag("system-out") - assert ( - "hello-stdout" in systemout.toxml() - ), "'hello-stdout' should be in system-out" + assert "hello-stdout" in systemout.toxml(), ( + "'hello-stdout' should be in system-out" + ) @pytest.mark.parametrize("junit_logging", ["no", "system-err"]) def test_pass_captures_stderr( @@ -831,14 +831,14 @@ def test_pass(): node = dom.find_first_by_tag("testsuite") pnode = node.find_first_by_tag("testcase") if junit_logging == "no": - assert not node.find_by_tag( - "system-err" - ), "system-err should not be generated" + assert not node.find_by_tag("system-err"), ( + "system-err should not be generated" + ) if junit_logging == "system-err": systemerr = pnode.find_first_by_tag("system-err") - assert ( - "hello-stderr" in systemerr.toxml() - ), "'hello-stderr' should be in system-err" + assert "hello-stderr" in systemerr.toxml(), ( + "'hello-stderr' should be in system-err" + ) @pytest.mark.parametrize("junit_logging", ["no", "system-out"]) def test_setup_error_captures_stdout( @@ -860,14 +860,14 @@ def test_function(arg): node = dom.find_first_by_tag("testsuite") pnode = node.find_first_by_tag("testcase") if junit_logging == "no": - assert not node.find_by_tag( - "system-out" - ), "system-out should not be generated" + assert not node.find_by_tag("system-out"), ( + "system-out should not be generated" + ) if junit_logging == "system-out": systemout = pnode.find_first_by_tag("system-out") - assert ( - "hello-stdout" in systemout.toxml() - ), "'hello-stdout' should be in system-out" + assert "hello-stdout" in systemout.toxml(), ( + "'hello-stdout' should be in system-out" + ) @pytest.mark.parametrize("junit_logging", ["no", "system-err"]) def test_setup_error_captures_stderr( @@ -890,14 +890,14 @@ def test_function(arg): node = dom.find_first_by_tag("testsuite") pnode = node.find_first_by_tag("testcase") if junit_logging == "no": - assert not node.find_by_tag( - "system-err" - ), "system-err should not be generated" + assert not node.find_by_tag("system-err"), ( + "system-err should not be generated" + ) if junit_logging == "system-err": systemerr = pnode.find_first_by_tag("system-err") - assert ( - "hello-stderr" in systemerr.toxml() - ), "'hello-stderr' should be in system-err" + assert "hello-stderr" in systemerr.toxml(), ( + "'hello-stderr' should be in system-err" + ) @pytest.mark.parametrize("junit_logging", ["no", "system-out"]) def test_avoid_double_stdout( @@ -921,9 +921,9 @@ def test_function(arg): node = dom.find_first_by_tag("testsuite") pnode = node.find_first_by_tag("testcase") if junit_logging == "no": - assert not node.find_by_tag( - "system-out" - ), "system-out should not be generated" + assert not node.find_by_tag("system-out"), ( + "system-out should not be generated" + ) if junit_logging == "system-out": systemout = pnode.find_first_by_tag("system-out") assert "hello-stdout call" in systemout.toxml() @@ -1544,9 +1544,9 @@ class Report(BaseReport): test_case = minidom.parse(str(path)).getElementsByTagName("testcase")[0] - assert ( - test_case.getAttribute("url") == test_url - ), "The URL did not get written to the xml" + assert test_case.getAttribute("url") == test_url, ( + "The URL did not get written to the xml" + ) @parametrize_families diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 32206364125..402e1f8dba3 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -336,7 +336,7 @@ def test_report_teststatus_explicit_markup( pytester.makeconftest( f""" def pytest_report_teststatus(report): - return {category !r}, 'F', ('FOO', {{'red': True}}) + return {category!r}, 'F', ('FOO', {{'red': True}}) """ ) pytester.makepyfile( @@ -1187,7 +1187,7 @@ def test(param): @pytest.mark.parametrize( ("use_ci", "expected_message"), ( - (True, f"- AssertionError: {'this_failed'*100}"), + (True, f"- AssertionError: {'this_failed' * 100}"), (False, "- AssertionError: this_failedt..."), ), ids=("on CI", "not on CI"), From 8826bb822fe01ca2ef36cf16ca5792628df7fe18 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Thu, 9 Jan 2025 22:26:25 +0100 Subject: [PATCH 255/445] [style] Use '<' or '>=' for 'sys.version_info' comparisons --- testing/_py/test_local.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/_py/test_local.py b/testing/_py/test_local.py index 71594d10903..461b0b599c1 100644 --- a/testing/_py/test_local.py +++ b/testing/_py/test_local.py @@ -18,7 +18,7 @@ @contextlib.contextmanager def ignore_encoding_warning(): with warnings.catch_warnings(): - if sys.version_info > (3, 10): + if sys.version_info >= (3, 10): warnings.simplefilter("ignore", EncodingWarning) # noqa: F821 yield From 05538acf906d6f6e0f75d1d0e2e2052e933761de Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 11 Jan 2025 16:45:01 +0100 Subject: [PATCH 256/445] Update links to microblogging pages (#13123) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update links to microblogging pages * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Apply suggestions from code review Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) --- RELEASING.rst | 6 +++++- doc/en/contact.rst | 7 +++++++ pyproject.toml | 3 ++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/RELEASING.rst b/RELEASING.rst index 52910de0002..7ef907f2296 100644 --- a/RELEASING.rst +++ b/RELEASING.rst @@ -168,4 +168,8 @@ Both automatic and manual processes described above follow the same steps from t * python-announce-list@python.org (all releases) * testing-in-python@lists.idyll.org (only major/minor releases) - And announce it on `Twitter `_ and `BlueSky `_ with the ``#pytest`` hashtag. + And announce it with the ``#pytest`` hashtag on: + + * `Bluesky `_ + * `Fosstodon `_ + * `Twitter/X `_ diff --git a/doc/en/contact.rst b/doc/en/contact.rst index d650a7efbab..cd34f548e99 100644 --- a/doc/en/contact.rst +++ b/doc/en/contact.rst @@ -24,6 +24,13 @@ Chat `_) - ``#pytest`` `on Matrix `_. +Microblogging +------------- + +- Bluesky: `@pytest.org `_ +- Mastodon: `@pytest@fosstodon.org `_ +- Twitter/X: `@pytestdotorg `_ + Mail ---- diff --git a/pyproject.toml b/pyproject.toml index df633e0a092..3c3c04d2d5b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,10 +64,11 @@ optional-dependencies.dev = [ "xmlschema", ] urls.Changelog = "https://docs.pytest.org/en/stable/changelog.html" +urls.Contact = "https://docs.pytest.org/en/stable/contact.html" +urls.Funding = "https://docs.pytest.org/en/stable/sponsor.html" urls.Homepage = "https://docs.pytest.org/en/latest/" urls.Source = "https://github.com/pytest-dev/pytest" urls.Tracker = "https://github.com/pytest-dev/pytest/issues" -urls.Twitter = "https://twitter.com/pytestdotorg" scripts."py.test" = "pytest:console_main" scripts.pytest = "pytest:console_main" From 7d721d2b9338bea0c1c52e8e441a42d336a69cef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 11 Jan 2025 22:18:11 +0100 Subject: [PATCH 257/445] build(deps): Bump pytest-asyncio in /testing/plugins_integration (#13121) Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.25.0 to 0.25.2. - [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases) - [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.25.0...v0.25.2) --- updated-dependencies: - dependency-name: pytest-asyncio dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index d508bc525c1..aa35aeebcd2 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,6 +1,6 @@ anyio[trio]==4.8.0 django==5.1.4 -pytest-asyncio==0.25.0 +pytest-asyncio==0.25.2 pytest-bdd==8.1.0 pytest-cov==6.0.0 pytest-django==4.9.0 From 477e9283aabc93f8d3ad34ff0b98f68b5a432aa8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 12 Jan 2025 08:58:31 -0300 Subject: [PATCH 258/445] [automated] Update plugin list (#13128) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 124 ++++++++++++++++++------------- 1 file changed, 74 insertions(+), 50 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 2ccaa87b5e6..752bc869deb 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =8.2 - :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Jan 03, 2025 4 - Beta pytest>=6.2.0 + :pypi:`pytest-asyncio` Pytest support for asyncio Jan 08, 2025 4 - Beta pytest<9,>=8.2 + :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Jan 09, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Jul 04, 2024 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) :pypi:`pytest-async-mongodb` pytest plugin for async MongoDB Oct 18, 2017 5 - Production/Stable pytest (>=2.5.2) @@ -159,7 +159,7 @@ This list contains 1566 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Dec 23, 2024 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Jan 09, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -218,7 +218,7 @@ This list contains 1566 plugins. :pypi:`pytest-cassandra` Cassandra CCM Test Fixtures for pytest Nov 04, 2017 1 - Planning N/A :pypi:`pytest-catchlog` py.test plugin to catch log messages. This is a fork of pytest-capturelog. Jan 24, 2016 4 - Beta pytest (>=2.6) :pypi:`pytest-catch-server` Pytest plugin with server for catching HTTP requests. Dec 12, 2019 5 - Production/Stable N/A - :pypi:`pytest-cdist` Add your description here Dec 31, 2024 N/A pytest>=7 + :pypi:`pytest-cdist` A pytest plugin to split your test suite into multiple parts Jan 07, 2025 N/A pytest>=7 :pypi:`pytest-celery` Pytest plugin for Celery Sep 20, 2024 4 - Beta N/A :pypi:`pytest-cfg-fetcher` Pass config options to your unit tests. Feb 26, 2024 N/A N/A :pypi:`pytest-chainmaker` pytest plugin for chainmaker Oct 15, 2021 N/A N/A @@ -270,7 +270,7 @@ This list contains 1566 plugins. :pypi:`pytest-codegen` Automatically create pytest test signatures Aug 23, 2020 2 - Pre-Alpha N/A :pypi:`pytest-codeowners` Pytest plugin for selecting tests by GitHub CODEOWNERS. Mar 30, 2022 4 - Beta pytest (>=6.0.0) :pypi:`pytest-codestyle` pytest plugin to run pycodestyle Mar 23, 2020 3 - Alpha N/A - :pypi:`pytest-codspeed` Pytest plugin to create CodSpeed benchmarks Dec 09, 2024 5 - Production/Stable pytest>=3.8 + :pypi:`pytest-codspeed` Pytest plugin to create CodSpeed benchmarks Jan 09, 2025 5 - Production/Stable pytest>=3.8 :pypi:`pytest-collect-appoint-info` set your encoding Aug 03, 2023 N/A pytest :pypi:`pytest-collect-formatter` Formatter for pytest collect output Mar 29, 2021 5 - Production/Stable N/A :pypi:`pytest-collect-formatter2` Formatter for pytest collect output May 31, 2021 5 - Production/Stable N/A @@ -321,6 +321,7 @@ This list contains 1566 plugins. :pypi:`pytest-custom-outputs` A plugin that allows users to create and use custom outputs instead of the standard Pass and Fail. Also allows users to retrieve test results in fixtures. Jul 10, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-custom-report` Configure the symbols displayed for test outcomes Jan 30, 2019 N/A pytest :pypi:`pytest-custom-scheduling` Custom grouping for pytest-xdist, rename test cases name and test cases nodeid, support allure report Mar 01, 2021 N/A N/A + :pypi:`pytest-custom-timeout` Use custom logic when a test times out. Based on pytest-timeout. Jan 08, 2025 4 - Beta pytest>=8.0.0 :pypi:`pytest-cython` A plugin for testing Cython extension modules Apr 05, 2024 5 - Production/Stable pytest>=8 :pypi:`pytest-cython-collect` Jun 17, 2022 N/A pytest :pypi:`pytest-darker` A pytest plugin for checking of modified code using Darker Feb 25, 2024 N/A pytest <7,>=6.0.1 @@ -398,7 +399,7 @@ This list contains 1566 plugins. :pypi:`pytest-django-haystack` Cleanup your Haystack indexes between tests Sep 03, 2017 5 - Production/Stable pytest (>=2.3.4) :pypi:`pytest-django-ifactory` A model instance factory for pytest-django Aug 27, 2023 5 - Production/Stable N/A :pypi:`pytest-django-lite` The bare minimum to integrate py.test with Django. Jan 30, 2014 N/A N/A - :pypi:`pytest-django-liveserver-ssl` Jan 20, 2022 3 - Alpha N/A + :pypi:`pytest-django-liveserver-ssl` Jan 09, 2025 3 - Alpha N/A :pypi:`pytest-django-model` A Simple Way to Test your Django Models Feb 14, 2019 4 - Beta N/A :pypi:`pytest-django-ordering` A pytest plugin for preserving the order in which Django runs tests. Jul 25, 2019 5 - Production/Stable pytest (>=2.3.0) :pypi:`pytest-django-queries` Generate performance reports from your django database performance tests. Mar 01, 2021 N/A N/A @@ -500,6 +501,7 @@ This list contains 1566 plugins. :pypi:`pytest-eradicate` pytest plugin to check for commented out code Sep 08, 2020 N/A pytest (>=2.4.2) :pypi:`pytest_erp` py.test plugin to send test info to report portal dynamically Jan 13, 2015 N/A N/A :pypi:`pytest-error-for-skips` Pytest plugin to treat skipped tests a test failure Dec 19, 2019 4 - Beta pytest (>=4.6) + :pypi:`pytest-errxfail` pytest plugin to mark a test as xfailed if it fails with the specified error message in the captured output Jan 06, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-eth` PyTest plugin for testing Smart Contracts for Ethereum Virtual Machine (EVM). Aug 14, 2020 1 - Planning N/A :pypi:`pytest-ethereum` pytest-ethereum: Pytest library for ethereum projects. Jun 24, 2019 3 - Alpha pytest (==3.3.2); extra == 'dev' :pypi:`pytest-eucalyptus` Pytest Plugin for BDD Jun 28, 2022 N/A pytest (>=4.2.0) @@ -615,18 +617,18 @@ This list contains 1566 plugins. :pypi:`pytest-fxa` pytest plugin for Firefox Accounts Aug 28, 2018 5 - Production/Stable N/A :pypi:`pytest-fxa-mte` pytest plugin for Firefox Accounts Oct 02, 2024 5 - Production/Stable N/A :pypi:`pytest-fxtest` Oct 27, 2020 N/A N/A - :pypi:`pytest-fzf` fzf-based test selector for pytest Jul 03, 2024 4 - Beta pytest>=6.0.0 + :pypi:`pytest-fzf` fzf-based test selector for pytest Jan 06, 2025 4 - Beta pytest>=6.0.0 :pypi:`pytest_gae` pytest plugin for apps written with Google's AppEngine Aug 03, 2016 3 - Alpha N/A :pypi:`pytest-gather-fixtures` set up asynchronous pytest fixtures concurrently Aug 18, 2024 N/A pytest>=7.0.0 :pypi:`pytest-gc` The garbage collector plugin for py.test Feb 01, 2018 N/A N/A :pypi:`pytest-gcov` Uses gcov to measure test coverage of a C library Feb 01, 2018 3 - Alpha N/A :pypi:`pytest-gcs` GCS fixtures and fixture factories for Pytest. Mar 01, 2024 5 - Production/Stable pytest >=6.2 - :pypi:`pytest-gee` The Python plugin for your GEE based packages. Dec 12, 2024 3 - Alpha pytest + :pypi:`pytest-gee` The Python plugin for your GEE based packages. Jan 10, 2025 3 - Alpha pytest :pypi:`pytest-gevent` Ensure that gevent is properly patched when invoking pytest Feb 25, 2020 N/A pytest :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Dec 23, 2024 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Jan 08, 2025 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -670,7 +672,7 @@ This list contains 1566 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Jan 04, 2025 3 - Alpha pytest==8.3.4 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Jan 10, 2025 3 - Alpha pytest==8.3.4 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -690,7 +692,7 @@ This list contains 1566 plugins. :pypi:`pytest-html-thread` pytest plugin for generating HTML reports Dec 29, 2020 5 - Production/Stable N/A :pypi:`pytest-http` Fixture "http" for http requests Aug 22, 2024 N/A pytest :pypi:`pytest-httpbin` Easily test your HTTP library against a local copy of httpbin Sep 18, 2024 5 - Production/Stable pytest; extra == "test" - :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace Dec 29, 2024 4 - Beta pytest>=7.0.0 + :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace Jan 11, 2025 4 - Beta pytest>=7.0.0 :pypi:`pytest-http-mocker` Pytest plugin for http mocking (via https://github.com/vilus/mocker) Oct 20, 2019 N/A N/A :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Aug 11, 2024 3 - Alpha N/A @@ -901,7 +903,8 @@ This list contains 1566 plugins. :pypi:`pytest-molecule-JC` PyTest Molecule Plugin :: discover and run molecule tests Jul 18, 2023 5 - Production/Stable pytest (>=7.0.0) :pypi:`pytest-mongo` MongoDB process and client fixtures plugin for Pytest. Mar 13, 2024 5 - Production/Stable pytest >=6.2 :pypi:`pytest-mongodb` pytest plugin for MongoDB fixtures May 16, 2023 5 - Production/Stable N/A - :pypi:`pytest-mongodb-ry` pytest plugin for MongoDB Dec 31, 2024 N/A N/A + :pypi:`pytest-mongodb-nono` pytest plugin for MongoDB Jan 07, 2025 N/A N/A + :pypi:`pytest-mongodb-ry` pytest plugin for MongoDB Jan 10, 2025 N/A N/A :pypi:`pytest-monitor` Pytest plugin for analyzing resource usage. Jun 25, 2023 5 - Production/Stable pytest :pypi:`pytest-monkeyplus` pytest's monkeypatch subclass with extra functionalities Sep 18, 2012 5 - Production/Stable N/A :pypi:`pytest-monkeytype` pytest-monkeytype: Generate Monkeytype annotations from your pytest tests. Jul 29, 2020 4 - Beta N/A @@ -913,7 +916,7 @@ This list contains 1566 plugins. :pypi:`pytest-mpiexec` pytest plugin for running individual tests with mpiexec Jul 29, 2024 3 - Alpha pytest :pypi:`pytest-mpl` pytest plugin to help with testing figures output from Matplotlib Feb 14, 2024 4 - Beta pytest :pypi:`pytest-mproc` low-startup-overhead, scalable, distributed-testing pytest plugin Nov 15, 2022 4 - Beta pytest (>=6) - :pypi:`pytest-mqtt` pytest-mqtt supports testing systems based on MQTT Oct 19, 2024 4 - Beta pytest<9; extra == "test" + :pypi:`pytest-mqtt` pytest-mqtt supports testing systems based on MQTT Jan 07, 2025 5 - Production/Stable pytest<9; extra == "test" :pypi:`pytest-multihost` Utility for writing multi-host tests for pytest Apr 07, 2020 4 - Beta N/A :pypi:`pytest-multilog` Multi-process logs handling and other helpers for pytest Jan 17, 2023 N/A pytest :pypi:`pytest-multithreading` a pytest plugin for th and concurrent testing Aug 05, 2024 N/A N/A @@ -931,7 +934,7 @@ This list contains 1566 plugins. :pypi:`pytest-needle` pytest plugin for visual testing websites using selenium Dec 10, 2018 4 - Beta pytest (<5.0.0,>=3.0.0) :pypi:`pytest-neo` pytest-neo is a plugin for pytest that shows tests like screen of Matrix. Jan 08, 2022 3 - Alpha pytest (>=6.2.0) :pypi:`pytest-neos` Pytest plugin for neos Sep 10, 2024 5 - Production/Stable pytest<8.0,>=7.2; extra == "dev" - :pypi:`pytest-netconf` A pytest plugin that provides a mock NETCONF (RFC6241/RFC6242) server for local testing. Aug 08, 2024 N/A N/A + :pypi:`pytest-netconf` A pytest plugin that provides a mock NETCONF (RFC6241/RFC6242) server for local testing. Jan 06, 2025 N/A N/A :pypi:`pytest-netdut` "Automated software testing for switches using pytest" Jul 05, 2024 N/A pytest<7.3,>=3.5.0 :pypi:`pytest-network` A simple plugin to disable network on socket level. May 07, 2020 N/A N/A :pypi:`pytest-network-endpoints` Network endpoints plugin for pytest Mar 06, 2022 N/A pytest @@ -1017,7 +1020,7 @@ This list contains 1566 plugins. :pypi:`pytest-percents` Mar 16, 2024 N/A N/A :pypi:`pytest-perf` Run performance tests against the mainline code. May 20, 2024 5 - Production/Stable pytest!=8.1.*,>=6; extra == "testing" :pypi:`pytest-performance` A simple plugin to ensure the execution of critical sections of code has not been impacted Sep 11, 2020 5 - Production/Stable pytest (>=3.7.0) - :pypi:`pytest-performancetotal` A performance plugin for pytest Dec 31, 2024 5 - Production/Stable N/A + :pypi:`pytest-performancetotal` A performance plugin for pytest Jan 07, 2025 5 - Production/Stable N/A :pypi:`pytest-persistence` Pytest tool for persistent objects Aug 21, 2024 N/A N/A :pypi:`pytest-pexpect` Pytest pexpect plugin. Aug 13, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-pg` A tiny plugin for pytest which runs PostgreSQL in Docker May 21, 2024 5 - Production/Stable pytest>=6.0.0 @@ -1115,7 +1118,7 @@ This list contains 1566 plugins. :pypi:`pytest-pyvenv` A package for create venv in tests Feb 27, 2024 N/A pytest ; extra == 'test' :pypi:`pytest-pyvista` Pytest-pyvista package Sep 29, 2023 4 - Beta pytest>=3.5.0 :pypi:`pytest-qanova` A pytest plugin to collect test information Sep 05, 2024 3 - Alpha pytest - :pypi:`pytest-qaseio` Pytest plugin for Qase.io integration Nov 18, 2024 5 - Production/Stable pytest<9.0.0,>=7.2.2 + :pypi:`pytest-qaseio` Pytest plugin for Qase.io integration Jan 08, 2025 5 - Production/Stable pytest<9.0.0,>=7.2.2 :pypi:`pytest-qasync` Pytest support for qasync. Jul 12, 2021 4 - Beta pytest (>=5.4.0) :pypi:`pytest-qatouch` Pytest plugin for uploading test results to your QA Touch Testrun. Feb 14, 2023 4 - Beta pytest (>=6.2.0) :pypi:`pytest-qgis` A pytest plugin for testing QGIS python plugins Jun 14, 2024 5 - Production/Stable pytest>=6.0 @@ -1142,7 +1145,7 @@ This list contains 1566 plugins. :pypi:`pytest-ranking` A Pytest plugin for automatically prioritizing/ranking tests to speed up failure detection Dec 23, 2024 4 - Beta pytest>=7.4.3 :pypi:`pytest-readme` Test your README.md file Sep 02, 2022 5 - Production/Stable N/A :pypi:`pytest-reana` Pytest fixtures for REANA. Sep 04, 2024 3 - Alpha N/A - :pypi:`pytest-recorder` Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. Dec 19, 2024 N/A N/A + :pypi:`pytest-recorder` Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. Jan 09, 2025 N/A N/A :pypi:`pytest-recording` A pytest plugin that allows you recording of network interactions via VCR.py Jul 09, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-recordings` Provides pytest plugins for reporting request/response traffic, screenshots, and more to ReportPortal Aug 13, 2020 N/A N/A :pypi:`pytest-record-video` 用例执行过程中录制视频 Oct 31, 2024 N/A N/A @@ -1153,7 +1156,7 @@ This list contains 1566 plugins. :pypi:`pytest-reference-formatter` Conveniently run pytest with a dot-formatted test reference. Oct 01, 2019 4 - Beta N/A :pypi:`pytest-regex` Select pytest tests with regular expressions May 29, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-regex-dependency` Management of Pytest dependencies via regex patterns Jun 12, 2022 N/A pytest - :pypi:`pytest-regressions` Easy to use fixtures to write regression tests. Dec 17, 2024 5 - Production/Stable pytest>=6.2.0 + :pypi:`pytest-regressions` Easy to use fixtures to write regression tests. Jan 10, 2025 5 - Production/Stable pytest>=6.2.0 :pypi:`pytest-regtest` pytest plugin for snapshot regression testing Nov 12, 2024 N/A pytest>7.2 :pypi:`pytest-relative-order` a pytest plugin that sorts tests using "before" and "after" markers May 17, 2021 4 - Beta N/A :pypi:`pytest-relative-path` Handle relative path in pytest options or ini configs Aug 30, 2024 N/A pytest @@ -1171,7 +1174,7 @@ This list contains 1566 plugins. :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Oct 11, 2024 4 - Beta N/A :pypi:`pytest-reporter-html-dots` A basic HTML report for pytest using Jinja2 template engine. Jan 22, 2023 N/A N/A - :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots and webpage sources. Jan 04, 2025 N/A pytest>=8.0.0 + :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots, webpage sources and attachments. Jan 09, 2025 N/A pytest>=8.0.0 :pypi:`pytest-reportinfra` Pytest plugin for reportinfra Aug 11, 2019 3 - Alpha N/A :pypi:`pytest-reporting` A plugin to report summarized results in a table format Oct 25, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-reportlog` Replacement for the --resultlog option, focused in simplicity and extensibility May 22, 2023 3 - Alpha pytest @@ -1230,7 +1233,7 @@ This list contains 1566 plugins. :pypi:`pytest-ruff` pytest plugin to check ruff requirements. Jul 21, 2024 4 - Beta pytest>=5 :pypi:`pytest-run-changed` Pytest plugin that runs changed tests only Apr 02, 2021 3 - Alpha pytest :pypi:`pytest-runfailed` implement a --failed option for pytest Mar 24, 2016 N/A N/A - :pypi:`pytest-run-parallel` A simple pytest plugin to run tests concurrently Nov 13, 2024 4 - Beta pytest>=6.2.0 + :pypi:`pytest-run-parallel` A simple pytest plugin to run tests concurrently Jan 06, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-run-subprocess` Pytest Plugin for running and testing subprocesses. Nov 12, 2022 5 - Production/Stable pytest :pypi:`pytest-runtime-types` Checks type annotations on runtime while running tests. Feb 09, 2023 N/A pytest :pypi:`pytest-runtime-xfail` Call runtime_xfail() to mark running test as xfail. Aug 26, 2021 N/A pytest>=5.0.0 @@ -1246,7 +1249,7 @@ This list contains 1566 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Dec 25, 2024 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Jan 10, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1257,7 +1260,7 @@ This list contains 1566 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Dec 25, 2024 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Jan 10, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1303,7 +1306,7 @@ This list contains 1566 plugins. :pypi:`pytest-smartcollect` A plugin for collecting tests that touch changed code Oct 04, 2018 N/A pytest (>=3.5.0) :pypi:`pytest-smartcov` Smart coverage plugin for pytest. Sep 30, 2017 3 - Alpha N/A :pypi:`pytest-smell` Automated bad smell detection tool for Pytest Jun 26, 2022 N/A N/A - :pypi:`pytest-smoke` Pytest plugin for smoke testing Dec 30, 2024 4 - Beta pytest<9,>=7.0.0 + :pypi:`pytest-smoke` Pytest plugin for smoke testing Jan 10, 2025 4 - Beta pytest<9,>=7.0.0 :pypi:`pytest-smtp` Send email with pytest execution result Feb 20, 2021 N/A pytest :pypi:`pytest-smtp4dev` Plugin for smtp4dev API Jun 27, 2023 5 - Production/Stable N/A :pypi:`pytest-smtpd` An SMTP server for testing built on aiosmtpd May 15, 2023 N/A pytest @@ -2173,14 +2176,14 @@ This list contains 1566 plugins. Pytest fixtures for async generators :pypi:`pytest-asyncio` - *last release*: Jan 02, 2025, + *last release*: Jan 08, 2025, *status*: 4 - Beta, *requires*: pytest<9,>=8.2 Pytest support for asyncio :pypi:`pytest-asyncio-concurrent` - *last release*: Jan 03, 2025, + *last release*: Jan 09, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -2481,7 +2484,7 @@ This list contains 1566 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Dec 23, 2024, + *last release*: Jan 09, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -2894,11 +2897,11 @@ This list contains 1566 plugins. Pytest plugin with server for catching HTTP requests. :pypi:`pytest-cdist` - *last release*: Dec 31, 2024, + *last release*: Jan 07, 2025, *status*: N/A, *requires*: pytest>=7 - Add your description here + A pytest plugin to split your test suite into multiple parts :pypi:`pytest-celery` *last release*: Sep 20, 2024, @@ -3258,7 +3261,7 @@ This list contains 1566 plugins. pytest plugin to run pycodestyle :pypi:`pytest-codspeed` - *last release*: Dec 09, 2024, + *last release*: Jan 09, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=3.8 @@ -3614,6 +3617,13 @@ This list contains 1566 plugins. Custom grouping for pytest-xdist, rename test cases name and test cases nodeid, support allure report + :pypi:`pytest-custom-timeout` + *last release*: Jan 08, 2025, + *status*: 4 - Beta, + *requires*: pytest>=8.0.0 + + Use custom logic when a test times out. Based on pytest-timeout. + :pypi:`pytest-cython` *last release*: Apr 05, 2024, *status*: 5 - Production/Stable, @@ -4154,7 +4164,7 @@ This list contains 1566 plugins. The bare minimum to integrate py.test with Django. :pypi:`pytest-django-liveserver-ssl` - *last release*: Jan 20, 2022, + *last release*: Jan 09, 2025, *status*: 3 - Alpha, *requires*: N/A @@ -4867,6 +4877,13 @@ This list contains 1566 plugins. Pytest plugin to treat skipped tests a test failure + :pypi:`pytest-errxfail` + *last release*: Jan 06, 2025, + *status*: 4 - Beta, + *requires*: pytest>=6.2.0 + + pytest plugin to mark a test as xfailed if it fails with the specified error message in the captured output + :pypi:`pytest-eth` *last release*: Aug 14, 2020, *status*: 1 - Planning, @@ -5673,7 +5690,7 @@ This list contains 1566 plugins. :pypi:`pytest-fzf` - *last release*: Jul 03, 2024, + *last release*: Jan 06, 2025, *status*: 4 - Beta, *requires*: pytest>=6.0.0 @@ -5715,7 +5732,7 @@ This list contains 1566 plugins. GCS fixtures and fixture factories for Pytest. :pypi:`pytest-gee` - *last release*: Dec 12, 2024, + *last release*: Jan 10, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -5750,7 +5767,7 @@ This list contains 1566 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Dec 23, 2024, + *last release*: Jan 08, 2025, *status*: N/A, *requires*: pytest>=3.6 @@ -6058,7 +6075,7 @@ This list contains 1566 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Jan 04, 2025, + *last release*: Jan 10, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.4 @@ -6198,7 +6215,7 @@ This list contains 1566 plugins. Easily test your HTTP library against a local copy of httpbin :pypi:`pytest-httpdbg` - *last release*: Dec 29, 2024, + *last release*: Jan 11, 2025, *status*: 4 - Beta, *requires*: pytest>=7.0.0 @@ -7674,8 +7691,15 @@ This list contains 1566 plugins. pytest plugin for MongoDB fixtures + :pypi:`pytest-mongodb-nono` + *last release*: Jan 07, 2025, + *status*: N/A, + *requires*: N/A + + pytest plugin for MongoDB + :pypi:`pytest-mongodb-ry` - *last release*: Dec 31, 2024, + *last release*: Jan 10, 2025, *status*: N/A, *requires*: N/A @@ -7759,8 +7783,8 @@ This list contains 1566 plugins. low-startup-overhead, scalable, distributed-testing pytest plugin :pypi:`pytest-mqtt` - *last release*: Oct 19, 2024, - *status*: 4 - Beta, + *last release*: Jan 07, 2025, + *status*: 5 - Production/Stable, *requires*: pytest<9; extra == "test" pytest-mqtt supports testing systems based on MQTT @@ -7885,7 +7909,7 @@ This list contains 1566 plugins. Pytest plugin for neos :pypi:`pytest-netconf` - *last release*: Aug 08, 2024, + *last release*: Jan 06, 2025, *status*: N/A, *requires*: N/A @@ -8487,7 +8511,7 @@ This list contains 1566 plugins. A simple plugin to ensure the execution of critical sections of code has not been impacted :pypi:`pytest-performancetotal` - *last release*: Dec 31, 2024, + *last release*: Jan 07, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -9173,7 +9197,7 @@ This list contains 1566 plugins. A pytest plugin to collect test information :pypi:`pytest-qaseio` - *last release*: Nov 18, 2024, + *last release*: Jan 08, 2025, *status*: 5 - Production/Stable, *requires*: pytest<9.0.0,>=7.2.2 @@ -9362,7 +9386,7 @@ This list contains 1566 plugins. Pytest fixtures for REANA. :pypi:`pytest-recorder` - *last release*: Dec 19, 2024, + *last release*: Jan 09, 2025, *status*: N/A, *requires*: N/A @@ -9439,7 +9463,7 @@ This list contains 1566 plugins. Management of Pytest dependencies via regex patterns :pypi:`pytest-regressions` - *last release*: Dec 17, 2024, + *last release*: Jan 10, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=6.2.0 @@ -9565,11 +9589,11 @@ This list contains 1566 plugins. A basic HTML report for pytest using Jinja2 template engine. :pypi:`pytest-report-extras` - *last release*: Jan 04, 2025, + *last release*: Jan 09, 2025, *status*: N/A, *requires*: pytest>=8.0.0 - Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots and webpage sources. + Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots, webpage sources and attachments. :pypi:`pytest-reportinfra` *last release*: Aug 11, 2019, @@ -9978,7 +10002,7 @@ This list contains 1566 plugins. implement a --failed option for pytest :pypi:`pytest-run-parallel` - *last release*: Nov 13, 2024, + *last release*: Jan 06, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -10090,7 +10114,7 @@ This list contains 1566 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Dec 25, 2024, + *last release*: Jan 10, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10167,7 +10191,7 @@ This list contains 1566 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Dec 25, 2024, + *last release*: Jan 10, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10489,7 +10513,7 @@ This list contains 1566 plugins. Automated bad smell detection tool for Pytest :pypi:`pytest-smoke` - *last release*: Dec 30, 2024, + *last release*: Jan 10, 2025, *status*: 4 - Beta, *requires*: pytest<9,>=7.0.0 From 517b0066b903e9688beab3377a3bd2439175797f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 06:40:40 -0300 Subject: [PATCH 259/445] [pre-commit.ci] pre-commit autoupdate (#13130) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.0 → v0.9.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.0...v0.9.1) - [github.com/woodruffw/zizmor-pre-commit: v1.0.1 → v1.1.1](https://github.com/woodruffw/zizmor-pre-commit/compare/v1.0.1...v1.1.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0533a404c3d..45af5f7f9b9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.9.0" + rev: "v0.9.1" hooks: - id: ruff args: ["--fix"] @@ -12,7 +12,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/woodruffw/zizmor-pre-commit - rev: v1.0.1 + rev: v1.1.1 hooks: - id: zizmor - repo: https://github.com/adamchainz/blacken-docs From 43064f5b61815496afa52a802ee6809fee0c06e2 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 10 Jan 2025 12:34:52 -0300 Subject: [PATCH 260/445] Improve stepwise to not forget failed tests Now `--stepwise` will remember the last failed test, even if the previous pytest invocations did not pass `--stepwise`. Previously it would always clear the cache if not active, which hinders certain interactive workflows, which is the prime use cases for the flag. --- changelog/13122.improvement.rst | 11 ++++++++++ src/_pytest/stepwise.py | 2 -- testing/test_cacheprovider.py | 4 ++-- testing/test_stepwise.py | 38 +++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 changelog/13122.improvement.rst diff --git a/changelog/13122.improvement.rst b/changelog/13122.improvement.rst new file mode 100644 index 00000000000..d7372380e81 --- /dev/null +++ b/changelog/13122.improvement.rst @@ -0,0 +1,11 @@ +Improve the ``--stepwise`` flag to not forget the last failed test in case pytest is executed later without the flag. + +This enables the following workflow: + +1. Execute pytest with ``--stepwise``, pytest then stops at the first failing test; +2. User iteratively updates the code and runs the test in isolation, without the ``--stepwise`` flag + (for example in an IDE), until it is fixed. +3. At this point, the user can execute pytest with ``--stepwise`` again and pytest will continue from the previously + failed test, and if it passes, continue with the next tests. + +Previously, at step 3, pytest would start from the beginning, forgetting the failed tests. diff --git a/src/_pytest/stepwise.py b/src/_pytest/stepwise.py index c7860808c35..82d1fe3aee5 100644 --- a/src/_pytest/stepwise.py +++ b/src/_pytest/stepwise.py @@ -47,8 +47,6 @@ def pytest_sessionfinish(session: Session) -> None: # Do not update cache if this process is a xdist worker to prevent # race conditions (#10641). return - # Clear the list of failing tests if the plugin is not active. - session.config.cache.set(STEPWISE_CACHE_DIR, []) class StepwisePlugin: diff --git a/testing/test_cacheprovider.py b/testing/test_cacheprovider.py index 1ba4659d84e..ca417e86ee5 100644 --- a/testing/test_cacheprovider.py +++ b/testing/test_cacheprovider.py @@ -104,7 +104,7 @@ def test_cache_failure_warns( pytester.makepyfile("def test_error(): raise Exception") result = pytester.runpytest() assert result.ret == 1 - # warnings from nodeids, lastfailed, and stepwise + # warnings from nodeids and lastfailed result.stdout.fnmatch_lines( [ # Validate location/stacklevel of warning from cacheprovider. @@ -113,7 +113,7 @@ def test_cache_failure_warns( " */cacheprovider.py:*: PytestCacheWarning: could not create cache path " f"{unwritable_cache_dir}/v/cache/nodeids: *", ' config.cache.set("cache/nodeids", sorted(self.cached_nodeids))', - "*1 failed, 3 warnings in*", + "*1 failed, 2 warnings in*", ] ) diff --git a/testing/test_stepwise.py b/testing/test_stepwise.py index affdb73375e..02239e8b5f1 100644 --- a/testing/test_stepwise.py +++ b/testing/test_stepwise.py @@ -358,3 +358,41 @@ def test_one(): with stepwise_cache_file.open(encoding="utf-8") as file_handle: observed_value = file_handle.readlines() assert [expected_value] == observed_value + + +def test_do_not_clear_cache_if_disabled(pytester: Pytester) -> None: + """ + If pytest is run without --step-wise, do not clear the stepwise cache. + + Keeping the cache around is important for this workflow: + + 1. Run tests with --stepwise + 2. Stop at the failing test, and iterate over it changing the code and running it in isolation + (in the IDE for example). + 3. Run tests with --stepwise again - at this point we expect to start from the failing test, which should now pass, + and continue with the next tests. + """ + pytester.makepyfile( + """ + def test_1(): + pass + def test_2(): + assert False + def test_3(): + pass + """ + ) + result = pytester.runpytest("--stepwise") + result.stdout.fnmatch_lines( + ["*::test_2 - assert False*", "*failed, continuing from this test next run*"] + ) + + # Run a specific test without passing `--stepwise`. + result = pytester.runpytest("-k", "test_1") + result.stdout.fnmatch_lines(["*1 passed*"]) + + # Running with `--stepwise` should continue from the last failing test. + result = pytester.runpytest("--stepwise") + result.stdout.fnmatch_lines( + ["*::test_2 - assert False*", "*failed, continuing from this test next run*"] + ) From 40b38f97c977e51f165aa32ccfe95ec3a0e5f8c8 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 10 Jan 2025 13:48:29 -0300 Subject: [PATCH 261/445] Add --stepwise-reset to restart the stepwise workflow --- changelog/13122.improvement.rst | 4 +++- src/_pytest/stepwise.py | 16 +++++++++++++++- testing/test_stepwise.py | 31 +++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/changelog/13122.improvement.rst b/changelog/13122.improvement.rst index d7372380e81..808e19dcc00 100644 --- a/changelog/13122.improvement.rst +++ b/changelog/13122.improvement.rst @@ -1,4 +1,4 @@ -Improve the ``--stepwise`` flag to not forget the last failed test in case pytest is executed later without the flag. +Improve the ``--stepwise``/``--sw`` flag to not forget the last failed test in case pytest is executed later without the flag. This enables the following workflow: @@ -9,3 +9,5 @@ This enables the following workflow: failed test, and if it passes, continue with the next tests. Previously, at step 3, pytest would start from the beginning, forgetting the failed tests. + +Also added the new ``--stepwise-reset``/``--sw-reset``, allowing the user to explicitly reset the stepwise state and restart the workflow from the beginning. diff --git a/src/_pytest/stepwise.py b/src/_pytest/stepwise.py index 82d1fe3aee5..28db3bfc6e2 100644 --- a/src/_pytest/stepwise.py +++ b/src/_pytest/stepwise.py @@ -30,11 +30,23 @@ def pytest_addoption(parser: Parser) -> None: help="Ignore the first failing test but stop on the next failing test. " "Implicitly enables --stepwise.", ) + group.addoption( + "--sw-reset", + "--stepwise-reset", + action="store_true", + default=False, + dest="stepwise_reset", + help="Resets stepwise state, restarting the stepwise workflow. " + "Implicitly enables --stepwise.", + ) def pytest_configure(config: Config) -> None: + # --stepwise-skip implies stepwise. if config.option.stepwise_skip: - # allow --stepwise-skip to work on its own merits. + config.option.stepwise = True + # --stepwise-clear implies stepwise. + if config.option.stepwise_reset: config.option.stepwise = True if config.getoption("stepwise"): config.pluginmanager.register(StepwisePlugin(config), "stepwiseplugin") @@ -58,6 +70,8 @@ def __init__(self, config: Config) -> None: self.cache: Cache = config.cache self.lastfailed: str | None = self.cache.get(STEPWISE_CACHE_DIR, None) self.skip: bool = config.getoption("stepwise_skip") + if config.getoption("stepwise_reset"): + self.lastfailed = None def pytest_sessionstart(self, session: Session) -> None: self.session = session diff --git a/testing/test_stepwise.py b/testing/test_stepwise.py index 02239e8b5f1..4d3d1e91b7f 100644 --- a/testing/test_stepwise.py +++ b/testing/test_stepwise.py @@ -396,3 +396,34 @@ def test_3(): result.stdout.fnmatch_lines( ["*::test_2 - assert False*", "*failed, continuing from this test next run*"] ) + + +def test_stepwise_reset(pytester: Pytester) -> None: + pytester.makepyfile( + """ + def test_1(): + pass + def test_2(): + assert False + def test_3(): + pass + """ + ) + result = pytester.runpytest("--stepwise", "-v") + result.stdout.fnmatch_lines( + [ + "*::test_1 *PASSED*", + "*::test_2 *FAILED*", + "*failed, continuing from this test next run*", + ] + ) + + # Running with --stepwise-reset restarts the stepwise workflow. + result = pytester.runpytest("-v", "--stepwise-reset") + result.stdout.fnmatch_lines( + [ + "*::test_1 *PASSED*", + "*::test_2 *FAILED*", + "*failed, continuing from this test next run*", + ] + ) From 18378585628247d92e668c05b2a1254a544d7d7c Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 10 Jan 2025 19:37:06 -0300 Subject: [PATCH 262/445] Tweak changelog --- changelog/13122.improvement.rst | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/changelog/13122.improvement.rst b/changelog/13122.improvement.rst index 808e19dcc00..4079696d676 100644 --- a/changelog/13122.improvement.rst +++ b/changelog/13122.improvement.rst @@ -3,11 +3,9 @@ Improve the ``--stepwise``/``--sw`` flag to not forget the last failed test in c This enables the following workflow: 1. Execute pytest with ``--stepwise``, pytest then stops at the first failing test; -2. User iteratively updates the code and runs the test in isolation, without the ``--stepwise`` flag - (for example in an IDE), until it is fixed. -3. At this point, the user can execute pytest with ``--stepwise`` again and pytest will continue from the previously - failed test, and if it passes, continue with the next tests. +2. Iteratively update the code and run the test in isolation, without the ``--stepwise`` flag (for example in an IDE), until it is fixed. +3. Execute pytest with ``--stepwise`` again and pytest will continue from the previously failed test, and if it passes, continue on to the next tests. -Previously, at step 3, pytest would start from the beginning, forgetting the failed tests. +Previously, at step 3, pytest would start from the beginning, forgetting the previously failed test. Also added the new ``--stepwise-reset``/``--sw-reset``, allowing the user to explicitly reset the stepwise state and restart the workflow from the beginning. From b6f1dadeb201677bd08601283649c9dcc5491895 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 10 Jan 2025 19:44:26 -0300 Subject: [PATCH 263/445] Tighten test --- testing/test_stepwise.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/testing/test_stepwise.py b/testing/test_stepwise.py index 4d3d1e91b7f..dbf49f73535 100644 --- a/testing/test_stepwise.py +++ b/testing/test_stepwise.py @@ -384,7 +384,11 @@ def test_3(): ) result = pytester.runpytest("--stepwise") result.stdout.fnmatch_lines( - ["*::test_2 - assert False*", "*failed, continuing from this test next run*"] + [ + "*::test_2 - assert False*", + "*failed, continuing from this test next run*", + "=* 1 failed, 1 passed in *", + ] ) # Run a specific test without passing `--stepwise`. @@ -394,7 +398,12 @@ def test_3(): # Running with `--stepwise` should continue from the last failing test. result = pytester.runpytest("--stepwise") result.stdout.fnmatch_lines( - ["*::test_2 - assert False*", "*failed, continuing from this test next run*"] + [ + "stepwise: skipping 1 already passed items.", + "*::test_2 - assert False*", + "*failed, continuing from this test next run*", + "=* 1 failed, 1 deselected in *", + ] ) From 0c30a580606f6984897bd84f6b940e1a025f29bd Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 12 Jan 2025 10:12:16 -0300 Subject: [PATCH 264/445] Show cache information and reset cache if test count changes --- changelog/13122.improvement.rst | 18 ++-- src/_pytest/stepwise.py | 113 ++++++++++++++++++++----- testing/test_stepwise.py | 145 +++++++++++++++++++++++++++----- 3 files changed, 231 insertions(+), 45 deletions(-) diff --git a/changelog/13122.improvement.rst b/changelog/13122.improvement.rst index 4079696d676..c302713b320 100644 --- a/changelog/13122.improvement.rst +++ b/changelog/13122.improvement.rst @@ -1,11 +1,15 @@ -Improve the ``--stepwise``/``--sw`` flag to not forget the last failed test in case pytest is executed later without the flag. +The ``--stepwise`` mode received a number of improvements: -This enables the following workflow: +* It no longer forgets the last failed test in case pytest is executed later without the flag. -1. Execute pytest with ``--stepwise``, pytest then stops at the first failing test; -2. Iteratively update the code and run the test in isolation, without the ``--stepwise`` flag (for example in an IDE), until it is fixed. -3. Execute pytest with ``--stepwise`` again and pytest will continue from the previously failed test, and if it passes, continue on to the next tests. + This enables the following workflow: -Previously, at step 3, pytest would start from the beginning, forgetting the previously failed test. + 1. Execute pytest with ``--stepwise``, pytest then stops at the first failing test; + 2. Iteratively update the code and run the test in isolation, without the ``--stepwise`` flag (for example in an IDE), until it is fixed. + 3. Execute pytest with ``--stepwise`` again and pytest will continue from the previously failed test, and if it passes, continue on to the next tests. -Also added the new ``--stepwise-reset``/``--sw-reset``, allowing the user to explicitly reset the stepwise state and restart the workflow from the beginning. + Previously, at step 3, pytest would start from the beginning, forgetting the previously failed test. + + This change however might cause issues if the ``--stepwise`` mode is used far apart in time, as the state might get stale, so the internal state will be reset automatically in case the test suite changes (for now only the number of tests are considered for this, we might change/improve this on the future). + +* New ``--stepwise-reset``/``--sw-reset`` flag, allowing the user to explicitly reset the stepwise state and restart the workflow from the beginning. diff --git a/src/_pytest/stepwise.py b/src/_pytest/stepwise.py index 28db3bfc6e2..7ee869bcef8 100644 --- a/src/_pytest/stepwise.py +++ b/src/_pytest/stepwise.py @@ -1,5 +1,10 @@ from __future__ import annotations +import dataclasses +from datetime import datetime +from typing import Any +from typing import TYPE_CHECKING + from _pytest import nodes from _pytest.cacheprovider import Cache from _pytest.config import Config @@ -8,7 +13,12 @@ from _pytest.reports import TestReport -STEPWISE_CACHE_DIR = "cache/stepwise" +if TYPE_CHECKING: + from typing import ClassVar + + from typing_extensions import Self + +STEPWISE_CACHE_DIR = "cache/stepwise2" def pytest_addoption(parser: Parser) -> None: @@ -61,17 +71,63 @@ def pytest_sessionfinish(session: Session) -> None: return +@dataclasses.dataclass +class StepwiseCacheInfo: + # The nodeid of the last failed test. + last_failed: str | None + + # The number of tests in the last time --stepwise was run. + # We use this information as a simple way to invalidate the cache information, avoiding + # confusing behavior in case the cache is stale. + last_test_count: int | None + + # The date when the cache was last updated, for information purposes only. + last_cache_date_str: str + + _DATE_FORMAT: ClassVar[str] = "%Y-%m-%d %H:%M:%S" + + @property + def last_cache_date(self) -> datetime: + return datetime.strptime(self.last_cache_date_str, self._DATE_FORMAT) + + @classmethod + def empty(cls) -> Self: + return cls( + last_failed=None, + last_test_count=None, + last_cache_date_str=datetime.now().strftime(cls._DATE_FORMAT), + ) + + def update_date_to_now(self) -> None: + self.last_cache_date_str = datetime.now().strftime(self._DATE_FORMAT) + + class StepwisePlugin: def __init__(self, config: Config) -> None: self.config = config self.session: Session | None = None - self.report_status = "" + self.report_status: list[str] = [] assert config.cache is not None self.cache: Cache = config.cache - self.lastfailed: str | None = self.cache.get(STEPWISE_CACHE_DIR, None) self.skip: bool = config.getoption("stepwise_skip") - if config.getoption("stepwise_reset"): - self.lastfailed = None + self.reset: bool = config.getoption("stepwise_reset") + self.cached_info = self._load_cached_info() + + def _load_cached_info(self) -> StepwiseCacheInfo: + cached_dict: dict[str, Any] | None = self.cache.get(STEPWISE_CACHE_DIR, None) + if cached_dict: + try: + return StepwiseCacheInfo( + cached_dict["last_failed"], + cached_dict["last_test_count"], + cached_dict["last_cache_date_str"], + ) + except Exception as e: + error = f"{type(e).__name__}: {e}" + self.report_status.append(f"error reading cache, discarding ({error})") + + # Cache not found or error during load, return a new cache. + return StepwiseCacheInfo.empty() def pytest_sessionstart(self, session: Session) -> None: self.session = session @@ -79,23 +135,41 @@ def pytest_sessionstart(self, session: Session) -> None: def pytest_collection_modifyitems( self, config: Config, items: list[nodes.Item] ) -> None: - if not self.lastfailed: - self.report_status = "no previously failed tests, not skipping." + last_test_count = self.cached_info.last_test_count + self.cached_info.last_test_count = len(items) + + if self.reset: + self.report_status.append("resetting state, not skipping.") + self.cached_info.last_failed = None + return + + if not self.cached_info.last_failed: + self.report_status.append("no previously failed tests, not skipping.") + return + + if last_test_count is not None and last_test_count != len(items): + self.report_status.append( + f"test count changed, not skipping (now {len(items)} tests, previously {last_test_count})." + ) + self.cached_info.last_failed = None return - # check all item nodes until we find a match on last failed + # Check all item nodes until we find a match on last failed. failed_index = None for index, item in enumerate(items): - if item.nodeid == self.lastfailed: + if item.nodeid == self.cached_info.last_failed: failed_index = index break # If the previously failed test was not found among the test items, # do not skip any tests. if failed_index is None: - self.report_status = "previously failed test not found, not skipping." + self.report_status.append("previously failed test not found, not skipping.") else: - self.report_status = f"skipping {failed_index} already passed items." + self.report_status.append( + f"skipping {failed_index} already passed items (cache from {self.cached_info.last_cache_date}," + f" use --sw-reset to discard)." + ) deselected = items[:failed_index] del items[:failed_index] config.hook.pytest_deselected(items=deselected) @@ -105,13 +179,13 @@ def pytest_runtest_logreport(self, report: TestReport) -> None: if self.skip: # Remove test from the failed ones (if it exists) and unset the skip option # to make sure the following tests will not be skipped. - if report.nodeid == self.lastfailed: - self.lastfailed = None + if report.nodeid == self.cached_info.last_failed: + self.cached_info.last_failed = None self.skip = False else: # Mark test as the last failing and interrupt the test session. - self.lastfailed = report.nodeid + self.cached_info.last_failed = report.nodeid assert self.session is not None self.session.shouldstop = ( "Test failed, continuing from this test next run." @@ -121,12 +195,12 @@ def pytest_runtest_logreport(self, report: TestReport) -> None: # If the test was actually run and did pass. if report.when == "call": # Remove test from the failed ones, if exists. - if report.nodeid == self.lastfailed: - self.lastfailed = None + if report.nodeid == self.cached_info.last_failed: + self.cached_info.last_failed = None - def pytest_report_collectionfinish(self) -> str | None: + def pytest_report_collectionfinish(self) -> list[str] | None: if self.config.get_verbosity() >= 0 and self.report_status: - return f"stepwise: {self.report_status}" + return [f"stepwise: {x}" for x in self.report_status] return None def pytest_sessionfinish(self) -> None: @@ -134,4 +208,5 @@ def pytest_sessionfinish(self) -> None: # Do not update cache if this process is a xdist worker to prevent # race conditions (#10641). return - self.cache.set(STEPWISE_CACHE_DIR, self.lastfailed) + self.cached_info.update_date_to_now() + self.cache.set(STEPWISE_CACHE_DIR, dataclasses.asdict(self.cached_info)) diff --git a/testing/test_stepwise.py b/testing/test_stepwise.py index dbf49f73535..8e040cca28e 100644 --- a/testing/test_stepwise.py +++ b/testing/test_stepwise.py @@ -1,6 +1,8 @@ -# mypy: allow-untyped-defs +# mypy: disallow-untyped-defs from __future__ import annotations +from collections.abc import Sequence +import json from pathlib import Path from _pytest.cacheprovider import Cache @@ -84,7 +86,7 @@ def broken_pytester(pytester: Pytester) -> Pytester: return pytester -def _strip_resource_warnings(lines): +def _strip_resource_warnings(lines: Sequence[str]) -> Sequence[str]: # Strip unreliable ResourceWarnings, so no-output assertions on stderr can work. # (https://github.com/pytest-dev/pytest/issues/5088) return [ @@ -114,7 +116,10 @@ def test_data(expected): result.stdout.fnmatch_lines(["stepwise: no previously failed tests, not skipping."]) result = pytester.runpytest("-v", "--stepwise") result.stdout.fnmatch_lines( - ["stepwise: skipping 4 already passed items.", "*1 failed, 4 deselected*"] + [ + "stepwise: skipping 4 already passed items (cache from *, use --sw-reset to discard).", + "*1 failed, 4 deselected*", + ] ) @@ -360,9 +365,9 @@ def test_one(): assert [expected_value] == observed_value -def test_do_not_clear_cache_if_disabled(pytester: Pytester) -> None: +def test_do_not_reset_cache_if_disabled(pytester: Pytester) -> None: """ - If pytest is run without --step-wise, do not clear the stepwise cache. + If pytest is run without --stepwise, do not clear the stepwise cache. Keeping the cache around is important for this workflow: @@ -374,12 +379,9 @@ def test_do_not_clear_cache_if_disabled(pytester: Pytester) -> None: """ pytester.makepyfile( """ - def test_1(): - pass - def test_2(): - assert False - def test_3(): - pass + def test_1(): pass + def test_2(): assert False + def test_3(): pass """ ) result = pytester.runpytest("--stepwise") @@ -399,7 +401,7 @@ def test_3(): result = pytester.runpytest("--stepwise") result.stdout.fnmatch_lines( [ - "stepwise: skipping 1 already passed items.", + "stepwise: skipping 1 already passed items (cache from *, use --sw-reset to discard).", "*::test_2 - assert False*", "*failed, continuing from this test next run*", "=* 1 failed, 1 deselected in *", @@ -407,23 +409,32 @@ def test_3(): ) -def test_stepwise_reset(pytester: Pytester) -> None: +def test_reset(pytester: Pytester) -> None: pytester.makepyfile( """ - def test_1(): - pass - def test_2(): - assert False - def test_3(): - pass + def test_1(): pass + def test_2(): assert False + def test_3(): pass """ ) result = pytester.runpytest("--stepwise", "-v") result.stdout.fnmatch_lines( [ + "stepwise: no previously failed tests, not skipping.", "*::test_1 *PASSED*", "*::test_2 *FAILED*", "*failed, continuing from this test next run*", + "* 1 failed, 1 passed in *", + ] + ) + + result = pytester.runpytest("--stepwise", "-v") + result.stdout.fnmatch_lines( + [ + "stepwise: skipping 1 already passed items (cache from *, use --sw-reset to discard).", + "*::test_2 *FAILED*", + "*failed, continuing from this test next run*", + "* 1 failed, 1 deselected in *", ] ) @@ -431,8 +442,104 @@ def test_3(): result = pytester.runpytest("-v", "--stepwise-reset") result.stdout.fnmatch_lines( [ + "stepwise: resetting state, not skipping.", "*::test_1 *PASSED*", "*::test_2 *FAILED*", "*failed, continuing from this test next run*", + "* 1 failed, 1 passed in *", + ] + ) + + +def test_change_test_count(pytester: Pytester) -> None: + # Run initially with 3 tests. + pytester.makepyfile( + """ + def test_1(): pass + def test_2(): assert False + def test_3(): pass + """ + ) + result = pytester.runpytest("--stepwise", "-v") + result.stdout.fnmatch_lines( + [ + "stepwise: no previously failed tests, not skipping.", + "*::test_1 *PASSED*", + "*::test_2 *FAILED*", + "*failed, continuing from this test next run*", + "* 1 failed, 1 passed in *", + ] + ) + + # Change the number of tests, which invalidates the test cache. + pytester.makepyfile( + """ + def test_1(): pass + def test_2(): assert False + def test_3(): pass + def test_4(): pass + """ + ) + result = pytester.runpytest("--stepwise", "-v") + result.stdout.fnmatch_lines( + [ + "stepwise: test count changed, not skipping (now 4 tests, previously 3).", + "*::test_1 *PASSED*", + "*::test_2 *FAILED*", + "*failed, continuing from this test next run*", + "* 1 failed, 1 passed in *", + ] + ) + + # Fix the failing test and run again. + pytester.makepyfile( + """ + def test_1(): pass + def test_2(): pass + def test_3(): pass + def test_4(): pass + """ + ) + result = pytester.runpytest("--stepwise", "-v") + result.stdout.fnmatch_lines( + [ + "stepwise: skipping 1 already passed items (cache from *, use --sw-reset to discard).", + "*::test_2 *PASSED*", + "*::test_3 *PASSED*", + "*::test_4 *PASSED*", + "* 3 passed, 1 deselected in *", + ] + ) + + +def test_cache_error(pytester: Pytester) -> None: + pytester.makepyfile( + """ + def test_1(): pass + """ + ) + # Run stepwise normally to generate the cache information. + result = pytester.runpytest("--stepwise", "-v") + result.stdout.fnmatch_lines( + [ + "stepwise: no previously failed tests, not skipping.", + "*::test_1 *PASSED*", + "* 1 passed in *", + ] + ) + + # Corrupt the cache. + cache_file = pytester.path / f".pytest_cache/v/{STEPWISE_CACHE_DIR}" + assert cache_file.is_file() + cache_file.write_text(json.dumps({"invalid": True}), encoding="UTF-8") + + # Check we run as if the cache did not exist, but also show an error message. + result = pytester.runpytest("--stepwise", "-v") + result.stdout.fnmatch_lines( + [ + "stepwise: error reading cache, discarding (KeyError: *", + "stepwise: no previously failed tests, not skipping.", + "*::test_1 *PASSED*", + "* 1 passed in *", ] ) From 1f7a1517dbcf381980e2ca1839209e0ca21a595d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 13 Jan 2025 12:59:43 -0300 Subject: [PATCH 265/445] Code review requests --- src/_pytest/stepwise.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/_pytest/stepwise.py b/src/_pytest/stepwise.py index 7ee869bcef8..c25f260a1ca 100644 --- a/src/_pytest/stepwise.py +++ b/src/_pytest/stepwise.py @@ -14,11 +14,9 @@ if TYPE_CHECKING: - from typing import ClassVar - from typing_extensions import Self -STEPWISE_CACHE_DIR = "cache/stepwise2" +STEPWISE_CACHE_DIR = "cache/stepwise" def pytest_addoption(parser: Parser) -> None: @@ -52,11 +50,8 @@ def pytest_addoption(parser: Parser) -> None: def pytest_configure(config: Config) -> None: - # --stepwise-skip implies stepwise. - if config.option.stepwise_skip: - config.option.stepwise = True - # --stepwise-clear implies stepwise. - if config.option.stepwise_reset: + # --stepwise-skip/--stepwise-reset implies stepwise. + if config.option.stepwise_skip or config.option.stepwise_reset: config.option.stepwise = True if config.getoption("stepwise"): config.pluginmanager.register(StepwisePlugin(config), "stepwiseplugin") @@ -84,22 +79,20 @@ class StepwiseCacheInfo: # The date when the cache was last updated, for information purposes only. last_cache_date_str: str - _DATE_FORMAT: ClassVar[str] = "%Y-%m-%d %H:%M:%S" - @property def last_cache_date(self) -> datetime: - return datetime.strptime(self.last_cache_date_str, self._DATE_FORMAT) + return datetime.fromisoformat(self.last_cache_date_str) @classmethod def empty(cls) -> Self: return cls( last_failed=None, last_test_count=None, - last_cache_date_str=datetime.now().strftime(cls._DATE_FORMAT), + last_cache_date_str=datetime.now().isoformat(), ) def update_date_to_now(self) -> None: - self.last_cache_date_str = datetime.now().strftime(self._DATE_FORMAT) + self.last_cache_date_str = datetime.now().isoformat() class StepwisePlugin: @@ -122,7 +115,7 @@ def _load_cached_info(self) -> StepwiseCacheInfo: cached_dict["last_test_count"], cached_dict["last_cache_date_str"], ) - except Exception as e: + except (KeyError, TypeError) as e: error = f"{type(e).__name__}: {e}" self.report_status.append(f"error reading cache, discarding ({error})") From 2fcaa79358ae781ae68cc3a335f93aff7c80d521 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 15 Jan 2025 14:48:06 -0300 Subject: [PATCH 266/445] Show cache age instead of update date --- src/_pytest/stepwise.py | 6 +++++- testing/test_stepwise.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/_pytest/stepwise.py b/src/_pytest/stepwise.py index c25f260a1ca..8901540eb59 100644 --- a/src/_pytest/stepwise.py +++ b/src/_pytest/stepwise.py @@ -2,6 +2,7 @@ import dataclasses from datetime import datetime +from datetime import timedelta from typing import Any from typing import TYPE_CHECKING @@ -159,8 +160,11 @@ def pytest_collection_modifyitems( if failed_index is None: self.report_status.append("previously failed test not found, not skipping.") else: + cache_age = datetime.now() - self.cached_info.last_cache_date + # Round up to avoid showing microseconds. + cache_age = timedelta(seconds=int(cache_age.total_seconds())) self.report_status.append( - f"skipping {failed_index} already passed items (cache from {self.cached_info.last_cache_date}," + f"skipping {failed_index} already passed items (cache from {cache_age} ago," f" use --sw-reset to discard)." ) deselected = items[:failed_index] diff --git a/testing/test_stepwise.py b/testing/test_stepwise.py index 8e040cca28e..d2ad3bae500 100644 --- a/testing/test_stepwise.py +++ b/testing/test_stepwise.py @@ -117,7 +117,7 @@ def test_data(expected): result = pytester.runpytest("-v", "--stepwise") result.stdout.fnmatch_lines( [ - "stepwise: skipping 4 already passed items (cache from *, use --sw-reset to discard).", + "stepwise: skipping 4 already passed items (cache from * ago, use --sw-reset to discard).", "*1 failed, 4 deselected*", ] ) From f93da9228d16fdbc619a775c5d2e2ffa761e2cac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 07:04:23 +0100 Subject: [PATCH 267/445] build(deps): Bump django in /testing/plugins_integration (#13146) Bumps [django](https://github.com/django/django) from 5.1.4 to 5.1.5. - [Commits](https://github.com/django/django/compare/5.1.4...5.1.5) --- updated-dependencies: - dependency-name: django dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index aa35aeebcd2..4c3c66636ba 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,5 +1,5 @@ anyio[trio]==4.8.0 -django==5.1.4 +django==5.1.5 pytest-asyncio==0.25.2 pytest-bdd==8.1.0 pytest-cov==6.0.0 From 1ba36bc940f5570046ae2c4bec71102e9028ed90 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 12:24:50 -0300 Subject: [PATCH 268/445] build(deps): Bump peter-evans/create-pull-request from 7.0.5 to 7.0.6 (#13147) Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 7.0.5 to 7.0.6. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/5e914681df9dc83aa4e4905692ca88beb2f9e91f...67ccf781d68cd99b580ae25a5c18a1cc84ffff1f) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/update-plugin-list.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-plugin-list.yml b/.github/workflows/update-plugin-list.yml index ce3e9fd5230..a4eeb4b0a36 100644 --- a/.github/workflows/update-plugin-list.yml +++ b/.github/workflows/update-plugin-list.yml @@ -48,7 +48,7 @@ jobs: - name: Create Pull Request id: pr - uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f + uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f with: commit-message: '[automated] Update plugin list' author: 'pytest bot ' From 195f7e1bd22e0c1dc99da8d3ba6e5ab3d7627b3b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 12:25:15 -0300 Subject: [PATCH 269/445] [automated] Update plugin list (#13143) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 104 +++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 32 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 752bc869deb..e575d58ac7f 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =7 :pypi:`pytest-adaptavist` pytest plugin for generating test execution results within Jira Test Management (tm4j) Oct 13, 2022 N/A pytest (>=5.4.0) - :pypi:`pytest-adaptavist-fixed` pytest plugin for generating test execution results within Jira Test Management (tm4j) Nov 08, 2023 N/A pytest >=5.4.0 + :pypi:`pytest-adaptavist-fixed` pytest plugin for generating test execution results within Jira Test Management (tm4j) Jan 17, 2025 N/A pytest>=5.4.0 :pypi:`pytest-addons-test` 用于测试pytest的插件 Aug 02, 2021 N/A pytest (>=6.2.4,<7.0.0) :pypi:`pytest-adf` Pytest plugin for writing Azure Data Factory integration tests May 10, 2021 4 - Beta pytest (>=3.5.0) :pypi:`pytest-adf-azure-identity` Pytest plugin for writing Azure Data Factory integration tests Mar 06, 2021 4 - Beta pytest (>=3.5.0) @@ -52,7 +52,7 @@ This list contains 1569 plugins. :pypi:`pytest-aggreport` pytest plugin for pytest-repeat that generate aggregate report of the same test cases with additional statistics details. Mar 07, 2021 4 - Beta pytest (>=6.2.2) :pypi:`pytest-ai1899` pytest plugin for connecting to ai1899 smart system stack Mar 13, 2024 5 - Production/Stable N/A :pypi:`pytest-aio` Pytest plugin for testing async python code Jul 31, 2024 5 - Production/Stable pytest - :pypi:`pytest-aioboto3` Aioboto3 Pytest with Moto Nov 26, 2024 N/A N/A + :pypi:`pytest-aioboto3` Aioboto3 Pytest with Moto Jan 17, 2025 N/A N/A :pypi:`pytest-aiofiles` pytest fixtures for writing aiofiles tests with pyfakefs May 14, 2017 5 - Production/Stable N/A :pypi:`pytest-aiogram` May 06, 2023 N/A N/A :pypi:`pytest-aiohttp` Pytest plugin for aiohttp support Sep 06, 2023 4 - Beta pytest >=6.1.0 @@ -116,7 +116,7 @@ This list contains 1569 plugins. :pypi:`pytest_async` pytest-async - Run your coroutine in event loop without decorator Feb 26, 2020 N/A N/A :pypi:`pytest-async-generators` Pytest fixtures for async generators Jul 05, 2023 N/A N/A :pypi:`pytest-asyncio` Pytest support for asyncio Jan 08, 2025 4 - Beta pytest<9,>=8.2 - :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Jan 09, 2025 4 - Beta pytest>=6.2.0 + :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Jan 17, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Jul 04, 2024 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) :pypi:`pytest-async-mongodb` pytest plugin for async MongoDB Oct 18, 2017 5 - Production/Stable pytest (>=2.5.2) @@ -159,7 +159,7 @@ This list contains 1569 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Jan 09, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Jan 16, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -505,6 +505,7 @@ This list contains 1569 plugins. :pypi:`pytest-eth` PyTest plugin for testing Smart Contracts for Ethereum Virtual Machine (EVM). Aug 14, 2020 1 - Planning N/A :pypi:`pytest-ethereum` pytest-ethereum: Pytest library for ethereum projects. Jun 24, 2019 3 - Alpha pytest (==3.3.2); extra == 'dev' :pypi:`pytest-eucalyptus` Pytest Plugin for BDD Jun 28, 2022 N/A pytest (>=4.2.0) + :pypi:`pytest-evals` A pytest plugin for running and analyzing LLM evaluation tests Jan 16, 2025 N/A pytest>=7.0.0 :pypi:`pytest-eventlet` Applies eventlet monkey-patch as a pytest plugin. Oct 04, 2021 N/A pytest ; extra == 'dev' :pypi:`pytest_evm` The testing package containing tools to test Web3-based projects Sep 23, 2024 4 - Beta pytest<9.0.0,>=8.1.1 :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A @@ -522,6 +523,7 @@ This list contains 1569 plugins. :pypi:`pytest-exit-code` A pytest plugin that overrides the built-in exit codes to retain more information about the test results. May 06, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-expect` py.test plugin to store test expectations and mark tests based on them Apr 21, 2016 4 - Beta N/A :pypi:`pytest-expectdir` A pytest plugin to provide initial/expected directories, and check a test transforms the initial directory to the expected one Mar 19, 2023 5 - Production/Stable pytest (>=5.0) + :pypi:`pytest-expected` Record and play back your expectations Jan 14, 2025 N/A pytest :pypi:`pytest-expecter` Better testing with expecter and pytest. Sep 18, 2022 5 - Production/Stable N/A :pypi:`pytest-expectr` This plugin is used to expect multiple assert using pytest framework. Oct 05, 2018 N/A pytest (>=2.4.2) :pypi:`pytest-expect-test` A fixture to support expect tests in pytest Apr 10, 2023 4 - Beta pytest (>=3.5.0) @@ -623,7 +625,7 @@ This list contains 1569 plugins. :pypi:`pytest-gc` The garbage collector plugin for py.test Feb 01, 2018 N/A N/A :pypi:`pytest-gcov` Uses gcov to measure test coverage of a C library Feb 01, 2018 3 - Alpha N/A :pypi:`pytest-gcs` GCS fixtures and fixture factories for Pytest. Mar 01, 2024 5 - Production/Stable pytest >=6.2 - :pypi:`pytest-gee` The Python plugin for your GEE based packages. Jan 10, 2025 3 - Alpha pytest + :pypi:`pytest-gee` The Python plugin for your GEE based packages. Jan 13, 2025 3 - Alpha pytest :pypi:`pytest-gevent` Ensure that gevent is properly patched when invoking pytest Feb 25, 2020 N/A pytest :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest @@ -635,7 +637,7 @@ This list contains 1569 plugins. :pypi:`pytest-git-diff` Pytest plugin that allows the user to select the tests affected by a range of git commits Apr 02, 2024 N/A N/A :pypi:`pytest-git-fixtures` Pytest fixtures for testing with git. Mar 11, 2021 4 - Beta pytest :pypi:`pytest-github` Plugin for py.test that associates tests with github issues using a marker. Mar 07, 2019 5 - Production/Stable N/A - :pypi:`pytest-github-actions-annotate-failures` pytest plugin to annotate failed tests with a workflow command for GitHub Actions May 04, 2023 5 - Production/Stable pytest (>=4.0.0) + :pypi:`pytest-github-actions-annotate-failures` pytest plugin to annotate failed tests with a workflow command for GitHub Actions Jan 17, 2025 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-github-report` Generate a GitHub report using pytest in GitHub Workflows Jun 03, 2022 4 - Beta N/A :pypi:`pytest-gitignore` py.test plugin to ignore the same files as git Jul 17, 2015 4 - Beta N/A :pypi:`pytest-gitlab` Pytest Plugin for Gitlab Oct 16, 2024 N/A N/A @@ -727,7 +729,7 @@ This list contains 1569 plugins. :pypi:`pytest-initry` Plugin for sending automation test data from Pytest to the initry Apr 30, 2024 N/A pytest<9.0.0,>=8.1.1 :pypi:`pytest-inline` A pytest plugin for writing inline tests Oct 24, 2024 4 - Beta pytest<9.0,>=7.0 :pypi:`pytest-inmanta` A py.test plugin providing fixtures to simplify inmanta modules testing. Oct 10, 2024 5 - Production/Stable pytest - :pypi:`pytest-inmanta-extensions` Inmanta tests package Oct 10, 2024 5 - Production/Stable N/A + :pypi:`pytest-inmanta-extensions` Inmanta tests package Jan 17, 2025 5 - Production/Stable N/A :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Dec 13, 2024 5 - Production/Stable N/A :pypi:`pytest-inmanta-yang` Common fixtures used in inmanta yang related modules Feb 22, 2024 4 - Beta pytest :pypi:`pytest-Inomaly` A simple image diff plugin for pytest Feb 13, 2018 4 - Beta N/A @@ -747,7 +749,7 @@ This list contains 1569 plugins. :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A :pypi:`pytest-ipywidgets` Dec 19, 2024 N/A pytest - :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Nov 24, 2024 4 - Beta pytest + :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Jan 16, 2025 4 - Beta pytest :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Dec 05, 2024 4 - Beta pytest>=5 :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-it` Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it. Jan 29, 2024 4 - Beta N/A @@ -834,7 +836,7 @@ This list contains 1569 plugins. :pypi:`pytest-logging` Configures logging and allows tweaking the log level with a py.test flag Nov 04, 2015 4 - Beta N/A :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) :pypi:`pytest-logging-strict` pytest fixture logging configured from packaged YAML Jan 03, 2025 3 - Alpha pytest - :pypi:`pytest-logikal` Common testing environment Nov 27, 2024 5 - Production/Stable pytest==8.3.3 + :pypi:`pytest-logikal` Common testing environment Jan 18, 2025 5 - Production/Stable pytest==8.3.4 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Sep 30, 2024 4 - Beta pytest>=8.2.2 :pypi:`pytest-loguru` Pytest Loguru Mar 20, 2024 5 - Production/Stable pytest; extra == "test" @@ -904,7 +906,7 @@ This list contains 1569 plugins. :pypi:`pytest-mongo` MongoDB process and client fixtures plugin for Pytest. Mar 13, 2024 5 - Production/Stable pytest >=6.2 :pypi:`pytest-mongodb` pytest plugin for MongoDB fixtures May 16, 2023 5 - Production/Stable N/A :pypi:`pytest-mongodb-nono` pytest plugin for MongoDB Jan 07, 2025 N/A N/A - :pypi:`pytest-mongodb-ry` pytest plugin for MongoDB Jan 10, 2025 N/A N/A + :pypi:`pytest-mongodb-ry` pytest plugin for MongoDB Jan 13, 2025 N/A N/A :pypi:`pytest-monitor` Pytest plugin for analyzing resource usage. Jun 25, 2023 5 - Production/Stable pytest :pypi:`pytest-monkeyplus` pytest's monkeypatch subclass with extra functionalities Sep 18, 2012 5 - Production/Stable N/A :pypi:`pytest-monkeytype` pytest-monkeytype: Generate Monkeytype annotations from your pytest tests. Jul 29, 2020 4 - Beta N/A @@ -1027,6 +1029,7 @@ This list contains 1569 plugins. :pypi:`pytest-pgsql` Pytest plugins and helpers for tests using a Postgres database. May 13, 2020 5 - Production/Stable pytest (>=3.0.0) :pypi:`pytest-phmdoctest` pytest plugin to test Python examples in Markdown using phmdoctest. Apr 15, 2022 4 - Beta pytest (>=5.4.3) :pypi:`pytest-picked` Run the tests related to the changed files Nov 06, 2024 N/A pytest>=3.7.0 + :pypi:`pytest-pickle-cache` A pytest plugin for caching test results using pickle. Jan 18, 2025 N/A pytest>=7 :pypi:`pytest-pigeonhole` Jun 25, 2018 5 - Production/Stable pytest (>=3.4) :pypi:`pytest-pikachu` Show surprise when tests are passing Aug 05, 2021 5 - Production/Stable pytest :pypi:`pytest-pilot` Slice in your test base thanks to powerful markers. Oct 09, 2020 5 - Production/Stable N/A @@ -1142,7 +1145,7 @@ This list contains 1569 plugins. :pypi:`pytest-randomness` Pytest plugin about random seed management May 30, 2019 3 - Alpha N/A :pypi:`pytest-random-num` Randomise the order in which pytest tests are run with some control over the randomness Oct 19, 2020 5 - Production/Stable N/A :pypi:`pytest-random-order` Randomise the order in which pytest tests are run with some control over the randomness Jan 20, 2024 5 - Production/Stable pytest >=3.0.0 - :pypi:`pytest-ranking` A Pytest plugin for automatically prioritizing/ranking tests to speed up failure detection Dec 23, 2024 4 - Beta pytest>=7.4.3 + :pypi:`pytest-ranking` A Pytest plugin for automatically prioritizing/ranking tests to speed up failure detection Jan 14, 2025 4 - Beta pytest>=7.4.3 :pypi:`pytest-readme` Test your README.md file Sep 02, 2022 5 - Production/Stable N/A :pypi:`pytest-reana` Pytest fixtures for REANA. Sep 04, 2024 3 - Alpha N/A :pypi:`pytest-recorder` Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. Jan 09, 2025 N/A N/A @@ -1249,7 +1252,7 @@ This list contains 1569 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Jan 10, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Jan 14, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1260,7 +1263,7 @@ This list contains 1569 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Jan 10, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Jan 14, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1317,6 +1320,7 @@ This list contains 1569 plugins. :pypi:`pytest-snapshot` A plugin for snapshot testing with pytest. Apr 23, 2022 4 - Beta pytest (>=3.0.0) :pypi:`pytest-snapshot-with-message-generator` A plugin for snapshot testing with pytest. Jul 25, 2023 4 - Beta pytest (>=3.0.0) :pypi:`pytest-snmpserver` May 12, 2021 N/A N/A + :pypi:`pytest-snob` A pytest plugin that only selects meaningful python tests to run. Jan 12, 2025 N/A pytest :pypi:`pytest-snowflake-bdd` Setup test data and run tests on snowflake in BDD style! Jan 05, 2022 4 - Beta pytest (>=6.2.0) :pypi:`pytest-socket` Pytest Plugin to disable socket calls during tests Jan 28, 2024 4 - Beta pytest (>=6.2.5) :pypi:`pytest-sofaepione` Test the installation of SOFA and the SofaEpione plugin. Aug 17, 2022 N/A N/A @@ -1557,13 +1561,14 @@ This list contains 1569 plugins. :pypi:`pytest-winnotify` Windows tray notifications for py.test results. Apr 22, 2016 N/A N/A :pypi:`pytest-wiremock` A pytest plugin for programmatically using wiremock in integration tests Mar 27, 2022 N/A pytest (>=7.1.1,<8.0.0) :pypi:`pytest-with-docker` pytest with docker helpers. Nov 09, 2021 N/A pytest + :pypi:`pytest-workaround-12888` forces an import of readline early in the process to work around pytest bug #12888 Jan 15, 2025 N/A N/A :pypi:`pytest-workflow` A pytest plugin for configuring workflow/pipeline tests using YAML files Mar 18, 2024 5 - Production/Stable pytest >=7.0.0 :pypi:`pytest-xdist` pytest xdist plugin for distributed testing, most importantly across multiple CPUs Apr 28, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-xdist-debug-for-graingert` pytest xdist plugin for distributed testing and loop-on-failing modes Jul 24, 2019 5 - Production/Stable pytest (>=4.4.0) :pypi:`pytest-xdist-forked` forked from pytest-xdist Feb 10, 2020 5 - Production/Stable pytest (>=4.4.0) :pypi:`pytest-xdist-tracker` pytest plugin helps to reproduce failures for particular xdist node Nov 18, 2021 3 - Alpha pytest (>=3.5.1) :pypi:`pytest-xdist-worker-stats` A pytest plugin to list worker statistics after a xdist run. Apr 16, 2024 4 - Beta pytest>=7.0.0 - :pypi:`pytest-xdocker` Pytest fixture to run docker across test runs. Jan 04, 2025 N/A pytest<8.0.0,>=7.4.2 + :pypi:`pytest-xdocker` Pytest fixture to run docker across test runs. Jan 15, 2025 N/A pytest<8.0.0,>=7.4.2 :pypi:`pytest-xfaillist` Maintain a xfaillist in an additional file to avoid merge-conflicts. Sep 17, 2021 N/A pytest (>=6.2.2,<7.0.0) :pypi:`pytest-xfiles` Pytest fixtures providing data read from function, module or package related (x)files. Feb 27, 2018 N/A N/A :pypi:`pytest-xflaky` A simple plugin to use with pytest Oct 14, 2024 4 - Beta pytest>=8.2.1 @@ -1665,9 +1670,9 @@ This list contains 1569 plugins. pytest plugin for generating test execution results within Jira Test Management (tm4j) :pypi:`pytest-adaptavist-fixed` - *last release*: Nov 08, 2023, + *last release*: Jan 17, 2025, *status*: N/A, - *requires*: pytest >=5.4.0 + *requires*: pytest>=5.4.0 pytest plugin for generating test execution results within Jira Test Management (tm4j) @@ -1735,7 +1740,7 @@ This list contains 1569 plugins. Pytest plugin for testing async python code :pypi:`pytest-aioboto3` - *last release*: Nov 26, 2024, + *last release*: Jan 17, 2025, *status*: N/A, *requires*: N/A @@ -2183,7 +2188,7 @@ This list contains 1569 plugins. Pytest support for asyncio :pypi:`pytest-asyncio-concurrent` - *last release*: Jan 09, 2025, + *last release*: Jan 17, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -2484,7 +2489,7 @@ This list contains 1569 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Jan 09, 2025, + *last release*: Jan 16, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -4905,6 +4910,13 @@ This list contains 1569 plugins. Pytest Plugin for BDD + :pypi:`pytest-evals` + *last release*: Jan 16, 2025, + *status*: N/A, + *requires*: pytest>=7.0.0 + + A pytest plugin for running and analyzing LLM evaluation tests + :pypi:`pytest-eventlet` *last release*: Oct 04, 2021, *status*: N/A, @@ -5024,6 +5036,13 @@ This list contains 1569 plugins. A pytest plugin to provide initial/expected directories, and check a test transforms the initial directory to the expected one + :pypi:`pytest-expected` + *last release*: Jan 14, 2025, + *status*: N/A, + *requires*: pytest + + Record and play back your expectations + :pypi:`pytest-expecter` *last release*: Sep 18, 2022, *status*: 5 - Production/Stable, @@ -5732,7 +5751,7 @@ This list contains 1569 plugins. GCS fixtures and fixture factories for Pytest. :pypi:`pytest-gee` - *last release*: Jan 10, 2025, + *last release*: Jan 13, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -5816,9 +5835,9 @@ This list contains 1569 plugins. Plugin for py.test that associates tests with github issues using a marker. :pypi:`pytest-github-actions-annotate-failures` - *last release*: May 04, 2023, + *last release*: Jan 17, 2025, *status*: 5 - Production/Stable, - *requires*: pytest (>=4.0.0) + *requires*: pytest>=6.0.0 pytest plugin to annotate failed tests with a workflow command for GitHub Actions @@ -6460,7 +6479,7 @@ This list contains 1569 plugins. A py.test plugin providing fixtures to simplify inmanta modules testing. :pypi:`pytest-inmanta-extensions` - *last release*: Oct 10, 2024, + *last release*: Jan 17, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -6600,7 +6619,7 @@ This list contains 1569 plugins. :pypi:`pytest-isolate` - *last release*: Nov 24, 2024, + *last release*: Jan 16, 2025, *status*: 4 - Beta, *requires*: pytest @@ -7209,9 +7228,9 @@ This list contains 1569 plugins. pytest fixture logging configured from packaged YAML :pypi:`pytest-logikal` - *last release*: Nov 27, 2024, + *last release*: Jan 18, 2025, *status*: 5 - Production/Stable, - *requires*: pytest==8.3.3 + *requires*: pytest==8.3.4 Common testing environment @@ -7699,7 +7718,7 @@ This list contains 1569 plugins. pytest plugin for MongoDB :pypi:`pytest-mongodb-ry` - *last release*: Jan 10, 2025, + *last release*: Jan 13, 2025, *status*: N/A, *requires*: N/A @@ -8559,6 +8578,13 @@ This list contains 1569 plugins. Run the tests related to the changed files + :pypi:`pytest-pickle-cache` + *last release*: Jan 18, 2025, + *status*: N/A, + *requires*: pytest>=7 + + A pytest plugin for caching test results using pickle. + :pypi:`pytest-pigeonhole` *last release*: Jun 25, 2018, *status*: 5 - Production/Stable, @@ -9365,7 +9391,7 @@ This list contains 1569 plugins. Randomise the order in which pytest tests are run with some control over the randomness :pypi:`pytest-ranking` - *last release*: Dec 23, 2024, + *last release*: Jan 14, 2025, *status*: 4 - Beta, *requires*: pytest>=7.4.3 @@ -10114,7 +10140,7 @@ This list contains 1569 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Jan 10, 2025, + *last release*: Jan 14, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10191,7 +10217,7 @@ This list contains 1569 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Jan 10, 2025, + *last release*: Jan 14, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10589,6 +10615,13 @@ This list contains 1569 plugins. + :pypi:`pytest-snob` + *last release*: Jan 12, 2025, + *status*: N/A, + *requires*: pytest + + A pytest plugin that only selects meaningful python tests to run. + :pypi:`pytest-snowflake-bdd` *last release*: Jan 05, 2022, *status*: 4 - Beta, @@ -12269,6 +12302,13 @@ This list contains 1569 plugins. pytest with docker helpers. + :pypi:`pytest-workaround-12888` + *last release*: Jan 15, 2025, + *status*: N/A, + *requires*: N/A + + forces an import of readline early in the process to work around pytest bug #12888 + :pypi:`pytest-workflow` *last release*: Mar 18, 2024, *status*: 5 - Production/Stable, @@ -12312,7 +12352,7 @@ This list contains 1569 plugins. A pytest plugin to list worker statistics after a xdist run. :pypi:`pytest-xdocker` - *last release*: Jan 04, 2025, + *last release*: Jan 15, 2025, *status*: N/A, *requires*: pytest<8.0.0,>=7.4.2 From b89c1ce279b6dd7083a5e3795979683de269190f Mon Sep 17 00:00:00 2001 From: Emil Hjelm Date: Mon, 20 Jan 2025 16:27:21 +0100 Subject: [PATCH 270/445] Add confval ``console_output_style`` option ``times`` (#13126) Fixes #13125 --------- Co-authored-by: Bruno Oliveira --- AUTHORS | 1 + changelog/13125.feature.rst | 1 + doc/en/reference/reference.rst | 1 + src/_pytest/terminal.py | 70 +++++++++++++++++-- testing/test_terminal.py | 118 +++++++++++++++++++++++++++++++++ 5 files changed, 184 insertions(+), 7 deletions(-) create mode 100644 changelog/13125.feature.rst diff --git a/AUTHORS b/AUTHORS index ef36a4251b1..8a1a7d183a3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -142,6 +142,7 @@ Eero Vaher Eli Boyarski Elizaveta Shashkova Éloi Rivard +Emil Hjelm Endre Galaczi Eric Hunsberger Eric Liu diff --git a/changelog/13125.feature.rst b/changelog/13125.feature.rst new file mode 100644 index 00000000000..0c7d66c1169 --- /dev/null +++ b/changelog/13125.feature.rst @@ -0,0 +1 @@ +:confval:`console_output_style` now supports ``times`` to show execution time of each test. diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 26572174ad4..809e97b4747 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1355,6 +1355,7 @@ passed multiple times. The expected format is ``name=value``. For example:: * ``progress``: like classic pytest output, but with a progress indicator. * ``progress-even-when-capture-no``: allows the use of the progress indicator even when ``capture=no``. * ``count``: like progress, but shows progress as the number of tests completed instead of a percent. + * ``times``: show tests duration. The default is ``progress``, but you can fallback to ``classic`` if you prefer or the new mode is causing unexpected problems: diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 348a78af9f5..1d58bb9c8e8 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -382,12 +382,15 @@ def __init__(self, config: Config, file: TextIO | None = None) -> None: self.hasmarkup = self._tw.hasmarkup self.isatty = file.isatty() self._progress_nodeids_reported: set[str] = set() + self._timing_nodeids_reported: set[str] = set() self._show_progress_info = self._determine_show_progress_info() self._collect_report_last_write: float | None = None self._already_displayed_warnings: int | None = None self._keyboardinterrupt_memo: ExceptionRepr | None = None - def _determine_show_progress_info(self) -> Literal["progress", "count", False]: + def _determine_show_progress_info( + self, + ) -> Literal["progress", "count", "times", False]: """Return whether we should display progress information based on the current config.""" # do not show progress if we are not capturing output (#3038) unless explicitly # overridden by progress-even-when-capture-no @@ -405,6 +408,8 @@ def _determine_show_progress_info(self) -> Literal["progress", "count", False]: return "progress" elif cfg == "count": return "count" + elif cfg == "times": + return "times" else: return False @@ -692,12 +697,38 @@ def _get_progress_information_message(self) -> str: format_string = f" [{counter_format}/{{}}]" return format_string.format(progress, collected) return f" [ {collected} / {collected} ]" - else: - if collected: - return ( - f" [{len(self._progress_nodeids_reported) * 100 // collected:3d}%]" - ) - return " [100%]" + if self._show_progress_info == "times": + if not collected: + return "" + all_reports = ( + self._get_reports_to_display("passed") + + self._get_reports_to_display("xpassed") + + self._get_reports_to_display("failed") + + self._get_reports_to_display("xfailed") + + self._get_reports_to_display("skipped") + + self._get_reports_to_display("error") + + self._get_reports_to_display("") + ) + current_location = all_reports[-1].location[0] + not_reported = [ + r for r in all_reports if r.nodeid not in self._timing_nodeids_reported + ] + tests_in_module = sum( + i.location[0] == current_location for i in self._session.items + ) + tests_completed = sum( + r.when == "setup" + for r in not_reported + if r.location[0] == current_location + ) + last_in_module = tests_completed == tests_in_module + if self.showlongtestinfo or last_in_module: + self._timing_nodeids_reported.update(r.nodeid for r in not_reported) + return format_node_duration(sum(r.duration for r in not_reported)) + return "" + if collected: + return f" [{len(self._progress_nodeids_reported) * 100 // collected:3d}%]" + return " [100%]" def _write_progress_information_if_past_edge(self) -> None: w = self._width_of_current_line @@ -705,6 +736,8 @@ def _write_progress_information_if_past_edge(self) -> None: assert self._session num_tests = self._session.testscollected progress_length = len(f" [{num_tests}/{num_tests}]") + elif self._show_progress_info == "times": + progress_length = len(" 99h 59m") else: progress_length = len(" [100%]") past_edge = w + progress_length + 1 >= self._screen_width @@ -1554,6 +1587,29 @@ def format_session_duration(seconds: float) -> str: return f"{seconds:.2f}s ({dt})" +def format_node_duration(seconds: float) -> str: + """Format the given seconds in a human readable manner to show in the test progress.""" + # The formatting is designed to be compact and readable, with at most 7 characters + # for durations below 100 hours. + if seconds < 0.00001: + return f" {seconds * 1000000:.3f}us" + if seconds < 0.0001: + return f" {seconds * 1000000:.2f}us" + if seconds < 0.001: + return f" {seconds * 1000000:.1f}us" + if seconds < 0.01: + return f" {seconds * 1000:.3f}ms" + if seconds < 0.1: + return f" {seconds * 1000:.2f}ms" + if seconds < 1: + return f" {seconds * 1000:.1f}ms" + if seconds < 60: + return f" {seconds:.3f}s" + if seconds < 3600: + return f" {seconds // 60:.0f}m {seconds % 60:.0f}s" + return f" {seconds // 3600:.0f}h {(seconds % 3600) // 60:.0f}m" + + def _get_raw_skip_reason(report: TestReport) -> str: """Get the reason string of a skip/xfail/xpass test report. diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 402e1f8dba3..84c92753546 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -2073,6 +2073,21 @@ def test_foobar(i): pass """, ) + @pytest.fixture + def more_tests_files(self, pytester: Pytester) -> None: + pytester.makepyfile( + test_bar=""" + import pytest + @pytest.mark.parametrize('i', range(30)) + def test_bar(i): pass + """, + test_foo=""" + import pytest + @pytest.mark.parametrize('i', range(5)) + def test_foo(i): pass + """, + ) + def test_zero_tests_collected(self, pytester: Pytester) -> None: """Some plugins (testmon for example) might issue pytest_runtest_logreport without any tests being actually collected (#2971).""" @@ -2169,6 +2184,52 @@ def test_count(self, many_tests_files, pytester: Pytester) -> None: ] ) + def test_times(self, many_tests_files, pytester: Pytester) -> None: + pytester.makeini( + """ + [pytest] + console_output_style = times + """ + ) + output = pytester.runpytest() + output.stdout.re_match_lines( + [ + r"test_bar.py \.{10} \s+ \d{1,3}[\.[a-z\ ]{1,2}\d{0,3}\w{1,2}$", + r"test_foo.py \.{5} \s+ \d{1,3}[\.[a-z\ ]{1,2}\d{0,3}\w{1,2}$", + r"test_foobar.py \.{5} \s+ \d{1,3}[\.[a-z\ ]{1,2}\d{0,3}\w{1,2}$", + ] + ) + + def test_times_multiline( + self, more_tests_files, monkeypatch, pytester: Pytester + ) -> None: + monkeypatch.setenv("COLUMNS", "40") + pytester.makeini( + """ + [pytest] + console_output_style = times + """ + ) + output = pytester.runpytest() + output.stdout.re_match_lines( + [ + r"test_bar.py ...................", + r"........... \s+ \d{1,3}[\.[a-z\ ]{1,2}\d{0,3}\w{1,2}$", + r"test_foo.py \.{5} \s+ \d{1,3}[\.[a-z\ ]{1,2}\d{0,3}\w{1,2}$", + ], + consecutive=True, + ) + + def test_times_none_collected(self, pytester: Pytester) -> None: + pytester.makeini( + """ + [pytest] + console_output_style = times + """ + ) + output = pytester.runpytest() + assert output.ret == ExitCode.NO_TESTS_COLLECTED + def test_verbose(self, many_tests_files, pytester: Pytester) -> None: output = pytester.runpytest("-v") output.stdout.re_match_lines( @@ -2195,6 +2256,22 @@ def test_verbose_count(self, many_tests_files, pytester: Pytester) -> None: ] ) + def test_verbose_times(self, many_tests_files, pytester: Pytester) -> None: + pytester.makeini( + """ + [pytest] + console_output_style = times + """ + ) + output = pytester.runpytest("-v") + output.stdout.re_match_lines( + [ + r"test_bar.py::test_bar\[0\] PASSED \s+ \d{1,3}[\.[a-z\ ]{1,2}\d{0,3}\w{1,2}$", + r"test_foo.py::test_foo\[4\] PASSED \s+ \d{1,3}[\.[a-z\ ]{1,2}\d{0,3}\w{1,2}$", + r"test_foobar.py::test_foobar\[4\] PASSED \s+ \d{1,3}[\.[a-z\ ]{1,2}\d{0,3}\w{1,2}$", + ] + ) + def test_xdist_normal( self, many_tests_files, pytester: Pytester, monkeypatch ) -> None: @@ -2247,6 +2324,26 @@ def test_xdist_verbose( ] ) + def test_xdist_times( + self, many_tests_files, pytester: Pytester, monkeypatch + ) -> None: + pytest.importorskip("xdist") + monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False) + pytester.makeini( + """ + [pytest] + console_output_style = times + """ + ) + output = pytester.runpytest("-n2", "-v") + output.stdout.re_match_lines_random( + [ + r"\[gw\d\] \d{1,3}[\.[a-z\ ]{1,2}\d{0,3}\w{1,2} PASSED test_bar.py::test_bar\[1\]", + r"\[gw\d\] \d{1,3}[\.[a-z\ ]{1,2}\d{0,3}\w{1,2} PASSED test_foo.py::test_foo\[1\]", + r"\[gw\d\] \d{1,3}[\.[a-z\ ]{1,2}\d{0,3}\w{1,2} PASSED test_foobar.py::test_foobar\[1\]", + ] + ) + def test_capture_no(self, many_tests_files, pytester: Pytester) -> None: output = pytester.runpytest("-s") output.stdout.re_match_lines( @@ -2537,6 +2634,27 @@ def test_format_session_duration(seconds, expected): assert format_session_duration(seconds) == expected +@pytest.mark.parametrize( + "seconds, expected", + [ + (3600 * 100 - 60, " 99h 59m"), + (31 * 60 - 1, " 30m 59s"), + (10.1236, " 10.124s"), + (9.1236, " 9.124s"), + (0.1236, " 123.6ms"), + (0.01236, " 12.36ms"), + (0.001236, " 1.236ms"), + (0.0001236, " 123.6us"), + (0.00001236, " 12.36us"), + (0.000001236, " 1.236us"), + ], +) +def test_format_node_duration(seconds: float, expected: str) -> None: + from _pytest.terminal import format_node_duration + + assert format_node_duration(seconds) == expected + + def test_collecterror(pytester: Pytester) -> None: p1 = pytester.makepyfile("raise SyntaxError()") result = pytester.runpytest("-ra", str(p1)) From d6ab675a08c89606bfdc172eb410a4cdb56a5e60 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 05:04:10 +0100 Subject: [PATCH 271/445] [pre-commit.ci] pre-commit autoupdate (#13151) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.1 → v0.9.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.1...v0.9.2) - [github.com/woodruffw/zizmor-pre-commit: v1.1.1 → v1.2.2](https://github.com/woodruffw/zizmor-pre-commit/compare/v1.1.1...v1.2.2) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 45af5f7f9b9..763d09eab7a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.9.1" + rev: "v0.9.2" hooks: - id: ruff args: ["--fix"] @@ -12,7 +12,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/woodruffw/zizmor-pre-commit - rev: v1.1.1 + rev: v1.2.2 hooks: - id: zizmor - repo: https://github.com/adamchainz/blacken-docs From 4a6a512443e5e1aaed0b5bb0cc82adb2c09d4b66 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 21 Jan 2025 08:02:56 -0300 Subject: [PATCH 272/445] Fix example in pytest_collection_modifyitems (#13152) Ref #13149 --- src/_pytest/hookspec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py index 8b20061d6f0..12653ea11fe 100644 --- a/src/_pytest/hookspec.py +++ b/src/_pytest/hookspec.py @@ -277,7 +277,7 @@ def pytest_collection_modifyitems( When items are deselected (filtered out from ``items``), the hook :hook:`pytest_deselected` must be called explicitly with the deselected items to properly notify other plugins, - e.g. with ``config.hook.pytest_deselected(deselected_items)``. + e.g. with ``config.hook.pytest_deselected(items=deselected_items)``. :param session: The pytest session object. :param config: The pytest config object. From 2f1c143b17edab8e1525d553e0757a5fc27bb068 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 21 Jan 2025 10:32:01 -0300 Subject: [PATCH 273/445] Fix internal mypy error on Windows (#13153) When running `pre-commit` on Windows, I get the error below: ``` src\_pytest\_py\error.py:95: error: Invalid index type "Optional[int]" for "dict[int, int]"; expected type "int" [index] Found 1 error in 1 file (checked 234 source files) ``` Ignore the error because we do catch the `KeyError` anyway. --- src/_pytest/_py/error.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/_pytest/_py/error.py b/src/_pytest/_py/error.py index 1c7984f5a8f..dace23764ff 100644 --- a/src/_pytest/_py/error.py +++ b/src/_pytest/_py/error.py @@ -92,7 +92,9 @@ def checked_call( raise if sys.platform == "win32": try: - cls = self._geterrnoclass(_winerrnomap[value.errno]) + # error: Invalid index type "Optional[int]" for "dict[int, int]"; expected type "int" [index] + # OK to ignore because we catch the KeyError below. + cls = self._geterrnoclass(_winerrnomap[value.errno]) # type:ignore[index] except KeyError: raise value else: From ecff0babe9449e9c89118b9f24bc28251e1634c4 Mon Sep 17 00:00:00 2001 From: Tobias Alex-Petersen Date: Fri, 24 Jan 2025 02:39:17 +0100 Subject: [PATCH 274/445] Accept generic ExceptionGroups for raises (#13134) * Accept generic ExceptionGroups for raises Closes #13115 * Fix review suggestions * Add extra test, changelog improvement * Minor suggested refactor of if clause (review comment) --------- Co-authored-by: Bruno Oliveira --- AUTHORS | 1 + changelog/13115.improvement.rst | 8 ++++++ src/_pytest/python_api.py | 47 +++++++++++++++++++++++++++++---- testing/code/test_excinfo.py | 34 ++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 changelog/13115.improvement.rst diff --git a/AUTHORS b/AUTHORS index 8a1a7d183a3..8600735c8b5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -435,6 +435,7 @@ Tim Hoffmann Tim Strazny TJ Bruno Tobias Diez +Tobias Petersen Tom Dalton Tom Viner Tomáš Gavenčiak diff --git a/changelog/13115.improvement.rst b/changelog/13115.improvement.rst new file mode 100644 index 00000000000..9ac45820917 --- /dev/null +++ b/changelog/13115.improvement.rst @@ -0,0 +1,8 @@ +Allows supplying ``ExceptionGroup[Exception]`` and ``BaseExceptionGroup[BaseException]`` to ``pytest.raises`` to keep full typing on :class:`ExceptionInfo `: + +.. code-block:: python + + with pytest.raises(ExceptionGroup[Exception]) as exc_info: + some_function() + +Parametrizing with other exception types remains an error - we do not check the types of child exceptions and thus do not permit code that might look like we do. diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 25cf9f04d61..ddbf9b87251 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -12,10 +12,13 @@ from numbers import Complex import pprint import re +import sys from types import TracebackType from typing import Any from typing import cast from typing import final +from typing import get_args +from typing import get_origin from typing import overload from typing import TYPE_CHECKING from typing import TypeVar @@ -24,6 +27,10 @@ from _pytest.outcomes import fail +if sys.version_info < (3, 11): + from exceptiongroup import BaseExceptionGroup + from exceptiongroup import ExceptionGroup + if TYPE_CHECKING: from numpy import ndarray @@ -954,15 +961,45 @@ def raises( f"Raising exceptions is already understood as failing the test, so you don't need " f"any special code to say 'this should never raise an exception'." ) + + expected_exceptions: tuple[type[E], ...] + origin_exc: type[E] | None = get_origin(expected_exception) if isinstance(expected_exception, type): - expected_exceptions: tuple[type[E], ...] = (expected_exception,) + expected_exceptions = (expected_exception,) + elif origin_exc and issubclass(origin_exc, BaseExceptionGroup): + expected_exceptions = (cast(type[E], expected_exception),) else: expected_exceptions = expected_exception - for exc in expected_exceptions: - if not isinstance(exc, type) or not issubclass(exc, BaseException): + + def validate_exc(exc: type[E]) -> type[E]: + __tracebackhide__ = True + origin_exc: type[E] | None = get_origin(exc) + if origin_exc and issubclass(origin_exc, BaseExceptionGroup): + exc_type = get_args(exc)[0] + if ( + issubclass(origin_exc, ExceptionGroup) and exc_type in (Exception, Any) + ) or ( + issubclass(origin_exc, BaseExceptionGroup) + and exc_type in (BaseException, Any) + ): + return cast(type[E], origin_exc) + else: + raise ValueError( + f"Only `ExceptionGroup[Exception]` or `BaseExceptionGroup[BaseExeption]` " + f"are accepted as generic types but got `{exc}`. " + f"As `raises` will catch all instances of the specified group regardless of the " + f"generic argument specific nested exceptions has to be checked " + f"with `ExceptionInfo.group_contains()`" + ) + + elif not isinstance(exc, type) or not issubclass(exc, BaseException): msg = "expected exception must be a BaseException type, not {}" # type: ignore[unreachable] not_a = exc.__name__ if isinstance(exc, type) else type(exc).__name__ raise TypeError(msg.format(not_a)) + else: + return exc + + expected_exceptions = tuple(validate_exc(exc) for exc in expected_exceptions) message = f"DID NOT RAISE {expected_exception}" @@ -973,14 +1010,14 @@ def raises( msg += ", ".join(sorted(kwargs)) msg += "\nUse context-manager form instead?" raise TypeError(msg) - return RaisesContext(expected_exception, message, match) + return RaisesContext(expected_exceptions, message, match) else: func = args[0] if not callable(func): raise TypeError(f"{func!r} object (type: {type(func)}) must be callable") try: func(*args[1:], **kwargs) - except expected_exception as e: + except expected_exceptions as e: return _pytest._code.ExceptionInfo.from_exception(e) fail(message) diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 22e695977e1..2e1d4bdf6dc 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -31,6 +31,7 @@ from _pytest._code.code import TracebackStyle if sys.version_info < (3, 11): + from exceptiongroup import BaseExceptionGroup from exceptiongroup import ExceptionGroup @@ -453,6 +454,39 @@ def test_division_zero(): result.stdout.re_match_lines([r".*__tracebackhide__ = True.*", *match]) +def test_raises_accepts_generic_group() -> None: + with pytest.raises(ExceptionGroup[Exception]) as exc_info: + raise ExceptionGroup("", [RuntimeError()]) + assert exc_info.group_contains(RuntimeError) + + +def test_raises_accepts_generic_base_group() -> None: + with pytest.raises(BaseExceptionGroup[BaseException]) as exc_info: + raise ExceptionGroup("", [RuntimeError()]) + assert exc_info.group_contains(RuntimeError) + + +def test_raises_rejects_specific_generic_group() -> None: + with pytest.raises(ValueError): + pytest.raises(ExceptionGroup[RuntimeError]) + + +def test_raises_accepts_generic_group_in_tuple() -> None: + with pytest.raises((ValueError, ExceptionGroup[Exception])) as exc_info: + raise ExceptionGroup("", [RuntimeError()]) + assert exc_info.group_contains(RuntimeError) + + +def test_raises_exception_escapes_generic_group() -> None: + try: + with pytest.raises(ExceptionGroup[Exception]): + raise ValueError("my value error") + except ValueError as e: + assert str(e) == "my value error" + else: + pytest.fail("Expected ValueError to be raised") + + class TestGroupContains: def test_contains_exception_type(self) -> None: exc_group = ExceptionGroup("", [RuntimeError()]) From 6c9939b08b23b29da93854b4412ae4e5a17faaf1 Mon Sep 17 00:00:00 2001 From: Kenny Y <24802984+kenny-y-dev@users.noreply.github.com> Date: Sun, 15 Dec 2024 09:41:27 -0500 Subject: [PATCH 275/445] Add --force-short-summary option This option allows the users to always see the "short test summary" section regardless of the verbosity level. Fix #12713 --- changelog/12713.feature.rst | 3 +++ src/_pytest/terminal.py | 11 ++++++++++- testing/test_terminal.py | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 changelog/12713.feature.rst diff --git a/changelog/12713.feature.rst b/changelog/12713.feature.rst new file mode 100644 index 00000000000..90867b87eae --- /dev/null +++ b/changelog/12713.feature.rst @@ -0,0 +1,3 @@ +New `--force-short-summary` option to force condensed summary output regardless of verbosity level. + +This lets users still see condensed summary output of failures for quick reference in log files from job outputs, being especially useful if non-condensed output is very verbose. diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 1d58bb9c8e8..b2cdda37507 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -161,6 +161,13 @@ def pytest_addoption(parser: Parser) -> None: default=True, help="Do not fold skipped tests in short summary.", ) + group._addoption( + "--force-short-summary", + action="store_true", + dest="force_short_summary", + default=False, + help="Force condensed summary output regardless of verbosity level.", + ) group._addoption( "-q", "--quiet", @@ -1500,7 +1507,9 @@ def _get_line_with_reprcrash_message( except AttributeError: pass else: - if running_on_ci() or config.option.verbose >= 2: + if ( + running_on_ci() or config.option.verbose >= 2 + ) and not config.option.force_short_summary: msg = f" - {msg}" else: available_width = tw.fullwidth - line_width diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 84c92753546..b8242ec1b21 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -2617,6 +2617,23 @@ def test(): ) +def test_force_short_summary(monkeypatch: MonkeyPatch, pytester: Pytester) -> None: + monkeypatch.setattr(_pytest.terminal, "running_on_ci", lambda: False) + + pytester.makepyfile( + """ + def test(): + assert "a\\n" * 10 == "" + """ + ) + + result = pytester.runpytest("-vv", "--force-short-summary") + assert result.ret == 1 + result.stdout.fnmatch_lines( + ["*short test summary info*", "*AssertionError: assert 'a\\na\\na\\na..."] + ) + + @pytest.mark.parametrize( "seconds, expected", [ From d471aef98473523f400f092071dadc7f745c7196 Mon Sep 17 00:00:00 2001 From: Kenny Y <24802984+kenny-y-dev@users.noreply.github.com> Date: Sun, 26 Jan 2025 09:20:04 -0300 Subject: [PATCH 276/445] Fix sequences being shortened even with `-vv` verbosity. Fix #11777 --- changelog/11777.bugfix.rst | 1 + src/_pytest/assertion/rewrite.py | 3 +++ testing/test_terminal.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 changelog/11777.bugfix.rst diff --git a/changelog/11777.bugfix.rst b/changelog/11777.bugfix.rst new file mode 100644 index 00000000000..3f1ffc27a68 --- /dev/null +++ b/changelog/11777.bugfix.rst @@ -0,0 +1 @@ +Fixed issue where sequences were still being shortened even with ``-vv`` verbosity. diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index 41e3d271396..2e606d1903a 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -28,6 +28,7 @@ from _pytest._io.saferepr import DEFAULT_REPR_MAX_SIZE from _pytest._io.saferepr import saferepr +from _pytest._io.saferepr import saferepr_unlimited from _pytest._version import version from _pytest.assertion import util from _pytest.config import Config @@ -433,6 +434,8 @@ def _saferepr(obj: object) -> str: return obj.__name__ maxsize = _get_maxsize_for_saferepr(util._config) + if not maxsize: + return saferepr_unlimited(obj).replace("\n", "\\n") return saferepr(obj, maxsize=maxsize).replace("\n", "\\n") diff --git a/testing/test_terminal.py b/testing/test_terminal.py index b8242ec1b21..42638f2edd7 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -2617,6 +2617,35 @@ def test(): ) +def test_full_sequence_print_with_vv( + monkeypatch: MonkeyPatch, pytester: Pytester +) -> None: + """Do not truncate sequences in summaries with -vv (#11777).""" + monkeypatch.setattr(_pytest.terminal, "running_on_ci", lambda: False) + + pytester.makepyfile( + """ + def test_len_list(): + l = list(range(10)) + assert len(l) == 9 + + def test_len_dict(): + d = dict(zip(range(10), range(10))) + assert len(d) == 9 + """ + ) + + result = pytester.runpytest("-vv") + assert result.ret == 1 + result.stdout.fnmatch_lines( + [ + "*short test summary info*", + f"*{list(range(10))}*", + f"*{dict(zip(range(10), range(10)))}*", + ] + ) + + def test_force_short_summary(monkeypatch: MonkeyPatch, pytester: Pytester) -> None: monkeypatch.setattr(_pytest.terminal, "running_on_ci", lambda: False) From a0e3a49f194175bec96a551791b2b02b23e06a09 Mon Sep 17 00:00:00 2001 From: Ammar Askar Date: Sun, 26 Jan 2025 23:15:14 -0500 Subject: [PATCH 277/445] Add basic implementation of PEP657 style expression markers in tracebacks (#13102) * Add very basic implementation of PEP657 style line markers in tracebacks * Version guard the py3.11 attributes * Change version guard to make mypy happy. Also, stop using private traceback function * Version guard unit test * Fix repr cycle test * Add changelog entry * Add pragma no cover for branch where column info is missing --- AUTHORS | 1 + changelog/10224.improvement.rst | 18 +++++ src/_pytest/_code/code.py | 121 +++++++++++++++++++++++++++++++- src/_pytest/_code/source.py | 10 +++ testing/code/test_excinfo.py | 110 ++++++++++++++++++++++------- 5 files changed, 234 insertions(+), 26 deletions(-) create mode 100644 changelog/10224.improvement.rst diff --git a/AUTHORS b/AUTHORS index 8600735c8b5..e670571566a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -24,6 +24,7 @@ Alice Purcell Allan Feldman Aly Sivji Amir Elkess +Ammar Askar Anatoly Bubenkoff Anders Hovmöller Andras Mitzki diff --git a/changelog/10224.improvement.rst b/changelog/10224.improvement.rst new file mode 100644 index 00000000000..93afe9e2c1e --- /dev/null +++ b/changelog/10224.improvement.rst @@ -0,0 +1,18 @@ +pytest's ``short`` and ``long`` traceback styles (:ref:`how-to-modifying-python-tb-printing`) +now have partial :pep:`657` support and will show specific code segments in the +traceback. + +.. code-block:: pytest + + ================================= FAILURES ================================= + _______________________ test_gets_correct_tracebacks _______________________ + + test_tracebacks.py:12: in test_gets_correct_tracebacks + assert manhattan_distance(p1, p2) == 1 + ^^^^^^^^^^^^^^^^^^^^^^^^^^ + test_tracebacks.py:6: in manhattan_distance + return abs(point_1.x - point_2.x) + abs(point_1.y - point_2.y) + ^^^^^^^^^ + E AttributeError: 'NoneType' object has no attribute 'x' + +-- by :user:`ammaraskar` diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 5be200df9de..f812f0633c8 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -208,6 +208,45 @@ def with_repr_style( def lineno(self) -> int: return self._rawentry.tb_lineno - 1 + def get_python_framesummary(self) -> traceback.FrameSummary: + # Python's built-in traceback module implements all the nitty gritty + # details to get column numbers of out frames. + stack_summary = traceback.extract_tb(self._rawentry, limit=1) + return stack_summary[0] + + # Column and end line numbers introduced in python 3.11 + if sys.version_info < (3, 11): + + @property + def end_lineno_relative(self) -> int | None: + return None + + @property + def colno(self) -> int | None: + return None + + @property + def end_colno(self) -> int | None: + return None + else: + + @property + def end_lineno_relative(self) -> int | None: + frame_summary = self.get_python_framesummary() + if frame_summary.end_lineno is None: # pragma: no cover + return None + return frame_summary.end_lineno - 1 - self.frame.code.firstlineno + + @property + def colno(self) -> int | None: + """Starting byte offset of the expression in the traceback entry.""" + return self.get_python_framesummary().colno + + @property + def end_colno(self) -> int | None: + """Ending byte offset of the expression in the traceback entry.""" + return self.get_python_framesummary().end_colno + @property def frame(self) -> Frame: return Frame(self._rawentry.tb_frame) @@ -856,6 +895,9 @@ def get_source( line_index: int = -1, excinfo: ExceptionInfo[BaseException] | None = None, short: bool = False, + end_line_index: int | None = None, + colno: int | None = None, + end_colno: int | None = None, ) -> list[str]: """Return formatted and marked up source lines.""" lines = [] @@ -869,10 +911,30 @@ def get_source( space_prefix = " " if short: lines.append(space_prefix + source.lines[line_index].strip()) + lines.extend( + self.get_highlight_arrows_for_line( + raw_line=source.raw_lines[line_index], + line=source.lines[line_index].strip(), + lineno=line_index, + end_lineno=end_line_index, + colno=colno, + end_colno=end_colno, + ) + ) else: for line in source.lines[:line_index]: lines.append(space_prefix + line) lines.append(self.flow_marker + " " + source.lines[line_index]) + lines.extend( + self.get_highlight_arrows_for_line( + raw_line=source.raw_lines[line_index], + line=source.lines[line_index], + lineno=line_index, + end_lineno=end_line_index, + colno=colno, + end_colno=end_colno, + ) + ) for line in source.lines[line_index + 1 :]: lines.append(space_prefix + line) if excinfo is not None: @@ -880,6 +942,43 @@ def get_source( lines.extend(self.get_exconly(excinfo, indent=indent, markall=True)) return lines + def get_highlight_arrows_for_line( + self, + line: str, + raw_line: str, + lineno: int | None, + end_lineno: int | None, + colno: int | None, + end_colno: int | None, + ) -> list[str]: + """Return characters highlighting a source line. + + Example with colno and end_colno pointing to the bar expression: + "foo() + bar()" + returns " ^^^^^" + """ + if lineno != end_lineno: + # Don't handle expressions that span multiple lines. + return [] + if colno is None or end_colno is None: + # Can't do anything without column information. + return [] + + num_stripped_chars = len(raw_line) - len(line) + + start_char_offset = _byte_offset_to_character_offset(raw_line, colno) + end_char_offset = _byte_offset_to_character_offset(raw_line, end_colno) + num_carets = end_char_offset - start_char_offset + # If the highlight would span the whole line, it is redundant, don't + # show it. + if num_carets >= len(line.strip()): + return [] + + highlights = " " + highlights += " " * (start_char_offset - num_stripped_chars + 1) + highlights += "^" * num_carets + return [highlights] + def get_exconly( self, excinfo: ExceptionInfo[BaseException], @@ -939,11 +1038,23 @@ def repr_traceback_entry( if source is None: source = Source("???") line_index = 0 + end_line_index, colno, end_colno = None, None, None else: - line_index = entry.lineno - entry.getfirstlinesource() + line_index = entry.relline + end_line_index = entry.end_lineno_relative + colno = entry.colno + end_colno = entry.end_colno short = style == "short" reprargs = self.repr_args(entry) if not short else None - s = self.get_source(source, line_index, excinfo, short=short) + s = self.get_source( + source=source, + line_index=line_index, + excinfo=excinfo, + short=short, + end_line_index=end_line_index, + colno=colno, + end_colno=end_colno, + ) lines.extend(s) if short: message = f"in {entry.name}" @@ -1374,6 +1485,12 @@ def getfslineno(obj: object) -> tuple[str | Path, int]: return code.path, code.firstlineno +def _byte_offset_to_character_offset(str, offset): + """Converts a byte based offset in a string to a code-point.""" + as_utf8 = str.encode("utf-8") + return len(as_utf8[:offset].decode("utf-8", errors="replace")) + + # Relative paths that we use to filter traceback entries from appearing to the user; # see filter_traceback. # note: if we need to add more paths than what we have now we should probably use a list diff --git a/src/_pytest/_code/source.py b/src/_pytest/_code/source.py index e24ee3a260e..a8f7201a40f 100644 --- a/src/_pytest/_code/source.py +++ b/src/_pytest/_code/source.py @@ -22,12 +22,16 @@ class Source: def __init__(self, obj: object = None) -> None: if not obj: self.lines: list[str] = [] + self.raw_lines: list[str] = [] elif isinstance(obj, Source): self.lines = obj.lines + self.raw_lines = obj.raw_lines elif isinstance(obj, (tuple, list)): self.lines = deindent(x.rstrip("\n") for x in obj) + self.raw_lines = list(x.rstrip("\n") for x in obj) elif isinstance(obj, str): self.lines = deindent(obj.split("\n")) + self.raw_lines = obj.split("\n") else: try: rawcode = getrawcode(obj) @@ -35,6 +39,7 @@ def __init__(self, obj: object = None) -> None: except TypeError: src = inspect.getsource(obj) # type: ignore[arg-type] self.lines = deindent(src.split("\n")) + self.raw_lines = src.split("\n") def __eq__(self, other: object) -> bool: if not isinstance(other, Source): @@ -58,6 +63,7 @@ def __getitem__(self, key: int | slice) -> str | Source: raise IndexError("cannot slice a Source with a step") newsource = Source() newsource.lines = self.lines[key.start : key.stop] + newsource.raw_lines = self.raw_lines[key.start : key.stop] return newsource def __iter__(self) -> Iterator[str]: @@ -74,6 +80,7 @@ def strip(self) -> Source: while end > start and not self.lines[end - 1].strip(): end -= 1 source = Source() + source.raw_lines = self.raw_lines source.lines[:] = self.lines[start:end] return source @@ -81,6 +88,7 @@ def indent(self, indent: str = " " * 4) -> Source: """Return a copy of the source object with all lines indented by the given indent-string.""" newsource = Source() + newsource.raw_lines = self.raw_lines newsource.lines = [(indent + line) for line in self.lines] return newsource @@ -102,6 +110,7 @@ def deindent(self) -> Source: """Return a new Source object deindented.""" newsource = Source() newsource.lines[:] = deindent(self.lines) + newsource.raw_lines = self.raw_lines return newsource def __str__(self) -> str: @@ -120,6 +129,7 @@ def findsource(obj) -> tuple[Source | None, int]: return None, -1 source = Source() source.lines = [line.rstrip() for line in sourcelines] + source.raw_lines = sourcelines return source, lineno diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 2e1d4bdf6dc..89088576980 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -883,6 +883,37 @@ def entry(): assert basename in str(reprtb.reprfileloc.path) assert reprtb.reprfileloc.lineno == 3 + @pytest.mark.skipif( + "sys.version_info < (3,11)", + reason="Column level traceback info added in python 3.11", + ) + def test_repr_traceback_entry_short_carets(self, importasmod) -> None: + mod = importasmod( + """ + def div_by_zero(): + return 1 / 0 + def func1(): + return 42 + div_by_zero() + def entry(): + func1() + """ + ) + excinfo = pytest.raises(ZeroDivisionError, mod.entry) + p = FormattedExcinfo(style="short") + reprtb = p.repr_traceback_entry(excinfo.traceback[-3]) + assert len(reprtb.lines) == 1 + assert reprtb.lines[0] == " func1()" + + reprtb = p.repr_traceback_entry(excinfo.traceback[-2]) + assert len(reprtb.lines) == 2 + assert reprtb.lines[0] == " return 42 + div_by_zero()" + assert reprtb.lines[1] == " ^^^^^^^^^^^^^" + + reprtb = p.repr_traceback_entry(excinfo.traceback[-1]) + assert len(reprtb.lines) == 2 + assert reprtb.lines[0] == " return 1 / 0" + assert reprtb.lines[1] == " ^^^^^" + def test_repr_tracebackentry_no(self, importasmod): mod = importasmod( """ @@ -1343,7 +1374,7 @@ def g(): raise ValueError() def h(): - raise AttributeError() + if True: raise AttributeError() """ ) excinfo = pytest.raises(AttributeError, mod.f) @@ -1404,12 +1435,22 @@ def h(): assert tw_mock.lines[40] == ("_ ", None) assert tw_mock.lines[41] == "" assert tw_mock.lines[42] == " def h():" - assert tw_mock.lines[43] == "> raise AttributeError()" - assert tw_mock.lines[44] == "E AttributeError" - assert tw_mock.lines[45] == "" - line = tw_mock.get_write_msg(46) - assert line.endswith("mod.py") - assert tw_mock.lines[47] == ":15: AttributeError" + # On python 3.11 and greater, check for carets in the traceback. + if sys.version_info >= (3, 11): + assert tw_mock.lines[43] == "> if True: raise AttributeError()" + assert tw_mock.lines[44] == " ^^^^^^^^^^^^^^^^^^^^^^" + assert tw_mock.lines[45] == "E AttributeError" + assert tw_mock.lines[46] == "" + line = tw_mock.get_write_msg(47) + assert line.endswith("mod.py") + assert tw_mock.lines[48] == ":15: AttributeError" + else: + assert tw_mock.lines[43] == "> if True: raise AttributeError()" + assert tw_mock.lines[44] == "E AttributeError" + assert tw_mock.lines[45] == "" + line = tw_mock.get_write_msg(46) + assert line.endswith("mod.py") + assert tw_mock.lines[47] == ":15: AttributeError" @pytest.mark.parametrize("mode", ["from_none", "explicit_suppress"]) def test_exc_repr_chain_suppression(self, importasmod, mode, tw_mock): @@ -1528,23 +1569,44 @@ def unreraise(): r = excinfo.getrepr(style="short") r.toterminal(tw_mock) out = "\n".join(line for line in tw_mock.lines if isinstance(line, str)) - expected_out = textwrap.dedent( - """\ - :13: in unreraise - reraise() - :10: in reraise - raise Err() from e - E test_exc_chain_repr_cycle0.mod.Err - - During handling of the above exception, another exception occurred: - :15: in unreraise - raise e.__cause__ - :8: in reraise - fail() - :5: in fail - return 0 / 0 - E ZeroDivisionError: division by zero""" - ) + # Assert highlighting carets in python3.11+ + if sys.version_info >= (3, 11): + expected_out = textwrap.dedent( + """\ + :13: in unreraise + reraise() + :10: in reraise + raise Err() from e + E test_exc_chain_repr_cycle0.mod.Err + + During handling of the above exception, another exception occurred: + :15: in unreraise + raise e.__cause__ + :8: in reraise + fail() + :5: in fail + return 0 / 0 + ^^^^^ + E ZeroDivisionError: division by zero""" + ) + else: + expected_out = textwrap.dedent( + """\ + :13: in unreraise + reraise() + :10: in reraise + raise Err() from e + E test_exc_chain_repr_cycle0.mod.Err + + During handling of the above exception, another exception occurred: + :15: in unreraise + raise e.__cause__ + :8: in reraise + fail() + :5: in fail + return 0 / 0 + E ZeroDivisionError: division by zero""" + ) assert out == expected_out def test_exec_type_error_filter(self, importasmod): From fb7f0440c4b212b8fa34d9224988792006d32931 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 07:58:30 -0300 Subject: [PATCH 278/445] build(deps): Bump pypa/gh-action-pypi-publish from 1.12.3 to 1.12.4 (#13165) Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.12.3 to 1.12.4. - [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases) - [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.12.3...v1.12.4) --- updated-dependencies: - dependency-name: pypa/gh-action-pypi-publish dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 32d55361e54..fb58390b597 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -56,7 +56,7 @@ jobs: path: dist - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@v1.12.3 + uses: pypa/gh-action-pypi-publish@v1.12.4 with: attestations: true From 991db2e1b1d478f87ad460ecde98dbeeab53b13b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 07:59:11 -0300 Subject: [PATCH 279/445] build(deps): Bump hynek/build-and-inspect-python-package (#13166) Bumps [hynek/build-and-inspect-python-package](https://github.com/hynek/build-and-inspect-python-package) from 2.11.0 to 2.12.0. - [Release notes](https://github.com/hynek/build-and-inspect-python-package/releases) - [Changelog](https://github.com/hynek/build-and-inspect-python-package/blob/main/CHANGELOG.md) - [Commits](https://github.com/hynek/build-and-inspect-python-package/compare/v2.11.0...v2.12.0) --- updated-dependencies: - dependency-name: hynek/build-and-inspect-python-package dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/deploy.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fb58390b597..2ad6e9d5054 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,7 +31,7 @@ jobs: persist-credentials: false - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v2.11.0 + uses: hynek/build-and-inspect-python-package@v2.12.0 with: attest-build-provenance-github: 'true' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5814c81fb30..44c9d68c03d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,7 +40,7 @@ jobs: fetch-depth: 0 persist-credentials: false - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v2.11.0 + uses: hynek/build-and-inspect-python-package@v2.12.0 build: needs: [package] From 2f369848ea0ead42182efc77000a5ecef629a0ba Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 28 Jan 2025 09:26:40 +0100 Subject: [PATCH 280/445] [pre-commit.ci] pre-commit autoupdate (#13167) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.2 → v0.9.3](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.2...v0.9.3) - [github.com/codespell-project/codespell: v2.3.0 → v2.4.0](https://github.com/codespell-project/codespell/compare/v2.3.0...v2.4.0) --- .pre-commit-config.yaml | 4 ++-- doc/en/how-to/cache.rst | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 763d09eab7a..527586a1f68 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.9.2" + rev: "v0.9.3" hooks: - id: ruff args: ["--fix"] @@ -21,7 +21,7 @@ repos: - id: blacken-docs additional_dependencies: [black==24.1.1] - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.0 hooks: - id: codespell args: ["--toml=pyproject.toml"] diff --git a/doc/en/how-to/cache.rst b/doc/en/how-to/cache.rst index 40cd3f00dd6..a3b2a862534 100644 --- a/doc/en/how-to/cache.rst +++ b/doc/en/how-to/cache.rst @@ -199,7 +199,7 @@ The new config.cache object Plugins or conftest.py support code can get a cached value using the pytest ``config`` object. Here is a basic example plugin which -implements a :ref:`fixture ` which re-uses previously created state +implements a :ref:`fixture ` which reuses previously created state across pytest invocations: .. code-block:: python From 9bcd7704ab77719bf9155a3a92c7191c944ef428 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 31 Jan 2025 13:04:25 +0100 Subject: [PATCH 281/445] [automated] Update plugin list (#13162) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 174 ++++++++++++++++++------------- 1 file changed, 103 insertions(+), 71 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index e575d58ac7f..4b1b7241379 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =6.2.2) + :pypi:`pytest-ai` A Python package to generate regular, edge-case, and security HTTP tests. Jan 22, 2025 N/A N/A :pypi:`pytest-ai1899` pytest plugin for connecting to ai1899 smart system stack Mar 13, 2024 5 - Production/Stable N/A :pypi:`pytest-aio` Pytest plugin for testing async python code Jul 31, 2024 5 - Production/Stable pytest :pypi:`pytest-aioboto3` Aioboto3 Pytest with Moto Jan 17, 2025 N/A N/A :pypi:`pytest-aiofiles` pytest fixtures for writing aiofiles tests with pyfakefs May 14, 2017 5 - Production/Stable N/A :pypi:`pytest-aiogram` May 06, 2023 N/A N/A - :pypi:`pytest-aiohttp` Pytest plugin for aiohttp support Sep 06, 2023 4 - Beta pytest >=6.1.0 + :pypi:`pytest-aiohttp` Pytest plugin for aiohttp support Jan 23, 2025 4 - Beta pytest>=6.1.0 :pypi:`pytest-aiohttp-client` Pytest \`client\` fixture for the Aiohttp Jan 10, 2023 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-aiomoto` pytest-aiomoto Jun 24, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-aioresponses` py.test integration for aioresponses Jan 02, 2025 4 - Beta pytest>=3.5.0 @@ -78,7 +79,7 @@ This list contains 1574 plugins. :pypi:`pytest-anki` A pytest plugin for testing Anki add-ons Jul 31, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-annotate` pytest-annotate: Generate PyAnnotate annotations from your pytest tests. Jun 07, 2022 3 - Alpha pytest (<8.0.0,>=3.2.0) :pypi:`pytest-annotated` Pytest plugin to allow use of Annotated in tests to resolve fixtures Sep 30, 2024 N/A pytest>=8.3.3 - :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures Dec 12, 2024 5 - Production/Stable pytest>=6 + :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures Jan 21, 2025 5 - Production/Stable pytest>=6 :pypi:`pytest-ansible-playbook` Pytest fixture which runs given ansible playbook file. Mar 08, 2019 4 - Beta N/A :pypi:`pytest-ansible-playbook-runner` Pytest fixture which runs given ansible playbook file. Dec 02, 2020 4 - Beta pytest (>=3.1.0) :pypi:`pytest-ansible-units` A pytest plugin for running unit tests within an ansible collection Apr 14, 2022 N/A N/A @@ -159,7 +160,7 @@ This list contains 1574 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Jan 16, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Jan 22, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -259,7 +260,7 @@ This list contains 1574 plugins. :pypi:`pytest-cloud` Distributed tests planner plugin for pytest testing framework. Oct 05, 2020 6 - Mature N/A :pypi:`pytest-cloudflare-worker` pytest plugin for testing cloudflare workers Mar 30, 2021 4 - Beta pytest (>=6.0.0) :pypi:`pytest-cloudist` Distribute tests to cloud machines without fuss Sep 02, 2022 4 - Beta pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-cmake` Provide CMake module for Pytest Oct 27, 2024 N/A pytest<9,>=4 + :pypi:`pytest-cmake` Provide CMake module for Pytest Jan 19, 2025 N/A pytest<9,>=4 :pypi:`pytest-cmake-presets` Execute CMake Presets via pytest Dec 26, 2022 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-cmdline-add-args` Pytest plugin for custom argument handling and Allure reporting. This plugin allows you to add arguments before running a test. Sep 01, 2024 N/A N/A :pypi:`pytest-cobra` PyTest plugin for testing Smart Contracts for Ethereum blockchain. Jun 29, 2019 3 - Alpha pytest (<4.0.0,>=3.7.1) @@ -433,7 +434,7 @@ This list contains 1574 plugins. :pypi:`pytest-doctest-ellipsis-markers` Setup additional values for ELLIPSIS_MARKER for doctests Jan 12, 2018 4 - Beta N/A :pypi:`pytest-doctest-import` A simple pytest plugin to import names and add them to the doctest namespace. Nov 13, 2018 4 - Beta pytest (>=3.3.0) :pypi:`pytest-doctest-mkdocstrings` Run pytest --doctest-modules with markdown docstrings in code blocks (\`\`\`) Mar 02, 2024 N/A pytest - :pypi:`pytest-doctestplus` Pytest plugin with advanced doctest features. Nov 25, 2024 5 - Production/Stable pytest>=4.6 + :pypi:`pytest-doctestplus` Pytest plugin with advanced doctest features. Jan 25, 2025 5 - Production/Stable pytest>=4.6 :pypi:`pytest-documentary` A simple pytest plugin to generate test documentation Jul 11, 2024 N/A pytest :pypi:`pytest-dogu-report` pytest plugin for dogu report Jul 07, 2023 N/A N/A :pypi:`pytest-dogu-sdk` pytest plugin for the Dogu Dec 14, 2023 N/A N/A @@ -449,7 +450,7 @@ This list contains 1574 plugins. :pypi:`pytest-drivings` Tool to allow webdriver automation to be ran locally or remotely Jan 13, 2021 N/A N/A :pypi:`pytest-drop-dup-tests` A Pytest plugin to drop duplicated tests during collection Mar 04, 2024 5 - Production/Stable pytest >=7 :pypi:`pytest-dryci` Test caching plugin for pytest Sep 27, 2024 4 - Beta N/A - :pypi:`pytest-dryrun` A Pytest plugin to ignore tests during collection without reporting them in the test summary. Jul 18, 2023 5 - Production/Stable pytest (>=7.4.0,<8.0.0) + :pypi:`pytest-dryrun` A Pytest plugin to ignore tests during collection without reporting them in the test summary. Jan 19, 2025 5 - Production/Stable pytest<9,>=7.40 :pypi:`pytest-dummynet` A py.test plugin providing access to a dummynet. Dec 15, 2021 5 - Production/Stable pytest :pypi:`pytest-dump2json` A pytest plugin for dumping test results to json. Jun 29, 2015 N/A N/A :pypi:`pytest-duration-insights` Jul 15, 2024 N/A N/A @@ -472,15 +473,15 @@ This list contains 1574 plugins. :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Dec 02, 2024 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Dec 02, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Dec 02, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Dec 02, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Dec 02, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Dec 02, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Dec 02, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Dec 02, 2024 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Dec 02, 2024 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Jan 21, 2025 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Jan 21, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Jan 21, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Jan 21, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Jan 21, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Jan 21, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Jan 21, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Jan 21, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Jan 21, 2025 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -505,7 +506,7 @@ This list contains 1574 plugins. :pypi:`pytest-eth` PyTest plugin for testing Smart Contracts for Ethereum Virtual Machine (EVM). Aug 14, 2020 1 - Planning N/A :pypi:`pytest-ethereum` pytest-ethereum: Pytest library for ethereum projects. Jun 24, 2019 3 - Alpha pytest (==3.3.2); extra == 'dev' :pypi:`pytest-eucalyptus` Pytest Plugin for BDD Jun 28, 2022 N/A pytest (>=4.2.0) - :pypi:`pytest-evals` A pytest plugin for running and analyzing LLM evaluation tests Jan 16, 2025 N/A pytest>=7.0.0 + :pypi:`pytest-evals` A pytest plugin for running and analyzing LLM evaluation tests Jan 21, 2025 N/A pytest>=7.0.0 :pypi:`pytest-eventlet` Applies eventlet monkey-patch as a pytest plugin. Oct 04, 2021 N/A pytest ; extra == 'dev' :pypi:`pytest_evm` The testing package containing tools to test Web3-based projects Sep 23, 2024 4 - Beta pytest<9.0.0,>=8.1.1 :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A @@ -521,6 +522,7 @@ This list contains 1574 plugins. :pypi:`pytest-executable` pytest plugin for testing executables Oct 07, 2023 N/A pytest <8,>=5 :pypi:`pytest-execution-timer` A timer for the phases of Pytest's execution. Dec 24, 2021 4 - Beta N/A :pypi:`pytest-exit-code` A pytest plugin that overrides the built-in exit codes to retain more information about the test results. May 06, 2024 4 - Beta pytest>=6.2.0 + :pypi:`pytest-exit-status` Enhance. Jan 25, 2025 N/A pytest>=8.0.0 :pypi:`pytest-expect` py.test plugin to store test expectations and mark tests based on them Apr 21, 2016 4 - Beta N/A :pypi:`pytest-expectdir` A pytest plugin to provide initial/expected directories, and check a test transforms the initial directory to the expected one Mar 19, 2023 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-expected` Record and play back your expectations Jan 14, 2025 N/A pytest @@ -537,7 +539,7 @@ This list contains 1574 plugins. :pypi:`pytest_extra` Some helpers for writing tests with pytest. Aug 14, 2014 N/A N/A :pypi:`pytest-extra-durations` A pytest plugin to get durations on a per-function basis and per module basis. Apr 21, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-extra-markers` Additional pytest markers to dynamically enable/disable tests viia CLI flags Mar 05, 2023 4 - Beta pytest - :pypi:`pytest-f3ts` Pytest Plugin for communicating test results and information to a FixturFab Test Runner GUI Dec 11, 2024 N/A pytest<8.0.0,>=7.2.1 + :pypi:`pytest-f3ts` Pytest Plugin for communicating test results and information to a FixturFab Test Runner GUI Jan 22, 2025 N/A pytest<8.0.0,>=7.2.1 :pypi:`pytest-fabric` Provides test utilities to run fabric task tests by using docker containers Sep 12, 2018 5 - Production/Stable N/A :pypi:`pytest-factor` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A :pypi:`pytest-factory` Use factories for test setup with py.test Sep 06, 2020 3 - Alpha pytest (>4.3) @@ -608,7 +610,7 @@ This list contains 1574 plugins. :pypi:`pytest-forward-compatibility` A pytest plugin to shim pytest commandline options for fowards compatibility Sep 29, 2020 N/A N/A :pypi:`pytest-frappe` Pytest Frappe Plugin - A set of pytest fixtures to test Frappe applications Jul 30, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-freethreaded` pytest plugin for running parallel tests Oct 03, 2024 5 - Production/Stable pytest - :pypi:`pytest-freezeblaster` Wrap tests with fixtures in freeze_time Jul 10, 2024 N/A pytest>=6.2.5 + :pypi:`pytest-freezeblaster` Wrap tests with fixtures in freeze_time Jan 23, 2025 N/A pytest>=6.2.5 :pypi:`pytest-freezegun` Wrap tests with fixtures in freeze_time Jul 19, 2020 4 - Beta pytest (>=3.0.0) :pypi:`pytest-freezer` Pytest plugin providing a fixture interface for spulec/freezegun Dec 12, 2024 N/A pytest>=3.6 :pypi:`pytest-freeze-reqs` Check if requirement files are frozen Apr 29, 2021 N/A N/A @@ -624,13 +626,13 @@ This list contains 1574 plugins. :pypi:`pytest-gather-fixtures` set up asynchronous pytest fixtures concurrently Aug 18, 2024 N/A pytest>=7.0.0 :pypi:`pytest-gc` The garbage collector plugin for py.test Feb 01, 2018 N/A N/A :pypi:`pytest-gcov` Uses gcov to measure test coverage of a C library Feb 01, 2018 3 - Alpha N/A - :pypi:`pytest-gcs` GCS fixtures and fixture factories for Pytest. Mar 01, 2024 5 - Production/Stable pytest >=6.2 + :pypi:`pytest-gcs` GCS fixtures and fixture factories for Pytest. Jan 24, 2025 5 - Production/Stable pytest>=6.2 :pypi:`pytest-gee` The Python plugin for your GEE based packages. Jan 13, 2025 3 - Alpha pytest :pypi:`pytest-gevent` Ensure that gevent is properly patched when invoking pytest Feb 25, 2020 N/A pytest :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Jan 08, 2025 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Jan 22, 2025 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -674,7 +676,7 @@ This list contains 1574 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Jan 10, 2025 3 - Alpha pytest==8.3.4 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Jan 25, 2025 3 - Alpha pytest==8.3.4 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -697,7 +699,7 @@ This list contains 1574 plugins. :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace Jan 11, 2025 4 - Beta pytest>=7.0.0 :pypi:`pytest-http-mocker` Pytest plugin for http mocking (via https://github.com/vilus/mocker) Oct 20, 2019 N/A N/A :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A - :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Aug 11, 2024 3 - Alpha N/A + :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Jan 21, 2025 3 - Alpha N/A :pypi:`pytest-httptesting` http_testing framework on top of pytest Dec 19, 2024 N/A pytest>=8.2.0 :pypi:`pytest-httpx` Send responses to httpx. Nov 28, 2024 5 - Production/Stable pytest==8.* :pypi:`pytest-httpx-blockage` Disable httpx requests during a test run Feb 16, 2023 N/A pytest (>=7.2.1) @@ -803,7 +805,7 @@ This list contains 1574 plugins. :pypi:`pytest-launchable` Launchable Pytest Plugin Apr 05, 2023 N/A pytest (>=4.2.0) :pypi:`pytest-layab` Pytest fixtures for layab. Oct 05, 2020 5 - Production/Stable N/A :pypi:`pytest-lazy-fixture` It helps to use fixtures in pytest.mark.parametrize Feb 01, 2020 4 - Beta pytest (>=3.2.5) - :pypi:`pytest-lazy-fixtures` Allows you to use fixtures in @pytest.mark.parametrize. Jul 22, 2024 N/A pytest>=7 + :pypi:`pytest-lazy-fixtures` Allows you to use fixtures in @pytest.mark.parametrize. Jan 25, 2025 N/A pytest>=7 :pypi:`pytest-ldap` python-ldap fixtures for pytest Aug 18, 2020 N/A pytest :pypi:`pytest-leak-finder` Find the test that's leaking before the one that fails Feb 15, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-leaks` A pytest plugin to trace resource leaks. Nov 27, 2019 1 - Planning N/A @@ -835,7 +837,7 @@ This list contains 1574 plugins. :pypi:`pytest-logger` Plugin configuring handlers for loggers from Python logging module. Mar 10, 2024 5 - Production/Stable pytest (>=3.2) :pypi:`pytest-logging` Configures logging and allows tweaking the log level with a py.test flag Nov 04, 2015 4 - Beta N/A :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-logging-strict` pytest fixture logging configured from packaged YAML Jan 03, 2025 3 - Alpha pytest + :pypi:`pytest-logging-strict` pytest fixture logging configured from packaged YAML Jan 19, 2025 3 - Alpha pytest :pypi:`pytest-logikal` Common testing environment Jan 18, 2025 5 - Production/Stable pytest==8.3.4 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Sep 30, 2024 4 - Beta pytest>=8.2.2 @@ -872,7 +874,7 @@ This list contains 1574 plugins. :pypi:`pytest-memray` A simple plugin to use with pytest Jul 25, 2024 N/A pytest>=7.2 :pypi:`pytest-menu` A pytest plugin for console based interactive test selection just after the collection phase Oct 04, 2017 3 - Alpha pytest (>=2.4.2) :pypi:`pytest-mercurial` pytest plugin to write integration tests for projects using Mercurial Python internals Nov 21, 2020 1 - Planning N/A - :pypi:`pytest-mergify` Pytest plugin for Mergify Dec 27, 2024 N/A N/A + :pypi:`pytest-mergify` Pytest plugin for Mergify Jan 23, 2025 N/A N/A :pypi:`pytest-mesh` pytest_mesh插件 Aug 05, 2022 N/A pytest (==7.1.2) :pypi:`pytest-message` Pytest plugin for sending report message of marked tests execution Aug 04, 2022 N/A pytest (>=6.2.5) :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A @@ -906,7 +908,7 @@ This list contains 1574 plugins. :pypi:`pytest-mongo` MongoDB process and client fixtures plugin for Pytest. Mar 13, 2024 5 - Production/Stable pytest >=6.2 :pypi:`pytest-mongodb` pytest plugin for MongoDB fixtures May 16, 2023 5 - Production/Stable N/A :pypi:`pytest-mongodb-nono` pytest plugin for MongoDB Jan 07, 2025 N/A N/A - :pypi:`pytest-mongodb-ry` pytest plugin for MongoDB Jan 13, 2025 N/A N/A + :pypi:`pytest-mongodb-ry` pytest plugin for MongoDB Jan 21, 2025 N/A N/A :pypi:`pytest-monitor` Pytest plugin for analyzing resource usage. Jun 25, 2023 5 - Production/Stable pytest :pypi:`pytest-monkeyplus` pytest's monkeypatch subclass with extra functionalities Sep 18, 2012 5 - Production/Stable N/A :pypi:`pytest-monkeytype` pytest-monkeytype: Generate Monkeytype annotations from your pytest tests. Jul 29, 2020 4 - Beta N/A @@ -963,6 +965,7 @@ This list contains 1574 plugins. :pypi:`pytest-notion` A PyTest Reporter to send test runs to Notion.so Aug 07, 2019 N/A N/A :pypi:`pytest-nunit` A pytest plugin for generating NUnit3 test result XML output Feb 26, 2024 5 - Production/Stable N/A :pypi:`pytest-oar` PyTest plugin for the OAR testing framework May 02, 2023 N/A pytest>=6.0.1 + :pypi:`pytest-oarepo` Jan 22, 2025 N/A pytest>=7.1.2; extra == "local" :pypi:`pytest-object-getter` Import any object from a 3rd party module while mocking its namespace on demand. Jul 31, 2022 5 - Production/Stable pytest :pypi:`pytest-ochrus` pytest results data-base and HTML reporter Feb 21, 2018 4 - Beta N/A :pypi:`pytest-odc` A pytest plugin for simplifying ODC database tests Aug 04, 2023 4 - Beta pytest (>=3.5.0) @@ -1177,7 +1180,7 @@ This list contains 1574 plugins. :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Oct 11, 2024 4 - Beta N/A :pypi:`pytest-reporter-html-dots` A basic HTML report for pytest using Jinja2 template engine. Jan 22, 2023 N/A N/A - :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots, webpage sources and attachments. Jan 09, 2025 N/A pytest>=8.0.0 + :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots, webpage sources and attachments. Jan 25, 2025 N/A pytest>=8.0.0 :pypi:`pytest-reportinfra` Pytest plugin for reportinfra Aug 11, 2019 3 - Alpha N/A :pypi:`pytest-reporting` A plugin to report summarized results in a table format Oct 25, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-reportlog` Replacement for the --resultlog option, focused in simplicity and extensibility May 22, 2023 3 - Alpha pytest @@ -1213,7 +1216,7 @@ This list contains 1574 plugins. :pypi:`pytest-result-sender-lj` Default template for PDM package Dec 17, 2024 N/A pytest>=8.3.4 :pypi:`pytest-resume` A Pytest plugin to resuming from the last run test Apr 22, 2023 4 - Beta pytest (>=7.0) :pypi:`pytest-rethinkdb` A RethinkDB plugin for pytest. Jul 24, 2016 4 - Beta N/A - :pypi:`pytest-retry` Adds the ability to retry flaky tests in CI environments May 14, 2024 N/A pytest>=7.0.0 + :pypi:`pytest-retry` Adds the ability to retry flaky tests in CI environments Jan 19, 2025 N/A pytest>=7.0.0 :pypi:`pytest-retry-class` A pytest plugin to rerun entire class on failure Nov 24, 2024 N/A pytest>=5.3 :pypi:`pytest-reusable-testcases` Apr 28, 2023 N/A N/A :pypi:`pytest-revealtype-injector` Pytest plugin for replacing reveal_type() calls inside test functions with static and runtime type checking result comparison, for confirming type annotation validity. Dec 19, 2024 4 - Beta pytest>=7.0 @@ -1252,7 +1255,7 @@ This list contains 1574 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Jan 14, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Jan 25, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1263,7 +1266,7 @@ This list contains 1574 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Jan 14, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Jan 25, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1401,6 +1404,7 @@ This list contains 1574 plugins. :pypi:`pytest-tcpclient` A pytest plugin for testing TCP clients Nov 16, 2022 N/A pytest (<8,>=7.1.3) :pypi:`pytest-tdd` run pytest on a python module Aug 18, 2023 4 - Beta N/A :pypi:`pytest-teamcity-logblock` py.test plugin to introduce block structure in teamcity build log, if output is not captured May 15, 2018 4 - Beta N/A + :pypi:`pytest-teardown` Jan 22, 2025 N/A pytest<9.0.0,>=7.4.1 :pypi:`pytest-telegram` Pytest to Telegram reporting plugin Apr 25, 2024 5 - Production/Stable N/A :pypi:`pytest-telegram-notifier` Telegram notification plugin for Pytest Jun 27, 2023 5 - Production/Stable N/A :pypi:`pytest-tempdir` Predictable and repeatable tempdir support. Oct 11, 2019 4 - Beta pytest (>=2.8.1) @@ -1444,7 +1448,7 @@ This list contains 1574 plugins. :pypi:`pytest-test-tracer-for-pytest-bdd` A plugin that allows coll test data for use on Test Tracer Aug 20, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-test-utils` Feb 08, 2024 N/A pytest >=3.9 :pypi:`pytest-tesults` Tesults plugin for pytest Nov 12, 2024 5 - Production/Stable pytest>=3.5.0 - :pypi:`pytest-textual-snapshot` Snapshot testing for Textual apps Jul 22, 2024 4 - Beta pytest>=8.0.0 + :pypi:`pytest-textual-snapshot` Snapshot testing for Textual apps Jan 23, 2025 5 - Production/Stable pytest>=8.0.0 :pypi:`pytest-tezos` pytest-ligo Jan 16, 2020 4 - Beta N/A :pypi:`pytest-tf` Test your OpenTofu and Terraform config using a PyTest plugin May 29, 2024 N/A pytest<9.0.0,>=8.2.1 :pypi:`pytest-th2-bdd` pytest_th2_bdd May 13, 2022 N/A N/A @@ -1452,7 +1456,7 @@ This list contains 1574 plugins. :pypi:`pytest-thread` Jul 07, 2023 N/A N/A :pypi:`pytest-threadleak` Detects thread leaks Jul 03, 2022 4 - Beta pytest (>=3.1.1) :pypi:`pytest-tick` Ticking on tests Aug 31, 2021 5 - Production/Stable pytest (>=6.2.5,<7.0.0) - :pypi:`pytest-time` Aug 28, 2024 3 - Alpha pytest + :pypi:`pytest-time` Jan 20, 2025 3 - Alpha pytest :pypi:`pytest-timeassert-ethan` execution duration Dec 25, 2023 N/A pytest :pypi:`pytest-timeit` A pytest plugin to time test function runs Oct 13, 2016 4 - Beta N/A :pypi:`pytest-timeout` pytest plugin to abort hanging tests Mar 07, 2024 5 - Production/Stable pytest >=7.0.0 @@ -1568,7 +1572,7 @@ This list contains 1574 plugins. :pypi:`pytest-xdist-forked` forked from pytest-xdist Feb 10, 2020 5 - Production/Stable pytest (>=4.4.0) :pypi:`pytest-xdist-tracker` pytest plugin helps to reproduce failures for particular xdist node Nov 18, 2021 3 - Alpha pytest (>=3.5.1) :pypi:`pytest-xdist-worker-stats` A pytest plugin to list worker statistics after a xdist run. Apr 16, 2024 4 - Beta pytest>=7.0.0 - :pypi:`pytest-xdocker` Pytest fixture to run docker across test runs. Jan 15, 2025 N/A pytest<8.0.0,>=7.4.2 + :pypi:`pytest-xdocker` Pytest fixture to run docker across test runs. Jan 22, 2025 N/A pytest<8.0.0,>=7.4.2 :pypi:`pytest-xfaillist` Maintain a xfaillist in an additional file to avoid merge-conflicts. Sep 17, 2021 N/A pytest (>=6.2.2,<7.0.0) :pypi:`pytest-xfiles` Pytest fixtures providing data read from function, module or package related (x)files. Feb 27, 2018 N/A N/A :pypi:`pytest-xflaky` A simple plugin to use with pytest Oct 14, 2024 4 - Beta pytest>=8.2.1 @@ -1725,6 +1729,13 @@ This list contains 1574 plugins. pytest plugin for pytest-repeat that generate aggregate report of the same test cases with additional statistics details. + :pypi:`pytest-ai` + *last release*: Jan 22, 2025, + *status*: N/A, + *requires*: N/A + + A Python package to generate regular, edge-case, and security HTTP tests. + :pypi:`pytest-ai1899` *last release*: Mar 13, 2024, *status*: 5 - Production/Stable, @@ -1761,9 +1772,9 @@ This list contains 1574 plugins. :pypi:`pytest-aiohttp` - *last release*: Sep 06, 2023, + *last release*: Jan 23, 2025, *status*: 4 - Beta, - *requires*: pytest >=6.1.0 + *requires*: pytest>=6.1.0 Pytest plugin for aiohttp support @@ -1922,7 +1933,7 @@ This list contains 1574 plugins. Pytest plugin to allow use of Annotated in tests to resolve fixtures :pypi:`pytest-ansible` - *last release*: Dec 12, 2024, + *last release*: Jan 21, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=6 @@ -2489,7 +2500,7 @@ This list contains 1574 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Jan 16, 2025, + *last release*: Jan 22, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -3189,7 +3200,7 @@ This list contains 1574 plugins. Distribute tests to cloud machines without fuss :pypi:`pytest-cmake` - *last release*: Oct 27, 2024, + *last release*: Jan 19, 2025, *status*: N/A, *requires*: pytest<9,>=4 @@ -4407,7 +4418,7 @@ This list contains 1574 plugins. Run pytest --doctest-modules with markdown docstrings in code blocks (\`\`\`) :pypi:`pytest-doctestplus` - *last release*: Nov 25, 2024, + *last release*: Jan 25, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=4.6 @@ -4519,9 +4530,9 @@ This list contains 1574 plugins. Test caching plugin for pytest :pypi:`pytest-dryrun` - *last release*: Jul 18, 2023, + *last release*: Jan 19, 2025, *status*: 5 - Production/Stable, - *requires*: pytest (>=7.4.0,<8.0.0) + *requires*: pytest<9,>=7.40 A Pytest plugin to ignore tests during collection without reporting them in the test summary. @@ -4680,63 +4691,63 @@ This list contains 1574 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: Dec 02, 2024, + *last release*: Jan 21, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: Dec 02, 2024, + *last release*: Jan 21, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: Dec 02, 2024, + *last release*: Jan 21, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: Dec 02, 2024, + *last release*: Jan 21, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. :pypi:`pytest-embedded-nuttx` - *last release*: Dec 02, 2024, + *last release*: Jan 21, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with NuttX. :pypi:`pytest-embedded-qemu` - *last release*: Dec 02, 2024, + *last release*: Jan 21, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: Dec 02, 2024, + *last release*: Jan 21, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: Dec 02, 2024, + *last release*: Jan 21, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: Dec 02, 2024, + *last release*: Jan 21, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -4911,7 +4922,7 @@ This list contains 1574 plugins. Pytest Plugin for BDD :pypi:`pytest-evals` - *last release*: Jan 16, 2025, + *last release*: Jan 21, 2025, *status*: N/A, *requires*: pytest>=7.0.0 @@ -5022,6 +5033,13 @@ This list contains 1574 plugins. A pytest plugin that overrides the built-in exit codes to retain more information about the test results. + :pypi:`pytest-exit-status` + *last release*: Jan 25, 2025, + *status*: N/A, + *requires*: pytest>=8.0.0 + + Enhance. + :pypi:`pytest-expect` *last release*: Apr 21, 2016, *status*: 4 - Beta, @@ -5135,7 +5153,7 @@ This list contains 1574 plugins. Additional pytest markers to dynamically enable/disable tests viia CLI flags :pypi:`pytest-f3ts` - *last release*: Dec 11, 2024, + *last release*: Jan 22, 2025, *status*: N/A, *requires*: pytest<8.0.0,>=7.2.1 @@ -5632,7 +5650,7 @@ This list contains 1574 plugins. pytest plugin for running parallel tests :pypi:`pytest-freezeblaster` - *last release*: Jul 10, 2024, + *last release*: Jan 23, 2025, *status*: N/A, *requires*: pytest>=6.2.5 @@ -5744,9 +5762,9 @@ This list contains 1574 plugins. Uses gcov to measure test coverage of a C library :pypi:`pytest-gcs` - *last release*: Mar 01, 2024, + *last release*: Jan 24, 2025, *status*: 5 - Production/Stable, - *requires*: pytest >=6.2 + *requires*: pytest>=6.2 GCS fixtures and fixture factories for Pytest. @@ -5786,7 +5804,7 @@ This list contains 1574 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Jan 08, 2025, + *last release*: Jan 22, 2025, *status*: N/A, *requires*: pytest>=3.6 @@ -6094,7 +6112,7 @@ This list contains 1574 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Jan 10, 2025, + *last release*: Jan 25, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.4 @@ -6255,7 +6273,7 @@ This list contains 1574 plugins. A thin wrapper of HTTPretty for pytest :pypi:`pytest_httpserver` - *last release*: Aug 11, 2024, + *last release*: Jan 21, 2025, *status*: 3 - Alpha, *requires*: N/A @@ -6997,7 +7015,7 @@ This list contains 1574 plugins. It helps to use fixtures in pytest.mark.parametrize :pypi:`pytest-lazy-fixtures` - *last release*: Jul 22, 2024, + *last release*: Jan 25, 2025, *status*: N/A, *requires*: pytest>=7 @@ -7221,7 +7239,7 @@ This list contains 1574 plugins. :pypi:`pytest-logging-strict` - *last release*: Jan 03, 2025, + *last release*: Jan 19, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -7480,7 +7498,7 @@ This list contains 1574 plugins. pytest plugin to write integration tests for projects using Mercurial Python internals :pypi:`pytest-mergify` - *last release*: Dec 27, 2024, + *last release*: Jan 23, 2025, *status*: N/A, *requires*: N/A @@ -7718,7 +7736,7 @@ This list contains 1574 plugins. pytest plugin for MongoDB :pypi:`pytest-mongodb-ry` - *last release*: Jan 13, 2025, + *last release*: Jan 21, 2025, *status*: N/A, *requires*: N/A @@ -8116,6 +8134,13 @@ This list contains 1574 plugins. PyTest plugin for the OAR testing framework + :pypi:`pytest-oarepo` + *last release*: Jan 22, 2025, + *status*: N/A, + *requires*: pytest>=7.1.2; extra == "local" + + + :pypi:`pytest-object-getter` *last release*: Jul 31, 2022, *status*: 5 - Production/Stable, @@ -9615,7 +9640,7 @@ This list contains 1574 plugins. A basic HTML report for pytest using Jinja2 template engine. :pypi:`pytest-report-extras` - *last release*: Jan 09, 2025, + *last release*: Jan 25, 2025, *status*: N/A, *requires*: pytest>=8.0.0 @@ -9867,7 +9892,7 @@ This list contains 1574 plugins. A RethinkDB plugin for pytest. :pypi:`pytest-retry` - *last release*: May 14, 2024, + *last release*: Jan 19, 2025, *status*: N/A, *requires*: pytest>=7.0.0 @@ -10140,7 +10165,7 @@ This list contains 1574 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Jan 14, 2025, + *last release*: Jan 25, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10217,7 +10242,7 @@ This list contains 1574 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Jan 14, 2025, + *last release*: Jan 25, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -11182,6 +11207,13 @@ This list contains 1574 plugins. py.test plugin to introduce block structure in teamcity build log, if output is not captured + :pypi:`pytest-teardown` + *last release*: Jan 22, 2025, + *status*: N/A, + *requires*: pytest<9.0.0,>=7.4.1 + + + :pypi:`pytest-telegram` *last release*: Apr 25, 2024, *status*: 5 - Production/Stable, @@ -11484,8 +11516,8 @@ This list contains 1574 plugins. Tesults plugin for pytest :pypi:`pytest-textual-snapshot` - *last release*: Jul 22, 2024, - *status*: 4 - Beta, + *last release*: Jan 23, 2025, + *status*: 5 - Production/Stable, *requires*: pytest>=8.0.0 Snapshot testing for Textual apps @@ -11540,7 +11572,7 @@ This list contains 1574 plugins. Ticking on tests :pypi:`pytest-time` - *last release*: Aug 28, 2024, + *last release*: Jan 20, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -12352,7 +12384,7 @@ This list contains 1574 plugins. A pytest plugin to list worker statistics after a xdist run. :pypi:`pytest-xdocker` - *last release*: Jan 15, 2025, + *last release*: Jan 22, 2025, *status*: N/A, *requires*: pytest<8.0.0,>=7.4.2 From c962c86845aea805f47c33f1c67582640a7d3e6f Mon Sep 17 00:00:00 2001 From: Sadra Barikbin Date: Fri, 31 Jan 2025 16:35:39 +0330 Subject: [PATCH 282/445] Update pythonpath.rst (#13181) Fix two tiny typos in `pythonpath.rst` --- doc/en/explanation/pythonpath.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/en/explanation/pythonpath.rst b/doc/en/explanation/pythonpath.rst index d0314a6dbcd..e68f455cedf 100644 --- a/doc/en/explanation/pythonpath.rst +++ b/doc/en/explanation/pythonpath.rst @@ -8,7 +8,7 @@ pytest import mechanisms and ``sys.path``/``PYTHONPATH`` Import modes ------------ -pytest as a testing framework that needs to import test modules and ``conftest.py`` files for execution. +pytest as a testing framework needs to import test modules and ``conftest.py`` files for execution. Importing files in Python is a non-trivial process, so aspects of the import process can be controlled through the ``--import-mode`` command-line flag, which can assume @@ -78,7 +78,7 @@ these values: For non-test modules, this will work if they are accessible via :py:data:`sys.path`. So for example, ``.env/lib/site-packages/app/core.py`` will be importable as ``app.core``. - This is happens when plugins import non-test modules (for example doctesting). + This happens when plugins import non-test modules (for example doctesting). If this step succeeds, the module is returned. From 5bb569f8432bf99a5b914e4dd297a7ce839eb203 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 2 Feb 2025 19:03:21 -0300 Subject: [PATCH 283/445] [automated] Update plugin list (#13184) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 176 ++++++++++++++++++------------- 1 file changed, 100 insertions(+), 76 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 4b1b7241379..2e8bf36500d 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =8.3 - :pypi:`logassert` Simple but powerful assertion and verification of logged lines. Dec 09, 2024 5 - Production/Stable N/A + :pypi:`logassert` Simple but powerful assertion and verification of logged lines Jan 29, 2025 5 - Production/Stable pytest; extra == "dev" :pypi:`logot` Test whether your code is logging correctly 🪵 Mar 23, 2024 5 - Production/Stable pytest<9,>=7; extra == "pytest" :pypi:`nuts` Network Unit Testing System Jul 19, 2024 N/A pytest<8,>=7 :pypi:`pytest-abq` Pytest integration for the ABQ universal test runner. Apr 07, 2023 N/A N/A @@ -64,6 +64,7 @@ This list contains 1578 plugins. :pypi:`pytest-airflow` pytest support for airflow. Apr 03, 2019 3 - Alpha pytest (>=4.4.0) :pypi:`pytest-airflow-utils` Nov 15, 2021 N/A N/A :pypi:`pytest-alembic` A pytest plugin for verifying alembic migrations. Jul 29, 2024 N/A pytest>=6.0 + :pypi:`pytest-alerts` A pytest plugin for sending test results to Slack and Telegram Feb 01, 2025 4 - Beta pytest>=7.4.0 :pypi:`pytest-allclose` Pytest fixture extending Numpy's allclose function Jul 30, 2019 5 - Production/Stable pytest :pypi:`pytest-allure-adaptor` Plugin for py.test to generate allure xml reports Jan 10, 2018 N/A pytest (>=2.7.3) :pypi:`pytest-allure-adaptor2` Plugin for py.test to generate allure xml reports Oct 14, 2020 N/A pytest (>=2.7.3) @@ -116,7 +117,7 @@ This list contains 1578 plugins. :pypi:`pytest-ast-transformer` May 04, 2019 3 - Alpha pytest :pypi:`pytest_async` pytest-async - Run your coroutine in event loop without decorator Feb 26, 2020 N/A N/A :pypi:`pytest-async-generators` Pytest fixtures for async generators Jul 05, 2023 N/A N/A - :pypi:`pytest-asyncio` Pytest support for asyncio Jan 08, 2025 4 - Beta pytest<9,>=8.2 + :pypi:`pytest-asyncio` Pytest support for asyncio Jan 28, 2025 4 - Beta pytest<9,>=8.2 :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Jan 17, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Jul 04, 2024 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) @@ -160,7 +161,7 @@ This list contains 1578 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Jan 22, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Jan 30, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -219,7 +220,7 @@ This list contains 1578 plugins. :pypi:`pytest-cassandra` Cassandra CCM Test Fixtures for pytest Nov 04, 2017 1 - Planning N/A :pypi:`pytest-catchlog` py.test plugin to catch log messages. This is a fork of pytest-capturelog. Jan 24, 2016 4 - Beta pytest (>=2.6) :pypi:`pytest-catch-server` Pytest plugin with server for catching HTTP requests. Dec 12, 2019 5 - Production/Stable N/A - :pypi:`pytest-cdist` A pytest plugin to split your test suite into multiple parts Jan 07, 2025 N/A pytest>=7 + :pypi:`pytest-cdist` A pytest plugin to split your test suite into multiple parts Jan 30, 2025 N/A pytest>=7 :pypi:`pytest-celery` Pytest plugin for Celery Sep 20, 2024 4 - Beta N/A :pypi:`pytest-cfg-fetcher` Pass config options to your unit tests. Feb 26, 2024 N/A N/A :pypi:`pytest-chainmaker` pytest plugin for chainmaker Oct 15, 2021 N/A N/A @@ -253,14 +254,14 @@ This list contains 1578 plugins. :pypi:`pytest-cleanslate` Collects and executes pytest tests separately Sep 04, 2024 N/A pytest :pypi:`pytest_cleanup` Automated, comprehensive and well-organised pytest test cases. Jan 28, 2020 N/A N/A :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Nov 08, 2024 5 - Production/Stable N/A - :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Nov 29, 2024 N/A pytest<9.0.0,>=8.0.0 + :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Jan 30, 2025 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-click` Pytest plugin for Click Feb 11, 2022 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-cli-fixtures` Automatically register fixtures for custom CLI arguments Jul 28, 2022 N/A pytest (~=7.0) :pypi:`pytest-clld` Oct 23, 2024 N/A pytest>=3.9 :pypi:`pytest-cloud` Distributed tests planner plugin for pytest testing framework. Oct 05, 2020 6 - Mature N/A :pypi:`pytest-cloudflare-worker` pytest plugin for testing cloudflare workers Mar 30, 2021 4 - Beta pytest (>=6.0.0) :pypi:`pytest-cloudist` Distribute tests to cloud machines without fuss Sep 02, 2022 4 - Beta pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-cmake` Provide CMake module for Pytest Jan 19, 2025 N/A pytest<9,>=4 + :pypi:`pytest-cmake` Provide CMake module for Pytest Jan 29, 2025 N/A pytest<9,>=4 :pypi:`pytest-cmake-presets` Execute CMake Presets via pytest Dec 26, 2022 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-cmdline-add-args` Pytest plugin for custom argument handling and Allure reporting. This plugin allows you to add arguments before running a test. Sep 01, 2024 N/A N/A :pypi:`pytest-cobra` PyTest plugin for testing Smart Contracts for Ethereum blockchain. Jun 29, 2019 3 - Alpha pytest (<4.0.0,>=3.7.1) @@ -271,7 +272,7 @@ This list contains 1578 plugins. :pypi:`pytest-codegen` Automatically create pytest test signatures Aug 23, 2020 2 - Pre-Alpha N/A :pypi:`pytest-codeowners` Pytest plugin for selecting tests by GitHub CODEOWNERS. Mar 30, 2022 4 - Beta pytest (>=6.0.0) :pypi:`pytest-codestyle` pytest plugin to run pycodestyle Mar 23, 2020 3 - Alpha N/A - :pypi:`pytest-codspeed` Pytest plugin to create CodSpeed benchmarks Jan 09, 2025 5 - Production/Stable pytest>=3.8 + :pypi:`pytest-codspeed` Pytest plugin to create CodSpeed benchmarks Jan 31, 2025 5 - Production/Stable pytest>=3.8 :pypi:`pytest-collect-appoint-info` set your encoding Aug 03, 2023 N/A pytest :pypi:`pytest-collect-formatter` Formatter for pytest collect output Mar 29, 2021 5 - Production/Stable N/A :pypi:`pytest-collect-formatter2` Formatter for pytest collect output May 31, 2021 5 - Production/Stable N/A @@ -292,7 +293,7 @@ This list contains 1578 plugins. :pypi:`pytest-contexts` A plugin to run tests written with the Contexts framework using pytest May 19, 2021 4 - Beta N/A :pypi:`pytest-continuous` A pytest plugin to run tests continuously until failure or interruption. Apr 23, 2024 N/A N/A :pypi:`pytest-cookies` The pytest plugin for your Cookiecutter templates. 🍪 Mar 22, 2023 5 - Production/Stable pytest (>=3.9.0) - :pypi:`pytest-copie` The pytest plugin for your copier templates 📒 Jun 26, 2024 3 - Alpha pytest + :pypi:`pytest-copie` The pytest plugin for your copier templates 📒 Jan 31, 2025 3 - Alpha pytest :pypi:`pytest-copier` A pytest plugin to help testing Copier templates Dec 11, 2023 4 - Beta pytest>=7.3.2 :pypi:`pytest-couchdbkit` py.test extension for per-test couchdb databases using couchdbkit Apr 17, 2012 N/A N/A :pypi:`pytest-count` count erros and send email Jan 12, 2018 4 - Beta N/A @@ -464,7 +465,7 @@ This list contains 1578 plugins. :pypi:`pytest-easy-server` Pytest plugin for easy testing against servers May 01, 2021 4 - Beta pytest (<5.0.0,>=4.3.1) ; python_version < "3.5" :pypi:`pytest-ebics-sandbox` A pytest plugin for testing against an EBICS sandbox server. Requires docker. Aug 15, 2022 N/A N/A :pypi:`pytest-ec2` Pytest execution on EC2 instance Oct 22, 2019 3 - Alpha N/A - :pypi:`pytest-echo` pytest plugin with mechanisms for echoing environment variables, package version and generic attributes Dec 05, 2023 5 - Production/Stable pytest >=2.2 + :pypi:`pytest-echo` pytest plugin with mechanisms for echoing environment variables, package version and generic attributes Feb 01, 2025 5 - Production/Stable pytest>=6.0 :pypi:`pytest-edit` Edit the source code of a failed test with \`pytest --edit\`. Nov 17, 2024 N/A pytest :pypi:`pytest-ekstazi` Pytest plugin to select test using Ekstazi algorithm Sep 10, 2022 N/A pytest :pypi:`pytest-elasticsearch` Elasticsearch fixtures and fixture factories for Pytest. Dec 03, 2024 5 - Production/Stable pytest>=7.0 @@ -473,15 +474,15 @@ This list contains 1578 plugins. :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Jan 21, 2025 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Jan 21, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Jan 21, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Jan 21, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Jan 21, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Jan 21, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Jan 21, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Jan 21, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Jan 21, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Jan 29, 2025 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Jan 29, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Jan 29, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Jan 29, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Jan 29, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Jan 29, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Jan 29, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Jan 29, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Jan 29, 2025 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -506,7 +507,7 @@ This list contains 1578 plugins. :pypi:`pytest-eth` PyTest plugin for testing Smart Contracts for Ethereum Virtual Machine (EVM). Aug 14, 2020 1 - Planning N/A :pypi:`pytest-ethereum` pytest-ethereum: Pytest library for ethereum projects. Jun 24, 2019 3 - Alpha pytest (==3.3.2); extra == 'dev' :pypi:`pytest-eucalyptus` Pytest Plugin for BDD Jun 28, 2022 N/A pytest (>=4.2.0) - :pypi:`pytest-evals` A pytest plugin for running and analyzing LLM evaluation tests Jan 21, 2025 N/A pytest>=7.0.0 + :pypi:`pytest-evals` A pytest plugin for running and analyzing LLM evaluation tests Jan 29, 2025 N/A pytest>=7.0.0 :pypi:`pytest-eventlet` Applies eventlet monkey-patch as a pytest plugin. Oct 04, 2021 N/A pytest ; extra == 'dev' :pypi:`pytest_evm` The testing package containing tools to test Web3-based projects Sep 23, 2024 4 - Beta pytest<9.0.0,>=8.1.1 :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A @@ -617,7 +618,7 @@ This list contains 1578 plugins. :pypi:`pytest-frozen-uuids` Deterministically frozen UUID's for your tests Apr 17, 2022 N/A pytest (>=3.0) :pypi:`pytest-func-cov` Pytest plugin for measuring function coverage Apr 15, 2021 3 - Alpha pytest (>=5) :pypi:`pytest-funparam` An alternative way to parametrize test cases. Dec 02, 2021 4 - Beta pytest >=4.6.0 - :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Dec 12, 2024 N/A pytest + :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Jan 31, 2025 N/A pytest :pypi:`pytest-fxa` pytest plugin for Firefox Accounts Aug 28, 2018 5 - Production/Stable N/A :pypi:`pytest-fxa-mte` pytest plugin for Firefox Accounts Oct 02, 2024 5 - Production/Stable N/A :pypi:`pytest-fxtest` Oct 27, 2020 N/A N/A @@ -627,7 +628,7 @@ This list contains 1578 plugins. :pypi:`pytest-gc` The garbage collector plugin for py.test Feb 01, 2018 N/A N/A :pypi:`pytest-gcov` Uses gcov to measure test coverage of a C library Feb 01, 2018 3 - Alpha N/A :pypi:`pytest-gcs` GCS fixtures and fixture factories for Pytest. Jan 24, 2025 5 - Production/Stable pytest>=6.2 - :pypi:`pytest-gee` The Python plugin for your GEE based packages. Jan 13, 2025 3 - Alpha pytest + :pypi:`pytest-gee` The Python plugin for your GEE based packages. Jan 30, 2025 3 - Alpha pytest :pypi:`pytest-gevent` Ensure that gevent is properly patched when invoking pytest Feb 25, 2020 N/A pytest :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest @@ -676,7 +677,7 @@ This list contains 1578 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Jan 25, 2025 3 - Alpha pytest==8.3.4 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Feb 01, 2025 3 - Alpha pytest==8.3.4 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -750,7 +751,7 @@ This list contains 1578 plugins. :pypi:`pytest-iovis` A Pytest plugin to enable Jupyter Notebook testing with Papermill Nov 06, 2024 4 - Beta pytest>=7.1.0 :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A - :pypi:`pytest-ipywidgets` Dec 19, 2024 N/A pytest + :pypi:`pytest-ipywidgets` Jan 29, 2025 N/A pytest :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Jan 16, 2025 4 - Beta pytest :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Dec 05, 2024 4 - Beta pytest>=5 :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) @@ -838,7 +839,7 @@ This list contains 1578 plugins. :pypi:`pytest-logging` Configures logging and allows tweaking the log level with a py.test flag Nov 04, 2015 4 - Beta N/A :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) :pypi:`pytest-logging-strict` pytest fixture logging configured from packaged YAML Jan 19, 2025 3 - Alpha pytest - :pypi:`pytest-logikal` Common testing environment Jan 18, 2025 5 - Production/Stable pytest==8.3.4 + :pypi:`pytest-logikal` Common testing environment Jan 31, 2025 5 - Production/Stable pytest==8.3.4 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Sep 30, 2024 4 - Beta pytest>=8.2.2 :pypi:`pytest-loguru` Pytest Loguru Mar 20, 2024 5 - Production/Stable pytest; extra == "test" @@ -855,7 +856,7 @@ This list contains 1578 plugins. :pypi:`pytest-mark-manage` 用例标签化管理 Aug 15, 2024 N/A pytest :pypi:`pytest-mark-no-py3` pytest plugin and bowler codemod to help migrate tests to Python 3 May 17, 2019 N/A pytest :pypi:`pytest-marks` UNKNOWN Nov 23, 2012 3 - Alpha N/A - :pypi:`pytest-mask-secrets` Pytest plugin to hide sensitive data in test reports Sep 27, 2024 N/A N/A + :pypi:`pytest-mask-secrets` Pytest plugin to hide sensitive data in test reports Jan 28, 2025 N/A N/A :pypi:`pytest-matcher` Easy way to match captured \`pytest\` output against expectations stored in files Aug 01, 2024 5 - Production/Stable pytest :pypi:`pytest-matchers` Matchers for pytest Aug 26, 2024 N/A pytest<9.0,>=7.0 :pypi:`pytest-match-skip` Skip matching marks. Matches partial marks using wildcards. May 15, 2019 4 - Beta pytest (>=4.4.1) @@ -927,6 +928,7 @@ This list contains 1578 plugins. :pypi:`pytest-multithreading-allure` pytest_multithreading_allure Nov 25, 2022 N/A N/A :pypi:`pytest-mutagen` Add the mutation testing feature to pytest Jul 24, 2020 N/A pytest (>=5.4) :pypi:`pytest-my-cool-lib` Nov 02, 2023 N/A pytest (>=7.1.3,<8.0.0) + :pypi:`pytest-my-plugin` A pytest plugin that does awesome things Jan 27, 2025 N/A pytest>=6.0 :pypi:`pytest-mypy` Mypy static type checker plugin for Pytest Dec 18, 2022 4 - Beta pytest (>=6.2) ; python_version >= "3.10" :pypi:`pytest-mypyd` Mypy static type checker plugin for Pytest Aug 20, 2019 4 - Beta pytest (<4.7,>=2.8) ; python_version < "3.5" :pypi:`pytest-mypy-plugins` pytest plugin for writing tests for mypy plugins Dec 21, 2024 4 - Beta pytest>=7.0.0 @@ -965,7 +967,7 @@ This list contains 1578 plugins. :pypi:`pytest-notion` A PyTest Reporter to send test runs to Notion.so Aug 07, 2019 N/A N/A :pypi:`pytest-nunit` A pytest plugin for generating NUnit3 test result XML output Feb 26, 2024 5 - Production/Stable N/A :pypi:`pytest-oar` PyTest plugin for the OAR testing framework May 02, 2023 N/A pytest>=6.0.1 - :pypi:`pytest-oarepo` Jan 22, 2025 N/A pytest>=7.1.2; extra == "local" + :pypi:`pytest-oarepo` Jan 28, 2025 N/A pytest>=7.1.2; extra == "local" :pypi:`pytest-object-getter` Import any object from a 3rd party module while mocking its namespace on demand. Jul 31, 2022 5 - Production/Stable pytest :pypi:`pytest-ochrus` pytest results data-base and HTML reporter Feb 21, 2018 4 - Beta N/A :pypi:`pytest-odc` A pytest plugin for simplifying ODC database tests Aug 04, 2023 4 - Beta pytest (>=3.5.0) @@ -1025,7 +1027,7 @@ This list contains 1578 plugins. :pypi:`pytest-percents` Mar 16, 2024 N/A N/A :pypi:`pytest-perf` Run performance tests against the mainline code. May 20, 2024 5 - Production/Stable pytest!=8.1.*,>=6; extra == "testing" :pypi:`pytest-performance` A simple plugin to ensure the execution of critical sections of code has not been impacted Sep 11, 2020 5 - Production/Stable pytest (>=3.7.0) - :pypi:`pytest-performancetotal` A performance plugin for pytest Jan 07, 2025 5 - Production/Stable N/A + :pypi:`pytest-performancetotal` A performance plugin for pytest Feb 01, 2025 5 - Production/Stable N/A :pypi:`pytest-persistence` Pytest tool for persistent objects Aug 21, 2024 N/A N/A :pypi:`pytest-pexpect` Pytest pexpect plugin. Aug 13, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-pg` A tiny plugin for pytest which runs PostgreSQL in Docker May 21, 2024 5 - Production/Stable pytest>=6.0.0 @@ -1045,9 +1047,9 @@ This list contains 1578 plugins. :pypi:`pytest-platform-markers` Markers for pytest to skip tests on specific platforms Sep 09, 2019 4 - Beta pytest (>=3.6.0) :pypi:`pytest-play` pytest plugin that let you automate actions and assertions with test metrics reporting executing plain YAML files Jun 12, 2019 5 - Production/Stable N/A :pypi:`pytest-playbook` Pytest plugin for reading playbooks. Jan 21, 2021 3 - Alpha pytest (>=6.1.2,<7.0.0) - :pypi:`pytest-playwright` A pytest wrapper with fixtures for Playwright to automate web browsers Nov 26, 2024 N/A pytest<9.0.0,>=6.2.4 + :pypi:`pytest-playwright` A pytest wrapper with fixtures for Playwright to automate web browsers Jan 31, 2025 N/A pytest<9.0.0,>=6.2.4 :pypi:`pytest_playwright_async` ASYNC Pytest plugin for Playwright Sep 28, 2024 N/A N/A - :pypi:`pytest-playwright-asyncio` A pytest wrapper with fixtures for Playwright to automate web browsers Nov 26, 2024 N/A pytest<9.0.0,>=6.2.4 + :pypi:`pytest-playwright-asyncio` A pytest wrapper with async fixtures for Playwright to automate web browsers Jan 31, 2025 N/A pytest<9.0.0,>=6.2.4 :pypi:`pytest-playwright-enhanced` A pytest plugin for playwright python Mar 24, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-playwrights` A pytest wrapper with fixtures for Playwright to automate web browsers Dec 02, 2021 N/A N/A :pypi:`pytest-playwright-snapshot` A pytest wrapper for snapshot testing with playwright Aug 19, 2021 N/A N/A @@ -1055,7 +1057,7 @@ This list contains 1578 plugins. :pypi:`pytest-plone` Pytest plugin to test Plone addons May 15, 2024 3 - Alpha pytest<8.0.0 :pypi:`pytest-plt` Fixtures for quickly making Matplotlib plots in tests Jan 17, 2024 5 - Production/Stable pytest :pypi:`pytest-plugin-helpers` A plugin to help developing and testing other plugins Nov 23, 2019 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-plus` PyTest Plus Plugin :: extends pytest functionality Mar 26, 2024 5 - Production/Stable pytest>=7.4.2 + :pypi:`pytest-plus` PyTest Plus Plugin :: extends pytest functionality Jan 31, 2025 5 - Production/Stable pytest>=7.4.2 :pypi:`pytest-pmisc` Mar 21, 2019 5 - Production/Stable N/A :pypi:`pytest-pogo` Pytest plugin for pogo-migrate Sep 09, 2024 4 - Beta pytest<9,>=7 :pypi:`pytest-pointers` Pytest plugin to define functions you test with special marks for better navigation and reports Dec 26, 2022 N/A N/A @@ -1180,7 +1182,7 @@ This list contains 1578 plugins. :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Oct 11, 2024 4 - Beta N/A :pypi:`pytest-reporter-html-dots` A basic HTML report for pytest using Jinja2 template engine. Jan 22, 2023 N/A N/A - :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots, webpage sources and attachments. Jan 25, 2025 N/A pytest>=8.0.0 + :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots, webpage sources and attachments. Feb 01, 2025 N/A pytest>=8.0.0 :pypi:`pytest-reportinfra` Pytest plugin for reportinfra Aug 11, 2019 3 - Alpha N/A :pypi:`pytest-reporting` A plugin to report summarized results in a table format Oct 25, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-reportlog` Replacement for the --resultlog option, focused in simplicity and extensibility May 22, 2023 3 - Alpha pytest @@ -1255,18 +1257,19 @@ This list contains 1578 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Jan 25, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Feb 01, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A :pypi:`pytest-schema` 👍 Validate return values against a schema-like object in testing Feb 16, 2024 5 - Production/Stable pytest >=3.5.0 + :pypi:`pytest-scim2-server` SCIM2 server fixture for Pytest Jan 27, 2025 N/A pytest>=8.3.4 :pypi:`pytest-screenshot-on-failure` Saves a screenshot when a test case from a pytest execution fails Jul 21, 2023 4 - Beta N/A :pypi:`pytest-scrutinize` Scrutinize your pytest test suites for slow fixtures, tests and more. Aug 19, 2024 4 - Beta pytest>=6 :pypi:`pytest-securestore` An encrypted password store for use within pytest cases Nov 08, 2021 4 - Beta N/A :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Jan 25, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Feb 01, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1312,7 +1315,7 @@ This list contains 1578 plugins. :pypi:`pytest-smartcollect` A plugin for collecting tests that touch changed code Oct 04, 2018 N/A pytest (>=3.5.0) :pypi:`pytest-smartcov` Smart coverage plugin for pytest. Sep 30, 2017 3 - Alpha N/A :pypi:`pytest-smell` Automated bad smell detection tool for Pytest Jun 26, 2022 N/A N/A - :pypi:`pytest-smoke` Pytest plugin for smoke testing Jan 10, 2025 4 - Beta pytest<9,>=7.0.0 + :pypi:`pytest-smoke` Pytest plugin for smoke testing Jan 30, 2025 4 - Beta pytest<9,>=7.0.0 :pypi:`pytest-smtp` Send email with pytest execution result Feb 20, 2021 N/A pytest :pypi:`pytest-smtp4dev` Plugin for smtp4dev API Jun 27, 2023 5 - Production/Stable N/A :pypi:`pytest-smtpd` An SMTP server for testing built on aiosmtpd May 15, 2023 N/A pytest @@ -1396,7 +1399,7 @@ This list contains 1578 plugins. :pypi:`pytest-takeltest` Fixtures for ansible, testinfra and molecule Sep 07, 2024 N/A N/A :pypi:`pytest-talisker` Nov 28, 2021 N/A N/A :pypi:`pytest-tally` A Pytest plugin to generate realtime summary stats, and display them in-console using a text-based dashboard. May 22, 2023 4 - Beta pytest (>=6.2.5) - :pypi:`pytest-tap` Test Anything Protocol (TAP) reporting plugin for pytest Jul 15, 2023 5 - Production/Stable pytest (>=3.0) + :pypi:`pytest-tap` Test Anything Protocol (TAP) reporting plugin for pytest Jan 30, 2025 5 - Production/Stable pytest>=3.0 :pypi:`pytest-tape` easy assertion with expected results saved to yaml files Mar 17, 2021 4 - Beta N/A :pypi:`pytest-target` Pytest plugin for remote target orchestration. Jan 21, 2021 3 - Alpha pytest (>=6.1.2,<7.0.0) :pypi:`pytest-taskgraph` Add your description here Dec 12, 2024 N/A pytest @@ -1625,11 +1628,11 @@ This list contains 1578 plugins. Python Testing for Databricks :pypi:`logassert` - *last release*: Dec 09, 2024, + *last release*: Jan 29, 2025, *status*: 5 - Production/Stable, - *requires*: N/A + *requires*: pytest; extra == "dev" - Simple but powerful assertion and verification of logged lines. + Simple but powerful assertion and verification of logged lines :pypi:`logot` *last release*: Mar 23, 2024, @@ -1827,6 +1830,13 @@ This list contains 1578 plugins. A pytest plugin for verifying alembic migrations. + :pypi:`pytest-alerts` + *last release*: Feb 01, 2025, + *status*: 4 - Beta, + *requires*: pytest>=7.4.0 + + A pytest plugin for sending test results to Slack and Telegram + :pypi:`pytest-allclose` *last release*: Jul 30, 2019, *status*: 5 - Production/Stable, @@ -2192,7 +2202,7 @@ This list contains 1578 plugins. Pytest fixtures for async generators :pypi:`pytest-asyncio` - *last release*: Jan 08, 2025, + *last release*: Jan 28, 2025, *status*: 4 - Beta, *requires*: pytest<9,>=8.2 @@ -2500,7 +2510,7 @@ This list contains 1578 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Jan 22, 2025, + *last release*: Jan 30, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -2913,7 +2923,7 @@ This list contains 1578 plugins. Pytest plugin with server for catching HTTP requests. :pypi:`pytest-cdist` - *last release*: Jan 07, 2025, + *last release*: Jan 30, 2025, *status*: N/A, *requires*: pytest>=7 @@ -3151,7 +3161,7 @@ This list contains 1578 plugins. A cleanup plugin for pytest :pypi:`pytest-clerk` - *last release*: Nov 29, 2024, + *last release*: Jan 30, 2025, *status*: N/A, *requires*: pytest<9.0.0,>=8.0.0 @@ -3200,7 +3210,7 @@ This list contains 1578 plugins. Distribute tests to cloud machines without fuss :pypi:`pytest-cmake` - *last release*: Jan 19, 2025, + *last release*: Jan 29, 2025, *status*: N/A, *requires*: pytest<9,>=4 @@ -3277,7 +3287,7 @@ This list contains 1578 plugins. pytest plugin to run pycodestyle :pypi:`pytest-codspeed` - *last release*: Jan 09, 2025, + *last release*: Jan 31, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=3.8 @@ -3424,7 +3434,7 @@ This list contains 1578 plugins. The pytest plugin for your Cookiecutter templates. 🍪 :pypi:`pytest-copie` - *last release*: Jun 26, 2024, + *last release*: Jan 31, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -4628,9 +4638,9 @@ This list contains 1578 plugins. Pytest execution on EC2 instance :pypi:`pytest-echo` - *last release*: Dec 05, 2023, + *last release*: Feb 01, 2025, *status*: 5 - Production/Stable, - *requires*: pytest >=2.2 + *requires*: pytest>=6.0 pytest plugin with mechanisms for echoing environment variables, package version and generic attributes @@ -4691,63 +4701,63 @@ This list contains 1578 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: Jan 21, 2025, + *last release*: Jan 29, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: Jan 21, 2025, + *last release*: Jan 29, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: Jan 21, 2025, + *last release*: Jan 29, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: Jan 21, 2025, + *last release*: Jan 29, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. :pypi:`pytest-embedded-nuttx` - *last release*: Jan 21, 2025, + *last release*: Jan 29, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with NuttX. :pypi:`pytest-embedded-qemu` - *last release*: Jan 21, 2025, + *last release*: Jan 29, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: Jan 21, 2025, + *last release*: Jan 29, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: Jan 21, 2025, + *last release*: Jan 29, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: Jan 21, 2025, + *last release*: Jan 29, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -4922,7 +4932,7 @@ This list contains 1578 plugins. Pytest Plugin for BDD :pypi:`pytest-evals` - *last release*: Jan 21, 2025, + *last release*: Jan 29, 2025, *status*: N/A, *requires*: pytest>=7.0.0 @@ -5699,7 +5709,7 @@ This list contains 1578 plugins. An alternative way to parametrize test cases. :pypi:`pytest-fv` - *last release*: Dec 12, 2024, + *last release*: Jan 31, 2025, *status*: N/A, *requires*: pytest @@ -5769,7 +5779,7 @@ This list contains 1578 plugins. GCS fixtures and fixture factories for Pytest. :pypi:`pytest-gee` - *last release*: Jan 13, 2025, + *last release*: Jan 30, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -6112,7 +6122,7 @@ This list contains 1578 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Jan 25, 2025, + *last release*: Feb 01, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.4 @@ -6630,7 +6640,7 @@ This list contains 1578 plugins. THIS PROJECT IS ABANDONED :pypi:`pytest-ipywidgets` - *last release*: Dec 19, 2024, + *last release*: Jan 29, 2025, *status*: N/A, *requires*: pytest @@ -7246,7 +7256,7 @@ This list contains 1578 plugins. pytest fixture logging configured from packaged YAML :pypi:`pytest-logikal` - *last release*: Jan 18, 2025, + *last release*: Jan 31, 2025, *status*: 5 - Production/Stable, *requires*: pytest==8.3.4 @@ -7365,7 +7375,7 @@ This list contains 1578 plugins. UNKNOWN :pypi:`pytest-mask-secrets` - *last release*: Sep 27, 2024, + *last release*: Jan 28, 2025, *status*: N/A, *requires*: N/A @@ -7868,6 +7878,13 @@ This list contains 1578 plugins. + :pypi:`pytest-my-plugin` + *last release*: Jan 27, 2025, + *status*: N/A, + *requires*: pytest>=6.0 + + A pytest plugin that does awesome things + :pypi:`pytest-mypy` *last release*: Dec 18, 2022, *status*: 4 - Beta, @@ -8135,7 +8152,7 @@ This list contains 1578 plugins. PyTest plugin for the OAR testing framework :pypi:`pytest-oarepo` - *last release*: Jan 22, 2025, + *last release*: Jan 28, 2025, *status*: N/A, *requires*: pytest>=7.1.2; extra == "local" @@ -8555,7 +8572,7 @@ This list contains 1578 plugins. A simple plugin to ensure the execution of critical sections of code has not been impacted :pypi:`pytest-performancetotal` - *last release*: Jan 07, 2025, + *last release*: Feb 01, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -8695,7 +8712,7 @@ This list contains 1578 plugins. Pytest plugin for reading playbooks. :pypi:`pytest-playwright` - *last release*: Nov 26, 2024, + *last release*: Jan 31, 2025, *status*: N/A, *requires*: pytest<9.0.0,>=6.2.4 @@ -8709,11 +8726,11 @@ This list contains 1578 plugins. ASYNC Pytest plugin for Playwright :pypi:`pytest-playwright-asyncio` - *last release*: Nov 26, 2024, + *last release*: Jan 31, 2025, *status*: N/A, *requires*: pytest<9.0.0,>=6.2.4 - A pytest wrapper with fixtures for Playwright to automate web browsers + A pytest wrapper with async fixtures for Playwright to automate web browsers :pypi:`pytest-playwright-enhanced` *last release*: Mar 24, 2024, @@ -8765,7 +8782,7 @@ This list contains 1578 plugins. A plugin to help developing and testing other plugins :pypi:`pytest-plus` - *last release*: Mar 26, 2024, + *last release*: Jan 31, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.4.2 @@ -9640,7 +9657,7 @@ This list contains 1578 plugins. A basic HTML report for pytest using Jinja2 template engine. :pypi:`pytest-report-extras` - *last release*: Jan 25, 2025, + *last release*: Feb 01, 2025, *status*: N/A, *requires*: pytest>=8.0.0 @@ -10165,7 +10182,7 @@ This list contains 1578 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Jan 25, 2025, + *last release*: Feb 01, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10199,6 +10216,13 @@ This list contains 1578 plugins. 👍 Validate return values against a schema-like object in testing + :pypi:`pytest-scim2-server` + *last release*: Jan 27, 2025, + *status*: N/A, + *requires*: pytest>=8.3.4 + + SCIM2 server fixture for Pytest + :pypi:`pytest-screenshot-on-failure` *last release*: Jul 21, 2023, *status*: 4 - Beta, @@ -10242,7 +10266,7 @@ This list contains 1578 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Jan 25, 2025, + *last release*: Feb 01, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10564,7 +10588,7 @@ This list contains 1578 plugins. Automated bad smell detection tool for Pytest :pypi:`pytest-smoke` - *last release*: Jan 10, 2025, + *last release*: Jan 30, 2025, *status*: 4 - Beta, *requires*: pytest<9,>=7.0.0 @@ -11152,9 +11176,9 @@ This list contains 1578 plugins. A Pytest plugin to generate realtime summary stats, and display them in-console using a text-based dashboard. :pypi:`pytest-tap` - *last release*: Jul 15, 2023, + *last release*: Jan 30, 2025, *status*: 5 - Production/Stable, - *requires*: pytest (>=3.0) + *requires*: pytest>=3.0 Test Anything Protocol (TAP) reporting plugin for pytest From 31fd03a67ef759b4cc1ee7119cd199902d270fe3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Feb 2025 06:08:27 +0100 Subject: [PATCH 284/445] build(deps): Bump pytest-asyncio in /testing/plugins_integration (#13185) Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.25.2 to 0.25.3. - [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases) - [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.25.2...v0.25.3) --- updated-dependencies: - dependency-name: pytest-asyncio dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 4c3c66636ba..3d89d055f2b 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,6 +1,6 @@ anyio[trio]==4.8.0 django==5.1.5 -pytest-asyncio==0.25.2 +pytest-asyncio==0.25.3 pytest-bdd==8.1.0 pytest-cov==6.0.0 pytest-django==4.9.0 From b4009b31978053fe077a32d219ad947a5ba7243c Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 3 Feb 2025 14:46:28 +0100 Subject: [PATCH 285/445] Add readline workaround for libedit (#13176) * Add readline workaround for libedit We had a very similar workaround before for pyreadline, which had a similar issue: - Introduced in #1281 - Removed in #8848 for #8733 and #8847 This technically will regress the issues above, but those issues just mean that `import readline` is broken in general, so the user should fix it instead (by e.g. uninstalling pyreadline). Fixes #12888 Fixes #13170 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Handle no readline on Windows --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- changelog/12888.bugfix.rst | 1 + src/_pytest/capture.py | 18 ++++++++++++++++++ testing/test_capture.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 changelog/12888.bugfix.rst diff --git a/changelog/12888.bugfix.rst b/changelog/12888.bugfix.rst new file mode 100644 index 00000000000..635e35a11ea --- /dev/null +++ b/changelog/12888.bugfix.rst @@ -0,0 +1 @@ +Fixed broken input when using Python 3.13+ and a ``libedit`` build of Python, such as on macOS or with uv-managed Python binaries from the ``python-build-standalone`` project. This could manifest e.g. by a broken prompt when using ``Pdb``, or seeing empty inputs with manual usage of ``input()`` and suspended capturing. diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index 5c21590c937..5b64c34e772 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -80,6 +80,23 @@ def _colorama_workaround() -> None: pass +def _readline_workaround() -> None: + """Ensure readline is imported early so it attaches to the correct stdio handles. + + This isn't a problem with the default GNU readline implementation, but in + some configurations, Python uses libedit instead (on macOS, and for prebuilt + binaries such as used by uv). + + In theory this is only needed if readline.backend == "libedit", but the + workaround consists of importing readline here, so we already worked around + the issue by the time we could check if we need to. + """ + try: + import readline # noqa: F401 + except ImportError: + pass + + def _windowsconsoleio_workaround(stream: TextIO) -> None: """Workaround for Windows Unicode console handling. @@ -141,6 +158,7 @@ def pytest_load_initial_conftests(early_config: Config) -> Generator[None]: if ns.capture == "fd": _windowsconsoleio_workaround(sys.stdout) _colorama_workaround() + _readline_workaround() pluginmanager = early_config.pluginmanager capman = CaptureManager(ns.capture) pluginmanager.register(capman, "capturemanager") diff --git a/testing/test_capture.py b/testing/test_capture.py index 98986af6f1f..a59273734c4 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -6,6 +6,7 @@ import io from io import UnsupportedOperation import os +import re import subprocess import sys import textwrap @@ -1666,3 +1667,32 @@ def test_logging(): ) result.stdout.no_fnmatch_line("*Captured stderr call*") result.stdout.no_fnmatch_line("*during collection*") + + +def test_libedit_workaround(pytester: Pytester) -> None: + pytester.makeconftest(""" + import pytest + + + def pytest_terminal_summary(config): + capture = config.pluginmanager.getplugin("capturemanager") + capture.suspend_global_capture(in_=True) + + print("Enter 'hi'") + value = input() + print(f"value: {value!r}") + + capture.resume_global_capture() + """) + readline = pytest.importorskip("readline") + backend = getattr(readline, "backend", readline.__doc__) # added in Python 3.13 + print(f"Readline backend: {backend}") + + child = pytester.spawn_pytest("") + child.expect(r"Enter 'hi'") + child.sendline("hi") + rest = child.read().decode("utf8") + print(rest) + match = re.search(r"^value: '(.*)'\r?$", rest, re.MULTILINE) + assert match is not None + assert match.group(1) == "hi" From afdf03bc23ac24253f851bd3e1b91e776abc506b Mon Sep 17 00:00:00 2001 From: Virendra Patil <70162563+virendrapatil24@users.noreply.github.com> Date: Mon, 3 Feb 2025 19:19:08 +0530 Subject: [PATCH 286/445] Fixed invalid regex handling in filterwarnings (#13124) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Thomas Grainger --- changelog/13119.bugfix.rst | 1 + src/_pytest/config/__init__.py | 7 +++++++ testing/test_warnings.py | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 changelog/13119.bugfix.rst diff --git a/changelog/13119.bugfix.rst b/changelog/13119.bugfix.rst new file mode 100644 index 00000000000..b7e56af9bb8 --- /dev/null +++ b/changelog/13119.bugfix.rst @@ -0,0 +1 @@ +Improved handling of invalid regex patterns for filter warnings by providing a clear error message. diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 3db5e3da983..9e5b192b335 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1953,6 +1953,13 @@ def parse_warning_filter( ) from None else: lineno = 0 + try: + re.compile(message) + re.compile(module) + except re.error as e: + raise UsageError( + error_template.format(error=f"Invalid regex {e.pattern!r}: {e}") + ) from None return action, message, category, module, lineno diff --git a/testing/test_warnings.py b/testing/test_warnings.py index d4d0e0b7f93..c302e7c6e3c 100644 --- a/testing/test_warnings.py +++ b/testing/test_warnings.py @@ -511,6 +511,29 @@ def test_hidden_by_system(self, pytester: Pytester, monkeypatch) -> None: result = pytester.runpytest_subprocess() assert WARNINGS_SUMMARY_HEADER not in result.stdout.str() + def test_invalid_regex_in_filterwarning(self, pytester: Pytester) -> None: + self.create_file(pytester) + pytester.makeini( + """ + [pytest] + filterwarnings = + ignore::DeprecationWarning:* + """ + ) + result = pytester.runpytest_subprocess() + assert result.ret == pytest.ExitCode.USAGE_ERROR + result.stderr.fnmatch_lines( + [ + "ERROR: while parsing the following warning configuration:", + "", + " ignore::DeprecationWarning:[*]", + "", + "This error occurred:", + "", + "Invalid regex '[*]': nothing to repeat at position 0", + ] + ) + @pytest.mark.skip("not relevant until pytest 9.0") @pytest.mark.parametrize("change_default", [None, "ini", "cmdline"]) From 3930353bb933a579eaa540e7a7267117ba9aa332 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 Feb 2025 09:11:25 +0100 Subject: [PATCH 287/445] [pre-commit.ci] pre-commit autoupdate (#13190) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.3 → v0.9.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.3...v0.9.4) - [github.com/woodruffw/zizmor-pre-commit: v1.2.2 → v1.3.0](https://github.com/woodruffw/zizmor-pre-commit/compare/v1.2.2...v1.3.0) - [github.com/codespell-project/codespell: v2.4.0 → v2.4.1](https://github.com/codespell-project/codespell/compare/v2.4.0...v2.4.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 527586a1f68..62d72d5e9f3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.9.3" + rev: "v0.9.4" hooks: - id: ruff args: ["--fix"] @@ -12,7 +12,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/woodruffw/zizmor-pre-commit - rev: v1.2.2 + rev: v1.3.0 hooks: - id: zizmor - repo: https://github.com/adamchainz/blacken-docs @@ -21,7 +21,7 @@ repos: - id: blacken-docs additional_dependencies: [black==24.1.1] - repo: https://github.com/codespell-project/codespell - rev: v2.4.0 + rev: v2.4.1 hooks: - id: codespell args: ["--toml=pyproject.toml"] From 857daa808132a5fd0ef4ea60397c1b53073c3703 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Tue, 4 Feb 2025 12:16:47 +0100 Subject: [PATCH 288/445] disable gc within the subprocess --- testing/test_unraisableexception.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/testing/test_unraisableexception.py b/testing/test_unraisableexception.py index 3f191073e2b..328177a7ba3 100644 --- a/testing/test_unraisableexception.py +++ b/testing/test_unraisableexception.py @@ -321,6 +321,9 @@ def test_refcycle_unraisable_warning_filter_default(pytester: Pytester) -> None: # see: https://github.com/pytest-dev/pytest/pull/13057#discussion_r1888396126 pytester.makepyfile( test_it=""" + import gc + gc.disable() + import pytest class BrokenDel: @@ -335,8 +338,8 @@ def test_it(): """ ) - with _disable_gc(): - result = pytester.runpytest_subprocess("-Wdefault") + # since we use subprocess we need to disable gc inside test_it + result = pytester.runpytest_subprocess("-Wdefault") assert result.ret == pytest.ExitCode.OK From c93130c1b9048d66551070d28aabe631c0f10b8e Mon Sep 17 00:00:00 2001 From: jakkdl Date: Tue, 4 Feb 2025 13:30:01 +0100 Subject: [PATCH 289/445] add RaisesGroup & Matcher --- changelog/11671.feature.rst | 1 + src/_pytest/_raises_group.py | 1003 ++++++++++++++++++++++++++++ src/pytest/__init__.py | 6 + testing/python/raises_group.py | 1137 ++++++++++++++++++++++++++++++++ testing/typing_raises_group.py | 234 +++++++ 5 files changed, 2381 insertions(+) create mode 100644 changelog/11671.feature.rst create mode 100644 src/_pytest/_raises_group.py create mode 100644 testing/python/raises_group.py create mode 100644 testing/typing_raises_group.py diff --git a/changelog/11671.feature.rst b/changelog/11671.feature.rst new file mode 100644 index 00000000000..9e401112ad0 --- /dev/null +++ b/changelog/11671.feature.rst @@ -0,0 +1 @@ +Added `RaisesGroup` (also available as `raises_group`) and `Matcher`, as an equivalent to `raises` for expecting `ExceptionGroup`. It includes the ability to specity multiple different expected exceptions, the structure of nested exception groups, and/or closely emulating `except_star`. diff --git a/src/_pytest/_raises_group.py b/src/_pytest/_raises_group.py new file mode 100644 index 00000000000..68303c4a3fe --- /dev/null +++ b/src/_pytest/_raises_group.py @@ -0,0 +1,1003 @@ +from __future__ import annotations + +from abc import ABC +from abc import abstractmethod +import re +from re import Pattern +import sys +from textwrap import indent +from typing import cast +from typing import final +from typing import Generic +from typing import Literal +from typing import overload +from typing import TYPE_CHECKING + +from _pytest._code import ExceptionInfo +from _pytest.outcomes import fail + + +if TYPE_CHECKING: + from collections.abc import Callable + from collections.abc import Sequence + + # for some reason Sphinx does not play well with 'from types import TracebackType' + import types + + from typing_extensions import TypeGuard + from typing_extensions import TypeVar + + # this conditional definition is because we want to allow a TypeVar default + MatchE = TypeVar( + "MatchE", + bound=BaseException, + default=BaseException, + covariant=True, + ) +else: + from typing import TypeVar + + MatchE = TypeVar("MatchE", bound=BaseException, covariant=True) + +# RaisesGroup doesn't work with a default. +BaseExcT_co = TypeVar("BaseExcT_co", bound=BaseException, covariant=True) +BaseExcT_1 = TypeVar("BaseExcT_1", bound=BaseException) +BaseExcT_2 = TypeVar("BaseExcT_2", bound=BaseException) +ExcT_1 = TypeVar("ExcT_1", bound=Exception) +ExcT_2 = TypeVar("ExcT_2", bound=Exception) + +if sys.version_info < (3, 11): + from exceptiongroup import BaseExceptionGroup + from exceptiongroup import ExceptionGroup + + +# this differs slightly from pytest.ExceptionInfo._stringify_exception +# as we don't want '(1 sub-exception)' when matching group strings +def _stringify_exception(exc: BaseException) -> str: + return "\n".join( + [ + exc.message if isinstance(exc, BaseExceptionGroup) else str(exc), + *getattr(exc, "__notes__", []), + ], + ) + + +# String patterns default to including the unicode flag. +_REGEX_NO_FLAGS = re.compile(r"").flags + + +def _match_pattern(match: Pattern[str]) -> str | Pattern[str]: + """Helper function to remove redundant `re.compile` calls when printing regex""" + return match.pattern if match.flags == _REGEX_NO_FLAGS else match + + +def repr_callable(fun: Callable[[BaseExcT_1], bool]) -> str: + """Get the repr of a ``check`` parameter. + + Split out so it can be monkeypatched (e.g. by hypothesis) + """ + return repr(fun) + + +def _exception_type_name(e: type[BaseException]) -> str: + return repr(e.__name__) + + +def _check_raw_type( + expected_type: type[BaseException] | None, + exception: BaseException, +) -> str | None: + if expected_type is None: + return None + + if not isinstance( + exception, + expected_type, + ): + actual_type_str = _exception_type_name(type(exception)) + expected_type_str = _exception_type_name(expected_type) + if isinstance(exception, BaseExceptionGroup) and not issubclass( + expected_type, BaseExceptionGroup + ): + return f"Unexpected nested {actual_type_str}, expected {expected_type_str}" + return f"{actual_type_str} is not of type {expected_type_str}" + return None + + +class AbstractMatcher(ABC, Generic[BaseExcT_co]): + """ABC with common functionality shared between Matcher and RaisesGroup""" + + def __init__( + self, + match: str | Pattern[str] | None, + check: Callable[[BaseExcT_co], bool] | None, + ) -> None: + if isinstance(match, str): + self.match: Pattern[str] | None = re.compile(match) + else: + self.match = match + self.check = check + self._fail_reason: str | None = None + + # used to suppress repeated printing of `repr(self.check)` + self._nested: bool = False + + @property + def fail_reason(self) -> str | None: + """Set after a call to `matches` to give a human-readable reason for why the match failed. + When used as a context manager the string will be given as the text of an + `Failed`""" + return self._fail_reason + + def _check_check( + self: AbstractMatcher[BaseExcT_1], + exception: BaseExcT_1, + ) -> bool: + if self.check is None: + return True + + if self.check(exception): + return True + + check_repr = "" if self._nested else " " + repr_callable(self.check) + self._fail_reason = f"check{check_repr} did not return True" + return False + + def _check_match(self, e: BaseException) -> bool: + if self.match is None or re.search( + self.match, + stringified_exception := _stringify_exception(e), + ): + return True + + maybe_specify_type = ( + f" of {_exception_type_name(type(e))}" + if isinstance(e, BaseExceptionGroup) + else "" + ) + self._fail_reason = ( + f"Regex pattern {_match_pattern(self.match)!r}" + f" did not match {stringified_exception!r}{maybe_specify_type}" + ) + if _match_pattern(self.match) == stringified_exception: + self._fail_reason += "\n Did you mean to `re.escape()` the regex?" + return False + + @abstractmethod + def matches( + self: AbstractMatcher[BaseExcT_1], exc_val: BaseException + ) -> TypeGuard[BaseExcT_1]: + """Check if an exception matches the requirements of this AbstractMatcher. + If it fails, `AbstractMatcher.fail_reason` should be set. + """ + + +@final +class Matcher(AbstractMatcher[MatchE]): + """Helper class to be used together with RaisesGroups when you want to specify requirements on sub-exceptions. + Only specifying the type is redundant, and it's also unnecessary when the type is a + nested `RaisesGroup` since it supports the same arguments. + The type is checked with `isinstance`, and does not need to be an exact match. + If that is wanted you can use the ``check`` parameter. + :meth:`Matcher.matches` can also be used standalone to check individual exceptions. + + Examples:: + + with RaisesGroups(Matcher(ValueError, match="string")) + ... + with RaisesGroups(Matcher(check=lambda x: x.args == (3, "hello"))): + ... + with RaisesGroups(Matcher(check=lambda x: type(x) is ValueError)): + ... + + Tip: if you install ``hypothesis`` and import it in ``conftest.py`` you will get + readable ``repr``s of ``check`` callables in the output. + """ + + # Trio bundled hypothesis monkeypatching, we will probably instead assume that + # hypothesis will handle that in their pytest plugin by the time this is released. + # Alternatively we could add a version of get_pretty_function_description ourselves + # https://github.com/HypothesisWorks/hypothesis/blob/8ced2f59f5c7bea3344e35d2d53e1f8f8eb9fcd8/hypothesis-python/src/hypothesis/internal/reflection.py#L439 + + # At least one of the three parameters must be passed. + @overload + def __init__( + self: Matcher[MatchE], + exception_type: type[MatchE], + match: str | Pattern[str] = ..., + check: Callable[[MatchE], bool] = ..., + ) -> None: ... + + @overload + def __init__( + self: Matcher[BaseException], # Give E a value. + *, + match: str | Pattern[str], + # If exception_type is not provided, check() must do any typechecks itself. + check: Callable[[BaseException], bool] = ..., + ) -> None: ... + + @overload + def __init__(self, *, check: Callable[[BaseException], bool]) -> None: ... + + def __init__( + self, + exception_type: type[MatchE] | None = None, + match: str | Pattern[str] | None = None, + check: Callable[[MatchE], bool] | None = None, + ): + super().__init__(match, check) + if exception_type is None and match is None and check is None: + raise ValueError("You must specify at least one parameter to match on.") + if exception_type is not None and not issubclass(exception_type, BaseException): + raise TypeError( + f"exception_type {exception_type} must be a subclass of BaseException", + ) + self.exception_type = exception_type + + def matches( + self, + exception: BaseException, + ) -> TypeGuard[MatchE]: + """Check if an exception matches the requirements of this Matcher. + If it fails, `Matcher.fail_reason` will be set. + + Examples:: + + assert Matcher(ValueError).matches(my_exception): + # is equivalent to + assert isinstance(my_exception, ValueError) + + # this can be useful when checking e.g. the ``__cause__`` of an exception. + with pytest.raises(ValueError) as excinfo: + ... + assert Matcher(SyntaxError, match="foo").matches(excinfo.value.__cause__) + # above line is equivalent to + assert isinstance(excinfo.value.__cause__, SyntaxError) + assert re.search("foo", str(excinfo.value.__cause__) + + """ + if not self._check_type(exception): + return False + + if not self._check_match(exception): + return False + + return self._check_check(exception) + + def __repr__(self) -> str: + parameters = [] + if self.exception_type is not None: + parameters.append(self.exception_type.__name__) + if self.match is not None: + # If no flags were specified, discard the redundant re.compile() here. + parameters.append( + f"match={_match_pattern(self.match)!r}", + ) + if self.check is not None: + parameters.append(f"check={repr_callable(self.check)}") + return f"Matcher({', '.join(parameters)})" + + def _check_type(self, exception: BaseException) -> TypeGuard[MatchE]: + self._fail_reason = _check_raw_type(self.exception_type, exception) + return self._fail_reason is None + + +@final +class RaisesGroup(AbstractMatcher[BaseExceptionGroup[BaseExcT_co]]): + """Contextmanager for checking for an expected `ExceptionGroup`. + This works similar to ``pytest.raises``, but allows for specifying the structure of an `ExceptionGroup`. + `ExceptionInfo.group_contains` also tries to handle exception groups, + but it is very bad at checking that you *didn't* get exceptions you didn't expect. + + + The catching behaviour differs from :ref:`except* ` in multiple + different ways, being much stricter by default. + By using ``allow_unwrapped=True`` and ``flatten_subgroups=True`` you can match + ``except*`` fully when expecting a single exception. + + #. All specified exceptions must be present, *and no others*. + + * If you expect a variable number of exceptions you need to use ``pytest.raises(ExceptionGroup)`` and manually + check the contained exceptions. Consider making use of :func:`Matcher.matches`. + + #. It will only catch exceptions wrapped in an exceptiongroup by default. + + * With ``allow_unwrapped=True`` you can specify a single expected exception or `Matcher` and it will match + the exception even if it is not inside an `ExceptionGroup`. + If you expect one of several different exception types you need to use a `Matcher` object. + + #. By default it cares about the full structure with nested `ExceptionGroup`'s. You can specify nested + `ExceptionGroup`'s by passing `RaisesGroup` objects as expected exceptions. + + * With ``flatten_subgroups=True`` it will "flatten" the raised `ExceptionGroup`, + extracting all exceptions inside any nested :class:`ExceptionGroup`, before matching. + + It does not care about the order of the exceptions, so + ``RaisesGroups(ValueError, TypeError)`` + is equivalent to + ``RaisesGroups(TypeError, ValueError)``. + + Examples:: + + with RaisesGroups(ValueError): + raise ExceptionGroup("", (ValueError(),)) + with RaisesGroups( + ValueError, ValueError, Matcher(TypeError, match="expected int") + ): + ... + with RaisesGroups( + KeyboardInterrupt, + match="hello", + check=lambda x: type(x) is BaseExceptionGroup, + ): + ... + with RaisesGroups(RaisesGroups(ValueError)): + raise ExceptionGroup("", (ExceptionGroup("", (ValueError(),)),)) + + # flatten_subgroups + with RaisesGroups(ValueError, flatten_subgroups=True): + raise ExceptionGroup("", (ExceptionGroup("", (ValueError(),)),)) + + # allow_unwrapped + with RaisesGroups(ValueError, allow_unwrapped=True): + raise ValueError + + + `RaisesGroup.matches` can also be used directly to check a standalone exception group. + + + The matching algorithm is greedy, which means cases such as this may fail:: + + with RaisesGroups(ValueError, Matcher(ValueError, match="hello")): + raise ExceptionGroup("", (ValueError("hello"), ValueError("goodbye"))) + + even though it generally does not care about the order of the exceptions in the group. + To avoid the above you should specify the first ValueError with a Matcher as well. + + Tip: if you install ``hypothesis`` and import it in ``conftest.py`` you will get + readable ``repr``s of ``check`` callables in the output. + """ + + # allow_unwrapped=True requires: singular exception, exception not being + # RaisesGroup instance, match is None, check is None + @overload + def __init__( + self, + exception: type[BaseExcT_co] | Matcher[BaseExcT_co], + *, + allow_unwrapped: Literal[True], + flatten_subgroups: bool = False, + ) -> None: ... + + # flatten_subgroups = True also requires no nested RaisesGroup + @overload + def __init__( + self, + exception: type[BaseExcT_co] | Matcher[BaseExcT_co], + *other_exceptions: type[BaseExcT_co] | Matcher[BaseExcT_co], + flatten_subgroups: Literal[True], + match: str | Pattern[str] | None = None, + check: Callable[[BaseExceptionGroup[BaseExcT_co]], bool] | None = None, + ) -> None: ... + + # simplify the typevars if possible (the following 3 are equivalent but go simpler->complicated) + # ... the first handles RaisesGroup[ValueError], the second RaisesGroup[ExceptionGroup[ValueError]], + # the third RaisesGroup[ValueError | ExceptionGroup[ValueError]]. + # ... otherwise, we will get results like RaisesGroup[ValueError | ExceptionGroup[Never]] (I think) + # (technically correct but misleading) + @overload + def __init__( + self: RaisesGroup[ExcT_1], + exception: type[ExcT_1] | Matcher[ExcT_1], + *other_exceptions: type[ExcT_1] | Matcher[ExcT_1], + match: str | Pattern[str] | None = None, + check: Callable[[ExceptionGroup[ExcT_1]], bool] | None = None, + ) -> None: ... + + @overload + def __init__( + self: RaisesGroup[ExceptionGroup[ExcT_2]], + exception: RaisesGroup[ExcT_2], + *other_exceptions: RaisesGroup[ExcT_2], + match: str | Pattern[str] | None = None, + check: Callable[[ExceptionGroup[ExceptionGroup[ExcT_2]]], bool] | None = None, + ) -> None: ... + + @overload + def __init__( + self: RaisesGroup[ExcT_1 | ExceptionGroup[ExcT_2]], + exception: type[ExcT_1] | Matcher[ExcT_1] | RaisesGroup[ExcT_2], + *other_exceptions: type[ExcT_1] | Matcher[ExcT_1] | RaisesGroup[ExcT_2], + match: str | Pattern[str] | None = None, + check: ( + Callable[[ExceptionGroup[ExcT_1 | ExceptionGroup[ExcT_2]]], bool] | None + ) = None, + ) -> None: ... + + # same as the above 3 but handling BaseException + @overload + def __init__( + self: RaisesGroup[BaseExcT_1], + exception: type[BaseExcT_1] | Matcher[BaseExcT_1], + *other_exceptions: type[BaseExcT_1] | Matcher[BaseExcT_1], + match: str | Pattern[str] | None = None, + check: Callable[[BaseExceptionGroup[BaseExcT_1]], bool] | None = None, + ) -> None: ... + + @overload + def __init__( + self: RaisesGroup[BaseExceptionGroup[BaseExcT_2]], + exception: RaisesGroup[BaseExcT_2], + *other_exceptions: RaisesGroup[BaseExcT_2], + match: str | Pattern[str] | None = None, + check: ( + Callable[[BaseExceptionGroup[BaseExceptionGroup[BaseExcT_2]]], bool] | None + ) = None, + ) -> None: ... + + @overload + def __init__( + self: RaisesGroup[BaseExcT_1 | BaseExceptionGroup[BaseExcT_2]], + exception: type[BaseExcT_1] | Matcher[BaseExcT_1] | RaisesGroup[BaseExcT_2], + *other_exceptions: type[BaseExcT_1] + | Matcher[BaseExcT_1] + | RaisesGroup[BaseExcT_2], + match: str | Pattern[str] | None = None, + check: ( + Callable[ + [BaseExceptionGroup[BaseExcT_1 | BaseExceptionGroup[BaseExcT_2]]], + bool, + ] + | None + ) = None, + ) -> None: ... + + def __init__( + self: RaisesGroup[ExcT_1 | BaseExcT_1 | BaseExceptionGroup[BaseExcT_2]], + exception: type[BaseExcT_1] | Matcher[BaseExcT_1] | RaisesGroup[BaseExcT_2], + *other_exceptions: type[BaseExcT_1] + | Matcher[BaseExcT_1] + | RaisesGroup[BaseExcT_2], + allow_unwrapped: bool = False, + flatten_subgroups: bool = False, + match: str | Pattern[str] | None = None, + check: ( + Callable[[BaseExceptionGroup[BaseExcT_1]], bool] + | Callable[[ExceptionGroup[ExcT_1]], bool] + | None + ) = None, + ): + # The type hint on the `self` and `check` parameters uses different formats + # that are *very* hard to reconcile while adhering to the overloads, so we cast + # it to avoid an error when passing it to super().__init__ + check = cast( + "Callable[[" + "BaseExceptionGroup[ExcT_1|BaseExcT_1|BaseExceptionGroup[BaseExcT_2]]" + "], bool]", + check, + ) + super().__init__(match, check) + self.expected_exceptions: tuple[ + type[BaseExcT_co] | Matcher[BaseExcT_co] | RaisesGroup[BaseException], ... + ] = ( + exception, + *other_exceptions, + ) + self.allow_unwrapped = allow_unwrapped + self.flatten_subgroups: bool = flatten_subgroups + self.is_baseexceptiongroup = False + + if allow_unwrapped and other_exceptions: + raise ValueError( + "You cannot specify multiple exceptions with `allow_unwrapped=True.`" + " If you want to match one of multiple possible exceptions you should" + " use a `Matcher`." + " E.g. `Matcher(check=lambda e: isinstance(e, (...)))`", + ) + if allow_unwrapped and isinstance(exception, RaisesGroup): + raise ValueError( + "`allow_unwrapped=True` has no effect when expecting a `RaisesGroup`." + " You might want it in the expected `RaisesGroup`, or" + " `flatten_subgroups=True` if you don't care about the structure.", + ) + if allow_unwrapped and (match is not None or check is not None): + raise ValueError( + "`allow_unwrapped=True` bypasses the `match` and `check` parameters" + " if the exception is unwrapped. If you intended to match/check the" + " exception you should use a `Matcher` object. If you want to match/check" + " the exceptiongroup when the exception *is* wrapped you need to" + " do e.g. `if isinstance(exc.value, ExceptionGroup):" + " assert RaisesGroup(...).matches(exc.value)` afterwards.", + ) + + # verify `expected_exceptions` and set `self.is_baseexceptiongroup` + for exc in self.expected_exceptions: + if isinstance(exc, RaisesGroup): + if self.flatten_subgroups: + raise ValueError( + "You cannot specify a nested structure inside a RaisesGroup with" + " `flatten_subgroups=True`. The parameter will flatten subgroups" + " in the raised exceptiongroup before matching, which would never" + " match a nested structure.", + ) + self.is_baseexceptiongroup |= exc.is_baseexceptiongroup + exc._nested = True + elif isinstance(exc, Matcher): + if exc.exception_type is not None: + # Matcher __init__ assures it's a subclass of BaseException + self.is_baseexceptiongroup |= not issubclass( + exc.exception_type, + Exception, + ) + exc._nested = True + elif isinstance(exc, type) and issubclass(exc, BaseException): + self.is_baseexceptiongroup |= not issubclass(exc, Exception) + else: + raise TypeError( + f'Invalid argument "{exc!r}" must be exception type, Matcher, or' + " RaisesGroup.", + ) + + @overload + def __enter__( + self: RaisesGroup[ExcT_1], + ) -> ExceptionInfo[ExceptionGroup[ExcT_1]]: ... + @overload + def __enter__( + self: RaisesGroup[BaseExcT_1], + ) -> ExceptionInfo[BaseExceptionGroup[BaseExcT_1]]: ... + + def __enter__(self) -> ExceptionInfo[BaseExceptionGroup[BaseException]]: + self.excinfo: ExceptionInfo[BaseExceptionGroup[BaseExcT_co]] = ( + ExceptionInfo.for_later() + ) + return self.excinfo + + def __repr__(self) -> str: + reqs = [ + e.__name__ if isinstance(e, type) else repr(e) + for e in self.expected_exceptions + ] + if self.allow_unwrapped: + reqs.append(f"allow_unwrapped={self.allow_unwrapped}") + if self.flatten_subgroups: + reqs.append(f"flatten_subgroups={self.flatten_subgroups}") + if self.match is not None: + # If no flags were specified, discard the redundant re.compile() here. + reqs.append(f"match={_match_pattern(self.match)!r}") + if self.check is not None: + reqs.append(f"check={repr_callable(self.check)}") + return f"RaisesGroup({', '.join(reqs)})" + + def _unroll_exceptions( + self, + exceptions: Sequence[BaseException], + ) -> Sequence[BaseException]: + """Used if `flatten_subgroups=True`.""" + res: list[BaseException] = [] + for exc in exceptions: + if isinstance(exc, BaseExceptionGroup): + res.extend(self._unroll_exceptions(exc.exceptions)) + + else: + res.append(exc) + return res + + @overload + def matches( + self: RaisesGroup[ExcT_1], + exc_val: BaseException | None, + ) -> TypeGuard[ExceptionGroup[ExcT_1]]: ... + @overload + def matches( + self: RaisesGroup[BaseExcT_1], + exc_val: BaseException | None, + ) -> TypeGuard[BaseExceptionGroup[BaseExcT_1]]: ... + + def matches( + self, + exc_val: BaseException | None, + ) -> TypeGuard[BaseExceptionGroup[BaseExcT_co]]: + """Check if an exception matches the requirements of this RaisesGroup. + If it fails, `RaisesGroup.fail_reason` will be set. + + Example:: + + with pytest.raises(TypeError) as excinfo: + ... + assert RaisesGroups(ValueError).matches(excinfo.value.__cause__) + # the above line is equivalent to + myexc = excinfo.value.__cause + assert isinstance(myexc, BaseExceptionGroup) + assert len(myexc.exceptions) == 1 + assert isinstance(myexc.exceptions[0], ValueError) + """ + self._fail_reason = None + if exc_val is None: + self._fail_reason = "exception is None" + return False + if not isinstance(exc_val, BaseExceptionGroup): + # we opt to only print type of the exception here, as the repr would + # likely be quite long + not_group_msg = f"{type(exc_val).__name__!r} is not an exception group" + if len(self.expected_exceptions) > 1: + self._fail_reason = not_group_msg + return False + # if we have 1 expected exception, check if it would work even if + # allow_unwrapped is not set + res = self._check_expected(self.expected_exceptions[0], exc_val) + if res is None and self.allow_unwrapped: + return True + + if res is None: + self._fail_reason = ( + f"{not_group_msg}, but would match with `allow_unwrapped=True`" + ) + elif self.allow_unwrapped: + self._fail_reason = res + else: + self._fail_reason = not_group_msg + return False + + actual_exceptions: Sequence[BaseException] = exc_val.exceptions + if self.flatten_subgroups: + actual_exceptions = self._unroll_exceptions(actual_exceptions) + + if not self._check_match(exc_val): + self._fail_reason = cast(str, self._fail_reason) + old_reason = self._fail_reason + if ( + len(actual_exceptions) == len(self.expected_exceptions) == 1 + and isinstance(expected := self.expected_exceptions[0], type) + and isinstance(actual := actual_exceptions[0], expected) + and self._check_match(actual) + ): + assert self.match is not None, "can't be None if _check_match failed" + assert self._fail_reason is old_reason is not None + self._fail_reason += ( + f", but matched the expected {self._repr_expected(expected)}." + f" You might want RaisesGroup(Matcher({expected.__name__}, match={_match_pattern(self.match)!r}))" + ) + else: + self._fail_reason = old_reason + return False + + # do the full check on expected exceptions + if not self._check_exceptions( + exc_val, + actual_exceptions, + ): + self._fail_reason = cast(str, self._fail_reason) + assert self._fail_reason is not None + old_reason = self._fail_reason + # if we're not expecting a nested structure, and there is one, do a second + # pass where we try flattening it + if ( + not self.flatten_subgroups + and not any( + isinstance(e, RaisesGroup) for e in self.expected_exceptions + ) + and any(isinstance(e, BaseExceptionGroup) for e in actual_exceptions) + and self._check_exceptions( + exc_val, + self._unroll_exceptions(exc_val.exceptions), + ) + ): + # only indent if it's a single-line reason. In a multi-line there's already + # indented lines that this does not belong to. + indent = " " if "\n" not in self._fail_reason else "" + self._fail_reason = ( + old_reason + + f"\n{indent}Did you mean to use `flatten_subgroups=True`?" + ) + else: + self._fail_reason = old_reason + return False + + # Only run `self.check` once we know `exc_val` is of the correct type. + if not self._check_check(exc_val): + reason = cast(str, self._fail_reason) + f" on the {type(exc_val).__name__}" + if ( + len(actual_exceptions) == len(self.expected_exceptions) == 1 + and isinstance(expected := self.expected_exceptions[0], type) + # we explicitly break typing here :) + and self._check_check(actual_exceptions[0]) # type: ignore[arg-type] + ): + self._fail_reason = reason + ( + f", but did return True for the expected {self._repr_expected(expected)}." + f" You might want RaisesGroup(Matcher({expected.__name__}, check=<...>))" + ) + else: + self._fail_reason = reason + return False + + return True + + @staticmethod + def _check_expected( + expected_type: ( + type[BaseException] | Matcher[BaseException] | RaisesGroup[BaseException] + ), + exception: BaseException, + ) -> str | None: + """Helper method for `RaisesGroup.matches` and `RaisesGroup._check_exceptions` + to check one of potentially several expected exceptions.""" + if isinstance(expected_type, type): + return _check_raw_type(expected_type, exception) + res = expected_type.matches(exception) + if res: + return None + assert expected_type.fail_reason is not None + if expected_type.fail_reason.startswith("\n"): + return f"\n{expected_type!r}: {indent(expected_type.fail_reason, ' ')}" + return f"{expected_type!r}: {expected_type.fail_reason}" + + @staticmethod + def _repr_expected(e: type[BaseException] | AbstractMatcher[BaseException]) -> str: + """Get the repr of an expected type/Matcher/RaisesGroup, but we only want + the name if it's a type""" + if isinstance(e, type): + return _exception_type_name(e) + return repr(e) + + @overload + def _check_exceptions( + self: RaisesGroup[ExcT_1], + _exc_val: Exception, + actual_exceptions: Sequence[Exception], + ) -> TypeGuard[ExceptionGroup[ExcT_1]]: ... + @overload + def _check_exceptions( + self: RaisesGroup[BaseExcT_1], + _exc_val: BaseException, + actual_exceptions: Sequence[BaseException], + ) -> TypeGuard[BaseExceptionGroup[BaseExcT_1]]: ... + + def _check_exceptions( + self, + _exc_val: BaseException, + actual_exceptions: Sequence[BaseException], + ) -> TypeGuard[BaseExceptionGroup[BaseExcT_co]]: + """Helper method for RaisesGroup.matches that attempts to pair up expected and actual exceptions""" + # full table with all results + results = ResultHolder(self.expected_exceptions, actual_exceptions) + + # (indexes of) raised exceptions that haven't (yet) found an expected + remaining_actual = list(range(len(actual_exceptions))) + # (indexes of) expected exceptions that haven't found a matching raised + failed_expected: list[int] = [] + # successful greedy matches + matches: dict[int, int] = {} + + # loop over expected exceptions first to get a more predictable result + for i_exp, expected in enumerate(self.expected_exceptions): + for i_rem in remaining_actual: + res = self._check_expected(expected, actual_exceptions[i_rem]) + results.set_result(i_exp, i_rem, res) + if res is None: + remaining_actual.remove(i_rem) + matches[i_exp] = i_rem + break + else: + failed_expected.append(i_exp) + + # All exceptions matched up successfully + if not remaining_actual and not failed_expected: + return True + + # in case of a single expected and single raised we simplify the output + if 1 == len(actual_exceptions) == len(self.expected_exceptions): + assert not matches + self._fail_reason = res + return False + + # The test case is failing, so we can do a slow and exhaustive check to find + # duplicate matches etc that will be helpful in debugging + for i_exp, expected in enumerate(self.expected_exceptions): + for i_actual, actual in enumerate(actual_exceptions): + if results.has_result(i_exp, i_actual): + continue + results.set_result( + i_exp, i_actual, self._check_expected(expected, actual) + ) + + successful_str = ( + f"{len(matches)} matched exception{'s' if len(matches) > 1 else ''}. " + if matches + else "" + ) + + # all expected were found + if not failed_expected and results.no_match_for_actual(remaining_actual): + self._fail_reason = ( + f"{successful_str}Unexpected exception(s):" + f" {[actual_exceptions[i] for i in remaining_actual]!r}" + ) + return False + # all raised exceptions were expected + if not remaining_actual and results.no_match_for_expected(failed_expected): + no_match_for_str = ", ".join( + self._repr_expected(self.expected_exceptions[i]) + for i in failed_expected + ) + self._fail_reason = f"{successful_str}Too few exceptions raised, found no match for: [{no_match_for_str}]" + return False + + # if there's only one remaining and one failed, and the unmatched didn't match anything else, + # we elect to only print why the remaining and the failed didn't match. + if ( + 1 == len(remaining_actual) == len(failed_expected) + and results.no_match_for_actual(remaining_actual) + and results.no_match_for_expected(failed_expected) + ): + self._fail_reason = f"{successful_str}{results.get_result(failed_expected[0], remaining_actual[0])}" + return False + + # there's both expected and raised exceptions without matches + s = "" + if matches: + s += f"\n{successful_str}" + indent_1 = " " * 2 + indent_2 = " " * 4 + + if not remaining_actual: + s += "\nToo few exceptions raised!" + elif not failed_expected: + s += "\nUnexpected exception(s)!" + + if failed_expected: + s += "\nThe following expected exceptions did not find a match:" + rev_matches = {v: k for k, v in matches.items()} + for i_failed in failed_expected: + s += ( + f"\n{indent_1}{self._repr_expected(self.expected_exceptions[i_failed])}" + ) + for i_actual, actual in enumerate(actual_exceptions): + if results.get_result(i_exp, i_actual) is None: + # we print full repr of match target + s += ( + f"\n{indent_2}It matches {actual!r} which was paired with " + + self._repr_expected( + self.expected_exceptions[rev_matches[i_actual]] + ) + ) + + if remaining_actual: + s += "\nThe following raised exceptions did not find a match" + for i_actual in remaining_actual: + s += f"\n{indent_1}{actual_exceptions[i_actual]!r}:" + for i_exp, expected in enumerate(self.expected_exceptions): + res = results.get_result(i_exp, i_actual) + if i_exp in failed_expected: + assert res is not None + if res[0] != "\n": + s += "\n" + s += indent(res, indent_2) + if res is None: + # we print full repr of match target + s += ( + f"\n{indent_2}It matches {self._repr_expected(expected)} " + f"which was paired with {actual_exceptions[matches[i_exp]]!r}" + ) + + if len(self.expected_exceptions) == len(actual_exceptions) and possible_match( + results + ): + s += ( + "\nThere exist a possible match when attempting an exhaustive check," + " but RaisesGroup uses a greedy algorithm. " + "Please make your expected exceptions more stringent with `Matcher` etc" + " so the greedy algorithm can function." + ) + self._fail_reason = s + return False + + def __exit__( + self, + exc_type: type[BaseException] | None, + exc_val: BaseException | None, + exc_tb: types.TracebackType | None, + ) -> bool: + __tracebackhide__ = True + if exc_type is None: + fail(f"DID NOT RAISE any exception, expected {self.expected_type()}") + + assert self.excinfo is not None, ( + "Internal error - should have been constructed in __enter__" + ) + + group_str = ( + "(group)" + if self.allow_unwrapped and not issubclass(exc_type, BaseExceptionGroup) + else "group" + ) + + if not self.matches(exc_val): + fail(f"Raised exception {group_str} did not match: {self._fail_reason}") + + # Cast to narrow the exception type now that it's verified.... + # even though the TypeGuard in self.matches should be narrowing + exc_info = cast( + "tuple[type[BaseExceptionGroup[BaseExcT_co]], BaseExceptionGroup[BaseExcT_co], types.TracebackType]", + (exc_type, exc_val, exc_tb), + ) + self.excinfo.fill_unfilled(exc_info) + return True + + def expected_type(self) -> str: + subexcs = [] + for e in self.expected_exceptions: + if isinstance(e, Matcher): + subexcs.append(str(e)) + elif isinstance(e, RaisesGroup): + subexcs.append(e.expected_type()) + elif isinstance(e, type): + subexcs.append(e.__name__) + else: # pragma: no cover + raise AssertionError("unknown type") + group_type = "Base" if self.is_baseexceptiongroup else "" + return f"{group_type}ExceptionGroup({', '.join(subexcs)})" + + +@final +class NotChecked: + """Singleton for unchecked values in ResultHolder""" + + +class ResultHolder: + """Container for results of checking exceptions. + Used in RaisesGroup._check_exceptions and possible_match. + """ + + def __init__( + self, + expected_exceptions: tuple[ + type[BaseException] | AbstractMatcher[BaseException], ... + ], + actual_exceptions: Sequence[BaseException], + ) -> None: + self.results: list[list[str | type[NotChecked] | None]] = [ + [NotChecked for _ in expected_exceptions] for _ in actual_exceptions + ] + + def set_result(self, expected: int, actual: int, result: str | None) -> None: + self.results[actual][expected] = result + + def get_result(self, expected: int, actual: int) -> str | None: + res = self.results[actual][expected] + assert res is not NotChecked + # mypy doesn't support identity checking against anything but None + return res # type: ignore[return-value] + + def has_result(self, expected: int, actual: int) -> bool: + return self.results[actual][expected] is not NotChecked + + def no_match_for_expected(self, expected: list[int]) -> bool: + for i in expected: + for actual_results in self.results: + assert actual_results[i] is not NotChecked + if actual_results[i] is None: + return False + return True + + def no_match_for_actual(self, actual: list[int]) -> bool: + for i in actual: + for res in self.results[i]: + assert res is not NotChecked + if res is None: + return False + return True + + +def possible_match(results: ResultHolder, used: set[int] | None = None) -> bool: + if used is None: + used = set() + curr_row = len(used) + if curr_row == len(results.results): + return True + + for i, val in enumerate(results.results[curr_row]): + if val is None and i not in used and possible_match(results, used | {i}): + return True + return False diff --git a/src/pytest/__init__.py b/src/pytest/__init__.py index 70096d6593e..ca2c66fee03 100644 --- a/src/pytest/__init__.py +++ b/src/pytest/__init__.py @@ -6,6 +6,9 @@ from _pytest import __version__ from _pytest import version_tuple from _pytest._code import ExceptionInfo +from _pytest._raises_group import Matcher +from _pytest._raises_group import RaisesGroup +from _pytest._raises_group import RaisesGroup as raises_group from _pytest.assertion import register_assert_rewrite from _pytest.cacheprovider import Cache from _pytest.capture import CaptureFixture @@ -113,6 +116,7 @@ "Mark", "MarkDecorator", "MarkGenerator", + "Matcher", "Metafunc", "Module", "MonkeyPatch", @@ -133,6 +137,7 @@ "PytestUnraisableExceptionWarning", "PytestWarning", "Pytester", + "RaisesGroup", "RecordedHookCall", "RunResult", "Session", @@ -162,6 +167,7 @@ "mark", "param", "raises", + "raises_group", "register_assert_rewrite", "set_trace", "skip", diff --git a/testing/python/raises_group.py b/testing/python/raises_group.py new file mode 100644 index 00000000000..c10398d0b9e --- /dev/null +++ b/testing/python/raises_group.py @@ -0,0 +1,1137 @@ +from __future__ import annotations + +# several expected multi-line strings contain long lines. We don't wanna break them up +# as that makes it confusing to see where the line breaks are. +# ruff: noqa: E501 +import re +import sys +from typing import TYPE_CHECKING + +from _pytest._raises_group import Matcher +from _pytest._raises_group import RaisesGroup +from _pytest._raises_group import repr_callable +from _pytest.outcomes import Failed +import pytest + + +if sys.version_info < (3, 11): + from exceptiongroup import BaseExceptionGroup + from exceptiongroup import ExceptionGroup + +if TYPE_CHECKING: + from _pytest.python_api import RaisesContext + + +def wrap_escape(s: str) -> str: + return "^" + re.escape(s) + "$" + + +def fails_raises_group(msg: str, add_prefix: bool = True) -> RaisesContext[Failed]: + assert msg[-1] != "\n", ( + "developer error, expected string should not end with newline" + ) + prefix = "Raised exception group did not match: " if add_prefix else "" + return pytest.raises(Failed, match=wrap_escape(prefix + msg)) + + +def test_raises_group() -> None: + with pytest.raises( + TypeError, + match=wrap_escape( + f'Invalid argument "{ValueError()!r}" must be exception type, Matcher, or RaisesGroup.', + ), + ): + RaisesGroup(ValueError()) # type: ignore[call-overload] + with RaisesGroup(ValueError): + raise ExceptionGroup("foo", (ValueError(),)) + + with ( + fails_raises_group("'SyntaxError' is not of type 'ValueError'"), + RaisesGroup(ValueError), + ): + raise ExceptionGroup("foo", (SyntaxError(),)) + + # multiple exceptions + with RaisesGroup(ValueError, SyntaxError): + raise ExceptionGroup("foo", (ValueError(), SyntaxError())) + + # order doesn't matter + with RaisesGroup(SyntaxError, ValueError): + raise ExceptionGroup("foo", (ValueError(), SyntaxError())) + + # nested exceptions + with RaisesGroup(RaisesGroup(ValueError)): + raise ExceptionGroup("foo", (ExceptionGroup("bar", (ValueError(),)),)) + + with RaisesGroup( + SyntaxError, + RaisesGroup(ValueError), + RaisesGroup(RuntimeError), + ): + raise ExceptionGroup( + "foo", + ( + SyntaxError(), + ExceptionGroup("bar", (ValueError(),)), + ExceptionGroup("", (RuntimeError(),)), + ), + ) + + +def test_incorrect_number_exceptions() -> None: + # We previously gave an error saying the number of exceptions was wrong, + # but we now instead indicate excess/missing exceptions + with ( + fails_raises_group( + "1 matched exception. Unexpected exception(s): [RuntimeError()]" + ), + RaisesGroup(ValueError), + ): + raise ExceptionGroup("", (RuntimeError(), ValueError())) + + # will error if there's missing exceptions + with ( + fails_raises_group( + "1 matched exception. Too few exceptions raised, found no match for: ['SyntaxError']" + ), + RaisesGroup(ValueError, SyntaxError), + ): + raise ExceptionGroup("", (ValueError(),)) + + with ( + fails_raises_group( + "\n" + "1 matched exception. \n" + "Too few exceptions raised!\n" + "The following expected exceptions did not find a match:\n" + " 'ValueError'\n" + " It matches ValueError() which was paired with 'ValueError'" + ), + RaisesGroup(ValueError, ValueError), + ): + raise ExceptionGroup("", (ValueError(),)) + + with ( + fails_raises_group( + "\n" + "1 matched exception. \n" + "Unexpected exception(s)!\n" + "The following raised exceptions did not find a match\n" + " ValueError():\n" + " It matches 'ValueError' which was paired with ValueError()" + ), + RaisesGroup(ValueError), + ): + raise ExceptionGroup("", (ValueError(), ValueError())) + + with ( + fails_raises_group( + "\n" + "1 matched exception. \n" + "The following expected exceptions did not find a match:\n" + " 'ValueError'\n" + " It matches ValueError() which was paired with 'ValueError'\n" + "The following raised exceptions did not find a match\n" + " SyntaxError():\n" + " 'SyntaxError' is not of type 'ValueError'" + ), + RaisesGroup(ValueError, ValueError), + ): + raise ExceptionGroup("", [ValueError(), SyntaxError()]) + + +def test_flatten_subgroups() -> None: + # loose semantics, as with expect* + with RaisesGroup(ValueError, flatten_subgroups=True): + raise ExceptionGroup("", (ExceptionGroup("", (ValueError(),)),)) + + with RaisesGroup(ValueError, TypeError, flatten_subgroups=True): + raise ExceptionGroup("", (ExceptionGroup("", (ValueError(), TypeError())),)) + with RaisesGroup(ValueError, TypeError, flatten_subgroups=True): + raise ExceptionGroup("", [ExceptionGroup("", [ValueError()]), TypeError()]) + + # mixed loose is possible if you want it to be at least N deep + with RaisesGroup(RaisesGroup(ValueError, flatten_subgroups=True)): + raise ExceptionGroup("", (ExceptionGroup("", (ValueError(),)),)) + with RaisesGroup(RaisesGroup(ValueError, flatten_subgroups=True)): + raise ExceptionGroup( + "", + (ExceptionGroup("", (ExceptionGroup("", (ValueError(),)),)),), + ) + + # but not the other way around + with pytest.raises( + ValueError, + match=r"^You cannot specify a nested structure inside a RaisesGroup with", + ): + RaisesGroup(RaisesGroup(ValueError), flatten_subgroups=True) # type: ignore[call-overload] + + # flatten_subgroups is not sufficient to catch fully unwrapped + with ( + fails_raises_group( + "'ValueError' is not an exception group, but would match with `allow_unwrapped=True`" + ), + RaisesGroup(ValueError, flatten_subgroups=True), + ): + raise ValueError + with ( + fails_raises_group( + "RaisesGroup(ValueError, flatten_subgroups=True): 'ValueError' is not an exception group, but would match with `allow_unwrapped=True`" + ), + RaisesGroup(RaisesGroup(ValueError, flatten_subgroups=True)), + ): + raise ExceptionGroup("", (ValueError(),)) + + # helpful suggestion if flatten_subgroups would make it pass + with ( + fails_raises_group( + "Raised exception group did not match: \n" + "The following expected exceptions did not find a match:\n" + " 'ValueError'\n" + " 'TypeError'\n" + "The following raised exceptions did not find a match\n" + " ExceptionGroup('', [ValueError(), TypeError()]):\n" + " Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + " Unexpected nested 'ExceptionGroup', expected 'TypeError'\n" + "Did you mean to use `flatten_subgroups=True`?", + add_prefix=False, + ), + RaisesGroup(ValueError, TypeError), + ): + raise ExceptionGroup("", [ExceptionGroup("", [ValueError(), TypeError()])]) + # but doesn't consider check (otherwise we'd break typing guarantees) + with ( + fails_raises_group( + "Raised exception group did not match: \n" + "The following expected exceptions did not find a match:\n" + " 'ValueError'\n" + " 'TypeError'\n" + "The following raised exceptions did not find a match\n" + " ExceptionGroup('', [ValueError(), TypeError()]):\n" + " Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + " Unexpected nested 'ExceptionGroup', expected 'TypeError'\n" + "Did you mean to use `flatten_subgroups=True`?", + add_prefix=False, + ), + RaisesGroup( + ValueError, + TypeError, + check=lambda eg: len(eg.exceptions) == 1, + ), + ): + raise ExceptionGroup("", [ExceptionGroup("", [ValueError(), TypeError()])]) + # correct number of exceptions, and flatten_subgroups would make it pass + # This now doesn't print a repr of the caught exception at all, but that can be found in the traceback + with ( + fails_raises_group( + "Raised exception group did not match: Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + " Did you mean to use `flatten_subgroups=True`?", + add_prefix=False, + ), + RaisesGroup(ValueError), + ): + raise ExceptionGroup("", [ExceptionGroup("", [ValueError()])]) + # correct number of exceptions, but flatten_subgroups wouldn't help, so we don't suggest it + with ( + fails_raises_group("Unexpected nested 'ExceptionGroup', expected 'ValueError'"), + RaisesGroup(ValueError), + ): + raise ExceptionGroup("", [ExceptionGroup("", [TypeError()])]) + + # flatten_subgroups can be suggested if nested. This will implicitly ask the user to + # do `RaisesGroup(RaisesGroup(ValueError, flatten_subgroups=True))` which is unlikely + # to be what they actually want - but I don't think it's worth trying to special-case + with ( + fails_raises_group( + "RaisesGroup(ValueError): Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + " Did you mean to use `flatten_subgroups=True`?", + ), + RaisesGroup(RaisesGroup(ValueError)), + ): + raise ExceptionGroup( + "", + [ExceptionGroup("", [ExceptionGroup("", [ValueError()])])], + ) + + # Don't mention "unexpected nested" if expecting an ExceptionGroup. + # Although it should perhaps be an error to specify `RaisesGroup(ExceptionGroup)` in + # favor of doing `RaisesGroup(RaisesGroup(...))`. + with ( + fails_raises_group("'BaseExceptionGroup' is not of type 'ExceptionGroup'"), + RaisesGroup(ExceptionGroup), + ): + raise BaseExceptionGroup("", [BaseExceptionGroup("", [KeyboardInterrupt()])]) + + +def test_catch_unwrapped_exceptions() -> None: + # Catches lone exceptions with strict=False + # just as except* would + with RaisesGroup(ValueError, allow_unwrapped=True): + raise ValueError + + # expecting multiple unwrapped exceptions is not possible + with pytest.raises( + ValueError, + match=r"^You cannot specify multiple exceptions with", + ): + RaisesGroup(SyntaxError, ValueError, allow_unwrapped=True) # type: ignore[call-overload] + # if users want one of several exception types they need to use a Matcher + # (which the error message suggests) + with RaisesGroup( + Matcher(check=lambda e: isinstance(e, (SyntaxError, ValueError))), + allow_unwrapped=True, + ): + raise ValueError + + # Unwrapped nested `RaisesGroup` is likely a user error, so we raise an error. + with pytest.raises(ValueError, match="has no effect when expecting"): + RaisesGroup(RaisesGroup(ValueError), allow_unwrapped=True) # type: ignore[call-overload] + + # But it *can* be used to check for nesting level +- 1 if they move it to + # the nested RaisesGroup. Users should probably use `Matcher`s instead though. + with RaisesGroup(RaisesGroup(ValueError, allow_unwrapped=True)): + raise ExceptionGroup("", [ExceptionGroup("", [ValueError()])]) + with RaisesGroup(RaisesGroup(ValueError, allow_unwrapped=True)): + raise ExceptionGroup("", [ValueError()]) + + # with allow_unwrapped=False (default) it will not be caught + with ( + fails_raises_group( + "'ValueError' is not an exception group, but would match with `allow_unwrapped=True`" + ), + RaisesGroup(ValueError), + ): + raise ValueError("value error text") + + # allow_unwrapped on its own won't match against nested groups + with ( + fails_raises_group( + "Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + " Did you mean to use `flatten_subgroups=True`?", + ), + RaisesGroup(ValueError, allow_unwrapped=True), + ): + raise ExceptionGroup("foo", [ExceptionGroup("bar", [ValueError()])]) + + # you need both allow_unwrapped and flatten_subgroups to fully emulate except* + with RaisesGroup(ValueError, allow_unwrapped=True, flatten_subgroups=True): + raise ExceptionGroup("", [ExceptionGroup("", [ValueError()])]) + + # code coverage + with ( + fails_raises_group( + "Raised exception (group) did not match: 'TypeError' is not of type 'ValueError'", + add_prefix=False, + ), + RaisesGroup(ValueError, allow_unwrapped=True), + ): + raise TypeError("this text doesn't show up in the error message") + with ( + fails_raises_group( + "Raised exception (group) did not match: Matcher(ValueError): 'TypeError' is not of type 'ValueError'", + add_prefix=False, + ), + RaisesGroup(Matcher(ValueError), allow_unwrapped=True), + ): + raise TypeError + + # check we don't suggest unwrapping with nested RaisesGroup + with ( + fails_raises_group("'ValueError' is not an exception group"), + RaisesGroup(RaisesGroup(ValueError)), + ): + raise ValueError + + +def test_match() -> None: + # supports match string + with RaisesGroup(ValueError, match="bar"): + raise ExceptionGroup("bar", (ValueError(),)) + + # now also works with ^$ + with RaisesGroup(ValueError, match="^bar$"): + raise ExceptionGroup("bar", (ValueError(),)) + + # it also includes notes + with RaisesGroup(ValueError, match="my note"): + e = ExceptionGroup("bar", (ValueError(),)) + e.add_note("my note") + raise e + + # and technically you can match it all with ^$ + # but you're probably better off using a Matcher at that point + with RaisesGroup(ValueError, match="^bar\nmy note$"): + e = ExceptionGroup("bar", (ValueError(),)) + e.add_note("my note") + raise e + + with ( + fails_raises_group( + "Regex pattern 'foo' did not match 'bar' of 'ExceptionGroup'" + ), + RaisesGroup(ValueError, match="foo"), + ): + raise ExceptionGroup("bar", (ValueError(),)) + + # Suggest a fix for easy pitfall of adding match to the RaisesGroup instead of + # using a Matcher. + # This requires a single expected & raised exception, the expected is a type, + # and `isinstance(raised, expected_type)`. + with ( + fails_raises_group( + "Regex pattern 'foo' did not match 'bar' of 'ExceptionGroup', but matched the expected 'ValueError'. You might want RaisesGroup(Matcher(ValueError, match='foo'))" + ), + RaisesGroup(ValueError, match="foo"), + ): + raise ExceptionGroup("bar", [ValueError("foo")]) + + +def test_check() -> None: + exc = ExceptionGroup("", (ValueError(),)) + + def is_exc(e: ExceptionGroup[ValueError]) -> bool: + return e is exc + + is_exc_repr = repr_callable(is_exc) + with RaisesGroup(ValueError, check=is_exc): + raise exc + + with ( + fails_raises_group( + f"check {is_exc_repr} did not return True on the ExceptionGroup" + ), + RaisesGroup(ValueError, check=is_exc), + ): + raise ExceptionGroup("", (ValueError(),)) + + def is_value_error(e: BaseException) -> bool: + return isinstance(e, ValueError) + + # helpful suggestion if the user thinks the check is for the sub-exception + with ( + fails_raises_group( + f"check {is_value_error} did not return True on the ExceptionGroup, but did return True for the expected 'ValueError'. You might want RaisesGroup(Matcher(ValueError, check=<...>))" + ), + RaisesGroup(ValueError, check=is_value_error), + ): + raise ExceptionGroup("", (ValueError(),)) + + +def test_unwrapped_match_check() -> None: + def my_check(e: object) -> bool: # pragma: no cover + return True + + msg = ( + "`allow_unwrapped=True` bypasses the `match` and `check` parameters" + " if the exception is unwrapped. If you intended to match/check the" + " exception you should use a `Matcher` object. If you want to match/check" + " the exceptiongroup when the exception *is* wrapped you need to" + " do e.g. `if isinstance(exc.value, ExceptionGroup):" + " assert RaisesGroup(...).matches(exc.value)` afterwards." + ) + with pytest.raises(ValueError, match=re.escape(msg)): + RaisesGroup(ValueError, allow_unwrapped=True, match="foo") # type: ignore[call-overload] + with pytest.raises(ValueError, match=re.escape(msg)): + RaisesGroup(ValueError, allow_unwrapped=True, check=my_check) # type: ignore[call-overload] + + # Users should instead use a Matcher + rg = RaisesGroup(Matcher(ValueError, match="^foo$"), allow_unwrapped=True) + with rg: + raise ValueError("foo") + with rg: + raise ExceptionGroup("", [ValueError("foo")]) + + # or if they wanted to match/check the group, do a conditional `.matches()` + with RaisesGroup(ValueError, allow_unwrapped=True) as exc: + raise ExceptionGroup("bar", [ValueError("foo")]) + if isinstance(exc.value, ExceptionGroup): # pragma: no branch + assert RaisesGroup(ValueError, match="bar").matches(exc.value) + + +def test_RaisesGroup_matches() -> None: + rg = RaisesGroup(ValueError) + assert not rg.matches(None) + assert not rg.matches(ValueError()) + assert rg.matches(ExceptionGroup("", (ValueError(),))) + + +def test_message() -> None: + def check_message( + message: str, + body: RaisesGroup[BaseException], + ) -> None: + with ( + pytest.raises( + Failed, + match=f"^DID NOT RAISE any exception, expected {re.escape(message)}$", + ), + body, + ): + ... + + # basic + check_message("ExceptionGroup(ValueError)", RaisesGroup(ValueError)) + # multiple exceptions + check_message( + "ExceptionGroup(ValueError, ValueError)", + RaisesGroup(ValueError, ValueError), + ) + # nested + check_message( + "ExceptionGroup(ExceptionGroup(ValueError))", + RaisesGroup(RaisesGroup(ValueError)), + ) + + # Matcher + check_message( + "ExceptionGroup(Matcher(ValueError, match='my_str'))", + RaisesGroup(Matcher(ValueError, "my_str")), + ) + check_message( + "ExceptionGroup(Matcher(match='my_str'))", + RaisesGroup(Matcher(match="my_str")), + ) + + # BaseExceptionGroup + check_message( + "BaseExceptionGroup(KeyboardInterrupt)", + RaisesGroup(KeyboardInterrupt), + ) + # BaseExceptionGroup with type inside Matcher + check_message( + "BaseExceptionGroup(Matcher(KeyboardInterrupt))", + RaisesGroup(Matcher(KeyboardInterrupt)), + ) + # Base-ness transfers to parent containers + check_message( + "BaseExceptionGroup(BaseExceptionGroup(KeyboardInterrupt))", + RaisesGroup(RaisesGroup(KeyboardInterrupt)), + ) + # but not to child containers + check_message( + "BaseExceptionGroup(BaseExceptionGroup(KeyboardInterrupt), ExceptionGroup(ValueError))", + RaisesGroup(RaisesGroup(KeyboardInterrupt), RaisesGroup(ValueError)), + ) + + +def test_assert_message() -> None: + # the message does not need to list all parameters to RaisesGroup, nor all exceptions + # in the exception group, as those are both visible in the traceback. + # first fails to match + with ( + fails_raises_group("'TypeError' is not of type 'ValueError'"), + RaisesGroup(ValueError), + ): + raise ExceptionGroup("a", [TypeError()]) + with ( + fails_raises_group( + "Raised exception group did not match: \n" + "The following expected exceptions did not find a match:\n" + " RaisesGroup(ValueError)\n" + " RaisesGroup(ValueError, match='a')\n" + "The following raised exceptions did not find a match\n" + " ExceptionGroup('', [RuntimeError()]):\n" + " RaisesGroup(ValueError): 'RuntimeError' is not of type 'ValueError'\n" + " RaisesGroup(ValueError, match='a'): Regex pattern 'a' did not match '' of 'ExceptionGroup'\n" + " RuntimeError():\n" + " RaisesGroup(ValueError): 'RuntimeError' is not an exception group\n" + " RaisesGroup(ValueError, match='a'): 'RuntimeError' is not an exception group", + add_prefix=False, # to see the full structure + ), + RaisesGroup(RaisesGroup(ValueError), RaisesGroup(ValueError, match="a")), + ): + raise ExceptionGroup( + "", + [ExceptionGroup("", [RuntimeError()]), RuntimeError()], + ) + + with ( + fails_raises_group( + "Raised exception group did not match: \n" + "2 matched exceptions. \n" + "The following expected exceptions did not find a match:\n" + " RaisesGroup(RuntimeError)\n" + " RaisesGroup(ValueError)\n" + "The following raised exceptions did not find a match\n" + " RuntimeError():\n" + # " 'RuntimeError' is not of type 'ValueError'\n" + # " Matcher(TypeError): 'RuntimeError' is not of type 'TypeError'\n" + " RaisesGroup(RuntimeError): 'RuntimeError' is not an exception group, but would match with `allow_unwrapped=True`\n" + " RaisesGroup(ValueError): 'RuntimeError' is not an exception group\n" + " ValueError('bar'):\n" + " It matches 'ValueError' which was paired with ValueError('foo')\n" + " RaisesGroup(RuntimeError): 'ValueError' is not an exception group\n" + " RaisesGroup(ValueError): 'ValueError' is not an exception group, but would match with `allow_unwrapped=True`", + add_prefix=False, # to see the full structure + ), + RaisesGroup( + ValueError, + Matcher(TypeError), + RaisesGroup(RuntimeError), + RaisesGroup(ValueError), + ), + ): + raise ExceptionGroup( + "a", + [RuntimeError(), TypeError(), ValueError("foo"), ValueError("bar")], + ) + + with ( + fails_raises_group( + "1 matched exception. 'AssertionError' is not of type 'TypeError'" + ), + RaisesGroup(ValueError, TypeError), + ): + raise ExceptionGroup("a", [ValueError(), AssertionError()]) + + with ( + fails_raises_group( + "Matcher(ValueError): 'TypeError' is not of type 'ValueError'" + ), + RaisesGroup(Matcher(ValueError)), + ): + raise ExceptionGroup("a", [TypeError()]) + + # suggest escaping + with ( + fails_raises_group( + "Raised exception group did not match: Regex pattern 'h(ell)o' did not match 'h(ell)o' of 'ExceptionGroup'\n" + " Did you mean to `re.escape()` the regex?", + add_prefix=False, # to see the full structure + ), + RaisesGroup(ValueError, match="h(ell)o"), + ): + raise ExceptionGroup("h(ell)o", [ValueError()]) + with ( + fails_raises_group( + "Matcher(match='h(ell)o'): Regex pattern 'h(ell)o' did not match 'h(ell)o'\n" + " Did you mean to `re.escape()` the regex?", + ), + RaisesGroup(Matcher(match="h(ell)o")), + ): + raise ExceptionGroup("", [ValueError("h(ell)o")]) + + with ( + fails_raises_group( + "Raised exception group did not match: \n" + "The following expected exceptions did not find a match:\n" + " 'ValueError'\n" + " 'ValueError'\n" + " 'ValueError'\n" + " 'ValueError'\n" + "The following raised exceptions did not find a match\n" + " ExceptionGroup('', [ValueError(), TypeError()]):\n" + " Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + " Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + " Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + " Unexpected nested 'ExceptionGroup', expected 'ValueError'", + add_prefix=False, # to see the full structure + ), + RaisesGroup(ValueError, ValueError, ValueError, ValueError), + ): + raise ExceptionGroup("", [ExceptionGroup("", [ValueError(), TypeError()])]) + + +def test_message_indent() -> None: + with ( + fails_raises_group( + "Raised exception group did not match: \n" + "The following expected exceptions did not find a match:\n" + " RaisesGroup(ValueError, ValueError)\n" + " 'ValueError'\n" + "The following raised exceptions did not find a match\n" + " ExceptionGroup('', [TypeError(), RuntimeError()]):\n" + " RaisesGroup(ValueError, ValueError): \n" + " The following expected exceptions did not find a match:\n" + " 'ValueError'\n" + " 'ValueError'\n" + " The following raised exceptions did not find a match\n" + " TypeError():\n" + " 'TypeError' is not of type 'ValueError'\n" + " 'TypeError' is not of type 'ValueError'\n" + " RuntimeError():\n" + " 'RuntimeError' is not of type 'ValueError'\n" + " 'RuntimeError' is not of type 'ValueError'\n" + # TODO: this line is not great, should maybe follow the same format as the other and say + # 'ValueError': Unexpected nested 'ExceptionGroup' (?) + " Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + " TypeError():\n" + " RaisesGroup(ValueError, ValueError): 'TypeError' is not an exception group\n" + " 'TypeError' is not of type 'ValueError'", + add_prefix=False, + ), + RaisesGroup( + RaisesGroup(ValueError, ValueError), + ValueError, + ), + ): + raise ExceptionGroup( + "", + [ + ExceptionGroup("", [TypeError(), RuntimeError()]), + TypeError(), + ], + ) + with ( + fails_raises_group( + "Raised exception group did not match: \n" + "RaisesGroup(ValueError, ValueError): \n" + " The following expected exceptions did not find a match:\n" + " 'ValueError'\n" + " 'ValueError'\n" + " The following raised exceptions did not find a match\n" + " TypeError():\n" + " 'TypeError' is not of type 'ValueError'\n" + " 'TypeError' is not of type 'ValueError'\n" + " RuntimeError():\n" + " 'RuntimeError' is not of type 'ValueError'\n" + " 'RuntimeError' is not of type 'ValueError'", + add_prefix=False, + ), + RaisesGroup( + RaisesGroup(ValueError, ValueError), + ), + ): + raise ExceptionGroup( + "", + [ + ExceptionGroup("", [TypeError(), RuntimeError()]), + ], + ) + + +def test_suggestion_on_nested_and_brief_error() -> None: + # Make sure "Did you mean" suggestion gets indented iff it follows a single-line error + with ( + fails_raises_group( + "\n" + "The following expected exceptions did not find a match:\n" + " RaisesGroup(ValueError)\n" + " 'ValueError'\n" + "The following raised exceptions did not find a match\n" + " ExceptionGroup('', [ExceptionGroup('', [ValueError()])]):\n" + " RaisesGroup(ValueError): Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + " Did you mean to use `flatten_subgroups=True`?\n" + " Unexpected nested 'ExceptionGroup', expected 'ValueError'", + ), + RaisesGroup(RaisesGroup(ValueError), ValueError), + ): + raise ExceptionGroup( + "", + [ExceptionGroup("", [ExceptionGroup("", [ValueError()])])], + ) + # if indented here it would look like another raised exception + with ( + fails_raises_group( + "\n" + "The following expected exceptions did not find a match:\n" + " RaisesGroup(ValueError, ValueError)\n" + " 'ValueError'\n" + "The following raised exceptions did not find a match\n" + " ExceptionGroup('', [ValueError(), ExceptionGroup('', [ValueError()])]):\n" + " RaisesGroup(ValueError, ValueError): \n" + " 1 matched exception. \n" + " The following expected exceptions did not find a match:\n" + " 'ValueError'\n" + " It matches ValueError() which was paired with 'ValueError'\n" + " The following raised exceptions did not find a match\n" + " ExceptionGroup('', [ValueError()]):\n" + " Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + " Did you mean to use `flatten_subgroups=True`?\n" + " Unexpected nested 'ExceptionGroup', expected 'ValueError'" + ), + RaisesGroup(RaisesGroup(ValueError, ValueError), ValueError), + ): + raise ExceptionGroup( + "", + [ExceptionGroup("", [ValueError(), ExceptionGroup("", [ValueError()])])], + ) + + # re.escape always comes after single-line errors + with ( + fails_raises_group( + "\n" + "The following expected exceptions did not find a match:\n" + " RaisesGroup(Exception, match='^hello')\n" + " 'ValueError'\n" + "The following raised exceptions did not find a match\n" + " ExceptionGroup('^hello', [Exception()]):\n" + " RaisesGroup(Exception, match='^hello'): Regex pattern '^hello' did not match '^hello' of 'ExceptionGroup'\n" + " Did you mean to `re.escape()` the regex?\n" + " Unexpected nested 'ExceptionGroup', expected 'ValueError'" + ), + RaisesGroup(RaisesGroup(Exception, match="^hello"), ValueError), + ): + raise ExceptionGroup("", [ExceptionGroup("^hello", [Exception()])]) + + +def test_assert_message_nested() -> None: + # we only get one instance of aaaaaaaaaa... and bbbbbb..., but we do get multiple instances of ccccc... and dddddd.. + # but I think this now only prints the full repr when that is necessary to disambiguate exceptions + with ( + fails_raises_group( + "Raised exception group did not match: \n" + "The following expected exceptions did not find a match:\n" + " RaisesGroup(ValueError)\n" + " RaisesGroup(RaisesGroup(ValueError))\n" + " RaisesGroup(Matcher(TypeError, match='foo'))\n" + " RaisesGroup(TypeError, ValueError)\n" + "The following raised exceptions did not find a match\n" + " TypeError('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'):\n" + " RaisesGroup(ValueError): 'TypeError' is not an exception group\n" + " RaisesGroup(RaisesGroup(ValueError)): 'TypeError' is not an exception group\n" + " RaisesGroup(Matcher(TypeError, match='foo')): 'TypeError' is not an exception group\n" + " RaisesGroup(TypeError, ValueError): 'TypeError' is not an exception group\n" + " ExceptionGroup('Exceptions from Trio nursery', [TypeError('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb')]):\n" + " RaisesGroup(ValueError): 'TypeError' is not of type 'ValueError'\n" + " RaisesGroup(RaisesGroup(ValueError)): RaisesGroup(ValueError): 'TypeError' is not an exception group\n" + " RaisesGroup(Matcher(TypeError, match='foo')): Matcher(TypeError, match='foo'): Regex pattern 'foo' did not match 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'\n" + " RaisesGroup(TypeError, ValueError): 1 matched exception. Too few exceptions raised, found no match for: ['ValueError']\n" + " ExceptionGroup('Exceptions from Trio nursery', [TypeError('cccccccccccccccccccccccccccccc'), TypeError('dddddddddddddddddddddddddddddd')]):\n" + " RaisesGroup(ValueError): \n" + " The following expected exceptions did not find a match:\n" + " 'ValueError'\n" + " The following raised exceptions did not find a match\n" + " TypeError('cccccccccccccccccccccccccccccc'):\n" + " 'TypeError' is not of type 'ValueError'\n" + " TypeError('dddddddddddddddddddddddddddddd'):\n" + " 'TypeError' is not of type 'ValueError'\n" + " RaisesGroup(RaisesGroup(ValueError)): \n" + " The following expected exceptions did not find a match:\n" + " RaisesGroup(ValueError)\n" + " The following raised exceptions did not find a match\n" + " TypeError('cccccccccccccccccccccccccccccc'):\n" + " RaisesGroup(ValueError): 'TypeError' is not an exception group\n" + " TypeError('dddddddddddddddddddddddddddddd'):\n" + " RaisesGroup(ValueError): 'TypeError' is not an exception group\n" + " RaisesGroup(Matcher(TypeError, match='foo')): \n" + " The following expected exceptions did not find a match:\n" + " Matcher(TypeError, match='foo')\n" + " The following raised exceptions did not find a match\n" + " TypeError('cccccccccccccccccccccccccccccc'):\n" + " Matcher(TypeError, match='foo'): Regex pattern 'foo' did not match 'cccccccccccccccccccccccccccccc'\n" + " TypeError('dddddddddddddddddddddddddddddd'):\n" + " Matcher(TypeError, match='foo'): Regex pattern 'foo' did not match 'dddddddddddddddddddddddddddddd'\n" + " RaisesGroup(TypeError, ValueError): \n" + " 1 matched exception. \n" + " The following expected exceptions did not find a match:\n" + " 'ValueError'\n" + " The following raised exceptions did not find a match\n" + " TypeError('dddddddddddddddddddddddddddddd'):\n" + " It matches 'TypeError' which was paired with TypeError('cccccccccccccccccccccccccccccc')\n" + " 'TypeError' is not of type 'ValueError'", + add_prefix=False, # to see the full structure + ), + RaisesGroup( + RaisesGroup(ValueError), + RaisesGroup(RaisesGroup(ValueError)), + RaisesGroup(Matcher(TypeError, match="foo")), + RaisesGroup(TypeError, ValueError), + ), + ): + raise ExceptionGroup( + "", + [ + TypeError("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + ExceptionGroup( + "Exceptions from Trio nursery", + [TypeError("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")], + ), + ExceptionGroup( + "Exceptions from Trio nursery", + [ + TypeError("cccccccccccccccccccccccccccccc"), + TypeError("dddddddddddddddddddddddddddddd"), + ], + ), + ], + ) + + +@pytest.mark.skipif( + "hypothesis" in sys.modules, + reason="hypothesis may have monkeypatched _check_repr", +) +def test_check_no_patched_repr() -> None: + # We make `_check_repr` monkeypatchable to avoid this very ugly and verbose + # repr. The other tests that use `check` make use of `_check_repr` so they'll + # continue passing in case it is patched - but we have this one test that + # demonstrates just how nasty it gets otherwise. + match_str = ( + r"^Raised exception group did not match: \n" + r"The following expected exceptions did not find a match:\n" + r" Matcher\(check=. at .*>\)\n" + r" 'TypeError'\n" + r"The following raised exceptions did not find a match\n" + r" ValueError\('foo'\):\n" + r" Matcher\(check=. at .*>\): check did not return True\n" + r" 'ValueError' is not of type 'TypeError'\n" + r" ValueError\('bar'\):\n" + r" Matcher\(check=. at .*>\): check did not return True\n" + r" 'ValueError' is not of type 'TypeError'$" + ) + with ( + pytest.raises(Failed, match=match_str), + RaisesGroup(Matcher(check=lambda x: False), TypeError), + ): + raise ExceptionGroup("", [ValueError("foo"), ValueError("bar")]) + + +def test_misordering_example() -> None: + with ( + fails_raises_group( + "\n" + "3 matched exceptions. \n" + "The following expected exceptions did not find a match:\n" + " Matcher(ValueError, match='foo')\n" + " It matches ValueError('foo') which was paired with 'ValueError'\n" + " It matches ValueError('foo') which was paired with 'ValueError'\n" + " It matches ValueError('foo') which was paired with 'ValueError'\n" + "The following raised exceptions did not find a match\n" + " ValueError('bar'):\n" + " It matches 'ValueError' which was paired with ValueError('foo')\n" + " It matches 'ValueError' which was paired with ValueError('foo')\n" + " It matches 'ValueError' which was paired with ValueError('foo')\n" + " Matcher(ValueError, match='foo'): Regex pattern 'foo' did not match 'bar'\n" + "There exist a possible match when attempting an exhaustive check, but RaisesGroup uses a greedy algorithm. Please make your expected exceptions more stringent with `Matcher` etc so the greedy algorithm can function." + ), + RaisesGroup( + ValueError, ValueError, ValueError, Matcher(ValueError, match="foo") + ), + ): + raise ExceptionGroup( + "", + [ + ValueError("foo"), + ValueError("foo"), + ValueError("foo"), + ValueError("bar"), + ], + ) + + +def test_brief_error_on_one_fail() -> None: + """If only one raised and one expected fail to match up, we print a full table iff + the raised exception would match one of the expected that previously got matched""" + # no also-matched + with ( + fails_raises_group( + "1 matched exception. 'TypeError' is not of type 'RuntimeError'" + ), + RaisesGroup(ValueError, RuntimeError), + ): + raise ExceptionGroup("", [ValueError(), TypeError()]) + + # raised would match an expected + with ( + fails_raises_group( + "\n" + "1 matched exception. \n" + "The following expected exceptions did not find a match:\n" + " 'RuntimeError'\n" + "The following raised exceptions did not find a match\n" + " TypeError():\n" + " It matches 'Exception' which was paired with ValueError()\n" + " 'TypeError' is not of type 'RuntimeError'" + ), + RaisesGroup(Exception, RuntimeError), + ): + raise ExceptionGroup("", [ValueError(), TypeError()]) + + # expected would match a raised + with ( + fails_raises_group( + "\n" + "1 matched exception. \n" + "The following expected exceptions did not find a match:\n" + " 'ValueError'\n" + " It matches ValueError() which was paired with 'ValueError'\n" + "The following raised exceptions did not find a match\n" + " TypeError():\n" + " 'TypeError' is not of type 'ValueError'" + ), + RaisesGroup(ValueError, ValueError), + ): + raise ExceptionGroup("", [ValueError(), TypeError()]) + + +def test_identity_oopsies() -> None: + # it's both possible to have several instances of the same exception in the same group + # and to expect multiple of the same type + # this previously messed up the logic + + with ( + fails_raises_group( + "3 matched exceptions. 'RuntimeError' is not of type 'TypeError'" + ), + RaisesGroup(ValueError, ValueError, ValueError, TypeError), + ): + raise ExceptionGroup( + "", [ValueError(), ValueError(), ValueError(), RuntimeError()] + ) + + e = ValueError("foo") + m = Matcher(match="bar") + with ( + fails_raises_group( + "\n" + "The following expected exceptions did not find a match:\n" + " Matcher(match='bar')\n" + " Matcher(match='bar')\n" + " Matcher(match='bar')\n" + "The following raised exceptions did not find a match\n" + " ValueError('foo'):\n" + " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " ValueError('foo'):\n" + " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " ValueError('foo'):\n" + " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'" + ), + RaisesGroup(m, m, m), + ): + raise ExceptionGroup("", [e, e, e]) + + +def test_matcher() -> None: + with pytest.raises( + ValueError, + match=r"^You must specify at least one parameter to match on.$", + ): + Matcher() # type: ignore[call-overload] + with pytest.raises( + TypeError, + match=f"^exception_type {re.escape(repr(object))} must be a subclass of BaseException$", + ): + Matcher(object) # type: ignore[type-var] + + with RaisesGroup(Matcher(ValueError)): + raise ExceptionGroup("", (ValueError(),)) + with ( + fails_raises_group( + "Matcher(TypeError): 'ValueError' is not of type 'TypeError'" + ), + RaisesGroup(Matcher(TypeError)), + ): + raise ExceptionGroup("", (ValueError(),)) + + +def test_matcher_match() -> None: + with RaisesGroup(Matcher(ValueError, "foo")): + raise ExceptionGroup("", (ValueError("foo"),)) + with ( + fails_raises_group( + "Matcher(ValueError, match='foo'): Regex pattern 'foo' did not match 'bar'" + ), + RaisesGroup(Matcher(ValueError, "foo")), + ): + raise ExceptionGroup("", (ValueError("bar"),)) + + # Can be used without specifying the type + with RaisesGroup(Matcher(match="foo")): + raise ExceptionGroup("", (ValueError("foo"),)) + with ( + fails_raises_group( + "Matcher(match='foo'): Regex pattern 'foo' did not match 'bar'" + ), + RaisesGroup(Matcher(match="foo")), + ): + raise ExceptionGroup("", (ValueError("bar"),)) + + # check ^$ + with RaisesGroup(Matcher(ValueError, match="^bar$")): + raise ExceptionGroup("", [ValueError("bar")]) + with ( + fails_raises_group( + "Matcher(ValueError, match='^bar$'): Regex pattern '^bar$' did not match 'barr'" + ), + RaisesGroup(Matcher(ValueError, match="^bar$")), + ): + raise ExceptionGroup("", [ValueError("barr")]) + + +def test_Matcher_check() -> None: + def check_oserror_and_errno_is_5(e: BaseException) -> bool: + return isinstance(e, OSError) and e.errno == 5 + + with RaisesGroup(Matcher(check=check_oserror_and_errno_is_5)): + raise ExceptionGroup("", (OSError(5, ""),)) + + # specifying exception_type narrows the parameter type to the callable + def check_errno_is_5(e: OSError) -> bool: + return e.errno == 5 + + with RaisesGroup(Matcher(OSError, check=check_errno_is_5)): + raise ExceptionGroup("", (OSError(5, ""),)) + + # avoid printing overly verbose repr multiple times + with ( + fails_raises_group( + f"Matcher(OSError, check={check_errno_is_5!r}): check did not return True" + ), + RaisesGroup(Matcher(OSError, check=check_errno_is_5)), + ): + raise ExceptionGroup("", (OSError(6, ""),)) + + # in nested cases you still get it multiple times though + # to address this you'd need logic in Matcher.__repr__ and RaisesGroup.__repr__ + with ( + fails_raises_group( + f"RaisesGroup(Matcher(OSError, check={check_errno_is_5!r})): Matcher(OSError, check={check_errno_is_5!r}): check did not return True" + ), + RaisesGroup(RaisesGroup(Matcher(OSError, check=check_errno_is_5))), + ): + raise ExceptionGroup("", [ExceptionGroup("", [OSError(6, "")])]) + + +def test_matcher_tostring() -> None: + assert str(Matcher(ValueError)) == "Matcher(ValueError)" + assert str(Matcher(match="[a-z]")) == "Matcher(match='[a-z]')" + pattern_no_flags = re.compile(r"noflag", 0) + assert str(Matcher(match=pattern_no_flags)) == "Matcher(match='noflag')" + pattern_flags = re.compile(r"noflag", re.IGNORECASE) + assert str(Matcher(match=pattern_flags)) == f"Matcher(match={pattern_flags!r})" + assert ( + str(Matcher(ValueError, match="re", check=bool)) + == f"Matcher(ValueError, match='re', check={bool!r})" + ) + + +def test_raisesgroup_tostring() -> None: + def check_str_and_repr(s: str) -> None: + evaled = eval(s) + assert s == str(evaled) == repr(evaled) + + check_str_and_repr("RaisesGroup(ValueError)") + check_str_and_repr("RaisesGroup(RaisesGroup(ValueError))") + check_str_and_repr("RaisesGroup(Matcher(ValueError))") + check_str_and_repr("RaisesGroup(ValueError, allow_unwrapped=True)") + check_str_and_repr("RaisesGroup(ValueError, match='aoeu')") + + assert ( + str(RaisesGroup(ValueError, match="[a-z]", check=bool)) + == f"RaisesGroup(ValueError, match='[a-z]', check={bool!r})" + ) + + +def test_assert_matches() -> None: + e = ValueError() + + # it's easy to do this + assert Matcher(ValueError).matches(e) + + # but you don't get a helpful error + with pytest.raises(AssertionError, match=r"assert False\n \+ where False = .*"): + assert Matcher(TypeError).matches(e) + + # you'd need to do this arcane incantation + with pytest.raises(AssertionError, match="'ValueError' is not of type 'TypeError'"): + assert (m := Matcher(TypeError)).matches(e), m.fail_reason + + # but even if we add assert_matches, will people remember to use it? + # other than writing a linter rule, I don't think we can catch `assert Matcher(...).matches` diff --git a/testing/typing_raises_group.py b/testing/typing_raises_group.py new file mode 100644 index 00000000000..2dc35031dac --- /dev/null +++ b/testing/typing_raises_group.py @@ -0,0 +1,234 @@ +from __future__ import annotations + +import sys +from typing import Callable +from typing import Union + +from typing_extensions import assert_type + +from _pytest._raises_group import Matcher +from _pytest._raises_group import RaisesGroup + + +if sys.version_info < (3, 11): + from exceptiongroup import BaseExceptionGroup + from exceptiongroup import ExceptionGroup + +# split into functions to isolate the different scopes + + +def check_matcher_typevar_default(e: Matcher) -> None: + assert e.exception_type is not None + _exc: type[BaseException] = e.exception_type + # this would previously pass, as the type would be `Any` + e.exception_type().blah() # type: ignore + + +def check_basic_contextmanager() -> None: + with RaisesGroup(ValueError) as e: + raise ExceptionGroup("foo", (ValueError(),)) + assert_type(e.value, ExceptionGroup[ValueError]) + + +def check_basic_matches() -> None: + # check that matches gets rid of the naked ValueError in the union + exc: ExceptionGroup[ValueError] | ValueError = ExceptionGroup("", (ValueError(),)) + if RaisesGroup(ValueError).matches(exc): + assert_type(exc, ExceptionGroup[ValueError]) + + # also check that BaseExceptionGroup shows up for BaseExceptions + if RaisesGroup(KeyboardInterrupt).matches(exc): + assert_type(exc, BaseExceptionGroup[KeyboardInterrupt]) + + +def check_matches_with_different_exception_type() -> None: + e: BaseExceptionGroup[KeyboardInterrupt] = BaseExceptionGroup( + "", + (KeyboardInterrupt(),), + ) + + # note: it might be tempting to have this warn. + # however, that isn't possible with current typing + if RaisesGroup(ValueError).matches(e): + assert_type(e, ExceptionGroup[ValueError]) + + +def check_matcher_init() -> None: + def check_exc(exc: BaseException) -> bool: + return isinstance(exc, ValueError) + + # Check various combinations of constructor signatures. + # At least 1 arg must be provided. + Matcher() # type: ignore + Matcher(ValueError) + Matcher(ValueError, "regex") + Matcher(ValueError, "regex", check_exc) + Matcher(exception_type=ValueError) + Matcher(match="regex") + Matcher(check=check_exc) + Matcher(ValueError, match="regex") + Matcher(match="regex", check=check_exc) + + def check_filenotfound(exc: FileNotFoundError) -> bool: + return not exc.filename.endswith(".tmp") + + # If exception_type is provided, that narrows the `check` method's argument. + Matcher(FileNotFoundError, check=check_filenotfound) + Matcher(ValueError, check=check_filenotfound) # type: ignore + Matcher(check=check_filenotfound) # type: ignore + Matcher(FileNotFoundError, match="regex", check=check_filenotfound) + + +def raisesgroup_check_type_narrowing() -> None: + """Check type narrowing on the `check` argument to `RaisesGroup`. + All `type: ignore`s are correctly pointing out type errors. + """ + + def handle_exc(e: BaseExceptionGroup[BaseException]) -> bool: + return True + + def handle_kbi(e: BaseExceptionGroup[KeyboardInterrupt]) -> bool: + return True + + def handle_value(e: BaseExceptionGroup[ValueError]) -> bool: + return True + + RaisesGroup(BaseException, check=handle_exc) + RaisesGroup(BaseException, check=handle_kbi) # type: ignore + + RaisesGroup(Exception, check=handle_exc) + RaisesGroup(Exception, check=handle_value) # type: ignore + + RaisesGroup(KeyboardInterrupt, check=handle_exc) + RaisesGroup(KeyboardInterrupt, check=handle_kbi) + RaisesGroup(KeyboardInterrupt, check=handle_value) # type: ignore + + RaisesGroup(ValueError, check=handle_exc) + RaisesGroup(ValueError, check=handle_kbi) # type: ignore + RaisesGroup(ValueError, check=handle_value) + + RaisesGroup(ValueError, KeyboardInterrupt, check=handle_exc) + RaisesGroup(ValueError, KeyboardInterrupt, check=handle_kbi) # type: ignore + RaisesGroup(ValueError, KeyboardInterrupt, check=handle_value) # type: ignore + + +def raisesgroup_narrow_baseexceptiongroup() -> None: + """Check type narrowing specifically for the container exceptiongroup.""" + + def handle_group(e: ExceptionGroup[Exception]) -> bool: + return True + + def handle_group_value(e: ExceptionGroup[ValueError]) -> bool: + return True + + RaisesGroup(ValueError, check=handle_group_value) + + RaisesGroup(Exception, check=handle_group) + + +def check_matcher_transparent() -> None: + with RaisesGroup(Matcher(ValueError)) as e: + ... + _: BaseExceptionGroup[ValueError] = e.value + assert_type(e.value, ExceptionGroup[ValueError]) + + +def check_nested_raisesgroups_contextmanager() -> None: + with RaisesGroup(RaisesGroup(ValueError)) as excinfo: + raise ExceptionGroup("foo", (ValueError(),)) + + _: BaseExceptionGroup[BaseExceptionGroup[ValueError]] = excinfo.value + + assert_type( + excinfo.value, + ExceptionGroup[ExceptionGroup[ValueError]], + ) + + assert_type( + excinfo.value.exceptions[0], + # this union is because of how typeshed defines .exceptions + Union[ + ExceptionGroup[ValueError], + ExceptionGroup[ExceptionGroup[ValueError]], + ], + ) + + +def check_nested_raisesgroups_matches() -> None: + """Check nested RaisesGroups with .matches""" + exc: ExceptionGroup[ExceptionGroup[ValueError]] = ExceptionGroup( + "", + (ExceptionGroup("", (ValueError(),)),), + ) + + if RaisesGroup(RaisesGroup(ValueError)).matches(exc): + assert_type(exc, ExceptionGroup[ExceptionGroup[ValueError]]) + + +def check_multiple_exceptions_1() -> None: + a = RaisesGroup(ValueError, ValueError) + b = RaisesGroup(Matcher(ValueError), Matcher(ValueError)) + c = RaisesGroup(ValueError, Matcher(ValueError)) + + d: RaisesGroup[ValueError] + d = a + d = b + d = c + assert d + + +def check_multiple_exceptions_2() -> None: + # This previously failed due to lack of covariance in the TypeVar + a = RaisesGroup(Matcher(ValueError), Matcher(TypeError)) + b = RaisesGroup(Matcher(ValueError), TypeError) + c = RaisesGroup(ValueError, TypeError) + + d: RaisesGroup[Exception] + d = a + d = b + d = c + assert d + + +def check_raisesgroup_overloads() -> None: + # allow_unwrapped=True does not allow: + # multiple exceptions + RaisesGroup(ValueError, TypeError, allow_unwrapped=True) # type: ignore + # nested RaisesGroup + RaisesGroup(RaisesGroup(ValueError), allow_unwrapped=True) # type: ignore + # specifying match + RaisesGroup(ValueError, match="foo", allow_unwrapped=True) # type: ignore + # specifying check + RaisesGroup(ValueError, check=bool, allow_unwrapped=True) # type: ignore + # allowed variants + RaisesGroup(ValueError, allow_unwrapped=True) + RaisesGroup(ValueError, allow_unwrapped=True, flatten_subgroups=True) + RaisesGroup(Matcher(ValueError), allow_unwrapped=True) + + # flatten_subgroups=True does not allow nested RaisesGroup + RaisesGroup(RaisesGroup(ValueError), flatten_subgroups=True) # type: ignore + # but rest is plenty fine + RaisesGroup(ValueError, TypeError, flatten_subgroups=True) + RaisesGroup(ValueError, match="foo", flatten_subgroups=True) + RaisesGroup(ValueError, check=bool, flatten_subgroups=True) + RaisesGroup(ValueError, flatten_subgroups=True) + RaisesGroup(Matcher(ValueError), flatten_subgroups=True) + + # if they're both false we can of course specify nested raisesgroup + RaisesGroup(RaisesGroup(ValueError)) + + +def check_triple_nested_raisesgroup() -> None: + with RaisesGroup(RaisesGroup(RaisesGroup(ValueError))) as e: + assert_type(e.value, ExceptionGroup[ExceptionGroup[ExceptionGroup[ValueError]]]) + + +def check_check_typing() -> None: + # `BaseExceptiongroup` should perhaps be `ExceptionGroup`, but close enough + assert_type( + RaisesGroup(ValueError).check, + Union[ + Callable[[BaseExceptionGroup[ValueError]], bool], + None, + ], + ) From 4737c8cf95eb6b65d936d51479d29dbbfa009575 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Tue, 4 Feb 2025 15:33:06 +0100 Subject: [PATCH 290/445] add AbstractMatcher support to xfail --- src/_pytest/mark/structures.py | 6 +++++- src/_pytest/skipping.py | 23 +++++++++++++++++++---- testing/python/raises_group.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 1a0b3c5b5b8..b5f54d559e5 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -23,6 +23,7 @@ from .._code import getfslineno from ..compat import NOTSET from ..compat import NotSetType +from _pytest._raises_group import AbstractMatcher from _pytest.config import Config from _pytest.deprecated import check_ispytest from _pytest.deprecated import MARKED_FIXTURE @@ -459,7 +460,10 @@ def __call__( *conditions: str | bool, reason: str = ..., run: bool = ..., - raises: None | type[BaseException] | tuple[type[BaseException], ...] = ..., + raises: None + | type[BaseException] + | tuple[type[BaseException], ...] + | AbstractMatcher[BaseException] = ..., strict: bool = ..., ) -> MarkDecorator: ... diff --git a/src/_pytest/skipping.py b/src/_pytest/skipping.py index d21be181955..0736f48aa45 100644 --- a/src/_pytest/skipping.py +++ b/src/_pytest/skipping.py @@ -12,6 +12,7 @@ import traceback from typing import Optional +from _pytest._raises_group import AbstractMatcher from _pytest.config import Config from _pytest.config import hookimpl from _pytest.config.argparsing import Parser @@ -201,7 +202,12 @@ class Xfail: reason: str run: bool strict: bool - raises: tuple[type[BaseException], ...] | None + raises: ( + type[BaseException] + | tuple[type[BaseException], ...] + | AbstractMatcher[BaseException] + | None + ) def evaluate_xfail_marks(item: Item) -> Xfail | None: @@ -277,11 +283,20 @@ def pytest_runtest_makereport( elif not rep.skipped and xfailed: if call.excinfo: raises = xfailed.raises - if raises is not None and not isinstance(call.excinfo.value, raises): - rep.outcome = "failed" - else: + if raises is None or ( + ( + isinstance(raises, (type, tuple)) + and isinstance(call.excinfo.value, raises) + ) + or ( + isinstance(raises, AbstractMatcher) + and raises.matches(call.excinfo.value) + ) + ): rep.outcome = "skipped" rep.wasxfail = xfailed.reason + else: + rep.outcome = "failed" elif call.when == "call": if xfailed.strict: rep.outcome = "failed" diff --git a/testing/python/raises_group.py b/testing/python/raises_group.py index c10398d0b9e..73715ee1c21 100644 --- a/testing/python/raises_group.py +++ b/testing/python/raises_group.py @@ -11,6 +11,7 @@ from _pytest._raises_group import RaisesGroup from _pytest._raises_group import repr_callable from _pytest.outcomes import Failed +from _pytest.pytester import Pytester import pytest @@ -1135,3 +1136,30 @@ def test_assert_matches() -> None: # but even if we add assert_matches, will people remember to use it? # other than writing a linter rule, I don't think we can catch `assert Matcher(...).matches` + + +# https://github.com/pytest-dev/pytest/issues/12504 +def test_xfail_raisesgroup(pytester: Pytester) -> None: + pytester.makepyfile( + """ + import pytest + @pytest.mark.xfail(raises=pytest.RaisesGroup(ValueError)) + def test_foo() -> None: + raise ExceptionGroup("foo", [ValueError()]) + """ + ) + result = pytester.runpytest() + result.assert_outcomes(xfailed=1) + + +def test_xfail_Matcher(pytester: Pytester) -> None: + pytester.makepyfile( + """ + import pytest + @pytest.mark.xfail(raises=pytest.Matcher(ValueError)) + def test_foo() -> None: + raise ValueError + """ + ) + result = pytester.runpytest() + result.assert_outcomes(xfailed=1) From 1f1a10c0da051ada2cbb04d1592d0e14f6de1ac6 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 5 Feb 2025 16:11:40 +0100 Subject: [PATCH 291/445] doc: Change training to remote only (#13196) --- doc/en/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/index.rst b/doc/en/index.rst index 8b34d589643..7f3dbdd800d 100644 --- a/doc/en/index.rst +++ b/doc/en/index.rst @@ -2,7 +2,7 @@ .. sidebar:: **Next Open Trainings and Events** - - `Professional Testing with Python `_, via `Python Academy `_ (3 day in-depth training), **March 4th -- 6th 2025**, Leipzig (DE) / Remote + - `Professional Testing with Python `_, via `Python Academy `_ (3 day in-depth training), **March 4th -- 6th 2025**, Remote Also see :doc:`previous talks and blogposts ` From e1e1874cda7b8ee51172092158ab774960fa8d6c Mon Sep 17 00:00:00 2001 From: jakkdl <11260241+jakkdl@users.noreply.github.com> Date: Thu, 6 Feb 2025 15:39:25 +0100 Subject: [PATCH 292/445] rename AbstractMatcher -> AbstractRaises, Matcher->RaisesExc. Add docs on RaisesGroup&RaisesExc. Add warnings to group_contains. Remove group_contains example from getting-started page --- changelog/11538.feature.rst | 1 + changelog/11671.feature.rst | 1 - changelog/12504.feature.rst | 1 + doc/en/conf.py | 2 + doc/en/getting-started.rst | 26 +---- doc/en/how-to/assert.rst | 89 +++++++++++++- doc/en/reference/reference.rst | 12 ++ src/_pytest/_code/code.py | 7 ++ src/_pytest/_raises_group.py | 126 ++++++++++---------- src/_pytest/mark/structures.py | 4 +- src/_pytest/python_api.py | 5 + src/_pytest/skipping.py | 6 +- src/pytest/__init__.py | 4 +- testing/python/raises_group.py | 208 ++++++++++++++++++--------------- testing/typing_raises_group.py | 48 ++++---- 15 files changed, 325 insertions(+), 215 deletions(-) create mode 100644 changelog/11538.feature.rst delete mode 100644 changelog/11671.feature.rst create mode 100644 changelog/12504.feature.rst diff --git a/changelog/11538.feature.rst b/changelog/11538.feature.rst new file mode 100644 index 00000000000..60f191d05cb --- /dev/null +++ b/changelog/11538.feature.rst @@ -0,0 +1 @@ +Added :class:`pytest.RaisesGroup` (also export as ``pytest.raises_group``) and :class:`pytest.RaisesExc`, as an equivalent to :func:`pytest.raises` for expecting :exc:`ExceptionGroup`. It includes the ability to specify multiple different expected exceptions, the structure of nested exception groups, and flags for emulating :ref:`except* `. See :ref:`assert-matching-exception-groups` and docstrings for more information. diff --git a/changelog/11671.feature.rst b/changelog/11671.feature.rst deleted file mode 100644 index 9e401112ad0..00000000000 --- a/changelog/11671.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Added `RaisesGroup` (also available as `raises_group`) and `Matcher`, as an equivalent to `raises` for expecting `ExceptionGroup`. It includes the ability to specity multiple different expected exceptions, the structure of nested exception groups, and/or closely emulating `except_star`. diff --git a/changelog/12504.feature.rst b/changelog/12504.feature.rst new file mode 100644 index 00000000000..d72b97958c2 --- /dev/null +++ b/changelog/12504.feature.rst @@ -0,0 +1 @@ +:func:`pytest.mark.xfail` now accepts :class:`pytest.RaisesGroup` for the ``raises`` parameter when you expect an exception group. You can also pass a :class:`pytest.RaisesExc` if you e.g. want to make use of the ``check`` parameter. diff --git a/doc/en/conf.py b/doc/en/conf.py index 47fc70dce85..c89e14d07fa 100644 --- a/doc/en/conf.py +++ b/doc/en/conf.py @@ -106,6 +106,8 @@ ("py:obj", "_pytest.fixtures.FixtureValue"), ("py:obj", "_pytest.stash.T"), ("py:class", "_ScopeName"), + ("py:class", "BaseExcT_1"), + ("py:class", "ExcT_1"), ] add_module_names = False diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index faf81154c48..73ce82f6b7c 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -97,30 +97,6 @@ Use the :ref:`raises ` helper to assert that some code raises an e with pytest.raises(SystemExit): f() -You can also use the context provided by :ref:`raises ` to -assert that an expected exception is part of a raised :class:`ExceptionGroup`: - -.. code-block:: python - - # content of test_exceptiongroup.py - import pytest - - - def f(): - raise ExceptionGroup( - "Group message", - [ - RuntimeError(), - ], - ) - - - def test_exception_in_group(): - with pytest.raises(ExceptionGroup) as excinfo: - f() - assert excinfo.group_contains(RuntimeError) - assert not excinfo.group_contains(TypeError) - Execute the test function with “quiet” reporting mode: .. code-block:: pytest @@ -133,6 +109,8 @@ Execute the test function with “quiet” reporting mode: The ``-q/--quiet`` flag keeps the output brief in this and following examples. +See :ref:`assertraises` for specifying more details about the expected exception. + Group multiple tests in a class -------------------------------------------------------------- diff --git a/doc/en/how-to/assert.rst b/doc/en/how-to/assert.rst index 7b027744695..08e030b8cab 100644 --- a/doc/en/how-to/assert.rst +++ b/doc/en/how-to/assert.rst @@ -145,8 +145,93 @@ Notes: .. _`assert-matching-exception-groups`: -Matching exception groups -~~~~~~~~~~~~~~~~~~~~~~~~~ +Assertions about expected exception groups +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +When expecting a :exc:`BaseExceptionGroup` or :exc:`ExceptionGroup` you can use :class:`pytest.RaisesGroup`, also available as :class:`pytest.raises_group `: + +.. code-block:: python + + def test_exception_in_group(): + with pytest.raises_group(ValueError): + raise ExceptionGroup("group msg", [ValueError("value msg")]) + with pytest.raises_group(ValueError, TypeError): + raise ExceptionGroup("msg", [ValueError("foo"), TypeError("bar")]) + + +It accepts a ``match`` parameter, that checks against the group message, and a ``check`` parameter that takes an arbitrary callable which it passes the group to, and only succeeds if the callable returns ``True``. + +.. code-block:: python + + def test_raisesgroup_match_and_check(): + with pytest.raises_group(BaseException, match="my group msg"): + raise BaseExceptionGroup("my group msg", [KeyboardInterrupt()]) + with pytest.raises_group( + Exception, check=lambda eg: isinstance(eg.__cause__, ValueError) + ): + raise ExceptionGroup("", [TypeError()]) from ValueError() + +It is strict about structure and unwrapped exceptions, unlike :ref:`except* `, so you might want to set the ``flatten_subgroups`` and/or ``allow_unwrapped`` parameters. + +.. code-block:: python + + def test_structure(): + with pytest.raises_group(pytest.raises_group(ValueError)): + raise ExceptionGroup("", (ExceptionGroup("", (ValueError(),)),)) + with pytest.raises_group(ValueError, flatten_subgroups=True): + raise ExceptionGroup("1st group", [ExceptionGroup("2nd group", [ValueError()])]) + with pytest.raises_group(ValueError, allow_unwrapped=True): + raise ValueError + +To specify more details about the contained exception you can use :class:`pytest.RaisesExc` + +.. code-block:: python + + def test_raises_exc(): + with pytest.raises_group(pytest.RaisesExc(ValueError, match="foo")): + raise ExceptionGroup("", (ValueError("foo"))) + +They both supply a method :meth:`pytest.RaisesGroup.matches` :meth:`pytest.RaisesExc.matches` if you want to do matching outside of using it as a contextmanager. This can be helpful when checking ``.__context__`` or ``.__cause__``. + +.. code-block:: python + + def test_matches(): + exc = ValueError() + exc_group = ExceptionGroup("", [exc]) + if RaisesGroup(ValueError).matches(exc_group): + ... + # helpful error is available in `.fail_reason` if it fails to match + r = RaisesExc(ValueError) + assert r.matches(e), r.fail_reason + +Check the documentation on :class:`pytest.RaisesGroup` and :class:`pytest.RaisesExc` for more details and examples. + +``ExceptionInfo.group_contains()`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. warning:: + + This helper makes it easy to check for the presence of specific exceptions, but it is very bad for checking that the group does *not* contain *any other exceptions*. So this will pass: + + .. code-block:: python + + class EXTREMELYBADERROR(BaseException): + """This is a very bad error to miss""" + + + def test_for_value_error(): + with pytest.raises(ExceptionGroup) as excinfo: + excs = [ValueError()] + if very_unlucky(): + excs.append(EXTREMELYBADERROR()) + raise ExceptionGroup("", excs) + # this passes regardless of if there's other exceptions + assert excinfo.group_contains(ValueError) + # you can't simply list all exceptions you *don't* want to get here + + + There is no good way of using :func:`excinfo.group_contains() ` to ensure you're not getting *any* other exceptions than the one you expected. + You should instead use :class:`pytest.raises_group `, see :ref:`assert-matching-exception-groups`. You can also use the :func:`excinfo.group_contains() ` method to test for exceptions returned as part of an :class:`ExceptionGroup`: diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 809e97b4747..d7cf09100b7 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1014,6 +1014,18 @@ PytestPluginManager :inherited-members: :show-inheritance: +RaisesExc +~~~~~~~~~ + +.. autoclass:: pytest.RaisesExc() + :members: + +RaisesGroup +~~~~~~~~~~~ + +.. autoclass:: pytest.RaisesGroup() + :members: + TerminalReporter ~~~~~~~~~~~~~~~~ diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index f812f0633c8..5b85d295d36 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -828,6 +828,13 @@ def group_contains( the exceptions contained within the topmost exception group). .. versionadded:: 8.0 + + .. warning:: + This helper makes it easy to check for the presence of specific exceptions, + but it is very bad for checking that the group does *not* contain + *any other exceptions*. + You should instead consider using :class:`pytest.raises_group ` + """ msg = "Captured exception is not an instance of `BaseExceptionGroup`" assert isinstance(self.value, BaseExceptionGroup), msg diff --git a/src/_pytest/_raises_group.py b/src/_pytest/_raises_group.py index 68303c4a3fe..db4e51fc211 100644 --- a/src/_pytest/_raises_group.py +++ b/src/_pytest/_raises_group.py @@ -28,8 +28,8 @@ from typing_extensions import TypeVar # this conditional definition is because we want to allow a TypeVar default - MatchE = TypeVar( - "MatchE", + BaseExcT_co_default = TypeVar( + "BaseExcT_co_default", bound=BaseException, default=BaseException, covariant=True, @@ -37,7 +37,9 @@ else: from typing import TypeVar - MatchE = TypeVar("MatchE", bound=BaseException, covariant=True) + BaseExcT_co_default = TypeVar( + "BaseExcT_co_default", bound=BaseException, covariant=True + ) # RaisesGroup doesn't work with a default. BaseExcT_co = TypeVar("BaseExcT_co", bound=BaseException, covariant=True) @@ -104,8 +106,8 @@ def _check_raw_type( return None -class AbstractMatcher(ABC, Generic[BaseExcT_co]): - """ABC with common functionality shared between Matcher and RaisesGroup""" +class AbstractRaises(ABC, Generic[BaseExcT_co]): + """ABC with common functionality shared between RaisesExc and RaisesGroup""" def __init__( self, @@ -130,7 +132,7 @@ def fail_reason(self) -> str | None: return self._fail_reason def _check_check( - self: AbstractMatcher[BaseExcT_1], + self: AbstractRaises[BaseExcT_1], exception: BaseExcT_1, ) -> bool: if self.check is None: @@ -165,29 +167,29 @@ def _check_match(self, e: BaseException) -> bool: @abstractmethod def matches( - self: AbstractMatcher[BaseExcT_1], exc_val: BaseException + self: AbstractRaises[BaseExcT_1], exc_val: BaseException ) -> TypeGuard[BaseExcT_1]: - """Check if an exception matches the requirements of this AbstractMatcher. - If it fails, `AbstractMatcher.fail_reason` should be set. + """Check if an exception matches the requirements of this AbstractRaises. + If it fails, `AbstractRaises.fail_reason` should be set. """ @final -class Matcher(AbstractMatcher[MatchE]): +class RaisesExc(AbstractRaises[BaseExcT_co_default]): """Helper class to be used together with RaisesGroups when you want to specify requirements on sub-exceptions. Only specifying the type is redundant, and it's also unnecessary when the type is a nested `RaisesGroup` since it supports the same arguments. The type is checked with `isinstance`, and does not need to be an exact match. If that is wanted you can use the ``check`` parameter. - :meth:`Matcher.matches` can also be used standalone to check individual exceptions. + :meth:`RaisesExc.matches` can also be used standalone to check individual exceptions. Examples:: - with RaisesGroups(Matcher(ValueError, match="string")) + with RaisesGroups(RaisesExc(ValueError, match="string")) ... - with RaisesGroups(Matcher(check=lambda x: x.args == (3, "hello"))): + with RaisesGroups(RaisesExc(check=lambda x: x.args == (3, "hello"))): ... - with RaisesGroups(Matcher(check=lambda x: type(x) is ValueError)): + with RaisesGroups(RaisesExc(check=lambda x: type(x) is ValueError)): ... Tip: if you install ``hypothesis`` and import it in ``conftest.py`` you will get @@ -202,15 +204,15 @@ class Matcher(AbstractMatcher[MatchE]): # At least one of the three parameters must be passed. @overload def __init__( - self: Matcher[MatchE], - exception_type: type[MatchE], + self: RaisesExc[BaseExcT_co_default], + exception_type: type[BaseExcT_co_default], match: str | Pattern[str] = ..., - check: Callable[[MatchE], bool] = ..., + check: Callable[[BaseExcT_co_default], bool] = ..., ) -> None: ... @overload def __init__( - self: Matcher[BaseException], # Give E a value. + self: RaisesExc[BaseException], # Give E a value. *, match: str | Pattern[str], # If exception_type is not provided, check() must do any typechecks itself. @@ -222,9 +224,9 @@ def __init__(self, *, check: Callable[[BaseException], bool]) -> None: ... def __init__( self, - exception_type: type[MatchE] | None = None, + exception_type: type[BaseExcT_co_default] | None = None, match: str | Pattern[str] | None = None, - check: Callable[[MatchE], bool] | None = None, + check: Callable[[BaseExcT_co_default], bool] | None = None, ): super().__init__(match, check) if exception_type is None and match is None and check is None: @@ -238,20 +240,20 @@ def __init__( def matches( self, exception: BaseException, - ) -> TypeGuard[MatchE]: - """Check if an exception matches the requirements of this Matcher. - If it fails, `Matcher.fail_reason` will be set. + ) -> TypeGuard[BaseExcT_co_default]: + """Check if an exception matches the requirements of this RaisesExc. + If it fails, `RaisesExc.fail_reason` will be set. Examples:: - assert Matcher(ValueError).matches(my_exception): + assert RaisesExc(ValueError).matches(my_exception): # is equivalent to assert isinstance(my_exception, ValueError) # this can be useful when checking e.g. the ``__cause__`` of an exception. with pytest.raises(ValueError) as excinfo: ... - assert Matcher(SyntaxError, match="foo").matches(excinfo.value.__cause__) + assert RaisesExc(SyntaxError, match="foo").matches(excinfo.value.__cause__) # above line is equivalent to assert isinstance(excinfo.value.__cause__, SyntaxError) assert re.search("foo", str(excinfo.value.__cause__) @@ -276,15 +278,15 @@ def __repr__(self) -> str: ) if self.check is not None: parameters.append(f"check={repr_callable(self.check)}") - return f"Matcher({', '.join(parameters)})" + return f"RaisesExc({', '.join(parameters)})" - def _check_type(self, exception: BaseException) -> TypeGuard[MatchE]: + def _check_type(self, exception: BaseException) -> TypeGuard[BaseExcT_co_default]: self._fail_reason = _check_raw_type(self.exception_type, exception) return self._fail_reason is None @final -class RaisesGroup(AbstractMatcher[BaseExceptionGroup[BaseExcT_co]]): +class RaisesGroup(AbstractRaises[BaseExceptionGroup[BaseExcT_co]]): """Contextmanager for checking for an expected `ExceptionGroup`. This works similar to ``pytest.raises``, but allows for specifying the structure of an `ExceptionGroup`. `ExceptionInfo.group_contains` also tries to handle exception groups, @@ -299,13 +301,13 @@ class RaisesGroup(AbstractMatcher[BaseExceptionGroup[BaseExcT_co]]): #. All specified exceptions must be present, *and no others*. * If you expect a variable number of exceptions you need to use ``pytest.raises(ExceptionGroup)`` and manually - check the contained exceptions. Consider making use of :func:`Matcher.matches`. + check the contained exceptions. Consider making use of :func:`RaisesExc.matches`. #. It will only catch exceptions wrapped in an exceptiongroup by default. - * With ``allow_unwrapped=True`` you can specify a single expected exception or `Matcher` and it will match + * With ``allow_unwrapped=True`` you can specify a single expected exception or `RaisesExc` and it will match the exception even if it is not inside an `ExceptionGroup`. - If you expect one of several different exception types you need to use a `Matcher` object. + If you expect one of several different exception types you need to use a `RaisesExc` object. #. By default it cares about the full structure with nested `ExceptionGroup`'s. You can specify nested `ExceptionGroup`'s by passing `RaisesGroup` objects as expected exceptions. @@ -323,7 +325,7 @@ class RaisesGroup(AbstractMatcher[BaseExceptionGroup[BaseExcT_co]]): with RaisesGroups(ValueError): raise ExceptionGroup("", (ValueError(),)) with RaisesGroups( - ValueError, ValueError, Matcher(TypeError, match="expected int") + ValueError, ValueError, RaisesExc(TypeError, match="expected int") ): ... with RaisesGroups( @@ -349,11 +351,11 @@ class RaisesGroup(AbstractMatcher[BaseExceptionGroup[BaseExcT_co]]): The matching algorithm is greedy, which means cases such as this may fail:: - with RaisesGroups(ValueError, Matcher(ValueError, match="hello")): + with RaisesGroups(ValueError, RaisesExc(ValueError, match="hello")): raise ExceptionGroup("", (ValueError("hello"), ValueError("goodbye"))) even though it generally does not care about the order of the exceptions in the group. - To avoid the above you should specify the first ValueError with a Matcher as well. + To avoid the above you should specify the first ValueError with a RaisesExc as well. Tip: if you install ``hypothesis`` and import it in ``conftest.py`` you will get readable ``repr``s of ``check`` callables in the output. @@ -364,7 +366,7 @@ class RaisesGroup(AbstractMatcher[BaseExceptionGroup[BaseExcT_co]]): @overload def __init__( self, - exception: type[BaseExcT_co] | Matcher[BaseExcT_co], + exception: type[BaseExcT_co] | RaisesExc[BaseExcT_co], *, allow_unwrapped: Literal[True], flatten_subgroups: bool = False, @@ -374,8 +376,8 @@ def __init__( @overload def __init__( self, - exception: type[BaseExcT_co] | Matcher[BaseExcT_co], - *other_exceptions: type[BaseExcT_co] | Matcher[BaseExcT_co], + exception: type[BaseExcT_co] | RaisesExc[BaseExcT_co], + *other_exceptions: type[BaseExcT_co] | RaisesExc[BaseExcT_co], flatten_subgroups: Literal[True], match: str | Pattern[str] | None = None, check: Callable[[BaseExceptionGroup[BaseExcT_co]], bool] | None = None, @@ -389,8 +391,8 @@ def __init__( @overload def __init__( self: RaisesGroup[ExcT_1], - exception: type[ExcT_1] | Matcher[ExcT_1], - *other_exceptions: type[ExcT_1] | Matcher[ExcT_1], + exception: type[ExcT_1] | RaisesExc[ExcT_1], + *other_exceptions: type[ExcT_1] | RaisesExc[ExcT_1], match: str | Pattern[str] | None = None, check: Callable[[ExceptionGroup[ExcT_1]], bool] | None = None, ) -> None: ... @@ -407,8 +409,8 @@ def __init__( @overload def __init__( self: RaisesGroup[ExcT_1 | ExceptionGroup[ExcT_2]], - exception: type[ExcT_1] | Matcher[ExcT_1] | RaisesGroup[ExcT_2], - *other_exceptions: type[ExcT_1] | Matcher[ExcT_1] | RaisesGroup[ExcT_2], + exception: type[ExcT_1] | RaisesExc[ExcT_1] | RaisesGroup[ExcT_2], + *other_exceptions: type[ExcT_1] | RaisesExc[ExcT_1] | RaisesGroup[ExcT_2], match: str | Pattern[str] | None = None, check: ( Callable[[ExceptionGroup[ExcT_1 | ExceptionGroup[ExcT_2]]], bool] | None @@ -419,8 +421,8 @@ def __init__( @overload def __init__( self: RaisesGroup[BaseExcT_1], - exception: type[BaseExcT_1] | Matcher[BaseExcT_1], - *other_exceptions: type[BaseExcT_1] | Matcher[BaseExcT_1], + exception: type[BaseExcT_1] | RaisesExc[BaseExcT_1], + *other_exceptions: type[BaseExcT_1] | RaisesExc[BaseExcT_1], match: str | Pattern[str] | None = None, check: Callable[[BaseExceptionGroup[BaseExcT_1]], bool] | None = None, ) -> None: ... @@ -439,9 +441,9 @@ def __init__( @overload def __init__( self: RaisesGroup[BaseExcT_1 | BaseExceptionGroup[BaseExcT_2]], - exception: type[BaseExcT_1] | Matcher[BaseExcT_1] | RaisesGroup[BaseExcT_2], + exception: type[BaseExcT_1] | RaisesExc[BaseExcT_1] | RaisesGroup[BaseExcT_2], *other_exceptions: type[BaseExcT_1] - | Matcher[BaseExcT_1] + | RaisesExc[BaseExcT_1] | RaisesGroup[BaseExcT_2], match: str | Pattern[str] | None = None, check: ( @@ -455,9 +457,9 @@ def __init__( def __init__( self: RaisesGroup[ExcT_1 | BaseExcT_1 | BaseExceptionGroup[BaseExcT_2]], - exception: type[BaseExcT_1] | Matcher[BaseExcT_1] | RaisesGroup[BaseExcT_2], + exception: type[BaseExcT_1] | RaisesExc[BaseExcT_1] | RaisesGroup[BaseExcT_2], *other_exceptions: type[BaseExcT_1] - | Matcher[BaseExcT_1] + | RaisesExc[BaseExcT_1] | RaisesGroup[BaseExcT_2], allow_unwrapped: bool = False, flatten_subgroups: bool = False, @@ -479,7 +481,7 @@ def __init__( ) super().__init__(match, check) self.expected_exceptions: tuple[ - type[BaseExcT_co] | Matcher[BaseExcT_co] | RaisesGroup[BaseException], ... + type[BaseExcT_co] | RaisesExc[BaseExcT_co] | RaisesGroup[BaseException], ... ] = ( exception, *other_exceptions, @@ -492,8 +494,8 @@ def __init__( raise ValueError( "You cannot specify multiple exceptions with `allow_unwrapped=True.`" " If you want to match one of multiple possible exceptions you should" - " use a `Matcher`." - " E.g. `Matcher(check=lambda e: isinstance(e, (...)))`", + " use a `RaisesExc`." + " E.g. `RaisesExc(check=lambda e: isinstance(e, (...)))`", ) if allow_unwrapped and isinstance(exception, RaisesGroup): raise ValueError( @@ -505,7 +507,7 @@ def __init__( raise ValueError( "`allow_unwrapped=True` bypasses the `match` and `check` parameters" " if the exception is unwrapped. If you intended to match/check the" - " exception you should use a `Matcher` object. If you want to match/check" + " exception you should use a `RaisesExc` object. If you want to match/check" " the exceptiongroup when the exception *is* wrapped you need to" " do e.g. `if isinstance(exc.value, ExceptionGroup):" " assert RaisesGroup(...).matches(exc.value)` afterwards.", @@ -523,9 +525,9 @@ def __init__( ) self.is_baseexceptiongroup |= exc.is_baseexceptiongroup exc._nested = True - elif isinstance(exc, Matcher): + elif isinstance(exc, RaisesExc): if exc.exception_type is not None: - # Matcher __init__ assures it's a subclass of BaseException + # RaisesExc __init__ assures it's a subclass of BaseException self.is_baseexceptiongroup |= not issubclass( exc.exception_type, Exception, @@ -535,7 +537,7 @@ def __init__( self.is_baseexceptiongroup |= not issubclass(exc, Exception) else: raise TypeError( - f'Invalid argument "{exc!r}" must be exception type, Matcher, or' + f'Invalid argument "{exc!r}" must be exception type, RaisesExc, or' " RaisesGroup.", ) @@ -657,7 +659,7 @@ def matches( assert self._fail_reason is old_reason is not None self._fail_reason += ( f", but matched the expected {self._repr_expected(expected)}." - f" You might want RaisesGroup(Matcher({expected.__name__}, match={_match_pattern(self.match)!r}))" + f" You might want RaisesGroup(RaisesExc({expected.__name__}, match={_match_pattern(self.match)!r}))" ) else: self._fail_reason = old_reason @@ -706,7 +708,7 @@ def matches( ): self._fail_reason = reason + ( f", but did return True for the expected {self._repr_expected(expected)}." - f" You might want RaisesGroup(Matcher({expected.__name__}, check=<...>))" + f" You might want RaisesGroup(RaisesExc({expected.__name__}, check=<...>))" ) else: self._fail_reason = reason @@ -717,7 +719,7 @@ def matches( @staticmethod def _check_expected( expected_type: ( - type[BaseException] | Matcher[BaseException] | RaisesGroup[BaseException] + type[BaseException] | RaisesExc[BaseException] | RaisesGroup[BaseException] ), exception: BaseException, ) -> str | None: @@ -734,8 +736,8 @@ def _check_expected( return f"{expected_type!r}: {expected_type.fail_reason}" @staticmethod - def _repr_expected(e: type[BaseException] | AbstractMatcher[BaseException]) -> str: - """Get the repr of an expected type/Matcher/RaisesGroup, but we only want + def _repr_expected(e: type[BaseException] | AbstractRaises[BaseException]) -> str: + """Get the repr of an expected type/RaisesExc/RaisesGroup, but we only want the name if it's a type""" if isinstance(e, type): return _exception_type_name(e) @@ -887,7 +889,7 @@ def _check_exceptions( s += ( "\nThere exist a possible match when attempting an exhaustive check," " but RaisesGroup uses a greedy algorithm. " - "Please make your expected exceptions more stringent with `Matcher` etc" + "Please make your expected exceptions more stringent with `RaisesExc` etc" " so the greedy algorithm can function." ) self._fail_reason = s @@ -928,7 +930,7 @@ def __exit__( def expected_type(self) -> str: subexcs = [] for e in self.expected_exceptions: - if isinstance(e, Matcher): + if isinstance(e, RaisesExc): subexcs.append(str(e)) elif isinstance(e, RaisesGroup): subexcs.append(e.expected_type()) @@ -953,7 +955,7 @@ class ResultHolder: def __init__( self, expected_exceptions: tuple[ - type[BaseException] | AbstractMatcher[BaseException], ... + type[BaseException] | AbstractRaises[BaseException], ... ], actual_exceptions: Sequence[BaseException], ) -> None: diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index b5f54d559e5..50225f7529f 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -23,7 +23,7 @@ from .._code import getfslineno from ..compat import NOTSET from ..compat import NotSetType -from _pytest._raises_group import AbstractMatcher +from _pytest._raises_group import AbstractRaises from _pytest.config import Config from _pytest.deprecated import check_ispytest from _pytest.deprecated import MARKED_FIXTURE @@ -463,7 +463,7 @@ def __call__( raises: None | type[BaseException] | tuple[type[BaseException], ...] - | AbstractMatcher[BaseException] = ..., + | AbstractRaises[BaseException] = ..., strict: bool = ..., ) -> MarkDecorator: ... diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index ddbf9b87251..c90f67f7b3d 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -908,6 +908,11 @@ def raises( ... >>> assert exc_info.type is ValueError + **Expecting exception groups** + + When expecting exceptions wrapped in :exc:`BaseExceptionGroup` or + :exc:`ExceptionGroup`, you should instead use :class:`pytest.RaisesGroup`. + **Using with** ``pytest.mark.parametrize`` When using :ref:`pytest.mark.parametrize ref` diff --git a/src/_pytest/skipping.py b/src/_pytest/skipping.py index 0736f48aa45..293bea704cb 100644 --- a/src/_pytest/skipping.py +++ b/src/_pytest/skipping.py @@ -12,7 +12,7 @@ import traceback from typing import Optional -from _pytest._raises_group import AbstractMatcher +from _pytest._raises_group import AbstractRaises from _pytest.config import Config from _pytest.config import hookimpl from _pytest.config.argparsing import Parser @@ -205,7 +205,7 @@ class Xfail: raises: ( type[BaseException] | tuple[type[BaseException], ...] - | AbstractMatcher[BaseException] + | AbstractRaises[BaseException] | None ) @@ -289,7 +289,7 @@ def pytest_runtest_makereport( and isinstance(call.excinfo.value, raises) ) or ( - isinstance(raises, AbstractMatcher) + isinstance(raises, AbstractRaises) and raises.matches(call.excinfo.value) ) ): diff --git a/src/pytest/__init__.py b/src/pytest/__init__.py index ca2c66fee03..a16377ca6bb 100644 --- a/src/pytest/__init__.py +++ b/src/pytest/__init__.py @@ -6,7 +6,7 @@ from _pytest import __version__ from _pytest import version_tuple from _pytest._code import ExceptionInfo -from _pytest._raises_group import Matcher +from _pytest._raises_group import RaisesExc from _pytest._raises_group import RaisesGroup from _pytest._raises_group import RaisesGroup as raises_group from _pytest.assertion import register_assert_rewrite @@ -116,7 +116,6 @@ "Mark", "MarkDecorator", "MarkGenerator", - "Matcher", "Metafunc", "Module", "MonkeyPatch", @@ -137,6 +136,7 @@ "PytestUnraisableExceptionWarning", "PytestWarning", "Pytester", + "RaisesExc", "RaisesGroup", "RecordedHookCall", "RunResult", diff --git a/testing/python/raises_group.py b/testing/python/raises_group.py index 73715ee1c21..d0d443cc0cc 100644 --- a/testing/python/raises_group.py +++ b/testing/python/raises_group.py @@ -3,11 +3,13 @@ # several expected multi-line strings contain long lines. We don't wanna break them up # as that makes it confusing to see where the line breaks are. # ruff: noqa: E501 +from contextlib import AbstractContextManager import re import sys from typing import TYPE_CHECKING -from _pytest._raises_group import Matcher +from _pytest._code import ExceptionInfo +from _pytest._raises_group import RaisesExc from _pytest._raises_group import RaisesGroup from _pytest._raises_group import repr_callable from _pytest.outcomes import Failed @@ -39,7 +41,7 @@ def test_raises_group() -> None: with pytest.raises( TypeError, match=wrap_escape( - f'Invalid argument "{ValueError()!r}" must be exception type, Matcher, or RaisesGroup.', + f'Invalid argument "{ValueError()!r}" must be exception type, RaisesExc, or RaisesGroup.', ), ): RaisesGroup(ValueError()) # type: ignore[call-overload] @@ -276,10 +278,10 @@ def test_catch_unwrapped_exceptions() -> None: match=r"^You cannot specify multiple exceptions with", ): RaisesGroup(SyntaxError, ValueError, allow_unwrapped=True) # type: ignore[call-overload] - # if users want one of several exception types they need to use a Matcher + # if users want one of several exception types they need to use a RaisesExc # (which the error message suggests) with RaisesGroup( - Matcher(check=lambda e: isinstance(e, (SyntaxError, ValueError))), + RaisesExc(check=lambda e: isinstance(e, (SyntaxError, ValueError))), allow_unwrapped=True, ): raise ValueError @@ -289,7 +291,7 @@ def test_catch_unwrapped_exceptions() -> None: RaisesGroup(RaisesGroup(ValueError), allow_unwrapped=True) # type: ignore[call-overload] # But it *can* be used to check for nesting level +- 1 if they move it to - # the nested RaisesGroup. Users should probably use `Matcher`s instead though. + # the nested RaisesGroup. Users should probably use `RaisesExc`s instead though. with RaisesGroup(RaisesGroup(ValueError, allow_unwrapped=True)): raise ExceptionGroup("", [ExceptionGroup("", [ValueError()])]) with RaisesGroup(RaisesGroup(ValueError, allow_unwrapped=True)): @@ -329,10 +331,10 @@ def test_catch_unwrapped_exceptions() -> None: raise TypeError("this text doesn't show up in the error message") with ( fails_raises_group( - "Raised exception (group) did not match: Matcher(ValueError): 'TypeError' is not of type 'ValueError'", + "Raised exception (group) did not match: RaisesExc(ValueError): 'TypeError' is not of type 'ValueError'", add_prefix=False, ), - RaisesGroup(Matcher(ValueError), allow_unwrapped=True), + RaisesGroup(RaisesExc(ValueError), allow_unwrapped=True), ): raise TypeError @@ -360,7 +362,7 @@ def test_match() -> None: raise e # and technically you can match it all with ^$ - # but you're probably better off using a Matcher at that point + # but you're probably better off using a RaisesExc at that point with RaisesGroup(ValueError, match="^bar\nmy note$"): e = ExceptionGroup("bar", (ValueError(),)) e.add_note("my note") @@ -375,12 +377,12 @@ def test_match() -> None: raise ExceptionGroup("bar", (ValueError(),)) # Suggest a fix for easy pitfall of adding match to the RaisesGroup instead of - # using a Matcher. + # using a RaisesExc. # This requires a single expected & raised exception, the expected is a type, # and `isinstance(raised, expected_type)`. with ( fails_raises_group( - "Regex pattern 'foo' did not match 'bar' of 'ExceptionGroup', but matched the expected 'ValueError'. You might want RaisesGroup(Matcher(ValueError, match='foo'))" + "Regex pattern 'foo' did not match 'bar' of 'ExceptionGroup', but matched the expected 'ValueError'. You might want RaisesGroup(RaisesExc(ValueError, match='foo'))" ), RaisesGroup(ValueError, match="foo"), ): @@ -411,7 +413,7 @@ def is_value_error(e: BaseException) -> bool: # helpful suggestion if the user thinks the check is for the sub-exception with ( fails_raises_group( - f"check {is_value_error} did not return True on the ExceptionGroup, but did return True for the expected 'ValueError'. You might want RaisesGroup(Matcher(ValueError, check=<...>))" + f"check {is_value_error} did not return True on the ExceptionGroup, but did return True for the expected 'ValueError'. You might want RaisesGroup(RaisesExc(ValueError, check=<...>))" ), RaisesGroup(ValueError, check=is_value_error), ): @@ -425,7 +427,7 @@ def my_check(e: object) -> bool: # pragma: no cover msg = ( "`allow_unwrapped=True` bypasses the `match` and `check` parameters" " if the exception is unwrapped. If you intended to match/check the" - " exception you should use a `Matcher` object. If you want to match/check" + " exception you should use a `RaisesExc` object. If you want to match/check" " the exceptiongroup when the exception *is* wrapped you need to" " do e.g. `if isinstance(exc.value, ExceptionGroup):" " assert RaisesGroup(...).matches(exc.value)` afterwards." @@ -435,8 +437,8 @@ def my_check(e: object) -> bool: # pragma: no cover with pytest.raises(ValueError, match=re.escape(msg)): RaisesGroup(ValueError, allow_unwrapped=True, check=my_check) # type: ignore[call-overload] - # Users should instead use a Matcher - rg = RaisesGroup(Matcher(ValueError, match="^foo$"), allow_unwrapped=True) + # Users should instead use a RaisesExc + rg = RaisesGroup(RaisesExc(ValueError, match="^foo$"), allow_unwrapped=True) with rg: raise ValueError("foo") with rg: @@ -483,14 +485,14 @@ def check_message( RaisesGroup(RaisesGroup(ValueError)), ) - # Matcher + # RaisesExc check_message( - "ExceptionGroup(Matcher(ValueError, match='my_str'))", - RaisesGroup(Matcher(ValueError, "my_str")), + "ExceptionGroup(RaisesExc(ValueError, match='my_str'))", + RaisesGroup(RaisesExc(ValueError, "my_str")), ) check_message( - "ExceptionGroup(Matcher(match='my_str'))", - RaisesGroup(Matcher(match="my_str")), + "ExceptionGroup(RaisesExc(match='my_str'))", + RaisesGroup(RaisesExc(match="my_str")), ) # BaseExceptionGroup @@ -498,10 +500,10 @@ def check_message( "BaseExceptionGroup(KeyboardInterrupt)", RaisesGroup(KeyboardInterrupt), ) - # BaseExceptionGroup with type inside Matcher + # BaseExceptionGroup with type inside RaisesExc check_message( - "BaseExceptionGroup(Matcher(KeyboardInterrupt))", - RaisesGroup(Matcher(KeyboardInterrupt)), + "BaseExceptionGroup(RaisesExc(KeyboardInterrupt))", + RaisesGroup(RaisesExc(KeyboardInterrupt)), ) # Base-ness transfers to parent containers check_message( @@ -556,7 +558,7 @@ def test_assert_message() -> None: "The following raised exceptions did not find a match\n" " RuntimeError():\n" # " 'RuntimeError' is not of type 'ValueError'\n" - # " Matcher(TypeError): 'RuntimeError' is not of type 'TypeError'\n" + # " RaisesExc(TypeError): 'RuntimeError' is not of type 'TypeError'\n" " RaisesGroup(RuntimeError): 'RuntimeError' is not an exception group, but would match with `allow_unwrapped=True`\n" " RaisesGroup(ValueError): 'RuntimeError' is not an exception group\n" " ValueError('bar'):\n" @@ -567,7 +569,7 @@ def test_assert_message() -> None: ), RaisesGroup( ValueError, - Matcher(TypeError), + RaisesExc(TypeError), RaisesGroup(RuntimeError), RaisesGroup(ValueError), ), @@ -587,9 +589,9 @@ def test_assert_message() -> None: with ( fails_raises_group( - "Matcher(ValueError): 'TypeError' is not of type 'ValueError'" + "RaisesExc(ValueError): 'TypeError' is not of type 'ValueError'" ), - RaisesGroup(Matcher(ValueError)), + RaisesGroup(RaisesExc(ValueError)), ): raise ExceptionGroup("a", [TypeError()]) @@ -605,10 +607,10 @@ def test_assert_message() -> None: raise ExceptionGroup("h(ell)o", [ValueError()]) with ( fails_raises_group( - "Matcher(match='h(ell)o'): Regex pattern 'h(ell)o' did not match 'h(ell)o'\n" + "RaisesExc(match='h(ell)o'): Regex pattern 'h(ell)o' did not match 'h(ell)o'\n" " Did you mean to `re.escape()` the regex?", ), - RaisesGroup(Matcher(match="h(ell)o")), + RaisesGroup(RaisesExc(match="h(ell)o")), ): raise ExceptionGroup("", [ValueError("h(ell)o")]) @@ -775,18 +777,18 @@ def test_assert_message_nested() -> None: "The following expected exceptions did not find a match:\n" " RaisesGroup(ValueError)\n" " RaisesGroup(RaisesGroup(ValueError))\n" - " RaisesGroup(Matcher(TypeError, match='foo'))\n" + " RaisesGroup(RaisesExc(TypeError, match='foo'))\n" " RaisesGroup(TypeError, ValueError)\n" "The following raised exceptions did not find a match\n" " TypeError('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'):\n" " RaisesGroup(ValueError): 'TypeError' is not an exception group\n" " RaisesGroup(RaisesGroup(ValueError)): 'TypeError' is not an exception group\n" - " RaisesGroup(Matcher(TypeError, match='foo')): 'TypeError' is not an exception group\n" + " RaisesGroup(RaisesExc(TypeError, match='foo')): 'TypeError' is not an exception group\n" " RaisesGroup(TypeError, ValueError): 'TypeError' is not an exception group\n" " ExceptionGroup('Exceptions from Trio nursery', [TypeError('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb')]):\n" " RaisesGroup(ValueError): 'TypeError' is not of type 'ValueError'\n" " RaisesGroup(RaisesGroup(ValueError)): RaisesGroup(ValueError): 'TypeError' is not an exception group\n" - " RaisesGroup(Matcher(TypeError, match='foo')): Matcher(TypeError, match='foo'): Regex pattern 'foo' did not match 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'\n" + " RaisesGroup(RaisesExc(TypeError, match='foo')): RaisesExc(TypeError, match='foo'): Regex pattern 'foo' did not match 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'\n" " RaisesGroup(TypeError, ValueError): 1 matched exception. Too few exceptions raised, found no match for: ['ValueError']\n" " ExceptionGroup('Exceptions from Trio nursery', [TypeError('cccccccccccccccccccccccccccccc'), TypeError('dddddddddddddddddddddddddddddd')]):\n" " RaisesGroup(ValueError): \n" @@ -805,14 +807,14 @@ def test_assert_message_nested() -> None: " RaisesGroup(ValueError): 'TypeError' is not an exception group\n" " TypeError('dddddddddddddddddddddddddddddd'):\n" " RaisesGroup(ValueError): 'TypeError' is not an exception group\n" - " RaisesGroup(Matcher(TypeError, match='foo')): \n" + " RaisesGroup(RaisesExc(TypeError, match='foo')): \n" " The following expected exceptions did not find a match:\n" - " Matcher(TypeError, match='foo')\n" + " RaisesExc(TypeError, match='foo')\n" " The following raised exceptions did not find a match\n" " TypeError('cccccccccccccccccccccccccccccc'):\n" - " Matcher(TypeError, match='foo'): Regex pattern 'foo' did not match 'cccccccccccccccccccccccccccccc'\n" + " RaisesExc(TypeError, match='foo'): Regex pattern 'foo' did not match 'cccccccccccccccccccccccccccccc'\n" " TypeError('dddddddddddddddddddddddddddddd'):\n" - " Matcher(TypeError, match='foo'): Regex pattern 'foo' did not match 'dddddddddddddddddddddddddddddd'\n" + " RaisesExc(TypeError, match='foo'): Regex pattern 'foo' did not match 'dddddddddddddddddddddddddddddd'\n" " RaisesGroup(TypeError, ValueError): \n" " 1 matched exception. \n" " The following expected exceptions did not find a match:\n" @@ -826,7 +828,7 @@ def test_assert_message_nested() -> None: RaisesGroup( RaisesGroup(ValueError), RaisesGroup(RaisesGroup(ValueError)), - RaisesGroup(Matcher(TypeError, match="foo")), + RaisesGroup(RaisesExc(TypeError, match="foo")), RaisesGroup(TypeError, ValueError), ), ): @@ -861,19 +863,19 @@ def test_check_no_patched_repr() -> None: match_str = ( r"^Raised exception group did not match: \n" r"The following expected exceptions did not find a match:\n" - r" Matcher\(check=. at .*>\)\n" + r" RaisesExc\(check=. at .*>\)\n" r" 'TypeError'\n" r"The following raised exceptions did not find a match\n" r" ValueError\('foo'\):\n" - r" Matcher\(check=. at .*>\): check did not return True\n" + r" RaisesExc\(check=. at .*>\): check did not return True\n" r" 'ValueError' is not of type 'TypeError'\n" r" ValueError\('bar'\):\n" - r" Matcher\(check=. at .*>\): check did not return True\n" + r" RaisesExc\(check=. at .*>\): check did not return True\n" r" 'ValueError' is not of type 'TypeError'$" ) with ( pytest.raises(Failed, match=match_str), - RaisesGroup(Matcher(check=lambda x: False), TypeError), + RaisesGroup(RaisesExc(check=lambda x: False), TypeError), ): raise ExceptionGroup("", [ValueError("foo"), ValueError("bar")]) @@ -884,7 +886,7 @@ def test_misordering_example() -> None: "\n" "3 matched exceptions. \n" "The following expected exceptions did not find a match:\n" - " Matcher(ValueError, match='foo')\n" + " RaisesExc(ValueError, match='foo')\n" " It matches ValueError('foo') which was paired with 'ValueError'\n" " It matches ValueError('foo') which was paired with 'ValueError'\n" " It matches ValueError('foo') which was paired with 'ValueError'\n" @@ -893,11 +895,11 @@ def test_misordering_example() -> None: " It matches 'ValueError' which was paired with ValueError('foo')\n" " It matches 'ValueError' which was paired with ValueError('foo')\n" " It matches 'ValueError' which was paired with ValueError('foo')\n" - " Matcher(ValueError, match='foo'): Regex pattern 'foo' did not match 'bar'\n" - "There exist a possible match when attempting an exhaustive check, but RaisesGroup uses a greedy algorithm. Please make your expected exceptions more stringent with `Matcher` etc so the greedy algorithm can function." + " RaisesExc(ValueError, match='foo'): Regex pattern 'foo' did not match 'bar'\n" + "There exist a possible match when attempting an exhaustive check, but RaisesGroup uses a greedy algorithm. Please make your expected exceptions more stringent with `RaisesExc` etc so the greedy algorithm can function." ), RaisesGroup( - ValueError, ValueError, ValueError, Matcher(ValueError, match="foo") + ValueError, ValueError, ValueError, RaisesExc(ValueError, match="foo") ), ): raise ExceptionGroup( @@ -972,134 +974,134 @@ def test_identity_oopsies() -> None: ) e = ValueError("foo") - m = Matcher(match="bar") + m = RaisesExc(match="bar") with ( fails_raises_group( "\n" "The following expected exceptions did not find a match:\n" - " Matcher(match='bar')\n" - " Matcher(match='bar')\n" - " Matcher(match='bar')\n" + " RaisesExc(match='bar')\n" + " RaisesExc(match='bar')\n" + " RaisesExc(match='bar')\n" "The following raised exceptions did not find a match\n" " ValueError('foo'):\n" - " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'\n" - " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'\n" - " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'\n" " ValueError('foo'):\n" - " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'\n" - " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'\n" - " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'\n" " ValueError('foo'):\n" - " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'\n" - " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'\n" - " Matcher(match='bar'): Regex pattern 'bar' did not match 'foo'" + " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'" ), RaisesGroup(m, m, m), ): raise ExceptionGroup("", [e, e, e]) -def test_matcher() -> None: +def test_raisesexc() -> None: with pytest.raises( ValueError, match=r"^You must specify at least one parameter to match on.$", ): - Matcher() # type: ignore[call-overload] + RaisesExc() # type: ignore[call-overload] with pytest.raises( TypeError, match=f"^exception_type {re.escape(repr(object))} must be a subclass of BaseException$", ): - Matcher(object) # type: ignore[type-var] + RaisesExc(object) # type: ignore[type-var] - with RaisesGroup(Matcher(ValueError)): + with RaisesGroup(RaisesExc(ValueError)): raise ExceptionGroup("", (ValueError(),)) with ( fails_raises_group( - "Matcher(TypeError): 'ValueError' is not of type 'TypeError'" + "RaisesExc(TypeError): 'ValueError' is not of type 'TypeError'" ), - RaisesGroup(Matcher(TypeError)), + RaisesGroup(RaisesExc(TypeError)), ): raise ExceptionGroup("", (ValueError(),)) -def test_matcher_match() -> None: - with RaisesGroup(Matcher(ValueError, "foo")): +def test_raisesexc_match() -> None: + with RaisesGroup(RaisesExc(ValueError, "foo")): raise ExceptionGroup("", (ValueError("foo"),)) with ( fails_raises_group( - "Matcher(ValueError, match='foo'): Regex pattern 'foo' did not match 'bar'" + "RaisesExc(ValueError, match='foo'): Regex pattern 'foo' did not match 'bar'" ), - RaisesGroup(Matcher(ValueError, "foo")), + RaisesGroup(RaisesExc(ValueError, "foo")), ): raise ExceptionGroup("", (ValueError("bar"),)) # Can be used without specifying the type - with RaisesGroup(Matcher(match="foo")): + with RaisesGroup(RaisesExc(match="foo")): raise ExceptionGroup("", (ValueError("foo"),)) with ( fails_raises_group( - "Matcher(match='foo'): Regex pattern 'foo' did not match 'bar'" + "RaisesExc(match='foo'): Regex pattern 'foo' did not match 'bar'" ), - RaisesGroup(Matcher(match="foo")), + RaisesGroup(RaisesExc(match="foo")), ): raise ExceptionGroup("", (ValueError("bar"),)) # check ^$ - with RaisesGroup(Matcher(ValueError, match="^bar$")): + with RaisesGroup(RaisesExc(ValueError, match="^bar$")): raise ExceptionGroup("", [ValueError("bar")]) with ( fails_raises_group( - "Matcher(ValueError, match='^bar$'): Regex pattern '^bar$' did not match 'barr'" + "RaisesExc(ValueError, match='^bar$'): Regex pattern '^bar$' did not match 'barr'" ), - RaisesGroup(Matcher(ValueError, match="^bar$")), + RaisesGroup(RaisesExc(ValueError, match="^bar$")), ): raise ExceptionGroup("", [ValueError("barr")]) -def test_Matcher_check() -> None: +def test_RaisesExc_check() -> None: def check_oserror_and_errno_is_5(e: BaseException) -> bool: return isinstance(e, OSError) and e.errno == 5 - with RaisesGroup(Matcher(check=check_oserror_and_errno_is_5)): + with RaisesGroup(RaisesExc(check=check_oserror_and_errno_is_5)): raise ExceptionGroup("", (OSError(5, ""),)) # specifying exception_type narrows the parameter type to the callable def check_errno_is_5(e: OSError) -> bool: return e.errno == 5 - with RaisesGroup(Matcher(OSError, check=check_errno_is_5)): + with RaisesGroup(RaisesExc(OSError, check=check_errno_is_5)): raise ExceptionGroup("", (OSError(5, ""),)) # avoid printing overly verbose repr multiple times with ( fails_raises_group( - f"Matcher(OSError, check={check_errno_is_5!r}): check did not return True" + f"RaisesExc(OSError, check={check_errno_is_5!r}): check did not return True" ), - RaisesGroup(Matcher(OSError, check=check_errno_is_5)), + RaisesGroup(RaisesExc(OSError, check=check_errno_is_5)), ): raise ExceptionGroup("", (OSError(6, ""),)) # in nested cases you still get it multiple times though - # to address this you'd need logic in Matcher.__repr__ and RaisesGroup.__repr__ + # to address this you'd need logic in RaisesExc.__repr__ and RaisesGroup.__repr__ with ( fails_raises_group( - f"RaisesGroup(Matcher(OSError, check={check_errno_is_5!r})): Matcher(OSError, check={check_errno_is_5!r}): check did not return True" + f"RaisesGroup(RaisesExc(OSError, check={check_errno_is_5!r})): RaisesExc(OSError, check={check_errno_is_5!r}): check did not return True" ), - RaisesGroup(RaisesGroup(Matcher(OSError, check=check_errno_is_5))), + RaisesGroup(RaisesGroup(RaisesExc(OSError, check=check_errno_is_5))), ): raise ExceptionGroup("", [ExceptionGroup("", [OSError(6, "")])]) -def test_matcher_tostring() -> None: - assert str(Matcher(ValueError)) == "Matcher(ValueError)" - assert str(Matcher(match="[a-z]")) == "Matcher(match='[a-z]')" +def test_raisesexc_tostring() -> None: + assert str(RaisesExc(ValueError)) == "RaisesExc(ValueError)" + assert str(RaisesExc(match="[a-z]")) == "RaisesExc(match='[a-z]')" pattern_no_flags = re.compile(r"noflag", 0) - assert str(Matcher(match=pattern_no_flags)) == "Matcher(match='noflag')" + assert str(RaisesExc(match=pattern_no_flags)) == "RaisesExc(match='noflag')" pattern_flags = re.compile(r"noflag", re.IGNORECASE) - assert str(Matcher(match=pattern_flags)) == f"Matcher(match={pattern_flags!r})" + assert str(RaisesExc(match=pattern_flags)) == f"RaisesExc(match={pattern_flags!r})" assert ( - str(Matcher(ValueError, match="re", check=bool)) - == f"Matcher(ValueError, match='re', check={bool!r})" + str(RaisesExc(ValueError, match="re", check=bool)) + == f"RaisesExc(ValueError, match='re', check={bool!r})" ) @@ -1110,7 +1112,7 @@ def check_str_and_repr(s: str) -> None: check_str_and_repr("RaisesGroup(ValueError)") check_str_and_repr("RaisesGroup(RaisesGroup(ValueError))") - check_str_and_repr("RaisesGroup(Matcher(ValueError))") + check_str_and_repr("RaisesGroup(RaisesExc(ValueError))") check_str_and_repr("RaisesGroup(ValueError, allow_unwrapped=True)") check_str_and_repr("RaisesGroup(ValueError, match='aoeu')") @@ -1124,18 +1126,18 @@ def test_assert_matches() -> None: e = ValueError() # it's easy to do this - assert Matcher(ValueError).matches(e) + assert RaisesExc(ValueError).matches(e) # but you don't get a helpful error with pytest.raises(AssertionError, match=r"assert False\n \+ where False = .*"): - assert Matcher(TypeError).matches(e) + assert RaisesExc(TypeError).matches(e) # you'd need to do this arcane incantation with pytest.raises(AssertionError, match="'ValueError' is not of type 'TypeError'"): - assert (m := Matcher(TypeError)).matches(e), m.fail_reason + assert (m := RaisesExc(TypeError)).matches(e), m.fail_reason # but even if we add assert_matches, will people remember to use it? - # other than writing a linter rule, I don't think we can catch `assert Matcher(...).matches` + # other than writing a linter rule, I don't think we can catch `assert RaisesExc(...).matches` # https://github.com/pytest-dev/pytest/issues/12504 @@ -1152,14 +1154,30 @@ def test_foo() -> None: result.assert_outcomes(xfailed=1) -def test_xfail_Matcher(pytester: Pytester) -> None: +def test_xfail_RaisesExc(pytester: Pytester) -> None: pytester.makepyfile( """ import pytest - @pytest.mark.xfail(raises=pytest.Matcher(ValueError)) + @pytest.mark.xfail(raises=pytest.RaisesExc(ValueError)) def test_foo() -> None: raise ValueError """ ) result = pytester.runpytest() result.assert_outcomes(xfailed=1) + + +@pytest.mark.parametrize( + "wrap_in_group,handler", + [ + (False, pytest.raises(ValueError)), + (True, RaisesGroup(ValueError)), + ], +) +def test_parametrizing_conditional_raisesgroup( + wrap_in_group: bool, handler: AbstractContextManager[ExceptionInfo[BaseException]] +) -> None: + with handler: + if wrap_in_group: + raise ExceptionGroup("", [ValueError()]) + raise ValueError() diff --git a/testing/typing_raises_group.py b/testing/typing_raises_group.py index 2dc35031dac..87cce35b72d 100644 --- a/testing/typing_raises_group.py +++ b/testing/typing_raises_group.py @@ -6,7 +6,7 @@ from typing_extensions import assert_type -from _pytest._raises_group import Matcher +from _pytest._raises_group import RaisesExc from _pytest._raises_group import RaisesGroup @@ -17,7 +17,7 @@ # split into functions to isolate the different scopes -def check_matcher_typevar_default(e: Matcher) -> None: +def check_raisesexc_typevar_default(e: RaisesExc) -> None: assert e.exception_type is not None _exc: type[BaseException] = e.exception_type # this would previously pass, as the type would be `Any` @@ -53,30 +53,30 @@ def check_matches_with_different_exception_type() -> None: assert_type(e, ExceptionGroup[ValueError]) -def check_matcher_init() -> None: +def check_raisesexc_init() -> None: def check_exc(exc: BaseException) -> bool: return isinstance(exc, ValueError) # Check various combinations of constructor signatures. # At least 1 arg must be provided. - Matcher() # type: ignore - Matcher(ValueError) - Matcher(ValueError, "regex") - Matcher(ValueError, "regex", check_exc) - Matcher(exception_type=ValueError) - Matcher(match="regex") - Matcher(check=check_exc) - Matcher(ValueError, match="regex") - Matcher(match="regex", check=check_exc) + RaisesExc() # type: ignore + RaisesExc(ValueError) + RaisesExc(ValueError, "regex") + RaisesExc(ValueError, "regex", check_exc) + RaisesExc(exception_type=ValueError) + RaisesExc(match="regex") + RaisesExc(check=check_exc) + RaisesExc(ValueError, match="regex") + RaisesExc(match="regex", check=check_exc) def check_filenotfound(exc: FileNotFoundError) -> bool: return not exc.filename.endswith(".tmp") # If exception_type is provided, that narrows the `check` method's argument. - Matcher(FileNotFoundError, check=check_filenotfound) - Matcher(ValueError, check=check_filenotfound) # type: ignore - Matcher(check=check_filenotfound) # type: ignore - Matcher(FileNotFoundError, match="regex", check=check_filenotfound) + RaisesExc(FileNotFoundError, check=check_filenotfound) + RaisesExc(ValueError, check=check_filenotfound) # type: ignore + RaisesExc(check=check_filenotfound) # type: ignore + RaisesExc(FileNotFoundError, match="regex", check=check_filenotfound) def raisesgroup_check_type_narrowing() -> None: @@ -126,8 +126,8 @@ def handle_group_value(e: ExceptionGroup[ValueError]) -> bool: RaisesGroup(Exception, check=handle_group) -def check_matcher_transparent() -> None: - with RaisesGroup(Matcher(ValueError)) as e: +def check_raisesexc_transparent() -> None: + with RaisesGroup(RaisesExc(ValueError)) as e: ... _: BaseExceptionGroup[ValueError] = e.value assert_type(e.value, ExceptionGroup[ValueError]) @@ -167,8 +167,8 @@ def check_nested_raisesgroups_matches() -> None: def check_multiple_exceptions_1() -> None: a = RaisesGroup(ValueError, ValueError) - b = RaisesGroup(Matcher(ValueError), Matcher(ValueError)) - c = RaisesGroup(ValueError, Matcher(ValueError)) + b = RaisesGroup(RaisesExc(ValueError), RaisesExc(ValueError)) + c = RaisesGroup(ValueError, RaisesExc(ValueError)) d: RaisesGroup[ValueError] d = a @@ -179,8 +179,8 @@ def check_multiple_exceptions_1() -> None: def check_multiple_exceptions_2() -> None: # This previously failed due to lack of covariance in the TypeVar - a = RaisesGroup(Matcher(ValueError), Matcher(TypeError)) - b = RaisesGroup(Matcher(ValueError), TypeError) + a = RaisesGroup(RaisesExc(ValueError), RaisesExc(TypeError)) + b = RaisesGroup(RaisesExc(ValueError), TypeError) c = RaisesGroup(ValueError, TypeError) d: RaisesGroup[Exception] @@ -203,7 +203,7 @@ def check_raisesgroup_overloads() -> None: # allowed variants RaisesGroup(ValueError, allow_unwrapped=True) RaisesGroup(ValueError, allow_unwrapped=True, flatten_subgroups=True) - RaisesGroup(Matcher(ValueError), allow_unwrapped=True) + RaisesGroup(RaisesExc(ValueError), allow_unwrapped=True) # flatten_subgroups=True does not allow nested RaisesGroup RaisesGroup(RaisesGroup(ValueError), flatten_subgroups=True) # type: ignore @@ -212,7 +212,7 @@ def check_raisesgroup_overloads() -> None: RaisesGroup(ValueError, match="foo", flatten_subgroups=True) RaisesGroup(ValueError, check=bool, flatten_subgroups=True) RaisesGroup(ValueError, flatten_subgroups=True) - RaisesGroup(Matcher(ValueError), flatten_subgroups=True) + RaisesGroup(RaisesExc(ValueError), flatten_subgroups=True) # if they're both false we can of course specify nested raisesgroup RaisesGroup(RaisesGroup(ValueError)) From e73c4111d201f5614b8a5b8e064efc5e46b0acf2 Mon Sep 17 00:00:00 2001 From: jakkdl <11260241+jakkdl@users.noreply.github.com> Date: Thu, 6 Feb 2025 15:52:56 +0100 Subject: [PATCH 293/445] fix test on py<311 --- testing/python/raises_group.py | 2 ++ tox.ini | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/testing/python/raises_group.py b/testing/python/raises_group.py index d0d443cc0cc..f3f3bcb5316 100644 --- a/testing/python/raises_group.py +++ b/testing/python/raises_group.py @@ -1145,6 +1145,8 @@ def test_xfail_raisesgroup(pytester: Pytester) -> None: pytester.makepyfile( """ import pytest + if sys.version_info < (3, 11): + from exceptiongroup import ExceptionGroup @pytest.mark.xfail(raises=pytest.RaisesGroup(ValueError)) def test_foo() -> None: raise ExceptionGroup("foo", [ValueError()]) diff --git a/tox.ini b/tox.ini index 80fae513142..645a28f0126 100644 --- a/tox.ini +++ b/tox.ini @@ -107,8 +107,8 @@ allowlist_externals = git commands = # Retrieve possibly missing commits: - -git fetch --unshallow - -git fetch --tags + #-git fetch --unshallow + #-git fetch --tags sphinx-build \ -j auto \ From ff36649db4b7f37c1c559677027b8afac124e532 Mon Sep 17 00:00:00 2001 From: jakkdl <11260241+jakkdl@users.noreply.github.com> Date: Thu, 6 Feb 2025 16:14:37 +0100 Subject: [PATCH 294/445] remove git fetch from tox docs environment --- tox.ini | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tox.ini b/tox.ini index 80fae513142..97a74dde937 100644 --- a/tox.ini +++ b/tox.ini @@ -103,13 +103,7 @@ basepython = python3.12 # sync with rtd to get errors usedevelop = True deps = -r{toxinidir}/doc/en/requirements.txt -allowlist_externals = - git commands = - # Retrieve possibly missing commits: - -git fetch --unshallow - -git fetch --tags - sphinx-build \ -j auto \ -W --keep-going \ From c011e9b6f3d1d177947190428df14ee54fbc3cf1 Mon Sep 17 00:00:00 2001 From: jakkdl <11260241+jakkdl@users.noreply.github.com> Date: Thu, 6 Feb 2025 17:12:56 +0100 Subject: [PATCH 295/445] fix test, fix references in docstrings --- doc/en/reference/reference.rst | 5 +++ src/_pytest/_raises_group.py | 62 ++++++++++++++++++---------------- testing/python/raises_group.py | 1 + tox.ini | 4 +-- 4 files changed, 41 insertions(+), 31 deletions(-) diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index d7cf09100b7..2f1c2206596 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1020,12 +1020,17 @@ RaisesExc .. autoclass:: pytest.RaisesExc() :members: + .. autoattribute:: fail_reason + RaisesGroup ~~~~~~~~~~~ +**Tutorial**: :ref:`assert-matching-exception-groups` .. autoclass:: pytest.RaisesGroup() :members: + .. autoattribute:: fail_reason + TerminalReporter ~~~~~~~~~~~~~~~~ diff --git a/src/_pytest/_raises_group.py b/src/_pytest/_raises_group.py index db4e51fc211..92884409694 100644 --- a/src/_pytest/_raises_group.py +++ b/src/_pytest/_raises_group.py @@ -126,9 +126,9 @@ def __init__( @property def fail_reason(self) -> str | None: - """Set after a call to `matches` to give a human-readable reason for why the match failed. - When used as a context manager the string will be given as the text of an - `Failed`""" + """Set after a call to :meth:`matches` to give a human-readable reason for why the match failed. + When used as a context manager the string will be printed as the reason for the + test failing.""" return self._fail_reason def _check_check( @@ -170,17 +170,20 @@ def matches( self: AbstractRaises[BaseExcT_1], exc_val: BaseException ) -> TypeGuard[BaseExcT_1]: """Check if an exception matches the requirements of this AbstractRaises. - If it fails, `AbstractRaises.fail_reason` should be set. + If it fails, :meth:`AbstractRaises.fail_reason` should be set. """ @final class RaisesExc(AbstractRaises[BaseExcT_co_default]): """Helper class to be used together with RaisesGroups when you want to specify requirements on sub-exceptions. - Only specifying the type is redundant, and it's also unnecessary when the type is a - nested `RaisesGroup` since it supports the same arguments. - The type is checked with `isinstance`, and does not need to be an exact match. + + You don't need this if you only want to specify the type, since :class:`RaisesGroup` + accepts ``type[BaseException]``. + + The type is checked with :func:`isinstance`, and does not need to be an exact match. If that is wanted you can use the ``check`` parameter. + :meth:`RaisesExc.matches` can also be used standalone to check individual exceptions. Examples:: @@ -193,7 +196,7 @@ class RaisesExc(AbstractRaises[BaseExcT_co_default]): ... Tip: if you install ``hypothesis`` and import it in ``conftest.py`` you will get - readable ``repr``s of ``check`` callables in the output. + readable ``repr``'s of ``check`` callables in the output. """ # Trio bundled hypothesis monkeypatching, we will probably instead assume that @@ -241,8 +244,8 @@ def matches( self, exception: BaseException, ) -> TypeGuard[BaseExcT_co_default]: - """Check if an exception matches the requirements of this RaisesExc. - If it fails, `RaisesExc.fail_reason` will be set. + """Check if an exception matches the requirements of this :class:`RaisesExc`. + If it fails, :attr:`RaisesExc.fail_reason` will be set. Examples:: @@ -287,33 +290,34 @@ def _check_type(self, exception: BaseException) -> TypeGuard[BaseExcT_co_default @final class RaisesGroup(AbstractRaises[BaseExceptionGroup[BaseExcT_co]]): - """Contextmanager for checking for an expected `ExceptionGroup`. - This works similar to ``pytest.raises``, but allows for specifying the structure of an `ExceptionGroup`. - `ExceptionInfo.group_contains` also tries to handle exception groups, - but it is very bad at checking that you *didn't* get exceptions you didn't expect. + """Contextmanager for checking for an expected :exc:`ExceptionGroup`. + This works similar to :func:`pytest.raises`, but allows for specifying the structure of an :exc:`ExceptionGroup`. + :meth:`ExceptionInfo.group_contains` also tries to handle exception groups, + but it is very bad at checking that you *didn't* get unexpected exceptions. - The catching behaviour differs from :ref:`except* ` in multiple - different ways, being much stricter by default. + The catching behaviour differs from :ref:`except* `, being much + stricter about the structure by default. By using ``allow_unwrapped=True`` and ``flatten_subgroups=True`` you can match - ``except*`` fully when expecting a single exception. + :ref:`except* ` fully when expecting a single exception. #. All specified exceptions must be present, *and no others*. - * If you expect a variable number of exceptions you need to use ``pytest.raises(ExceptionGroup)`` and manually - check the contained exceptions. Consider making use of :func:`RaisesExc.matches`. + * If you expect a variable number of exceptions you need to use + :func:`pytest.raises(ExceptionGroup) ` and manually check + the contained exceptions. Consider making use of :meth:`RaisesExc.matches`. #. It will only catch exceptions wrapped in an exceptiongroup by default. - * With ``allow_unwrapped=True`` you can specify a single expected exception or `RaisesExc` and it will match - the exception even if it is not inside an `ExceptionGroup`. - If you expect one of several different exception types you need to use a `RaisesExc` object. + * With ``allow_unwrapped=True`` you can specify a single expected exception (or `RaisesExc`) and it will match + the exception even if it is not inside an :exc:`ExceptionGroup`. + If you expect one of several different exception types you need to use a :class:`RaisesExc` object. - #. By default it cares about the full structure with nested `ExceptionGroup`'s. You can specify nested - `ExceptionGroup`'s by passing `RaisesGroup` objects as expected exceptions. + #. By default it cares about the full structure with nested :exc:`ExceptionGroup`'s. You can specify nested + :exc:`ExceptionGroup`'s by passing :class:`RaisesGroup` objects as expected exceptions. - * With ``flatten_subgroups=True`` it will "flatten" the raised `ExceptionGroup`, - extracting all exceptions inside any nested :class:`ExceptionGroup`, before matching. + * With ``flatten_subgroups=True`` it will "flatten" the raised :exc:`ExceptionGroup`, + extracting all exceptions inside any nested :exc:`ExceptionGroup`, before matching. It does not care about the order of the exceptions, so ``RaisesGroups(ValueError, TypeError)`` @@ -346,7 +350,7 @@ class RaisesGroup(AbstractRaises[BaseExceptionGroup[BaseExcT_co]]): raise ValueError - `RaisesGroup.matches` can also be used directly to check a standalone exception group. + :meth:`RaisesGroup.matches` can also be used directly to check a standalone exception group. The matching algorithm is greedy, which means cases such as this may fail:: @@ -355,10 +359,10 @@ class RaisesGroup(AbstractRaises[BaseExceptionGroup[BaseExcT_co]]): raise ExceptionGroup("", (ValueError("hello"), ValueError("goodbye"))) even though it generally does not care about the order of the exceptions in the group. - To avoid the above you should specify the first ValueError with a RaisesExc as well. + To avoid the above you should specify the first :exc:`ValueError` with a :class:`RaisesExc` as well. Tip: if you install ``hypothesis`` and import it in ``conftest.py`` you will get - readable ``repr``s of ``check`` callables in the output. + readable ``repr``'s of ``check`` callables in the output. """ # allow_unwrapped=True requires: singular exception, exception not being diff --git a/testing/python/raises_group.py b/testing/python/raises_group.py index f3f3bcb5316..4ac6f8a7ced 100644 --- a/testing/python/raises_group.py +++ b/testing/python/raises_group.py @@ -1144,6 +1144,7 @@ def test_assert_matches() -> None: def test_xfail_raisesgroup(pytester: Pytester) -> None: pytester.makepyfile( """ + import sys import pytest if sys.version_info < (3, 11): from exceptiongroup import ExceptionGroup diff --git a/tox.ini b/tox.ini index 645a28f0126..80fae513142 100644 --- a/tox.ini +++ b/tox.ini @@ -107,8 +107,8 @@ allowlist_externals = git commands = # Retrieve possibly missing commits: - #-git fetch --unshallow - #-git fetch --tags + -git fetch --unshallow + -git fetch --tags sphinx-build \ -j auto \ From a3d55a69552dfe34e3039a4bcb0a8bf8f9376716 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 8 Feb 2025 17:07:57 +0100 Subject: [PATCH 296/445] Make pygments mandatory and fix string highlighting (#13189) * Make pygments dependency required Closes #7683 * Also highlight comparisons between strings Fixes #13175 --- changelog/13175.bugfix.rst | 1 + changelog/7683.improvement.rst | 1 + pyproject.toml | 2 +- src/_pytest/_io/terminalwriter.py | 54 ++++++++++--------------------- src/_pytest/assertion/util.py | 29 +++++++++++++---- testing/test_assertion.py | 10 ++++++ 6 files changed, 52 insertions(+), 45 deletions(-) create mode 100644 changelog/13175.bugfix.rst create mode 100644 changelog/7683.improvement.rst diff --git a/changelog/13175.bugfix.rst b/changelog/13175.bugfix.rst new file mode 100644 index 00000000000..bdbb72b41e1 --- /dev/null +++ b/changelog/13175.bugfix.rst @@ -0,0 +1 @@ +The diff is now also highlighted correctly when comparing two strings. diff --git a/changelog/7683.improvement.rst b/changelog/7683.improvement.rst new file mode 100644 index 00000000000..311abe4df93 --- /dev/null +++ b/changelog/7683.improvement.rst @@ -0,0 +1 @@ +The formerly optional ``pygments`` dependency is now required, causing output always to be source-highlighted (unless disabled via the ``--code-highlight=no`` CLI option). diff --git a/pyproject.toml b/pyproject.toml index 3c3c04d2d5b..263e0c23836 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,6 +51,7 @@ dependencies = [ "iniconfig", "packaging", "pluggy>=1.5,<2", + "pygments>=2.7.2", "tomli>=1; python_version<'3.11'", ] optional-dependencies.dev = [ @@ -58,7 +59,6 @@ optional-dependencies.dev = [ "attrs>=19.2", "hypothesis>=3.56", "mock", - "pygments>=2.7.2", "requests", "setuptools", "xmlschema", diff --git a/src/_pytest/_io/terminalwriter.py b/src/_pytest/_io/terminalwriter.py index 50ce463f6b2..fd808f8b3b7 100644 --- a/src/_pytest/_io/terminalwriter.py +++ b/src/_pytest/_io/terminalwriter.py @@ -9,17 +9,17 @@ from typing import final from typing import Literal from typing import TextIO -from typing import TYPE_CHECKING + +import pygments +from pygments.formatters.terminal import TerminalFormatter +from pygments.lexer import Lexer +from pygments.lexers.diff import DiffLexer +from pygments.lexers.python import PythonLexer from ..compat import assert_never from .wcwidth import wcswidth -if TYPE_CHECKING: - from pygments.formatter import Formatter - from pygments.lexer import Lexer - - # This code was initially copied from py 1.8.1, file _io/terminalwriter.py. @@ -201,37 +201,22 @@ def _write_source(self, lines: Sequence[str], indents: Sequence[str] = ()) -> No for indent, new_line in zip(indents, new_lines): self.line(indent + new_line) - def _get_pygments_lexer(self, lexer: Literal["python", "diff"]) -> Lexer | None: - try: - if lexer == "python": - from pygments.lexers.python import PythonLexer - - return PythonLexer() - elif lexer == "diff": - from pygments.lexers.diff import DiffLexer - - return DiffLexer() - else: - assert_never(lexer) - except ModuleNotFoundError: - return None - - def _get_pygments_formatter(self) -> Formatter | None: - try: - import pygments.util - except ModuleNotFoundError: - return None + def _get_pygments_lexer(self, lexer: Literal["python", "diff"]) -> Lexer: + if lexer == "python": + return PythonLexer() + elif lexer == "diff": + return DiffLexer() + else: + assert_never(lexer) + def _get_pygments_formatter(self) -> TerminalFormatter: from _pytest.config.exceptions import UsageError theme = os.getenv("PYTEST_THEME") theme_mode = os.getenv("PYTEST_THEME_MODE", "dark") try: - from pygments.formatters.terminal import TerminalFormatter - return TerminalFormatter(bg=theme_mode, style=theme) - except pygments.util.ClassNotFound as e: raise UsageError( f"PYTEST_THEME environment variable has an invalid value: '{theme}'. " @@ -251,16 +236,11 @@ def _highlight( return source pygments_lexer = self._get_pygments_lexer(lexer) - if pygments_lexer is None: - return source - pygments_formatter = self._get_pygments_formatter() - if pygments_formatter is None: - return source - - from pygments import highlight - highlighted: str = highlight(source, pygments_lexer, pygments_formatter) + highlighted: str = pygments.highlight( + source, pygments_lexer, pygments_formatter + ) # pygments terminal formatter may add a newline when there wasn't one. # We don't want this, remove. if highlighted[-1] == "\n" and source[-1] != "\n": diff --git a/src/_pytest/assertion/util.py b/src/_pytest/assertion/util.py index 3fe7eb9d862..30aee185d57 100644 --- a/src/_pytest/assertion/util.py +++ b/src/_pytest/assertion/util.py @@ -43,6 +43,14 @@ def __call__(self, source: str, lexer: Literal["diff", "python"] = "python") -> """Apply highlighting to the given source.""" +def dummy_highlighter(source: str, lexer: Literal["diff", "python"] = "python") -> str: + """Dummy highlighter that returns the text unprocessed. + + Needed for _notin_text, as the diff gets post-processed to only show the "+" part. + """ + return source + + def format_explanation(explanation: str) -> str: r"""Format an explanation. @@ -242,7 +250,7 @@ def _compare_eq_any( ) -> list[str]: explanation = [] if istext(left) and istext(right): - explanation = _diff_text(left, right, verbose) + explanation = _diff_text(left, right, highlighter, verbose) else: from _pytest.python_api import ApproxBase @@ -274,7 +282,9 @@ def _compare_eq_any( return explanation -def _diff_text(left: str, right: str, verbose: int = 0) -> list[str]: +def _diff_text( + left: str, right: str, highlighter: _HighlightFunc, verbose: int = 0 +) -> list[str]: """Return the explanation for the diff between text. Unless --verbose is used this will skip leading and trailing @@ -315,10 +325,15 @@ def _diff_text(left: str, right: str, verbose: int = 0) -> list[str]: explanation += ["Strings contain only whitespace, escaping them using repr()"] # "right" is the expected base against which we compare "left", # see https://github.com/pytest-dev/pytest/issues/3333 - explanation += [ - line.strip("\n") - for line in ndiff(right.splitlines(keepends), left.splitlines(keepends)) - ] + explanation.extend( + highlighter( + "\n".join( + line.strip("\n") + for line in ndiff(right.splitlines(keepends), left.splitlines(keepends)) + ), + lexer="diff", + ).splitlines() + ) return explanation @@ -586,7 +601,7 @@ def _notin_text(term: str, text: str, verbose: int = 0) -> list[str]: head = text[:index] tail = text[index + len(term) :] correct_text = head + tail - diff = _diff_text(text, correct_text, verbose) + diff = _diff_text(text, correct_text, dummy_highlighter, verbose) newdiff = [f"{saferepr(term, maxsize=42)} is contained here:"] for line in diff: if line.startswith("Skipping"): diff --git a/testing/test_assertion.py b/testing/test_assertion.py index a2e2304d342..e3d45478466 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -2019,6 +2019,16 @@ def test(): "{bold}{red}E {light-green}+ 'number-is-5': 5,{hl-reset}{endline}{reset}", ], ), + ( + """ + def test(): + assert "abcd" == "abce" + """, + [ + "{bold}{red}E {reset}{light-red}- abce{hl-reset}{endline}{reset}", + "{bold}{red}E {light-green}+ abcd{hl-reset}{endline}{reset}", + ], + ), ), ) def test_comparisons_handle_colors( From 4c3f286532b452e7ce4966f34d010369cbe08342 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 9 Feb 2025 06:23:44 +0000 Subject: [PATCH 297/445] [automated] Update plugin list (#13206) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 134 +++++++++++++++++-------------- 1 file changed, 75 insertions(+), 59 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 2e8bf36500d..cf1f0902885 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,14 +27,14 @@ please refer to `the update script =8.3 + :pypi:`databricks-labs-pytester` Python Testing for Databricks Feb 03, 2025 4 - Beta pytest>=8.3 :pypi:`logassert` Simple but powerful assertion and verification of logged lines Jan 29, 2025 5 - Production/Stable pytest; extra == "dev" :pypi:`logot` Test whether your code is logging correctly 🪵 Mar 23, 2024 5 - Production/Stable pytest<9,>=7; extra == "pytest" :pypi:`nuts` Network Unit Testing System Jul 19, 2024 N/A pytest<8,>=7 @@ -161,7 +161,7 @@ This list contains 1581 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Jan 30, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Feb 05, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -332,7 +332,7 @@ This list contains 1581 plugins. :pypi:`pytest-data` Useful functions for managing data for pytest fixtures Nov 01, 2016 5 - Production/Stable N/A :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Oct 20, 2024 4 - Beta pytest :pypi:`pytest-databricks` Pytest plugin for remote Databricks notebooks testing Jul 29, 2020 N/A pytest - :pypi:`pytest-datadir` pytest plugin for test data directories and files Oct 03, 2023 5 - Production/Stable pytest >=5.0 + :pypi:`pytest-datadir` pytest plugin for test data directories and files Feb 07, 2025 5 - Production/Stable pytest>=7.0 :pypi:`pytest-datadir-mgr` Manager for test data: downloads, artifact caching, and a tmpdir context. Apr 06, 2023 5 - Production/Stable pytest (>=7.1) :pypi:`pytest-datadir-ng` Fixtures for pytest allowing test functions/methods to easily retrieve test resources from the local filesystem. Dec 25, 2019 5 - Production/Stable pytest :pypi:`pytest-datadir-nng` Fixtures for pytest allowing test functions/methods to easily retrieve test resources from the local filesystem. Nov 09, 2022 5 - Production/Stable pytest (>=7.0.0,<8.0.0) @@ -353,6 +353,7 @@ This list contains 1581 plugins. :pypi:`pytest-dbt-adapter` A pytest plugin for testing dbt adapter plugins Nov 24, 2021 N/A pytest (<7,>=6) :pypi:`pytest-dbt-conventions` A pytest plugin for linting a dbt project's conventions Mar 02, 2022 N/A pytest (>=6.2.5,<7.0.0) :pypi:`pytest-dbt-core` Pytest extension for dbt. Jun 04, 2024 N/A pytest>=6.2.5; extra == "test" + :pypi:`pytest-dbt-duckdb` Add your description here Feb 07, 2025 N/A pytest>=8.3.4 :pypi:`pytest-dbt-postgres` Pytest tooling to unittest DBT & Postgres models Sep 03, 2024 N/A pytest<9.0.0,>=8.3.2 :pypi:`pytest-dbus-notification` D-BUS notifications for pytest results. Mar 05, 2014 5 - Production/Stable N/A :pypi:`pytest-dbx` Pytest plugin to run unit tests for dbx (Databricks CLI extensions) related code Nov 29, 2022 N/A pytest (>=7.1.3,<8.0.0) @@ -412,7 +413,7 @@ This list contains 1581 plugins. :pypi:`pytest-doc` A documentation plugin for py.test. Jun 28, 2015 5 - Production/Stable N/A :pypi:`pytest-docfiles` pytest plugin to test codeblocks in your documentation. Dec 22, 2021 4 - Beta pytest (>=3.7.0) :pypi:`pytest-docgen` An RST Documentation Generator for pytest-based test suites Apr 17, 2020 N/A N/A - :pypi:`pytest-docker` Simple pytest fixtures for Docker and Docker Compose based tests Feb 02, 2024 N/A pytest <9.0,>=4.0 + :pypi:`pytest-docker` Simple pytest fixtures for Docker and Docker Compose based tests Feb 06, 2025 N/A pytest<9.0,>=4.0 :pypi:`pytest-docker-apache-fixtures` Pytest fixtures for testing with apache2 (httpd). Aug 12, 2024 4 - Beta pytest :pypi:`pytest-docker-butla` Jun 16, 2019 3 - Alpha N/A :pypi:`pytest-dockerc` Run, manage and stop Docker Compose project from Docker API Oct 09, 2020 5 - Production/Stable pytest (>=3.0) @@ -474,15 +475,15 @@ This list contains 1581 plugins. :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Jan 29, 2025 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Jan 29, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Jan 29, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Jan 29, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Jan 29, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Jan 29, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Jan 29, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Jan 29, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Jan 29, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Feb 06, 2025 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Feb 06, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Feb 06, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Feb 06, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Feb 06, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Feb 06, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Feb 06, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Feb 06, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Feb 06, 2025 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -507,7 +508,7 @@ This list contains 1581 plugins. :pypi:`pytest-eth` PyTest plugin for testing Smart Contracts for Ethereum Virtual Machine (EVM). Aug 14, 2020 1 - Planning N/A :pypi:`pytest-ethereum` pytest-ethereum: Pytest library for ethereum projects. Jun 24, 2019 3 - Alpha pytest (==3.3.2); extra == 'dev' :pypi:`pytest-eucalyptus` Pytest Plugin for BDD Jun 28, 2022 N/A pytest (>=4.2.0) - :pypi:`pytest-evals` A pytest plugin for running and analyzing LLM evaluation tests Jan 29, 2025 N/A pytest>=7.0.0 + :pypi:`pytest-evals` A pytest plugin for running and analyzing LLM evaluation tests Feb 02, 2025 N/A pytest>=7.0.0 :pypi:`pytest-eventlet` Applies eventlet monkey-patch as a pytest plugin. Oct 04, 2021 N/A pytest ; extra == 'dev' :pypi:`pytest_evm` The testing package containing tools to test Web3-based projects Sep 23, 2024 4 - Beta pytest<9.0.0,>=8.1.1 :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A @@ -677,7 +678,7 @@ This list contains 1581 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Feb 01, 2025 3 - Alpha pytest==8.3.4 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Feb 08, 2025 3 - Alpha pytest==8.3.4 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -709,13 +710,13 @@ This list contains 1581 plugins. :pypi:`pytest-hylang` Pytest plugin to allow running tests written in hylang Mar 28, 2021 N/A pytest :pypi:`pytest-hypo-25` help hypo module for pytest Jan 12, 2020 3 - Alpha N/A :pypi:`pytest-iam` A fully functional OAUTH2 / OpenID Connect (OIDC) server to be used in your testsuite Jul 25, 2024 4 - Beta pytest>=7.0.0 - :pypi:`pytest-ibutsu` A plugin to sent pytest results to an Ibutsu server Aug 05, 2022 4 - Beta pytest>=7.1 + :pypi:`pytest-ibutsu` A plugin to sent pytest results to an Ibutsu server Feb 06, 2025 4 - Beta pytest>=7.1 :pypi:`pytest-icdiff` use icdiff for better error messages in pytest assertions Dec 05, 2023 4 - Beta pytest :pypi:`pytest-idapro` A pytest plugin for idapython. Allows a pytest setup to run tests outside and inside IDA in an automated manner by runnig pytest inside IDA and by mocking idapython api Nov 03, 2018 N/A N/A :pypi:`pytest-idem` A pytest plugin to help with testing idem projects Dec 13, 2023 5 - Production/Stable N/A :pypi:`pytest-idempotent` Pytest plugin for testing function idempotence. Jul 25, 2022 N/A N/A :pypi:`pytest-ignore-flaky` ignore failures from flaky tests (pytest plugin) Apr 20, 2024 5 - Production/Stable pytest>=6.0 - :pypi:`pytest-ignore-test-results` A pytest plugin to ignore test results. Aug 17, 2023 2 - Pre-Alpha pytest>=7.0 + :pypi:`pytest-ignore-test-results` A pytest plugin to ignore test results. Feb 03, 2025 5 - Production/Stable pytest>=7.0 :pypi:`pytest-image-diff` Dec 31, 2024 3 - Alpha pytest :pypi:`pytest-image-snapshot` A pytest plugin for image snapshot management and comparison. Jul 01, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-import-check` pytest plugin to check whether Python modules can be imported Jul 19, 2024 3 - Alpha pytest>=8.1 @@ -796,7 +797,7 @@ This list contains 1581 plugins. :pypi:`pytest-kookit` Your simple but kooky integration testing with pytest Sep 10, 2024 N/A N/A :pypi:`pytest-koopmans` A plugin for testing the koopmans package Nov 21, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-krtech-common` pytest krtech common library Nov 28, 2016 4 - Beta N/A - :pypi:`pytest-kubernetes` Oct 28, 2024 N/A pytest<9.0.0,>=8.3.0 + :pypi:`pytest-kubernetes` Feb 04, 2025 N/A pytest<9.0.0,>=8.3.0 :pypi:`pytest-kuunda` pytest plugin to help with test data setup for PySpark tests Feb 25, 2024 4 - Beta pytest >=6.2.0 :pypi:`pytest-kwparametrize` Alternate syntax for @pytest.mark.parametrize with test cases as dictionaries and default value fallbacks Jan 22, 2021 N/A pytest (>=6) :pypi:`pytest-lambda` Define pytest fixtures with lambda functions. May 27, 2024 5 - Production/Stable pytest<9,>=3.6 @@ -875,7 +876,7 @@ This list contains 1581 plugins. :pypi:`pytest-memray` A simple plugin to use with pytest Jul 25, 2024 N/A pytest>=7.2 :pypi:`pytest-menu` A pytest plugin for console based interactive test selection just after the collection phase Oct 04, 2017 3 - Alpha pytest (>=2.4.2) :pypi:`pytest-mercurial` pytest plugin to write integration tests for projects using Mercurial Python internals Nov 21, 2020 1 - Planning N/A - :pypi:`pytest-mergify` Pytest plugin for Mergify Jan 23, 2025 N/A N/A + :pypi:`pytest-mergify` Pytest plugin for Mergify Feb 06, 2025 N/A N/A :pypi:`pytest-mesh` pytest_mesh插件 Aug 05, 2022 N/A pytest (==7.1.2) :pypi:`pytest-message` Pytest plugin for sending report message of marked tests execution Aug 04, 2022 N/A pytest (>=6.2.5) :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A @@ -914,7 +915,7 @@ This list contains 1581 plugins. :pypi:`pytest-monkeyplus` pytest's monkeypatch subclass with extra functionalities Sep 18, 2012 5 - Production/Stable N/A :pypi:`pytest-monkeytype` pytest-monkeytype: Generate Monkeytype annotations from your pytest tests. Jul 29, 2020 4 - Beta N/A :pypi:`pytest-moto` Fixtures for integration tests of AWS services,uses moto mocking library. Aug 28, 2015 1 - Planning N/A - :pypi:`pytest-moto-fixtures` Fixtures for testing code that interacts with AWS Oct 24, 2024 1 - Planning pytest<9.0,>=8.3; extra == "pytest" + :pypi:`pytest-moto-fixtures` Fixtures for testing code that interacts with AWS Feb 04, 2025 1 - Planning pytest<9,>=8.3; extra == "pytest" :pypi:`pytest-motor` A pytest plugin for motor, the non-blocking MongoDB driver. Jul 21, 2021 3 - Alpha pytest :pypi:`pytest-mp` A test batcher for multiprocessed Pytest runs May 23, 2018 4 - Beta pytest :pypi:`pytest-mpi` pytest plugin to collect information from tests Jan 08, 2022 3 - Alpha pytest @@ -1057,7 +1058,7 @@ This list contains 1581 plugins. :pypi:`pytest-plone` Pytest plugin to test Plone addons May 15, 2024 3 - Alpha pytest<8.0.0 :pypi:`pytest-plt` Fixtures for quickly making Matplotlib plots in tests Jan 17, 2024 5 - Production/Stable pytest :pypi:`pytest-plugin-helpers` A plugin to help developing and testing other plugins Nov 23, 2019 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-plus` PyTest Plus Plugin :: extends pytest functionality Jan 31, 2025 5 - Production/Stable pytest>=7.4.2 + :pypi:`pytest-plus` PyTest Plus Plugin :: extends pytest functionality Feb 02, 2025 5 - Production/Stable pytest>=7.4.2 :pypi:`pytest-pmisc` Mar 21, 2019 5 - Production/Stable N/A :pypi:`pytest-pogo` Pytest plugin for pogo-migrate Sep 09, 2024 4 - Beta pytest<9,>=7 :pypi:`pytest-pointers` Pytest plugin to define functions you test with special marks for better navigation and reports Dec 26, 2022 N/A N/A @@ -1176,7 +1177,7 @@ This list contains 1581 plugins. :pypi:`pytest-reorder` Reorder tests depending on their paths and names. May 31, 2018 4 - Beta pytest :pypi:`pytest-repeat` pytest plugin for repeating tests Oct 09, 2023 5 - Production/Stable pytest :pypi:`pytest_repeater` py.test plugin for repeating single test multiple times. Feb 09, 2018 1 - Planning N/A - :pypi:`pytest-replay` Saves previous test runs and allow re-execute previous pytest runs to reproduce crashes or flaky tests Nov 29, 2024 5 - Production/Stable pytest + :pypi:`pytest-replay` Saves previous test runs and allow re-execute previous pytest runs to reproduce crashes or flaky tests Feb 05, 2025 5 - Production/Stable pytest :pypi:`pytest-repo-health` A pytest plugin to report on repository standards conformance Apr 17, 2023 3 - Alpha pytest :pypi:`pytest-report` Creates json report that is compatible with atom.io's linter message format May 11, 2016 4 - Beta N/A :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest @@ -1241,7 +1242,7 @@ This list contains 1581 plugins. :pypi:`pytest-ruff` pytest plugin to check ruff requirements. Jul 21, 2024 4 - Beta pytest>=5 :pypi:`pytest-run-changed` Pytest plugin that runs changed tests only Apr 02, 2021 3 - Alpha pytest :pypi:`pytest-runfailed` implement a --failed option for pytest Mar 24, 2016 N/A N/A - :pypi:`pytest-run-parallel` A simple pytest plugin to run tests concurrently Jan 06, 2025 4 - Beta pytest>=6.2.0 + :pypi:`pytest-run-parallel` A simple pytest plugin to run tests concurrently Feb 05, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-run-subprocess` Pytest Plugin for running and testing subprocesses. Nov 12, 2022 5 - Production/Stable pytest :pypi:`pytest-runtime-types` Checks type annotations on runtime while running tests. Feb 09, 2023 N/A pytest :pypi:`pytest-runtime-xfail` Call runtime_xfail() to mark running test as xfail. Aug 26, 2021 N/A pytest>=5.0.0 @@ -1257,7 +1258,7 @@ This list contains 1581 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Feb 01, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Feb 08, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1269,7 +1270,7 @@ This list contains 1581 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Feb 01, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Feb 08, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1407,7 +1408,7 @@ This list contains 1581 plugins. :pypi:`pytest-tcpclient` A pytest plugin for testing TCP clients Nov 16, 2022 N/A pytest (<8,>=7.1.3) :pypi:`pytest-tdd` run pytest on a python module Aug 18, 2023 4 - Beta N/A :pypi:`pytest-teamcity-logblock` py.test plugin to introduce block structure in teamcity build log, if output is not captured May 15, 2018 4 - Beta N/A - :pypi:`pytest-teardown` Jan 22, 2025 N/A pytest<9.0.0,>=7.4.1 + :pypi:`pytest-teardown` Feb 03, 2025 N/A pytest<9.0.0,>=7.4.1 :pypi:`pytest-telegram` Pytest to Telegram reporting plugin Apr 25, 2024 5 - Production/Stable N/A :pypi:`pytest-telegram-notifier` Telegram notification plugin for Pytest Jun 27, 2023 5 - Production/Stable N/A :pypi:`pytest-tempdir` Predictable and repeatable tempdir support. Oct 11, 2019 4 - Beta pytest (>=2.8.1) @@ -1450,6 +1451,7 @@ This list contains 1581 plugins. :pypi:`pytest-test-tracer-for-pytest` A plugin that allows coll test data for use on Test Tracer Jun 28, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-test-tracer-for-pytest-bdd` A plugin that allows coll test data for use on Test Tracer Aug 20, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-test-utils` Feb 08, 2024 N/A pytest >=3.9 + :pypi:`pytest-test-yaml` a pytest test package Feb 08, 2025 N/A pytest :pypi:`pytest-tesults` Tesults plugin for pytest Nov 12, 2024 5 - Production/Stable pytest>=3.5.0 :pypi:`pytest-textual-snapshot` Snapshot testing for Textual apps Jan 23, 2025 5 - Production/Stable pytest>=8.0.0 :pypi:`pytest-tezos` pytest-ligo Jan 16, 2020 4 - Beta N/A @@ -1544,7 +1546,7 @@ This list contains 1581 plugins. :pypi:`pytest-voluptuous` Pytest plugin for asserting data against voluptuous schema. Jun 09, 2020 N/A pytest :pypi:`pytest-vscodedebug` A pytest plugin to easily enable debugging tests within Visual Studio Code Dec 04, 2020 4 - Beta N/A :pypi:`pytest-vscode-pycharm-cls` A PyTest helper to enable start remote debugger on test start or failure or when pytest.set_trace is used. Feb 01, 2023 N/A pytest - :pypi:`pytest-vtestify` A pytest plugin for visual assertion using SSIM and image comparison. Oct 10, 2024 N/A pytest + :pypi:`pytest-vtestify` A pytest plugin for visual assertion using SSIM and image comparison. Feb 04, 2025 N/A pytest :pypi:`pytest-vts` pytest plugin for automatic recording of http stubbed tests Jun 05, 2019 N/A pytest (>=2.3) :pypi:`pytest-vulture` A pytest plugin to checks dead code with vulture Nov 25, 2024 N/A pytest>=7.0.0 :pypi:`pytest-vw` pytest-vw makes your failing test cases succeed under CI tools scrutiny Oct 07, 2015 4 - Beta N/A @@ -1621,7 +1623,7 @@ This list contains 1581 plugins. :pypi:`databricks-labs-pytester` - *last release*: Nov 15, 2024, + *last release*: Feb 03, 2025, *status*: 4 - Beta, *requires*: pytest>=8.3 @@ -2510,7 +2512,7 @@ This list contains 1581 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Jan 30, 2025, + *last release*: Feb 05, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -3707,9 +3709,9 @@ This list contains 1581 plugins. Pytest plugin for remote Databricks notebooks testing :pypi:`pytest-datadir` - *last release*: Oct 03, 2023, + *last release*: Feb 07, 2025, *status*: 5 - Production/Stable, - *requires*: pytest >=5.0 + *requires*: pytest>=7.0 pytest plugin for test data directories and files @@ -3853,6 +3855,13 @@ This list contains 1581 plugins. Pytest extension for dbt. + :pypi:`pytest-dbt-duckdb` + *last release*: Feb 07, 2025, + *status*: N/A, + *requires*: pytest>=8.3.4 + + Add your description here + :pypi:`pytest-dbt-postgres` *last release*: Sep 03, 2024, *status*: N/A, @@ -4267,9 +4276,9 @@ This list contains 1581 plugins. An RST Documentation Generator for pytest-based test suites :pypi:`pytest-docker` - *last release*: Feb 02, 2024, + *last release*: Feb 06, 2025, *status*: N/A, - *requires*: pytest <9.0,>=4.0 + *requires*: pytest<9.0,>=4.0 Simple pytest fixtures for Docker and Docker Compose based tests @@ -4701,63 +4710,63 @@ This list contains 1581 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: Jan 29, 2025, + *last release*: Feb 06, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: Jan 29, 2025, + *last release*: Feb 06, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: Jan 29, 2025, + *last release*: Feb 06, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: Jan 29, 2025, + *last release*: Feb 06, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. :pypi:`pytest-embedded-nuttx` - *last release*: Jan 29, 2025, + *last release*: Feb 06, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with NuttX. :pypi:`pytest-embedded-qemu` - *last release*: Jan 29, 2025, + *last release*: Feb 06, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: Jan 29, 2025, + *last release*: Feb 06, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: Jan 29, 2025, + *last release*: Feb 06, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: Jan 29, 2025, + *last release*: Feb 06, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -4932,7 +4941,7 @@ This list contains 1581 plugins. Pytest Plugin for BDD :pypi:`pytest-evals` - *last release*: Jan 29, 2025, + *last release*: Feb 02, 2025, *status*: N/A, *requires*: pytest>=7.0.0 @@ -6122,7 +6131,7 @@ This list contains 1581 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Feb 01, 2025, + *last release*: Feb 08, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.4 @@ -6346,7 +6355,7 @@ This list contains 1581 plugins. A fully functional OAUTH2 / OpenID Connect (OIDC) server to be used in your testsuite :pypi:`pytest-ibutsu` - *last release*: Aug 05, 2022, + *last release*: Feb 06, 2025, *status*: 4 - Beta, *requires*: pytest>=7.1 @@ -6388,8 +6397,8 @@ This list contains 1581 plugins. ignore failures from flaky tests (pytest plugin) :pypi:`pytest-ignore-test-results` - *last release*: Aug 17, 2023, - *status*: 2 - Pre-Alpha, + *last release*: Feb 03, 2025, + *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin to ignore test results. @@ -6955,7 +6964,7 @@ This list contains 1581 plugins. pytest krtech common library :pypi:`pytest-kubernetes` - *last release*: Oct 28, 2024, + *last release*: Feb 04, 2025, *status*: N/A, *requires*: pytest<9.0.0,>=8.3.0 @@ -7508,7 +7517,7 @@ This list contains 1581 plugins. pytest plugin to write integration tests for projects using Mercurial Python internals :pypi:`pytest-mergify` - *last release*: Jan 23, 2025, + *last release*: Feb 06, 2025, *status*: N/A, *requires*: N/A @@ -7781,9 +7790,9 @@ This list contains 1581 plugins. Fixtures for integration tests of AWS services,uses moto mocking library. :pypi:`pytest-moto-fixtures` - *last release*: Oct 24, 2024, + *last release*: Feb 04, 2025, *status*: 1 - Planning, - *requires*: pytest<9.0,>=8.3; extra == "pytest" + *requires*: pytest<9,>=8.3; extra == "pytest" Fixtures for testing code that interacts with AWS @@ -8782,7 +8791,7 @@ This list contains 1581 plugins. A plugin to help developing and testing other plugins :pypi:`pytest-plus` - *last release*: Jan 31, 2025, + *last release*: Feb 02, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.4.2 @@ -9615,7 +9624,7 @@ This list contains 1581 plugins. py.test plugin for repeating single test multiple times. :pypi:`pytest-replay` - *last release*: Nov 29, 2024, + *last release*: Feb 05, 2025, *status*: 5 - Production/Stable, *requires*: pytest @@ -10070,7 +10079,7 @@ This list contains 1581 plugins. implement a --failed option for pytest :pypi:`pytest-run-parallel` - *last release*: Jan 06, 2025, + *last release*: Feb 05, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -10182,7 +10191,7 @@ This list contains 1581 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Feb 01, 2025, + *last release*: Feb 08, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10266,7 +10275,7 @@ This list contains 1581 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Feb 01, 2025, + *last release*: Feb 08, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -11232,7 +11241,7 @@ This list contains 1581 plugins. py.test plugin to introduce block structure in teamcity build log, if output is not captured :pypi:`pytest-teardown` - *last release*: Jan 22, 2025, + *last release*: Feb 03, 2025, *status*: N/A, *requires*: pytest<9.0.0,>=7.4.1 @@ -11532,6 +11541,13 @@ This list contains 1581 plugins. + :pypi:`pytest-test-yaml` + *last release*: Feb 08, 2025, + *status*: N/A, + *requires*: pytest + + a pytest test package + :pypi:`pytest-tesults` *last release*: Nov 12, 2024, *status*: 5 - Production/Stable, @@ -12191,7 +12207,7 @@ This list contains 1581 plugins. A PyTest helper to enable start remote debugger on test start or failure or when pytest.set_trace is used. :pypi:`pytest-vtestify` - *last release*: Oct 10, 2024, + *last release*: Feb 04, 2025, *status*: N/A, *requires*: pytest From 2a8593c701856e82547a09e86eedcfbc017e9dd5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 08:45:39 +0100 Subject: [PATCH 298/445] build(deps): Bump django in /testing/plugins_integration (#13210) Bumps [django](https://github.com/django/django) from 5.1.5 to 5.1.6. - [Commits](https://github.com/django/django/compare/5.1.5...5.1.6) --- updated-dependencies: - dependency-name: django dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 3d89d055f2b..ca4f6f700c4 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,5 +1,5 @@ anyio[trio]==4.8.0 -django==5.1.5 +django==5.1.6 pytest-asyncio==0.25.3 pytest-bdd==8.1.0 pytest-cov==6.0.0 From 05cc85400c3dfa0666be8da3d16988deeae81a37 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 11 Feb 2025 01:38:22 +0100 Subject: [PATCH 299/445] [pre-commit.ci] pre-commit autoupdate (#13214) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.4 → v0.9.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.4...v0.9.6) - [github.com/woodruffw/zizmor-pre-commit: v1.3.0 → v1.3.1](https://github.com/woodruffw/zizmor-pre-commit/compare/v1.3.0...v1.3.1) - [github.com/pre-commit/mirrors-mypy: v1.14.1 → v1.15.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.14.1...v1.15.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62d72d5e9f3..d746af2e4e5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.9.4" + rev: "v0.9.6" hooks: - id: ruff args: ["--fix"] @@ -12,7 +12,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/woodruffw/zizmor-pre-commit - rev: v1.3.0 + rev: v1.3.1 hooks: - id: zizmor - repo: https://github.com/adamchainz/blacken-docs @@ -32,7 +32,7 @@ repos: hooks: - id: python-use-type-annotations - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.14.1 + rev: v1.15.0 hooks: - id: mypy files: ^(src/|testing/|scripts/) From f0cc122edddea0c10e4ec4139065b6137ce45ad1 Mon Sep 17 00:00:00 2001 From: Samuel Bronson Date: Thu, 13 Feb 2025 10:13:18 +0000 Subject: [PATCH 300/445] Update capture-warnings.rst: Fix PEP number in link (#13215) This was linking to a completely unrelated PEP, presumably due to a typo. Sorry there's no changelog, filing from my phone. --- doc/en/how-to/capture-warnings.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/how-to/capture-warnings.rst b/doc/en/how-to/capture-warnings.rst index 65a43cec6e8..4b1de6f3704 100644 --- a/doc/en/how-to/capture-warnings.rst +++ b/doc/en/how-to/capture-warnings.rst @@ -250,7 +250,7 @@ See :ref:`@pytest.mark.filterwarnings ` and the :envvar:`python:PYTHONWARNINGS` environment variable or the ``-W`` command-line option, pytest will not configure any filters by default. - Also pytest doesn't follow :pep:`506` suggestion of resetting all warning filters because + Also pytest doesn't follow :pep:`565` suggestion of resetting all warning filters because it might break test suites that configure warning filters themselves by calling :func:`warnings.simplefilter` (see :issue:`2430` for an example of that). From 62aa4272229a4e604582db534796df1a729b4752 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 15 Feb 2025 15:48:35 +0100 Subject: [PATCH 301/445] doc: Clarify capturing .readouterr() return value (#13222) This got added in 38fb6aae7830837209c40ec1a4ccb68950bc107c, where the "The return value ... changed" made a lot of sense. However, 9c5da9c0d15ccf7ab9f3a8fbd6540e4a56ea789f removed the "versionadded" without adjusting the wording. Also see 3a4435fb59604d40c5d2e2f65e9acba99dd9cff0. --- doc/en/how-to/capture-stdout-stderr.rst | 2 +- doc/en/how-to/parametrize.rst | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/doc/en/how-to/capture-stdout-stderr.rst b/doc/en/how-to/capture-stdout-stderr.rst index 9f7ddce3499..d91bef736e7 100644 --- a/doc/en/how-to/capture-stdout-stderr.rst +++ b/doc/en/how-to/capture-stdout-stderr.rst @@ -131,7 +131,7 @@ test from having to care about setting/resetting output streams and also interacts well with pytest's own per-test capturing. -The return value from ``readouterr`` changed to a ``namedtuple`` with two attributes, ``out`` and ``err``. +The return value of ``readouterr()`` is a ``namedtuple`` with two attributes, ``out`` and ``err``. If the code under test writes non-textual data (``bytes``), you can capture this using the :fixture:`capsysbinary` fixture which instead returns ``bytes`` from diff --git a/doc/en/how-to/parametrize.rst b/doc/en/how-to/parametrize.rst index b6466c491b4..5a16684eb96 100644 --- a/doc/en/how-to/parametrize.rst +++ b/doc/en/how-to/parametrize.rst @@ -29,10 +29,6 @@ pytest enables test parametrization at several levels: .. regendoc: wipe - - - Several improvements. - The builtin :ref:`pytest.mark.parametrize ref` decorator enables parametrization of arguments for a test function. Here is a typical example of a test function that implements checking that a certain input leads From 60173b59fd269bdcaa660b7a5ed813f380b721bc Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 13 Feb 2025 12:31:56 +0100 Subject: [PATCH 302/445] Move CLI options to correct help section Before: pytest-warnings: -W, --pythonwarnings PYTHONWARNINGS Set which warnings to report, see -W option of Python itself --maxfail=num Exit after first num failures or errors --strict-config Any warnings encountered while parsing the `pytest` section of the configuration file raise errors --strict-markers Markers not registered in the `markers` section of the configuration file raise errors --strict (Deprecated) alias to --strict-markers -c, --config-file FILE Load configuration from `FILE` instead of trying to locate one of the implicit configuration files. --continue-on-collection-errors Force test execution even if collection errors occur --rootdir=ROOTDIR Define root directory for tests. Can be relative path: 'root_dir', './root_dir', 'root_dir/another_dir/'; absolute path: '/home/user/root_dir'; path with variables: '$HOME/root_dir'. But other than -W, those options aren't related to pytest-warnings at all. This is a regression in 19e99ab4131fbd709ce0e5a17694e1be3b22f355, which added `group = parser.getgroup("pytest-warnings")` in the middle of those "general" options, thus moving the help section for some of them. --- src/_pytest/main.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 26b0db74ff9..64ffb488d94 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -92,20 +92,6 @@ def pytest_addoption(parser: Parser) -> None: const=1, help="Exit instantly on first error or failed test", ) - group = parser.getgroup("pytest-warnings") - group.addoption( - "-W", - "--pythonwarnings", - action="append", - help="Set which warnings to report, see -W option of Python itself", - ) - parser.addini( - "filterwarnings", - type="linelist", - help="Each line specifies a pattern for " - "warnings.filterwarnings. " - "Processed after -W/--pythonwarnings.", - ) group._addoption( "--maxfail", metavar="num", @@ -157,6 +143,21 @@ def pytest_addoption(parser: Parser) -> None: "'$HOME/root_dir'.", ) + group = parser.getgroup("pytest-warnings") + group.addoption( + "-W", + "--pythonwarnings", + action="append", + help="Set which warnings to report, see -W option of Python itself", + ) + parser.addini( + "filterwarnings", + type="linelist", + help="Each line specifies a pattern for " + "warnings.filterwarnings. " + "Processed after -W/--pythonwarnings.", + ) + group = parser.getgroup("collect", "collection") group.addoption( "--collectonly", From d7176e25f7ffd9865b8cd4a3492e3a93f59f1c8b Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 13 Feb 2025 12:38:14 +0100 Subject: [PATCH 303/445] Move collection options to correct section Moves --continue-on-collection-errors to "collection:" --- src/_pytest/main.py | 72 ++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 64ffb488d94..344df7a53ed 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -54,35 +54,6 @@ def pytest_addoption(parser: Parser) -> None: - parser.addini( - "norecursedirs", - "Directory patterns to avoid for recursion", - type="args", - default=[ - "*.egg", - ".*", - "_darcs", - "build", - "CVS", - "dist", - "node_modules", - "venv", - "{arch}", - ], - ) - parser.addini( - "testpaths", - "Directories to search for tests when no files or directories are given on the " - "command line", - type="args", - default=[], - ) - parser.addini( - "collect_imported_tests", - "Whether to collect tests in imported modules outside `testpaths`", - type="bool", - default=True, - ) group = parser.getgroup("general", "Running and selection options") group._addoption( "-x", @@ -127,13 +98,6 @@ def pytest_addoption(parser: Parser) -> None: help="Load configuration from `FILE` instead of trying to locate one of the " "implicit configuration files.", ) - group._addoption( - "--continue-on-collection-errors", - action="store_true", - default=False, - dest="continue_on_collection_errors", - help="Force test execution even if collection errors occur", - ) group._addoption( "--rootdir", action="store", @@ -219,6 +183,13 @@ def pytest_addoption(parser: Parser) -> None: default=False, help="Don't ignore tests in a local virtualenv directory", ) + group._addoption( + "--continue-on-collection-errors", + action="store_true", + default=False, + dest="continue_on_collection_errors", + help="Force test execution even if collection errors occur", + ) group.addoption( "--import-mode", default="prepend", @@ -227,6 +198,35 @@ def pytest_addoption(parser: Parser) -> None: help="Prepend/append to sys.path when importing test modules and conftest " "files. Default: prepend.", ) + parser.addini( + "norecursedirs", + "Directory patterns to avoid for recursion", + type="args", + default=[ + "*.egg", + ".*", + "_darcs", + "build", + "CVS", + "dist", + "node_modules", + "venv", + "{arch}", + ], + ) + parser.addini( + "testpaths", + "Directories to search for tests when no files or directories are given on the " + "command line", + type="args", + default=[], + ) + parser.addini( + "collect_imported_tests", + "Whether to collect tests in imported modules outside `testpaths`", + type="bool", + default=True, + ) parser.addini( "consider_namespace_packages", type="bool", From 71ae4d1df4d8b1ceb688f364e04a8bbcccebc495 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 13 Feb 2025 12:39:47 +0100 Subject: [PATCH 304/445] Move --config-file / --rootdir options "test session [...] configuration" seems more fitting than "general" --- src/_pytest/main.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 344df7a53ed..81350781f3f 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -89,23 +89,6 @@ def pytest_addoption(parser: Parser) -> None: action="store_true", help="(Deprecated) alias to --strict-markers", ) - group._addoption( - "-c", - "--config-file", - metavar="FILE", - type=str, - dest="inifilename", - help="Load configuration from `FILE` instead of trying to locate one of the " - "implicit configuration files.", - ) - group._addoption( - "--rootdir", - action="store", - dest="rootdir", - help="Define root directory for tests. Can be relative path: 'root_dir', './root_dir', " - "'root_dir/another_dir/'; absolute path: '/home/user/root_dir'; path with variables: " - "'$HOME/root_dir'.", - ) group = parser.getgroup("pytest-warnings") group.addoption( @@ -235,6 +218,23 @@ def pytest_addoption(parser: Parser) -> None: ) group = parser.getgroup("debugconfig", "test session debugging and configuration") + group._addoption( + "-c", + "--config-file", + metavar="FILE", + type=str, + dest="inifilename", + help="Load configuration from `FILE` instead of trying to locate one of the " + "implicit configuration files.", + ) + group._addoption( + "--rootdir", + action="store", + dest="rootdir", + help="Define root directory for tests. Can be relative path: 'root_dir', './root_dir', " + "'root_dir/another_dir/'; absolute path: '/home/user/root_dir'; path with variables: " + "'$HOME/root_dir'.", + ) group.addoption( "--basetemp", dest="basetemp", From 2861de3293e0be788cb047aa5fc52faf90b6e744 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 13 Feb 2025 12:49:29 +0100 Subject: [PATCH 305/445] Avoid using private _addoption The only differences between the two is that: - `addoption` checks for conflicts, but `_addoption` does not - `addoption` complains if a lower-case short option is given, `_addoption` does not Yet it looks like using the latter has been inconsistently cargo-culted with newer options. --- src/_pytest/capture.py | 4 ++-- src/_pytest/debugging.py | 6 +++--- src/_pytest/helpconfig.py | 6 +++--- src/_pytest/main.py | 16 ++++++++-------- src/_pytest/mark/__init__.py | 4 ++-- src/_pytest/pastebin.py | 2 +- src/_pytest/terminal.py | 34 +++++++++++++++++----------------- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index 5b64c34e772..d447d087031 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -48,7 +48,7 @@ def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("general") - group._addoption( + group.addoption( "--capture", action="store", default="fd", @@ -56,7 +56,7 @@ def pytest_addoption(parser: Parser) -> None: choices=["fd", "sys", "no", "tee-sys"], help="Per-test capturing method: one of fd|sys|no|tee-sys", ) - group._addoption( + group._addoption( # private to use reserved lower-case short option "-s", action="store_const", const="no", diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py index a9886c29d3c..040e8994b37 100644 --- a/src/_pytest/debugging.py +++ b/src/_pytest/debugging.py @@ -40,13 +40,13 @@ def _validate_usepdb_cls(value: str) -> tuple[str, str]: def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("general") - group._addoption( + group.addoption( "--pdb", dest="usepdb", action="store_true", help="Start the interactive Python debugger on errors or KeyboardInterrupt", ) - group._addoption( + group.addoption( "--pdbcls", dest="usepdb_cls", metavar="modulename:classname", @@ -54,7 +54,7 @@ def pytest_addoption(parser: Parser) -> None: help="Specify a custom interactive Python debugger for use with --pdb." "For example: --pdbcls=IPython.terminal.debugger:TerminalPdb", ) - group._addoption( + group.addoption( "--trace", dest="trace", action="store_true", diff --git a/src/_pytest/helpconfig.py b/src/_pytest/helpconfig.py index 3d607189dbe..2b377c70f7b 100644 --- a/src/_pytest/helpconfig.py +++ b/src/_pytest/helpconfig.py @@ -55,14 +55,14 @@ def pytest_addoption(parser: Parser) -> None: help="Display pytest version and information about plugins. " "When given twice, also display information about plugins.", ) - group._addoption( + group._addoption( # private to use reserved lower-case short option "-h", "--help", action=HelpAction, dest="help", help="Show help message and configuration info", ) - group._addoption( + group._addoption( # private to use reserved lower-case short option "-p", action="append", dest="plugins", @@ -90,7 +90,7 @@ def pytest_addoption(parser: Parser) -> None: "This file is opened with 'w' and truncated as a result, care advised. " "Default: pytestdebug.log.", ) - group._addoption( + group._addoption( # private to use reserved lower-case short option "-o", "--override-ini", dest="override_ini", diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 81350781f3f..dac084b553a 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -55,7 +55,7 @@ def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("general", "Running and selection options") - group._addoption( + group._addoption( # private to use reserved lower-case short option "-x", "--exitfirst", action="store_const", @@ -63,7 +63,7 @@ def pytest_addoption(parser: Parser) -> None: const=1, help="Exit instantly on first error or failed test", ) - group._addoption( + group.addoption( "--maxfail", metavar="num", action="store", @@ -72,19 +72,19 @@ def pytest_addoption(parser: Parser) -> None: default=0, help="Exit after first num failures or errors", ) - group._addoption( + group.addoption( "--strict-config", action="store_true", help="Any warnings encountered while parsing the `pytest` section of the " "configuration file raise errors", ) - group._addoption( + group.addoption( "--strict-markers", action="store_true", help="Markers not registered in the `markers` section of the configuration " "file raise errors", ) - group._addoption( + group.addoption( "--strict", action="store_true", help="(Deprecated) alias to --strict-markers", @@ -166,7 +166,7 @@ def pytest_addoption(parser: Parser) -> None: default=False, help="Don't ignore tests in a local virtualenv directory", ) - group._addoption( + group.addoption( "--continue-on-collection-errors", action="store_true", default=False, @@ -218,7 +218,7 @@ def pytest_addoption(parser: Parser) -> None: ) group = parser.getgroup("debugconfig", "test session debugging and configuration") - group._addoption( + group._addoption( # private to use reserved lower-case short option "-c", "--config-file", metavar="FILE", @@ -227,7 +227,7 @@ def pytest_addoption(parser: Parser) -> None: help="Load configuration from `FILE` instead of trying to locate one of the " "implicit configuration files.", ) - group._addoption( + group.addoption( "--rootdir", action="store", dest="rootdir", diff --git a/src/_pytest/mark/__init__.py b/src/_pytest/mark/__init__.py index efb966c09aa..488b562a298 100644 --- a/src/_pytest/mark/__init__.py +++ b/src/_pytest/mark/__init__.py @@ -79,7 +79,7 @@ def test_eval(test_input, expected): def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("general") - group._addoption( + group._addoption( # private to use reserved lower-case short option "-k", action="store", dest="keyword", @@ -99,7 +99,7 @@ def pytest_addoption(parser: Parser) -> None: "The matching is case-insensitive.", ) - group._addoption( + group._addoption( # private to use reserved lower-case short option "-m", action="store", dest="markexpr", diff --git a/src/_pytest/pastebin.py b/src/_pytest/pastebin.py index 69c011ed24a..d5c4f29c4c3 100644 --- a/src/_pytest/pastebin.py +++ b/src/_pytest/pastebin.py @@ -20,7 +20,7 @@ def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("terminal reporting") - group._addoption( + group.addoption( "--pastebin", metavar="mode", action="store", diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index b2cdda37507..3297c38e848 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -132,7 +132,7 @@ class TestShortLogReport(NamedTuple): def pytest_addoption(parser: Parser) -> None: group = parser.getgroup("terminal reporting", "Reporting", after="general") - group._addoption( + group._addoption( # private to use reserved lower-case short option "-v", "--verbose", action="count", @@ -140,35 +140,35 @@ def pytest_addoption(parser: Parser) -> None: dest="verbose", help="Increase verbosity", ) - group._addoption( + group.addoption( "--no-header", action="store_true", default=False, dest="no_header", help="Disable header", ) - group._addoption( + group.addoption( "--no-summary", action="store_true", default=False, dest="no_summary", help="Disable summary", ) - group._addoption( + group.addoption( "--no-fold-skipped", action="store_false", dest="fold_skipped", default=True, help="Do not fold skipped tests in short summary.", ) - group._addoption( + group.addoption( "--force-short-summary", action="store_true", dest="force_short_summary", default=False, help="Force condensed summary output regardless of verbosity level.", ) - group._addoption( + group._addoption( # private to use reserved lower-case short option "-q", "--quiet", action=MoreQuietAction, @@ -176,14 +176,14 @@ def pytest_addoption(parser: Parser) -> None: dest="verbose", help="Decrease verbosity", ) - group._addoption( + group.addoption( "--verbosity", dest="verbose", type=int, default=0, help="Set verbosity. Default: 0.", ) - group._addoption( + group._addoption( # private to use reserved lower-case short option "-r", action="store", dest="reportchars", @@ -195,7 +195,7 @@ def pytest_addoption(parser: Parser) -> None: "(w)arnings are enabled by default (see --disable-warnings), " "'N' can be used to reset the list. (default: 'fE').", ) - group._addoption( + group.addoption( "--disable-warnings", "--disable-pytest-warnings", default=False, @@ -203,7 +203,7 @@ def pytest_addoption(parser: Parser) -> None: action="store_true", help="Disable warnings summary", ) - group._addoption( + group._addoption( # private to use reserved lower-case short option "-l", "--showlocals", action="store_true", @@ -211,13 +211,13 @@ def pytest_addoption(parser: Parser) -> None: default=False, help="Show locals in tracebacks (disabled by default)", ) - group._addoption( + group.addoption( "--no-showlocals", action="store_false", dest="showlocals", help="Hide locals in tracebacks (negate --showlocals passed through addopts)", ) - group._addoption( + group.addoption( "--tb", metavar="style", action="store", @@ -226,14 +226,14 @@ def pytest_addoption(parser: Parser) -> None: choices=["auto", "long", "short", "no", "line", "native"], help="Traceback print mode (auto/long/short/line/native/no)", ) - group._addoption( + group.addoption( "--xfail-tb", action="store_true", dest="xfail_tb", default=False, help="Show tracebacks for xfail (as long as --tb != no)", ) - group._addoption( + group.addoption( "--show-capture", action="store", dest="showcapture", @@ -242,14 +242,14 @@ def pytest_addoption(parser: Parser) -> None: help="Controls how captured stdout/stderr/log is shown on failed tests. " "Default: all.", ) - group._addoption( + group.addoption( "--fulltrace", "--full-trace", action="store_true", default=False, help="Don't cut any tracebacks (default is to cut)", ) - group._addoption( + group.addoption( "--color", metavar="color", action="store", @@ -258,7 +258,7 @@ def pytest_addoption(parser: Parser) -> None: choices=["yes", "no", "auto"], help="Color terminal output (yes/no/auto)", ) - group._addoption( + group.addoption( "--code-highlight", default="yes", choices=["yes", "no"], From 174333e940c3548a8f494824d0ff1092b94a3722 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 15 Feb 2025 16:02:44 +0100 Subject: [PATCH 306/445] Add changelog --- changelog/13221.doc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/13221.doc.rst diff --git a/changelog/13221.doc.rst b/changelog/13221.doc.rst new file mode 100644 index 00000000000..cfd35f821b4 --- /dev/null +++ b/changelog/13221.doc.rst @@ -0,0 +1 @@ +Improved grouping of CLI options in the ``--help`` output. From d126389308eb787efa0c0ebffc566a5bb1619e4d Mon Sep 17 00:00:00 2001 From: Harmin Parra Rueda Date: Sat, 15 Feb 2025 20:30:12 +0100 Subject: [PATCH 307/445] Add 'int' and 'float' ini option types Fixes #11381 --------- Co-authored-by: Bruno Oliveira Co-authored-by: Florian Bruhin --- changelog/11381.improvement.rst | 17 +++++++ src/_pytest/config/__init__.py | 22 +++++++-- src/_pytest/config/argparsing.py | 27 +++++++++++- src/_pytest/config/findpaths.py | 17 +++++-- testing/test_config.py | 76 ++++++++++++++++++++++++++++++++ 5 files changed, 151 insertions(+), 8 deletions(-) create mode 100644 changelog/11381.improvement.rst diff --git a/changelog/11381.improvement.rst b/changelog/11381.improvement.rst new file mode 100644 index 00000000000..74c080cc188 --- /dev/null +++ b/changelog/11381.improvement.rst @@ -0,0 +1,17 @@ +The ``type`` parameter of the ``parser.addini`` method now accepts `"int"` and ``"float"`` parameters, facilitating the parsing of configuration values in the configuration file. + +Example: + +.. code-block:: python + + def pytest_addoption(parser): + parser.addini("int_value", type="int", default=2, help="my int value") + parser.addini("float_value", type="float", default=4.2, help="my float value") + +The `pytest.ini` file: + +.. code-block:: ini + + [pytest] + int_value = 3 + float_value = 5.4 diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 9e5b192b335..02da5cf9229 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1587,6 +1587,8 @@ def getini(self, name: str): ``paths``, ``pathlist``, ``args`` and ``linelist`` : empty list ``[]`` ``bool`` : ``False`` ``string`` : empty string ``""`` + ``int`` : ``0`` + ``float`` : ``0.0`` If neither the ``default`` nor the ``type`` parameter is passed while registering the configuration through @@ -1605,9 +1607,11 @@ def getini(self, name: str): # Meant for easy monkeypatching by legacypath plugin. # Can be inlined back (with no cover removed) once legacypath is gone. - def _getini_unknown_type(self, name: str, type: str, value: str | list[str]): - msg = f"unknown configuration type: {type}" - raise ValueError(msg, value) # pragma: no cover + def _getini_unknown_type(self, name: str, type: str, value: object): + msg = ( + f"Option {name} has unknown configuration type {type} with value {value!r}" + ) + raise ValueError(msg) # pragma: no cover def _getini(self, name: str): try: @@ -1656,6 +1660,18 @@ def _getini(self, name: str): return _strtobool(str(value).strip()) elif type == "string": return value + elif type == "int": + if not isinstance(value, str): + raise TypeError( + f"Expected an int string for option {name} of type integer, but got: {value!r}" + ) from None + return int(value) + elif type == "float": + if not isinstance(value, str): + raise TypeError( + f"Expected a float string for option {name} of type float, but got: {value!r}" + ) from None + return float(value) elif type is None: return value else: diff --git a/src/_pytest/config/argparsing.py b/src/_pytest/config/argparsing.py index d535fe1096a..948dfe8a510 100644 --- a/src/_pytest/config/argparsing.py +++ b/src/_pytest/config/argparsing.py @@ -191,6 +191,12 @@ def addini( * ``linelist``: a list of strings, separated by line breaks * ``paths``: a list of :class:`pathlib.Path`, separated as in a shell * ``pathlist``: a list of ``py.path``, separated as in a shell + * ``int``: an integer + * ``float``: a floating-point number + + .. versionadded:: 8.4 + + The ``float`` and ``int`` types. For ``paths`` and ``pathlist`` types, they are considered relative to the ini-file. In case the execution is happening without an ini-file defined, @@ -209,7 +215,17 @@ def addini( The value of ini-variables can be retrieved via a call to :py:func:`config.getini(name) `. """ - assert type in (None, "string", "paths", "pathlist", "args", "linelist", "bool") + assert type in ( + None, + "string", + "paths", + "pathlist", + "args", + "linelist", + "bool", + "int", + "float", + ) if default is NOT_SET: default = get_ini_default_for_type(type) @@ -218,7 +234,10 @@ def addini( def get_ini_default_for_type( - type: Literal["string", "paths", "pathlist", "args", "linelist", "bool"] | None, + type: Literal[ + "string", "paths", "pathlist", "args", "linelist", "bool", "int", "float" + ] + | None, ) -> Any: """ Used by addini to get the default value for a given ini-option type, when @@ -230,6 +249,10 @@ def get_ini_default_for_type( return [] elif type == "bool": return False + elif type == "int": + return 0 + elif type == "float": + return 0.0 else: return "" diff --git a/src/_pytest/config/findpaths.py b/src/_pytest/config/findpaths.py index a7f45bf593e..15bfbb0613e 100644 --- a/src/_pytest/config/findpaths.py +++ b/src/_pytest/config/findpaths.py @@ -5,6 +5,7 @@ import os from pathlib import Path import sys +from typing import TYPE_CHECKING import iniconfig @@ -15,6 +16,16 @@ from _pytest.pathlib import safe_exists +if TYPE_CHECKING: + from typing import Union + + from typing_extensions import TypeAlias + + # Even though TOML supports richer data types, all values are converted to str/list[str] during + # parsing to maintain compatibility with the rest of the configuration system. + ConfigDict: TypeAlias = dict[str, Union[str, list[str]]] + + def _parse_ini_config(path: Path) -> iniconfig.IniConfig: """Parse the given generic '.ini' file using legacy IniConfig parser, returning the parsed object. @@ -29,7 +40,7 @@ def _parse_ini_config(path: Path) -> iniconfig.IniConfig: def load_config_dict_from_file( filepath: Path, -) -> dict[str, str | list[str]] | None: +) -> ConfigDict | None: """Load pytest configuration from the given file path, if supported. Return None if the file does not contain valid pytest configuration. @@ -85,7 +96,7 @@ def make_scalar(v: object) -> str | list[str]: def locate_config( invocation_dir: Path, args: Iterable[Path], -) -> tuple[Path | None, Path | None, dict[str, str | list[str]]]: +) -> tuple[Path | None, Path | None, ConfigDict]: """Search in the list of arguments for a valid ini-file for pytest, and return a tuple of (rootdir, inifile, cfg-dict).""" config_names = [ @@ -172,7 +183,7 @@ def determine_setup( args: Sequence[str], rootdir_cmd_arg: str | None, invocation_dir: Path, -) -> tuple[Path, Path | None, dict[str, str | list[str]]]: +) -> tuple[Path, Path | None, ConfigDict]: """Determine the rootdir, inifile and ini configuration values from the command line arguments. diff --git a/testing/test_config.py b/testing/test_config.py index 53f26269f09..de07141238c 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -848,6 +848,82 @@ def pytest_addoption(parser): config = pytester.parseconfig() assert config.getini("strip") is bool_val + @pytest.mark.parametrize("str_val, int_val", [("10", 10), ("no-ini", 2)]) + def test_addini_int(self, pytester: Pytester, str_val: str, int_val: bool) -> None: + pytester.makeconftest( + """ + def pytest_addoption(parser): + parser.addini("ini_param", "", type="int", default=2) + """ + ) + if str_val != "no-ini": + pytester.makeini( + f""" + [pytest] + ini_param={str_val} + """ + ) + config = pytester.parseconfig() + assert config.getini("ini_param") == int_val + + def test_addini_int_invalid(self, pytester: Pytester) -> None: + pytester.makeconftest( + """ + def pytest_addoption(parser): + parser.addini("ini_param", "", type="int", default=2) + """ + ) + pytester.makepyprojecttoml( + """ + [tool.pytest.ini_options] + ini_param=["foo"] + """ + ) + config = pytester.parseconfig() + with pytest.raises( + TypeError, match="Expected an int string for option ini_param" + ): + _ = config.getini("ini_param") + + @pytest.mark.parametrize("str_val, float_val", [("10.5", 10.5), ("no-ini", 2.2)]) + def test_addini_float( + self, pytester: Pytester, str_val: str, float_val: bool + ) -> None: + pytester.makeconftest( + """ + def pytest_addoption(parser): + parser.addini("ini_param", "", type="float", default=2.2) + """ + ) + if str_val != "no-ini": + pytester.makeini( + f""" + [pytest] + ini_param={str_val} + """ + ) + config = pytester.parseconfig() + assert config.getini("ini_param") == float_val + + def test_addini_float_invalid(self, pytester: Pytester) -> None: + pytester.makeconftest( + """ + def pytest_addoption(parser): + parser.addini("ini_param", "", type="float", default=2.2) + """ + ) + pytester.makepyprojecttoml( + """ + [tool.pytest.ini_options] + ini_param=["foo"] + """ + ) + config = pytester.parseconfig() + with pytest.raises( + TypeError, match="Expected a float string for option ini_param" + ): + _ = config.getini("ini_param") + def test_addinivalue_line_existing(self, pytester: Pytester) -> None: pytester.makeconftest( """ From 7d73ace975a294f0a297fe19a6af92fbac7024b9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Feb 2025 06:43:55 +0100 Subject: [PATCH 308/445] build(deps): Bump pytest-django in /testing/plugins_integration (#13231) Bumps [pytest-django](https://github.com/pytest-dev/pytest-django) from 4.9.0 to 4.10.0. - [Release notes](https://github.com/pytest-dev/pytest-django/releases) - [Changelog](https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst) - [Commits](https://github.com/pytest-dev/pytest-django/compare/v4.9.0...v4.10.0) --- updated-dependencies: - dependency-name: pytest-django dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index ca4f6f700c4..5562329e1de 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -3,7 +3,7 @@ django==5.1.6 pytest-asyncio==0.25.3 pytest-bdd==8.1.0 pytest-cov==6.0.0 -pytest-django==4.9.0 +pytest-django==4.10.0 pytest-flakes==4.0.5 pytest-html==4.1.1 pytest-mock==3.14.0 From d68ad68e35277e8a1763dcc0b9425a95bc031cce Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 18 Feb 2025 07:17:58 -0300 Subject: [PATCH 309/445] [automated] Update plugin list (#13226) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 172 +++++++++++++++++-------------- 1 file changed, 94 insertions(+), 78 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index cf1f0902885..28492e22a62 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =8.2 - :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Jan 17, 2025 4 - Beta pytest>=6.2.0 + :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Feb 10, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Jul 04, 2024 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) :pypi:`pytest-async-mongodb` pytest plugin for async MongoDB Oct 18, 2017 5 - Production/Stable pytest (>=2.5.2) @@ -161,7 +161,7 @@ This list contains 1583 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Feb 05, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Feb 11, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -230,7 +230,7 @@ This list contains 1583 plugins. :pypi:`pytest-change-report` turn . into √,turn F into x Sep 14, 2020 N/A pytest :pypi:`pytest-change-xds` turn . into √,turn F into x Apr 16, 2022 N/A pytest :pypi:`pytest-chdir` A pytest fixture for changing current working directory Jan 28, 2020 N/A pytest (>=5.0.0,<6.0.0) - :pypi:`pytest-check` A pytest plugin that allows multiple failures per test. Aug 28, 2024 5 - Production/Stable pytest>=7.0.0 + :pypi:`pytest-check` A pytest plugin that allows multiple failures per test. Feb 13, 2025 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-checkdocs` check the README when running tests Apr 30, 2024 5 - Production/Stable pytest!=8.1.*,>=6; extra == "testing" :pypi:`pytest-checkipdb` plugin to check if there are ipdb debugs left Dec 04, 2023 5 - Production/Stable pytest >=2.9.2 :pypi:`pytest-check-library` check your missing library Jul 17, 2022 N/A N/A @@ -261,7 +261,7 @@ This list contains 1583 plugins. :pypi:`pytest-cloud` Distributed tests planner plugin for pytest testing framework. Oct 05, 2020 6 - Mature N/A :pypi:`pytest-cloudflare-worker` pytest plugin for testing cloudflare workers Mar 30, 2021 4 - Beta pytest (>=6.0.0) :pypi:`pytest-cloudist` Distribute tests to cloud machines without fuss Sep 02, 2022 4 - Beta pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-cmake` Provide CMake module for Pytest Jan 29, 2025 N/A pytest<9,>=4 + :pypi:`pytest-cmake` Provide CMake module for Pytest Feb 09, 2025 N/A pytest<9,>=4 :pypi:`pytest-cmake-presets` Execute CMake Presets via pytest Dec 26, 2022 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-cmdline-add-args` Pytest plugin for custom argument handling and Allure reporting. This plugin allows you to add arguments before running a test. Sep 01, 2024 N/A N/A :pypi:`pytest-cobra` PyTest plugin for testing Smart Contracts for Ethereum blockchain. Jun 29, 2019 3 - Alpha pytest (<4.0.0,>=3.7.1) @@ -330,7 +330,7 @@ This list contains 1583 plugins. :pypi:`pytest-dash` pytest fixtures to run dash applications. Mar 18, 2019 N/A N/A :pypi:`pytest-dashboard` May 30, 2024 N/A pytest<8.0.0,>=7.4.3 :pypi:`pytest-data` Useful functions for managing data for pytest fixtures Nov 01, 2016 5 - Production/Stable N/A - :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Oct 20, 2024 4 - Beta pytest + :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Feb 11, 2025 4 - Beta pytest :pypi:`pytest-databricks` Pytest plugin for remote Databricks notebooks testing Jul 29, 2020 N/A pytest :pypi:`pytest-datadir` pytest plugin for test data directories and files Feb 07, 2025 5 - Production/Stable pytest>=7.0 :pypi:`pytest-datadir-mgr` Manager for test data: downloads, artifact caching, and a tmpdir context. Apr 06, 2023 5 - Production/Stable pytest (>=7.1) @@ -353,7 +353,7 @@ This list contains 1583 plugins. :pypi:`pytest-dbt-adapter` A pytest plugin for testing dbt adapter plugins Nov 24, 2021 N/A pytest (<7,>=6) :pypi:`pytest-dbt-conventions` A pytest plugin for linting a dbt project's conventions Mar 02, 2022 N/A pytest (>=6.2.5,<7.0.0) :pypi:`pytest-dbt-core` Pytest extension for dbt. Jun 04, 2024 N/A pytest>=6.2.5; extra == "test" - :pypi:`pytest-dbt-duckdb` Add your description here Feb 07, 2025 N/A pytest>=8.3.4 + :pypi:`pytest-dbt-duckdb` Fearless testing for dbt models, powered by DuckDB. Feb 09, 2025 4 - Beta pytest>=8.3.4 :pypi:`pytest-dbt-postgres` Pytest tooling to unittest DBT & Postgres models Sep 03, 2024 N/A pytest<9.0.0,>=8.3.2 :pypi:`pytest-dbus-notification` D-BUS notifications for pytest results. Mar 05, 2014 5 - Production/Stable N/A :pypi:`pytest-dbx` Pytest plugin to run unit tests for dbx (Databricks CLI extensions) related code Nov 29, 2022 N/A pytest (>=7.1.3,<8.0.0) @@ -388,7 +388,7 @@ This list contains 1583 plugins. :pypi:`pytest-ditto` Snapshot testing pytest plugin with minimal ceremony and flexible persistence formats. Jun 09, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-ditto-pandas` pytest-ditto plugin for pandas snapshots. May 29, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-ditto-pyarrow` pytest-ditto plugin for pyarrow tables. Jun 09, 2024 4 - Beta pytest>=3.5.0 - :pypi:`pytest-django` A Django plugin for pytest. Sep 02, 2024 5 - Production/Stable pytest>=7.0.0 + :pypi:`pytest-django` A Django plugin for pytest. Feb 10, 2025 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-django-ahead` A Django plugin for pytest. Oct 27, 2016 5 - Production/Stable pytest (>=2.9) :pypi:`pytest-djangoapp` Nice pytest plugin to help you with Django pluggable application testing. May 19, 2023 4 - Beta pytest :pypi:`pytest-django-cache-xdist` A djangocachexdist plugin for pytest May 12, 2020 4 - Beta N/A @@ -475,15 +475,15 @@ This list contains 1583 plugins. :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Feb 06, 2025 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Feb 06, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Feb 06, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Feb 06, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Feb 06, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Feb 06, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Feb 06, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Feb 06, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Feb 06, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Feb 11, 2025 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Feb 11, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Feb 11, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Feb 11, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Feb 11, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Feb 11, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Feb 11, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Feb 11, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Feb 11, 2025 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -513,11 +513,11 @@ This list contains 1583 plugins. :pypi:`pytest_evm` The testing package containing tools to test Web3-based projects Sep 23, 2024 4 - Beta pytest<9.0.0,>=8.1.1 :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Nov 20, 2024 N/A pytest>=7 - :pypi:`pytest-exasol-backend` Nov 22, 2024 N/A pytest<9,>=7 - :pypi:`pytest-exasol-extension` Oct 10, 2024 N/A pytest<9,>=7 + :pypi:`pytest-exasol-backend` Feb 11, 2025 N/A pytest<9,>=7 + :pypi:`pytest-exasol-extension` Feb 11, 2025 N/A pytest<9,>=7 :pypi:`pytest-exasol-itde` Nov 22, 2024 N/A pytest<9,>=7 :pypi:`pytest-exasol-saas` Nov 22, 2024 N/A pytest<9,>=7 - :pypi:`pytest-exasol-slc` Nov 01, 2024 N/A pytest<9,>=7 + :pypi:`pytest-exasol-slc` Feb 11, 2025 N/A pytest<9,>=7 :pypi:`pytest-excel` pytest plugin for generating excel reports Jun 18, 2024 5 - Production/Stable pytest>3.6 :pypi:`pytest-exceptional` Better exceptions Mar 16, 2017 4 - Beta N/A :pypi:`pytest-exception-script` Walk your code through exception script to check it's resiliency to failures. Aug 04, 2020 3 - Alpha pytest @@ -612,7 +612,7 @@ This list contains 1583 plugins. :pypi:`pytest-forward-compatibility` A pytest plugin to shim pytest commandline options for fowards compatibility Sep 29, 2020 N/A N/A :pypi:`pytest-frappe` Pytest Frappe Plugin - A set of pytest fixtures to test Frappe applications Jul 30, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-freethreaded` pytest plugin for running parallel tests Oct 03, 2024 5 - Production/Stable pytest - :pypi:`pytest-freezeblaster` Wrap tests with fixtures in freeze_time Jan 23, 2025 N/A pytest>=6.2.5 + :pypi:`pytest-freezeblaster` Wrap tests with fixtures in freeze_time Feb 11, 2025 N/A pytest>=6.2.5 :pypi:`pytest-freezegun` Wrap tests with fixtures in freeze_time Jul 19, 2020 4 - Beta pytest (>=3.0.0) :pypi:`pytest-freezer` Pytest plugin providing a fixture interface for spulec/freezegun Dec 12, 2024 N/A pytest>=3.6 :pypi:`pytest-freeze-reqs` Check if requirement files are frozen Apr 29, 2021 N/A N/A @@ -634,7 +634,7 @@ This list contains 1583 plugins. :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Jan 22, 2025 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Feb 14, 2025 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -678,7 +678,7 @@ This list contains 1583 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Feb 08, 2025 3 - Alpha pytest==8.3.4 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Feb 15, 2025 3 - Alpha pytest==8.3.4 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -698,7 +698,7 @@ This list contains 1583 plugins. :pypi:`pytest-html-thread` pytest plugin for generating HTML reports Dec 29, 2020 5 - Production/Stable N/A :pypi:`pytest-http` Fixture "http" for http requests Aug 22, 2024 N/A pytest :pypi:`pytest-httpbin` Easily test your HTTP library against a local copy of httpbin Sep 18, 2024 5 - Production/Stable pytest; extra == "test" - :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace Jan 11, 2025 4 - Beta pytest>=7.0.0 + :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace. Feb 11, 2025 4 - Beta pytest>=7.0.0 :pypi:`pytest-http-mocker` Pytest plugin for http mocking (via https://github.com/vilus/mocker) Oct 20, 2019 N/A N/A :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Jan 21, 2025 3 - Alpha N/A @@ -746,12 +746,13 @@ This list contains 1583 plugins. :pypi:`pytest-integration-mark` Automatic integration test marking and excluding plugin for pytest May 22, 2023 N/A pytest (>=5.2) :pypi:`pytest-interactive` A pytest plugin for console based interactive test selection just after the collection phase Nov 30, 2017 3 - Alpha N/A :pypi:`pytest-intercept-remote` Pytest plugin for intercepting outgoing connection requests during pytest run. May 24, 2021 4 - Beta pytest (>=4.6) - :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Nov 19, 2024 4 - Beta pytest + :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Feb 13, 2025 4 - Beta pytest :pypi:`pytest-invenio` Pytest fixtures for Invenio. Dec 02, 2024 5 - Production/Stable pytest<9.0.0,>=6 :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-iovis` A Pytest plugin to enable Jupyter Notebook testing with Papermill Nov 06, 2024 4 - Beta pytest>=7.1.0 :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A + :pypi:`pytest-ipynb2` Pytest plugin to run tests in Jupyter Notebooks Feb 14, 2025 N/A pytest :pypi:`pytest-ipywidgets` Jan 29, 2025 N/A pytest :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Jan 16, 2025 4 - Beta pytest :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Dec 05, 2024 4 - Beta pytest>=5 @@ -859,7 +860,7 @@ This list contains 1583 plugins. :pypi:`pytest-marks` UNKNOWN Nov 23, 2012 3 - Alpha N/A :pypi:`pytest-mask-secrets` Pytest plugin to hide sensitive data in test reports Jan 28, 2025 N/A N/A :pypi:`pytest-matcher` Easy way to match captured \`pytest\` output against expectations stored in files Aug 01, 2024 5 - Production/Stable pytest - :pypi:`pytest-matchers` Matchers for pytest Aug 26, 2024 N/A pytest<9.0,>=7.0 + :pypi:`pytest-matchers` Matchers for pytest Feb 11, 2025 N/A pytest<9.0,>=7.0 :pypi:`pytest-match-skip` Skip matching marks. Matches partial marks using wildcards. May 15, 2019 4 - Beta pytest (>=4.4.1) :pypi:`pytest-mat-report` this is report Jan 20, 2021 N/A N/A :pypi:`pytest-matrix` Provide tools for generating tests from combinations of fixtures. Jun 24, 2020 5 - Production/Stable pytest (>=5.4.3,<6.0.0) @@ -876,7 +877,7 @@ This list contains 1583 plugins. :pypi:`pytest-memray` A simple plugin to use with pytest Jul 25, 2024 N/A pytest>=7.2 :pypi:`pytest-menu` A pytest plugin for console based interactive test selection just after the collection phase Oct 04, 2017 3 - Alpha pytest (>=2.4.2) :pypi:`pytest-mercurial` pytest plugin to write integration tests for projects using Mercurial Python internals Nov 21, 2020 1 - Planning N/A - :pypi:`pytest-mergify` Pytest plugin for Mergify Feb 06, 2025 N/A N/A + :pypi:`pytest-mergify` Pytest plugin for Mergify Feb 14, 2025 N/A N/A :pypi:`pytest-mesh` pytest_mesh插件 Aug 05, 2022 N/A pytest (==7.1.2) :pypi:`pytest-message` Pytest plugin for sending report message of marked tests execution Aug 04, 2022 N/A pytest (>=6.2.5) :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A @@ -933,7 +934,7 @@ This list contains 1583 plugins. :pypi:`pytest-mypy` Mypy static type checker plugin for Pytest Dec 18, 2022 4 - Beta pytest (>=6.2) ; python_version >= "3.10" :pypi:`pytest-mypyd` Mypy static type checker plugin for Pytest Aug 20, 2019 4 - Beta pytest (<4.7,>=2.8) ; python_version < "3.5" :pypi:`pytest-mypy-plugins` pytest plugin for writing tests for mypy plugins Dec 21, 2024 4 - Beta pytest>=7.0.0 - :pypi:`pytest-mypy-plugins-shim` Substitute for "pytest-mypy-plugins" for Python implementations which aren't supported by mypy. Apr 12, 2021 N/A pytest>=6.0.0 + :pypi:`pytest-mypy-plugins-shim` Substitute for "pytest-mypy-plugins" for Python implementations which aren't supported by mypy. Feb 14, 2025 N/A pytest>=6.0.0 :pypi:`pytest-mypy-runner` Run the mypy static type checker as a pytest test case Apr 23, 2024 N/A pytest>=8.0 :pypi:`pytest-mypy-testing` Pytest plugin to check mypy output. Mar 04, 2024 N/A pytest>=7,<9 :pypi:`pytest-mysql` MySQL process and client fixtures for pytest Dec 10, 2024 5 - Production/Stable pytest>=6.2 @@ -968,7 +969,7 @@ This list contains 1583 plugins. :pypi:`pytest-notion` A PyTest Reporter to send test runs to Notion.so Aug 07, 2019 N/A N/A :pypi:`pytest-nunit` A pytest plugin for generating NUnit3 test result XML output Feb 26, 2024 5 - Production/Stable N/A :pypi:`pytest-oar` PyTest plugin for the OAR testing framework May 02, 2023 N/A pytest>=6.0.1 - :pypi:`pytest-oarepo` Jan 28, 2025 N/A pytest>=7.1.2; extra == "local" + :pypi:`pytest-oarepo` Feb 14, 2025 N/A pytest>=7.1.2; extra == "base" :pypi:`pytest-object-getter` Import any object from a 3rd party module while mocking its namespace on demand. Jul 31, 2022 5 - Production/Stable pytest :pypi:`pytest-ochrus` pytest results data-base and HTML reporter Feb 21, 2018 4 - Beta N/A :pypi:`pytest-odc` A pytest plugin for simplifying ODC database tests Aug 04, 2023 4 - Beta pytest (>=3.5.0) @@ -994,7 +995,7 @@ This list contains 1583 plugins. :pypi:`pytest-order-modify` 新增run_marker 来自定义用例的执行顺序 Nov 04, 2022 N/A N/A :pypi:`pytest-osxnotify` OS X notifications for py.test results. May 15, 2015 N/A N/A :pypi:`pytest-ot` A pytest plugin for instrumenting test runs via OpenTelemetry Mar 21, 2024 N/A pytest; extra == "dev" - :pypi:`pytest-otel` OpenTelemetry plugin for Pytest Mar 18, 2024 N/A pytest==8.1.1 + :pypi:`pytest-otel` OpenTelemetry plugin for Pytest Feb 10, 2025 N/A pytest==8.3.4 :pypi:`pytest-override-env-var` Pytest mark to override a value of an environment variable. Feb 25, 2023 N/A N/A :pypi:`pytest-owner` Add owner mark for tests Aug 19, 2024 N/A pytest :pypi:`pytest-pact` A simple plugin to use with pytest Jan 07, 2019 4 - Beta N/A @@ -1127,7 +1128,7 @@ This list contains 1583 plugins. :pypi:`pytest-pyvenv` A package for create venv in tests Feb 27, 2024 N/A pytest ; extra == 'test' :pypi:`pytest-pyvista` Pytest-pyvista package Sep 29, 2023 4 - Beta pytest>=3.5.0 :pypi:`pytest-qanova` A pytest plugin to collect test information Sep 05, 2024 3 - Alpha pytest - :pypi:`pytest-qaseio` Pytest plugin for Qase.io integration Jan 08, 2025 5 - Production/Stable pytest<9.0.0,>=7.2.2 + :pypi:`pytest-qaseio` Pytest plugin for Qase.io integration Feb 11, 2025 5 - Production/Stable pytest<9.0.0,>=7.2.2 :pypi:`pytest-qasync` Pytest support for qasync. Jul 12, 2021 4 - Beta pytest (>=5.4.0) :pypi:`pytest-qatouch` Pytest plugin for uploading test results to your QA Touch Testrun. Feb 14, 2023 4 - Beta pytest (>=6.2.0) :pypi:`pytest-qgis` A pytest plugin for testing QGIS python plugins Jun 14, 2024 5 - Production/Stable pytest>=6.0 @@ -1258,7 +1259,7 @@ This list contains 1583 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Feb 08, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Feb 13, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1270,7 +1271,7 @@ This list contains 1583 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Feb 08, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Feb 13, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1451,7 +1452,6 @@ This list contains 1583 plugins. :pypi:`pytest-test-tracer-for-pytest` A plugin that allows coll test data for use on Test Tracer Jun 28, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-test-tracer-for-pytest-bdd` A plugin that allows coll test data for use on Test Tracer Aug 20, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-test-utils` Feb 08, 2024 N/A pytest >=3.9 - :pypi:`pytest-test-yaml` a pytest test package Feb 08, 2025 N/A pytest :pypi:`pytest-tesults` Tesults plugin for pytest Nov 12, 2024 5 - Production/Stable pytest>=3.5.0 :pypi:`pytest-textual-snapshot` Snapshot testing for Textual apps Jan 23, 2025 5 - Production/Stable pytest>=8.0.0 :pypi:`pytest-tezos` pytest-ligo Jan 16, 2020 4 - Beta N/A @@ -1522,6 +1522,7 @@ This list contains 1583 plugins. :pypi:`pytest-unhandled-exception-exit-code` Plugin for py.test set a different exit code on uncaught exceptions Jun 22, 2020 5 - Production/Stable pytest (>=2.3) :pypi:`pytest-unique` Pytest fixture to generate unique values. Jan 03, 2025 N/A pytest<8.0.0,>=7.4.2 :pypi:`pytest-unittest-filter` A pytest plugin for filtering unittest-based test classes Jan 12, 2019 4 - Beta pytest (>=3.1.0) + :pypi:`pytest-unittest-id-runner` A pytest plugin to run tests using unittest-style test IDs Feb 09, 2025 N/A pytest>=6.0.0 :pypi:`pytest-unmagic` Pytest fixtures with conventional import semantics Oct 22, 2024 5 - Production/Stable pytest :pypi:`pytest-unmarked` Run only unmarked tests Aug 27, 2019 5 - Production/Stable N/A :pypi:`pytest-unordered` Test equality of unordered collections in pytest Jul 05, 2024 4 - Beta pytest>=7.0.0 @@ -1595,6 +1596,7 @@ This list contains 1583 plugins. :pypi:`pytest-xvfb` A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. May 29, 2023 4 - Beta pytest (>=2.8.1) :pypi:`pytest-xvirt` A pytest plugin to virtualize test. For example to transparently running them on a remote box. Dec 15, 2024 4 - Beta pytest>=7.2.2 :pypi:`pytest-yaml` This plugin is used to load yaml output to your test using pytest framework. Oct 05, 2018 N/A pytest + :pypi:`pytest-yaml-fei` a pytest yaml allure package Feb 09, 2025 N/A pytest :pypi:`pytest-yaml-sanmu` Pytest plugin for generating test cases with YAML. In test cases, you can use markers, fixtures, variables, and even call Python functions. Jan 03, 2025 N/A pytest>=8.2.2 :pypi:`pytest-yamltree` Create or check file/directory trees described by YAML Mar 02, 2020 4 - Beta pytest (>=3.1.1) :pypi:`pytest-yamlwsgi` Run tests against wsgi apps defined in yaml May 11, 2010 N/A N/A @@ -2211,7 +2213,7 @@ This list contains 1583 plugins. Pytest support for asyncio :pypi:`pytest-asyncio-concurrent` - *last release*: Jan 17, 2025, + *last release*: Feb 10, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -2512,7 +2514,7 @@ This list contains 1583 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Feb 05, 2025, + *last release*: Feb 11, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -2995,7 +2997,7 @@ This list contains 1583 plugins. A pytest fixture for changing current working directory :pypi:`pytest-check` - *last release*: Aug 28, 2024, + *last release*: Feb 13, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0.0 @@ -3212,7 +3214,7 @@ This list contains 1583 plugins. Distribute tests to cloud machines without fuss :pypi:`pytest-cmake` - *last release*: Jan 29, 2025, + *last release*: Feb 09, 2025, *status*: N/A, *requires*: pytest<9,>=4 @@ -3695,7 +3697,7 @@ This list contains 1583 plugins. Useful functions for managing data for pytest fixtures :pypi:`pytest-databases` - *last release*: Oct 20, 2024, + *last release*: Feb 11, 2025, *status*: 4 - Beta, *requires*: pytest @@ -3856,11 +3858,11 @@ This list contains 1583 plugins. Pytest extension for dbt. :pypi:`pytest-dbt-duckdb` - *last release*: Feb 07, 2025, - *status*: N/A, + *last release*: Feb 09, 2025, + *status*: 4 - Beta, *requires*: pytest>=8.3.4 - Add your description here + Fearless testing for dbt models, powered by DuckDB. :pypi:`pytest-dbt-postgres` *last release*: Sep 03, 2024, @@ -4101,7 +4103,7 @@ This list contains 1583 plugins. pytest-ditto plugin for pyarrow tables. :pypi:`pytest-django` - *last release*: Sep 02, 2024, + *last release*: Feb 10, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0.0 @@ -4710,63 +4712,63 @@ This list contains 1583 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: Feb 06, 2025, + *last release*: Feb 11, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: Feb 06, 2025, + *last release*: Feb 11, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: Feb 06, 2025, + *last release*: Feb 11, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: Feb 06, 2025, + *last release*: Feb 11, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. :pypi:`pytest-embedded-nuttx` - *last release*: Feb 06, 2025, + *last release*: Feb 11, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with NuttX. :pypi:`pytest-embedded-qemu` - *last release*: Feb 06, 2025, + *last release*: Feb 11, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: Feb 06, 2025, + *last release*: Feb 11, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: Feb 06, 2025, + *last release*: Feb 11, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: Feb 06, 2025, + *last release*: Feb 11, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -4976,14 +4978,14 @@ This list contains 1583 plugins. Pytest plugin for testing examples in docstrings and markdown files. :pypi:`pytest-exasol-backend` - *last release*: Nov 22, 2024, + *last release*: Feb 11, 2025, *status*: N/A, *requires*: pytest<9,>=7 :pypi:`pytest-exasol-extension` - *last release*: Oct 10, 2024, + *last release*: Feb 11, 2025, *status*: N/A, *requires*: pytest<9,>=7 @@ -5004,7 +5006,7 @@ This list contains 1583 plugins. :pypi:`pytest-exasol-slc` - *last release*: Nov 01, 2024, + *last release*: Feb 11, 2025, *status*: N/A, *requires*: pytest<9,>=7 @@ -5669,7 +5671,7 @@ This list contains 1583 plugins. pytest plugin for running parallel tests :pypi:`pytest-freezeblaster` - *last release*: Jan 23, 2025, + *last release*: Feb 11, 2025, *status*: N/A, *requires*: pytest>=6.2.5 @@ -5823,7 +5825,7 @@ This list contains 1583 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Jan 22, 2025, + *last release*: Feb 14, 2025, *status*: N/A, *requires*: pytest>=3.6 @@ -6131,7 +6133,7 @@ This list contains 1583 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Feb 08, 2025, + *last release*: Feb 15, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.4 @@ -6271,11 +6273,11 @@ This list contains 1583 plugins. Easily test your HTTP library against a local copy of httpbin :pypi:`pytest-httpdbg` - *last release*: Jan 11, 2025, + *last release*: Feb 11, 2025, *status*: 4 - Beta, *requires*: pytest>=7.0.0 - A pytest plugin to record HTTP(S) requests with stack trace + A pytest plugin to record HTTP(S) requests with stack trace. :pypi:`pytest-http-mocker` *last release*: Oct 20, 2019, @@ -6607,7 +6609,7 @@ This list contains 1583 plugins. Pytest plugin for intercepting outgoing connection requests during pytest run. :pypi:`pytest-interface-tester` - *last release*: Nov 19, 2024, + *last release*: Feb 13, 2025, *status*: 4 - Beta, *requires*: pytest @@ -6648,6 +6650,13 @@ This list contains 1583 plugins. THIS PROJECT IS ABANDONED + :pypi:`pytest-ipynb2` + *last release*: Feb 14, 2025, + *status*: N/A, + *requires*: pytest + + Pytest plugin to run tests in Jupyter Notebooks + :pypi:`pytest-ipywidgets` *last release*: Jan 29, 2025, *status*: N/A, @@ -7398,7 +7407,7 @@ This list contains 1583 plugins. Easy way to match captured \`pytest\` output against expectations stored in files :pypi:`pytest-matchers` - *last release*: Aug 26, 2024, + *last release*: Feb 11, 2025, *status*: N/A, *requires*: pytest<9.0,>=7.0 @@ -7517,7 +7526,7 @@ This list contains 1583 plugins. pytest plugin to write integration tests for projects using Mercurial Python internals :pypi:`pytest-mergify` - *last release*: Feb 06, 2025, + *last release*: Feb 14, 2025, *status*: N/A, *requires*: N/A @@ -7916,7 +7925,7 @@ This list contains 1583 plugins. pytest plugin for writing tests for mypy plugins :pypi:`pytest-mypy-plugins-shim` - *last release*: Apr 12, 2021, + *last release*: Feb 14, 2025, *status*: N/A, *requires*: pytest>=6.0.0 @@ -8161,9 +8170,9 @@ This list contains 1583 plugins. PyTest plugin for the OAR testing framework :pypi:`pytest-oarepo` - *last release*: Jan 28, 2025, + *last release*: Feb 14, 2025, *status*: N/A, - *requires*: pytest>=7.1.2; extra == "local" + *requires*: pytest>=7.1.2; extra == "base" @@ -8343,9 +8352,9 @@ This list contains 1583 plugins. A pytest plugin for instrumenting test runs via OpenTelemetry :pypi:`pytest-otel` - *last release*: Mar 18, 2024, + *last release*: Feb 10, 2025, *status*: N/A, - *requires*: pytest==8.1.1 + *requires*: pytest==8.3.4 OpenTelemetry plugin for Pytest @@ -9274,7 +9283,7 @@ This list contains 1583 plugins. A pytest plugin to collect test information :pypi:`pytest-qaseio` - *last release*: Jan 08, 2025, + *last release*: Feb 11, 2025, *status*: 5 - Production/Stable, *requires*: pytest<9.0.0,>=7.2.2 @@ -10191,7 +10200,7 @@ This list contains 1583 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Feb 08, 2025, + *last release*: Feb 13, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10275,7 +10284,7 @@ This list contains 1583 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Feb 08, 2025, + *last release*: Feb 13, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -11541,13 +11550,6 @@ This list contains 1583 plugins. - :pypi:`pytest-test-yaml` - *last release*: Feb 08, 2025, - *status*: N/A, - *requires*: pytest - - a pytest test package - :pypi:`pytest-tesults` *last release*: Nov 12, 2024, *status*: 5 - Production/Stable, @@ -12038,6 +12040,13 @@ This list contains 1583 plugins. A pytest plugin for filtering unittest-based test classes + :pypi:`pytest-unittest-id-runner` + *last release*: Feb 09, 2025, + *status*: N/A, + *requires*: pytest>=6.0.0 + + A pytest plugin to run tests using unittest-style test IDs + :pypi:`pytest-unmagic` *last release*: Oct 22, 2024, *status*: 5 - Production/Stable, @@ -12549,6 +12558,13 @@ This list contains 1583 plugins. This plugin is used to load yaml output to your test using pytest framework. + :pypi:`pytest-yaml-fei` + *last release*: Feb 09, 2025, + *status*: N/A, + *requires*: pytest + + a pytest yaml allure package + :pypi:`pytest-yaml-sanmu` *last release*: Jan 03, 2025, *status*: N/A, From 426fe19199a0e2e3ce5ba1fdd0ec45e9fd383ca9 Mon Sep 17 00:00:00 2001 From: John Litborn <11260241+jakkdl@users.noreply.github.com> Date: Tue, 18 Feb 2025 13:20:08 +0100 Subject: [PATCH 310/445] Apply suggestions from code review add `versionadded` Co-authored-by: Bruno Oliveira --- src/_pytest/_raises_group.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/_pytest/_raises_group.py b/src/_pytest/_raises_group.py index 92884409694..64b0388a103 100644 --- a/src/_pytest/_raises_group.py +++ b/src/_pytest/_raises_group.py @@ -290,7 +290,10 @@ def _check_type(self, exception: BaseException) -> TypeGuard[BaseExcT_co_default @final class RaisesGroup(AbstractRaises[BaseExceptionGroup[BaseExcT_co]]): - """Contextmanager for checking for an expected :exc:`ExceptionGroup`. + """ + .. versionadded:: 8.4 + + Contextmanager for checking for an expected :exc:`ExceptionGroup`. This works similar to :func:`pytest.raises`, but allows for specifying the structure of an :exc:`ExceptionGroup`. :meth:`ExceptionInfo.group_contains` also tries to handle exception groups, but it is very bad at checking that you *didn't* get unexpected exceptions. @@ -309,7 +312,7 @@ class RaisesGroup(AbstractRaises[BaseExceptionGroup[BaseExcT_co]]): #. It will only catch exceptions wrapped in an exceptiongroup by default. - * With ``allow_unwrapped=True`` you can specify a single expected exception (or `RaisesExc`) and it will match + * With ``allow_unwrapped=True`` you can specify a single expected exception (or :class:`RaisesExc`) and it will match the exception even if it is not inside an :exc:`ExceptionGroup`. If you expect one of several different exception types you need to use a :class:`RaisesExc` object. From 7f9966bab49f7a76356ab10c56fc54ffb6a7eb70 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 18 Feb 2025 12:20:35 +0000 Subject: [PATCH 311/445] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/_pytest/_raises_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/_raises_group.py b/src/_pytest/_raises_group.py index 64b0388a103..a66eea45f94 100644 --- a/src/_pytest/_raises_group.py +++ b/src/_pytest/_raises_group.py @@ -292,7 +292,7 @@ def _check_type(self, exception: BaseException) -> TypeGuard[BaseExcT_co_default class RaisesGroup(AbstractRaises[BaseExceptionGroup[BaseExcT_co]]): """ .. versionadded:: 8.4 - + Contextmanager for checking for an expected :exc:`ExceptionGroup`. This works similar to :func:`pytest.raises`, but allows for specifying the structure of an :exc:`ExceptionGroup`. :meth:`ExceptionInfo.group_contains` also tries to handle exception groups, From 0cdc5da1faecba5f860f66c8b57d7d3b80b8bea5 Mon Sep 17 00:00:00 2001 From: John Litborn <11260241+jakkdl@users.noreply.github.com> Date: Tue, 18 Feb 2025 13:21:10 +0100 Subject: [PATCH 312/445] Update src/_pytest/_raises_group.py Co-authored-by: Bruno Oliveira --- src/_pytest/_raises_group.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/_pytest/_raises_group.py b/src/_pytest/_raises_group.py index a66eea45f94..5df3b8df9aa 100644 --- a/src/_pytest/_raises_group.py +++ b/src/_pytest/_raises_group.py @@ -176,7 +176,10 @@ def matches( @final class RaisesExc(AbstractRaises[BaseExcT_co_default]): - """Helper class to be used together with RaisesGroups when you want to specify requirements on sub-exceptions. + """ + .. versionadded:: 8.4 + + Helper class to be used together with RaisesGroups when you want to specify requirements on sub-exceptions. You don't need this if you only want to specify the type, since :class:`RaisesGroup` accepts ``type[BaseException]``. From cb3067436e963e24143fdd7e346e831b3924d280 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 18 Feb 2025 12:21:36 +0000 Subject: [PATCH 313/445] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/_pytest/_raises_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/_raises_group.py b/src/_pytest/_raises_group.py index 5df3b8df9aa..f31a9634af0 100644 --- a/src/_pytest/_raises_group.py +++ b/src/_pytest/_raises_group.py @@ -178,7 +178,7 @@ def matches( class RaisesExc(AbstractRaises[BaseExcT_co_default]): """ .. versionadded:: 8.4 - + Helper class to be used together with RaisesGroups when you want to specify requirements on sub-exceptions. You don't need this if you only want to specify the type, since :class:`RaisesGroup` From 9714dc0b5c467d70e672311bc7165bf8739f7a02 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Tue, 18 Feb 2025 15:11:00 +0100 Subject: [PATCH 314/445] doc improvements after review --- doc/en/how-to/assert.rst | 22 ++++++++++++++----- .../{_raises_group.py => raises_group.py} | 12 +++++----- 2 files changed, 24 insertions(+), 10 deletions(-) rename src/_pytest/{_raises_group.py => raises_group.py} (98%) diff --git a/doc/en/how-to/assert.rst b/doc/en/how-to/assert.rst index 08e030b8cab..c01e59a7a0e 100644 --- a/doc/en/how-to/assert.rst +++ b/doc/en/how-to/assert.rst @@ -279,12 +279,12 @@ exception at a specific level; exceptions contained directly in the top assert not excinfo.group_contains(RuntimeError, depth=2) assert not excinfo.group_contains(TypeError, depth=1) -Alternate form (legacy) -~~~~~~~~~~~~~~~~~~~~~~~ +Alternate `pytest.raises` form (legacy) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -There is an alternate form where you pass -a function that will be executed, along ``*args`` and ``**kwargs``, and :func:`pytest.raises` -will execute the function with the arguments and assert that the given exception is raised: +There is an alternate form of :func:`pytest.raises` where you pass +a function that will be executed, along with ``*args`` and ``**kwargs``. :func:`pytest.raises` +will then execute the function with those arguments and assert that the given exception is raised: .. code-block:: python @@ -329,6 +329,18 @@ This will only "xfail" if the test fails by raising ``IndexError`` or subclasses * Using :func:`pytest.raises` is likely to be better for cases where you are testing exceptions your own code is deliberately raising, which is the majority of cases. +You can also use :class:`pytest.RaisesGroup`: + +.. code-block:: python + + def f(): + raise ExceptionGroup("", [IndexError()]) + + + @pytest.mark.xfail(raises=RaisesGroup(IndexError)) + def test_f(): + f() + .. _`assertwarns`: diff --git a/src/_pytest/_raises_group.py b/src/_pytest/raises_group.py similarity index 98% rename from src/_pytest/_raises_group.py rename to src/_pytest/raises_group.py index f31a9634af0..a6caab919da 100644 --- a/src/_pytest/_raises_group.py +++ b/src/_pytest/raises_group.py @@ -197,9 +197,6 @@ class RaisesExc(AbstractRaises[BaseExcT_co_default]): ... with RaisesGroups(RaisesExc(check=lambda x: type(x) is ValueError)): ... - - Tip: if you install ``hypothesis`` and import it in ``conftest.py`` you will get - readable ``repr``'s of ``check`` callables in the output. """ # Trio bundled hypothesis monkeypatching, we will probably instead assume that @@ -367,8 +364,13 @@ class RaisesGroup(AbstractRaises[BaseExceptionGroup[BaseExcT_co]]): even though it generally does not care about the order of the exceptions in the group. To avoid the above you should specify the first :exc:`ValueError` with a :class:`RaisesExc` as well. - Tip: if you install ``hypothesis`` and import it in ``conftest.py`` you will get - readable ``repr``'s of ``check`` callables in the output. + .. note:: + When raised exceptions don't match the expected ones, you'll get a detailed error + message explaining why. This includes ``repr(check)`` if set, which in Python can be + overly verbose, showing memory locations etc etc. + + If installed and imported (in e.g. ``conftest.py``), the ``hypothesis`` library will + monkeypatch this output to provide shorter & more readable repr's. """ # allow_unwrapped=True requires: singular exception, exception not being From 4d2c70911b55f211eba704b8baedca38c79da62a Mon Sep 17 00:00:00 2001 From: jakkdl Date: Tue, 18 Feb 2025 15:16:36 +0100 Subject: [PATCH 315/445] fix imports after file rename --- src/_pytest/mark/structures.py | 2 +- src/_pytest/skipping.py | 2 +- src/pytest/__init__.py | 6 +++--- testing/python/raises_group.py | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 50225f7529f..b624a089617 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -23,11 +23,11 @@ from .._code import getfslineno from ..compat import NOTSET from ..compat import NotSetType -from _pytest._raises_group import AbstractRaises from _pytest.config import Config from _pytest.deprecated import check_ispytest from _pytest.deprecated import MARKED_FIXTURE from _pytest.outcomes import fail +from _pytest.raises_group import AbstractRaises from _pytest.scope import _ScopeName from _pytest.warning_types import PytestUnknownMarkWarning diff --git a/src/_pytest/skipping.py b/src/_pytest/skipping.py index 293bea704cb..20efefb84df 100644 --- a/src/_pytest/skipping.py +++ b/src/_pytest/skipping.py @@ -12,7 +12,6 @@ import traceback from typing import Optional -from _pytest._raises_group import AbstractRaises from _pytest.config import Config from _pytest.config import hookimpl from _pytest.config.argparsing import Parser @@ -21,6 +20,7 @@ from _pytest.outcomes import fail from _pytest.outcomes import skip from _pytest.outcomes import xfail +from _pytest.raises_group import AbstractRaises from _pytest.reports import BaseReport from _pytest.reports import TestReport from _pytest.runner import CallInfo diff --git a/src/pytest/__init__.py b/src/pytest/__init__.py index a16377ca6bb..e3e782654fe 100644 --- a/src/pytest/__init__.py +++ b/src/pytest/__init__.py @@ -6,9 +6,6 @@ from _pytest import __version__ from _pytest import version_tuple from _pytest._code import ExceptionInfo -from _pytest._raises_group import RaisesExc -from _pytest._raises_group import RaisesGroup -from _pytest._raises_group import RaisesGroup as raises_group from _pytest.assertion import register_assert_rewrite from _pytest.cacheprovider import Cache from _pytest.capture import CaptureFixture @@ -63,6 +60,9 @@ from _pytest.python import Package from _pytest.python_api import approx from _pytest.python_api import raises +from _pytest.raises_group import RaisesExc +from _pytest.raises_group import RaisesGroup +from _pytest.raises_group import RaisesGroup as raises_group from _pytest.recwarn import deprecated_call from _pytest.recwarn import WarningsRecorder from _pytest.recwarn import warns diff --git a/testing/python/raises_group.py b/testing/python/raises_group.py index 4ac6f8a7ced..60eb28386f8 100644 --- a/testing/python/raises_group.py +++ b/testing/python/raises_group.py @@ -9,11 +9,11 @@ from typing import TYPE_CHECKING from _pytest._code import ExceptionInfo -from _pytest._raises_group import RaisesExc -from _pytest._raises_group import RaisesGroup -from _pytest._raises_group import repr_callable from _pytest.outcomes import Failed from _pytest.pytester import Pytester +from _pytest.raises_group import RaisesExc +from _pytest.raises_group import RaisesGroup +from _pytest.raises_group import repr_callable import pytest From 9e38a9ed2c4375b91c0c4553608470987187b4e2 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Tue, 18 Feb 2025 16:00:09 +0100 Subject: [PATCH 316/445] fix another import --- src/_pytest/raises_group.py | 4 ++-- testing/typing_raises_group.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/_pytest/raises_group.py b/src/_pytest/raises_group.py index a6caab919da..9c2a6aa05e4 100644 --- a/src/_pytest/raises_group.py +++ b/src/_pytest/raises_group.py @@ -312,8 +312,8 @@ class RaisesGroup(AbstractRaises[BaseExceptionGroup[BaseExcT_co]]): #. It will only catch exceptions wrapped in an exceptiongroup by default. - * With ``allow_unwrapped=True`` you can specify a single expected exception (or :class:`RaisesExc`) and it will match - the exception even if it is not inside an :exc:`ExceptionGroup`. + * With ``allow_unwrapped=True`` you can specify a single expected exception (or :class:`RaisesExc`) and it will + match the exception even if it is not inside an :exc:`ExceptionGroup`. If you expect one of several different exception types you need to use a :class:`RaisesExc` object. #. By default it cares about the full structure with nested :exc:`ExceptionGroup`'s. You can specify nested diff --git a/testing/typing_raises_group.py b/testing/typing_raises_group.py index 87cce35b72d..3dd786672b6 100644 --- a/testing/typing_raises_group.py +++ b/testing/typing_raises_group.py @@ -6,8 +6,8 @@ from typing_extensions import assert_type -from _pytest._raises_group import RaisesExc -from _pytest._raises_group import RaisesGroup +from _pytest.raises_group import RaisesExc +from _pytest.raises_group import RaisesGroup if sys.version_info < (3, 11): From ff9dd38a7a194374eaafeae34f930aea8a749acb Mon Sep 17 00:00:00 2001 From: jakkdl Date: Tue, 18 Feb 2025 16:29:54 +0100 Subject: [PATCH 317/445] sed s/RaisesGroups/RaisesGroup --- src/_pytest/raises_group.py | 28 ++++++++++++++-------------- testing/typing_raises_group.py | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/_pytest/raises_group.py b/src/_pytest/raises_group.py index 9c2a6aa05e4..d9b514089de 100644 --- a/src/_pytest/raises_group.py +++ b/src/_pytest/raises_group.py @@ -179,7 +179,7 @@ class RaisesExc(AbstractRaises[BaseExcT_co_default]): """ .. versionadded:: 8.4 - Helper class to be used together with RaisesGroups when you want to specify requirements on sub-exceptions. + Helper class to be used together with RaisesGroup when you want to specify requirements on sub-exceptions. You don't need this if you only want to specify the type, since :class:`RaisesGroup` accepts ``type[BaseException]``. @@ -191,11 +191,11 @@ class RaisesExc(AbstractRaises[BaseExcT_co_default]): Examples:: - with RaisesGroups(RaisesExc(ValueError, match="string")) + with RaisesGroup(RaisesExc(ValueError, match="string")) ... - with RaisesGroups(RaisesExc(check=lambda x: x.args == (3, "hello"))): + with RaisesGroup(RaisesExc(check=lambda x: x.args == (3, "hello"))): ... - with RaisesGroups(RaisesExc(check=lambda x: type(x) is ValueError)): + with RaisesGroup(RaisesExc(check=lambda x: type(x) is ValueError)): ... """ @@ -323,33 +323,33 @@ class RaisesGroup(AbstractRaises[BaseExceptionGroup[BaseExcT_co]]): extracting all exceptions inside any nested :exc:`ExceptionGroup`, before matching. It does not care about the order of the exceptions, so - ``RaisesGroups(ValueError, TypeError)`` + ``RaisesGroup(ValueError, TypeError)`` is equivalent to - ``RaisesGroups(TypeError, ValueError)``. + ``RaisesGroup(TypeError, ValueError)``. Examples:: - with RaisesGroups(ValueError): + with RaisesGroup(ValueError): raise ExceptionGroup("", (ValueError(),)) - with RaisesGroups( + with RaisesGroup( ValueError, ValueError, RaisesExc(TypeError, match="expected int") ): ... - with RaisesGroups( + with RaisesGroup( KeyboardInterrupt, match="hello", check=lambda x: type(x) is BaseExceptionGroup, ): ... - with RaisesGroups(RaisesGroups(ValueError)): + with RaisesGroup(RaisesGroup(ValueError)): raise ExceptionGroup("", (ExceptionGroup("", (ValueError(),)),)) # flatten_subgroups - with RaisesGroups(ValueError, flatten_subgroups=True): + with RaisesGroup(ValueError, flatten_subgroups=True): raise ExceptionGroup("", (ExceptionGroup("", (ValueError(),)),)) # allow_unwrapped - with RaisesGroups(ValueError, allow_unwrapped=True): + with RaisesGroup(ValueError, allow_unwrapped=True): raise ValueError @@ -358,7 +358,7 @@ class RaisesGroup(AbstractRaises[BaseExceptionGroup[BaseExcT_co]]): The matching algorithm is greedy, which means cases such as this may fail:: - with RaisesGroups(ValueError, RaisesExc(ValueError, match="hello")): + with RaisesGroup(ValueError, RaisesExc(ValueError, match="hello")): raise ExceptionGroup("", (ValueError("hello"), ValueError("goodbye"))) even though it generally does not care about the order of the exceptions in the group. @@ -620,7 +620,7 @@ def matches( with pytest.raises(TypeError) as excinfo: ... - assert RaisesGroups(ValueError).matches(excinfo.value.__cause__) + assert RaisesGroup(ValueError).matches(excinfo.value.__cause__) # the above line is equivalent to myexc = excinfo.value.__cause assert isinstance(myexc, BaseExceptionGroup) diff --git a/testing/typing_raises_group.py b/testing/typing_raises_group.py index 3dd786672b6..6e91cbf6da1 100644 --- a/testing/typing_raises_group.py +++ b/testing/typing_raises_group.py @@ -155,7 +155,7 @@ def check_nested_raisesgroups_contextmanager() -> None: def check_nested_raisesgroups_matches() -> None: - """Check nested RaisesGroups with .matches""" + """Check nested RaisesGroup with .matches""" exc: ExceptionGroup[ExceptionGroup[ValueError]] = ExceptionGroup( "", (ExceptionGroup("", (ValueError(),)),), From 2c8cd64d5f0f4bf8ea6c9f5723f6422a03b28bf7 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Thu, 20 Feb 2025 16:38:02 +0100 Subject: [PATCH 318/445] make pytest.raises use RaisesExc... which made me notice about a million small things differing between raises and RaisesExc, and some random other stuff... --- src/_pytest/_code/code.py | 2 +- src/_pytest/python_api.py | 172 ++++--------- src/_pytest/raises_group.py | 399 ++++++++++++++++++++++-------- testing/python/raises.py | 63 ++++- testing/python/raises_group.py | 427 ++++++++++++++++++++++----------- testing/typing_raises_group.py | 6 +- 6 files changed, 687 insertions(+), 382 deletions(-) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 5b85d295d36..429b856596b 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -763,7 +763,7 @@ def match(self, regexp: str | re.Pattern[str]) -> Literal[True]: """ __tracebackhide__ = True value = self._stringify_exception(self.value) - msg = f"Regex pattern did not match.\n Regex: {regexp!r}\n Input: {value!r}" + msg = f"Raised exception did not match: Regex pattern did not match.\n Regex: {regexp!r}\n Input: {value!r}" if regexp == value: msg += "\n Did you mean to `re.escape()` the regex?" assert re.search(regexp, value), msg diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index c90f67f7b3d..8a11a128293 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -6,30 +6,25 @@ from collections.abc import Mapping from collections.abc import Sequence from collections.abc import Sized -from contextlib import AbstractContextManager from decimal import Decimal import math from numbers import Complex import pprint import re import sys -from types import TracebackType from typing import Any -from typing import cast -from typing import final -from typing import get_args -from typing import get_origin from typing import overload from typing import TYPE_CHECKING from typing import TypeVar import _pytest._code from _pytest.outcomes import fail +from _pytest.raises_group import BaseExcT_co_default +from _pytest.raises_group import RaisesExc if sys.version_info < (3, 11): - from exceptiongroup import BaseExceptionGroup - from exceptiongroup import ExceptionGroup + pass if TYPE_CHECKING: from numpy import ndarray @@ -791,7 +786,7 @@ def _as_numpy_array(obj: object) -> ndarray | None: # builtin pytest.raises helper -E = TypeVar("E", bound=BaseException) +E = TypeVar("E", bound=BaseException, default=BaseException) @overload @@ -799,7 +794,21 @@ def raises( expected_exception: type[E] | tuple[type[E], ...], *, match: str | re.Pattern[str] | None = ..., -) -> RaisesContext[E]: ... + check: Callable[[BaseExcT_co_default], bool] = ..., +) -> RaisesExc[E]: ... + + +@overload +def raises( + *, + match: str | re.Pattern[str], + # If exception_type is not provided, check() must do any typechecks itself. + check: Callable[[BaseException], bool] = ..., +) -> RaisesExc[BaseException]: ... + + +@overload +def raises(*, check: Callable[[BaseException], bool]) -> RaisesExc[BaseException]: ... @overload @@ -812,8 +821,10 @@ def raises( def raises( - expected_exception: type[E] | tuple[type[E], ...], *args: Any, **kwargs: Any -) -> RaisesContext[E] | _pytest._code.ExceptionInfo[E]: + expected_exception: type[E] | tuple[type[E], ...] | None = None, + *args: Any, + **kwargs: Any, +) -> RaisesExc[BaseException] | _pytest._code.ExceptionInfo[E]: r"""Assert that a code block/function call raises an exception type, or one of its subclasses. :param expected_exception: @@ -960,117 +971,38 @@ def raises( """ __tracebackhide__ = True + if not args: + if set(kwargs) - {"match", "check", "expected_exception"}: + msg = "Unexpected keyword arguments passed to pytest.raises: " + msg += ", ".join(sorted(kwargs)) + msg += "\nUse context-manager form instead?" + raise TypeError(msg) + + if expected_exception is None: + return RaisesExc(**kwargs) + return RaisesExc(expected_exception, **kwargs) + if not expected_exception: raise ValueError( f"Expected an exception type or a tuple of exception types, but got `{expected_exception!r}`. " f"Raising exceptions is already understood as failing the test, so you don't need " f"any special code to say 'this should never raise an exception'." ) - - expected_exceptions: tuple[type[E], ...] - origin_exc: type[E] | None = get_origin(expected_exception) - if isinstance(expected_exception, type): - expected_exceptions = (expected_exception,) - elif origin_exc and issubclass(origin_exc, BaseExceptionGroup): - expected_exceptions = (cast(type[E], expected_exception),) - else: - expected_exceptions = expected_exception - - def validate_exc(exc: type[E]) -> type[E]: - __tracebackhide__ = True - origin_exc: type[E] | None = get_origin(exc) - if origin_exc and issubclass(origin_exc, BaseExceptionGroup): - exc_type = get_args(exc)[0] - if ( - issubclass(origin_exc, ExceptionGroup) and exc_type in (Exception, Any) - ) or ( - issubclass(origin_exc, BaseExceptionGroup) - and exc_type in (BaseException, Any) - ): - return cast(type[E], origin_exc) - else: - raise ValueError( - f"Only `ExceptionGroup[Exception]` or `BaseExceptionGroup[BaseExeption]` " - f"are accepted as generic types but got `{exc}`. " - f"As `raises` will catch all instances of the specified group regardless of the " - f"generic argument specific nested exceptions has to be checked " - f"with `ExceptionInfo.group_contains()`" - ) - - elif not isinstance(exc, type) or not issubclass(exc, BaseException): - msg = "expected exception must be a BaseException type, not {}" # type: ignore[unreachable] - not_a = exc.__name__ if isinstance(exc, type) else type(exc).__name__ - raise TypeError(msg.format(not_a)) - else: - return exc - - expected_exceptions = tuple(validate_exc(exc) for exc in expected_exceptions) - - message = f"DID NOT RAISE {expected_exception}" - - if not args: - match: str | re.Pattern[str] | None = kwargs.pop("match", None) - if kwargs: - msg = "Unexpected keyword arguments passed to pytest.raises: " - msg += ", ".join(sorted(kwargs)) - msg += "\nUse context-manager form instead?" - raise TypeError(msg) - return RaisesContext(expected_exceptions, message, match) - else: - func = args[0] - if not callable(func): - raise TypeError(f"{func!r} object (type: {type(func)}) must be callable") - try: - func(*args[1:], **kwargs) - except expected_exceptions as e: - return _pytest._code.ExceptionInfo.from_exception(e) - fail(message) - - -# This doesn't work with mypy for now. Use fail.Exception instead. -raises.Exception = fail.Exception # type: ignore - - -@final -class RaisesContext(AbstractContextManager[_pytest._code.ExceptionInfo[E]]): - def __init__( - self, - expected_exception: type[E] | tuple[type[E], ...], - message: str, - match_expr: str | re.Pattern[str] | None = None, - ) -> None: - self.expected_exception = expected_exception - self.message = message - self.match_expr = match_expr - self.excinfo: _pytest._code.ExceptionInfo[E] | None = None - if self.match_expr is not None: - re_error = None - try: - re.compile(self.match_expr) - except re.error as e: - re_error = e - if re_error is not None: - fail(f"Invalid regex pattern provided to 'match': {re_error}") - - def __enter__(self) -> _pytest._code.ExceptionInfo[E]: - self.excinfo = _pytest._code.ExceptionInfo.for_later() - return self.excinfo - - def __exit__( - self, - exc_type: type[BaseException] | None, - exc_val: BaseException | None, - exc_tb: TracebackType | None, - ) -> bool: - __tracebackhide__ = True - if exc_type is None: - fail(self.message) - assert self.excinfo is not None - if not issubclass(exc_type, self.expected_exception): - return False - # Cast to narrow the exception type now that it's verified. - exc_info = cast(tuple[type[E], E, TracebackType], (exc_type, exc_val, exc_tb)) - self.excinfo.fill_unfilled(exc_info) - if self.match_expr is not None: - self.excinfo.match(self.match_expr) - return True + func = args[0] + if not callable(func): + raise TypeError(f"{func!r} object (type: {type(func)}) must be callable") + with RaisesExc(expected_exception) as excinfo: + func(*args[1:], **kwargs) + try: + return excinfo + finally: + del excinfo + + +# note: RaisesExc/RaisesGroup uses fail() internally, so this alias +# indicates (to [internal] plugins?) that `pytest.raises` will +# raise `_pytest.outcomes.Failed`, where +# `outcomes.Failed is outcomes.fail.Exception is raises.Exception` +# note: this is *not* the same as `_pytest.main.Failed` +# note: mypy does not recognize this attribute +raises.Exception = fail.Exception # type: ignore[attr-defined] diff --git a/src/_pytest/raises_group.py b/src/_pytest/raises_group.py index d9b514089de..e549b8e8975 100644 --- a/src/_pytest/raises_group.py +++ b/src/_pytest/raises_group.py @@ -6,15 +6,20 @@ from re import Pattern import sys from textwrap import indent +from typing import Any from typing import cast from typing import final from typing import Generic +from typing import get_args +from typing import get_origin from typing import Literal from typing import overload from typing import TYPE_CHECKING +import warnings from _pytest._code import ExceptionInfo from _pytest.outcomes import fail +from _pytest.warning_types import PytestWarning if TYPE_CHECKING: @@ -24,9 +29,12 @@ # for some reason Sphinx does not play well with 'from types import TracebackType' import types + from typing_extensions import ParamSpec from typing_extensions import TypeGuard from typing_extensions import TypeVar + P = ParamSpec("P") + # this conditional definition is because we want to allow a TypeVar default BaseExcT_co_default = TypeVar( "BaseExcT_co_default", @@ -81,31 +89,58 @@ def repr_callable(fun: Callable[[BaseExcT_1], bool]) -> str: return repr(fun) -def _exception_type_name(e: type[BaseException]) -> str: - return repr(e.__name__) +def backquote(s: str) -> str: + return "`" + s + "`" + + +def _exception_type_name( + e: type[BaseException] | tuple[type[BaseException], ...], +) -> str: + if isinstance(e, type): + return e.__name__ + if len(e) == 1: + return e[0].__name__ + return "(" + ", ".join(ee.__name__ for ee in e) + ")" def _check_raw_type( - expected_type: type[BaseException] | None, + expected_type: type[BaseException] | tuple[type[BaseException], ...] | None, exception: BaseException, ) -> str | None: - if expected_type is None: + if expected_type is None or expected_type == (): return None if not isinstance( exception, expected_type, ): - actual_type_str = _exception_type_name(type(exception)) - expected_type_str = _exception_type_name(expected_type) - if isinstance(exception, BaseExceptionGroup) and not issubclass( - expected_type, BaseExceptionGroup + actual_type_str = backquote(_exception_type_name(type(exception)) + "()") + expected_type_str = backquote(_exception_type_name(expected_type)) + if ( + isinstance(exception, BaseExceptionGroup) + and isinstance(expected_type, type) + and not issubclass(expected_type, BaseExceptionGroup) ): return f"Unexpected nested {actual_type_str}, expected {expected_type_str}" - return f"{actual_type_str} is not of type {expected_type_str}" + return f"{actual_type_str} is not an instance of {expected_type_str}" return None +def is_fully_escaped(s: str) -> bool: + # we know we won't compile with re.VERBOSE, so whitespace doesn't need to be escaped + metacharacters = "{}()+.*?^$[]" + + for i, c in enumerate(s): + if c in metacharacters and (i == 0 or s[i - 1] != "\\"): + return False + + return True + + +def unescape(s: str) -> str: + return re.sub(r"\\([{}()+-.*?^$\[\]\s\\])", r"\1", s) + + class AbstractRaises(ABC, Generic[BaseExcT_co]): """ABC with common functionality shared between RaisesExc and RaisesGroup""" @@ -115,15 +150,85 @@ def __init__( check: Callable[[BaseExcT_co], bool] | None, ) -> None: if isinstance(match, str): - self.match: Pattern[str] | None = re.compile(match) + # juggle error in order to avoid context to fail (necessary?) + re_error = None + try: + self.match: Pattern[str] | None = re.compile(match) + except re.error as e: + re_error = e + if re_error is not None: + fail(f"Invalid regex pattern provided to 'match': {re_error}") + if match == "": + warnings.warn( + PytestWarning( + "session.shouldstop cannot be unset after it has been set; ignoring." + "matching against an empty string will *always* pass. If you want " + "to check for an empty message you need to pass '^$'. If you don't " + "want to match you should pass `None` or leave out the parameter." + ), + stacklevel=2, + ) else: self.match = match + + # check if this is a fully escaped regex and has ^$ to match fully + # in which case we can do a proper diff on error + self.rawmatch: str | None = None + if isinstance(match, str) or ( + isinstance(match, Pattern) and match.flags == _REGEX_NO_FLAGS + ): + if isinstance(match, Pattern): + match = match.pattern + if ( + match + and match[0] == "^" + and match[-1] == "$" + and is_fully_escaped(match[1:-1]) + ): + self.rawmatch = unescape(match[1:-1]) + self.check = check self._fail_reason: str | None = None # used to suppress repeated printing of `repr(self.check)` self._nested: bool = False + # set in self._parse_exc + self.is_baseexception = False + + def _parse_exc( + self, exc: type[BaseExcT_1] | types.GenericAlias, expected: str + ) -> type[BaseExcT_1]: + if isinstance(exc, type) and issubclass(exc, BaseException): + if not issubclass(exc, Exception): + self.is_baseexception = True + return exc + # because RaisesGroup does not support variable number of exceptions there's + # still a use for RaisesExc(ExceptionGroup[Exception]). + origin_exc: type[BaseException] | None = get_origin(exc) + if origin_exc and issubclass(origin_exc, BaseExceptionGroup): + exc_type = get_args(exc)[0] + if ( + issubclass(origin_exc, ExceptionGroup) and exc_type in (Exception, Any) + ) or ( + issubclass(origin_exc, BaseExceptionGroup) + and exc_type in (BaseException, Any) + ): + if not isinstance(exc, Exception): + self.is_baseexception = True + return cast(type[BaseExcT_1], origin_exc) + else: + raise TypeError( + f"Only `ExceptionGroup[Exception]` or `BaseExceptionGroup[BaseExeption]` " + f"are accepted as generic types but got `{exc}`. " + f"As `raises` will catch all instances of the specified group regardless of the " + f"generic argument specific nested exceptions has to be checked " + f"with `RaisesGroup`." + ) + not_a = exc.__name__ if isinstance(exc, type) else type(exc).__name__ + msg = f"expected exception must be {expected}, not {not_a}" + raise TypeError(msg) + @property def fail_reason(self) -> str | None: """Set after a call to :meth:`matches` to give a human-readable reason for why the match failed. @@ -152,22 +257,37 @@ def _check_match(self, e: BaseException) -> bool: ): return True + # if we're matching a group, make sure we're explicit to reduce confusion + # if they're trying to match an exception contained within the group maybe_specify_type = ( - f" of {_exception_type_name(type(e))}" + f" the `{_exception_type_name(type(e))}()`" if isinstance(e, BaseExceptionGroup) else "" ) + if isinstance(self.rawmatch, str): + # TODO: it instructs to use `-v` to print leading text, but that doesn't work + # I also don't know if this is the proper entry point, or tool to use at all + from _pytest.assertion.util import _diff_text + from _pytest.assertion.util import dummy_highlighter + + diff = _diff_text(self.rawmatch, stringified_exception, dummy_highlighter) + self._fail_reason = ("\n" if diff[0][0] == "-" else "") + "\n".join(diff) + return False + + # I don't love "Regex"+"Input" vs something like "expected regex"+"exception message" + # when they're similar it's not always obvious which is which self._fail_reason = ( - f"Regex pattern {_match_pattern(self.match)!r}" - f" did not match {stringified_exception!r}{maybe_specify_type}" + f"Regex pattern did not match{maybe_specify_type}.\n" + f" Regex: {_match_pattern(self.match)!r}\n" + f" Input: {stringified_exception!r}" ) if _match_pattern(self.match) == stringified_exception: - self._fail_reason += "\n Did you mean to `re.escape()` the regex?" + self._fail_reason += "\n Did you mean to `re.escape()` the regex?" return False @abstractmethod def matches( - self: AbstractRaises[BaseExcT_1], exc_val: BaseException + self: AbstractRaises[BaseExcT_1], exception: BaseException ) -> TypeGuard[BaseExcT_1]: """Check if an exception matches the requirements of this AbstractRaises. If it fails, :meth:`AbstractRaises.fail_reason` should be set. @@ -208,18 +328,20 @@ class RaisesExc(AbstractRaises[BaseExcT_co_default]): @overload def __init__( self: RaisesExc[BaseExcT_co_default], - exception_type: type[BaseExcT_co_default], - match: str | Pattern[str] = ..., - check: Callable[[BaseExcT_co_default], bool] = ..., + expected_exception: ( + type[BaseExcT_co_default] | tuple[type[BaseExcT_co_default], ...] + ), + match: str | Pattern[str] | None = ..., + check: Callable[[BaseExcT_co_default], bool] | None = ..., ) -> None: ... @overload def __init__( self: RaisesExc[BaseException], # Give E a value. *, - match: str | Pattern[str], + match: str | Pattern[str] | None, # If exception_type is not provided, check() must do any typechecks itself. - check: Callable[[BaseException], bool] = ..., + check: Callable[[BaseException], bool] | None = ..., ) -> None: ... @overload @@ -227,22 +349,31 @@ def __init__(self, *, check: Callable[[BaseException], bool]) -> None: ... def __init__( self, - exception_type: type[BaseExcT_co_default] | None = None, + expected_exception: ( + type[BaseExcT_co_default] | tuple[type[BaseExcT_co_default], ...] | None + ) = None, match: str | Pattern[str] | None = None, check: Callable[[BaseExcT_co_default], bool] | None = None, ): super().__init__(match, check) - if exception_type is None and match is None and check is None: + if isinstance(expected_exception, tuple): + expected_exceptions = expected_exception + elif expected_exception is None: + expected_exceptions = () + else: + expected_exceptions = (expected_exception,) + + if (expected_exceptions == ()) and match is None and check is None: raise ValueError("You must specify at least one parameter to match on.") - if exception_type is not None and not issubclass(exception_type, BaseException): - raise TypeError( - f"exception_type {exception_type} must be a subclass of BaseException", - ) - self.exception_type = exception_type + + self.expected_exceptions = tuple( + self._parse_exc(e, expected="a BaseException type") + for e in expected_exceptions + ) def matches( self, - exception: BaseException, + exception: BaseException | None, ) -> TypeGuard[BaseExcT_co_default]: """Check if an exception matches the requirements of this :class:`RaisesExc`. If it fails, :attr:`RaisesExc.fail_reason` will be set. @@ -262,6 +393,9 @@ def matches( assert re.search("foo", str(excinfo.value.__cause__) """ + if exception is None: + self._fail_reason = "exception is None" + return False if not self._check_type(exception): return False @@ -272,8 +406,8 @@ def matches( def __repr__(self) -> str: parameters = [] - if self.exception_type is not None: - parameters.append(self.exception_type.__name__) + if self.expected_exceptions: + parameters.append(_exception_type_name(self.expected_exceptions)) if self.match is not None: # If no flags were specified, discard the redundant re.compile() here. parameters.append( @@ -284,9 +418,50 @@ def __repr__(self) -> str: return f"RaisesExc({', '.join(parameters)})" def _check_type(self, exception: BaseException) -> TypeGuard[BaseExcT_co_default]: - self._fail_reason = _check_raw_type(self.exception_type, exception) + self._fail_reason = _check_raw_type(self.expected_exceptions, exception) return self._fail_reason is None + def __enter__(self) -> ExceptionInfo[BaseExcT_co_default]: + self.excinfo: ExceptionInfo[BaseExcT_co_default] = ExceptionInfo.for_later() + return self.excinfo + + def expected_type(self) -> str: + if self.expected_exceptions == (): + return "BaseException" + return _exception_type_name(self.expected_exceptions) + + # TODO: move common code into superclass + def __exit__( + self, + exc_type: type[BaseException] | None, + exc_val: BaseException | None, + exc_tb: types.TracebackType | None, + ) -> bool: + __tracebackhide__ = True + if exc_type is None: + if not self.expected_exceptions: + fail("DID NOT RAISE any exception") + if len(self.expected_exceptions) > 1: + fail(f"DID NOT RAISE any of {self.expected_exceptions!r}") + + fail(f"DID NOT RAISE {self.expected_exceptions[0]!r}") + + assert self.excinfo is not None, ( + "Internal error - should have been constructed in __enter__" + ) + + if not self.matches(exc_val): + raise AssertionError(f"Raised exception did not match: {self._fail_reason}") + + # Cast to narrow the exception type now that it's verified.... + # even though the TypeGuard in self.matches should be narrowing + exc_info = cast( + "tuple[type[BaseExcT_co_default], BaseExcT_co_default, types.TracebackType]", + (exc_type, exc_val, exc_tb), + ) + self.excinfo.fill_unfilled(exc_info) + return True + @final class RaisesGroup(AbstractRaises[BaseExceptionGroup[BaseExcT_co]]): @@ -378,7 +553,7 @@ class RaisesGroup(AbstractRaises[BaseExceptionGroup[BaseExcT_co]]): @overload def __init__( self, - exception: type[BaseExcT_co] | RaisesExc[BaseExcT_co], + expected_exception: type[BaseExcT_co] | RaisesExc[BaseExcT_co], *, allow_unwrapped: Literal[True], flatten_subgroups: bool = False, @@ -388,7 +563,7 @@ def __init__( @overload def __init__( self, - exception: type[BaseExcT_co] | RaisesExc[BaseExcT_co], + expected_exception: type[BaseExcT_co] | RaisesExc[BaseExcT_co], *other_exceptions: type[BaseExcT_co] | RaisesExc[BaseExcT_co], flatten_subgroups: Literal[True], match: str | Pattern[str] | None = None, @@ -403,7 +578,7 @@ def __init__( @overload def __init__( self: RaisesGroup[ExcT_1], - exception: type[ExcT_1] | RaisesExc[ExcT_1], + expected_exception: type[ExcT_1] | RaisesExc[ExcT_1], *other_exceptions: type[ExcT_1] | RaisesExc[ExcT_1], match: str | Pattern[str] | None = None, check: Callable[[ExceptionGroup[ExcT_1]], bool] | None = None, @@ -412,7 +587,7 @@ def __init__( @overload def __init__( self: RaisesGroup[ExceptionGroup[ExcT_2]], - exception: RaisesGroup[ExcT_2], + expected_exception: RaisesGroup[ExcT_2], *other_exceptions: RaisesGroup[ExcT_2], match: str | Pattern[str] | None = None, check: Callable[[ExceptionGroup[ExceptionGroup[ExcT_2]]], bool] | None = None, @@ -421,7 +596,7 @@ def __init__( @overload def __init__( self: RaisesGroup[ExcT_1 | ExceptionGroup[ExcT_2]], - exception: type[ExcT_1] | RaisesExc[ExcT_1] | RaisesGroup[ExcT_2], + expected_exception: type[ExcT_1] | RaisesExc[ExcT_1] | RaisesGroup[ExcT_2], *other_exceptions: type[ExcT_1] | RaisesExc[ExcT_1] | RaisesGroup[ExcT_2], match: str | Pattern[str] | None = None, check: ( @@ -433,7 +608,7 @@ def __init__( @overload def __init__( self: RaisesGroup[BaseExcT_1], - exception: type[BaseExcT_1] | RaisesExc[BaseExcT_1], + expected_exception: type[BaseExcT_1] | RaisesExc[BaseExcT_1], *other_exceptions: type[BaseExcT_1] | RaisesExc[BaseExcT_1], match: str | Pattern[str] | None = None, check: Callable[[BaseExceptionGroup[BaseExcT_1]], bool] | None = None, @@ -442,7 +617,7 @@ def __init__( @overload def __init__( self: RaisesGroup[BaseExceptionGroup[BaseExcT_2]], - exception: RaisesGroup[BaseExcT_2], + expected_exception: RaisesGroup[BaseExcT_2], *other_exceptions: RaisesGroup[BaseExcT_2], match: str | Pattern[str] | None = None, check: ( @@ -453,7 +628,9 @@ def __init__( @overload def __init__( self: RaisesGroup[BaseExcT_1 | BaseExceptionGroup[BaseExcT_2]], - exception: type[BaseExcT_1] | RaisesExc[BaseExcT_1] | RaisesGroup[BaseExcT_2], + expected_exception: type[BaseExcT_1] + | RaisesExc[BaseExcT_1] + | RaisesGroup[BaseExcT_2], *other_exceptions: type[BaseExcT_1] | RaisesExc[BaseExcT_1] | RaisesGroup[BaseExcT_2], @@ -469,7 +646,9 @@ def __init__( def __init__( self: RaisesGroup[ExcT_1 | BaseExcT_1 | BaseExceptionGroup[BaseExcT_2]], - exception: type[BaseExcT_1] | RaisesExc[BaseExcT_1] | RaisesGroup[BaseExcT_2], + expected_exception: type[BaseExcT_1] + | RaisesExc[BaseExcT_1] + | RaisesGroup[BaseExcT_2], *other_exceptions: type[BaseExcT_1] | RaisesExc[BaseExcT_1] | RaisesGroup[BaseExcT_2], @@ -492,15 +671,9 @@ def __init__( check, ) super().__init__(match, check) - self.expected_exceptions: tuple[ - type[BaseExcT_co] | RaisesExc[BaseExcT_co] | RaisesGroup[BaseException], ... - ] = ( - exception, - *other_exceptions, - ) self.allow_unwrapped = allow_unwrapped self.flatten_subgroups: bool = flatten_subgroups - self.is_baseexceptiongroup = False + self.is_baseexception = False if allow_unwrapped and other_exceptions: raise ValueError( @@ -509,7 +682,7 @@ def __init__( " use a `RaisesExc`." " E.g. `RaisesExc(check=lambda e: isinstance(e, (...)))`", ) - if allow_unwrapped and isinstance(exception, RaisesGroup): + if allow_unwrapped and isinstance(expected_exception, RaisesGroup): raise ValueError( "`allow_unwrapped=True` has no effect when expecting a `RaisesGroup`." " You might want it in the expected `RaisesGroup`, or" @@ -525,33 +698,45 @@ def __init__( " assert RaisesGroup(...).matches(exc.value)` afterwards.", ) - # verify `expected_exceptions` and set `self.is_baseexceptiongroup` - for exc in self.expected_exceptions: - if isinstance(exc, RaisesGroup): - if self.flatten_subgroups: - raise ValueError( - "You cannot specify a nested structure inside a RaisesGroup with" - " `flatten_subgroups=True`. The parameter will flatten subgroups" - " in the raised exceptiongroup before matching, which would never" - " match a nested structure.", - ) - self.is_baseexceptiongroup |= exc.is_baseexceptiongroup - exc._nested = True - elif isinstance(exc, RaisesExc): - if exc.exception_type is not None: - # RaisesExc __init__ assures it's a subclass of BaseException - self.is_baseexceptiongroup |= not issubclass( - exc.exception_type, - Exception, - ) - exc._nested = True - elif isinstance(exc, type) and issubclass(exc, BaseException): - self.is_baseexceptiongroup |= not issubclass(exc, Exception) - else: - raise TypeError( - f'Invalid argument "{exc!r}" must be exception type, RaisesExc, or' - " RaisesGroup.", + self.expected_exceptions: tuple[ + type[BaseExcT_co] | RaisesExc[BaseExcT_co] | RaisesGroup[BaseException], ... + ] = tuple( + self._parse_excgroup(e, "a BaseException type, RaisesExc, or RaisesGroup") + for e in ( + expected_exception, + *other_exceptions, + ) + ) + + def _parse_excgroup( + self, + exc: ( + type[BaseExcT_co] + | types.GenericAlias + | RaisesExc[BaseExcT_1] + | RaisesGroup[BaseExcT_2] + ), + expected: str, + ) -> type[BaseExcT_co] | RaisesExc[BaseExcT_1] | RaisesGroup[BaseExcT_2]: + # verify exception type and set `self.is_baseexception` + if isinstance(exc, RaisesGroup): + if self.flatten_subgroups: + raise ValueError( + "You cannot specify a nested structure inside a RaisesGroup with" + " `flatten_subgroups=True`. The parameter will flatten subgroups" + " in the raised exceptiongroup before matching, which would never" + " match a nested structure.", ) + self.is_baseexception |= exc.is_baseexception + exc._nested = True + return exc + elif isinstance(exc, RaisesExc): + self.is_baseexception |= exc.is_baseexception + exc._nested = True + return exc + else: + # validate_exc transforms GenericAlias ExceptionGroup[Exception] -> type[ExceptionGroup] + return super()._parse_exc(exc, expected) @overload def __enter__( @@ -601,17 +786,17 @@ def _unroll_exceptions( @overload def matches( self: RaisesGroup[ExcT_1], - exc_val: BaseException | None, + exception: BaseException | None, ) -> TypeGuard[ExceptionGroup[ExcT_1]]: ... @overload def matches( self: RaisesGroup[BaseExcT_1], - exc_val: BaseException | None, + exception: BaseException | None, ) -> TypeGuard[BaseExceptionGroup[BaseExcT_1]]: ... def matches( self, - exc_val: BaseException | None, + exception: BaseException | None, ) -> TypeGuard[BaseExceptionGroup[BaseExcT_co]]: """Check if an exception matches the requirements of this RaisesGroup. If it fails, `RaisesGroup.fail_reason` will be set. @@ -628,19 +813,19 @@ def matches( assert isinstance(myexc.exceptions[0], ValueError) """ self._fail_reason = None - if exc_val is None: + if exception is None: self._fail_reason = "exception is None" return False - if not isinstance(exc_val, BaseExceptionGroup): + if not isinstance(exception, BaseExceptionGroup): # we opt to only print type of the exception here, as the repr would # likely be quite long - not_group_msg = f"{type(exc_val).__name__!r} is not an exception group" + not_group_msg = f"`{type(exception).__name__}()` is not an exception group" if len(self.expected_exceptions) > 1: self._fail_reason = not_group_msg return False # if we have 1 expected exception, check if it would work even if # allow_unwrapped is not set - res = self._check_expected(self.expected_exceptions[0], exc_val) + res = self._check_expected(self.expected_exceptions[0], exception) if res is None and self.allow_unwrapped: return True @@ -654,11 +839,11 @@ def matches( self._fail_reason = not_group_msg return False - actual_exceptions: Sequence[BaseException] = exc_val.exceptions + actual_exceptions: Sequence[BaseException] = exception.exceptions if self.flatten_subgroups: actual_exceptions = self._unroll_exceptions(actual_exceptions) - if not self._check_match(exc_val): + if not self._check_match(exception): self._fail_reason = cast(str, self._fail_reason) old_reason = self._fail_reason if ( @@ -670,8 +855,10 @@ def matches( assert self.match is not None, "can't be None if _check_match failed" assert self._fail_reason is old_reason is not None self._fail_reason += ( - f", but matched the expected {self._repr_expected(expected)}." - f" You might want RaisesGroup(RaisesExc({expected.__name__}, match={_match_pattern(self.match)!r}))" + f"\n" + f" but matched the expected `{self._repr_expected(expected)}`.\n" + f" You might want " + f"`RaisesGroup(RaisesExc({expected.__name__}, match={_match_pattern(self.match)!r}))`" ) else: self._fail_reason = old_reason @@ -679,7 +866,7 @@ def matches( # do the full check on expected exceptions if not self._check_exceptions( - exc_val, + exception, actual_exceptions, ): self._fail_reason = cast(str, self._fail_reason) @@ -694,8 +881,8 @@ def matches( ) and any(isinstance(e, BaseExceptionGroup) for e in actual_exceptions) and self._check_exceptions( - exc_val, - self._unroll_exceptions(exc_val.exceptions), + exception, + self._unroll_exceptions(exception.exceptions), ) ): # only indent if it's a single-line reason. In a multi-line there's already @@ -709,9 +896,11 @@ def matches( self._fail_reason = old_reason return False - # Only run `self.check` once we know `exc_val` is of the correct type. - if not self._check_check(exc_val): - reason = cast(str, self._fail_reason) + f" on the {type(exc_val).__name__}" + # Only run `self.check` once we know `exception` is of the correct type. + if not self._check_check(exception): + reason = ( + cast(str, self._fail_reason) + f" on the {type(exception).__name__}" + ) if ( len(actual_exceptions) == len(self.expected_exceptions) == 1 and isinstance(expected := self.expected_exceptions[0], type) @@ -758,22 +947,24 @@ def _repr_expected(e: type[BaseException] | AbstractRaises[BaseException]) -> st @overload def _check_exceptions( self: RaisesGroup[ExcT_1], - _exc_val: Exception, + _exception: Exception, actual_exceptions: Sequence[Exception], ) -> TypeGuard[ExceptionGroup[ExcT_1]]: ... @overload def _check_exceptions( self: RaisesGroup[BaseExcT_1], - _exc_val: BaseException, + _exception: BaseException, actual_exceptions: Sequence[BaseException], ) -> TypeGuard[BaseExceptionGroup[BaseExcT_1]]: ... def _check_exceptions( self, - _exc_val: BaseException, + _exception: BaseException, actual_exceptions: Sequence[BaseException], ) -> TypeGuard[BaseExceptionGroup[BaseExcT_co]]: """Helper method for RaisesGroup.matches that attempts to pair up expected and actual exceptions""" + # The _exception parameter is not used, but necessary for the TypeGuard + # full table with all results results = ResultHolder(self.expected_exceptions, actual_exceptions) @@ -871,9 +1062,11 @@ def _check_exceptions( if results.get_result(i_exp, i_actual) is None: # we print full repr of match target s += ( - f"\n{indent_2}It matches {actual!r} which was paired with " - + self._repr_expected( - self.expected_exceptions[rev_matches[i_actual]] + f"\n{indent_2}It matches {backquote(repr(actual))} which was paired with " + + backquote( + self._repr_expected( + self.expected_exceptions[rev_matches[i_actual]] + ) ) ) @@ -891,8 +1084,8 @@ def _check_exceptions( if res is None: # we print full repr of match target s += ( - f"\n{indent_2}It matches {self._repr_expected(expected)} " - f"which was paired with {actual_exceptions[matches[i_exp]]!r}" + f"\n{indent_2}It matches {backquote(self._repr_expected(expected))} " + f"which was paired with {backquote(repr(actual_exceptions[matches[i_exp]]))}" ) if len(self.expected_exceptions) == len(actual_exceptions) and possible_match( @@ -915,12 +1108,14 @@ def __exit__( ) -> bool: __tracebackhide__ = True if exc_type is None: - fail(f"DID NOT RAISE any exception, expected {self.expected_type()}") + fail(f"DID NOT RAISE any exception, expected `{self.expected_type()}`") assert self.excinfo is not None, ( "Internal error - should have been constructed in __enter__" ) + # group_str is the only thing that differs between RaisesExc and RaisesGroup... + # I might just scrap it? Or make it part of fail_reason group_str = ( "(group)" if self.allow_unwrapped and not issubclass(exc_type, BaseExceptionGroup) @@ -943,14 +1138,14 @@ def expected_type(self) -> str: subexcs = [] for e in self.expected_exceptions: if isinstance(e, RaisesExc): - subexcs.append(str(e)) + subexcs.append(repr(e)) elif isinstance(e, RaisesGroup): subexcs.append(e.expected_type()) elif isinstance(e, type): subexcs.append(e.__name__) else: # pragma: no cover raise AssertionError("unknown type") - group_type = "Base" if self.is_baseexceptiongroup else "" + group_type = "Base" if self.is_baseexception else "" return f"{group_type}ExceptionGroup({', '.join(subexcs)})" diff --git a/testing/python/raises.py b/testing/python/raises.py index 2011c81615e..c7ecc301701 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -6,9 +6,14 @@ from _pytest.outcomes import Failed from _pytest.pytester import Pytester +from _pytest.warning_types import PytestWarning import pytest +def wrap_escape(s: str) -> str: + return "^" + re.escape(s) + "$" + + class TestRaises: def test_check_callable(self) -> None: with pytest.raises(TypeError, match=r".* must be callable"): @@ -23,13 +28,19 @@ def test_raises_function(self): assert "invalid literal" in str(excinfo.value) def test_raises_does_not_allow_none(self): - with pytest.raises(ValueError, match="Expected an exception type or"): + with pytest.raises( + ValueError, + match=wrap_escape("You must specify at least one parameter to match on."), + ): # We're testing that this invalid usage gives a helpful error, # so we can ignore Mypy telling us that None is invalid. pytest.raises(expected_exception=None) # type: ignore def test_raises_does_not_allow_empty_tuple(self): - with pytest.raises(ValueError, match="Expected an exception type or"): + with pytest.raises( + ValueError, + match=wrap_escape("You must specify at least one parameter to match on."), + ): pytest.raises(expected_exception=()) def test_raises_callable_no_exception(self) -> None: @@ -84,7 +95,7 @@ def test_noraise(): int() def test_raise_wrong_exception_passes_by(): - with pytest.raises(ZeroDivisionError): + with pytest.raises(AssertionError): with pytest.raises(ValueError): 1/0 """ @@ -181,7 +192,9 @@ def test_no_raise_message(self) -> None: else: assert False, "Expected pytest.raises.Exception" - @pytest.mark.parametrize("method", ["function", "function_match", "with"]) + @pytest.mark.parametrize( + "method", ["function", "function_match", "with", "with_raisesexc", "with_group"] + ) def test_raises_cyclic_reference(self, method): """Ensure pytest.raises does not leave a reference cycle (#1965).""" import gc @@ -197,9 +210,17 @@ def __call__(self): pytest.raises(ValueError, t) elif method == "function_match": pytest.raises(ValueError, t).match("^$") - else: + elif method == "with": with pytest.raises(ValueError): t() + elif method == "with_raisesexc": + with pytest.RaisesExc(ValueError): + t() + elif method == "with_group": + with pytest.RaisesGroup(ValueError, allow_unwrapped=True): + t() + else: + raise AssertionError("bad parametrization") # ensure both forms of pytest.raises don't leave exceptions in sys.exc_info() assert sys.exc_info() == (None, None, None) @@ -217,11 +238,11 @@ def test_raises_match(self) -> None: msg = "with base 16" expr = ( - "Regex pattern did not match.\n" + "Raised exception did not match: Regex pattern did not match.\n" f" Regex: {msg!r}\n" " Input: \"invalid literal for int() with base 10: 'asdf'\"" ) - with pytest.raises(AssertionError, match="(?m)" + re.escape(expr)): + with pytest.raises(AssertionError, match="^" + re.escape(expr) + "$"): with pytest.raises(ValueError, match=msg): int("asdf", base=10) @@ -239,12 +260,27 @@ def tfunc(match): pytest.raises(ValueError, tfunc, match="asdf").match("match=asdf") pytest.raises(ValueError, tfunc, match="").match("match=") + # empty string matches everything, which is probably not what the user wants + # FIXME: I have no clue what session.shouldstop is doing here + with pytest.warns( + PytestWarning, + match=wrap_escape( + "session.shouldstop cannot be unset after it has been set; ignoring.matching against " + "an empty string will *always* pass. If you want to check for an empty message you " + "need to pass '^$'. If you don't want to match you should pass `None` or leave out the parameter." + ), + ): + pytest.raises(match="") + def test_match_failure_string_quoting(self): with pytest.raises(AssertionError) as excinfo: with pytest.raises(AssertionError, match="'foo"): raise AssertionError("'bar") (msg,) = excinfo.value.args - assert msg == '''Regex pattern did not match.\n Regex: "'foo"\n Input: "'bar"''' + assert ( + msg + == '''Raised exception did not match: Regex pattern did not match.\n Regex: "'foo"\n Input: "'bar"''' + ) def test_match_failure_exact_string_message(self): message = "Oh here is a message with (42) numbers in parameters" @@ -253,7 +289,7 @@ def test_match_failure_exact_string_message(self): raise AssertionError(message) (msg,) = excinfo.value.args assert msg == ( - "Regex pattern did not match.\n" + "Raised exception did not match: Regex pattern did not match.\n" " Regex: 'Oh here is a message with (42) numbers in parameters'\n" " Input: 'Oh here is a message with (42) numbers in parameters'\n" " Did you mean to `re.escape()` the regex?" @@ -265,7 +301,12 @@ def test_raises_match_wrong_type(self): pytest should throw the unexpected exception - the pattern match is not really relevant if we got a different exception. """ - with pytest.raises(ValueError): + with pytest.raises( + AssertionError, + match=wrap_escape( + "Raised exception did not match: `ValueError()` is not an instance of `IndexError`" + ), + ): with pytest.raises(IndexError, match="nomatch"): int("asdf") @@ -301,6 +342,8 @@ def __class__(self): assert "via __class__" in excinfo.value.args[0] def test_raises_context_manager_with_kwargs(self): + with pytest.raises(expected_exception=ValueError): + raise ValueError with pytest.raises(TypeError) as excinfo: with pytest.raises(OSError, foo="bar"): # type: ignore[call-overload] pass diff --git a/testing/python/raises_group.py b/testing/python/raises_group.py index 60eb28386f8..5e00aaa06bb 100644 --- a/testing/python/raises_group.py +++ b/testing/python/raises_group.py @@ -6,7 +6,6 @@ from contextlib import AbstractContextManager import re import sys -from typing import TYPE_CHECKING from _pytest._code import ExceptionInfo from _pytest.outcomes import Failed @@ -21,15 +20,12 @@ from exceptiongroup import BaseExceptionGroup from exceptiongroup import ExceptionGroup -if TYPE_CHECKING: - from _pytest.python_api import RaisesContext - def wrap_escape(s: str) -> str: return "^" + re.escape(s) + "$" -def fails_raises_group(msg: str, add_prefix: bool = True) -> RaisesContext[Failed]: +def fails_raises_group(msg: str, add_prefix: bool = True) -> RaisesExc[Failed]: assert msg[-1] != "\n", ( "developer error, expected string should not end with newline" ) @@ -40,8 +36,9 @@ def fails_raises_group(msg: str, add_prefix: bool = True) -> RaisesContext[Faile def test_raises_group() -> None: with pytest.raises( TypeError, + # TODO: bad sentence structure match=wrap_escape( - f'Invalid argument "{ValueError()!r}" must be exception type, RaisesExc, or RaisesGroup.', + "expected exception must be a BaseException type, RaisesExc, or RaisesGroup, not ValueError", ), ): RaisesGroup(ValueError()) # type: ignore[call-overload] @@ -49,7 +46,7 @@ def test_raises_group() -> None: raise ExceptionGroup("foo", (ValueError(),)) with ( - fails_raises_group("'SyntaxError' is not of type 'ValueError'"), + fails_raises_group("`SyntaxError()` is not an instance of `ValueError`"), RaisesGroup(ValueError), ): raise ExceptionGroup("foo", (SyntaxError(),)) @@ -95,7 +92,7 @@ def test_incorrect_number_exceptions() -> None: # will error if there's missing exceptions with ( fails_raises_group( - "1 matched exception. Too few exceptions raised, found no match for: ['SyntaxError']" + "1 matched exception. Too few exceptions raised, found no match for: [SyntaxError]" ), RaisesGroup(ValueError, SyntaxError), ): @@ -107,8 +104,8 @@ def test_incorrect_number_exceptions() -> None: "1 matched exception. \n" "Too few exceptions raised!\n" "The following expected exceptions did not find a match:\n" - " 'ValueError'\n" - " It matches ValueError() which was paired with 'ValueError'" + " ValueError\n" + " It matches `ValueError()` which was paired with `ValueError`" ), RaisesGroup(ValueError, ValueError), ): @@ -120,23 +117,23 @@ def test_incorrect_number_exceptions() -> None: "1 matched exception. \n" "Unexpected exception(s)!\n" "The following raised exceptions did not find a match\n" - " ValueError():\n" - " It matches 'ValueError' which was paired with ValueError()" + " ValueError('b'):\n" + " It matches `ValueError` which was paired with `ValueError('a')`" ), RaisesGroup(ValueError), ): - raise ExceptionGroup("", (ValueError(), ValueError())) + raise ExceptionGroup("", (ValueError("a"), ValueError("b"))) with ( fails_raises_group( "\n" "1 matched exception. \n" "The following expected exceptions did not find a match:\n" - " 'ValueError'\n" - " It matches ValueError() which was paired with 'ValueError'\n" + " ValueError\n" + " It matches `ValueError()` which was paired with `ValueError`\n" "The following raised exceptions did not find a match\n" " SyntaxError():\n" - " 'SyntaxError' is not of type 'ValueError'" + " `SyntaxError()` is not an instance of `ValueError`" ), RaisesGroup(ValueError, ValueError), ): @@ -172,14 +169,14 @@ def test_flatten_subgroups() -> None: # flatten_subgroups is not sufficient to catch fully unwrapped with ( fails_raises_group( - "'ValueError' is not an exception group, but would match with `allow_unwrapped=True`" + "`ValueError()` is not an exception group, but would match with `allow_unwrapped=True`" ), RaisesGroup(ValueError, flatten_subgroups=True), ): raise ValueError with ( fails_raises_group( - "RaisesGroup(ValueError, flatten_subgroups=True): 'ValueError' is not an exception group, but would match with `allow_unwrapped=True`" + "RaisesGroup(ValueError, flatten_subgroups=True): `ValueError()` is not an exception group, but would match with `allow_unwrapped=True`" ), RaisesGroup(RaisesGroup(ValueError, flatten_subgroups=True)), ): @@ -190,12 +187,12 @@ def test_flatten_subgroups() -> None: fails_raises_group( "Raised exception group did not match: \n" "The following expected exceptions did not find a match:\n" - " 'ValueError'\n" - " 'TypeError'\n" + " ValueError\n" + " TypeError\n" "The following raised exceptions did not find a match\n" " ExceptionGroup('', [ValueError(), TypeError()]):\n" - " Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" - " Unexpected nested 'ExceptionGroup', expected 'TypeError'\n" + " Unexpected nested `ExceptionGroup()`, expected `ValueError`\n" + " Unexpected nested `ExceptionGroup()`, expected `TypeError`\n" "Did you mean to use `flatten_subgroups=True`?", add_prefix=False, ), @@ -207,12 +204,12 @@ def test_flatten_subgroups() -> None: fails_raises_group( "Raised exception group did not match: \n" "The following expected exceptions did not find a match:\n" - " 'ValueError'\n" - " 'TypeError'\n" + " ValueError\n" + " TypeError\n" "The following raised exceptions did not find a match\n" " ExceptionGroup('', [ValueError(), TypeError()]):\n" - " Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" - " Unexpected nested 'ExceptionGroup', expected 'TypeError'\n" + " Unexpected nested `ExceptionGroup()`, expected `ValueError`\n" + " Unexpected nested `ExceptionGroup()`, expected `TypeError`\n" "Did you mean to use `flatten_subgroups=True`?", add_prefix=False, ), @@ -227,7 +224,7 @@ def test_flatten_subgroups() -> None: # This now doesn't print a repr of the caught exception at all, but that can be found in the traceback with ( fails_raises_group( - "Raised exception group did not match: Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + "Raised exception group did not match: Unexpected nested `ExceptionGroup()`, expected `ValueError`\n" " Did you mean to use `flatten_subgroups=True`?", add_prefix=False, ), @@ -236,7 +233,9 @@ def test_flatten_subgroups() -> None: raise ExceptionGroup("", [ExceptionGroup("", [ValueError()])]) # correct number of exceptions, but flatten_subgroups wouldn't help, so we don't suggest it with ( - fails_raises_group("Unexpected nested 'ExceptionGroup', expected 'ValueError'"), + fails_raises_group( + "Unexpected nested `ExceptionGroup()`, expected `ValueError`" + ), RaisesGroup(ValueError), ): raise ExceptionGroup("", [ExceptionGroup("", [TypeError()])]) @@ -246,7 +245,7 @@ def test_flatten_subgroups() -> None: # to be what they actually want - but I don't think it's worth trying to special-case with ( fails_raises_group( - "RaisesGroup(ValueError): Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + "RaisesGroup(ValueError): Unexpected nested `ExceptionGroup()`, expected `ValueError`\n" " Did you mean to use `flatten_subgroups=True`?", ), RaisesGroup(RaisesGroup(ValueError)), @@ -260,7 +259,9 @@ def test_flatten_subgroups() -> None: # Although it should perhaps be an error to specify `RaisesGroup(ExceptionGroup)` in # favor of doing `RaisesGroup(RaisesGroup(...))`. with ( - fails_raises_group("'BaseExceptionGroup' is not of type 'ExceptionGroup'"), + fails_raises_group( + "`BaseExceptionGroup()` is not an instance of `ExceptionGroup`" + ), RaisesGroup(ExceptionGroup), ): raise BaseExceptionGroup("", [BaseExceptionGroup("", [KeyboardInterrupt()])]) @@ -300,7 +301,7 @@ def test_catch_unwrapped_exceptions() -> None: # with allow_unwrapped=False (default) it will not be caught with ( fails_raises_group( - "'ValueError' is not an exception group, but would match with `allow_unwrapped=True`" + "`ValueError()` is not an exception group, but would match with `allow_unwrapped=True`" ), RaisesGroup(ValueError), ): @@ -309,7 +310,7 @@ def test_catch_unwrapped_exceptions() -> None: # allow_unwrapped on its own won't match against nested groups with ( fails_raises_group( - "Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + "Unexpected nested `ExceptionGroup()`, expected `ValueError`\n" " Did you mean to use `flatten_subgroups=True`?", ), RaisesGroup(ValueError, allow_unwrapped=True), @@ -323,7 +324,7 @@ def test_catch_unwrapped_exceptions() -> None: # code coverage with ( fails_raises_group( - "Raised exception (group) did not match: 'TypeError' is not of type 'ValueError'", + "Raised exception (group) did not match: `TypeError()` is not an instance of `ValueError`", add_prefix=False, ), RaisesGroup(ValueError, allow_unwrapped=True), @@ -331,7 +332,7 @@ def test_catch_unwrapped_exceptions() -> None: raise TypeError("this text doesn't show up in the error message") with ( fails_raises_group( - "Raised exception (group) did not match: RaisesExc(ValueError): 'TypeError' is not of type 'ValueError'", + "Raised exception (group) did not match: RaisesExc(ValueError): `TypeError()` is not an instance of `ValueError`", add_prefix=False, ), RaisesGroup(RaisesExc(ValueError), allow_unwrapped=True), @@ -340,7 +341,7 @@ def test_catch_unwrapped_exceptions() -> None: # check we don't suggest unwrapping with nested RaisesGroup with ( - fails_raises_group("'ValueError' is not an exception group"), + fails_raises_group("`ValueError()` is not an exception group"), RaisesGroup(RaisesGroup(ValueError)), ): raise ValueError @@ -370,7 +371,9 @@ def test_match() -> None: with ( fails_raises_group( - "Regex pattern 'foo' did not match 'bar' of 'ExceptionGroup'" + "Regex pattern did not match the `ExceptionGroup()`.\n" + " Regex: 'foo'\n" + " Input: 'bar'" ), RaisesGroup(ValueError, match="foo"), ): @@ -382,7 +385,11 @@ def test_match() -> None: # and `isinstance(raised, expected_type)`. with ( fails_raises_group( - "Regex pattern 'foo' did not match 'bar' of 'ExceptionGroup', but matched the expected 'ValueError'. You might want RaisesGroup(RaisesExc(ValueError, match='foo'))" + "Regex pattern did not match the `ExceptionGroup()`.\n" + " Regex: 'foo'\n" + " Input: 'bar'\n" + " but matched the expected `ValueError`.\n" + " You might want `RaisesGroup(RaisesExc(ValueError, match='foo'))`" ), RaisesGroup(ValueError, match="foo"), ): @@ -413,7 +420,7 @@ def is_value_error(e: BaseException) -> bool: # helpful suggestion if the user thinks the check is for the sub-exception with ( fails_raises_group( - f"check {is_value_error} did not return True on the ExceptionGroup, but did return True for the expected 'ValueError'. You might want RaisesGroup(RaisesExc(ValueError, check=<...>))" + f"check {is_value_error} did not return True on the ExceptionGroup, but did return True for the expected ValueError. You might want RaisesGroup(RaisesExc(ValueError, check=<...>))" ), RaisesGroup(ValueError, check=is_value_error), ): @@ -466,7 +473,7 @@ def check_message( with ( pytest.raises( Failed, - match=f"^DID NOT RAISE any exception, expected {re.escape(message)}$", + match=f"^DID NOT RAISE any exception, expected `{re.escape(message)}`$", ), body, ): @@ -494,6 +501,15 @@ def check_message( "ExceptionGroup(RaisesExc(match='my_str'))", RaisesGroup(RaisesExc(match="my_str")), ) + # one-size tuple is printed as not being a tuple + check_message( + "ExceptionGroup(RaisesExc(ValueError))", + RaisesGroup(RaisesExc((ValueError,))), + ) + check_message( + "ExceptionGroup(RaisesExc((ValueError, IndexError)))", + RaisesGroup(RaisesExc((ValueError, IndexError))), + ) # BaseExceptionGroup check_message( @@ -505,6 +521,10 @@ def check_message( "BaseExceptionGroup(RaisesExc(KeyboardInterrupt))", RaisesGroup(RaisesExc(KeyboardInterrupt)), ) + check_message( + "BaseExceptionGroup(RaisesExc((ValueError, KeyboardInterrupt)))", + RaisesGroup(RaisesExc((ValueError, KeyboardInterrupt))), + ) # Base-ness transfers to parent containers check_message( "BaseExceptionGroup(BaseExceptionGroup(KeyboardInterrupt))", @@ -522,7 +542,7 @@ def test_assert_message() -> None: # in the exception group, as those are both visible in the traceback. # first fails to match with ( - fails_raises_group("'TypeError' is not of type 'ValueError'"), + fails_raises_group("`TypeError()` is not an instance of `ValueError`"), RaisesGroup(ValueError), ): raise ExceptionGroup("a", [TypeError()]) @@ -534,11 +554,13 @@ def test_assert_message() -> None: " RaisesGroup(ValueError, match='a')\n" "The following raised exceptions did not find a match\n" " ExceptionGroup('', [RuntimeError()]):\n" - " RaisesGroup(ValueError): 'RuntimeError' is not of type 'ValueError'\n" - " RaisesGroup(ValueError, match='a'): Regex pattern 'a' did not match '' of 'ExceptionGroup'\n" + " RaisesGroup(ValueError): `RuntimeError()` is not an instance of `ValueError`\n" + " RaisesGroup(ValueError, match='a'): Regex pattern did not match the `ExceptionGroup()`.\n" + " Regex: 'a'\n" + " Input: ''\n" " RuntimeError():\n" - " RaisesGroup(ValueError): 'RuntimeError' is not an exception group\n" - " RaisesGroup(ValueError, match='a'): 'RuntimeError' is not an exception group", + " RaisesGroup(ValueError): `RuntimeError()` is not an exception group\n" + " RaisesGroup(ValueError, match='a'): `RuntimeError()` is not an exception group", add_prefix=False, # to see the full structure ), RaisesGroup(RaisesGroup(ValueError), RaisesGroup(ValueError, match="a")), @@ -557,14 +579,12 @@ def test_assert_message() -> None: " RaisesGroup(ValueError)\n" "The following raised exceptions did not find a match\n" " RuntimeError():\n" - # " 'RuntimeError' is not of type 'ValueError'\n" - # " RaisesExc(TypeError): 'RuntimeError' is not of type 'TypeError'\n" - " RaisesGroup(RuntimeError): 'RuntimeError' is not an exception group, but would match with `allow_unwrapped=True`\n" - " RaisesGroup(ValueError): 'RuntimeError' is not an exception group\n" + " RaisesGroup(RuntimeError): `RuntimeError()` is not an exception group, but would match with `allow_unwrapped=True`\n" + " RaisesGroup(ValueError): `RuntimeError()` is not an exception group\n" " ValueError('bar'):\n" - " It matches 'ValueError' which was paired with ValueError('foo')\n" - " RaisesGroup(RuntimeError): 'ValueError' is not an exception group\n" - " RaisesGroup(ValueError): 'ValueError' is not an exception group, but would match with `allow_unwrapped=True`", + " It matches `ValueError` which was paired with `ValueError('foo')`\n" + " RaisesGroup(RuntimeError): `ValueError()` is not an exception group\n" + " RaisesGroup(ValueError): `ValueError()` is not an exception group, but would match with `allow_unwrapped=True`", add_prefix=False, # to see the full structure ), RaisesGroup( @@ -581,7 +601,7 @@ def test_assert_message() -> None: with ( fails_raises_group( - "1 matched exception. 'AssertionError' is not of type 'TypeError'" + "1 matched exception. `AssertionError()` is not an instance of `TypeError`" ), RaisesGroup(ValueError, TypeError), ): @@ -589,7 +609,7 @@ def test_assert_message() -> None: with ( fails_raises_group( - "RaisesExc(ValueError): 'TypeError' is not of type 'ValueError'" + "RaisesExc(ValueError): `TypeError()` is not an instance of `ValueError`" ), RaisesGroup(RaisesExc(ValueError)), ): @@ -598,8 +618,11 @@ def test_assert_message() -> None: # suggest escaping with ( fails_raises_group( - "Raised exception group did not match: Regex pattern 'h(ell)o' did not match 'h(ell)o' of 'ExceptionGroup'\n" - " Did you mean to `re.escape()` the regex?", + # TODO: did not match Exceptiongroup('h(ell)o', ...) ? + "Raised exception group did not match: Regex pattern did not match the `ExceptionGroup()`.\n" + " Regex: 'h(ell)o'\n" + " Input: 'h(ell)o'\n" + " Did you mean to `re.escape()` the regex?", add_prefix=False, # to see the full structure ), RaisesGroup(ValueError, match="h(ell)o"), @@ -607,8 +630,10 @@ def test_assert_message() -> None: raise ExceptionGroup("h(ell)o", [ValueError()]) with ( fails_raises_group( - "RaisesExc(match='h(ell)o'): Regex pattern 'h(ell)o' did not match 'h(ell)o'\n" - " Did you mean to `re.escape()` the regex?", + "RaisesExc(match='h(ell)o'): Regex pattern did not match.\n" + " Regex: 'h(ell)o'\n" + " Input: 'h(ell)o'\n" + " Did you mean to `re.escape()` the regex?", ), RaisesGroup(RaisesExc(match="h(ell)o")), ): @@ -618,16 +643,16 @@ def test_assert_message() -> None: fails_raises_group( "Raised exception group did not match: \n" "The following expected exceptions did not find a match:\n" - " 'ValueError'\n" - " 'ValueError'\n" - " 'ValueError'\n" - " 'ValueError'\n" + " ValueError\n" + " ValueError\n" + " ValueError\n" + " ValueError\n" "The following raised exceptions did not find a match\n" " ExceptionGroup('', [ValueError(), TypeError()]):\n" - " Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" - " Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" - " Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" - " Unexpected nested 'ExceptionGroup', expected 'ValueError'", + " Unexpected nested `ExceptionGroup()`, expected `ValueError`\n" + " Unexpected nested `ExceptionGroup()`, expected `ValueError`\n" + " Unexpected nested `ExceptionGroup()`, expected `ValueError`\n" + " Unexpected nested `ExceptionGroup()`, expected `ValueError`", add_prefix=False, # to see the full structure ), RaisesGroup(ValueError, ValueError, ValueError, ValueError), @@ -641,26 +666,26 @@ def test_message_indent() -> None: "Raised exception group did not match: \n" "The following expected exceptions did not find a match:\n" " RaisesGroup(ValueError, ValueError)\n" - " 'ValueError'\n" + " ValueError\n" "The following raised exceptions did not find a match\n" " ExceptionGroup('', [TypeError(), RuntimeError()]):\n" " RaisesGroup(ValueError, ValueError): \n" " The following expected exceptions did not find a match:\n" - " 'ValueError'\n" - " 'ValueError'\n" + " ValueError\n" + " ValueError\n" " The following raised exceptions did not find a match\n" " TypeError():\n" - " 'TypeError' is not of type 'ValueError'\n" - " 'TypeError' is not of type 'ValueError'\n" + " `TypeError()` is not an instance of `ValueError`\n" + " `TypeError()` is not an instance of `ValueError`\n" " RuntimeError():\n" - " 'RuntimeError' is not of type 'ValueError'\n" - " 'RuntimeError' is not of type 'ValueError'\n" + " `RuntimeError()` is not an instance of `ValueError`\n" + " `RuntimeError()` is not an instance of `ValueError`\n" # TODO: this line is not great, should maybe follow the same format as the other and say - # 'ValueError': Unexpected nested 'ExceptionGroup' (?) - " Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + # ValueError: Unexpected nested `ExceptionGroup()` (?) + " Unexpected nested `ExceptionGroup()`, expected `ValueError`\n" " TypeError():\n" - " RaisesGroup(ValueError, ValueError): 'TypeError' is not an exception group\n" - " 'TypeError' is not of type 'ValueError'", + " RaisesGroup(ValueError, ValueError): `TypeError()` is not an exception group\n" + " `TypeError()` is not an instance of `ValueError`", add_prefix=False, ), RaisesGroup( @@ -680,15 +705,15 @@ def test_message_indent() -> None: "Raised exception group did not match: \n" "RaisesGroup(ValueError, ValueError): \n" " The following expected exceptions did not find a match:\n" - " 'ValueError'\n" - " 'ValueError'\n" + " ValueError\n" + " ValueError\n" " The following raised exceptions did not find a match\n" " TypeError():\n" - " 'TypeError' is not of type 'ValueError'\n" - " 'TypeError' is not of type 'ValueError'\n" + " `TypeError()` is not an instance of `ValueError`\n" + " `TypeError()` is not an instance of `ValueError`\n" " RuntimeError():\n" - " 'RuntimeError' is not of type 'ValueError'\n" - " 'RuntimeError' is not of type 'ValueError'", + " `RuntimeError()` is not an instance of `ValueError`\n" + " `RuntimeError()` is not an instance of `ValueError`", add_prefix=False, ), RaisesGroup( @@ -710,12 +735,12 @@ def test_suggestion_on_nested_and_brief_error() -> None: "\n" "The following expected exceptions did not find a match:\n" " RaisesGroup(ValueError)\n" - " 'ValueError'\n" + " ValueError\n" "The following raised exceptions did not find a match\n" " ExceptionGroup('', [ExceptionGroup('', [ValueError()])]):\n" - " RaisesGroup(ValueError): Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + " RaisesGroup(ValueError): Unexpected nested `ExceptionGroup()`, expected `ValueError`\n" " Did you mean to use `flatten_subgroups=True`?\n" - " Unexpected nested 'ExceptionGroup', expected 'ValueError'", + " Unexpected nested `ExceptionGroup()`, expected `ValueError`", ), RaisesGroup(RaisesGroup(ValueError), ValueError), ): @@ -729,19 +754,19 @@ def test_suggestion_on_nested_and_brief_error() -> None: "\n" "The following expected exceptions did not find a match:\n" " RaisesGroup(ValueError, ValueError)\n" - " 'ValueError'\n" + " ValueError\n" "The following raised exceptions did not find a match\n" " ExceptionGroup('', [ValueError(), ExceptionGroup('', [ValueError()])]):\n" " RaisesGroup(ValueError, ValueError): \n" " 1 matched exception. \n" " The following expected exceptions did not find a match:\n" - " 'ValueError'\n" - " It matches ValueError() which was paired with 'ValueError'\n" + " ValueError\n" + " It matches `ValueError()` which was paired with `ValueError`\n" " The following raised exceptions did not find a match\n" " ExceptionGroup('', [ValueError()]):\n" - " Unexpected nested 'ExceptionGroup', expected 'ValueError'\n" + " Unexpected nested `ExceptionGroup()`, expected `ValueError`\n" " Did you mean to use `flatten_subgroups=True`?\n" - " Unexpected nested 'ExceptionGroup', expected 'ValueError'" + " Unexpected nested `ExceptionGroup()`, expected `ValueError`" ), RaisesGroup(RaisesGroup(ValueError, ValueError), ValueError), ): @@ -756,12 +781,14 @@ def test_suggestion_on_nested_and_brief_error() -> None: "\n" "The following expected exceptions did not find a match:\n" " RaisesGroup(Exception, match='^hello')\n" - " 'ValueError'\n" + " ValueError\n" "The following raised exceptions did not find a match\n" " ExceptionGroup('^hello', [Exception()]):\n" - " RaisesGroup(Exception, match='^hello'): Regex pattern '^hello' did not match '^hello' of 'ExceptionGroup'\n" - " Did you mean to `re.escape()` the regex?\n" - " Unexpected nested 'ExceptionGroup', expected 'ValueError'" + " RaisesGroup(Exception, match='^hello'): Regex pattern did not match the `ExceptionGroup()`.\n" + " Regex: '^hello'\n" + " Input: '^hello'\n" + " Did you mean to `re.escape()` the regex?\n" + " Unexpected nested `ExceptionGroup()`, expected `ValueError`" ), RaisesGroup(RaisesGroup(Exception, match="^hello"), ValueError), ): @@ -781,48 +808,54 @@ def test_assert_message_nested() -> None: " RaisesGroup(TypeError, ValueError)\n" "The following raised exceptions did not find a match\n" " TypeError('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'):\n" - " RaisesGroup(ValueError): 'TypeError' is not an exception group\n" - " RaisesGroup(RaisesGroup(ValueError)): 'TypeError' is not an exception group\n" - " RaisesGroup(RaisesExc(TypeError, match='foo')): 'TypeError' is not an exception group\n" - " RaisesGroup(TypeError, ValueError): 'TypeError' is not an exception group\n" + " RaisesGroup(ValueError): `TypeError()` is not an exception group\n" + " RaisesGroup(RaisesGroup(ValueError)): `TypeError()` is not an exception group\n" + " RaisesGroup(RaisesExc(TypeError, match='foo')): `TypeError()` is not an exception group\n" + " RaisesGroup(TypeError, ValueError): `TypeError()` is not an exception group\n" " ExceptionGroup('Exceptions from Trio nursery', [TypeError('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb')]):\n" - " RaisesGroup(ValueError): 'TypeError' is not of type 'ValueError'\n" - " RaisesGroup(RaisesGroup(ValueError)): RaisesGroup(ValueError): 'TypeError' is not an exception group\n" - " RaisesGroup(RaisesExc(TypeError, match='foo')): RaisesExc(TypeError, match='foo'): Regex pattern 'foo' did not match 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'\n" - " RaisesGroup(TypeError, ValueError): 1 matched exception. Too few exceptions raised, found no match for: ['ValueError']\n" + " RaisesGroup(ValueError): `TypeError()` is not an instance of `ValueError`\n" + " RaisesGroup(RaisesGroup(ValueError)): RaisesGroup(ValueError): `TypeError()` is not an exception group\n" + " RaisesGroup(RaisesExc(TypeError, match='foo')): RaisesExc(TypeError, match='foo'): Regex pattern did not match.\n" + " Regex: 'foo'\n" + " Input: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'\n" + " RaisesGroup(TypeError, ValueError): 1 matched exception. Too few exceptions raised, found no match for: [ValueError]\n" " ExceptionGroup('Exceptions from Trio nursery', [TypeError('cccccccccccccccccccccccccccccc'), TypeError('dddddddddddddddddddddddddddddd')]):\n" " RaisesGroup(ValueError): \n" " The following expected exceptions did not find a match:\n" - " 'ValueError'\n" + " ValueError\n" " The following raised exceptions did not find a match\n" " TypeError('cccccccccccccccccccccccccccccc'):\n" - " 'TypeError' is not of type 'ValueError'\n" + " `TypeError()` is not an instance of `ValueError`\n" " TypeError('dddddddddddddddddddddddddddddd'):\n" - " 'TypeError' is not of type 'ValueError'\n" + " `TypeError()` is not an instance of `ValueError`\n" " RaisesGroup(RaisesGroup(ValueError)): \n" " The following expected exceptions did not find a match:\n" " RaisesGroup(ValueError)\n" " The following raised exceptions did not find a match\n" " TypeError('cccccccccccccccccccccccccccccc'):\n" - " RaisesGroup(ValueError): 'TypeError' is not an exception group\n" + " RaisesGroup(ValueError): `TypeError()` is not an exception group\n" " TypeError('dddddddddddddddddddddddddddddd'):\n" - " RaisesGroup(ValueError): 'TypeError' is not an exception group\n" + " RaisesGroup(ValueError): `TypeError()` is not an exception group\n" " RaisesGroup(RaisesExc(TypeError, match='foo')): \n" " The following expected exceptions did not find a match:\n" " RaisesExc(TypeError, match='foo')\n" " The following raised exceptions did not find a match\n" " TypeError('cccccccccccccccccccccccccccccc'):\n" - " RaisesExc(TypeError, match='foo'): Regex pattern 'foo' did not match 'cccccccccccccccccccccccccccccc'\n" + " RaisesExc(TypeError, match='foo'): Regex pattern did not match.\n" + " Regex: 'foo'\n" + " Input: 'cccccccccccccccccccccccccccccc'\n" " TypeError('dddddddddddddddddddddddddddddd'):\n" - " RaisesExc(TypeError, match='foo'): Regex pattern 'foo' did not match 'dddddddddddddddddddddddddddddd'\n" + " RaisesExc(TypeError, match='foo'): Regex pattern did not match.\n" + " Regex: 'foo'\n" + " Input: 'dddddddddddddddddddddddddddddd'\n" " RaisesGroup(TypeError, ValueError): \n" " 1 matched exception. \n" " The following expected exceptions did not find a match:\n" - " 'ValueError'\n" + " ValueError\n" " The following raised exceptions did not find a match\n" " TypeError('dddddddddddddddddddddddddddddd'):\n" - " It matches 'TypeError' which was paired with TypeError('cccccccccccccccccccccccccccccc')\n" - " 'TypeError' is not of type 'ValueError'", + " It matches `TypeError` which was paired with `TypeError('cccccccccccccccccccccccccccccc')`\n" + " `TypeError()` is not an instance of `ValueError`", add_prefix=False, # to see the full structure ), RaisesGroup( @@ -864,14 +897,14 @@ def test_check_no_patched_repr() -> None: r"^Raised exception group did not match: \n" r"The following expected exceptions did not find a match:\n" r" RaisesExc\(check=. at .*>\)\n" - r" 'TypeError'\n" + r" TypeError\n" r"The following raised exceptions did not find a match\n" r" ValueError\('foo'\):\n" r" RaisesExc\(check=. at .*>\): check did not return True\n" - r" 'ValueError' is not of type 'TypeError'\n" + r" `ValueError\(\)` is not an instance of `TypeError`\n" r" ValueError\('bar'\):\n" r" RaisesExc\(check=. at .*>\): check did not return True\n" - r" 'ValueError' is not of type 'TypeError'$" + r" `ValueError\(\)` is not an instance of `TypeError`$" ) with ( pytest.raises(Failed, match=match_str), @@ -887,15 +920,17 @@ def test_misordering_example() -> None: "3 matched exceptions. \n" "The following expected exceptions did not find a match:\n" " RaisesExc(ValueError, match='foo')\n" - " It matches ValueError('foo') which was paired with 'ValueError'\n" - " It matches ValueError('foo') which was paired with 'ValueError'\n" - " It matches ValueError('foo') which was paired with 'ValueError'\n" + " It matches `ValueError('foo')` which was paired with `ValueError`\n" + " It matches `ValueError('foo')` which was paired with `ValueError`\n" + " It matches `ValueError('foo')` which was paired with `ValueError`\n" "The following raised exceptions did not find a match\n" " ValueError('bar'):\n" - " It matches 'ValueError' which was paired with ValueError('foo')\n" - " It matches 'ValueError' which was paired with ValueError('foo')\n" - " It matches 'ValueError' which was paired with ValueError('foo')\n" - " RaisesExc(ValueError, match='foo'): Regex pattern 'foo' did not match 'bar'\n" + " It matches `ValueError` which was paired with `ValueError('foo')`\n" + " It matches `ValueError` which was paired with `ValueError('foo')`\n" + " It matches `ValueError` which was paired with `ValueError('foo')`\n" + " RaisesExc(ValueError, match='foo'): Regex pattern did not match.\n" + " Regex: 'foo'\n" + " Input: 'bar'\n" "There exist a possible match when attempting an exhaustive check, but RaisesGroup uses a greedy algorithm. Please make your expected exceptions more stringent with `RaisesExc` etc so the greedy algorithm can function." ), RaisesGroup( @@ -919,7 +954,7 @@ def test_brief_error_on_one_fail() -> None: # no also-matched with ( fails_raises_group( - "1 matched exception. 'TypeError' is not of type 'RuntimeError'" + "1 matched exception. `TypeError()` is not an instance of `RuntimeError`" ), RaisesGroup(ValueError, RuntimeError), ): @@ -931,11 +966,11 @@ def test_brief_error_on_one_fail() -> None: "\n" "1 matched exception. \n" "The following expected exceptions did not find a match:\n" - " 'RuntimeError'\n" + " RuntimeError\n" "The following raised exceptions did not find a match\n" " TypeError():\n" - " It matches 'Exception' which was paired with ValueError()\n" - " 'TypeError' is not of type 'RuntimeError'" + " It matches `Exception` which was paired with `ValueError()`\n" + " `TypeError()` is not an instance of `RuntimeError`" ), RaisesGroup(Exception, RuntimeError), ): @@ -947,11 +982,11 @@ def test_brief_error_on_one_fail() -> None: "\n" "1 matched exception. \n" "The following expected exceptions did not find a match:\n" - " 'ValueError'\n" - " It matches ValueError() which was paired with 'ValueError'\n" + " ValueError\n" + " It matches `ValueError()` which was paired with `ValueError`\n" "The following raised exceptions did not find a match\n" " TypeError():\n" - " 'TypeError' is not of type 'ValueError'" + " `TypeError()` is not an instance of `ValueError`" ), RaisesGroup(ValueError, ValueError), ): @@ -965,7 +1000,7 @@ def test_identity_oopsies() -> None: with ( fails_raises_group( - "3 matched exceptions. 'RuntimeError' is not of type 'TypeError'" + "3 matched exceptions. `RuntimeError()` is not an instance of `TypeError`" ), RaisesGroup(ValueError, ValueError, ValueError, TypeError), ): @@ -984,17 +1019,35 @@ def test_identity_oopsies() -> None: " RaisesExc(match='bar')\n" "The following raised exceptions did not find a match\n" " ValueError('foo'):\n" - " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'\n" - " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'\n" - " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " RaisesExc(match='bar'): Regex pattern did not match.\n" + " Regex: 'bar'\n" + " Input: 'foo'\n" + " RaisesExc(match='bar'): Regex pattern did not match.\n" + " Regex: 'bar'\n" + " Input: 'foo'\n" + " RaisesExc(match='bar'): Regex pattern did not match.\n" + " Regex: 'bar'\n" + " Input: 'foo'\n" " ValueError('foo'):\n" - " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'\n" - " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'\n" - " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'\n" + " RaisesExc(match='bar'): Regex pattern did not match.\n" + " Regex: 'bar'\n" + " Input: 'foo'\n" + " RaisesExc(match='bar'): Regex pattern did not match.\n" + " Regex: 'bar'\n" + " Input: 'foo'\n" + " RaisesExc(match='bar'): Regex pattern did not match.\n" + " Regex: 'bar'\n" + " Input: 'foo'\n" " ValueError('foo'):\n" - " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'\n" - " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'\n" - " RaisesExc(match='bar'): Regex pattern 'bar' did not match 'foo'" + " RaisesExc(match='bar'): Regex pattern did not match.\n" + " Regex: 'bar'\n" + " Input: 'foo'\n" + " RaisesExc(match='bar'): Regex pattern did not match.\n" + " Regex: 'bar'\n" + " Input: 'foo'\n" + " RaisesExc(match='bar'): Regex pattern did not match.\n" + " Regex: 'bar'\n" + " Input: 'foo'" ), RaisesGroup(m, m, m), ): @@ -1009,7 +1062,9 @@ def test_raisesexc() -> None: RaisesExc() # type: ignore[call-overload] with pytest.raises( TypeError, - match=f"^exception_type {re.escape(repr(object))} must be a subclass of BaseException$", + match=wrap_escape( + "expected exception must be a BaseException type, not object" + ), ): RaisesExc(object) # type: ignore[type-var] @@ -1017,19 +1072,53 @@ def test_raisesexc() -> None: raise ExceptionGroup("", (ValueError(),)) with ( fails_raises_group( - "RaisesExc(TypeError): 'ValueError' is not of type 'TypeError'" + "RaisesExc(TypeError): `ValueError()` is not an instance of `TypeError`" ), RaisesGroup(RaisesExc(TypeError)), ): raise ExceptionGroup("", (ValueError(),)) + with RaisesExc(ValueError): + raise ValueError + + # FIXME: leaving this one formatted differently for now to not change + # tests in python/raises.py + with pytest.raises(Failed, match=wrap_escape("DID NOT RAISE ")): + with RaisesExc(ValueError): + ... + + with pytest.raises(Failed, match=wrap_escape("DID NOT RAISE any exception")): + with RaisesExc(match="foo"): + ... + + with pytest.raises( + # FIXME: do we want repr(type) or type.__name__ ? + Failed, + match=wrap_escape( + "DID NOT RAISE any of (, )" + ), + ): + with RaisesExc((ValueError, TypeError)): + ... + + with pytest.raises( + AssertionError, + match=wrap_escape( + "Raised exception did not match: `TypeError()` is not an instance of `ValueError`" + ), + ): + with RaisesExc(ValueError): + raise TypeError + def test_raisesexc_match() -> None: with RaisesGroup(RaisesExc(ValueError, "foo")): raise ExceptionGroup("", (ValueError("foo"),)) with ( fails_raises_group( - "RaisesExc(ValueError, match='foo'): Regex pattern 'foo' did not match 'bar'" + "RaisesExc(ValueError, match='foo'): Regex pattern did not match.\n" + " Regex: 'foo'\n" + " Input: 'bar'" ), RaisesGroup(RaisesExc(ValueError, "foo")), ): @@ -1040,7 +1129,9 @@ def test_raisesexc_match() -> None: raise ExceptionGroup("", (ValueError("foo"),)) with ( fails_raises_group( - "RaisesExc(match='foo'): Regex pattern 'foo' did not match 'bar'" + "RaisesExc(match='foo'): Regex pattern did not match.\n" + " Regex: 'foo'\n" + " Input: 'bar'" ), RaisesGroup(RaisesExc(match="foo")), ): @@ -1051,7 +1142,7 @@ def test_raisesexc_match() -> None: raise ExceptionGroup("", [ValueError("bar")]) with ( fails_raises_group( - "RaisesExc(ValueError, match='^bar$'): Regex pattern '^bar$' did not match 'barr'" + "\nRaisesExc(ValueError, match='^bar$'): \n - barr\n ? -\n + bar" ), RaisesGroup(RaisesExc(ValueError, match="^bar$")), ): @@ -1132,12 +1223,21 @@ def test_assert_matches() -> None: with pytest.raises(AssertionError, match=r"assert False\n \+ where False = .*"): assert RaisesExc(TypeError).matches(e) - # you'd need to do this arcane incantation - with pytest.raises(AssertionError, match="'ValueError' is not of type 'TypeError'"): + with pytest.raises( + AssertionError, + match=wrap_escape( + "`ValueError()` is not an instance of `TypeError`\n" + "assert False\n" + " + where False = matches(ValueError())\n" + " + where matches = RaisesExc(TypeError).matches" + ), + ): + # you'd need to do this arcane incantation assert (m := RaisesExc(TypeError)).matches(e), m.fail_reason # but even if we add assert_matches, will people remember to use it? # other than writing a linter rule, I don't think we can catch `assert RaisesExc(...).matches` + # ... no wait pytest catches other asserts ... so we probably can?? # https://github.com/pytest-dev/pytest/issues/12504 @@ -1184,3 +1284,38 @@ def test_parametrizing_conditional_raisesgroup( if wrap_in_group: raise ExceptionGroup("", [ValueError()]) raise ValueError() + + +def test_annotated_group() -> None: + fail_msg = wrap_escape( + "Only `ExceptionGroup[Exception]` or `BaseExceptionGroup[BaseExeption]` are accepted as generic types but got `ExceptionGroup[ValueError]`. As `raises` will catch all instances of the specified group regardless of the generic argument specific nested exceptions has to be checked with `RaisesGroup`." + ) + with pytest.raises(TypeError, match=fail_msg): + with RaisesGroup(ExceptionGroup[ValueError]): + ... # pragma: no cover + with pytest.raises(TypeError, match=fail_msg): + with RaisesExc(ExceptionGroup[ValueError]): + ... # pragma: no cover + with RaisesGroup(ExceptionGroup[Exception]): + raise ExceptionGroup( + "", [ExceptionGroup("", [ValueError(), ValueError(), ValueError()])] + ) + with RaisesExc(BaseExceptionGroup[BaseException]): + raise BaseExceptionGroup("", [KeyboardInterrupt()]) + + +def test_tuples() -> None: + # raises has historically supported one of several exceptions being raised + with pytest.raises((ValueError, IndexError)): + raise ValueError + # so now RaisesExc also does + with RaisesExc((ValueError, IndexError)): + raise IndexError + # but RaisesGroup currently doesn't. There's an argument it shouldn't because + # it can be confusing - RaisesGroup((ValueError, TypeError)) looks a lot like + # RaisesGroup(ValueError, TypeError), and the former might be interpreted as the latter. + with pytest.raises( + TypeError, + match="expected exception must be a BaseException type, RaisesExc, or RaisesGroup, not tuple", + ): + RaisesGroup((ValueError, IndexError)) # type: ignore[call-overload] diff --git a/testing/typing_raises_group.py b/testing/typing_raises_group.py index 6e91cbf6da1..380c80768d0 100644 --- a/testing/typing_raises_group.py +++ b/testing/typing_raises_group.py @@ -18,8 +18,8 @@ def check_raisesexc_typevar_default(e: RaisesExc) -> None: - assert e.exception_type is not None - _exc: type[BaseException] = e.exception_type + assert e.expected_exceptions is not None + _exc: type[BaseException] | tuple[type[BaseException], ...] = e.expected_exceptions # this would previously pass, as the type would be `Any` e.exception_type().blah() # type: ignore @@ -63,7 +63,7 @@ def check_exc(exc: BaseException) -> bool: RaisesExc(ValueError) RaisesExc(ValueError, "regex") RaisesExc(ValueError, "regex", check_exc) - RaisesExc(exception_type=ValueError) + RaisesExc(expected_exception=ValueError) RaisesExc(match="regex") RaisesExc(check=check_exc) RaisesExc(ValueError, match="regex") From 09d06fe99dcf2493383c0ef82d04e9561ab0fd7e Mon Sep 17 00:00:00 2001 From: jakkdl Date: Thu, 20 Feb 2025 17:14:43 +0100 Subject: [PATCH 319/445] fix tests --- src/_pytest/_code/code.py | 2 +- src/_pytest/python_api.py | 4 ++-- src/_pytest/raises_group.py | 5 +++-- testing/code/test_excinfo.py | 5 +++-- testing/python/raises.py | 13 ++++--------- testing/python/raises_group.py | 13 +++++++------ 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 429b856596b..5b85d295d36 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -763,7 +763,7 @@ def match(self, regexp: str | re.Pattern[str]) -> Literal[True]: """ __tracebackhide__ = True value = self._stringify_exception(self.value) - msg = f"Raised exception did not match: Regex pattern did not match.\n Regex: {regexp!r}\n Input: {value!r}" + msg = f"Regex pattern did not match.\n Regex: {regexp!r}\n Input: {value!r}" if regexp == value: msg += "\n Did you mean to `re.escape()` the regex?" assert re.search(regexp, value), msg diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 8a11a128293..b1da082134f 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -29,6 +29,8 @@ if TYPE_CHECKING: from numpy import ndarray + E = TypeVar("E", bound=BaseException, default=BaseException) + def _compare_approx( full_object: object, @@ -786,8 +788,6 @@ def _as_numpy_array(obj: object) -> ndarray | None: # builtin pytest.raises helper -E = TypeVar("E", bound=BaseException, default=BaseException) - @overload def raises( diff --git a/src/_pytest/raises_group.py b/src/_pytest/raises_group.py index e549b8e8975..d314f14af1c 100644 --- a/src/_pytest/raises_group.py +++ b/src/_pytest/raises_group.py @@ -218,7 +218,8 @@ def _parse_exc( self.is_baseexception = True return cast(type[BaseExcT_1], origin_exc) else: - raise TypeError( + # I kinda think this should be a TypeError... + raise ValueError( f"Only `ExceptionGroup[Exception]` or `BaseExceptionGroup[BaseExeption]` " f"are accepted as generic types but got `{exc}`. " f"As `raises` will catch all instances of the specified group regardless of the " @@ -451,7 +452,7 @@ def __exit__( ) if not self.matches(exc_val): - raise AssertionError(f"Raised exception did not match: {self._fail_reason}") + raise AssertionError(self._fail_reason) # Cast to narrow the exception type now that it's verified.... # even though the TypeGuard in self.matches should be narrowing diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 89088576980..438a5259f20 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -481,8 +481,9 @@ def test_raises_exception_escapes_generic_group() -> None: try: with pytest.raises(ExceptionGroup[Exception]): raise ValueError("my value error") - except ValueError as e: - assert str(e) == "my value error" + except AssertionError as e: + assert str(e) == "`ValueError()` is not an instance of `ExceptionGroup`" + assert str(e.__context__) == "my value error" else: pytest.fail("Expected ValueError to be raised") diff --git a/testing/python/raises.py b/testing/python/raises.py index c7ecc301701..65081b2adb1 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -238,7 +238,7 @@ def test_raises_match(self) -> None: msg = "with base 16" expr = ( - "Raised exception did not match: Regex pattern did not match.\n" + "Regex pattern did not match.\n" f" Regex: {msg!r}\n" " Input: \"invalid literal for int() with base 10: 'asdf'\"" ) @@ -277,10 +277,7 @@ def test_match_failure_string_quoting(self): with pytest.raises(AssertionError, match="'foo"): raise AssertionError("'bar") (msg,) = excinfo.value.args - assert ( - msg - == '''Raised exception did not match: Regex pattern did not match.\n Regex: "'foo"\n Input: "'bar"''' - ) + assert msg == '''Regex pattern did not match.\n Regex: "'foo"\n Input: "'bar"''' def test_match_failure_exact_string_message(self): message = "Oh here is a message with (42) numbers in parameters" @@ -289,7 +286,7 @@ def test_match_failure_exact_string_message(self): raise AssertionError(message) (msg,) = excinfo.value.args assert msg == ( - "Raised exception did not match: Regex pattern did not match.\n" + "Regex pattern did not match.\n" " Regex: 'Oh here is a message with (42) numbers in parameters'\n" " Input: 'Oh here is a message with (42) numbers in parameters'\n" " Did you mean to `re.escape()` the regex?" @@ -303,9 +300,7 @@ def test_raises_match_wrong_type(self): """ with pytest.raises( AssertionError, - match=wrap_escape( - "Raised exception did not match: `ValueError()` is not an instance of `IndexError`" - ), + match=wrap_escape("`ValueError()` is not an instance of `IndexError`"), ): with pytest.raises(IndexError, match="nomatch"): int("asdf") diff --git a/testing/python/raises_group.py b/testing/python/raises_group.py index 5e00aaa06bb..2619eb41c1d 100644 --- a/testing/python/raises_group.py +++ b/testing/python/raises_group.py @@ -1101,11 +1101,10 @@ def test_raisesexc() -> None: with RaisesExc((ValueError, TypeError)): ... + # currently RaisesGroup says "Raised exception did not match" but RaisesExc doesn't... with pytest.raises( AssertionError, - match=wrap_escape( - "Raised exception did not match: `TypeError()` is not an instance of `ValueError`" - ), + match=wrap_escape("`TypeError()` is not an instance of `ValueError`"), ): with RaisesExc(ValueError): raise TypeError @@ -1287,13 +1286,15 @@ def test_parametrizing_conditional_raisesgroup( def test_annotated_group() -> None: + # repr depends on if exceptiongroup backport is being used or not + t = repr(ExceptionGroup[ValueError]) fail_msg = wrap_escape( - "Only `ExceptionGroup[Exception]` or `BaseExceptionGroup[BaseExeption]` are accepted as generic types but got `ExceptionGroup[ValueError]`. As `raises` will catch all instances of the specified group regardless of the generic argument specific nested exceptions has to be checked with `RaisesGroup`." + f"Only `ExceptionGroup[Exception]` or `BaseExceptionGroup[BaseExeption]` are accepted as generic types but got `{t}`. As `raises` will catch all instances of the specified group regardless of the generic argument specific nested exceptions has to be checked with `RaisesGroup`." ) - with pytest.raises(TypeError, match=fail_msg): + with pytest.raises(ValueError, match=fail_msg): with RaisesGroup(ExceptionGroup[ValueError]): ... # pragma: no cover - with pytest.raises(TypeError, match=fail_msg): + with pytest.raises(ValueError, match=fail_msg): with RaisesExc(ExceptionGroup[ValueError]): ... # pragma: no cover with RaisesGroup(ExceptionGroup[Exception]): From 753df941da92bd02b9f4d453c14006e382c004e0 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Fri, 21 Feb 2025 13:01:57 +0100 Subject: [PATCH 320/445] harmonize stringify_exception, various comments --- src/_pytest/_code/code.py | 49 +++++++++++++++++++--------------- src/_pytest/outcomes.py | 4 +-- src/_pytest/python_api.py | 13 ++++++--- src/_pytest/raises_group.py | 24 ++++++++--------- testing/python/raises.py | 4 +-- testing/typing_raises_group.py | 13 +++++++-- 6 files changed, 62 insertions(+), 45 deletions(-) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 5b85d295d36..0a5a20161e4 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -459,6 +459,32 @@ def recursionindex(self) -> int | None: return None +def stringify_exception( + exc: BaseException, include_subexception_msg: bool = True +) -> str: + try: + notes = getattr(exc, "__notes__", []) + except KeyError: + # Workaround for https://github.com/python/cpython/issues/98778 on + # Python <= 3.9, and some 3.10 and 3.11 patch versions. + HTTPError = getattr(sys.modules.get("urllib.error", None), "HTTPError", ()) + if sys.version_info < (3, 12) and isinstance(exc, HTTPError): + notes = [] + else: + raise + if not include_subexception_msg and isinstance(exc, BaseExceptionGroup): + message = exc.message + else: + message = str(exc) + + return "\n".join( + [ + message, + *notes, + ] + ) + + E = TypeVar("E", bound=BaseException, covariant=True) @@ -736,25 +762,6 @@ def getrepr( ) return fmt.repr_excinfo(self) - def _stringify_exception(self, exc: BaseException) -> str: - try: - notes = getattr(exc, "__notes__", []) - except KeyError: - # Workaround for https://github.com/python/cpython/issues/98778 on - # Python <= 3.9, and some 3.10 and 3.11 patch versions. - HTTPError = getattr(sys.modules.get("urllib.error", None), "HTTPError", ()) - if sys.version_info < (3, 12) and isinstance(exc, HTTPError): - notes = [] - else: - raise - - return "\n".join( - [ - str(exc), - *notes, - ] - ) - def match(self, regexp: str | re.Pattern[str]) -> Literal[True]: """Check whether the regular expression `regexp` matches the string representation of the exception using :func:`python:re.search`. @@ -762,7 +769,7 @@ def match(self, regexp: str | re.Pattern[str]) -> Literal[True]: If it matches `True` is returned, otherwise an `AssertionError` is raised. """ __tracebackhide__ = True - value = self._stringify_exception(self.value) + value = stringify_exception(self.value) msg = f"Regex pattern did not match.\n Regex: {regexp!r}\n Input: {value!r}" if regexp == value: msg += "\n Did you mean to `re.escape()` the regex?" @@ -794,7 +801,7 @@ def _group_contains( if not isinstance(exc, expected_exception): continue if match is not None: - value = self._stringify_exception(exc) + value = stringify_exception(exc) if not re.search(match, value): continue return True diff --git a/src/_pytest/outcomes.py b/src/_pytest/outcomes.py index d792382a9c1..68ba0543365 100644 --- a/src/_pytest/outcomes.py +++ b/src/_pytest/outcomes.py @@ -77,8 +77,8 @@ def __init__( super().__init__(msg) -# Elaborate hack to work around https://github.com/python/mypy/issues/2087. -# Ideally would just be `exit.Exception = Exit` etc. +# We need a callable protocol to add attributes, for discussion see +# https://github.com/python/mypy/issues/2087. _F = TypeVar("_F", bound=Callable[..., object]) _ET = TypeVar("_ET", bound=type[BaseException]) diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index b1da082134f..c8edce4274a 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -787,6 +787,9 @@ def _as_numpy_array(obj: object) -> ndarray | None: # builtin pytest.raises helper +# FIXME: This should probably me moved to 'src/_pytest.raises_group.py' +# (and rename the file to 'raises.py') +# since it's much more closely tied to those than to the other stuff in this file. @overload @@ -1000,9 +1003,11 @@ def raises( # note: RaisesExc/RaisesGroup uses fail() internally, so this alias -# indicates (to [internal] plugins?) that `pytest.raises` will -# raise `_pytest.outcomes.Failed`, where -# `outcomes.Failed is outcomes.fail.Exception is raises.Exception` +# indicates (to [internal] plugins?) that `pytest.raises` will +# raise `_pytest.outcomes.Failed`, where +# `outcomes.Failed is outcomes.fail.Exception is raises.Exception` # note: this is *not* the same as `_pytest.main.Failed` -# note: mypy does not recognize this attribute +# note: mypy does not recognize this attribute, and it's not possible +# to use a protocol/decorator like the others in outcomes due to +# https://github.com/python/mypy/issues/18715 raises.Exception = fail.Exception # type: ignore[attr-defined] diff --git a/src/_pytest/raises_group.py b/src/_pytest/raises_group.py index d314f14af1c..f60bacb7184 100644 --- a/src/_pytest/raises_group.py +++ b/src/_pytest/raises_group.py @@ -18,6 +18,7 @@ import warnings from _pytest._code import ExceptionInfo +from _pytest._code.code import stringify_exception from _pytest.outcomes import fail from _pytest.warning_types import PytestWarning @@ -61,17 +62,6 @@ from exceptiongroup import ExceptionGroup -# this differs slightly from pytest.ExceptionInfo._stringify_exception -# as we don't want '(1 sub-exception)' when matching group strings -def _stringify_exception(exc: BaseException) -> str: - return "\n".join( - [ - exc.message if isinstance(exc, BaseExceptionGroup) else str(exc), - *getattr(exc, "__notes__", []), - ], - ) - - # String patterns default to including the unicode flag. _REGEX_NO_FLAGS = re.compile(r"").flags @@ -141,6 +131,12 @@ def unescape(s: str) -> str: return re.sub(r"\\([{}()+-.*?^$\[\]\s\\])", r"\1", s) +# These classes conceptually differ from ExceptionInfo in that ExceptionInfo is tied, and +# constructed from, a particular exception - whereas these are constructed with expected +# exceptions, and later allow matching towards particular exceptions. +# But there's overlap in `ExceptionInfo.match` and `AbstractRaises._check_match`, as with +# `AbstractRaises.matches` and `ExceptionInfo.errisinstance`+`ExceptionInfo.group_contains`. +# The interaction between these classes should perhaps be improved. class AbstractRaises(ABC, Generic[BaseExcT_co]): """ABC with common functionality shared between RaisesExc and RaisesGroup""" @@ -161,7 +157,6 @@ def __init__( if match == "": warnings.warn( PytestWarning( - "session.shouldstop cannot be unset after it has been set; ignoring." "matching against an empty string will *always* pass. If you want " "to check for an empty message you need to pass '^$'. If you don't " "want to match you should pass `None` or leave out the parameter." @@ -251,10 +246,13 @@ def _check_check( self._fail_reason = f"check{check_repr} did not return True" return False + # TODO: harmonize with ExceptionInfo.match def _check_match(self, e: BaseException) -> bool: if self.match is None or re.search( self.match, - stringified_exception := _stringify_exception(e), + stringified_exception := stringify_exception( + e, include_subexception_msg=False + ), ): return True diff --git a/testing/python/raises.py b/testing/python/raises.py index 65081b2adb1..5dafef7a78d 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -261,12 +261,10 @@ def tfunc(match): pytest.raises(ValueError, tfunc, match="").match("match=") # empty string matches everything, which is probably not what the user wants - # FIXME: I have no clue what session.shouldstop is doing here with pytest.warns( PytestWarning, match=wrap_escape( - "session.shouldstop cannot be unset after it has been set; ignoring.matching against " - "an empty string will *always* pass. If you want to check for an empty message you " + "matching against an empty string will *always* pass. If you want to check for an empty message you " "need to pass '^$'. If you don't want to match you should pass `None` or leave out the parameter." ), ): diff --git a/testing/typing_raises_group.py b/testing/typing_raises_group.py index 380c80768d0..f27943e3a58 100644 --- a/testing/typing_raises_group.py +++ b/testing/typing_raises_group.py @@ -6,10 +6,19 @@ from typing_extensions import assert_type -from _pytest.raises_group import RaisesExc -from _pytest.raises_group import RaisesGroup +from _pytest.main import Failed as main_Failed +from _pytest.outcomes import Failed +from pytest import raises +from pytest import RaisesExc +from pytest import RaisesGroup +# does not work +assert_type(raises.Exception, Failed) # type: ignore[assert-type, attr-defined] + +# FIXME: these are different for some reason(?) +assert Failed is not main_Failed # type: ignore[comparison-overlap] + if sys.version_info < (3, 11): from exceptiongroup import BaseExceptionGroup from exceptiongroup import ExceptionGroup From 77f2c63a542fc9511f5919ddf7f4b64d237fda07 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 23 Feb 2025 12:40:57 -0300 Subject: [PATCH 321/445] [automated] Update plugin list (#13247) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 124 +++++++++++++++++-------------- 1 file changed, 70 insertions(+), 54 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 28492e22a62..b143608b6fd 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =4.4.0) :pypi:`pytest-airflow-utils` Nov 15, 2021 N/A N/A :pypi:`pytest-alembic` A pytest plugin for verifying alembic migrations. Jul 29, 2024 N/A pytest>=6.0 - :pypi:`pytest-alerts` A pytest plugin for sending test results to Slack and Telegram Feb 01, 2025 4 - Beta pytest>=7.4.0 + :pypi:`pytest-alerts` A pytest plugin for sending test results to Slack and Telegram Feb 21, 2025 4 - Beta pytest>=7.4.0 :pypi:`pytest-allclose` Pytest fixture extending Numpy's allclose function Jul 30, 2019 5 - Production/Stable pytest :pypi:`pytest-allure-adaptor` Plugin for py.test to generate allure xml reports Jan 10, 2018 N/A pytest (>=2.7.3) :pypi:`pytest-allure-adaptor2` Plugin for py.test to generate allure xml reports Oct 14, 2020 N/A pytest (>=2.7.3) @@ -161,7 +161,7 @@ This list contains 1585 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Feb 11, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Feb 17, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -221,7 +221,7 @@ This list contains 1585 plugins. :pypi:`pytest-catchlog` py.test plugin to catch log messages. This is a fork of pytest-capturelog. Jan 24, 2016 4 - Beta pytest (>=2.6) :pypi:`pytest-catch-server` Pytest plugin with server for catching HTTP requests. Dec 12, 2019 5 - Production/Stable N/A :pypi:`pytest-cdist` A pytest plugin to split your test suite into multiple parts Jan 30, 2025 N/A pytest>=7 - :pypi:`pytest-celery` Pytest plugin for Celery Sep 20, 2024 4 - Beta N/A + :pypi:`pytest-celery` Pytest plugin for Celery Feb 21, 2025 5 - Production/Stable N/A :pypi:`pytest-cfg-fetcher` Pass config options to your unit tests. Feb 26, 2024 N/A N/A :pypi:`pytest-chainmaker` pytest plugin for chainmaker Oct 15, 2021 N/A N/A :pypi:`pytest-chalice` A set of py.test fixtures for AWS Chalice Jul 01, 2020 4 - Beta N/A @@ -261,7 +261,7 @@ This list contains 1585 plugins. :pypi:`pytest-cloud` Distributed tests planner plugin for pytest testing framework. Oct 05, 2020 6 - Mature N/A :pypi:`pytest-cloudflare-worker` pytest plugin for testing cloudflare workers Mar 30, 2021 4 - Beta pytest (>=6.0.0) :pypi:`pytest-cloudist` Distribute tests to cloud machines without fuss Sep 02, 2022 4 - Beta pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-cmake` Provide CMake module for Pytest Feb 09, 2025 N/A pytest<9,>=4 + :pypi:`pytest-cmake` Provide CMake module for Pytest Feb 17, 2025 N/A pytest<9,>=4 :pypi:`pytest-cmake-presets` Execute CMake Presets via pytest Dec 26, 2022 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-cmdline-add-args` Pytest plugin for custom argument handling and Allure reporting. This plugin allows you to add arguments before running a test. Sep 01, 2024 N/A N/A :pypi:`pytest-cobra` PyTest plugin for testing Smart Contracts for Ethereum blockchain. Jun 29, 2019 3 - Alpha pytest (<4.0.0,>=3.7.1) @@ -475,15 +475,15 @@ This list contains 1585 plugins. :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Feb 11, 2025 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Feb 11, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Feb 11, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Feb 11, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Feb 11, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Feb 11, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Feb 11, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Feb 11, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Feb 11, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Feb 20, 2025 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Feb 20, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Feb 20, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Feb 20, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Feb 20, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Feb 20, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Feb 20, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Feb 20, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Feb 20, 2025 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -541,7 +541,7 @@ This list contains 1585 plugins. :pypi:`pytest_extra` Some helpers for writing tests with pytest. Aug 14, 2014 N/A N/A :pypi:`pytest-extra-durations` A pytest plugin to get durations on a per-function basis and per module basis. Apr 21, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-extra-markers` Additional pytest markers to dynamically enable/disable tests viia CLI flags Mar 05, 2023 4 - Beta pytest - :pypi:`pytest-f3ts` Pytest Plugin for communicating test results and information to a FixturFab Test Runner GUI Jan 22, 2025 N/A pytest<8.0.0,>=7.2.1 + :pypi:`pytest-f3ts` Pytest Plugin for communicating test results and information to a FixturFab Test Runner GUI Feb 21, 2025 N/A pytest<8.0.0,>=7.2.1 :pypi:`pytest-fabric` Provides test utilities to run fabric task tests by using docker containers Sep 12, 2018 5 - Production/Stable N/A :pypi:`pytest-factor` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A :pypi:`pytest-factory` Use factories for test setup with py.test Sep 06, 2020 3 - Alpha pytest (>4.3) @@ -629,12 +629,12 @@ This list contains 1585 plugins. :pypi:`pytest-gc` The garbage collector plugin for py.test Feb 01, 2018 N/A N/A :pypi:`pytest-gcov` Uses gcov to measure test coverage of a C library Feb 01, 2018 3 - Alpha N/A :pypi:`pytest-gcs` GCS fixtures and fixture factories for Pytest. Jan 24, 2025 5 - Production/Stable pytest>=6.2 - :pypi:`pytest-gee` The Python plugin for your GEE based packages. Jan 30, 2025 3 - Alpha pytest + :pypi:`pytest-gee` The Python plugin for your GEE based packages. Feb 20, 2025 3 - Alpha pytest :pypi:`pytest-gevent` Ensure that gevent is properly patched when invoking pytest Feb 25, 2020 N/A pytest :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Feb 14, 2025 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Feb 20, 2025 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -678,7 +678,7 @@ This list contains 1585 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Feb 15, 2025 3 - Alpha pytest==8.3.4 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Feb 22, 2025 3 - Alpha pytest==8.3.4 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -752,8 +752,8 @@ This list contains 1585 plugins. :pypi:`pytest-iovis` A Pytest plugin to enable Jupyter Notebook testing with Papermill Nov 06, 2024 4 - Beta pytest>=7.1.0 :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A - :pypi:`pytest-ipynb2` Pytest plugin to run tests in Jupyter Notebooks Feb 14, 2025 N/A pytest - :pypi:`pytest-ipywidgets` Jan 29, 2025 N/A pytest + :pypi:`pytest-ipynb2` Pytest plugin to run tests in Jupyter Notebooks Feb 19, 2025 N/A pytest + :pypi:`pytest-ipywidgets` Feb 18, 2025 N/A pytest :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Jan 16, 2025 4 - Beta pytest :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Dec 05, 2024 4 - Beta pytest>=5 :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) @@ -877,13 +877,13 @@ This list contains 1585 plugins. :pypi:`pytest-memray` A simple plugin to use with pytest Jul 25, 2024 N/A pytest>=7.2 :pypi:`pytest-menu` A pytest plugin for console based interactive test selection just after the collection phase Oct 04, 2017 3 - Alpha pytest (>=2.4.2) :pypi:`pytest-mercurial` pytest plugin to write integration tests for projects using Mercurial Python internals Nov 21, 2020 1 - Planning N/A - :pypi:`pytest-mergify` Pytest plugin for Mergify Feb 14, 2025 N/A N/A + :pypi:`pytest-mergify` Pytest plugin for Mergify Feb 19, 2025 N/A N/A :pypi:`pytest-mesh` pytest_mesh插件 Aug 05, 2022 N/A pytest (==7.1.2) :pypi:`pytest-message` Pytest plugin for sending report message of marked tests execution Aug 04, 2022 N/A pytest (>=6.2.5) :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A :pypi:`pytest-metadata` pytest plugin for test session metadata Feb 12, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-metrics` Custom metrics report for pytest Apr 04, 2020 N/A pytest - :pypi:`pytest-mh` Pytest multihost plugin Nov 28, 2024 N/A pytest + :pypi:`pytest-mh` Pytest multihost plugin Feb 20, 2025 N/A pytest :pypi:`pytest-mimesis` Mimesis integration with the pytest test runner Mar 21, 2020 5 - Production/Stable pytest (>=4.2) :pypi:`pytest-minecraft` A pytest plugin for running tests against Minecraft releases Apr 06, 2022 N/A pytest (>=6.0.1) :pypi:`pytest-mini` A plugin to test mp Feb 06, 2023 N/A pytest (>=7.2.0,<8.0.0) @@ -1036,7 +1036,7 @@ This list contains 1585 plugins. :pypi:`pytest-pgsql` Pytest plugins and helpers for tests using a Postgres database. May 13, 2020 5 - Production/Stable pytest (>=3.0.0) :pypi:`pytest-phmdoctest` pytest plugin to test Python examples in Markdown using phmdoctest. Apr 15, 2022 4 - Beta pytest (>=5.4.3) :pypi:`pytest-picked` Run the tests related to the changed files Nov 06, 2024 N/A pytest>=3.7.0 - :pypi:`pytest-pickle-cache` A pytest plugin for caching test results using pickle. Jan 18, 2025 N/A pytest>=7 + :pypi:`pytest-pickle-cache` A pytest plugin for caching test results using pickle. Feb 17, 2025 N/A pytest>=7 :pypi:`pytest-pigeonhole` Jun 25, 2018 5 - Production/Stable pytest (>=3.4) :pypi:`pytest-pikachu` Show surprise when tests are passing Aug 05, 2021 5 - Production/Stable pytest :pypi:`pytest-pilot` Slice in your test base thanks to powerful markers. Oct 09, 2020 5 - Production/Stable N/A @@ -1046,6 +1046,7 @@ This list contains 1585 plugins. :pypi:`pytest-pinpoint` A pytest plugin which runs SBFL algorithms to detect faults. Sep 25, 2020 N/A pytest (>=4.4.0) :pypi:`pytest-pipeline` Pytest plugin for functional testing of data analysispipelines Jan 24, 2017 3 - Alpha N/A :pypi:`pytest-pitch` runs tests in an order such that coverage increases as fast as possible Nov 02, 2023 4 - Beta pytest >=7.3.1 + :pypi:`pytest-platform-adapter` Pytest集成自动化平台插件 Feb 18, 2025 5 - Production/Stable pytest>=6.2.5 :pypi:`pytest-platform-markers` Markers for pytest to skip tests on specific platforms Sep 09, 2019 4 - Beta pytest (>=3.6.0) :pypi:`pytest-play` pytest plugin that let you automate actions and assertions with test metrics reporting executing plain YAML files Jun 12, 2019 5 - Production/Stable N/A :pypi:`pytest-playbook` Pytest plugin for reading playbooks. Jan 21, 2021 3 - Alpha pytest (>=6.1.2,<7.0.0) @@ -1108,6 +1109,7 @@ This list contains 1585 plugins. :pypi:`pytest-pydev` py.test plugin to connect to a remote debug server with PyDev or PyCharm. Nov 15, 2017 3 - Alpha N/A :pypi:`pytest-pydocstyle` pytest plugin to run pydocstyle Oct 09, 2024 3 - Alpha pytest>=7.0 :pypi:`pytest-pylint` pytest plugin to check source code with pylint Oct 06, 2023 5 - Production/Stable pytest >=7.0 + :pypi:`pytest-pylyzer` A pytest plugin for pylyzer Feb 15, 2025 4 - Beta N/A :pypi:`pytest-pymysql-autorecord` Record PyMySQL queries and mock with the stored data. Sep 02, 2022 N/A N/A :pypi:`pytest-pyodide` Pytest plugin for testing applications that use Pyodide Nov 23, 2024 N/A pytest :pypi:`pytest-pypi` Easily test your HTTP library against a local copy of pypi Mar 04, 2018 3 - Alpha N/A @@ -1184,7 +1186,7 @@ This list contains 1585 plugins. :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Oct 11, 2024 4 - Beta N/A :pypi:`pytest-reporter-html-dots` A basic HTML report for pytest using Jinja2 template engine. Jan 22, 2023 N/A N/A - :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots, webpage sources and attachments. Feb 01, 2025 N/A pytest>=8.0.0 + :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots, webpage sources and attachments. Feb 19, 2025 N/A pytest>=8.0.0 :pypi:`pytest-reportinfra` Pytest plugin for reportinfra Aug 11, 2019 3 - Alpha N/A :pypi:`pytest-reporting` A plugin to report summarized results in a table format Oct 25, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-reportlog` Replacement for the --resultlog option, focused in simplicity and extensibility May 22, 2023 3 - Alpha pytest @@ -1259,7 +1261,7 @@ This list contains 1585 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Feb 13, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Feb 20, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1271,7 +1273,7 @@ This list contains 1585 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Feb 13, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Feb 20, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1470,7 +1472,7 @@ This list contains 1585 plugins. :pypi:`pytest-timestamper` Pytest plugin to add a timestamp prefix to the pytest output Mar 27, 2024 N/A N/A :pypi:`pytest-timestamps` A simple plugin to view timestamps for each test Sep 11, 2023 N/A pytest (>=7.3,<8.0) :pypi:`pytest-tiny-api-client` The companion pytest plugin for tiny-api-client Jan 04, 2024 5 - Production/Stable pytest - :pypi:`pytest-tinybird` A pytest plugin to report test results to tinybird Aug 29, 2024 4 - Beta pytest>=3.8.0 + :pypi:`pytest-tinybird` A pytest plugin to report test results to tinybird Feb 18, 2025 4 - Beta pytest>=3.8.0 :pypi:`pytest-tipsi-django` Better fixtures for django Feb 05, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-tipsi-testing` Better fixtures management. Various helpers Feb 04, 2024 5 - Production/Stable pytest>=3.3.0 :pypi:`pytest-tldr` A pytest plugin that limits the output to just the things you need. Oct 26, 2022 4 - Beta pytest (>=3.5.0) @@ -1835,7 +1837,7 @@ This list contains 1585 plugins. A pytest plugin for verifying alembic migrations. :pypi:`pytest-alerts` - *last release*: Feb 01, 2025, + *last release*: Feb 21, 2025, *status*: 4 - Beta, *requires*: pytest>=7.4.0 @@ -2514,7 +2516,7 @@ This list contains 1585 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Feb 11, 2025, + *last release*: Feb 17, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -2934,8 +2936,8 @@ This list contains 1585 plugins. A pytest plugin to split your test suite into multiple parts :pypi:`pytest-celery` - *last release*: Sep 20, 2024, - *status*: 4 - Beta, + *last release*: Feb 21, 2025, + *status*: 5 - Production/Stable, *requires*: N/A Pytest plugin for Celery @@ -3214,7 +3216,7 @@ This list contains 1585 plugins. Distribute tests to cloud machines without fuss :pypi:`pytest-cmake` - *last release*: Feb 09, 2025, + *last release*: Feb 17, 2025, *status*: N/A, *requires*: pytest<9,>=4 @@ -4712,63 +4714,63 @@ This list contains 1585 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: Feb 11, 2025, + *last release*: Feb 20, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: Feb 11, 2025, + *last release*: Feb 20, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: Feb 11, 2025, + *last release*: Feb 20, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: Feb 11, 2025, + *last release*: Feb 20, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. :pypi:`pytest-embedded-nuttx` - *last release*: Feb 11, 2025, + *last release*: Feb 20, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with NuttX. :pypi:`pytest-embedded-qemu` - *last release*: Feb 11, 2025, + *last release*: Feb 20, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: Feb 11, 2025, + *last release*: Feb 20, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: Feb 11, 2025, + *last release*: Feb 20, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: Feb 11, 2025, + *last release*: Feb 20, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -5174,7 +5176,7 @@ This list contains 1585 plugins. Additional pytest markers to dynamically enable/disable tests viia CLI flags :pypi:`pytest-f3ts` - *last release*: Jan 22, 2025, + *last release*: Feb 21, 2025, *status*: N/A, *requires*: pytest<8.0.0,>=7.2.1 @@ -5790,7 +5792,7 @@ This list contains 1585 plugins. GCS fixtures and fixture factories for Pytest. :pypi:`pytest-gee` - *last release*: Jan 30, 2025, + *last release*: Feb 20, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -5825,7 +5827,7 @@ This list contains 1585 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Feb 14, 2025, + *last release*: Feb 20, 2025, *status*: N/A, *requires*: pytest>=3.6 @@ -6133,7 +6135,7 @@ This list contains 1585 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Feb 15, 2025, + *last release*: Feb 22, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.4 @@ -6651,14 +6653,14 @@ This list contains 1585 plugins. THIS PROJECT IS ABANDONED :pypi:`pytest-ipynb2` - *last release*: Feb 14, 2025, + *last release*: Feb 19, 2025, *status*: N/A, *requires*: pytest Pytest plugin to run tests in Jupyter Notebooks :pypi:`pytest-ipywidgets` - *last release*: Jan 29, 2025, + *last release*: Feb 18, 2025, *status*: N/A, *requires*: pytest @@ -7526,7 +7528,7 @@ This list contains 1585 plugins. pytest plugin to write integration tests for projects using Mercurial Python internals :pypi:`pytest-mergify` - *last release*: Feb 14, 2025, + *last release*: Feb 19, 2025, *status*: N/A, *requires*: N/A @@ -7568,7 +7570,7 @@ This list contains 1585 plugins. Custom metrics report for pytest :pypi:`pytest-mh` - *last release*: Nov 28, 2024, + *last release*: Feb 20, 2025, *status*: N/A, *requires*: pytest @@ -8639,7 +8641,7 @@ This list contains 1585 plugins. Run the tests related to the changed files :pypi:`pytest-pickle-cache` - *last release*: Jan 18, 2025, + *last release*: Feb 17, 2025, *status*: N/A, *requires*: pytest>=7 @@ -8708,6 +8710,13 @@ This list contains 1585 plugins. runs tests in an order such that coverage increases as fast as possible + :pypi:`pytest-platform-adapter` + *last release*: Feb 18, 2025, + *status*: 5 - Production/Stable, + *requires*: pytest>=6.2.5 + + Pytest集成自动化平台插件 + :pypi:`pytest-platform-markers` *last release*: Sep 09, 2019, *status*: 4 - Beta, @@ -9142,6 +9151,13 @@ This list contains 1585 plugins. pytest plugin to check source code with pylint + :pypi:`pytest-pylyzer` + *last release*: Feb 15, 2025, + *status*: 4 - Beta, + *requires*: N/A + + A pytest plugin for pylyzer + :pypi:`pytest-pymysql-autorecord` *last release*: Sep 02, 2022, *status*: N/A, @@ -9675,7 +9691,7 @@ This list contains 1585 plugins. A basic HTML report for pytest using Jinja2 template engine. :pypi:`pytest-report-extras` - *last release*: Feb 01, 2025, + *last release*: Feb 19, 2025, *status*: N/A, *requires*: pytest>=8.0.0 @@ -10200,7 +10216,7 @@ This list contains 1585 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Feb 13, 2025, + *last release*: Feb 20, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10284,7 +10300,7 @@ This list contains 1585 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Feb 13, 2025, + *last release*: Feb 20, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -11677,7 +11693,7 @@ This list contains 1585 plugins. The companion pytest plugin for tiny-api-client :pypi:`pytest-tinybird` - *last release*: Aug 29, 2024, + *last release*: Feb 18, 2025, *status*: 4 - Beta, *requires*: pytest>=3.8.0 From 4f682c17a23d56fbfd85bcf628f24f6d89edecfc Mon Sep 17 00:00:00 2001 From: jakkdl Date: Mon, 24 Feb 2025 11:54:58 +0100 Subject: [PATCH 322/445] fix rtd --- src/_pytest/python_api.py | 9 ++++----- src/_pytest/raises_group.py | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index c8edce4274a..ecb28c2ca49 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -17,10 +17,9 @@ from typing import TYPE_CHECKING from typing import TypeVar -import _pytest._code from _pytest.outcomes import fail -from _pytest.raises_group import BaseExcT_co_default from _pytest.raises_group import RaisesExc +from pytest import ExceptionInfo if sys.version_info < (3, 11): @@ -797,7 +796,7 @@ def raises( expected_exception: type[E] | tuple[type[E], ...], *, match: str | re.Pattern[str] | None = ..., - check: Callable[[BaseExcT_co_default], bool] = ..., + check: Callable[[E], bool] = ..., ) -> RaisesExc[E]: ... @@ -820,14 +819,14 @@ def raises( func: Callable[..., Any], *args: Any, **kwargs: Any, -) -> _pytest._code.ExceptionInfo[E]: ... +) -> ExceptionInfo[E]: ... def raises( expected_exception: type[E] | tuple[type[E], ...] | None = None, *args: Any, **kwargs: Any, -) -> RaisesExc[BaseException] | _pytest._code.ExceptionInfo[E]: +) -> RaisesExc[BaseException] | ExceptionInfo[E]: r"""Assert that a code block/function call raises an exception type, or one of its subclasses. :param expected_exception: diff --git a/src/_pytest/raises_group.py b/src/_pytest/raises_group.py index f60bacb7184..b521e1962b4 100644 --- a/src/_pytest/raises_group.py +++ b/src/_pytest/raises_group.py @@ -17,10 +17,10 @@ from typing import TYPE_CHECKING import warnings -from _pytest._code import ExceptionInfo from _pytest._code.code import stringify_exception from _pytest.outcomes import fail from _pytest.warning_types import PytestWarning +from pytest import ExceptionInfo if TYPE_CHECKING: From 309030c0ace99a725f9cbe830ddad87fd3a20140 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Mon, 24 Feb 2025 12:41:26 +0100 Subject: [PATCH 323/445] fix import loop --- src/_pytest/python_api.py | 2 +- src/_pytest/raises_group.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index ecb28c2ca49..f59d7ea8ef4 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -17,9 +17,9 @@ from typing import TYPE_CHECKING from typing import TypeVar +from _pytest._code import ExceptionInfo from _pytest.outcomes import fail from _pytest.raises_group import RaisesExc -from pytest import ExceptionInfo if sys.version_info < (3, 11): diff --git a/src/_pytest/raises_group.py b/src/_pytest/raises_group.py index b521e1962b4..f60bacb7184 100644 --- a/src/_pytest/raises_group.py +++ b/src/_pytest/raises_group.py @@ -17,10 +17,10 @@ from typing import TYPE_CHECKING import warnings +from _pytest._code import ExceptionInfo from _pytest._code.code import stringify_exception from _pytest.outcomes import fail from _pytest.warning_types import PytestWarning -from pytest import ExceptionInfo if TYPE_CHECKING: From 9cf2cae94355cd83ad7e8d88f976c5a524c98cfb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2025 20:59:07 +0000 Subject: [PATCH 324/445] [pre-commit.ci] pre-commit autoupdate (#13251) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.6 → v0.9.7](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.6...v0.9.7) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d746af2e4e5..085ea59ca05 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.9.6" + rev: "v0.9.7" hooks: - id: ruff args: ["--fix"] From 22fe7b17faf97f8413a57c6482f3dbfeb9287839 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Fri, 28 Feb 2025 15:07:26 +0100 Subject: [PATCH 325/445] =?UTF-8?q?=F0=9F=93=A6=F0=9F=93=9D=20Allow=20mode?= =?UTF-8?q?rn=20Towncrier=20in=20docs=20builds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/sphinx-contrib/sphinxcontrib-towncrier/issues/92 has been resolved and the recent Towncrier versions are compatible with the `sphinxcontrib.towncrier` Sphinx extension project yet again. --- doc/en/broken-dep-constraints.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/doc/en/broken-dep-constraints.txt b/doc/en/broken-dep-constraints.txt index 3a8d2c34b5a..1488e06fa23 100644 --- a/doc/en/broken-dep-constraints.txt +++ b/doc/en/broken-dep-constraints.txt @@ -1,6 +1,2 @@ # This file contains transitive dependencies that need to be pinned for some reason. # Eventually this file will be empty, but in this case keep it around for future use. - -# Pin towncrier temporarily due to incompatibility with sphinxcontrib-towncrier: -# https://github.com/sphinx-contrib/sphinxcontrib-towncrier/issues/92 -towncrier<24.7 From c51af71e635c1eafe421e61b5b9bf1647f6fd35b Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Fri, 28 Feb 2025 15:11:38 +0100 Subject: [PATCH 326/445] =?UTF-8?q?=F0=9F=93=9D=20Add=20a=20change=20note?= =?UTF-8?q?=20for=20#13256?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog/13256.contrib.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelog/13256.contrib.rst diff --git a/changelog/13256.contrib.rst b/changelog/13256.contrib.rst new file mode 100644 index 00000000000..fe3bac87ca1 --- /dev/null +++ b/changelog/13256.contrib.rst @@ -0,0 +1,2 @@ +Support for Towncier versions released in 2024 has been re-enabled +when building Sphinx docs -- by :user:`webknjaz`. From 611bb13108c249d2789014a631242f765efe1644 Mon Sep 17 00:00:00 2001 From: Anton Zhilin Date: Sat, 1 Mar 2025 16:06:40 +0300 Subject: [PATCH 327/445] Allow hiding a parameter set from test name (#13229) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #13228 --------- Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) --- AUTHORS | 1 + changelog/13228.feature.rst | 3 + doc/en/reference/reference.rst | 10 +++ src/_pytest/mark/__init__.py | 14 +++- src/_pytest/mark/structures.py | 22 ++++-- src/_pytest/python.py | 54 ++++++++++---- src/pytest/__init__.py | 2 + testing/python/metafunc.py | 125 +++++++++++++++++++++++++++++++++ testing/test_mark.py | 6 +- 9 files changed, 216 insertions(+), 21 deletions(-) create mode 100644 changelog/13228.feature.rst diff --git a/AUTHORS b/AUTHORS index e670571566a..e5c19cdca0d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -43,6 +43,7 @@ Anthony Shaw Anthony Sottile Anton Grinevich Anton Lodder +Anton Zhilin Antony Lee Arel Cordero Arias Emmanuel diff --git a/changelog/13228.feature.rst b/changelog/13228.feature.rst new file mode 100644 index 00000000000..c5d84182313 --- /dev/null +++ b/changelog/13228.feature.rst @@ -0,0 +1,3 @@ +:ref:`hidden-param` can now be used in ``id`` of :func:`pytest.param` or in +``ids`` of :py:func:`Metafunc.parametrize `. +It hides the parameter set from the test name. diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 809e97b4747..267ab37b1b1 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -20,6 +20,16 @@ The current pytest version, as a string:: >>> pytest.__version__ '7.0.0' +.. _`hidden-param`: + +pytest.HIDDEN_PARAM +~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 8.4 + +Can be passed to ``ids`` of :py:func:`Metafunc.parametrize ` +or to ``id`` of :func:`pytest.param` to hide a parameter set from the test name. +Can only be used at most 1 time, as test names need to be unique. .. _`version-tuple`: diff --git a/src/_pytest/mark/__init__.py b/src/_pytest/mark/__init__.py index 488b562a298..068c7410a46 100644 --- a/src/_pytest/mark/__init__.py +++ b/src/_pytest/mark/__init__.py @@ -12,8 +12,10 @@ from .expression import Expression from .expression import ParseError +from .structures import _HiddenParam from .structures import EMPTY_PARAMETERSET_OPTION from .structures import get_empty_parameterset_mark +from .structures import HIDDEN_PARAM from .structures import Mark from .structures import MARK_GEN from .structures import MarkDecorator @@ -33,6 +35,7 @@ __all__ = [ + "HIDDEN_PARAM", "MARK_GEN", "Mark", "MarkDecorator", @@ -48,7 +51,7 @@ def param( *values: object, marks: MarkDecorator | Collection[MarkDecorator | Mark] = (), - id: str | None = None, + id: str | _HiddenParam | None = None, ) -> ParameterSet: """Specify a parameter in `pytest.mark.parametrize`_ calls or :ref:`parametrized fixtures `. @@ -72,7 +75,14 @@ def test_eval(test_input, expected): :ref:`pytest.mark.usefixtures ` cannot be added via this parameter. - :param id: The id to attribute to this parameter set. + :type id: str | Literal[pytest.HIDDEN_PARAM] | None + :param id: + The id to attribute to this parameter set. + + .. versionadded:: 8.4 + :ref:`hidden-param` means to hide the parameter set + from the test name. Can only be used at most 1 time, as + test names need to be unique. """ return ParameterSet.param(*values, marks=marks, id=id) diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 1a0b3c5b5b8..a3290aed82e 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -10,6 +10,7 @@ from collections.abc import MutableMapping from collections.abc import Sequence import dataclasses +import enum import inspect from typing import Any from typing import final @@ -38,6 +39,16 @@ EMPTY_PARAMETERSET_OPTION = "empty_parameter_set_mark" +# Singleton type for HIDDEN_PARAM, as described in: +# https://www.python.org/dev/peps/pep-0484/#support-for-singleton-types-in-unions +class _HiddenParam(enum.Enum): + token = 0 + + +#: Can be used as a parameter set id to hide it from the test name. +HIDDEN_PARAM = _HiddenParam.token + + def istestfunc(func) -> bool: return callable(func) and getattr(func, "__name__", "") != "" @@ -68,14 +79,14 @@ def get_empty_parameterset_mark( class ParameterSet(NamedTuple): values: Sequence[object | NotSetType] marks: Collection[MarkDecorator | Mark] - id: str | None + id: str | _HiddenParam | None @classmethod def param( cls, *values: object, marks: MarkDecorator | Collection[MarkDecorator | Mark] = (), - id: str | None = None, + id: str | _HiddenParam | None = None, ) -> ParameterSet: if isinstance(marks, MarkDecorator): marks = (marks,) @@ -88,8 +99,11 @@ def param( ) if id is not None: - if not isinstance(id, str): - raise TypeError(f"Expected id to be a string, got {type(id)}: {id!r}") + if not isinstance(id, str) and id is not HIDDEN_PARAM: + raise TypeError( + "Expected id to be a string or a `pytest.HIDDEN_PARAM` sentinel, " + f"got {type(id)}: {id!r}", + ) return cls(values, marks, id) @classmethod diff --git a/src/_pytest/python.py b/src/_pytest/python.py index ef8a5f02b53..902bcfade9f 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -25,6 +25,7 @@ from typing import Any from typing import final from typing import Literal +from typing import NoReturn from typing import TYPE_CHECKING import warnings @@ -56,7 +57,9 @@ from _pytest.fixtures import get_scope_node from _pytest.main import Session from _pytest.mark import ParameterSet +from _pytest.mark.structures import _HiddenParam from _pytest.mark.structures import get_unpacked_marks +from _pytest.mark.structures import HIDDEN_PARAM from _pytest.mark.structures import Mark from _pytest.mark.structures import MarkDecorator from _pytest.mark.structures import normalize_mark_list @@ -473,7 +476,7 @@ def _genfunctions(self, name: str, funcobj) -> Iterator[Function]: fixtureinfo.prune_dependency_tree() for callspec in metafunc._calls: - subname = f"{name}[{callspec.id}]" + subname = f"{name}[{callspec.id}]" if callspec._idlist else name yield Function.from_parent( self, name=subname, @@ -884,7 +887,7 @@ class IdMaker: # Used only for clearer error messages. func_name: str | None - def make_unique_parameterset_ids(self) -> list[str]: + def make_unique_parameterset_ids(self) -> list[str | _HiddenParam]: """Make a unique identifier for each ParameterSet, that may be used to identify the parametrization in a node ID. @@ -905,6 +908,8 @@ def make_unique_parameterset_ids(self) -> list[str]: # Suffix non-unique IDs to make them unique. for index, id in enumerate(resolved_ids): if id_counts[id] > 1: + if id is HIDDEN_PARAM: + self._complain_multiple_hidden_parameter_sets() suffix = "" if id and id[-1].isdigit(): suffix = "_" @@ -919,15 +924,21 @@ def make_unique_parameterset_ids(self) -> list[str]: ) return resolved_ids - def _resolve_ids(self) -> Iterable[str]: + def _resolve_ids(self) -> Iterable[str | _HiddenParam]: """Resolve IDs for all ParameterSets (may contain duplicates).""" for idx, parameterset in enumerate(self.parametersets): if parameterset.id is not None: # ID provided directly - pytest.param(..., id="...") - yield _ascii_escaped_by_config(parameterset.id, self.config) + if parameterset.id is HIDDEN_PARAM: + yield HIDDEN_PARAM + else: + yield _ascii_escaped_by_config(parameterset.id, self.config) elif self.ids and idx < len(self.ids) and self.ids[idx] is not None: # ID provided in the IDs list - parametrize(..., ids=[...]). - yield self._idval_from_value_required(self.ids[idx], idx) + if self.ids[idx] is HIDDEN_PARAM: + yield HIDDEN_PARAM + else: + yield self._idval_from_value_required(self.ids[idx], idx) else: # ID not provided - generate it. yield "-".join( @@ -1001,12 +1012,7 @@ def _idval_from_value_required(self, val: object, idx: int) -> str: return id # Fail. - if self.func_name is not None: - prefix = f"In {self.func_name}: " - elif self.nodeid is not None: - prefix = f"In {self.nodeid}: " - else: - prefix = "" + prefix = self._make_error_prefix() msg = ( f"{prefix}ids contains unsupported value {saferepr(val)} (type: {type(val)!r}) at index {idx}. " "Supported types are: str, bytes, int, float, complex, bool, enum, regex or anything with a __name__." @@ -1019,6 +1025,21 @@ def _idval_from_argname(argname: str, idx: int) -> str: and the index of the ParameterSet.""" return str(argname) + str(idx) + def _complain_multiple_hidden_parameter_sets(self) -> NoReturn: + fail( + f"{self._make_error_prefix()}multiple instances of HIDDEN_PARAM " + "cannot be used in the same parametrize call, " + "because the tests names need to be unique." + ) + + def _make_error_prefix(self) -> str: + if self.func_name is not None: + return f"In {self.func_name}: " + elif self.nodeid is not None: + return f"In {self.nodeid}: " + else: + return "" + @final @dataclasses.dataclass(frozen=True) @@ -1047,7 +1068,7 @@ def setmulti( *, argnames: Iterable[str], valset: Iterable[object], - id: str, + id: str | _HiddenParam, marks: Iterable[Mark | MarkDecorator], scope: Scope, param_index: int, @@ -1065,7 +1086,7 @@ def setmulti( params=params, indices=indices, _arg2scope=arg2scope, - _idlist=[*self._idlist, id], + _idlist=self._idlist if id is HIDDEN_PARAM else [*self._idlist, id], marks=[*self.marks, *normalize_mark_list(marks)], ) @@ -1190,6 +1211,11 @@ def parametrize( They are mapped to the corresponding index in ``argvalues``. ``None`` means to use the auto-generated id. + .. versionadded:: 8.4 + :ref:`hidden-param` means to hide the parameter set + from the test name. Can only be used at most 1 time, as + test names need to be unique. + If it is a callable it will be called for each entry in ``argvalues``, and the return value is used as part of the auto-generated id for the whole set (where parts are joined with @@ -1322,7 +1348,7 @@ def _resolve_parameter_set_ids( ids: Iterable[object | None] | Callable[[Any], object | None] | None, parametersets: Sequence[ParameterSet], nodeid: str, - ) -> list[str]: + ) -> list[str | _HiddenParam]: """Resolve the actual ids for the given parameter sets. :param argnames: diff --git a/src/pytest/__init__.py b/src/pytest/__init__.py index 70096d6593e..f81b8cea1db 100644 --- a/src/pytest/__init__.py +++ b/src/pytest/__init__.py @@ -33,6 +33,7 @@ from _pytest.logging import LogCaptureFixture from _pytest.main import Dir from _pytest.main import Session +from _pytest.mark import HIDDEN_PARAM from _pytest.mark import Mark from _pytest.mark import MARK_GEN as mark from _pytest.mark import MarkDecorator @@ -89,6 +90,7 @@ __all__ = [ + "HIDDEN_PARAM", "Cache", "CallInfo", "CaptureFixture", diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 4e7e441768c..e8b345aecc6 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -19,6 +19,7 @@ from _pytest.compat import getfuncargnames from _pytest.compat import NOTSET from _pytest.outcomes import fail +from _pytest.outcomes import Failed from _pytest.pytester import Pytester from _pytest.python import Function from _pytest.python import IdMaker @@ -2143,3 +2144,127 @@ def test_converted_to_str(a, b): "*= 6 passed in *", ] ) + + +class TestHiddenParam: + """Test that pytest.HIDDEN_PARAM works""" + + def test_parametrize_ids(self, pytester: Pytester) -> None: + items = pytester.getitems( + """ + import pytest + + @pytest.mark.parametrize( + ("foo", "bar"), + [ + ("a", "x"), + ("b", "y"), + ("c", "z"), + ], + ids=["paramset1", pytest.HIDDEN_PARAM, "paramset3"], + ) + def test_func(foo, bar): + pass + """ + ) + names = [item.name for item in items] + assert names == [ + "test_func[paramset1]", + "test_func", + "test_func[paramset3]", + ] + + def test_param_id(self, pytester: Pytester) -> None: + items = pytester.getitems( + """ + import pytest + + @pytest.mark.parametrize( + ("foo", "bar"), + [ + pytest.param("a", "x", id="paramset1"), + pytest.param("b", "y", id=pytest.HIDDEN_PARAM), + ("c", "z"), + ], + ) + def test_func(foo, bar): + pass + """ + ) + names = [item.name for item in items] + assert names == [ + "test_func[paramset1]", + "test_func", + "test_func[c-z]", + ] + + def test_multiple_hidden_param_is_forbidden(self, pytester: Pytester) -> None: + pytester.makepyfile( + """ + import pytest + + @pytest.mark.parametrize( + ("foo", "bar"), + [ + ("a", "x"), + ("b", "y"), + ], + ids=[pytest.HIDDEN_PARAM, pytest.HIDDEN_PARAM], + ) + def test_func(foo, bar): + pass + """ + ) + result = pytester.runpytest("--collect-only") + result.stdout.fnmatch_lines( + [ + "collected 0 items / 1 error", + "", + "*= ERRORS =*", + "*_ ERROR collecting test_multiple_hidden_param_is_forbidden.py _*", + "E Failed: In test_func: multiple instances of HIDDEN_PARAM cannot be used " + "in the same parametrize call, because the tests names need to be unique.", + "*! Interrupted: 1 error during collection !*", + "*= no tests collected, 1 error in *", + ] + ) + + def test_multiple_hidden_param_is_forbidden_idmaker(self) -> None: + id_maker = IdMaker( + ("foo", "bar"), + [pytest.param("a", "x"), pytest.param("b", "y")], + None, + [pytest.HIDDEN_PARAM, pytest.HIDDEN_PARAM], + None, + "some_node_id", + None, + ) + expected = "In some_node_id: multiple instances of HIDDEN_PARAM" + with pytest.raises(Failed, match=expected): + id_maker.make_unique_parameterset_ids() + + def test_multiple_parametrize(self, pytester: Pytester) -> None: + items = pytester.getitems( + """ + import pytest + + @pytest.mark.parametrize( + "bar", + ["x", "y"], + ) + @pytest.mark.parametrize( + "foo", + ["a", "b"], + ids=["a", pytest.HIDDEN_PARAM], + ) + def test_func(foo, bar): + pass + """ + ) + names = [item.name for item in items] + assert names == [ + "test_func[a-x]", + "test_func[a-y]", + "test_func[x]", + "test_func[y]", + ] diff --git a/testing/test_mark.py b/testing/test_mark.py index 7b76acf9990..1e51f9db18f 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -1170,7 +1170,11 @@ def test_pytest_param_id_requires_string() -> None: with pytest.raises(TypeError) as excinfo: pytest.param(id=True) # type: ignore[arg-type] (msg,) = excinfo.value.args - assert msg == "Expected id to be a string, got : True" + expected = ( + "Expected id to be a string or a `pytest.HIDDEN_PARAM` sentinel, " + "got : True" + ) + assert msg == expected @pytest.mark.parametrize("s", (None, "hello world")) From 9f3c4d11d9b162d0926e9a3ae57ec6f262362d73 Mon Sep 17 00:00:00 2001 From: "Vincent (Wen Yu) Ge" Date: Sat, 1 Mar 2025 09:23:13 -0500 Subject: [PATCH 328/445] Add more resources and studies to flaky tests page in docs (#13250) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) Co-authored-by: Bruno Oliveira --- doc/en/explanation/flaky.rst | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/en/explanation/flaky.rst b/doc/en/explanation/flaky.rst index cb6c3983424..8369e1d9311 100644 --- a/doc/en/explanation/flaky.rst +++ b/doc/en/explanation/flaky.rst @@ -117,8 +117,11 @@ This is a limited list, please submit an issue or pull request to expand it! * Gao, Zebao, Yalan Liang, Myra B. Cohen, Atif M. Memon, and Zhen Wang. "Making system user interactive tests repeatable: When and what should we control?." In *Software Engineering (ICSE), 2015 IEEE/ACM 37th IEEE International Conference on*, vol. 1, pp. 55-65. IEEE, 2015. `PDF `__ * Palomba, Fabio, and Andy Zaidman. "Does refactoring of test smells induce fixing flaky tests?." In *Software Maintenance and Evolution (ICSME), 2017 IEEE International Conference on*, pp. 1-12. IEEE, 2017. `PDF in Google Drive `__ -* Bell, Jonathan, Owolabi Legunsen, Michael Hilton, Lamyaa Eloussi, Tifany Yung, and Darko Marinov. "DeFlaker: Automatically detecting flaky tests." In *Proceedings of the 2018 International Conference on Software Engineering*. 2018. `PDF `__ -* Dutta, Saikat and Shi, August and Choudhary, Rutvik and Zhang, Zhekun and Jain, Aryaman and Misailovic, Sasa. "Detecting flaky tests in probabilistic and machine learning applications." In *Proceedings of the 29th ACM SIGSOFT International Symposium on Software Testing and Analysis (ISSTA)*, pp. 211-224. ACM, 2020. `PDF `__ +* Bell, Jonathan, Owolabi Legunsen, Michael Hilton, Lamyaa Eloussi, Tifany Yung, and Darko Marinov. "DeFlaker: Automatically detecting flaky tests." In *Proceedings of the 2018 International Conference on Software Engineering*. 2018. `PDF `__ +* Dutta, Saikat and Shi, August and Choudhary, Rutvik and Zhang, Zhekun and Jain, Aryaman and Misailovic, Sasa. "Detecting flaky tests in probabilistic and machine learning applications." In *Proceedings of the 29th ACM SIGSOFT International Symposium on Software Testing and Analysis (ISSTA)*, pp. 211-224. ACM, 2020. `PDF `__ +* Habchi, Sarra and Haben, Guillaume and Sohn, Jeongju and Franci, Adriano and Papadakis, Mike and Cordy, Maxime and Le Traon, Yves. "What Made This Test Flake? Pinpointing Classes Responsible for Test Flakiness." In Proceedings of the 38th IEEE International Conference on Software Maintenance and Evolution (ICSME), IEEE, 2022. `PDF `__ +* Lamprou, Sokrates. "Non-deterministic tests and where to find them: Empirically investigating the relationship between flaky tests and test smells by examining test order dependency." Bachelor thesis, Department of Computer and Information Science, Linköping University, 2022. LIU-IDA/LITH-EX-G–19/056–SE. `PDF `__ +* Leinen, Fabian and Elsner, Daniel and Pretschner, Alexander and Stahlbauer, Andreas and Sailer, Michael and Jürgens, Elmar. "Cost of Flaky Tests in Continuous Integration: An Industrial Case Study." Technical University of Munich and CQSE GmbH, Munich, Germany, 2023. `PDF `__ Resources ^^^^^^^^^ @@ -137,5 +140,12 @@ Resources * `Flaky Tests at Google and How We Mitigate Them `_ by John Micco, 2016 * `Where do Google's flaky tests come from? `_ by Jeff Listfield, 2017 +* Dropbox: + * `Athena: Our automated build health management system `_ by Utsav Shah, 2019 + * `How To Manage Flaky Tests in your CI Workflows `_ by Li Haoyi, 2025 + +* Uber: + * `Handling Flaky Unit Tests in Java `_ by Uber Engineering, 2021 + * `Flaky Tests Overhaul at Uber `_ by Uber Engineering, 2024 .. _pytest-xdist: https://github.com/pytest-dev/pytest-xdist From 064638352d2c1f794fb494e52c0be522a6cb58c4 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 1 Mar 2025 15:00:17 +0000 Subject: [PATCH 329/445] Copy docstrings to wrapped pdb methods (#12947) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bruno Oliveira Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) --- changelog/12946.bugfix.rst | 1 + src/_pytest/debugging.py | 20 +++++++---- testing/test_debugging.py | 68 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 changelog/12946.bugfix.rst diff --git a/changelog/12946.bugfix.rst b/changelog/12946.bugfix.rst new file mode 100644 index 00000000000..b11da09e7ae --- /dev/null +++ b/changelog/12946.bugfix.rst @@ -0,0 +1 @@ +Fixed missing help for :mod:`pdb` commands wrapped by pytest -- by :user:`adamchainz`. diff --git a/src/_pytest/debugging.py b/src/_pytest/debugging.py index 040e8994b37..de1b2688f76 100644 --- a/src/_pytest/debugging.py +++ b/src/_pytest/debugging.py @@ -159,6 +159,9 @@ def do_debug(self, arg): cls._recursive_debug -= 1 return ret + if hasattr(pdb_cls, "do_debug"): + do_debug.__doc__ = pdb_cls.do_debug.__doc__ + def do_continue(self, arg): ret = super().do_continue(arg) if cls._recursive_debug == 0: @@ -185,15 +188,17 @@ def do_continue(self, arg): self._continued = True return ret + if hasattr(pdb_cls, "do_continue"): + do_continue.__doc__ = pdb_cls.do_continue.__doc__ + do_c = do_cont = do_continue def do_quit(self, arg): - """Raise Exit outcome when quit command is used in pdb. - - This is a bit of a hack - it would be better if BdbQuit - could be handled, but this would require to wrap the - whole pytest run, and adjust the report etc. - """ + # Raise Exit outcome when quit command is used in pdb. + # + # This is a bit of a hack - it would be better if BdbQuit + # could be handled, but this would require to wrap the + # whole pytest run, and adjust the report etc. ret = super().do_quit(arg) if cls._recursive_debug == 0: @@ -201,6 +206,9 @@ def do_quit(self, arg): return ret + if hasattr(pdb_cls, "do_quit"): + do_quit.__doc__ = pdb_cls.do_quit.__doc__ + do_q = do_quit do_exit = do_quit diff --git a/testing/test_debugging.py b/testing/test_debugging.py index 9588da8936f..45883568b11 100644 --- a/testing/test_debugging.py +++ b/testing/test_debugging.py @@ -52,6 +52,16 @@ def reset(self): def interaction(self, *args): called.append("interaction") + # Methods which we copy docstrings to. + def do_debug(self, *args): # pragma: no cover + pass + + def do_continue(self, *args): # pragma: no cover + pass + + def do_quit(self, *args): # pragma: no cover + pass + _pytest._CustomPdb = _CustomPdb # type: ignore return called @@ -75,6 +85,16 @@ def set_trace(self, frame): print("**CustomDebugger**") called.append("set_trace") + # Methods which we copy docstrings to. + def do_debug(self, *args): # pragma: no cover + pass + + def do_continue(self, *args): # pragma: no cover + pass + + def do_quit(self, *args): # pragma: no cover + pass + _pytest._CustomDebugger = _CustomDebugger # type: ignore yield called del _pytest._CustomDebugger # type: ignore @@ -965,6 +985,34 @@ def test_1(): child.sendeof() self.flush(child) + def test_pdb_wrapped_commands_docstrings(self, pytester: Pytester) -> None: + p1 = pytester.makepyfile( + """ + def test_1(): + assert False + """ + ) + + child = pytester.spawn_pytest(f"--pdb {p1}") + child.expect("Pdb") + + # Verify no undocumented commands + child.sendline("help") + child.expect("Documented commands") + assert "Undocumented commands" not in child.before.decode() + + child.sendline("help continue") + child.expect("Continue execution") + child.expect("Pdb") + + child.sendline("help debug") + child.expect("Enter a recursive debugger") + child.expect("Pdb") + + child.sendline("c") + child.sendeof() + self.flush(child) + class TestDebuggingBreakpoints: @pytest.mark.parametrize("arg", ["--pdb", ""]) @@ -1288,6 +1336,16 @@ def set_trace(self, *args): def runcall(self, *args, **kwds): print("runcall_called", args, kwds) + + # Methods which we copy the docstring over. + def do_debug(self, *args): + pass + + def do_continue(self, *args): + pass + + def do_quit(self, *args): + pass """, ) result = pytester.runpytest( @@ -1354,6 +1412,16 @@ def __init__(self, *args, **kwargs): def set_trace(self, *args): print("set_trace_called", args) + + # Methods which we copy the docstring over. + def do_debug(self, *args): + pass + + def do_continue(self, *args): + pass + + def do_quit(self, *args): + pass """, ) result = pytester.runpytest(str(p1), "--pdbcls=mypdb:MyPdb", syspathinsert=True) From d3adf46ad7a077233bc5f840f69d59fde5b4aa66 Mon Sep 17 00:00:00 2001 From: Andrew Pikul Date: Sat, 1 Mar 2025 10:37:16 -0500 Subject: [PATCH 330/445] Add capteesys capture fixture to bubble up output to `--capture` handler (#12854) The config dict is passed alongside the class that the fixture will eventually initialize. It can use the config dict for optional arguments to the implementation's constructor. --- AUTHORS | 1 + changelog/12081.feature.rst | 1 + doc/en/how-to/capture-stdout-stderr.rst | 10 ++++-- doc/en/reference/fixtures.rst | 4 +++ doc/en/reference/reference.rst | 10 ++++++ src/_pytest/capture.py | 41 +++++++++++++++++++++++-- testing/test_capture.py | 32 +++++++++++++++++++ 7 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 changelog/12081.feature.rst diff --git a/AUTHORS b/AUTHORS index e5c19cdca0d..ab72f4b7ed7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -32,6 +32,7 @@ Andras Tim Andrea Cimatoribus Andreas Motl Andreas Zeidler +Andrew Pikul Andrew Shapton Andrey Paramonov Andrzej Klajnert diff --git a/changelog/12081.feature.rst b/changelog/12081.feature.rst new file mode 100644 index 00000000000..6538fbf30f8 --- /dev/null +++ b/changelog/12081.feature.rst @@ -0,0 +1 @@ +Added :fixture:`capteesys` to capture AND pass output to next handler set by ``--capture=``. diff --git a/doc/en/how-to/capture-stdout-stderr.rst b/doc/en/how-to/capture-stdout-stderr.rst index d91bef736e7..e6affd80ea1 100644 --- a/doc/en/how-to/capture-stdout-stderr.rst +++ b/doc/en/how-to/capture-stdout-stderr.rst @@ -4,6 +4,12 @@ How to capture stdout/stderr output ========================================================= +Pytest intercepts stdout and stderr as configured by the ``--capture=`` +command-line argument or by using fixtures. The ``--capture=`` flag configures +reporting, whereas the fixtures offer more granular control and allows +inspection of output during testing. The reports can be customized with the +`-r flag <../reference/reference.html#command-line-flags>`_. + Default stdout/stderr/stdin capturing behaviour --------------------------------------------------------- @@ -106,8 +112,8 @@ of the failing function and hide the other one: Accessing captured output from a test function --------------------------------------------------- -The :fixture:`capsys`, :fixture:`capsysbinary`, :fixture:`capfd`, and :fixture:`capfdbinary` fixtures -allow access to ``stdout``/``stderr`` output created during test execution. +The :fixture:`capsys`, :fixture:`capteesys`, :fixture:`capsysbinary`, :fixture:`capfd`, and :fixture:`capfdbinary` +fixtures allow access to ``stdout``/``stderr`` output created during test execution. Here is an example test function that performs some output related checks: diff --git a/doc/en/reference/fixtures.rst b/doc/en/reference/fixtures.rst index dff93a035ef..566304d3330 100644 --- a/doc/en/reference/fixtures.rst +++ b/doc/en/reference/fixtures.rst @@ -32,6 +32,10 @@ Built-in fixtures :fixture:`capsys` Capture, as text, output to ``sys.stdout`` and ``sys.stderr``. + :fixture:`capteesys` + Capture in the same manner as :fixture:`capsys`, but also pass text + through according to ``--capture=``. + :fixture:`capsysbinary` Capture, as bytes, output to ``sys.stdout`` and ``sys.stderr``. diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 267ab37b1b1..7e328f60939 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -412,6 +412,16 @@ capsys .. autoclass:: pytest.CaptureFixture() :members: +.. fixture:: capteesys + +capteesys +~~~~~~~~~ + +**Tutorial**: :ref:`captures` + +.. autofunction:: _pytest.capture.capteesys() + :no-auto-options: + .. fixture:: capsysbinary capsysbinary diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index d447d087031..3812d88176a 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -922,11 +922,13 @@ def __init__( captureclass: type[CaptureBase[AnyStr]], request: SubRequest, *, + config: dict[str, Any] | None = None, _ispytest: bool = False, ) -> None: check_ispytest(_ispytest) self.captureclass: type[CaptureBase[AnyStr]] = captureclass self.request = request + self._config = config if config else {} self._capture: MultiCapture[AnyStr] | None = None self._captured_out: AnyStr = self.captureclass.EMPTY_BUFFER self._captured_err: AnyStr = self.captureclass.EMPTY_BUFFER @@ -935,8 +937,8 @@ def _start(self) -> None: if self._capture is None: self._capture = MultiCapture( in_=None, - out=self.captureclass(1), - err=self.captureclass(2), + out=self.captureclass(1, **self._config), + err=self.captureclass(2, **self._config), ) self._capture.start_capturing() @@ -1022,6 +1024,41 @@ def test_output(capsys): capman.unset_fixture() +@fixture +def capteesys(request: SubRequest) -> Generator[CaptureFixture[str]]: + r"""Enable simultaneous text capturing and pass-through of writes + to ``sys.stdout`` and ``sys.stderr`` as defined by ``--capture=``. + + + The captured output is made available via ``capteesys.readouterr()`` method + calls, which return a ``(out, err)`` namedtuple. + ``out`` and ``err`` will be ``text`` objects. + + The output is also passed-through, allowing it to be "live-printed", + reported, or both as defined by ``--capture=``. + + Returns an instance of :class:`CaptureFixture[str] `. + + Example: + + .. code-block:: python + + def test_output(capsys): + print("hello") + captured = capteesys.readouterr() + assert captured.out == "hello\n" + """ + capman: CaptureManager = request.config.pluginmanager.getplugin("capturemanager") + capture_fixture = CaptureFixture( + SysCapture, request, config=dict(tee=True), _ispytest=True + ) + capman.set_fixture(capture_fixture) + capture_fixture._start() + yield capture_fixture + capture_fixture.close() + capman.unset_fixture() + + @fixture def capsysbinary(request: SubRequest) -> Generator[CaptureFixture[bytes]]: r"""Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``. diff --git a/testing/test_capture.py b/testing/test_capture.py index a59273734c4..d9dacebd938 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -446,6 +446,38 @@ def test_hello(capsys): ) reprec.assertoutcome(passed=1) + def test_capteesys(self, pytester: Pytester) -> None: + p = pytester.makepyfile( + """\ + import sys + def test_one(capteesys): + print("sTdoUt") + print("sTdeRr", file=sys.stderr) + out, err = capteesys.readouterr() + assert out == "sTdoUt\\n" + assert err == "sTdeRr\\n" + """ + ) + # -rN and --capture=tee-sys means we'll read them on stdout/stderr, + # as opposed to both being reported on stdout + result = pytester.runpytest(p, "--quiet", "--quiet", "-rN", "--capture=tee-sys") + assert result.ret == ExitCode.OK + result.stdout.fnmatch_lines(["sTdoUt"]) # tee'd out + result.stderr.fnmatch_lines(["sTdeRr"]) # tee'd out + + result = pytester.runpytest(p, "--quiet", "--quiet", "-rA", "--capture=tee-sys") + assert result.ret == ExitCode.OK + result.stdout.fnmatch_lines( + ["sTdoUt", "sTdoUt", "sTdeRr"] + ) # tee'd out, the next two reported + result.stderr.fnmatch_lines(["sTdeRr"]) # tee'd out + + # -rA and --capture=sys means we'll read them on stdout. + result = pytester.runpytest(p, "--quiet", "--quiet", "-rA", "--capture=sys") + assert result.ret == ExitCode.OK + result.stdout.fnmatch_lines(["sTdoUt", "sTdeRr"]) # no tee, just reported + assert not result.stderr.lines + def test_capsyscapfd(self, pytester: Pytester) -> None: p = pytester.makepyfile( """\ From ca351458d85d0276ee4aa3079c8305feafe42b76 Mon Sep 17 00:00:00 2001 From: mwychung <145583690+mwychung@users.noreply.github.com> Date: Sun, 2 Mar 2025 00:00:57 +0800 Subject: [PATCH 331/445] Added dedicated page about using types with pytest #12842 (#12963) Fixes #12842 --------- Co-authored-by: Bruno Oliveira --- AUTHORS | 1 + changelog/12842.doc.rst | 3 ++ doc/en/explanation/index.rst | 1 + doc/en/explanation/types.rst | 89 ++++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 changelog/12842.doc.rst create mode 100644 doc/en/explanation/types.rst diff --git a/AUTHORS b/AUTHORS index ab72f4b7ed7..95e6b13f11e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -265,6 +265,7 @@ lovetheguitar Lukas Bednar Luke Murphy Maciek Fijalkowski +Maggie Chung Maho Maik Figura Mandeep Bhutani diff --git a/changelog/12842.doc.rst b/changelog/12842.doc.rst new file mode 100644 index 00000000000..0a0f5c5bc23 --- /dev/null +++ b/changelog/12842.doc.rst @@ -0,0 +1,3 @@ +Added dedicated page about using types with pytest. + +See :ref:`types` for detailed usage. diff --git a/doc/en/explanation/index.rst b/doc/en/explanation/index.rst index 2edf60a5d8b..2606d7d4b34 100644 --- a/doc/en/explanation/index.rst +++ b/doc/en/explanation/index.rst @@ -12,5 +12,6 @@ Explanation fixtures goodpractices pythonpath + types ci flaky diff --git a/doc/en/explanation/types.rst b/doc/en/explanation/types.rst new file mode 100644 index 00000000000..827a2bf02b6 --- /dev/null +++ b/doc/en/explanation/types.rst @@ -0,0 +1,89 @@ +.. _types: + +Typing in pytest +================ + +.. note:: + This page assumes the reader is familiar with Python's typing system and its advantages. + + For more information, refer to `Python's Typing Documentation `_. + +Why type tests? +--------------- + +Typing tests provides significant advantages: + +- **Readability:** Clearly defines expected inputs and outputs, improving readability, especially in complex or parameterized tests. + +- **Refactoring:** This is the main benefit in typing tests, as it will greatly help with refactoring, letting the type checker point out the necessary changes in both production and tests, without needing to run the full test suite. + +For production code, typing also helps catching some bugs that might not be caught by tests at all (regardless of coverage), for example: + +.. code-block:: python + + def get_caption(target: int, items: list[tuple[int, str]]) -> str: + for value, caption in items: + if value == target: + return caption + + +The type checker will correctly error out that the function might return `None`, however even a full coverage test suite might miss that case: + +.. code-block:: python + + def test_get_caption() -> None: + assert get_caption(10, [(1, "foo"), (10, "bar")]) == "bar" + + +Note the code above has 100% coverage, but the bug is not caught (of course the example is "obvious", but serves to illustrate the point). + + + +Using typing in test suites +--------------------------- + +To type fixtures in pytest, just add normal types to the fixture functions -- there is nothing special that needs to be done just because of the `fixture` decorator. + +.. code-block:: python + + import pytest + + + @pytest.fixture + def sample_fixture() -> int: + return 38 + +In the same manner, the fixtures passed to test functions need be annotated with the fixture's return type: + +.. code-block:: python + + def test_sample_fixture(sample_fixture: int) -> None: + assert sample_fixture == 38 + +From the POV of the type checker, it does not matter that `sample_fixture` is actually a fixture managed by pytest, all it matters to it is that `sample_fixture` is a parameter of type `int`. + + +The same logic applies to :ref:`@pytest.mark.parametrize <@pytest.mark.parametrize>`: + +.. code-block:: python + + + @pytest.mark.parametrize("input_value, expected_output", [(1, 2), (5, 6), (10, 11)]) + def test_increment(input_value: int, expected_output: int) -> None: + assert input_value + 1 == expected_output + + +The same logic applies when typing fixture functions which receive other fixtures: + +.. code-block:: python + + @pytest.fixture + def mock_env_user(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setenv("USER", "TestingUser") + + +Conclusion +---------- + +Incorporating typing into pytest tests enhances **clarity**, improves **debugging** and **maintenance**, and ensures **type safety**. +These practices lead to a **robust**, **readable**, and **easily maintainable** test suite that is better equipped to handle future changes with minimal risk of errors. From 5bd393cf0151d5278ad18b508ce06b15bc95a499 Mon Sep 17 00:00:00 2001 From: John Litborn <11260241+jakkdl@users.noreply.github.com> Date: Sat, 1 Mar 2025 23:27:25 +0100 Subject: [PATCH 332/445] add --disable-plugin-autoload (#13253) * add --disable-plugin-autoload * update comments in test, don't check __spec__ on pypy (????), add changelog * pemdas except not * Apply suggestions from code review Co-authored-by: Florian Bruhin * add parens * Simplify plugin name in test_installed_plugin_rewrite * Apply suggestions from code review * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Florian Bruhin Co-authored-by: Bruno Oliveira Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- changelog/13253.feature.rst | 1 + doc/en/how-to/plugins.rst | 27 ++++++++++++++- doc/en/reference/reference.rst | 7 ++-- src/_pytest/config/__init__.py | 26 +++++++++++---- src/_pytest/helpconfig.py | 9 ++++- testing/test_assertion.py | 51 +++++++++++++++++++++++----- testing/test_config.py | 61 +++++++++++++++++++++++++++------- 7 files changed, 151 insertions(+), 31 deletions(-) create mode 100644 changelog/13253.feature.rst diff --git a/changelog/13253.feature.rst b/changelog/13253.feature.rst new file mode 100644 index 00000000000..e497c207223 --- /dev/null +++ b/changelog/13253.feature.rst @@ -0,0 +1 @@ +New flag: :ref:`--disable-plugin-autoload ` which works as an alternative to :envvar:`PYTEST_DISABLE_PLUGIN_AUTOLOAD` when setting environment variables is inconvenient; and allows setting it in config files with :confval:`addopts`. diff --git a/doc/en/how-to/plugins.rst b/doc/en/how-to/plugins.rst index 7d5bcd85a31..fca8ab54e63 100644 --- a/doc/en/how-to/plugins.rst +++ b/doc/en/how-to/plugins.rst @@ -133,4 +133,29 @@ CI server), you can set ``PYTEST_ADDOPTS`` environment variable to See :ref:`findpluginname` for how to obtain the name of a plugin. -.. _`builtin plugins`: +.. _`disable_plugin_autoload`: + +Disabling plugins from autoloading +---------------------------------- + +If you want to disable plugins from loading automatically, instead of requiring you to +manually specify each plugin with ``-p`` or :envvar:`PYTEST_PLUGINS`, you can use ``--disable-plugin-autoload`` or :envvar:`PYTEST_DISABLE_PLUGIN_AUTOLOAD`. + +.. code-block:: bash + + export PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 + export PYTEST_PLUGINS=NAME,NAME2 + pytest + +.. code-block:: bash + + pytest --disable-plugin-autoload -p NAME,NAME2 + +.. code-block:: ini + + [pytest] + addopts = --disable-plugin-autoload -p NAME,NAME2 + +.. versionadded:: 8.4 + + The ``--disable-plugin-autoload`` command-line flag. diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index 7e328f60939..b42e69dfa23 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1181,8 +1181,9 @@ as discussed in :ref:`temporary directory location and retention`. .. envvar:: PYTEST_DISABLE_PLUGIN_AUTOLOAD When set, disables plugin auto-loading through :std:doc:`entry point packaging -metadata `. Only explicitly -specified plugins will be loaded. +metadata `. Only plugins +explicitly specified in :envvar:`PYTEST_PLUGINS` or with ``-p`` will be loaded. +See also :ref:`--disable-plugin-autoload `. .. envvar:: PYTEST_PLUGINS @@ -1192,6 +1193,8 @@ Contains comma-separated list of modules that should be loaded as plugins: export PYTEST_PLUGINS=mymodule.plugin,xdist +See also ``-p``. + .. envvar:: PYTEST_THEME Sets a `pygment style `_ to use for the code output. diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 02da5cf9229..56b04719641 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -70,6 +70,7 @@ if TYPE_CHECKING: + from _pytest.assertions.rewrite import AssertionRewritingHook from _pytest.cacheprovider import Cache from _pytest.terminal import TerminalReporter @@ -1271,6 +1272,10 @@ def _consider_importhook(self, args: Sequence[str]) -> None: """ ns, unknown_args = self._parser.parse_known_and_unknown_args(args) mode = getattr(ns, "assertmode", "plain") + + disable_autoload = getattr(ns, "disable_plugin_autoload", False) or bool( + os.environ.get("PYTEST_DISABLE_PLUGIN_AUTOLOAD") + ) if mode == "rewrite": import _pytest.assertion @@ -1279,16 +1284,18 @@ def _consider_importhook(self, args: Sequence[str]) -> None: except SystemError: mode = "plain" else: - self._mark_plugins_for_rewrite(hook) + self._mark_plugins_for_rewrite(hook, disable_autoload) self._warn_about_missing_assertion(mode) - def _mark_plugins_for_rewrite(self, hook) -> None: + def _mark_plugins_for_rewrite( + self, hook: AssertionRewritingHook, disable_autoload: bool + ) -> None: """Given an importhook, mark for rewrite any top-level modules or packages in the distribution package for all pytest plugins.""" self.pluginmanager.rewrite_hook = hook - if os.environ.get("PYTEST_DISABLE_PLUGIN_AUTOLOAD"): + if disable_autoload: # We don't autoload from distribution package entry points, # no need to continue. return @@ -1393,10 +1400,15 @@ def _preparse(self, args: list[str], addopts: bool = True) -> None: self._consider_importhook(args) self._configure_python_path() self.pluginmanager.consider_preparse(args, exclude_only=False) - if not os.environ.get("PYTEST_DISABLE_PLUGIN_AUTOLOAD"): - # Don't autoload from distribution package entry point. Only - # explicitly specified plugins are going to be loaded. + if ( + not os.environ.get("PYTEST_DISABLE_PLUGIN_AUTOLOAD") + and not self.known_args_namespace.disable_plugin_autoload + ): + # Autoloading from distribution package entry point has + # not been disabled. self.pluginmanager.load_setuptools_entrypoints("pytest11") + # Otherwise only plugins explicitly specified in PYTEST_PLUGINS + # are going to be loaded. self.pluginmanager.consider_env() self.known_args_namespace = self._parser.parse_known_args( @@ -1419,7 +1431,7 @@ def _preparse(self, args: list[str], addopts: bool = True) -> None: except ConftestImportFailure as e: if self.known_args_namespace.help or self.known_args_namespace.version: # we don't want to prevent --help/--version to work - # so just let is pass and print a warning at the end + # so just let it pass and print a warning at the end self.issue_config_time_warning( PytestConfigWarning(f"could not load initial conftests: {e.path}"), stacklevel=2, diff --git a/src/_pytest/helpconfig.py b/src/_pytest/helpconfig.py index 2b377c70f7b..b5ac0e6a50c 100644 --- a/src/_pytest/helpconfig.py +++ b/src/_pytest/helpconfig.py @@ -70,7 +70,14 @@ def pytest_addoption(parser: Parser) -> None: metavar="name", help="Early-load given plugin module name or entry point (multi-allowed). " "To avoid loading of plugins, use the `no:` prefix, e.g. " - "`no:doctest`.", + "`no:doctest`. See also --disable-plugin-autoload.", + ) + group.addoption( + "--disable-plugin-autoload", + action="store_true", + default=False, + help="Disable plugin auto-loading through entry point packaging metadata. " + "Only plugins explicitly specified in -p or env var PYTEST_PLUGINS will be loaded.", ) group.addoption( "--traceconfig", diff --git a/testing/test_assertion.py b/testing/test_assertion.py index e3d45478466..2c2830eb929 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -218,10 +218,36 @@ def test_foo(pytestconfig): assert result.ret == 0 @pytest.mark.parametrize("mode", ["plain", "rewrite"]) + @pytest.mark.parametrize("disable_plugin_autoload", ["env_var", "cli", ""]) + @pytest.mark.parametrize("explicit_specify", ["env_var", "cli", ""]) def test_installed_plugin_rewrite( - self, pytester: Pytester, mode, monkeypatch + self, + pytester: Pytester, + mode: str, + monkeypatch: pytest.MonkeyPatch, + disable_plugin_autoload: str, + explicit_specify: str, ) -> None: - monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False) + args = ["mainwrapper.py", "-s", f"--assert={mode}"] + if disable_plugin_autoload == "env_var": + monkeypatch.setenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", "1") + elif disable_plugin_autoload == "cli": + monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False) + args.append("--disable-plugin-autoload") + else: + assert disable_plugin_autoload == "" + monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False) + + name = "spamplugin" + + if explicit_specify == "env_var": + monkeypatch.setenv("PYTEST_PLUGINS", name) + elif explicit_specify == "cli": + args.append("-p") + args.append(name) + else: + assert explicit_specify == "" + # Make sure the hook is installed early enough so that plugins # installed via distribution package are rewritten. pytester.mkdir("hampkg") @@ -250,7 +276,7 @@ def check(values, value): import pytest class DummyEntryPoint(object): - name = 'spam' + name = 'spamplugin' module_name = 'spam.py' group = 'pytest11' @@ -275,20 +301,29 @@ def test(check_first): check_first([10, 30], 30) def test2(check_first2): - check_first([10, 30], 30) + check_first2([10, 30], 30) """, } pytester.makepyfile(**contents) - result = pytester.run( - sys.executable, "mainwrapper.py", "-s", f"--assert={mode}" - ) + result = pytester.run(sys.executable, *args) if mode == "plain": expected = "E AssertionError" elif mode == "rewrite": expected = "*assert 10 == 30*" else: assert 0 - result.stdout.fnmatch_lines([expected]) + + if not disable_plugin_autoload or explicit_specify: + result.assert_outcomes(failed=2) + result.stdout.fnmatch_lines([expected, expected]) + else: + result.assert_outcomes(errors=2) + result.stdout.fnmatch_lines( + [ + "E fixture 'check_first' not found", + "E fixture 'check_first2' not found", + ] + ) def test_rewrite_ast(self, pytester: Pytester) -> None: pytester.mkdir("pkg") diff --git a/testing/test_config.py b/testing/test_config.py index de07141238c..bb08c40fef4 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -6,6 +6,7 @@ import importlib.metadata import os from pathlib import Path +import platform import re import sys import textwrap @@ -1314,14 +1315,13 @@ def distributions(): ) -@pytest.mark.parametrize( - "parse_args,should_load", [(("-p", "mytestplugin"), True), ((), False)] -) +@pytest.mark.parametrize("disable_plugin_method", ["env_var", "flag", ""]) +@pytest.mark.parametrize("enable_plugin_method", ["env_var", "flag", ""]) def test_disable_plugin_autoload( pytester: Pytester, monkeypatch: MonkeyPatch, - parse_args: tuple[str, str] | tuple[()], - should_load: bool, + enable_plugin_method: str, + disable_plugin_method: str, ) -> None: class DummyEntryPoint: project_name = name = "mytestplugin" @@ -1342,23 +1342,60 @@ class PseudoPlugin: attrs_used = [] def __getattr__(self, name): - assert name == "__loader__" + assert name in ("__loader__", "__spec__") self.attrs_used.append(name) return object() def distributions(): return (Distribution(),) - monkeypatch.setenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", "1") + parse_args: list[str] = [] + + if disable_plugin_method == "env_var": + monkeypatch.setenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", "1") + elif disable_plugin_method == "flag": + monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD") + parse_args.append("--disable-plugin-autoload") + else: + assert disable_plugin_method == "" + monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD") + + if enable_plugin_method == "env_var": + monkeypatch.setenv("PYTEST_PLUGINS", "mytestplugin") + elif enable_plugin_method == "flag": + parse_args.extend(["-p", "mytestplugin"]) + else: + assert enable_plugin_method == "" + monkeypatch.setattr(importlib.metadata, "distributions", distributions) monkeypatch.setitem(sys.modules, "mytestplugin", PseudoPlugin()) config = pytester.parseconfig(*parse_args) + has_loaded = config.pluginmanager.get_plugin("mytestplugin") is not None - assert has_loaded == should_load - if should_load: - assert PseudoPlugin.attrs_used == ["__loader__"] - else: - assert PseudoPlugin.attrs_used == [] + # it should load if it's enabled, or we haven't disabled autoloading + assert has_loaded == (bool(enable_plugin_method) or not disable_plugin_method) + + # The reason for the discrepancy between 'has_loaded' and __loader__ being accessed + # appears to be the monkeypatching of importlib.metadata.distributions; where + # files being empty means that _mark_plugins_for_rewrite doesn't find the plugin. + # But enable_method==flag ends up in mark_rewrite being called and __loader__ + # being accessed. + assert ("__loader__" in PseudoPlugin.attrs_used) == ( + has_loaded + and not (enable_plugin_method in ("env_var", "") and not disable_plugin_method) + ) + + # __spec__ is accessed in AssertionRewritingHook.exec_module, which would be + # eventually called if we did a full pytest run; but it's only accessed with + # enable_plugin_method=="env_var" because that will early-load it. + # Except when autoloads aren't disabled, in which case PytestPluginManager.import_plugin + # bails out before importing it.. because it knows it'll be loaded later? + # The above seems a bit weird, but I *think* it's true. + if platform.python_implementation() != "PyPy": + assert ("__spec__" in PseudoPlugin.attrs_used) == bool( + enable_plugin_method == "env_var" and disable_plugin_method + ) + # __spec__ is present when testing locally on pypy, but not in CI ???? def test_plugin_loading_order(pytester: Pytester) -> None: From bc4abe4d4b4ee9256be020a28e1da4aef90e8105 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 2 Mar 2025 01:52:27 +0000 Subject: [PATCH 333/445] [automated] Update plugin list (#13261) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 128 ++++++++++++++++--------------- 1 file changed, 68 insertions(+), 60 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index b143608b6fd..59a73530796 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,14 +27,14 @@ please refer to `the update script =8.3 + :pypi:`databricks-labs-pytester` Python Testing for Databricks Feb 27, 2025 4 - Beta pytest>=8.3 :pypi:`logassert` Simple but powerful assertion and verification of logged lines Jan 29, 2025 5 - Production/Stable pytest; extra == "dev" :pypi:`logot` Test whether your code is logging correctly 🪵 Mar 23, 2024 5 - Production/Stable pytest<9,>=7; extra == "pytest" :pypi:`nuts` Network Unit Testing System Jul 19, 2024 N/A pytest<8,>=7 @@ -161,7 +161,7 @@ This list contains 1587 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Feb 17, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Feb 28, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -255,6 +255,7 @@ This list contains 1587 plugins. :pypi:`pytest_cleanup` Automated, comprehensive and well-organised pytest test cases. Jan 28, 2020 N/A N/A :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Nov 08, 2024 5 - Production/Stable N/A :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Jan 30, 2025 N/A pytest<9.0.0,>=8.0.0 + :pypi:`pytest-cli2-ansible` Feb 28, 2025 N/A N/A :pypi:`pytest-click` Pytest plugin for Click Feb 11, 2022 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-cli-fixtures` Automatically register fixtures for custom CLI arguments Jul 28, 2022 N/A pytest (~=7.0) :pypi:`pytest-clld` Oct 23, 2024 N/A pytest>=3.9 @@ -466,7 +467,7 @@ This list contains 1587 plugins. :pypi:`pytest-easy-server` Pytest plugin for easy testing against servers May 01, 2021 4 - Beta pytest (<5.0.0,>=4.3.1) ; python_version < "3.5" :pypi:`pytest-ebics-sandbox` A pytest plugin for testing against an EBICS sandbox server. Requires docker. Aug 15, 2022 N/A N/A :pypi:`pytest-ec2` Pytest execution on EC2 instance Oct 22, 2019 3 - Alpha N/A - :pypi:`pytest-echo` pytest plugin with mechanisms for echoing environment variables, package version and generic attributes Feb 01, 2025 5 - Production/Stable pytest>=6.0 + :pypi:`pytest-echo` pytest plugin with mechanisms for echoing environment variables, package version and generic attributes Feb 22, 2025 5 - Production/Stable pytest>=6.0 :pypi:`pytest-edit` Edit the source code of a failed test with \`pytest --edit\`. Nov 17, 2024 N/A pytest :pypi:`pytest-ekstazi` Pytest plugin to select test using Ekstazi algorithm Sep 10, 2022 N/A pytest :pypi:`pytest-elasticsearch` Elasticsearch fixtures and fixture factories for Pytest. Dec 03, 2024 5 - Production/Stable pytest>=7.0 @@ -527,7 +528,7 @@ This list contains 1587 plugins. :pypi:`pytest-exit-status` Enhance. Jan 25, 2025 N/A pytest>=8.0.0 :pypi:`pytest-expect` py.test plugin to store test expectations and mark tests based on them Apr 21, 2016 4 - Beta N/A :pypi:`pytest-expectdir` A pytest plugin to provide initial/expected directories, and check a test transforms the initial directory to the expected one Mar 19, 2023 5 - Production/Stable pytest (>=5.0) - :pypi:`pytest-expected` Record and play back your expectations Jan 14, 2025 N/A pytest + :pypi:`pytest-expected` Record and play back your expectations Feb 26, 2025 N/A pytest :pypi:`pytest-expecter` Better testing with expecter and pytest. Sep 18, 2022 5 - Production/Stable N/A :pypi:`pytest-expectr` This plugin is used to expect multiple assert using pytest framework. Oct 05, 2018 N/A pytest (>=2.4.2) :pypi:`pytest-expect-test` A fixture to support expect tests in pytest Apr 10, 2023 4 - Beta pytest (>=3.5.0) @@ -574,7 +575,7 @@ This list contains 1587 plugins. :pypi:`pytest-filter-subpackage` Pytest plugin for filtering based on sub-packages Mar 04, 2024 5 - Production/Stable pytest >=4.6 :pypi:`pytest-find-dependencies` A pytest plugin to find dependencies between tests Mar 16, 2024 4 - Beta pytest >=4.3.0 :pypi:`pytest-finer-verdicts` A pytest plugin to treat non-assertion failures as test errors. Jun 18, 2020 N/A pytest (>=5.4.3) - :pypi:`pytest-firefox` pytest plugin to manipulate firefox Aug 08, 2017 3 - Alpha pytest (>=3.0.2) + :pypi:`pytest-firefox` Feb 28, 2025 N/A N/A :pypi:`pytest-fixture-classes` Fixtures as classes that work well with dependency injection, autocompletetion, type checkers, and language servers Sep 02, 2023 5 - Production/Stable pytest :pypi:`pytest-fixturecollection` A pytest plugin to collect tests based on fixtures being used by tests Feb 22, 2024 4 - Beta pytest >=3.5.0 :pypi:`pytest-fixture-config` Fixture configuration utils for py.test Oct 17, 2024 5 - Production/Stable pytest @@ -602,12 +603,11 @@ This list contains 1587 plugins. :pypi:`pytest-flexreport` Apr 15, 2023 4 - Beta pytest :pypi:`pytest-fluent` A pytest plugin in order to provide logs via fluentd Aug 14, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-fluentbit` A pytest plugin in order to provide logs via fluentbit Jun 16, 2023 4 - Beta pytest (>=7.0.0) - :pypi:`pytest-fly` pytest observer Dec 03, 2024 3 - Alpha pytest + :pypi:`pytest-fly` pytest observer Feb 28, 2025 3 - Alpha pytest :pypi:`pytest-flyte` Pytest fixtures for simplifying Flyte integration testing May 03, 2021 N/A pytest :pypi:`pytest-focus` A pytest plugin that alerts user of failed test cases with screen notifications May 04, 2019 4 - Beta pytest :pypi:`pytest-forbid` Mar 07, 2023 N/A pytest (>=7.2.2,<8.0.0) :pypi:`pytest-forcefail` py.test plugin to make the test failing regardless of pytest.mark.xfail May 15, 2018 4 - Beta N/A - :pypi:`pytest-forks` Fork helper for pytest Mar 05, 2024 N/A N/A :pypi:`pytest-forward-compatability` A name to avoid typosquating pytest-foward-compatibility Sep 06, 2020 N/A N/A :pypi:`pytest-forward-compatibility` A pytest plugin to shim pytest commandline options for fowards compatibility Sep 29, 2020 N/A N/A :pypi:`pytest-frappe` Pytest Frappe Plugin - A set of pytest fixtures to test Frappe applications Jul 30, 2024 4 - Beta pytest>=7.0.0 @@ -619,7 +619,7 @@ This list contains 1587 plugins. :pypi:`pytest-frozen-uuids` Deterministically frozen UUID's for your tests Apr 17, 2022 N/A pytest (>=3.0) :pypi:`pytest-func-cov` Pytest plugin for measuring function coverage Apr 15, 2021 3 - Alpha pytest (>=5) :pypi:`pytest-funparam` An alternative way to parametrize test cases. Dec 02, 2021 4 - Beta pytest >=4.6.0 - :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Jan 31, 2025 N/A pytest + :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Feb 27, 2025 N/A pytest :pypi:`pytest-fxa` pytest plugin for Firefox Accounts Aug 28, 2018 5 - Production/Stable N/A :pypi:`pytest-fxa-mte` pytest plugin for Firefox Accounts Oct 02, 2024 5 - Production/Stable N/A :pypi:`pytest-fxtest` Oct 27, 2020 N/A N/A @@ -678,7 +678,7 @@ This list contains 1587 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Feb 22, 2025 3 - Alpha pytest==8.3.4 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Mar 01, 2025 3 - Alpha pytest==8.3.4 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -701,7 +701,7 @@ This list contains 1587 plugins. :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace. Feb 11, 2025 4 - Beta pytest>=7.0.0 :pypi:`pytest-http-mocker` Pytest plugin for http mocking (via https://github.com/vilus/mocker) Oct 20, 2019 N/A N/A :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A - :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Jan 21, 2025 3 - Alpha N/A + :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Feb 24, 2025 3 - Alpha N/A :pypi:`pytest-httptesting` http_testing framework on top of pytest Dec 19, 2024 N/A pytest>=8.2.0 :pypi:`pytest-httpx` Send responses to httpx. Nov 28, 2024 5 - Production/Stable pytest==8.* :pypi:`pytest-httpx-blockage` Disable httpx requests during a test run Feb 16, 2023 N/A pytest (>=7.2.1) @@ -755,7 +755,7 @@ This list contains 1587 plugins. :pypi:`pytest-ipynb2` Pytest plugin to run tests in Jupyter Notebooks Feb 19, 2025 N/A pytest :pypi:`pytest-ipywidgets` Feb 18, 2025 N/A pytest :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Jan 16, 2025 4 - Beta pytest - :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Dec 05, 2024 4 - Beta pytest>=5 + :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Feb 24, 2025 4 - Beta pytest>=5 :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-it` Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it. Jan 29, 2024 4 - Beta N/A :pypi:`pytest-item-dict` Get a hierarchical dict of session.items Nov 14, 2024 4 - Beta pytest>=8.3.0 @@ -805,6 +805,7 @@ This list contains 1587 plugins. :pypi:`pytest-lamp` Jan 06, 2017 3 - Alpha N/A :pypi:`pytest-langchain` Pytest-style test runner for langchain agents Feb 26, 2023 N/A pytest :pypi:`pytest-lark` Create fancy and clear HTML test reports. Nov 05, 2023 N/A N/A + :pypi:`pytest-latin-hypercube` Implementation of Latin Hypercube Sampling for pytest. Feb 27, 2025 N/A pytest :pypi:`pytest-launchable` Launchable Pytest Plugin Apr 05, 2023 N/A pytest (>=4.2.0) :pypi:`pytest-layab` Pytest fixtures for layab. Oct 05, 2020 5 - Production/Stable N/A :pypi:`pytest-lazy-fixture` It helps to use fixtures in pytest.mark.parametrize Feb 01, 2020 4 - Beta pytest (>=3.2.5) @@ -841,7 +842,7 @@ This list contains 1587 plugins. :pypi:`pytest-logging` Configures logging and allows tweaking the log level with a py.test flag Nov 04, 2015 4 - Beta N/A :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) :pypi:`pytest-logging-strict` pytest fixture logging configured from packaged YAML Jan 19, 2025 3 - Alpha pytest - :pypi:`pytest-logikal` Common testing environment Jan 31, 2025 5 - Production/Stable pytest==8.3.4 + :pypi:`pytest-logikal` Common testing environment Mar 02, 2025 5 - Production/Stable pytest==8.3.4 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Sep 30, 2024 4 - Beta pytest>=8.2.2 :pypi:`pytest-loguru` Pytest Loguru Mar 20, 2024 5 - Production/Stable pytest; extra == "test" @@ -908,7 +909,7 @@ This list contains 1587 plugins. :pypi:`pytest-modifyjunit` Utility for adding additional properties to junit xml for IDM QE Jan 10, 2019 N/A N/A :pypi:`pytest-molecule` PyTest Molecule Plugin :: discover and run molecule tests Mar 29, 2022 5 - Production/Stable pytest (>=7.0.0) :pypi:`pytest-molecule-JC` PyTest Molecule Plugin :: discover and run molecule tests Jul 18, 2023 5 - Production/Stable pytest (>=7.0.0) - :pypi:`pytest-mongo` MongoDB process and client fixtures plugin for Pytest. Mar 13, 2024 5 - Production/Stable pytest >=6.2 + :pypi:`pytest-mongo` MongoDB process and client fixtures plugin for Pytest. Feb 28, 2025 5 - Production/Stable pytest>=6.2 :pypi:`pytest-mongodb` pytest plugin for MongoDB fixtures May 16, 2023 5 - Production/Stable N/A :pypi:`pytest-mongodb-nono` pytest plugin for MongoDB Jan 07, 2025 N/A N/A :pypi:`pytest-mongodb-ry` pytest plugin for MongoDB Jan 21, 2025 N/A N/A @@ -958,7 +959,7 @@ This list contains 1587 plugins. :pypi:`pytest-nocustom` Run all tests without custom markers Aug 05, 2024 5 - Production/Stable N/A :pypi:`pytest-node-dependency` pytest plugin for controlling execution flow Apr 10, 2024 5 - Production/Stable N/A :pypi:`pytest-nodev` Test-driven source code search for Python. Jul 21, 2016 4 - Beta pytest (>=2.8.1) - :pypi:`pytest-nogarbage` Ensure a test produces no garbage Aug 29, 2021 5 - Production/Stable pytest (>=4.6.0) + :pypi:`pytest-nogarbage` Ensure a test produces no garbage Feb 24, 2025 5 - Production/Stable pytest>=4.6.0 :pypi:`pytest-nose-attrib` pytest plugin to use nose @attrib marks decorators and pick tests based on attributes and partially uses nose-attrib plugin approach Aug 13, 2023 N/A N/A :pypi:`pytest_notebook` A pytest plugin for testing Jupyter Notebooks. Nov 28, 2023 4 - Beta pytest>=3.5.0 :pypi:`pytest-notice` Send pytest execution result email Nov 05, 2020 N/A N/A @@ -1076,14 +1077,14 @@ This list contains 1587 plugins. :pypi:`pytest-porcochu` Show surprise when tests are passing Nov 28, 2024 5 - Production/Stable N/A :pypi:`pytest-portion` Select a portion of the collected tests Jan 28, 2021 4 - Beta pytest (>=3.5.0) :pypi:`pytest-postgres` Run PostgreSQL in Docker container in Pytest. Mar 22, 2020 N/A pytest - :pypi:`pytest-postgresql` Postgresql fixtures and fixture factories for Pytest. Sep 05, 2024 5 - Production/Stable pytest>=6.2 + :pypi:`pytest-postgresql` Postgresql fixtures and fixture factories for Pytest. Feb 23, 2025 5 - Production/Stable pytest>=6.2 :pypi:`pytest-power` pytest plugin with powerful fixtures Dec 31, 2020 N/A pytest (>=5.4) :pypi:`pytest-powerpack` A plugin containing extra batteries for pytest Jan 04, 2025 N/A pytest<9.0.0,>=8.1.1 :pypi:`pytest-prefer-nested-dup-tests` A Pytest plugin to drop duplicated tests during collection, but will prefer keeping nested packages. Apr 27, 2022 4 - Beta pytest (>=7.1.1,<8.0.0) :pypi:`pytest-pretty` pytest plugin for printing summary data as I want it Apr 05, 2023 5 - Production/Stable pytest>=7 :pypi:`pytest-pretty-terminal` pytest plugin for generating prettier terminal output Jan 31, 2022 N/A pytest (>=3.4.1) :pypi:`pytest-pride` Minitest-style test colors Apr 02, 2016 3 - Alpha N/A - :pypi:`pytest-print` pytest-print adds the printer fixture you can use to print messages to the user (directly to the pytest runner, not stdout) Sep 17, 2024 5 - Production/Stable pytest>=8.3.2 + :pypi:`pytest-print` pytest-print adds the printer fixture you can use to print messages to the user (directly to the pytest runner, not stdout) Feb 25, 2025 5 - Production/Stable pytest>=8.3.2 :pypi:`pytest-priority` pytest plugin for add priority for tests Aug 19, 2024 N/A pytest :pypi:`pytest-proceed` Oct 01, 2024 N/A pytest :pypi:`pytest-profiles` pytest plugin for configuration profiles Dec 09, 2021 4 - Beta pytest (>=3.7.0) @@ -1192,7 +1193,7 @@ This list contains 1587 plugins. :pypi:`pytest-reportlog` Replacement for the --resultlog option, focused in simplicity and extensibility May 22, 2023 3 - Alpha pytest :pypi:`pytest-report-me` A pytest plugin to generate report. Dec 31, 2020 N/A pytest :pypi:`pytest-report-parameters` pytest plugin for adding tests' parameters to junit report Jun 18, 2020 3 - Alpha pytest (>=2.4.2) - :pypi:`pytest-reportportal` Agent for Reporting results of tests to the Report Portal Dec 04, 2024 N/A pytest>=3.8.0 + :pypi:`pytest-reportportal` Agent for Reporting results of tests to the Report Portal Feb 28, 2025 N/A pytest>=4.6.10 :pypi:`pytest-report-stream` A pytest plugin which allows to stream test reports at runtime Oct 22, 2023 4 - Beta N/A :pypi:`pytest-repo-structure` Pytest Repo Structure Mar 18, 2024 1 - Planning N/A :pypi:`pytest-req` pytest requests plugin Aug 31, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.2 @@ -1200,7 +1201,7 @@ This list contains 1587 plugins. :pypi:`pytest-requests` A simple plugin to use with pytest Jun 24, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-requestselapsed` collect and show http requests elapsed time Aug 14, 2022 N/A N/A :pypi:`pytest-requests-futures` Pytest Plugin to Mock Requests Futures Jul 06, 2022 5 - Production/Stable pytest - :pypi:`pytest-requirements` pytest plugin for using custom markers to relate tests to requirements and usecases Nov 29, 2024 N/A pytest + :pypi:`pytest-requirements` pytest plugin for using custom markers to relate tests to requirements and usecases Feb 28, 2025 N/A pytest :pypi:`pytest-requires` A pytest plugin to elegantly skip tests with optional requirements Dec 21, 2021 4 - Beta pytest (>=3.5.0) :pypi:`pytest-reraise` Make multi-threaded pytest test cases fail when they should Sep 20, 2022 5 - Production/Stable pytest (>=4.6) :pypi:`pytest-rerun` Re-run only changed files in specified branch Jul 08, 2019 N/A pytest (>=3.6) @@ -1209,7 +1210,7 @@ This list contains 1587 plugins. :pypi:`pytest-rerunfailures` pytest plugin to re-run tests to eliminate flaky failures Nov 20, 2024 5 - Production/Stable pytest!=8.2.2,>=7.4 :pypi:`pytest-rerunfailures-all-logs` pytest plugin to re-run tests to eliminate flaky failures Mar 07, 2022 5 - Production/Stable N/A :pypi:`pytest-reserial` Pytest fixture for recording and replaying serial port traffic. Dec 22, 2024 4 - Beta pytest - :pypi:`pytest-resilient-circuits` Resilient Circuits fixtures for PyTest Dec 16, 2024 N/A pytest~=7.0 + :pypi:`pytest-resilient-circuits` Resilient Circuits fixtures for PyTest Feb 28, 2025 N/A pytest~=7.0 :pypi:`pytest-resource` Load resource fixture plugin to use with pytest Nov 14, 2018 4 - Beta N/A :pypi:`pytest-resource-path` Provides path for uniform access to test resources in isolated directory May 01, 2021 5 - Production/Stable pytest (>=3.5.0) :pypi:`pytest-resource-usage` Pytest plugin for reporting running time and peak memory usage Nov 06, 2022 5 - Production/Stable pytest>=7.0.0 @@ -1225,7 +1226,7 @@ This list contains 1587 plugins. :pypi:`pytest-retry` Adds the ability to retry flaky tests in CI environments Jan 19, 2025 N/A pytest>=7.0.0 :pypi:`pytest-retry-class` A pytest plugin to rerun entire class on failure Nov 24, 2024 N/A pytest>=5.3 :pypi:`pytest-reusable-testcases` Apr 28, 2023 N/A N/A - :pypi:`pytest-revealtype-injector` Pytest plugin for replacing reveal_type() calls inside test functions with static and runtime type checking result comparison, for confirming type annotation validity. Dec 19, 2024 4 - Beta pytest>=7.0 + :pypi:`pytest-revealtype-injector` Pytest plugin for replacing reveal_type() calls inside test functions with static and runtime type checking result comparison, for confirming type annotation validity. Feb 27, 2025 4 - Beta pytest<9,>=7.0 :pypi:`pytest-reverse` Pytest plugin to reverse test order. Oct 25, 2024 5 - Production/Stable pytest :pypi:`pytest-rich` Leverage rich for richer test session output Dec 12, 2024 4 - Beta pytest>=7.0 :pypi:`pytest-richer` Pytest plugin providing a Rich based reporter. Oct 27, 2023 3 - Alpha pytest @@ -1261,7 +1262,7 @@ This list contains 1587 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Feb 20, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Feb 26, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1273,12 +1274,12 @@ This list contains 1587 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Feb 20, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Feb 26, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 :pypi:`pytest-send-email` Send pytest execution result email Sep 02, 2024 N/A pytest - :pypi:`pytest-sentry` A pytest plugin to send testrun information to Sentry.io Nov 25, 2024 N/A pytest + :pypi:`pytest-sentry` A pytest plugin to send testrun information to Sentry.io Feb 24, 2025 N/A pytest :pypi:`pytest-sequence-markers` Pytest plugin for sequencing markers for execution of tests May 23, 2023 5 - Production/Stable N/A :pypi:`pytest-server` test server exec cmd Sep 09, 2024 N/A N/A :pypi:`pytest-server-fixtures` Extensible server fixtures for py.test Nov 29, 2024 5 - Production/Stable pytest @@ -1627,7 +1628,7 @@ This list contains 1587 plugins. :pypi:`databricks-labs-pytester` - *last release*: Feb 03, 2025, + *last release*: Feb 27, 2025, *status*: 4 - Beta, *requires*: pytest>=8.3 @@ -2516,7 +2517,7 @@ This list contains 1587 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Feb 17, 2025, + *last release*: Feb 28, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -3173,6 +3174,13 @@ This list contains 1587 plugins. A set of pytest fixtures to help with integration testing with Clerk. + :pypi:`pytest-cli2-ansible` + *last release*: Feb 28, 2025, + *status*: N/A, + *requires*: N/A + + + :pypi:`pytest-click` *last release*: Feb 11, 2022, *status*: 5 - Production/Stable, @@ -4651,7 +4659,7 @@ This list contains 1587 plugins. Pytest execution on EC2 instance :pypi:`pytest-echo` - *last release*: Feb 01, 2025, + *last release*: Feb 22, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=6.0 @@ -5078,7 +5086,7 @@ This list contains 1587 plugins. A pytest plugin to provide initial/expected directories, and check a test transforms the initial directory to the expected one :pypi:`pytest-expected` - *last release*: Jan 14, 2025, + *last release*: Feb 26, 2025, *status*: N/A, *requires*: pytest @@ -5407,11 +5415,11 @@ This list contains 1587 plugins. A pytest plugin to treat non-assertion failures as test errors. :pypi:`pytest-firefox` - *last release*: Aug 08, 2017, - *status*: 3 - Alpha, - *requires*: pytest (>=3.0.2) + *last release*: Feb 28, 2025, + *status*: N/A, + *requires*: N/A + - pytest plugin to manipulate firefox :pypi:`pytest-fixture-classes` *last release*: Sep 02, 2023, @@ -5603,7 +5611,7 @@ This list contains 1587 plugins. A pytest plugin in order to provide logs via fluentbit :pypi:`pytest-fly` - *last release*: Dec 03, 2024, + *last release*: Feb 28, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -5637,13 +5645,6 @@ This list contains 1587 plugins. py.test plugin to make the test failing regardless of pytest.mark.xfail - :pypi:`pytest-forks` - *last release*: Mar 05, 2024, - *status*: N/A, - *requires*: N/A - - Fork helper for pytest - :pypi:`pytest-forward-compatability` *last release*: Sep 06, 2020, *status*: N/A, @@ -5722,7 +5723,7 @@ This list contains 1587 plugins. An alternative way to parametrize test cases. :pypi:`pytest-fv` - *last release*: Jan 31, 2025, + *last release*: Feb 27, 2025, *status*: N/A, *requires*: pytest @@ -6135,7 +6136,7 @@ This list contains 1587 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Feb 22, 2025, + *last release*: Mar 01, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.4 @@ -6296,7 +6297,7 @@ This list contains 1587 plugins. A thin wrapper of HTTPretty for pytest :pypi:`pytest_httpserver` - *last release*: Jan 21, 2025, + *last release*: Feb 24, 2025, *status*: 3 - Alpha, *requires*: N/A @@ -6674,7 +6675,7 @@ This list contains 1587 plugins. Run pytest tests in isolated subprocesses :pypi:`pytest-isolate-mpi` - *last release*: Dec 05, 2024, + *last release*: Feb 24, 2025, *status*: 4 - Beta, *requires*: pytest>=5 @@ -7023,6 +7024,13 @@ This list contains 1587 plugins. Create fancy and clear HTML test reports. + :pypi:`pytest-latin-hypercube` + *last release*: Feb 27, 2025, + *status*: N/A, + *requires*: pytest + + Implementation of Latin Hypercube Sampling for pytest. + :pypi:`pytest-launchable` *last release*: Apr 05, 2023, *status*: N/A, @@ -7276,7 +7284,7 @@ This list contains 1587 plugins. pytest fixture logging configured from packaged YAML :pypi:`pytest-logikal` - *last release*: Jan 31, 2025, + *last release*: Mar 02, 2025, *status*: 5 - Production/Stable, *requires*: pytest==8.3.4 @@ -7745,9 +7753,9 @@ This list contains 1587 plugins. PyTest Molecule Plugin :: discover and run molecule tests :pypi:`pytest-mongo` - *last release*: Mar 13, 2024, + *last release*: Feb 28, 2025, *status*: 5 - Production/Stable, - *requires*: pytest >=6.2 + *requires*: pytest>=6.2 MongoDB process and client fixtures plugin for Pytest. @@ -8095,9 +8103,9 @@ This list contains 1587 plugins. Test-driven source code search for Python. :pypi:`pytest-nogarbage` - *last release*: Aug 29, 2021, + *last release*: Feb 24, 2025, *status*: 5 - Production/Stable, - *requires*: pytest (>=4.6.0) + *requires*: pytest>=4.6.0 Ensure a test produces no garbage @@ -8921,7 +8929,7 @@ This list contains 1587 plugins. Run PostgreSQL in Docker container in Pytest. :pypi:`pytest-postgresql` - *last release*: Sep 05, 2024, + *last release*: Feb 23, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=6.2 @@ -8970,7 +8978,7 @@ This list contains 1587 plugins. Minitest-style test colors :pypi:`pytest-print` - *last release*: Sep 17, 2024, + *last release*: Feb 25, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=8.3.2 @@ -9733,9 +9741,9 @@ This list contains 1587 plugins. pytest plugin for adding tests' parameters to junit report :pypi:`pytest-reportportal` - *last release*: Dec 04, 2024, + *last release*: Feb 28, 2025, *status*: N/A, - *requires*: pytest>=3.8.0 + *requires*: pytest>=4.6.10 Agent for Reporting results of tests to the Report Portal @@ -9789,7 +9797,7 @@ This list contains 1587 plugins. Pytest Plugin to Mock Requests Futures :pypi:`pytest-requirements` - *last release*: Nov 29, 2024, + *last release*: Feb 28, 2025, *status*: N/A, *requires*: pytest @@ -9852,7 +9860,7 @@ This list contains 1587 plugins. Pytest fixture for recording and replaying serial port traffic. :pypi:`pytest-resilient-circuits` - *last release*: Dec 16, 2024, + *last release*: Feb 28, 2025, *status*: N/A, *requires*: pytest~=7.0 @@ -9964,9 +9972,9 @@ This list contains 1587 plugins. :pypi:`pytest-revealtype-injector` - *last release*: Dec 19, 2024, + *last release*: Feb 27, 2025, *status*: 4 - Beta, - *requires*: pytest>=7.0 + *requires*: pytest<9,>=7.0 Pytest plugin for replacing reveal_type() calls inside test functions with static and runtime type checking result comparison, for confirming type annotation validity. @@ -10216,7 +10224,7 @@ This list contains 1587 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Feb 20, 2025, + *last release*: Feb 26, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10300,7 +10308,7 @@ This list contains 1587 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Feb 20, 2025, + *last release*: Feb 26, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10335,7 +10343,7 @@ This list contains 1587 plugins. Send pytest execution result email :pypi:`pytest-sentry` - *last release*: Nov 25, 2024, + *last release*: Feb 24, 2025, *status*: N/A, *requires*: pytest From 79f0733f094ff336d839b2088b7f1bfd011b5f3f Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 2 Mar 2025 09:02:44 -0300 Subject: [PATCH 334/445] Fix prepare-release-pr script The script is [currently failing with](https://github.com/pytest-dev/pytest/actions/runs/13615071695/job/38057071681): ``` remote: Support for password authentication was removed on August 13, 2021. remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication. fatal: Authentication failed for 'https://github.com/pytest-dev/pytest.git/' ``` Decided to remove the usage of `github3` and use the `gh` command-line tool directly, which simplifies the script, integrates nicely with GH, and enables to run it locally seamlessly. --- .github/workflows/prepare-release-pr.yml | 9 ++++-- scripts/prepare-release-pr.py | 39 +++++++++--------------- tox.ini | 5 +-- 3 files changed, 21 insertions(+), 32 deletions(-) diff --git a/.github/workflows/prepare-release-pr.yml b/.github/workflows/prepare-release-pr.yml index b803ba8517b..b21ca70cb46 100644 --- a/.github/workflows/prepare-release-pr.yml +++ b/.github/workflows/prepare-release-pr.yml @@ -30,7 +30,8 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - persist-credentials: false + # persist-credentials is needed in order for us to push the release branch. + persist-credentials: true - name: Set up Python uses: actions/setup-python@v5 @@ -47,13 +48,15 @@ jobs: env: BRANCH: ${{ github.event.inputs.branch }} PRERELEASE: ${{ github.event.inputs.prerelease }} + GH_TOKEN: ${{ github.token }} run: | - tox -e prepare-release-pr -- "$BRANCH" ${{ github.token }} --prerelease="$PRERELEASE" + tox -e prepare-release-pr -- "$BRANCH" --prerelease="$PRERELEASE" - name: Prepare release PR (major release) if: github.event.inputs.major == 'yes' env: BRANCH: ${{ github.event.inputs.branch }} PRERELEASE: ${{ github.event.inputs.prerelease }} + GH_TOKEN: ${{ github.token }} run: | - tox -e prepare-release-pr -- "$BRANCH" ${{ github.token }} --major --prerelease="$PRERELEASE" + tox -e prepare-release-pr -- "$BRANCH" --major --prerelease="$PRERELEASE" diff --git a/scripts/prepare-release-pr.py b/scripts/prepare-release-pr.py index 49f8f8c431d..c420a80b3d2 100644 --- a/scripts/prepare-release-pr.py +++ b/scripts/prepare-release-pr.py @@ -10,8 +10,7 @@ After that, it will create a release using the `release` tox environment, and push a new PR. -**Token**: currently the token from the GitHub Actions is used, pushed with -`pytest bot ` commit author. +Note: the script uses the `gh` command-line tool, so `GH_TOKEN` must be set in the environment. """ from __future__ import annotations @@ -25,7 +24,6 @@ from colorama import Fore from colorama import init -from github3.repos import Repository class InvalidFeatureRelease(Exception): @@ -54,17 +52,7 @@ class InvalidFeatureRelease(Exception): """ -def login(token: str) -> Repository: - import github3 - - github = github3.login(token=token) - owner, repo = SLUG.split("/") - return github.repository(owner, repo) - - -def prepare_release_pr( - base_branch: str, is_major: bool, token: str, prerelease: str -) -> None: +def prepare_release_pr(base_branch: str, is_major: bool, prerelease: str) -> None: print() print(f"Processing release for branch {Fore.CYAN}{base_branch}") @@ -131,22 +119,25 @@ def prepare_release_pr( check=True, ) - oauth_url = f"https://{token}:x-oauth-basic@github.com/{SLUG}.git" run( - ["git", "push", oauth_url, f"HEAD:{release_branch}", "--force"], + ["git", "push", "origin", f"HEAD:{release_branch}", "--force"], check=True, ) print(f"Branch {Fore.CYAN}{release_branch}{Fore.RESET} pushed.") body = PR_BODY.format(version=version) - repo = login(token) - pr = repo.create_pull( - f"Prepare release {version}", - base=base_branch, - head=release_branch, - body=body, + run( + [ + "gh", + "pr", + "new", + f"--base={base_branch}", + f"--head={release_branch}", + f"--title=Release {version}", + f"--body={body}", + ], + check=True, ) - print(f"Pull request {Fore.CYAN}{pr.url}{Fore.RESET} created.") def find_next_version( @@ -174,14 +165,12 @@ def main() -> None: init(autoreset=True) parser = argparse.ArgumentParser() parser.add_argument("base_branch") - parser.add_argument("token") parser.add_argument("--major", action="store_true", default=False) parser.add_argument("--prerelease", default="") options = parser.parse_args() prepare_release_pr( base_branch=options.base_branch, is_major=options.major, - token=options.token, prerelease=options.prerelease, ) diff --git a/tox.ini b/tox.ini index 97a74dde937..850def411cb 100644 --- a/tox.ini +++ b/tox.ini @@ -188,11 +188,8 @@ usedevelop = True passenv = * deps = colorama - github3.py pre-commit>=2.9.3 - wheel - # https://github.com/twisted/towncrier/issues/340 - towncrier<21.3.0 + towncrier commands = python scripts/release.py {posargs} [testenv:prepare-release-pr] From 55db9236e0eb44be7d8a141a5ff8e72ec0920351 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 2 Mar 2025 09:53:56 -0300 Subject: [PATCH 335/445] Add deploy command-line to RELEASING.rst --- RELEASING.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASING.rst b/RELEASING.rst index 7ef907f2296..0ca63ee4fbf 100644 --- a/RELEASING.rst +++ b/RELEASING.rst @@ -137,6 +137,10 @@ Both automatic and manual processes described above follow the same steps from t in https://github.com/pytest-dev/pytest/actions/workflows/deploy.yml, using the ``release-MAJOR.MINOR.PATCH`` branch as source. + Using the command-line:: + + $ gh workflow run deploy.yml -R pytest-dev/pytest --ref=release-{VERSION} -f version={VERSION} + This job will require approval from ``pytest-dev/core``, after which it will publish to PyPI and tag the repository. From 87018dbfebe1aeaa03327509ea4b1d45d7f07d65 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 1 Dec 2024 10:03:14 -0300 Subject: [PATCH 336/445] Merge pull request #13018 from pytest-dev/release-8.3.4 Prepare release 8.3.4 (cherry picked from commit 4707416fa1607f0a48debc1aabbfd4917c7529e5) --- changelog/10558.doc.rst | 1 - changelog/10829.doc.rst | 1 - changelog/12497.contrib.rst | 1 - changelog/12592.bugfix.rst | 1 - changelog/12818.bugfix.rst | 1 - changelog/12849.bugfix.rst | 1 - changelog/12866.doc.rst | 1 - changelog/12966.doc.rst | 1 - changelog/9353.bugfix.rst | 1 - doc/en/announce/index.rst | 1 + doc/en/announce/release-8.3.4.rst | 30 +++++++++++++++++++++ doc/en/builtin.rst | 36 +++++++++---------------- doc/en/changelog.rst | 41 +++++++++++++++++++++++++++++ doc/en/example/parametrize.rst | 6 ++--- doc/en/example/pythoncollection.rst | 4 +-- doc/en/getting-started.rst | 2 +- doc/en/how-to/fixtures.rst | 2 +- 17 files changed, 91 insertions(+), 40 deletions(-) delete mode 100644 changelog/10558.doc.rst delete mode 100644 changelog/10829.doc.rst delete mode 100644 changelog/12497.contrib.rst delete mode 100644 changelog/12592.bugfix.rst delete mode 100644 changelog/12818.bugfix.rst delete mode 100644 changelog/12849.bugfix.rst delete mode 100644 changelog/12866.doc.rst delete mode 100644 changelog/12966.doc.rst delete mode 100644 changelog/9353.bugfix.rst create mode 100644 doc/en/announce/release-8.3.4.rst diff --git a/changelog/10558.doc.rst b/changelog/10558.doc.rst deleted file mode 100644 index 1c242b9cf71..00000000000 --- a/changelog/10558.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Fix ambiguous docstring of :func:`pytest.Config.getoption`. diff --git a/changelog/10829.doc.rst b/changelog/10829.doc.rst deleted file mode 100644 index 1be45c7049d..00000000000 --- a/changelog/10829.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Improve documentation on the current handling of the ``--basetemp`` option and its lack of retention functionality (:ref:`temporary directory location and retention`). diff --git a/changelog/12497.contrib.rst b/changelog/12497.contrib.rst deleted file mode 100644 index ccf89731053..00000000000 --- a/changelog/12497.contrib.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed two failing pdb-related tests on Python 3.13. diff --git a/changelog/12592.bugfix.rst b/changelog/12592.bugfix.rst deleted file mode 100644 index 605783bcab4..00000000000 --- a/changelog/12592.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed :class:`KeyError` crash when using ``--import-mode=importlib`` in a directory layout where a directory contains a child directory with the same name. diff --git a/changelog/12818.bugfix.rst b/changelog/12818.bugfix.rst deleted file mode 100644 index 9d74f2fda2a..00000000000 --- a/changelog/12818.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Assertion rewriting now preserves the source ranges of the original instructions, making it play well with tools that deal with the ``AST``, like `executing `__. diff --git a/changelog/12849.bugfix.rst b/changelog/12849.bugfix.rst deleted file mode 100644 index fb72263aadd..00000000000 --- a/changelog/12849.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -ANSI escape codes for colored output now handled correctly in :func:`pytest.fail` with `pytrace=False`. diff --git a/changelog/12866.doc.rst b/changelog/12866.doc.rst deleted file mode 100644 index 865b2bbc600..00000000000 --- a/changelog/12866.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Improved cross-references concerning the :fixture:`recwarn` fixture. diff --git a/changelog/12966.doc.rst b/changelog/12966.doc.rst deleted file mode 100644 index 8a440c2ec0f..00000000000 --- a/changelog/12966.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Clarify :ref:`filterwarnings` docs on filter precedence/order when using multiple :ref:`@pytest.mark.filterwarnings ` marks. diff --git a/changelog/9353.bugfix.rst b/changelog/9353.bugfix.rst deleted file mode 100644 index 414f5a007b6..00000000000 --- a/changelog/9353.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -:func:`pytest.approx` now uses strict equality when given booleans. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index 61e4a772beb..8a38df7a2e1 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-8.3.4 release-8.3.3 release-8.3.2 release-8.3.1 diff --git a/doc/en/announce/release-8.3.4.rst b/doc/en/announce/release-8.3.4.rst new file mode 100644 index 00000000000..f76d60396dc --- /dev/null +++ b/doc/en/announce/release-8.3.4.rst @@ -0,0 +1,30 @@ +pytest-8.3.4 +======================================= + +pytest 8.3.4 has just been released to PyPI. + +This is a bug-fix release, being a drop-in replacement. To upgrade:: + + pip install --upgrade pytest + +The full changelog is available at https://docs.pytest.org/en/stable/changelog.html. + +Thanks to all of the contributors to this release: + +* Bruno Oliveira +* Florian Bruhin +* Frank Hoffmann +* Jakob van Santen +* Leonardus Chen +* Pierre Sassoulas +* Pradeep Kumar +* Ran Benita +* Serge Smertin +* Stefaan Lippens +* Sviatoslav Sydorenko (Святослав Сидоренко) +* dongfangtianyu +* suspe + + +Happy testing, +The pytest Development Team diff --git a/doc/en/builtin.rst b/doc/en/builtin.rst index 822ee48b3fb..85d280da50f 100644 --- a/doc/en/builtin.rst +++ b/doc/en/builtin.rst @@ -178,16 +178,11 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a Return a :class:`pytest.TempdirFactory` instance for the test session. tmpdir -- .../_pytest/legacypath.py:305 - Return a temporary directory path object which is unique to each test - function invocation, created as a sub directory of the base temporary - directory. - - 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:`temporary directory location and retention`. - - The returned object is a `legacy_path`_ object. + Return a temporary directory (as `legacy_path`_ object) + which is unique to each test function invocation. + The temporary directory is created as a subdirectory + of the base temporary directory, with configurable retention, + as discussed in :ref:`temporary directory location and retention`. .. note:: These days, it is preferred to use ``tmp_path``. @@ -236,22 +231,15 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a See :ref:`warnings` for information on warning categories. - tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:242 + tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:241 Return a :class:`pytest.TempPathFactory` instance for the test session. - tmp_path -- .../_pytest/tmpdir.py:257 - Return a temporary directory path object which is unique to each test - function invocation, created as a sub directory of the base temporary - directory. - - By default, a new base temporary directory is created each test session, - 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:`temporary directory location and retention`. - - The returned object is a :class:`pathlib.Path` object. + tmp_path -- .../_pytest/tmpdir.py:256 + Return a temporary directory (as :class:`pathlib.Path` object) + which is unique to each test function invocation. + The temporary directory is created as a subdirectory + of the base temporary directory, with configurable retention, + as discussed in :ref:`temporary directory location and retention`. ========================== no tests ran in 0.12s =========================== diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index 0a32f88c6ff..58128763a49 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -31,6 +31,47 @@ with advance notice in the **Deprecations** section of releases. .. towncrier release notes start +pytest 8.3.4 (2024-12-01) +========================= + +Bug fixes +--------- + +- `#12592 `_: Fixed :class:`KeyError` crash when using ``--import-mode=importlib`` in a directory layout where a directory contains a child directory with the same name. + + +- `#12818 `_: Assertion rewriting now preserves the source ranges of the original instructions, making it play well with tools that deal with the ``AST``, like `executing `__. + + +- `#12849 `_: ANSI escape codes for colored output now handled correctly in :func:`pytest.fail` with `pytrace=False`. + + +- `#9353 `_: :func:`pytest.approx` now uses strict equality when given booleans. + + + +Improved documentation +---------------------- + +- `#10558 `_: Fix ambiguous docstring of :func:`pytest.Config.getoption`. + + +- `#10829 `_: Improve documentation on the current handling of the ``--basetemp`` option and its lack of retention functionality (:ref:`temporary directory location and retention`). + + +- `#12866 `_: Improved cross-references concerning the :fixture:`recwarn` fixture. + + +- `#12966 `_: Clarify :ref:`filterwarnings` docs on filter precedence/order when using multiple :ref:`@pytest.mark.filterwarnings ` marks. + + + +Contributor-facing changes +-------------------------- + +- `#12497 `_: Fixed two failing pdb-related tests on Python 3.13. + + pytest 8.3.3 (2024-09-09) ========================= diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index fa43308d045..f1f7deb909c 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -162,7 +162,7 @@ objects, they are still using the default pytest representation: rootdir: /home/sweet/project collected 8 items - + @@ -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 - + @@ -318,7 +318,7 @@ Let's first see how it looks like at collection time: rootdir: /home/sweet/project collected 2 items - + diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 42a603f114c..1d1ce07c10a 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -152,7 +152,7 @@ The test collection would look like this: configfile: pytest.ini collected 2 items - + @@ -215,7 +215,7 @@ You can always peek at the collection tree without running tests like this: configfile: pytest.ini collected 3 items - + diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index faf81154c48..d4308e5aab3 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -22,7 +22,7 @@ Install ``pytest`` .. code-block:: bash $ pytest --version - pytest 8.3.3 + pytest 8.3.4 .. _`simpletest`: diff --git a/doc/en/how-to/fixtures.rst b/doc/en/how-to/fixtures.rst index 4f6e8cbee06..9232c9e8449 100644 --- a/doc/en/how-to/fixtures.rst +++ b/doc/en/how-to/fixtures.rst @@ -1418,7 +1418,7 @@ Running the above tests results in the following test IDs being used: rootdir: /home/sweet/project collected 12 items - + From 4603564f6437b544b7d34fec012e69016ce452f0 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 2 Mar 2025 09:55:51 -0300 Subject: [PATCH 337/445] Merge pull request #13264 from pytest-dev/release-8.3.5 Release 8.3.5 (cherry picked from commit f004b11caf49fa6fbacc8648bbc9c650a2e08bec) --- changelog/11777.bugfix.rst | 1 - changelog/12842.doc.rst | 3 --- changelog/12888.bugfix.rst | 1 - changelog/13026.bugfix.rst | 1 - changelog/13053.bugfix.rst | 1 - changelog/13083.bugfix.rst | 1 - changelog/13112.contrib.rst | 1 - changelog/13256.contrib.rst | 2 -- doc/en/announce/index.rst | 1 + doc/en/announce/release-8.3.5.rst | 26 ++++++++++++++++++ doc/en/builtin.rst | 8 +++--- doc/en/changelog.rst | 41 +++++++++++++++++++++++++++++ doc/en/example/parametrize.rst | 15 ++++++----- doc/en/example/pythoncollection.rst | 4 +-- doc/en/example/reportingdemo.rst | 18 ++++++------- doc/en/example/simple.rst | 2 +- doc/en/getting-started.rst | 2 +- doc/en/how-to/fixtures.rst | 2 +- doc/en/reference/reference.rst | 14 +++++----- 19 files changed, 102 insertions(+), 42 deletions(-) delete mode 100644 changelog/11777.bugfix.rst delete mode 100644 changelog/12842.doc.rst delete mode 100644 changelog/12888.bugfix.rst delete mode 100644 changelog/13026.bugfix.rst delete mode 100644 changelog/13053.bugfix.rst delete mode 100644 changelog/13083.bugfix.rst delete mode 100644 changelog/13112.contrib.rst delete mode 100644 changelog/13256.contrib.rst create mode 100644 doc/en/announce/release-8.3.5.rst diff --git a/changelog/11777.bugfix.rst b/changelog/11777.bugfix.rst deleted file mode 100644 index 3f1ffc27a68..00000000000 --- a/changelog/11777.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed issue where sequences were still being shortened even with ``-vv`` verbosity. diff --git a/changelog/12842.doc.rst b/changelog/12842.doc.rst deleted file mode 100644 index 0a0f5c5bc23..00000000000 --- a/changelog/12842.doc.rst +++ /dev/null @@ -1,3 +0,0 @@ -Added dedicated page about using types with pytest. - -See :ref:`types` for detailed usage. diff --git a/changelog/12888.bugfix.rst b/changelog/12888.bugfix.rst deleted file mode 100644 index 635e35a11ea..00000000000 --- a/changelog/12888.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed broken input when using Python 3.13+ and a ``libedit`` build of Python, such as on macOS or with uv-managed Python binaries from the ``python-build-standalone`` project. This could manifest e.g. by a broken prompt when using ``Pdb``, or seeing empty inputs with manual usage of ``input()`` and suspended capturing. diff --git a/changelog/13026.bugfix.rst b/changelog/13026.bugfix.rst deleted file mode 100644 index d10edbd111a..00000000000 --- a/changelog/13026.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed :class:`AttributeError` crash when using ``--import-mode=importlib`` when top-level directory same name as another module of the standard library. diff --git a/changelog/13053.bugfix.rst b/changelog/13053.bugfix.rst deleted file mode 100644 index b6744331394..00000000000 --- a/changelog/13053.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed a regression in pytest 8.3.4 where, when using ``--import-mode=importlib``, a directory containing py file with the same name would cause an ``ImportError`` diff --git a/changelog/13083.bugfix.rst b/changelog/13083.bugfix.rst deleted file mode 100644 index fc4564755ba..00000000000 --- a/changelog/13083.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed issue where pytest could crash if one of the collected directories got removed during collection. diff --git a/changelog/13112.contrib.rst b/changelog/13112.contrib.rst deleted file mode 100644 index 5e59a736edb..00000000000 --- a/changelog/13112.contrib.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed selftest failures in ``test_terminal.py`` with Pygments >= 2.19.0 diff --git a/changelog/13256.contrib.rst b/changelog/13256.contrib.rst deleted file mode 100644 index fe3bac87ca1..00000000000 --- a/changelog/13256.contrib.rst +++ /dev/null @@ -1,2 +0,0 @@ -Support for Towncier versions released in 2024 has been re-enabled -when building Sphinx docs -- by :user:`webknjaz`. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index 8a38df7a2e1..51edc964a0c 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-8.3.5 release-8.3.4 release-8.3.3 release-8.3.2 diff --git a/doc/en/announce/release-8.3.5.rst b/doc/en/announce/release-8.3.5.rst new file mode 100644 index 00000000000..3de02c1d7a4 --- /dev/null +++ b/doc/en/announce/release-8.3.5.rst @@ -0,0 +1,26 @@ +pytest-8.3.5 +======================================= + +pytest 8.3.5 has just been released to PyPI. + +This is a bug-fix release, being a drop-in replacement. + +The full changelog is available at https://docs.pytest.org/en/stable/changelog.html. + +Thanks to all of the contributors to this release: + +* Bruno Oliveira +* Florian Bruhin +* John Litborn +* Kenny Y +* Ran Benita +* Sadra Barikbin +* Vincent (Wen Yu) Ge +* delta87 +* dongfangtianyu +* mwychung +* 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) + + +Happy testing, +The pytest Development Team diff --git a/doc/en/builtin.rst b/doc/en/builtin.rst index 85d280da50f..8aa6fef681c 100644 --- a/doc/en/builtin.rst +++ b/doc/en/builtin.rst @@ -33,7 +33,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a Values can be any object handled by the json stdlib module. - capsysbinary -- .../_pytest/capture.py:1006 + capsysbinary -- .../_pytest/capture.py:1024 Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``. The captured output is made available via ``capsysbinary.readouterr()`` @@ -51,7 +51,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capsysbinary.readouterr() assert captured.out == b"hello\n" - capfd -- .../_pytest/capture.py:1034 + capfd -- .../_pytest/capture.py:1052 Enable text capturing of writes to file descriptors ``1`` and ``2``. The captured output is made available via ``capfd.readouterr()`` method @@ -69,7 +69,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capfd.readouterr() assert captured.out == "hello\n" - capfdbinary -- .../_pytest/capture.py:1062 + capfdbinary -- .../_pytest/capture.py:1080 Enable bytes capturing of writes to file descriptors ``1`` and ``2``. The captured output is made available via ``capfd.readouterr()`` method @@ -87,7 +87,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capfdbinary.readouterr() assert captured.out == b"hello\n" - capsys -- .../_pytest/capture.py:978 + capsys -- .../_pytest/capture.py:996 Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``. The captured output is made available via ``capsys.readouterr()`` method diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index 58128763a49..3074124465a 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -31,6 +31,47 @@ with advance notice in the **Deprecations** section of releases. .. towncrier release notes start +pytest 8.3.5 (2025-03-02) +========================= + +Bug fixes +--------- + +- `#11777 `_: Fixed issue where sequences were still being shortened even with ``-vv`` verbosity. + + +- `#12888 `_: Fixed broken input when using Python 3.13+ and a ``libedit`` build of Python, such as on macOS or with uv-managed Python binaries from the ``python-build-standalone`` project. This could manifest e.g. by a broken prompt when using ``Pdb``, or seeing empty inputs with manual usage of ``input()`` and suspended capturing. + + +- `#13026 `_: Fixed :class:`AttributeError` crash when using ``--import-mode=importlib`` when top-level directory same name as another module of the standard library. + + +- `#13053 `_: Fixed a regression in pytest 8.3.4 where, when using ``--import-mode=importlib``, a directory containing py file with the same name would cause an ``ImportError`` + + +- `#13083 `_: Fixed issue where pytest could crash if one of the collected directories got removed during collection. + + + +Improved documentation +---------------------- + +- `#12842 `_: Added dedicated page about using types with pytest. + + See :ref:`types` for detailed usage. + + + +Contributor-facing changes +-------------------------- + +- `#13112 `_: Fixed selftest failures in ``test_terminal.py`` with Pygments >= 2.19.0 + + +- `#13256 `_: Support for Towncier versions released in 2024 has been re-enabled + when building Sphinx docs -- by :user:`webknjaz`. + + pytest 8.3.4 (2024-12-01) ========================= diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index f1f7deb909c..69e715c9db1 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -162,7 +162,7 @@ objects, they are still using the default pytest representation: rootdir: /home/sweet/project collected 8 items - + @@ -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 - + @@ -318,7 +318,7 @@ Let's first see how it looks like at collection time: rootdir: /home/sweet/project collected 2 items - + @@ -503,11 +503,12 @@ 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%] + sssssssssssssssssssssssssss [100%] ========================= short test summary info ========================== - SKIPPED [12] multipython.py:67: 'python3.9' not found - SKIPPED [12] multipython.py:67: 'python3.11' not found - 3 passed, 24 skipped in 0.12s + SKIPPED [9] multipython.py:67: 'python3.9' not found + SKIPPED [9] multipython.py:67: 'python3.10' not found + SKIPPED [9] multipython.py:67: 'python3.11' not found + 27 skipped in 0.12s Parametrization of optional implementations/imports --------------------------------------------------- diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 1d1ce07c10a..89d7ee42614 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -152,7 +152,7 @@ The test collection would look like this: configfile: pytest.ini collected 2 items - + @@ -215,7 +215,7 @@ You can always peek at the collection tree without running tests like this: configfile: pytest.ini collected 3 items - + diff --git a/doc/en/example/reportingdemo.rst b/doc/en/example/reportingdemo.rst index 0da58d0490e..5e48815bbc9 100644 --- a/doc/en/example/reportingdemo.rst +++ b/doc/en/example/reportingdemo.rst @@ -568,12 +568,12 @@ Here is a nice run of several failures and how ``pytest`` presents things: E + where False = ('456') E + where = '123'.startswith E + where '123' = .f at 0xdeadbeef0029>() - E + and '456' = .g at 0xdeadbeef002a>() + E + and '456' = .g at 0xdeadbeef0003>() failure_demo.py:237: AssertionError _____________________ TestMoreErrors.test_global_func ______________________ - self = + self = def test_global_func(self): > assert isinstance(globf(42), float) @@ -584,18 +584,18 @@ Here is a nice run of several failures and how ``pytest`` presents things: failure_demo.py:240: AssertionError _______________________ TestMoreErrors.test_instance _______________________ - self = + self = def test_instance(self): self.x = 6 * 7 > assert self.x != 42 E assert 42 != 42 - E + where 42 = .x + E + where 42 = .x failure_demo.py:244: AssertionError _______________________ TestMoreErrors.test_compare ________________________ - self = + self = def test_compare(self): > assert globf(10) < 5 @@ -605,7 +605,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: failure_demo.py:247: AssertionError _____________________ TestMoreErrors.test_try_finally ______________________ - self = + self = def test_try_finally(self): x = 1 @@ -616,7 +616,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: failure_demo.py:252: AssertionError ___________________ TestCustomAssertMsg.test_single_line ___________________ - self = + self = def test_single_line(self): class A: @@ -631,7 +631,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: failure_demo.py:263: AssertionError ____________________ TestCustomAssertMsg.test_multiline ____________________ - self = + self = def test_multiline(self): class A: @@ -650,7 +650,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: failure_demo.py:270: AssertionError ___________________ TestCustomAssertMsg.test_custom_repr ___________________ - self = + self = def test_custom_repr(self): class JSON: diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index b50fbfed397..69d973e51d0 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -164,7 +164,7 @@ Now we'll get feedback on a bad argument: $ pytest -q --cmdopt=type3 ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...] - pytest: error: argument --cmdopt: invalid choice: 'type3' (choose from 'type1', 'type2') + pytest: error: argument --cmdopt: invalid choice: 'type3' (choose from type1, type2) If you need to provide more detailed error messages, you can use the diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index d4308e5aab3..5b9f38d7bf7 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -22,7 +22,7 @@ Install ``pytest`` .. code-block:: bash $ pytest --version - pytest 8.3.4 + pytest 8.3.5 .. _`simpletest`: diff --git a/doc/en/how-to/fixtures.rst b/doc/en/how-to/fixtures.rst index 9232c9e8449..8f84e4867a6 100644 --- a/doc/en/how-to/fixtures.rst +++ b/doc/en/how-to/fixtures.rst @@ -1418,7 +1418,7 @@ Running the above tests results in the following test IDs being used: rootdir: /home/sweet/project collected 12 items - + diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index b42e69dfa23..631d45191a7 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -2102,7 +2102,7 @@ All the command-line flags can be obtained by running ``pytest --help``:: Show cache contents, don't perform collection or tests. Optional argument: glob (default: '*'). --cache-clear Remove all cache contents at start of test run - --lfnf={all,none}, --last-failed-no-failures={all,none} + --lfnf, --last-failed-no-failures={all,none} With ``--lf``, determines whether to execute tests when there are no previously (known) failures or when no cached ``lastfailed`` data was found. @@ -2148,11 +2148,13 @@ All the command-line flags can be obtained by running ``pytest --help``:: Whether code should be highlighted (only if --color is also enabled). Default: yes. --pastebin=mode Send failed|all info to bpaste.net pastebin service - --junit-xml=path Create junit-xml style report file at given path - --junit-prefix=str Prepend prefix to classnames in junit-xml output + --junitxml, --junit-xml=path + Create junit-xml style report file at given path + --junitprefix, --junit-prefix=str + Prepend prefix to classnames in junit-xml output pytest-warnings: - -W PYTHONWARNINGS, --pythonwarnings=PYTHONWARNINGS + -W, --pythonwarnings PYTHONWARNINGS Set which warnings to report, see -W option of Python itself --maxfail=num Exit after first num failures or errors @@ -2161,7 +2163,7 @@ All the command-line flags can be obtained by running ``pytest --help``:: --strict-markers Markers not registered in the `markers` section of the configuration file raise errors --strict (Deprecated) alias to --strict-markers - -c FILE, --config-file=FILE + -c, --config-file FILE Load configuration from `FILE` instead of trying to locate one of the implicit configuration files. --continue-on-collection-errors @@ -2215,7 +2217,7 @@ All the command-line flags can be obtained by running ``pytest --help``:: Store internal tracing debug information in this log file. This file is opened with 'w' and truncated as a result, care advised. Default: pytestdebug.log. - -o OVERRIDE_INI, --override-ini=OVERRIDE_INI + -o, --override-ini OVERRIDE_INI Override ini option with "option=value" style, e.g. `-o xfail_strict=True -o cache_dir=cache`. --assert=MODE Control assertion debugging tools. From e18b245f0a07f03de889e9541242397e4d2ce388 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 2 Mar 2025 10:12:28 -0600 Subject: [PATCH 338/445] chore(changelog) Minor typo fix (#13267) --- doc/en/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index 3074124465a..c92cd7d4263 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -68,7 +68,7 @@ Contributor-facing changes - `#13112 `_: Fixed selftest failures in ``test_terminal.py`` with Pygments >= 2.19.0 -- `#13256 `_: Support for Towncier versions released in 2024 has been re-enabled +- `#13256 `_: Support for Towncrier versions released in 2024 has been re-enabled when building Sphinx docs -- by :user:`webknjaz`. From 4e9765203d61e2673f9d6c27e4e55811d000b424 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Mon, 3 Mar 2025 12:27:48 +0100 Subject: [PATCH 339/445] remove raises_group alias, doc fixes after review --- doc/en/how-to/assert.rst | 4 ++-- src/pytest/__init__.py | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/en/how-to/assert.rst b/doc/en/how-to/assert.rst index c01e59a7a0e..966ea8b38fc 100644 --- a/doc/en/how-to/assert.rst +++ b/doc/en/how-to/assert.rst @@ -225,9 +225,9 @@ Check the documentation on :class:`pytest.RaisesGroup` and :class:`pytest.Raises if very_unlucky(): excs.append(EXTREMELYBADERROR()) raise ExceptionGroup("", excs) - # this passes regardless of if there's other exceptions + # This passes regardless of if there's other exceptions. assert excinfo.group_contains(ValueError) - # you can't simply list all exceptions you *don't* want to get here + # You can't simply list all exceptions you *don't* want to get here. There is no good way of using :func:`excinfo.group_contains() ` to ensure you're not getting *any* other exceptions than the one you expected. diff --git a/src/pytest/__init__.py b/src/pytest/__init__.py index e3e782654fe..3e73605ce15 100644 --- a/src/pytest/__init__.py +++ b/src/pytest/__init__.py @@ -62,7 +62,6 @@ from _pytest.python_api import raises from _pytest.raises_group import RaisesExc from _pytest.raises_group import RaisesGroup -from _pytest.raises_group import RaisesGroup as raises_group from _pytest.recwarn import deprecated_call from _pytest.recwarn import WarningsRecorder from _pytest.recwarn import warns @@ -167,7 +166,6 @@ "mark", "param", "raises", - "raises_group", "register_assert_rewrite", "set_trace", "skip", From bfe0c83ed314741ee8e4b5aecaddaa84b44a3ec6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 15:40:29 +0100 Subject: [PATCH 340/445] build(deps): Bump peter-evans/create-pull-request from 7.0.6 to 7.0.7 (#13268) Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 7.0.6 to 7.0.7. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/67ccf781d68cd99b580ae25a5c18a1cc84ffff1f...dd2324fc52d5d43c699a5636bcf19fceaa70c284) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/update-plugin-list.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-plugin-list.yml b/.github/workflows/update-plugin-list.yml index a4eeb4b0a36..3200cb174cc 100644 --- a/.github/workflows/update-plugin-list.yml +++ b/.github/workflows/update-plugin-list.yml @@ -48,7 +48,7 @@ jobs: - name: Create Pull Request id: pr - uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f + uses: peter-evans/create-pull-request@dd2324fc52d5d43c699a5636bcf19fceaa70c284 with: commit-message: '[automated] Update plugin list' author: 'pytest bot ' From 410a052152720c572ec2e02ce6c034562b614c6f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Mar 2025 20:44:28 +0000 Subject: [PATCH 341/445] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.7 → v0.9.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.7...v0.9.9) - [github.com/woodruffw/zizmor-pre-commit: v1.3.1 → v1.4.1](https://github.com/woodruffw/zizmor-pre-commit/compare/v1.3.1...v1.4.1) - [github.com/tox-dev/pyproject-fmt: v2.5.0 → v2.5.1](https://github.com/tox-dev/pyproject-fmt/compare/v2.5.0...v2.5.1) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 085ea59ca05..26c5a7f5394 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.9.7" + rev: "v0.9.9" hooks: - id: ruff args: ["--fix"] @@ -12,7 +12,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/woodruffw/zizmor-pre-commit - rev: v1.3.1 + rev: v1.4.1 hooks: - id: zizmor - repo: https://github.com/adamchainz/blacken-docs @@ -48,7 +48,7 @@ repos: # on <3.11 - exceptiongroup>=1.0.0rc8 - repo: https://github.com/tox-dev/pyproject-fmt - rev: "v2.5.0" + rev: "v2.5.1" hooks: - id: pyproject-fmt # https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version From be2600ea40708b709f50aa8706d83b1cda17663c Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Mon, 3 Mar 2025 22:28:13 +0100 Subject: [PATCH 342/445] [pylint] Noqa a false positive with dynamic exception handling --- src/_pytest/python_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index ddbf9b87251..5fd9c5124d5 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -1017,7 +1017,7 @@ def validate_exc(exc: type[E]) -> type[E]: raise TypeError(f"{func!r} object (type: {type(func)}) must be callable") try: func(*args[1:], **kwargs) - except expected_exceptions as e: + except expected_exceptions as e: # pylint: disable=catching-non-exception return _pytest._code.ExceptionInfo.from_exception(e) fail(message) From a7479ced6cad92fd5aee476efea748e65090e650 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Mon, 3 Mar 2025 22:28:43 +0100 Subject: [PATCH 343/445] [pyupgrade] Apply pyupgrade on new code manually --- testing/acceptance_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index ffd1dcce219..50ea4ff44d2 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -999,14 +999,14 @@ def test_calls_showall_durationsmin_verbose( def check_tests_in_output( lines: Sequence[str], *expected_test_numbers: int, number_of_tests: int = 3 ) -> None: - found_test_numbers = set( + found_test_numbers = { test_number for test_number in range(1, number_of_tests + 1) if any( line.endswith(f"test_{test_number}") and " call " in line for line in lines ) - ) + } assert found_test_numbers == set(expected_test_numbers) def test_with_deselected(self, pytester: Pytester, mock_timing) -> None: From d37e6d66d3ba33a41d4c1d09bc66fe934f79b175 Mon Sep 17 00:00:00 2001 From: John Litborn <11260241+jakkdl@users.noreply.github.com> Date: Wed, 5 Mar 2025 16:22:15 +0100 Subject: [PATCH 344/445] Update 11538.feature.rst --- changelog/11538.feature.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/11538.feature.rst b/changelog/11538.feature.rst index 60f191d05cb..d6473b8fe73 100644 --- a/changelog/11538.feature.rst +++ b/changelog/11538.feature.rst @@ -1 +1 @@ -Added :class:`pytest.RaisesGroup` (also export as ``pytest.raises_group``) and :class:`pytest.RaisesExc`, as an equivalent to :func:`pytest.raises` for expecting :exc:`ExceptionGroup`. It includes the ability to specify multiple different expected exceptions, the structure of nested exception groups, and flags for emulating :ref:`except* `. See :ref:`assert-matching-exception-groups` and docstrings for more information. +Added :class:`pytest.RaisesGroup` as an equivalent to :func:`pytest.raises` for expecting :exc:`ExceptionGroup`. Also adds :class:`pytest.RaisesExc` which is now the logic behind :func:`pytest.raises` and used as parameter to :class:`pytest.RaisesGroup`. ``RaisesGroup`` includes the ability to specify multiple different expected exceptions, the structure of nested exception groups, and flags for emulating :ref:`except* `. See :ref:`assert-matching-exception-groups` and docstrings for more information. From 4c6ded7b0c879221e54161cb4d712505b46a59d2 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 5 Mar 2025 16:34:49 +0100 Subject: [PATCH 345/445] docs fixes after removing the raises_group alias. --- doc/en/how-to/assert.rst | 20 ++++++++++---------- src/_pytest/_code/code.py | 2 +- src/_pytest/python_api.py | 5 ----- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/doc/en/how-to/assert.rst b/doc/en/how-to/assert.rst index 966ea8b38fc..6bc8f6fed33 100644 --- a/doc/en/how-to/assert.rst +++ b/doc/en/how-to/assert.rst @@ -148,14 +148,14 @@ Notes: Assertions about expected exception groups ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -When expecting a :exc:`BaseExceptionGroup` or :exc:`ExceptionGroup` you can use :class:`pytest.RaisesGroup`, also available as :class:`pytest.raises_group `: +When expecting a :exc:`BaseExceptionGroup` or :exc:`ExceptionGroup` you can use :class:`pytest.RaisesGroup`: .. code-block:: python def test_exception_in_group(): - with pytest.raises_group(ValueError): + with pytest.RaisesGroup(ValueError): raise ExceptionGroup("group msg", [ValueError("value msg")]) - with pytest.raises_group(ValueError, TypeError): + with pytest.RaisesGroup(ValueError, TypeError): raise ExceptionGroup("msg", [ValueError("foo"), TypeError("bar")]) @@ -164,9 +164,9 @@ It accepts a ``match`` parameter, that checks against the group message, and a ` .. code-block:: python def test_raisesgroup_match_and_check(): - with pytest.raises_group(BaseException, match="my group msg"): + with pytest.RaisesGroup(BaseException, match="my group msg"): raise BaseExceptionGroup("my group msg", [KeyboardInterrupt()]) - with pytest.raises_group( + with pytest.RaisesGroup( Exception, check=lambda eg: isinstance(eg.__cause__, ValueError) ): raise ExceptionGroup("", [TypeError()]) from ValueError() @@ -176,11 +176,11 @@ It is strict about structure and unwrapped exceptions, unlike :ref:`except* ` to ensure you're not getting *any* other exceptions than the one you expected. - You should instead use :class:`pytest.raises_group `, see :ref:`assert-matching-exception-groups`. + You should instead use :class:`pytest.RaisesGroup`, see :ref:`assert-matching-exception-groups`. You can also use the :func:`excinfo.group_contains() ` method to test for exceptions returned as part of an :class:`ExceptionGroup`: diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 0a5a20161e4..b57569dff98 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -840,7 +840,7 @@ def group_contains( This helper makes it easy to check for the presence of specific exceptions, but it is very bad for checking that the group does *not* contain *any other exceptions*. - You should instead consider using :class:`pytest.raises_group ` + You should instead consider using :class:`pytest.RaisesGroup` """ msg = "Captured exception is not an instance of `BaseExceptionGroup`" diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index f59d7ea8ef4..74ddd73005b 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -22,9 +22,6 @@ from _pytest.raises_group import RaisesExc -if sys.version_info < (3, 11): - pass - if TYPE_CHECKING: from numpy import ndarray @@ -771,8 +768,6 @@ def _as_numpy_array(obj: object) -> ndarray | None: Return an ndarray if the given object is implicitly convertible to ndarray, and numpy is already imported, otherwise None. """ - import sys - np: Any = sys.modules.get("numpy") if np is not None: # avoid infinite recursion on numpy scalars, which have __array__ From 94f4409a4fbd9aa02a671ada6f216949b6204668 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 5 Mar 2025 17:34:06 +0100 Subject: [PATCH 346/445] require patches to be 100% coverage, instead of current project coverage% --- codecov.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index 0841ab049ff..c37e5ec4a09 100644 --- a/codecov.yml +++ b/codecov.yml @@ -6,6 +6,8 @@ codecov: coverage: status: - patch: true + patch: + default: + target: 100% # require patches to be 100% project: false comment: false From 31d64fc53ba12905008241afa4010472aff13bae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Mar 2025 06:23:52 +0100 Subject: [PATCH 347/445] build(deps): Bump django in /testing/plugins_integration (#13276) Bumps [django](https://github.com/django/django) from 5.1.6 to 5.1.7. - [Commits](https://github.com/django/django/compare/5.1.6...5.1.7) --- updated-dependencies: - dependency-name: django dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 5562329e1de..437df4dc2d1 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,5 +1,5 @@ anyio[trio]==4.8.0 -django==5.1.6 +django==5.1.7 pytest-asyncio==0.25.3 pytest-bdd==8.1.0 pytest-cov==6.0.0 From a98d093a71a3a0cb13ff7d337366f364a54c2ba3 Mon Sep 17 00:00:00 2001 From: John Litborn <11260241+jakkdl@users.noreply.github.com> Date: Fri, 7 Mar 2025 20:04:46 +0100 Subject: [PATCH 348/445] improve raisesgroup code coverage (#13275) * improve raisesgroup code coverage * fix coverage of a weird branch in python_api, explicitify match in other test * remove comment --- src/_pytest/_code/code.py | 3 ++- src/_pytest/raises_group.py | 6 ------ testing/python/raises.py | 24 +++++++++++++++++++++--- testing/python/raises_group.py | 29 ++++++++++++++++++++--------- 4 files changed, 43 insertions(+), 19 deletions(-) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index b57569dff98..2c872df3008 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -470,7 +470,8 @@ def stringify_exception( HTTPError = getattr(sys.modules.get("urllib.error", None), "HTTPError", ()) if sys.version_info < (3, 12) and isinstance(exc, HTTPError): notes = [] - else: + else: # pragma: no cover + # exception not related to above bug, reraise raise if not include_subexception_msg and isinstance(exc, BaseExceptionGroup): message = exc.message diff --git a/src/_pytest/raises_group.py b/src/_pytest/raises_group.py index f60bacb7184..51ab8aafaf4 100644 --- a/src/_pytest/raises_group.py +++ b/src/_pytest/raises_group.py @@ -213,7 +213,6 @@ def _parse_exc( self.is_baseexception = True return cast(type[BaseExcT_1], origin_exc) else: - # I kinda think this should be a TypeError... raise ValueError( f"Only `ExceptionGroup[Exception]` or `BaseExceptionGroup[BaseExeption]` " f"are accepted as generic types but got `{exc}`. " @@ -424,11 +423,6 @@ def __enter__(self) -> ExceptionInfo[BaseExcT_co_default]: self.excinfo: ExceptionInfo[BaseExcT_co_default] = ExceptionInfo.for_later() return self.excinfo - def expected_type(self) -> str: - if self.expected_exceptions == (): - return "BaseException" - return _exception_type_name(self.expected_exceptions) - # TODO: move common code into superclass def __exit__( self, diff --git a/testing/python/raises.py b/testing/python/raises.py index 5dafef7a78d..333e273db6a 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -36,6 +36,19 @@ def test_raises_does_not_allow_none(self): # so we can ignore Mypy telling us that None is invalid. pytest.raises(expected_exception=None) # type: ignore + # it's unclear if this message is helpful, and if it is, should it trigger more + # liberally? Usually you'd get a TypeError here + def test_raises_false_and_arg(self): + with pytest.raises( + ValueError, + match=wrap_escape( + "Expected an exception type or a tuple of exception types, but got `False`. " + "Raising exceptions is already understood as failing the test, so you don't need " + "any special code to say 'this should never raise an exception'." + ), + ): + pytest.raises(False, int) # type: ignore[call-overload] + def test_raises_does_not_allow_empty_tuple(self): with pytest.raises( ValueError, @@ -219,7 +232,7 @@ def __call__(self): elif method == "with_group": with pytest.RaisesGroup(ValueError, allow_unwrapped=True): t() - else: + else: # pragma: no cover raise AssertionError("bad parametrization") # ensure both forms of pytest.raises don't leave exceptions in sys.exc_info() @@ -337,10 +350,15 @@ def __class__(self): def test_raises_context_manager_with_kwargs(self): with pytest.raises(expected_exception=ValueError): raise ValueError - with pytest.raises(TypeError) as excinfo: + with pytest.raises( + TypeError, + match=wrap_escape( + "Unexpected keyword arguments passed to pytest.raises: foo\n" + "Use context-manager form instead?" + ), + ): with pytest.raises(OSError, foo="bar"): # type: ignore[call-overload] pass - assert "Unexpected keyword arguments" in str(excinfo.value) def test_expected_exception_is_not_a_baseexception(self) -> None: with pytest.raises(TypeError) as excinfo: diff --git a/testing/python/raises_group.py b/testing/python/raises_group.py index 2619eb41c1d..0dc2a58a1da 100644 --- a/testing/python/raises_group.py +++ b/testing/python/raises_group.py @@ -458,12 +458,16 @@ def my_check(e: object) -> bool: # pragma: no cover assert RaisesGroup(ValueError, match="bar").matches(exc.value) -def test_RaisesGroup_matches() -> None: +def test_matches() -> None: rg = RaisesGroup(ValueError) assert not rg.matches(None) assert not rg.matches(ValueError()) assert rg.matches(ExceptionGroup("", (ValueError(),))) + re = RaisesExc(ValueError) + assert not re.matches(None) + assert re.matches(ValueError()) + def test_message() -> None: def check_message( @@ -884,11 +888,13 @@ def test_assert_message_nested() -> None: ) +# CI always runs with hypothesis, but this is not a critical test - it overlaps +# with several others @pytest.mark.skipif( "hypothesis" in sys.modules, reason="hypothesis may have monkeypatched _check_repr", ) -def test_check_no_patched_repr() -> None: +def test_check_no_patched_repr() -> None: # pragma: no cover # We make `_check_repr` monkeypatchable to avoid this very ugly and verbose # repr. The other tests that use `check` make use of `_check_repr` so they'll # continue passing in case it is patched - but we have this one test that @@ -1288,15 +1294,20 @@ def test_parametrizing_conditional_raisesgroup( def test_annotated_group() -> None: # repr depends on if exceptiongroup backport is being used or not t = repr(ExceptionGroup[ValueError]) - fail_msg = wrap_escape( - f"Only `ExceptionGroup[Exception]` or `BaseExceptionGroup[BaseExeption]` are accepted as generic types but got `{t}`. As `raises` will catch all instances of the specified group regardless of the generic argument specific nested exceptions has to be checked with `RaisesGroup`." - ) + msg = "Only `ExceptionGroup[Exception]` or `BaseExceptionGroup[BaseExeption]` are accepted as generic types but got `{}`. As `raises` will catch all instances of the specified group regardless of the generic argument specific nested exceptions has to be checked with `RaisesGroup`." + + fail_msg = wrap_escape(msg.format(t)) with pytest.raises(ValueError, match=fail_msg): - with RaisesGroup(ExceptionGroup[ValueError]): - ... # pragma: no cover + RaisesGroup(ExceptionGroup[ValueError]) with pytest.raises(ValueError, match=fail_msg): - with RaisesExc(ExceptionGroup[ValueError]): - ... # pragma: no cover + RaisesExc(ExceptionGroup[ValueError]) + with pytest.raises( + ValueError, + match=wrap_escape(msg.format(repr(BaseExceptionGroup[KeyboardInterrupt]))), + ): + with RaisesExc(BaseExceptionGroup[KeyboardInterrupt]): + raise BaseExceptionGroup("", [KeyboardInterrupt()]) + with RaisesGroup(ExceptionGroup[Exception]): raise ExceptionGroup( "", [ExceptionGroup("", [ValueError(), ValueError(), ValueError()])] From 72031556c790b253df76342afc98c054e2f22e70 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 8 Mar 2025 12:19:13 +0100 Subject: [PATCH 349/445] doc: Update trainings (#13280) --- doc/en/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/index.rst b/doc/en/index.rst index 7f3dbdd800d..6e04dbb9ed0 100644 --- a/doc/en/index.rst +++ b/doc/en/index.rst @@ -2,7 +2,7 @@ .. sidebar:: **Next Open Trainings and Events** - - `Professional Testing with Python `_, via `Python Academy `_ (3 day in-depth training), **March 4th -- 6th 2025**, Remote + - `pytest - simple, rapid and fun testing with Python `_, at `PyConDE `_, **April 24th** (1.5), Darmstadt, Germany Also see :doc:`previous talks and blogposts ` From 611f336b802366e662e5d35380dbed50b0c327e3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 9 Mar 2025 06:26:22 +0000 Subject: [PATCH 350/445] [automated] Update plugin list (#13282) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 98 +++++++++++++++++--------------- 1 file changed, 53 insertions(+), 45 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 59a73530796..e8dfcc68028 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =8.2 - :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Feb 10, 2025 4 - Beta pytest>=6.2.0 + :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Mar 03, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Jul 04, 2024 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) :pypi:`pytest-async-mongodb` pytest plugin for async MongoDB Oct 18, 2017 5 - Production/Stable pytest (>=2.5.2) @@ -161,7 +161,7 @@ This list contains 1588 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Feb 28, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Mar 07, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -192,7 +192,7 @@ This list contains 1588 plugins. :pypi:`pytest-breakword` Use breakword with pytest Aug 04, 2021 N/A pytest (>=6.2.4,<7.0.0) :pypi:`pytest-breed-adapter` A simple plugin to connect with breed-server Nov 07, 2018 4 - Beta pytest (>=3.5.0) :pypi:`pytest-briefcase` A pytest plugin for running tests on a Briefcase project. Jun 14, 2020 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-broadcaster` Pytest plugin to broadcast pytest output to various destinations Apr 06, 2024 3 - Alpha pytest + :pypi:`pytest-broadcaster` Pytest plugin to broadcast pytest output to various destinations Mar 02, 2025 3 - Alpha pytest :pypi:`pytest-browser` A pytest plugin for console based browser test selection just after the collection phase Dec 10, 2016 3 - Alpha N/A :pypi:`pytest-browsermob-proxy` BrowserMob proxy plugin for py.test. Jun 11, 2013 4 - Beta N/A :pypi:`pytest_browserstack` Py.test plugin for BrowserStack Jan 27, 2016 4 - Beta N/A @@ -255,7 +255,7 @@ This list contains 1588 plugins. :pypi:`pytest_cleanup` Automated, comprehensive and well-organised pytest test cases. Jan 28, 2020 N/A N/A :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Nov 08, 2024 5 - Production/Stable N/A :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Jan 30, 2025 N/A pytest<9.0.0,>=8.0.0 - :pypi:`pytest-cli2-ansible` Feb 28, 2025 N/A N/A + :pypi:`pytest-cli2-ansible` Mar 05, 2025 N/A N/A :pypi:`pytest-click` Pytest plugin for Click Feb 11, 2022 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-cli-fixtures` Automatically register fixtures for custom CLI arguments Jul 28, 2022 N/A pytest (~=7.0) :pypi:`pytest-clld` Oct 23, 2024 N/A pytest>=3.9 @@ -476,15 +476,15 @@ This list contains 1588 plugins. :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Feb 20, 2025 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Feb 20, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Feb 20, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Feb 20, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Feb 20, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Feb 20, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Feb 20, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Feb 20, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Feb 20, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Mar 03, 2025 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Mar 03, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Mar 03, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Mar 03, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Mar 03, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Mar 03, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Mar 03, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Mar 03, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Mar 03, 2025 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -678,7 +678,7 @@ This list contains 1588 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Mar 01, 2025 3 - Alpha pytest==8.3.4 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Mar 08, 2025 3 - Alpha pytest==8.3.4 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -727,7 +727,7 @@ This list contains 1588 plugins. :pypi:`pytest-info-collector` pytest plugin to collect information from tests May 26, 2019 3 - Alpha N/A :pypi:`pytest-info-plugin` Get executed interface information in pytest interface automation framework Sep 14, 2023 N/A N/A :pypi:`pytest-informative-node` display more node ininformation. Apr 25, 2019 4 - Beta N/A - :pypi:`pytest-infrahouse` A set of fixtures to use with pytest Dec 19, 2024 4 - Beta pytest~=8.3 + :pypi:`pytest-infrahouse` A set of fixtures to use with pytest Mar 06, 2025 4 - Beta pytest~=8.3 :pypi:`pytest-infrastructure` pytest stack validation prior to testing executing Apr 12, 2020 4 - Beta N/A :pypi:`pytest-ini` Reuse pytest.ini to store env variables Apr 26, 2022 N/A N/A :pypi:`pytest-initry` Plugin for sending automation test data from Pytest to the initry Apr 30, 2024 N/A pytest<9.0.0,>=8.1.1 @@ -747,12 +747,12 @@ This list contains 1588 plugins. :pypi:`pytest-interactive` A pytest plugin for console based interactive test selection just after the collection phase Nov 30, 2017 3 - Alpha N/A :pypi:`pytest-intercept-remote` Pytest plugin for intercepting outgoing connection requests during pytest run. May 24, 2021 4 - Beta pytest (>=4.6) :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Feb 13, 2025 4 - Beta pytest - :pypi:`pytest-invenio` Pytest fixtures for Invenio. Dec 02, 2024 5 - Production/Stable pytest<9.0.0,>=6 + :pypi:`pytest-invenio` Pytest fixtures for Invenio. Mar 07, 2025 5 - Production/Stable pytest<9.0.0,>=6 :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-iovis` A Pytest plugin to enable Jupyter Notebook testing with Papermill Nov 06, 2024 4 - Beta pytest>=7.1.0 :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A - :pypi:`pytest-ipynb2` Pytest plugin to run tests in Jupyter Notebooks Feb 19, 2025 N/A pytest + :pypi:`pytest-ipynb2` Pytest plugin to run tests in Jupyter Notebooks Mar 03, 2025 N/A pytest :pypi:`pytest-ipywidgets` Feb 18, 2025 N/A pytest :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Jan 16, 2025 4 - Beta pytest :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Feb 24, 2025 4 - Beta pytest>=5 @@ -884,7 +884,7 @@ This list contains 1588 plugins. :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A :pypi:`pytest-metadata` pytest plugin for test session metadata Feb 12, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-metrics` Custom metrics report for pytest Apr 04, 2020 N/A pytest - :pypi:`pytest-mh` Pytest multihost plugin Feb 20, 2025 N/A pytest + :pypi:`pytest-mh` Pytest multihost plugin Mar 06, 2025 N/A pytest :pypi:`pytest-mimesis` Mimesis integration with the pytest test runner Mar 21, 2020 5 - Production/Stable pytest (>=4.2) :pypi:`pytest-minecraft` A pytest plugin for running tests against Minecraft releases Apr 06, 2022 N/A pytest (>=6.0.1) :pypi:`pytest-mini` A plugin to test mp Feb 06, 2023 N/A pytest (>=7.2.0,<8.0.0) @@ -1262,7 +1262,7 @@ This list contains 1588 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Feb 26, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Mar 07, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1274,7 +1274,7 @@ This list contains 1588 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Feb 26, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Mar 07, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1356,7 +1356,7 @@ This list contains 1588 plugins. :pypi:`pytest-splitio` Split.io SDK integration for e2e tests Sep 22, 2020 N/A pytest (<7,>=5.0) :pypi:`pytest-split-tests` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Forked from Mark Adams' original project pytest-test-groups. Jul 30, 2021 5 - Production/Stable pytest (>=2.5) :pypi:`pytest-split-tests-tresorit` Feb 22, 2021 1 - Planning N/A - :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Oct 28, 2024 N/A pytest<8,>5.4.0 + :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Mar 07, 2025 N/A pytest<8,>5.4.0 :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Jan 03, 2025 N/A N/A :pypi:`pytest-splunk-env` pytest fixtures for interaction with Splunk Enterprise and Splunk Cloud Oct 22, 2020 N/A pytest (>=6.1.1,<7.0.0) :pypi:`pytest-sqitch` sqitch for pytest Apr 06, 2020 4 - Beta N/A @@ -1365,6 +1365,7 @@ This list contains 1588 plugins. :pypi:`pytest-sqlalchemy-session` A pytest plugin for preserving test isolation that use SQLAlchemy. May 19, 2023 4 - Beta pytest (>=7.0) :pypi:`pytest-sql-bigquery` Yet another SQL-testing framework for BigQuery provided by pytest plugin Dec 19, 2019 N/A pytest :pypi:`pytest-sqlfluff` A pytest plugin to use sqlfluff to enable format checking of sql files. Dec 21, 2022 4 - Beta pytest (>=3.5.0) + :pypi:`pytest-sqlguard` Pytest fixture to record and check SQL Queries made by SQLAlchemy Mar 06, 2025 4 - Beta pytest>=7 :pypi:`pytest-squadcast` Pytest report plugin for Squadcast Feb 22, 2022 5 - Production/Stable pytest :pypi:`pytest-srcpaths` Add paths to sys.path Oct 15, 2021 N/A pytest>=6.2.0 :pypi:`pytest-ssh` pytest plugin for ssh command run May 27, 2019 N/A pytest @@ -1581,7 +1582,7 @@ This list contains 1588 plugins. :pypi:`pytest-xdist-forked` forked from pytest-xdist Feb 10, 2020 5 - Production/Stable pytest (>=4.4.0) :pypi:`pytest-xdist-tracker` pytest plugin helps to reproduce failures for particular xdist node Nov 18, 2021 3 - Alpha pytest (>=3.5.1) :pypi:`pytest-xdist-worker-stats` A pytest plugin to list worker statistics after a xdist run. Apr 16, 2024 4 - Beta pytest>=7.0.0 - :pypi:`pytest-xdocker` Pytest fixture to run docker across test runs. Jan 22, 2025 N/A pytest<8.0.0,>=7.4.2 + :pypi:`pytest-xdocker` Pytest fixture to run docker across test runs. Mar 07, 2025 N/A pytest<8.0.0,>=7.4.2 :pypi:`pytest-xfaillist` Maintain a xfaillist in an additional file to avoid merge-conflicts. Sep 17, 2021 N/A pytest (>=6.2.2,<7.0.0) :pypi:`pytest-xfiles` Pytest fixtures providing data read from function, module or package related (x)files. Feb 27, 2018 N/A N/A :pypi:`pytest-xflaky` A simple plugin to use with pytest Oct 14, 2024 4 - Beta pytest>=8.2.1 @@ -2216,7 +2217,7 @@ This list contains 1588 plugins. Pytest support for asyncio :pypi:`pytest-asyncio-concurrent` - *last release*: Feb 10, 2025, + *last release*: Mar 03, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -2517,7 +2518,7 @@ This list contains 1588 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Feb 28, 2025, + *last release*: Mar 07, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -2734,7 +2735,7 @@ This list contains 1588 plugins. A pytest plugin for running tests on a Briefcase project. :pypi:`pytest-broadcaster` - *last release*: Apr 06, 2024, + *last release*: Mar 02, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -3175,7 +3176,7 @@ This list contains 1588 plugins. A set of pytest fixtures to help with integration testing with Clerk. :pypi:`pytest-cli2-ansible` - *last release*: Feb 28, 2025, + *last release*: Mar 05, 2025, *status*: N/A, *requires*: N/A @@ -4722,63 +4723,63 @@ This list contains 1588 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: Feb 20, 2025, + *last release*: Mar 03, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: Feb 20, 2025, + *last release*: Mar 03, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: Feb 20, 2025, + *last release*: Mar 03, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: Feb 20, 2025, + *last release*: Mar 03, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. :pypi:`pytest-embedded-nuttx` - *last release*: Feb 20, 2025, + *last release*: Mar 03, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with NuttX. :pypi:`pytest-embedded-qemu` - *last release*: Feb 20, 2025, + *last release*: Mar 03, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: Feb 20, 2025, + *last release*: Mar 03, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: Feb 20, 2025, + *last release*: Mar 03, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: Feb 20, 2025, + *last release*: Mar 03, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -6136,7 +6137,7 @@ This list contains 1588 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Mar 01, 2025, + *last release*: Mar 08, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.4 @@ -6479,7 +6480,7 @@ This list contains 1588 plugins. display more node ininformation. :pypi:`pytest-infrahouse` - *last release*: Dec 19, 2024, + *last release*: Mar 06, 2025, *status*: 4 - Beta, *requires*: pytest~=8.3 @@ -6619,7 +6620,7 @@ This list contains 1588 plugins. Pytest plugin for checking charm relation interface protocol compliance. :pypi:`pytest-invenio` - *last release*: Dec 02, 2024, + *last release*: Mar 07, 2025, *status*: 5 - Production/Stable, *requires*: pytest<9.0.0,>=6 @@ -6654,7 +6655,7 @@ This list contains 1588 plugins. THIS PROJECT IS ABANDONED :pypi:`pytest-ipynb2` - *last release*: Feb 19, 2025, + *last release*: Mar 03, 2025, *status*: N/A, *requires*: pytest @@ -7578,7 +7579,7 @@ This list contains 1588 plugins. Custom metrics report for pytest :pypi:`pytest-mh` - *last release*: Feb 20, 2025, + *last release*: Mar 06, 2025, *status*: N/A, *requires*: pytest @@ -10224,7 +10225,7 @@ This list contains 1588 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Feb 26, 2025, + *last release*: Mar 07, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10308,7 +10309,7 @@ This list contains 1588 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Feb 26, 2025, + *last release*: Mar 07, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10882,7 +10883,7 @@ This list contains 1588 plugins. :pypi:`pytest-splunk-addon` - *last release*: Oct 28, 2024, + *last release*: Mar 07, 2025, *status*: N/A, *requires*: pytest<8,>5.4.0 @@ -10944,6 +10945,13 @@ This list contains 1588 plugins. A pytest plugin to use sqlfluff to enable format checking of sql files. + :pypi:`pytest-sqlguard` + *last release*: Mar 06, 2025, + *status*: 4 - Beta, + *requires*: pytest>=7 + + Pytest fixture to record and check SQL Queries made by SQLAlchemy + :pypi:`pytest-squadcast` *last release*: Feb 22, 2022, *status*: 5 - Production/Stable, @@ -12457,7 +12465,7 @@ This list contains 1588 plugins. A pytest plugin to list worker statistics after a xdist run. :pypi:`pytest-xdocker` - *last release*: Jan 22, 2025, + *last release*: Mar 07, 2025, *status*: N/A, *requires*: pytest<8.0.0,>=7.4.2 From ada9977b2add3ca49ce2c55f906c4d1266927734 Mon Sep 17 00:00:00 2001 From: Anton Zhilin Date: Sun, 9 Mar 2025 23:35:11 +0300 Subject: [PATCH 351/445] Prevent parametrize with scope from breaking fixture dependencies (#13249) * Prevent parametrize with scope from breaking fixture dependencies * Add myself to AUTHORS * Fix the regression test * Assert fixture value inside the test --------- Co-authored-by: Bruno Oliveira --- changelog/13248.bugfix.rst | 2 ++ src/_pytest/fixtures.py | 7 ++++++- testing/python/fixtures.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 changelog/13248.bugfix.rst diff --git a/changelog/13248.bugfix.rst b/changelog/13248.bugfix.rst new file mode 100644 index 00000000000..2ebb102fd07 --- /dev/null +++ b/changelog/13248.bugfix.rst @@ -0,0 +1,2 @@ +Fixed an issue where passing a ``scope`` in :py:func:`Metafunc.parametrize ` with ``indirect=True`` +could result in other fixtures being unable to depend on the parametrized fixture. diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index dcd06c3b40a..bb50b014dd1 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -605,7 +605,12 @@ def _get_active_fixturedef( param_index = 0 scope = fixturedef._scope self._check_fixturedef_without_param(fixturedef) - self._check_scope(fixturedef, scope) + # The parametrize invocation scope only controls caching behavior while + # allowing wider-scoped fixtures to keep depending on the parametrized + # fixture. Scope control is enforced for parametrized fixtures + # by recreating the whole fixture tree on parameter change. + # Hence `fixturedef._scope`, not `scope`. + self._check_scope(fixturedef, fixturedef._scope) subrequest = SubRequest( self, scope, param, param_index, fixturedef, _ispytest=True ) diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index dc69781095b..c8d1eb23838 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -5009,3 +5009,31 @@ def test_result(): ) result = pytester.runpytest() assert result.ret == 0 + + +def test_parametrized_fixture_scope_allowed(pytester: Pytester) -> None: + """ + Make sure scope from parametrize does not affect fixture's ability to be + depended upon. + + Regression test for #13248 + """ + pytester.makepyfile( + """ + import pytest + + @pytest.fixture(scope="session") + def my_fixture(request): + return getattr(request, "param", None) + + @pytest.fixture(scope="session") + def another_fixture(my_fixture): + return my_fixture + + @pytest.mark.parametrize("my_fixture", ["a value"], indirect=True, scope="function") + def test_foo(another_fixture): + assert another_fixture == "a value" + """ + ) + result = pytester.runpytest() + result.assert_outcomes(passed=1) From 03b5a79170679a017fb58894518b167ff9be463e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Mar 2025 07:14:46 +0100 Subject: [PATCH 352/445] build(deps): Bump peter-evans/create-pull-request from 7.0.7 to 7.0.8 (#13283) Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 7.0.7 to 7.0.8. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/dd2324fc52d5d43c699a5636bcf19fceaa70c284...271a8d0340265f705b14b6d32b9829c1cb33d45e) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/update-plugin-list.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-plugin-list.yml b/.github/workflows/update-plugin-list.yml index 3200cb174cc..c10aefa3a55 100644 --- a/.github/workflows/update-plugin-list.yml +++ b/.github/workflows/update-plugin-list.yml @@ -48,7 +48,7 @@ jobs: - name: Create Pull Request id: pr - uses: peter-evans/create-pull-request@dd2324fc52d5d43c699a5636bcf19fceaa70c284 + uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e with: commit-message: '[automated] Update plugin list' author: 'pytest bot ' From 338ef90968f14e6c008ff69188b88712e6019f14 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 10 Mar 2025 22:19:49 +0100 Subject: [PATCH 353/445] [pre-commit.ci] pre-commit autoupdate (#13285) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.9 → v0.9.10](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.9...v0.9.10) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 26c5a7f5394..be0fa02399b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.9.9" + rev: "v0.9.10" hooks: - id: ruff args: ["--fix"] From d149ab353adcfa67693f692e3ee235888971e744 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Tue, 11 Mar 2025 09:14:36 +0100 Subject: [PATCH 354/445] assorted code updates and f string migrations (#12017) * chore: setuponly - migrate to f string * chore: MockTiming - move impl to _pytest.timing * chore: fixture tests: migrate to f-strings * chore: skipping tests: migrate to f-strings * chore: junitxml tests: add more type annotations * chore: junitxml tests: introduce more typesafe helpers * add changelog * test junitxml: split the DomNode type to express the Document/Element difference * fixup: undo accidential name-mangling in the junitxml test helpers * fixup: junitxml logging test - restore validation for expected output nodes * fixup: have fake config .getini use correct types * Update changelog/12017.improvement.rst Co-authored-by: Bruno Oliveira * use contrib category for changelog * use datetime.fromisoformat instead of strptime * post rebase ruff fixes * add extra coverage for junit test helpers --------- Co-authored-by: Bruno Oliveira --- changelog/12017.contrib.rst | 7 + src/_pytest/setuponly.py | 10 +- src/_pytest/timing.py | 36 ++++ testing/conftest.py | 21 +- testing/python/fixtures.py | 42 ++-- testing/test_junitxml.py | 405 ++++++++++++++++++++---------------- testing/test_skipping.py | 16 +- 7 files changed, 305 insertions(+), 232 deletions(-) create mode 100644 changelog/12017.contrib.rst diff --git a/changelog/12017.contrib.rst b/changelog/12017.contrib.rst new file mode 100644 index 00000000000..ec1861893b3 --- /dev/null +++ b/changelog/12017.contrib.rst @@ -0,0 +1,7 @@ +Mixed internal improvements: + +* Migrate formatting to f-strings in some tests. +* Use type-safe constructs in JUnitXML tests. +* Moved`` MockTiming`` into ``_pytest.timing``. + +-- by :user:`RonnyPfannschmidt` diff --git a/src/_pytest/setuponly.py b/src/_pytest/setuponly.py index 1e887a896f5..7e6b46bcdb4 100644 --- a/src/_pytest/setuponly.py +++ b/src/_pytest/setuponly.py @@ -73,13 +73,9 @@ def _show_fixture_action( # Use smaller indentation the higher the scope: Session = 0, Package = 1, etc. scope_indent = list(reversed(Scope)).index(fixturedef._scope) tw.write(" " * 2 * scope_indent) - tw.write( - "{step} {scope} {fixture}".format( # noqa: UP032 (Readability) - step=msg.ljust(8), # align the output to TEARDOWN - scope=fixturedef.scope[0].upper(), - fixture=fixturedef.argname, - ) - ) + + scopename = fixturedef.scope[0].upper() + tw.write(f"{msg:<8} {scopename} {fixturedef.argname}") if msg == "SETUP": deps = sorted(arg for arg in fixturedef.argnames if arg != "request") diff --git a/src/_pytest/timing.py b/src/_pytest/timing.py index b23c7f69e2d..4422037a9d9 100644 --- a/src/_pytest/timing.py +++ b/src/_pytest/timing.py @@ -8,9 +8,45 @@ from __future__ import annotations +import dataclasses +from datetime import datetime from time import perf_counter from time import sleep from time import time +from typing import TYPE_CHECKING + + +if TYPE_CHECKING: + from pytest import MonkeyPatch + + +@dataclasses.dataclass +class MockTiming: + """Mocks _pytest.timing with a known object that can be used to control timing in tests + deterministically. + + pytest itself should always use functions from `_pytest.timing` instead of `time` directly. + + This then allows us more control over time during testing, if testing code also + uses `_pytest.timing` functions. + + Time is static, and only advances through `sleep` calls, thus tests might sleep over large + numbers and obtain accurate time() calls at the end, making tests reliable and instant.""" + + _current_time: float = datetime(2020, 5, 22, 14, 20, 50).timestamp() + + def sleep(self, seconds: float) -> None: + self._current_time += seconds + + def time(self) -> float: + return self._current_time + + def patch(self, monkeypatch: MonkeyPatch) -> None: + from _pytest import timing # noqa: PLW0406 + + monkeypatch.setattr(timing, "sleep", self.sleep) + monkeypatch.setattr(timing, "time", self.time) + monkeypatch.setattr(timing, "perf_counter", self.time) __all__ = ["perf_counter", "sleep", "time"] diff --git a/testing/conftest.py b/testing/conftest.py index 45a47cbdbaa..251b430e9cd 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -2,7 +2,6 @@ from __future__ import annotations from collections.abc import Generator -import dataclasses import importlib.metadata import re import sys @@ -233,24 +232,8 @@ def mock_timing(monkeypatch: MonkeyPatch): Time is static, and only advances through `sleep` calls, thus tests might sleep over large numbers and obtain accurate time() calls at the end, making tests reliable and instant. """ - - @dataclasses.dataclass - class MockTiming: - _current_time: float = 1590150050.0 - - def sleep(self, seconds: float) -> None: - self._current_time += seconds - - def time(self) -> float: - return self._current_time - - def patch(self) -> None: - from _pytest import timing - - monkeypatch.setattr(timing, "sleep", self.sleep) - monkeypatch.setattr(timing, "time", self.time) - monkeypatch.setattr(timing, "perf_counter", self.time) + from _pytest.timing import MockTiming result = MockTiming() - result.patch() + result.patch(monkeypatch) return result diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index c8d1eb23838..32453739e8c 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -2315,14 +2315,14 @@ def test_ordering_dependencies_torndown_first( ) -> None: """#226""" pytester.makepyfile( - """ + f""" import pytest values = [] - @pytest.fixture(%(param1)s) + @pytest.fixture({param1}) def arg1(request): request.addfinalizer(lambda: values.append("fin1")) values.append("new1") - @pytest.fixture(%(param2)s) + @pytest.fixture({param2}) def arg2(request, arg1): request.addfinalizer(lambda: values.append("fin2")) values.append("new2") @@ -2331,8 +2331,7 @@ def test_arg(arg2): pass def test_check(): assert values == ["new1", "new2", "fin2", "fin1"] - """ # noqa: UP031 (python syntax issues) - % locals() + """ ) reprec = pytester.inline_run("-s") reprec.assertoutcome(passed=2) @@ -3212,21 +3211,21 @@ def test_finalizer_order_on_parametrization( ) -> None: """#246""" pytester.makepyfile( - """ + f""" import pytest values = [] - @pytest.fixture(scope=%(scope)r, params=["1"]) + @pytest.fixture(scope={scope!r}, params=["1"]) def fix1(request): return request.param - @pytest.fixture(scope=%(scope)r) + @pytest.fixture(scope={scope!r}) def fix2(request, base): def cleanup_fix2(): assert not values, "base should not have been finalized" request.addfinalizer(cleanup_fix2) - @pytest.fixture(scope=%(scope)r) + @pytest.fixture(scope={scope!r}) def base(request, fix1): def cleanup_base(): values.append("fin_base") @@ -3239,8 +3238,7 @@ def test_baz(base, fix2): pass def test_other(): pass - """ # noqa: UP031 (python syntax issues) - % {"scope": scope} + """ ) reprec = pytester.inline_run("-lvs") reprec.assertoutcome(passed=3) @@ -3426,42 +3424,40 @@ class TestRequestScopeAccess: def test_setup(self, pytester: Pytester, scope, ok, error) -> None: pytester.makepyfile( - """ + f""" import pytest - @pytest.fixture(scope=%r, autouse=True) + @pytest.fixture(scope={scope!r}, autouse=True) def myscoped(request): - for x in %r: + for x in {ok.split()}: assert hasattr(request, x) - for x in %r: + for x in {error.split()}: pytest.raises(AttributeError, lambda: getattr(request, x)) assert request.session assert request.config def test_func(): pass - """ # noqa: UP031 (python syntax issues) - % (scope, ok.split(), error.split()) + """ ) reprec = pytester.inline_run("-l") reprec.assertoutcome(passed=1) def test_funcarg(self, pytester: Pytester, scope, ok, error) -> None: pytester.makepyfile( - """ + f""" import pytest - @pytest.fixture(scope=%r) + @pytest.fixture(scope={scope!r}) def arg(request): - for x in %r: + for x in {ok.split()!r}: assert hasattr(request, x) - for x in %r: + for x in {error.split()!r}: pytest.raises(AttributeError, lambda: getattr(request, x)) assert request.session assert request.config def test_func(arg): pass - """ # noqa: UP031 (python syntax issues) - % (scope, ok.split(), error.split()) + """ ) reprec = pytester.inline_run() reprec.assertoutcome(passed=1) diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index 5de0e6a5d7a..4145f34ab14 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -1,4 +1,3 @@ -# mypy: allow-untyped-defs from __future__ import annotations from datetime import datetime @@ -6,6 +5,7 @@ import os from pathlib import Path import platform +from typing import Any from typing import cast from typing import TYPE_CHECKING from xml.dom import minidom @@ -21,6 +21,7 @@ from _pytest.reports import BaseReport from _pytest.reports import TestReport from _pytest.stash import Stash +import _pytest.timing import pytest @@ -39,7 +40,7 @@ def __init__(self, pytester: Pytester, schema: xmlschema.XMLSchema) -> None: def __call__( self, *args: str | os.PathLike[str], family: str | None = "xunit1" - ) -> tuple[RunResult, DomNode]: + ) -> tuple[RunResult, DomDocument]: if family: args = ("-o", "junit_family=" + family, *args) xml_path = self.pytester.path.joinpath("junit.xml") @@ -48,7 +49,7 @@ def __call__( with xml_path.open(encoding="utf-8") as f: self.schema.validate(f) xmldoc = minidom.parse(str(xml_path)) - return result, DomNode(xmldoc) + return result, DomDocument(xmldoc) @pytest.fixture @@ -62,78 +63,129 @@ def run_and_parse(pytester: Pytester, schema: xmlschema.XMLSchema) -> RunAndPars return RunAndParse(pytester, schema) -def assert_attr(node, **kwargs): +def assert_attr(node: minidom.Element, **kwargs: object) -> None: __tracebackhide__ = True - def nodeval(node, name): + def nodeval(node: minidom.Element, name: str) -> str | None: anode = node.getAttributeNode(name) - if anode is not None: - return anode.value + return anode.value if anode is not None else None expected = {name: str(value) for name, value in kwargs.items()} on_node = {name: nodeval(node, name) for name in expected} assert on_node == expected -class DomNode: - def __init__(self, dom): - self.__node = dom +class DomDocument: + def __init__(self, dom: minidom.Document): + self._node = dom - def __repr__(self): - return self.__node.toxml() + _node: minidom.Document | minidom.Element - def find_first_by_tag(self, tag): + def find_first_by_tag(self, tag: str) -> DomNode | None: return self.find_nth_by_tag(tag, 0) - def _by_tag(self, tag): - return self.__node.getElementsByTagName(tag) + def get_first_by_tag(self, tag: str) -> DomNode: + maybe = self.find_first_by_tag(tag) + if maybe is None: + raise LookupError(tag) + else: + return maybe + + def find_nth_by_tag(self, tag: str, n: int) -> DomNode | None: + items = self._node.getElementsByTagName(tag) + try: + nth = items[n] + except IndexError: + return None + else: + return DomNode(nth) + + def find_by_tag(self, tag: str) -> list[DomNode]: + return [DomNode(x) for x in self._node.getElementsByTagName(tag)] @property - def children(self): - return [type(self)(x) for x in self.__node.childNodes] + def children(self) -> list[DomNode]: + return [DomNode(x) for x in self._node.childNodes] @property - def get_unique_child(self): + def get_unique_child(self) -> DomNode: children = self.children assert len(children) == 1 return children[0] - def find_nth_by_tag(self, tag, n): - items = self._by_tag(tag) - try: - nth = items[n] - except IndexError: - pass - else: - return type(self)(nth) + def toxml(self) -> str: + return self._node.toxml() + + +class DomNode(DomDocument): + _node: minidom.Element + + def __init__(self, dom: minidom.Element): + self._node = dom - def find_by_tag(self, tag): - t = type(self) - return [t(x) for x in self.__node.getElementsByTagName(tag)] + def __repr__(self) -> str: + return self.toxml() - def __getitem__(self, key): - node = self.__node.getAttributeNode(key) + def __getitem__(self, key: str) -> str: + node = self._node.getAttributeNode(key) if node is not None: - return node.value + return cast(str, node.value) + else: + raise KeyError(key) - def assert_attr(self, **kwargs): + def assert_attr(self, **kwargs: object) -> None: __tracebackhide__ = True - return assert_attr(self.__node, **kwargs) - - def toxml(self): - return self.__node.toxml() + return assert_attr(self._node, **kwargs) @property - def text(self): - return self.__node.childNodes[0].wholeText + def text(self) -> str: + return cast(str, self._node.childNodes[0].wholeText) @property - def tag(self): - return self.__node.tagName + def tag(self) -> str: + return self._node.tagName - @property - def next_sibling(self): - return type(self)(self.__node.nextSibling) + +class TestJunitHelpers: + """minimal test to increase coverage for methods that are used in debugging""" + + @pytest.fixture + def document(self) -> DomDocument: + doc = minidom.parseString(""" + + + + +""") + return DomDocument(doc) + + def test_uc_root(self, document: DomDocument) -> None: + assert document.get_unique_child.tag == "root" + + def test_node_assert_attr(self, document: DomDocument) -> None: + item = document.get_first_by_tag("item") + + item.assert_attr(name="a") + + with pytest.raises(AssertionError): + item.assert_attr(missing="foo") + + def test_node_getitem(self, document: DomDocument) -> None: + item = document.get_first_by_tag("item") + assert item["name"] == "a" + + with pytest.raises(KeyError, match="missing"): + item["missing"] + + def test_node_get_first_lookup(self, document: DomDocument) -> None: + with pytest.raises(LookupError, match="missing"): + document.get_first_by_tag("missing") + + def test_node_repr(self, document: DomDocument) -> None: + item = document.get_first_by_tag("item") + + assert repr(item) == item.toxml() + assert item.toxml() == '' parametrize_families = pytest.mark.parametrize("xunit_family", ["xunit1", "xunit2"]) @@ -163,7 +215,7 @@ def test_xpass(): ) result, dom = run_and_parse(family=xunit_family) assert result.ret - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(name="pytest", errors=0, failures=1, skipped=2, tests=5) @parametrize_families @@ -192,7 +244,7 @@ def test_xpass(): ) result, dom = run_and_parse(family=xunit_family) assert result.ret - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(name="pytest", errors=1, failures=2, skipped=1, tests=5) @parametrize_families @@ -206,7 +258,7 @@ def test_pass(): """ ) result, dom = run_and_parse(family=xunit_family) - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(hostname=platform.node()) @parametrize_families @@ -221,12 +273,15 @@ def test_pass(): ) start_time = datetime.now(timezone.utc) result, dom = run_and_parse(family=xunit_family) - node = dom.find_first_by_tag("testsuite") - timestamp = datetime.strptime(node["timestamp"], "%Y-%m-%dT%H:%M:%S.%f%z") + node = dom.get_first_by_tag("testsuite") + timestamp = datetime.fromisoformat(node["timestamp"]) assert start_time <= timestamp < datetime.now(timezone.utc) def test_timing_function( - self, pytester: Pytester, run_and_parse: RunAndParse, mock_timing + self, + pytester: Pytester, + run_and_parse: RunAndParse, + mock_timing: _pytest.timing.MockTiming, ) -> None: pytester.makepyfile( """ @@ -240,9 +295,10 @@ def test_sleep(): """ ) result, dom = run_and_parse() - node = dom.find_first_by_tag("testsuite") - tnode = node.find_first_by_tag("testcase") + node = dom.get_first_by_tag("testsuite") + tnode = node.get_first_by_tag("testcase") val = tnode["time"] + assert val is not None assert float(val) == 7.0 @pytest.mark.parametrize("duration_report", ["call", "total"]) @@ -256,7 +312,7 @@ def test_junit_duration_report( # mock LogXML.node_reporter so it always sets a known duration to each test report object original_node_reporter = LogXML.node_reporter - def node_reporter_wrapper(s, report): + def node_reporter_wrapper(s: Any, report: TestReport) -> Any: report.duration = 1.0 reporter = original_node_reporter(s, report) return reporter @@ -270,8 +326,8 @@ def test_foo(): """ ) result, dom = run_and_parse("-o", f"junit_duration_report={duration_report}") - node = dom.find_first_by_tag("testsuite") - tnode = node.find_first_by_tag("testcase") + node = dom.get_first_by_tag("testsuite") + tnode = node.get_first_by_tag("testcase") val = float(tnode["time"]) if duration_report == "total": assert val == 3.0 @@ -296,11 +352,11 @@ def test_function(arg): ) result, dom = run_and_parse(family=xunit_family) assert result.ret - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(errors=1, tests=1) - tnode = node.find_first_by_tag("testcase") + tnode = node.get_first_by_tag("testcase") tnode.assert_attr(classname="test_setup_error", name="test_function") - fnode = tnode.find_first_by_tag("error") + fnode = tnode.get_first_by_tag("error") fnode.assert_attr(message='failed on setup with "ValueError: Error reason"') assert "ValueError" in fnode.toxml() @@ -322,10 +378,10 @@ def test_function(arg): ) result, dom = run_and_parse(family=xunit_family) assert result.ret - node = dom.find_first_by_tag("testsuite") - tnode = node.find_first_by_tag("testcase") + node = dom.get_first_by_tag("testsuite") + tnode = node.get_first_by_tag("testcase") tnode.assert_attr(classname="test_teardown_error", name="test_function") - fnode = tnode.find_first_by_tag("error") + fnode = tnode.get_first_by_tag("error") fnode.assert_attr(message='failed on teardown with "ValueError: Error reason"') assert "ValueError" in fnode.toxml() @@ -347,15 +403,15 @@ def test_function(arg): ) result, dom = run_and_parse(family=xunit_family) assert result.ret - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(errors=1, failures=1, tests=1) first, second = dom.find_by_tag("testcase") assert first assert second assert first != second - fnode = first.find_first_by_tag("failure") + fnode = first.get_first_by_tag("failure") fnode.assert_attr(message="Exception: Call Exception") - snode = second.find_first_by_tag("error") + snode = second.get_first_by_tag("error") snode.assert_attr( message='failed on teardown with "Exception: Teardown Exception"' ) @@ -373,11 +429,11 @@ def test_skip(): ) result, dom = run_and_parse(family=xunit_family) assert result.ret == 0 - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(skipped=1) - tnode = node.find_first_by_tag("testcase") + tnode = node.get_first_by_tag("testcase") tnode.assert_attr(classname="test_skip_contains_name_reason", name="test_skip") - snode = tnode.find_first_by_tag("skipped") + snode = tnode.get_first_by_tag("skipped") snode.assert_attr(type="pytest.skip", message="hello23") @parametrize_families @@ -394,13 +450,13 @@ def test_skip(): ) result, dom = run_and_parse(family=xunit_family) assert result.ret == 0 - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(skipped=1) - tnode = node.find_first_by_tag("testcase") + tnode = node.get_first_by_tag("testcase") tnode.assert_attr( classname="test_mark_skip_contains_name_reason", name="test_skip" ) - snode = tnode.find_first_by_tag("skipped") + snode = tnode.get_first_by_tag("skipped") snode.assert_attr(type="pytest.skip", message="hello24") @parametrize_families @@ -418,13 +474,13 @@ def test_skip(): ) result, dom = run_and_parse(family=xunit_family) assert result.ret == 0 - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(skipped=1) - tnode = node.find_first_by_tag("testcase") + tnode = node.get_first_by_tag("testcase") tnode.assert_attr( classname="test_mark_skipif_contains_name_reason", name="test_skip" ) - snode = tnode.find_first_by_tag("skipped") + snode = tnode.get_first_by_tag("skipped") snode.assert_attr(type="pytest.skip", message="hello25") @parametrize_families @@ -441,7 +497,7 @@ def test_skip(): ) result, dom = run_and_parse(family=xunit_family) assert result.ret == 0 - node_xml = dom.find_first_by_tag("testsuite").toxml() + node_xml = dom.get_first_by_tag("testsuite").toxml() assert "bar!" not in node_xml @parametrize_families @@ -457,9 +513,9 @@ def test_method(self): ) result, dom = run_and_parse(family=xunit_family) assert result.ret - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(failures=1) - tnode = node.find_first_by_tag("testcase") + tnode = node.get_first_by_tag("testcase") tnode.assert_attr( classname="test_classname_instance.TestClass", name="test_method" ) @@ -472,9 +528,9 @@ def test_classname_nested_dir( p.write_text("def test_func(): 0/0", encoding="utf-8") result, dom = run_and_parse(family=xunit_family) assert result.ret - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(failures=1) - tnode = node.find_first_by_tag("testcase") + tnode = node.get_first_by_tag("testcase") tnode.assert_attr(classname="sub.test_hello", name="test_func") @parametrize_families @@ -485,11 +541,11 @@ def test_internal_error( pytester.makepyfile("def test_function(): pass") result, dom = run_and_parse(family=xunit_family) assert result.ret - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(errors=1, tests=1) - tnode = node.find_first_by_tag("testcase") + tnode = node.get_first_by_tag("testcase") tnode.assert_attr(classname="pytest", name="internal") - fnode = tnode.find_first_by_tag("error") + fnode = tnode.get_first_by_tag("error") fnode.assert_attr(message="internal error") assert "Division" in fnode.toxml() @@ -500,9 +556,9 @@ def test_internal_error( def test_failure_function( self, pytester: Pytester, - junit_logging, + junit_logging: str, run_and_parse: RunAndParse, - xunit_family, + xunit_family: str, ) -> None: pytester.makepyfile( """ @@ -522,22 +578,22 @@ def test_fail(): "-o", f"junit_logging={junit_logging}", family=xunit_family ) assert result.ret, "Expected ret > 0" - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(failures=1, tests=1) - tnode = node.find_first_by_tag("testcase") + tnode = node.get_first_by_tag("testcase") tnode.assert_attr(classname="test_failure_function", name="test_fail") - fnode = tnode.find_first_by_tag("failure") + fnode = tnode.get_first_by_tag("failure") fnode.assert_attr(message="ValueError: 42") assert "ValueError" in fnode.toxml(), "ValueError not included" if junit_logging in ["log", "all"]: - logdata = tnode.find_first_by_tag("system-out") + logdata = tnode.get_first_by_tag("system-out") log_xml = logdata.toxml() assert logdata.tag == "system-out", "Expected tag: system-out" assert "info msg" not in log_xml, "Unexpected INFO message" assert "warning msg" in log_xml, "Missing WARN message" if junit_logging in ["system-out", "out-err", "all"]: - systemout = tnode.find_first_by_tag("system-out") + systemout = tnode.get_first_by_tag("system-out") systemout_xml = systemout.toxml() assert systemout.tag == "system-out", "Expected tag: system-out" assert "info msg" not in systemout_xml, "INFO message found in system-out" @@ -545,7 +601,7 @@ def test_fail(): "Missing 'hello-stdout' in system-out" ) if junit_logging in ["system-err", "out-err", "all"]: - systemerr = tnode.find_first_by_tag("system-err") + systemerr = tnode.get_first_by_tag("system-err") systemerr_xml = systemerr.toxml() assert systemerr.tag == "system-err", "Expected tag: system-err" assert "info msg" not in systemerr_xml, "INFO message found in system-err" @@ -576,9 +632,9 @@ def test_fail(): """ ) result, dom = run_and_parse(family=xunit_family) - node = dom.find_first_by_tag("testsuite") - tnode = node.find_first_by_tag("testcase") - fnode = tnode.find_first_by_tag("failure") + node = dom.get_first_by_tag("testsuite") + tnode = node.get_first_by_tag("testcase") + fnode = tnode.get_first_by_tag("failure") fnode.assert_attr(message="AssertionError: An error\nassert 0") @parametrize_families @@ -598,15 +654,15 @@ def test_func(arg1): "-o", "junit_logging=system-out", family=xunit_family ) assert result.ret - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(failures=3, tests=3) - - for index, char in enumerate("<&'"): - tnode = node.find_nth_by_tag("testcase", index) + tnodes = node.find_by_tag("testcase") + assert len(tnodes) == 3 + for tnode, char in zip(tnodes, "<&'"): tnode.assert_attr( classname="test_failure_escape", name=f"test_func[{char}]" ) - sysout = tnode.find_first_by_tag("system-out") + sysout = tnode.get_first_by_tag("system-out") text = sysout.text assert f"{char}\n" in text @@ -625,11 +681,11 @@ def test_hello(self): ) result, dom = run_and_parse("--junitprefix=xyz", family=xunit_family) assert result.ret - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(failures=1, tests=2) - tnode = node.find_first_by_tag("testcase") + tnode = node.get_first_by_tag("testcase") tnode.assert_attr(classname="xyz.test_junit_prefixing", name="test_func") - tnode = node.find_nth_by_tag("testcase", 1) + tnode = node.find_by_tag("testcase")[1] tnode.assert_attr( classname="xyz.test_junit_prefixing.TestHello", name="test_hello" ) @@ -647,11 +703,11 @@ def test_xfail(): ) result, dom = run_and_parse(family=xunit_family) assert not result.ret - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(skipped=1, tests=1) - tnode = node.find_first_by_tag("testcase") + tnode = node.get_first_by_tag("testcase") tnode.assert_attr(classname="test_xfailure_function", name="test_xfail") - fnode = tnode.find_first_by_tag("skipped") + fnode = tnode.get_first_by_tag("skipped") fnode.assert_attr(type="pytest.xfail", message="42") @parametrize_families @@ -668,11 +724,11 @@ def test_xfail(): ) result, dom = run_and_parse(family=xunit_family) assert not result.ret - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(skipped=1, tests=1) - tnode = node.find_first_by_tag("testcase") + tnode = node.get_first_by_tag("testcase") tnode.assert_attr(classname="test_xfailure_marker", name="test_xfail") - fnode = tnode.find_first_by_tag("skipped") + fnode = tnode.get_first_by_tag("skipped") fnode.assert_attr(type="pytest.xfail", message="42") @pytest.mark.parametrize( @@ -694,17 +750,17 @@ def test_fail(): """ ) result, dom = run_and_parse("-o", f"junit_logging={junit_logging}") - node = dom.find_first_by_tag("testsuite") - tnode = node.find_first_by_tag("testcase") - if junit_logging in ["system-err", "out-err", "all"]: - assert len(tnode.find_by_tag("system-err")) == 1 - else: - assert len(tnode.find_by_tag("system-err")) == 0 + node = dom.get_first_by_tag("testsuite") + tnode = node.get_first_by_tag("testcase") - if junit_logging in ["log", "system-out", "out-err", "all"]: - assert len(tnode.find_by_tag("system-out")) == 1 - else: - assert len(tnode.find_by_tag("system-out")) == 0 + has_err_logging = junit_logging in ["system-err", "out-err", "all"] + expected_err_output_len = 1 if has_err_logging else 0 + assert len(tnode.find_by_tag("system-err")) == expected_err_output_len + + has_out_logigng = junit_logging in ("log", "system-out", "out-err", "all") + expected_out_output_len = 1 if has_out_logigng else 0 + + assert len(tnode.find_by_tag("system-out")) == expected_out_output_len @parametrize_families def test_xfailure_xpass( @@ -720,9 +776,9 @@ def test_xpass(): ) result, dom = run_and_parse(family=xunit_family) # assert result.ret - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(skipped=0, tests=1) - tnode = node.find_first_by_tag("testcase") + tnode = node.get_first_by_tag("testcase") tnode.assert_attr(classname="test_xfailure_xpass", name="test_xpass") @parametrize_families @@ -739,11 +795,11 @@ def test_xpass(): ) result, dom = run_and_parse(family=xunit_family) # assert result.ret - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(skipped=0, tests=1) - tnode = node.find_first_by_tag("testcase") + tnode = node.get_first_by_tag("testcase") tnode.assert_attr(classname="test_xfailure_xpass_strict", name="test_xpass") - fnode = tnode.find_first_by_tag("failure") + fnode = tnode.get_first_by_tag("failure") fnode.assert_attr(message="[XPASS(strict)] This needs to fail!") @parametrize_families @@ -753,10 +809,10 @@ def test_collect_error( pytester.makepyfile("syntax error") result, dom = run_and_parse(family=xunit_family) assert result.ret - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(errors=1, tests=1) - tnode = node.find_first_by_tag("testcase") - fnode = tnode.find_first_by_tag("error") + tnode = node.get_first_by_tag("testcase") + fnode = tnode.get_first_by_tag("error") fnode.assert_attr(message="collection failure") assert "SyntaxError" in fnode.toxml() @@ -772,8 +828,8 @@ def test_hello(): ) result, dom = run_and_parse() assert result.ret == 1 - tnode = dom.find_first_by_tag("testcase") - fnode = tnode.find_first_by_tag("failure") + tnode = dom.get_first_by_tag("testcase") + fnode = tnode.get_first_by_tag("failure") assert "hx" in fnode.toxml() def test_assertion_binchars( @@ -804,14 +860,14 @@ def test_pass(): """ ) result, dom = run_and_parse("-o", f"junit_logging={junit_logging}") - node = dom.find_first_by_tag("testsuite") - pnode = node.find_first_by_tag("testcase") + node = dom.get_first_by_tag("testsuite") + pnode = node.get_first_by_tag("testcase") if junit_logging == "no": assert not node.find_by_tag("system-out"), ( "system-out should not be generated" ) if junit_logging == "system-out": - systemout = pnode.find_first_by_tag("system-out") + systemout = pnode.get_first_by_tag("system-out") assert "hello-stdout" in systemout.toxml(), ( "'hello-stdout' should be in system-out" ) @@ -828,14 +884,14 @@ def test_pass(): """ ) result, dom = run_and_parse("-o", f"junit_logging={junit_logging}") - node = dom.find_first_by_tag("testsuite") - pnode = node.find_first_by_tag("testcase") + node = dom.get_first_by_tag("testsuite") + pnode = node.get_first_by_tag("testcase") if junit_logging == "no": assert not node.find_by_tag("system-err"), ( "system-err should not be generated" ) if junit_logging == "system-err": - systemerr = pnode.find_first_by_tag("system-err") + systemerr = pnode.get_first_by_tag("system-err") assert "hello-stderr" in systemerr.toxml(), ( "'hello-stderr' should be in system-err" ) @@ -857,14 +913,14 @@ def test_function(arg): """ ) result, dom = run_and_parse("-o", f"junit_logging={junit_logging}") - node = dom.find_first_by_tag("testsuite") - pnode = node.find_first_by_tag("testcase") + node = dom.get_first_by_tag("testsuite") + pnode = node.get_first_by_tag("testcase") if junit_logging == "no": assert not node.find_by_tag("system-out"), ( "system-out should not be generated" ) if junit_logging == "system-out": - systemout = pnode.find_first_by_tag("system-out") + systemout = pnode.get_first_by_tag("system-out") assert "hello-stdout" in systemout.toxml(), ( "'hello-stdout' should be in system-out" ) @@ -887,14 +943,14 @@ def test_function(arg): """ ) result, dom = run_and_parse("-o", f"junit_logging={junit_logging}") - node = dom.find_first_by_tag("testsuite") - pnode = node.find_first_by_tag("testcase") + node = dom.get_first_by_tag("testsuite") + pnode = node.get_first_by_tag("testcase") if junit_logging == "no": assert not node.find_by_tag("system-err"), ( "system-err should not be generated" ) if junit_logging == "system-err": - systemerr = pnode.find_first_by_tag("system-err") + systemerr = pnode.get_first_by_tag("system-err") assert "hello-stderr" in systemerr.toxml(), ( "'hello-stderr' should be in system-err" ) @@ -918,14 +974,14 @@ def test_function(arg): """ ) result, dom = run_and_parse("-o", f"junit_logging={junit_logging}") - node = dom.find_first_by_tag("testsuite") - pnode = node.find_first_by_tag("testcase") + node = dom.get_first_by_tag("testsuite") + pnode = node.get_first_by_tag("testcase") if junit_logging == "no": assert not node.find_by_tag("system-out"), ( "system-out should not be generated" ) if junit_logging == "system-out": - systemout = pnode.find_first_by_tag("system-out") + systemout = pnode.get_first_by_tag("system-out") assert "hello-stdout call" in systemout.toxml() assert "hello-stdout teardown" in systemout.toxml() @@ -945,12 +1001,12 @@ class FakeConfig: if TYPE_CHECKING: workerinput = None - def __init__(self): + def __init__(self) -> None: self.pluginmanager = self self.option = self self.stash = Stash() - def getini(self, name): + def getini(self, name: str) -> str: return "pytest" junitprefix = None @@ -989,11 +1045,11 @@ def repr_failure(self, excinfo): pytester.path.joinpath("myfile.xyz").write_text("hello", encoding="utf-8") result, dom = run_and_parse(family=xunit_family) assert result.ret - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(errors=0, failures=1, skipped=0, tests=1) - tnode = node.find_first_by_tag("testcase") + tnode = node.get_first_by_tag("testcase") tnode.assert_attr(name="myfile.xyz") - fnode = tnode.find_first_by_tag("failure") + fnode = tnode.get_first_by_tag("failure") fnode.assert_attr(message="custom item runtest failed") assert "custom item runtest failed" in fnode.toxml() @@ -1134,7 +1190,7 @@ def test_func(char): ) result, dom = run_and_parse() assert result.ret == 0 - node = dom.find_first_by_tag("testcase") + node = dom.get_first_by_tag("testcase") node.assert_attr(name="test_func[\\x00]") @@ -1151,7 +1207,7 @@ def test_func(param): ) result, dom = run_and_parse() assert result.ret == 0 - node = dom.find_first_by_tag("testcase") + node = dom.get_first_by_tag("testcase") node.assert_attr(classname="test_double_colon_split_function_issue469") node.assert_attr(name="test_func[double::colon]") @@ -1170,7 +1226,7 @@ def test_func(self, param): ) result, dom = run_and_parse() assert result.ret == 0 - node = dom.find_first_by_tag("testcase") + node = dom.get_first_by_tag("testcase") node.assert_attr(classname="test_double_colon_split_method_issue469.TestClass") node.assert_attr(name="test_func[double::colon]") @@ -1218,9 +1274,9 @@ def test_record(record_property, other): """ ) result, dom = run_and_parse() - node = dom.find_first_by_tag("testsuite") - tnode = node.find_first_by_tag("testcase") - psnode = tnode.find_first_by_tag("properties") + node = dom.get_first_by_tag("testsuite") + tnode = node.get_first_by_tag("testcase") + psnode = tnode.get_first_by_tag("properties") pnodes = psnode.find_by_tag("property") pnodes[0].assert_attr(name="bar", value="1") pnodes[1].assert_attr(name="foo", value="<1") @@ -1246,10 +1302,10 @@ def test_record(record_property, other): """ ) result, dom = run_and_parse() - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") tnodes = node.find_by_tag("testcase") for tnode in tnodes: - psnode = tnode.find_first_by_tag("properties") + psnode = tnode.get_first_by_tag("properties") assert psnode, f"testcase didn't had expected properties:\n{tnode}" pnodes = psnode.find_by_tag("property") pnodes[0].assert_attr(name="bar", value="1") @@ -1268,9 +1324,9 @@ def test_record_with_same_name(record_property): """ ) result, dom = run_and_parse() - node = dom.find_first_by_tag("testsuite") - tnode = node.find_first_by_tag("testcase") - psnode = tnode.find_first_by_tag("properties") + node = dom.get_first_by_tag("testsuite") + tnode = node.get_first_by_tag("testcase") + psnode = tnode.get_first_by_tag("properties") pnodes = psnode.find_by_tag("property") pnodes[0].assert_attr(name="foo", value="bar") pnodes[1].assert_attr(name="foo", value="baz") @@ -1310,8 +1366,8 @@ def test_record(record_xml_attribute, other): """ ) result, dom = run_and_parse() - node = dom.find_first_by_tag("testsuite") - tnode = node.find_first_by_tag("testcase") + node = dom.get_first_by_tag("testsuite") + tnode = node.get_first_by_tag("testcase") tnode.assert_attr(bar="1") tnode.assert_attr(foo="<1") result.stdout.fnmatch_lines( @@ -1373,7 +1429,7 @@ def test_x(i): """ ) _, dom = run_and_parse("-n2") - suite_node = dom.find_first_by_tag("testsuite") + suite_node = dom.get_first_by_tag("testsuite") failed = [] for case_node in suite_node.find_by_tag("testcase"): if case_node.find_first_by_tag("failure"): @@ -1469,7 +1525,7 @@ def test_pass(): result.stdout.no_fnmatch_line("*INTERNALERROR*") items = sorted( - "%(classname)s %(name)s" % x # noqa: UP031 + f"{x['classname']} {x['name']}" # dom is a DomNode not a mapping, it's not possible to ** it. for x in dom.find_by_tag("testcase") ) @@ -1564,10 +1620,11 @@ def test_func2(record_testsuite_property): ) result, dom = run_and_parse(family=xunit_family) assert result.ret == 0 - node = dom.find_first_by_tag("testsuite") - properties_node = node.find_first_by_tag("properties") - p1_node = properties_node.find_nth_by_tag("property", 0) - p2_node = properties_node.find_nth_by_tag("property", 1) + node = dom.get_first_by_tag("testsuite") + properties_node = node.get_first_by_tag("properties") + p1_node, p2_node = properties_node.find_by_tag( + "property", + )[:2] p1_node.assert_attr(name="stats", value="all good") p2_node.assert_attr(name="stats", value="10") @@ -1627,7 +1684,7 @@ def test_func(): ) result, dom = run_and_parse(family=xunit_family) assert result.ret == 0 - node = dom.find_first_by_tag("testsuite") + node = dom.get_first_by_tag("testsuite") node.assert_attr(name=expected) @@ -1643,8 +1700,8 @@ def test_skip(): """ ) _, dom = run_and_parse() - node = dom.find_first_by_tag("testcase") - snode = node.find_first_by_tag("skipped") + node = dom.get_first_by_tag("testcase") + snode = node.get_first_by_tag("skipped") assert "1 <> 2" in snode.text snode.assert_attr(message="1 <> 2") @@ -1660,8 +1717,8 @@ def test_skip(): """ ) _, dom = run_and_parse() - node = dom.find_first_by_tag("testcase") - snode = node.find_first_by_tag("skipped") + node = dom.get_first_by_tag("testcase") + snode = node.get_first_by_tag("skipped") assert "#x1B[31;1mred#x1B[0m" in snode.text snode.assert_attr(message="#x1B[31;1mred#x1B[0m") @@ -1682,8 +1739,8 @@ def test_esc(my_setup): """ ) _, dom = run_and_parse() - node = dom.find_first_by_tag("testcase") - snode = node.find_first_by_tag("error") + node = dom.get_first_by_tag("testcase") + snode = node.get_first_by_tag("error") assert "#x1B[31mred#x1B[m" in snode["message"] assert "#x1B[31mred#x1B[m" in snode.text @@ -1714,7 +1771,7 @@ def test_func(): ) result, dom = run_and_parse(family=xunit_family) assert result.ret == 0 - node = dom.find_first_by_tag("testcase") + node = dom.get_first_by_tag("testcase") assert len(node.find_by_tag("system-err")) == 0 assert len(node.find_by_tag("system-out")) == 0 @@ -1749,7 +1806,7 @@ def test_func(): "-o", f"junit_logging={junit_logging}", family=xunit_family ) assert result.ret == 1 - node = dom.find_first_by_tag("testcase") + node = dom.get_first_by_tag("testcase") if junit_logging == "system-out": assert len(node.find_by_tag("system-err")) == 0 assert len(node.find_by_tag("system-out")) == 1 diff --git a/testing/test_skipping.py b/testing/test_skipping.py index d1a63b1d920..57113ba93d5 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -602,13 +602,12 @@ def test_xfail_raises( self, expected, actual, matchline, pytester: Pytester ) -> None: p = pytester.makepyfile( - """ + f""" import pytest - @pytest.mark.xfail(raises=%s) + @pytest.mark.xfail(raises={expected}) def test_raises(): - raise %s() - """ # noqa: UP031 (python syntax issues) - % (expected, actual) + raise {actual}() + """ ) result = pytester.runpytest(p) result.stdout.fnmatch_lines([matchline]) @@ -900,13 +899,12 @@ def test_func(): ) def test_skipif_reporting(self, pytester: Pytester, params) -> None: p = pytester.makepyfile( - test_foo=""" + test_foo=f""" import pytest - @pytest.mark.skipif(%(params)s) + @pytest.mark.skipif({params}) def test_that(): assert 0 - """ # noqa: UP031 (python syntax issues) - % dict(params=params) + """ ) result = pytester.runpytest(p, "-s", "-rs") result.stdout.fnmatch_lines(["*SKIP*1*test_foo.py*platform*", "*1 skipped*"]) From b7854561993d00b8dddf3f43ce6b042b4111fa4c Mon Sep 17 00:00:00 2001 From: jakkdl Date: Wed, 12 Mar 2025 15:10:29 +0100 Subject: [PATCH 355/445] fix attrs==25.2.0 compatibility --- changelog/13291.bugfix.rst | 1 + src/_pytest/assertion/util.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog/13291.bugfix.rst diff --git a/changelog/13291.bugfix.rst b/changelog/13291.bugfix.rst new file mode 100644 index 00000000000..03ce06b697a --- /dev/null +++ b/changelog/13291.bugfix.rst @@ -0,0 +1 @@ +Fixed ``repr`` of ``attrs`` objects in assertion failure messages when using ``attrs>=25.2``. diff --git a/src/_pytest/assertion/util.py b/src/_pytest/assertion/util.py index 30aee185d57..c545e6cd20c 100644 --- a/src/_pytest/assertion/util.py +++ b/src/_pytest/assertion/util.py @@ -169,7 +169,7 @@ def has_default_eq( code_filename = obj.__eq__.__code__.co_filename if isattrs(obj): - return "attrs generated eq" in code_filename + return "attrs generated " in code_filename return code_filename == "" # data class return True From fc115f06ea47daa7f6bea62930c78d1e896ce92b Mon Sep 17 00:00:00 2001 From: Guillaume Gauvrit Date: Sat, 15 Mar 2025 21:34:21 +0100 Subject: [PATCH 356/445] Update additional projects list --- scripts/update-plugin-list.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/update-plugin-list.py b/scripts/update-plugin-list.py index 347952cc7e4..61debb44043 100644 --- a/scripts/update-plugin-list.py +++ b/scripts/update-plugin-list.py @@ -67,6 +67,7 @@ "nuts", "flask_fixture", "databricks-labs-pytester", + "tursu", } From 23e496bf62f5e3acdfc205e268947b19a7901425 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 16 Mar 2025 09:26:43 +0000 Subject: [PATCH 357/445] [automated] Update plugin list (#13301) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 172 ++++++++++++++++++++----------- 1 file changed, 114 insertions(+), 58 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index e8dfcc68028..6d587217dc8 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =8.2 - :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Mar 03, 2025 4 - Beta pytest>=6.2.0 + :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Mar 15, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Jul 04, 2024 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) :pypi:`pytest-async-mongodb` pytest plugin for async MongoDB Oct 18, 2017 5 - Production/Stable pytest (>=2.5.2) @@ -161,7 +161,7 @@ This list contains 1589 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Mar 07, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Mar 14, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -213,6 +213,7 @@ This list contains 1589 plugins. :pypi:`pytest-camel-collect` Enable CamelCase-aware pytest class collection Aug 02, 2020 N/A pytest (>=2.9) :pypi:`pytest-canonical-data` A plugin which allows to compare results with canonical results, based on previous runs May 08, 2020 2 - Pre-Alpha pytest (>=3.5.0) :pypi:`pytest-caprng` A plugin that replays pRNG state on failure. May 02, 2018 4 - Beta N/A + :pypi:`pytest-capsqlalchemy` Pytest plugin to allow capturing SQLAlchemy queries. Mar 14, 2025 4 - Beta N/A :pypi:`pytest-capture-deprecatedwarnings` pytest plugin to capture all deprecatedwarnings and put them in one file Apr 30, 2019 N/A N/A :pypi:`pytest-capture-warnings` pytest plugin to capture all warnings and put them in one file of your choice May 03, 2022 N/A pytest :pypi:`pytest-case` A clean, modern, wrapper for pytest.mark.parametrize Nov 25, 2024 N/A pytest<9.0.0,>=8.3.3 @@ -251,6 +252,7 @@ This list contains 1589 plugins. :pypi:`pytest-clarity` A plugin providing an alternative, colourful diff output for failing assertions. Jun 11, 2021 N/A N/A :pypi:`pytest-class-fixtures` Class as PyTest fixtures (and BDD steps) Nov 15, 2024 N/A pytest<9.0.0,>=8.3.3 :pypi:`pytest-cldf` Easy quality control for CLDF datasets using pytest Nov 07, 2022 N/A pytest (>=3.6) + :pypi:`pytest-clean-database` A pytest plugin that cleans your database up after every test. Mar 14, 2025 3 - Alpha pytest<9,>=7.0 :pypi:`pytest-cleanslate` Collects and executes pytest tests separately Sep 04, 2024 N/A pytest :pypi:`pytest_cleanup` Automated, comprehensive and well-organised pytest test cases. Jan 28, 2020 N/A N/A :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Nov 08, 2024 5 - Production/Stable N/A @@ -310,6 +312,7 @@ This list contains 1589 plugins. :pypi:`pytest-cram` Run cram tests with pytest. Aug 08, 2020 N/A N/A :pypi:`pytest-crate` Manages CrateDB instances during your integration tests May 28, 2019 3 - Alpha pytest (>=4.0) :pypi:`pytest-cratedb` Manage CrateDB instances for integration tests Oct 08, 2024 4 - Beta pytest<9 + :pypi:`pytest-cratedb-reporter` A pytest plugin for reporting test results to CrateDB Mar 11, 2025 N/A pytest>=6.0.0 :pypi:`pytest-crayons` A pytest plugin for colorful print statements Oct 08, 2023 N/A pytest :pypi:`pytest-create` pytest-create Feb 15, 2023 1 - Planning N/A :pypi:`pytest-cricri` A Cricri plugin for pytest. Jan 27, 2018 N/A pytest @@ -430,7 +433,7 @@ This list contains 1589 plugins. :pypi:`pytest-docker-registry-fixtures` Pytest fixtures for testing with docker registries. Aug 12, 2024 4 - Beta pytest :pypi:`pytest-docker-service` pytest plugin to start docker container Jan 03, 2024 3 - Alpha pytest (>=7.1.3) :pypi:`pytest-docker-squid-fixtures` Pytest fixtures for testing with squid. Aug 12, 2024 4 - Beta pytest - :pypi:`pytest-docker-tools` Docker integration tests for pytest Feb 17, 2022 4 - Beta pytest (>=6.0.1) + :pypi:`pytest-docker-tools` Docker integration tests for pytest Mar 15, 2025 4 - Beta pytest>=6.0.1 :pypi:`pytest-docs` Documentation tool for pytest Nov 11, 2018 4 - Beta pytest (>=3.5.0) :pypi:`pytest-docstyle` pytest plugin to run pydocstyle Mar 23, 2020 3 - Alpha N/A :pypi:`pytest-doctest-custom` A py.test plugin for customizing string representations of doctest results. Jul 25, 2016 4 - Beta N/A @@ -476,15 +479,15 @@ This list contains 1589 plugins. :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Mar 03, 2025 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Mar 03, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Mar 03, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Mar 03, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Mar 03, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Mar 03, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Mar 03, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Mar 03, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Mar 03, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Mar 13, 2025 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Mar 13, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Mar 13, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Mar 13, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Mar 13, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Mar 13, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Mar 13, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Mar 13, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Mar 13, 2025 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -537,6 +540,7 @@ This list contains 1589 plugins. :pypi:`pytest-exploratory` Interactive console for pytest. Sep 18, 2024 N/A pytest>=6.2 :pypi:`pytest-explorer` terminal ui for exploring and running tests Aug 01, 2023 N/A N/A :pypi:`pytest-ext` pytest plugin for automation test Mar 31, 2024 N/A pytest>=5.3 + :pypi:`pytest-extended-mock` a pytest extension for easy mock setup Mar 12, 2025 N/A pytest<9.0.0,>=8.3.5 :pypi:`pytest-extensions` A collection of helpers for pytest to ease testing Aug 17, 2022 4 - Beta pytest ; extra == 'testing' :pypi:`pytest-external-blockers` a special outcome for tests that are blocked for external reasons Oct 05, 2021 N/A pytest :pypi:`pytest_extra` Some helpers for writing tests with pytest. Aug 14, 2014 N/A N/A @@ -603,7 +607,7 @@ This list contains 1589 plugins. :pypi:`pytest-flexreport` Apr 15, 2023 4 - Beta pytest :pypi:`pytest-fluent` A pytest plugin in order to provide logs via fluentd Aug 14, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-fluentbit` A pytest plugin in order to provide logs via fluentbit Jun 16, 2023 4 - Beta pytest (>=7.0.0) - :pypi:`pytest-fly` pytest observer Feb 28, 2025 3 - Alpha pytest + :pypi:`pytest-fly` pytest runner and observer Mar 13, 2025 3 - Alpha pytest :pypi:`pytest-flyte` Pytest fixtures for simplifying Flyte integration testing May 03, 2021 N/A pytest :pypi:`pytest-focus` A pytest plugin that alerts user of failed test cases with screen notifications May 04, 2019 4 - Beta pytest :pypi:`pytest-forbid` Mar 07, 2023 N/A pytest (>=7.2.2,<8.0.0) @@ -678,7 +682,7 @@ This list contains 1589 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Mar 08, 2025 3 - Alpha pytest==8.3.4 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Mar 15, 2025 3 - Alpha pytest==8.3.4 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -752,7 +756,7 @@ This list contains 1589 plugins. :pypi:`pytest-iovis` A Pytest plugin to enable Jupyter Notebook testing with Papermill Nov 06, 2024 4 - Beta pytest>=7.1.0 :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A - :pypi:`pytest-ipynb2` Pytest plugin to run tests in Jupyter Notebooks Mar 03, 2025 N/A pytest + :pypi:`pytest-ipynb2` Pytest plugin to run tests in Jupyter Notebooks Mar 09, 2025 N/A pytest :pypi:`pytest-ipywidgets` Feb 18, 2025 N/A pytest :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Jan 16, 2025 4 - Beta pytest :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Feb 24, 2025 4 - Beta pytest>=5 @@ -848,11 +852,12 @@ This list contains 1589 plugins. :pypi:`pytest-loguru` Pytest Loguru Mar 20, 2024 5 - Production/Stable pytest; extra == "test" :pypi:`pytest-loop` pytest plugin for looping tests Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-lsp` A pytest plugin for end-to-end testing of language servers Nov 23, 2024 3 - Alpha pytest + :pypi:`pytest-lw-realtime-result` Pytest plugin to generate realtime test results to a file Mar 13, 2025 N/A pytest>=3.5.0 :pypi:`pytest-manual-marker` pytest marker for marking manual tests Aug 04, 2022 3 - Alpha pytest>=7 :pypi:`pytest-mark-count` Get a count of the number of tests marked, unmarked, and unique tests if tests have multiple markers Nov 13, 2024 4 - Beta pytest>=8.0.0 :pypi:`pytest-markdoctest` A pytest plugin to doctest your markdown files Jul 22, 2022 4 - Beta pytest (>=6) :pypi:`pytest-markdown` Test your markdown docs with pytest Jan 15, 2021 4 - Beta pytest (>=6.0.1,<7.0.0) - :pypi:`pytest-markdown-docs` Run markdown code fences through pytest Nov 28, 2024 N/A pytest>=7.0.0 + :pypi:`pytest-markdown-docs` Run markdown code fences through pytest Mar 13, 2025 N/A pytest>=7.0.0 :pypi:`pytest-marker-bugzilla` py.test bugzilla integration plugin, using markers Jan 09, 2020 N/A N/A :pypi:`pytest-markers-presence` A simple plugin to detect missed pytest tags and markers" Oct 30, 2024 4 - Beta pytest>=6.0 :pypi:`pytest-markfiltration` UNKNOWN Nov 08, 2011 3 - Alpha N/A @@ -878,7 +883,7 @@ This list contains 1589 plugins. :pypi:`pytest-memray` A simple plugin to use with pytest Jul 25, 2024 N/A pytest>=7.2 :pypi:`pytest-menu` A pytest plugin for console based interactive test selection just after the collection phase Oct 04, 2017 3 - Alpha pytest (>=2.4.2) :pypi:`pytest-mercurial` pytest plugin to write integration tests for projects using Mercurial Python internals Nov 21, 2020 1 - Planning N/A - :pypi:`pytest-mergify` Pytest plugin for Mergify Feb 19, 2025 N/A N/A + :pypi:`pytest-mergify` Pytest plugin for Mergify Mar 14, 2025 N/A N/A :pypi:`pytest-mesh` pytest_mesh插件 Aug 05, 2022 N/A pytest (==7.1.2) :pypi:`pytest-message` Pytest plugin for sending report message of marked tests execution Aug 04, 2022 N/A pytest (>=6.2.5) :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A @@ -900,7 +905,7 @@ This list contains 1589 plugins. :pypi:`pytest-mock-helper` Help you mock HTTP call and generate mock code Jan 24, 2018 N/A pytest :pypi:`pytest-mockito` Base fixtures for mockito Jul 11, 2018 4 - Beta N/A :pypi:`pytest-mockredis` An in-memory mock of a Redis server that runs in a separate thread. This is to be used for unit-tests that require a Redis database. Jan 02, 2018 2 - Pre-Alpha N/A - :pypi:`pytest-mock-resources` A pytest plugin for easily instantiating reproducible mock resources. Sep 17, 2024 N/A pytest>=1.0 + :pypi:`pytest-mock-resources` A pytest plugin for easily instantiating reproducible mock resources. Mar 10, 2025 N/A pytest>=1.0 :pypi:`pytest-mock-server` Mock server plugin for pytest Jan 09, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-mockservers` A set of fixtures to test your requests to HTTP/UDP servers Mar 31, 2020 N/A pytest (>=4.3.0) :pypi:`pytest-mocktcp` A pytest plugin for testing TCP clients Oct 11, 2022 N/A pytest @@ -974,7 +979,7 @@ This list contains 1589 plugins. :pypi:`pytest-object-getter` Import any object from a 3rd party module while mocking its namespace on demand. Jul 31, 2022 5 - Production/Stable pytest :pypi:`pytest-ochrus` pytest results data-base and HTML reporter Feb 21, 2018 4 - Beta N/A :pypi:`pytest-odc` A pytest plugin for simplifying ODC database tests Aug 04, 2023 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-odoo` py.test plugin to run Odoo tests Oct 08, 2024 5 - Production/Stable pytest>=8 + :pypi:`pytest-odoo` py.test plugin to run Odoo tests Mar 12, 2025 5 - Production/Stable pytest>=8 :pypi:`pytest-odoo-fixtures` Project description Jun 25, 2019 N/A N/A :pypi:`pytest-oerp` pytest plugin to test OpenERP modules Feb 28, 2012 3 - Alpha N/A :pypi:`pytest-offline` Mar 09, 2023 1 - Planning pytest (>=7.0.0,<8.0.0) @@ -1182,7 +1187,7 @@ This list contains 1589 plugins. :pypi:`pytest-repeat` pytest plugin for repeating tests Oct 09, 2023 5 - Production/Stable pytest :pypi:`pytest_repeater` py.test plugin for repeating single test multiple times. Feb 09, 2018 1 - Planning N/A :pypi:`pytest-replay` Saves previous test runs and allow re-execute previous pytest runs to reproduce crashes or flaky tests Feb 05, 2025 5 - Production/Stable pytest - :pypi:`pytest-repo-health` A pytest plugin to report on repository standards conformance Apr 17, 2023 3 - Alpha pytest + :pypi:`pytest-repo-health` A pytest plugin to report on repository standards conformance Mar 12, 2025 3 - Alpha pytest :pypi:`pytest-report` Creates json report that is compatible with atom.io's linter message format May 11, 2016 4 - Beta N/A :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Oct 11, 2024 4 - Beta N/A @@ -1219,8 +1224,10 @@ This list contains 1589 plugins. :pypi:`pytest-rest-api` Aug 08, 2022 N/A pytest (>=7.1.2,<8.0.0) :pypi:`pytest-restrict` Pytest plugin to restrict the test types allowed Oct 24, 2024 5 - Production/Stable pytest :pypi:`pytest-result-log` A pytest plugin that records the start, end, and result information of each use case in a log file Jan 10, 2024 N/A pytest>=7.2.0 + :pypi:`pytest-results` Easily spot regressions in your tests. Mar 14, 2025 4 - Beta pytest :pypi:`pytest-result-sender` Apr 20, 2023 N/A pytest>=7.3.1 :pypi:`pytest-result-sender-lj` Default template for PDM package Dec 17, 2024 N/A pytest>=8.3.4 + :pypi:`pytest-result-sender-lyt` Default template for PDM package Mar 14, 2025 N/A pytest>=8.3.5 :pypi:`pytest-resume` A Pytest plugin to resuming from the last run test Apr 22, 2023 4 - Beta pytest (>=7.0) :pypi:`pytest-rethinkdb` A RethinkDB plugin for pytest. Jul 24, 2016 4 - Beta N/A :pypi:`pytest-retry` Adds the ability to retry flaky tests in CI environments Jan 19, 2025 N/A pytest>=7.0.0 @@ -1262,7 +1269,7 @@ This list contains 1589 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Mar 07, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Mar 12, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1274,7 +1281,7 @@ This list contains 1589 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Mar 07, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Mar 12, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1284,7 +1291,7 @@ This list contains 1589 plugins. :pypi:`pytest-server` test server exec cmd Sep 09, 2024 N/A N/A :pypi:`pytest-server-fixtures` Extensible server fixtures for py.test Nov 29, 2024 5 - Production/Stable pytest :pypi:`pytest-serverless` Automatically mocks resources from serverless.yml in pytest using moto. May 09, 2022 4 - Beta N/A - :pypi:`pytest-servers` pytest servers Dec 29, 2024 3 - Alpha pytest>=6.2 + :pypi:`pytest-servers` pytest servers Mar 12, 2025 3 - Alpha pytest>=6.2 :pypi:`pytest-service` Aug 06, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-services` Services plugin for pytest testing framework Oct 30, 2020 6 - Mature N/A :pypi:`pytest-session2file` pytest-session2file (aka: pytest-session_to_file for v0.1.0 - v0.1.2) is a py.test plugin for capturing and saving to file the stdout of py.test. Jan 26, 2021 3 - Alpha pytest @@ -1365,7 +1372,7 @@ This list contains 1589 plugins. :pypi:`pytest-sqlalchemy-session` A pytest plugin for preserving test isolation that use SQLAlchemy. May 19, 2023 4 - Beta pytest (>=7.0) :pypi:`pytest-sql-bigquery` Yet another SQL-testing framework for BigQuery provided by pytest plugin Dec 19, 2019 N/A pytest :pypi:`pytest-sqlfluff` A pytest plugin to use sqlfluff to enable format checking of sql files. Dec 21, 2022 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-sqlguard` Pytest fixture to record and check SQL Queries made by SQLAlchemy Mar 06, 2025 4 - Beta pytest>=7 + :pypi:`pytest-sqlguard` Pytest fixture to record and check SQL Queries made by SQLAlchemy Mar 11, 2025 4 - Beta pytest>=7 :pypi:`pytest-squadcast` Pytest report plugin for Squadcast Feb 22, 2022 5 - Production/Stable pytest :pypi:`pytest-srcpaths` Add paths to sys.path Oct 15, 2021 N/A pytest>=6.2.0 :pypi:`pytest-ssh` pytest plugin for ssh command run May 27, 2019 N/A pytest @@ -1531,7 +1538,7 @@ This list contains 1589 plugins. :pypi:`pytest-unmarked` Run only unmarked tests Aug 27, 2019 5 - Production/Stable N/A :pypi:`pytest-unordered` Test equality of unordered collections in pytest Jul 05, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-unstable` Set a test as unstable to return 0 even if it failed Sep 27, 2022 4 - Beta N/A - :pypi:`pytest-unused-fixtures` A pytest plugin to list unused fixtures after a test run. Apr 08, 2024 4 - Beta pytest>7.3.2 + :pypi:`pytest-unused-fixtures` A pytest plugin to list unused fixtures after a test run. Mar 15, 2025 4 - Beta pytest>7.3.2 :pypi:`pytest-upload-report` pytest-upload-report is a plugin for pytest that upload your test report for test results. Jun 18, 2021 5 - Production/Stable N/A :pypi:`pytest-utils` Some helpers for pytest. Feb 02, 2023 4 - Beta pytest (>=7.0.0,<8.0.0) :pypi:`pytest-vagrant` A py.test plugin providing access to vagrant. Sep 07, 2021 5 - Production/Stable pytest @@ -1581,7 +1588,7 @@ This list contains 1589 plugins. :pypi:`pytest-xdist-debug-for-graingert` pytest xdist plugin for distributed testing and loop-on-failing modes Jul 24, 2019 5 - Production/Stable pytest (>=4.4.0) :pypi:`pytest-xdist-forked` forked from pytest-xdist Feb 10, 2020 5 - Production/Stable pytest (>=4.4.0) :pypi:`pytest-xdist-tracker` pytest plugin helps to reproduce failures for particular xdist node Nov 18, 2021 3 - Alpha pytest (>=3.5.1) - :pypi:`pytest-xdist-worker-stats` A pytest plugin to list worker statistics after a xdist run. Apr 16, 2024 4 - Beta pytest>=7.0.0 + :pypi:`pytest-xdist-worker-stats` A pytest plugin to list worker statistics after a xdist run. Mar 15, 2025 4 - Beta pytest>=7.0.0 :pypi:`pytest-xdocker` Pytest fixture to run docker across test runs. Mar 07, 2025 N/A pytest<8.0.0,>=7.4.2 :pypi:`pytest-xfaillist` Maintain a xfaillist in an additional file to avoid merge-conflicts. Sep 17, 2021 N/A pytest (>=6.2.2,<7.0.0) :pypi:`pytest-xfiles` Pytest fixtures providing data read from function, module or package related (x)files. Feb 27, 2018 N/A N/A @@ -1597,7 +1604,7 @@ This list contains 1589 plugins. :pypi:`pytest-xray-server` May 03, 2022 3 - Alpha pytest (>=5.3.1) :pypi:`pytest-xskynet` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A :pypi:`pytest-xstress` Jun 01, 2024 N/A pytest<9.0.0,>=8.0.0 - :pypi:`pytest-xvfb` A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. May 29, 2023 4 - Beta pytest (>=2.8.1) + :pypi:`pytest-xvfb` A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. Mar 12, 2025 4 - Beta pytest>=2.8.1 :pypi:`pytest-xvirt` A pytest plugin to virtualize test. For example to transparently running them on a remote box. Dec 15, 2024 4 - Beta pytest>=7.2.2 :pypi:`pytest-yaml` This plugin is used to load yaml output to your test using pytest framework. Oct 05, 2018 N/A pytest :pypi:`pytest-yaml-fei` a pytest yaml allure package Feb 09, 2025 N/A pytest @@ -2217,7 +2224,7 @@ This list contains 1589 plugins. Pytest support for asyncio :pypi:`pytest-asyncio-concurrent` - *last release*: Mar 03, 2025, + *last release*: Mar 15, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -2518,7 +2525,7 @@ This list contains 1589 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Mar 07, 2025, + *last release*: Mar 14, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -2881,6 +2888,13 @@ This list contains 1589 plugins. A plugin that replays pRNG state on failure. + :pypi:`pytest-capsqlalchemy` + *last release*: Mar 14, 2025, + *status*: 4 - Beta, + *requires*: N/A + + Pytest plugin to allow capturing SQLAlchemy queries. + :pypi:`pytest-capture-deprecatedwarnings` *last release*: Apr 30, 2019, *status*: N/A, @@ -3147,6 +3161,13 @@ This list contains 1589 plugins. Easy quality control for CLDF datasets using pytest + :pypi:`pytest-clean-database` + *last release*: Mar 14, 2025, + *status*: 3 - Alpha, + *requires*: pytest<9,>=7.0 + + A pytest plugin that cleans your database up after every test. + :pypi:`pytest-cleanslate` *last release*: Sep 04, 2024, *status*: N/A, @@ -3560,6 +3581,13 @@ This list contains 1589 plugins. Manage CrateDB instances for integration tests + :pypi:`pytest-cratedb-reporter` + *last release*: Mar 11, 2025, + *status*: N/A, + *requires*: pytest>=6.0.0 + + A pytest plugin for reporting test results to CrateDB + :pypi:`pytest-crayons` *last release*: Oct 08, 2023, *status*: N/A, @@ -4401,9 +4429,9 @@ This list contains 1589 plugins. Pytest fixtures for testing with squid. :pypi:`pytest-docker-tools` - *last release*: Feb 17, 2022, + *last release*: Mar 15, 2025, *status*: 4 - Beta, - *requires*: pytest (>=6.0.1) + *requires*: pytest>=6.0.1 Docker integration tests for pytest @@ -4723,63 +4751,63 @@ This list contains 1589 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: Mar 03, 2025, + *last release*: Mar 13, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: Mar 03, 2025, + *last release*: Mar 13, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: Mar 03, 2025, + *last release*: Mar 13, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: Mar 03, 2025, + *last release*: Mar 13, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. :pypi:`pytest-embedded-nuttx` - *last release*: Mar 03, 2025, + *last release*: Mar 13, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with NuttX. :pypi:`pytest-embedded-qemu` - *last release*: Mar 03, 2025, + *last release*: Mar 13, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: Mar 03, 2025, + *last release*: Mar 13, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: Mar 03, 2025, + *last release*: Mar 13, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: Mar 03, 2025, + *last release*: Mar 13, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -5149,6 +5177,13 @@ This list contains 1589 plugins. pytest plugin for automation test + :pypi:`pytest-extended-mock` + *last release*: Mar 12, 2025, + *status*: N/A, + *requires*: pytest<9.0.0,>=8.3.5 + + a pytest extension for easy mock setup + :pypi:`pytest-extensions` *last release*: Aug 17, 2022, *status*: 4 - Beta, @@ -5612,11 +5647,11 @@ This list contains 1589 plugins. A pytest plugin in order to provide logs via fluentbit :pypi:`pytest-fly` - *last release*: Feb 28, 2025, + *last release*: Mar 13, 2025, *status*: 3 - Alpha, *requires*: pytest - pytest observer + pytest runner and observer :pypi:`pytest-flyte` *last release*: May 03, 2021, @@ -6137,7 +6172,7 @@ This list contains 1589 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Mar 08, 2025, + *last release*: Mar 15, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.4 @@ -6655,7 +6690,7 @@ This list contains 1589 plugins. THIS PROJECT IS ABANDONED :pypi:`pytest-ipynb2` - *last release*: Mar 03, 2025, + *last release*: Mar 09, 2025, *status*: N/A, *requires*: pytest @@ -7326,6 +7361,13 @@ This list contains 1589 plugins. A pytest plugin for end-to-end testing of language servers + :pypi:`pytest-lw-realtime-result` + *last release*: Mar 13, 2025, + *status*: N/A, + *requires*: pytest>=3.5.0 + + Pytest plugin to generate realtime test results to a file + :pypi:`pytest-manual-marker` *last release*: Aug 04, 2022, *status*: 3 - Alpha, @@ -7355,7 +7397,7 @@ This list contains 1589 plugins. Test your markdown docs with pytest :pypi:`pytest-markdown-docs` - *last release*: Nov 28, 2024, + *last release*: Mar 13, 2025, *status*: N/A, *requires*: pytest>=7.0.0 @@ -7537,7 +7579,7 @@ This list contains 1589 plugins. pytest plugin to write integration tests for projects using Mercurial Python internals :pypi:`pytest-mergify` - *last release*: Feb 19, 2025, + *last release*: Mar 14, 2025, *status*: N/A, *requires*: N/A @@ -7691,7 +7733,7 @@ This list contains 1589 plugins. An in-memory mock of a Redis server that runs in a separate thread. This is to be used for unit-tests that require a Redis database. :pypi:`pytest-mock-resources` - *last release*: Sep 17, 2024, + *last release*: Mar 10, 2025, *status*: N/A, *requires*: pytest>=1.0 @@ -8209,7 +8251,7 @@ This list contains 1589 plugins. A pytest plugin for simplifying ODC database tests :pypi:`pytest-odoo` - *last release*: Oct 08, 2024, + *last release*: Mar 12, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=8 @@ -9665,7 +9707,7 @@ This list contains 1589 plugins. Saves previous test runs and allow re-execute previous pytest runs to reproduce crashes or flaky tests :pypi:`pytest-repo-health` - *last release*: Apr 17, 2023, + *last release*: Mar 12, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -9923,6 +9965,13 @@ This list contains 1589 plugins. A pytest plugin that records the start, end, and result information of each use case in a log file + :pypi:`pytest-results` + *last release*: Mar 14, 2025, + *status*: 4 - Beta, + *requires*: pytest + + Easily spot regressions in your tests. + :pypi:`pytest-result-sender` *last release*: Apr 20, 2023, *status*: N/A, @@ -9937,6 +9986,13 @@ This list contains 1589 plugins. Default template for PDM package + :pypi:`pytest-result-sender-lyt` + *last release*: Mar 14, 2025, + *status*: N/A, + *requires*: pytest>=8.3.5 + + Default template for PDM package + :pypi:`pytest-resume` *last release*: Apr 22, 2023, *status*: 4 - Beta, @@ -10225,7 +10281,7 @@ This list contains 1589 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Mar 07, 2025, + *last release*: Mar 12, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10309,7 +10365,7 @@ This list contains 1589 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Mar 07, 2025, + *last release*: Mar 12, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10379,7 +10435,7 @@ This list contains 1589 plugins. Automatically mocks resources from serverless.yml in pytest using moto. :pypi:`pytest-servers` - *last release*: Dec 29, 2024, + *last release*: Mar 12, 2025, *status*: 3 - Alpha, *requires*: pytest>=6.2 @@ -10946,7 +11002,7 @@ This list contains 1589 plugins. A pytest plugin to use sqlfluff to enable format checking of sql files. :pypi:`pytest-sqlguard` - *last release*: Mar 06, 2025, + *last release*: Mar 11, 2025, *status*: 4 - Beta, *requires*: pytest>=7 @@ -12108,7 +12164,7 @@ This list contains 1589 plugins. Set a test as unstable to return 0 even if it failed :pypi:`pytest-unused-fixtures` - *last release*: Apr 08, 2024, + *last release*: Mar 15, 2025, *status*: 4 - Beta, *requires*: pytest>7.3.2 @@ -12458,7 +12514,7 @@ This list contains 1589 plugins. pytest plugin helps to reproduce failures for particular xdist node :pypi:`pytest-xdist-worker-stats` - *last release*: Apr 16, 2024, + *last release*: Mar 15, 2025, *status*: 4 - Beta, *requires*: pytest>=7.0.0 @@ -12570,9 +12626,9 @@ This list contains 1589 plugins. :pypi:`pytest-xvfb` - *last release*: May 29, 2023, + *last release*: Mar 12, 2025, *status*: 4 - Beta, - *requires*: pytest (>=2.8.1) + *requires*: pytest>=2.8.1 A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. From 21257689662aee77fe237fb070d006be9f4d6fe6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 06:49:22 +0100 Subject: [PATCH 358/445] build(deps): Bump anyio[trio] in /testing/plugins_integration (#13303) Bumps [anyio[trio]](https://github.com/agronholm/anyio) from 4.8.0 to 4.9.0. - [Release notes](https://github.com/agronholm/anyio/releases) - [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst) - [Commits](https://github.com/agronholm/anyio/compare/4.8.0...4.9.0) --- updated-dependencies: - dependency-name: anyio[trio] dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 437df4dc2d1..bf0a87129eb 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,4 +1,4 @@ -anyio[trio]==4.8.0 +anyio[trio]==4.9.0 django==5.1.7 pytest-asyncio==0.25.3 pytest-bdd==8.1.0 From 9666efad756bd9fa123d7ffc69ad34ef0b2f7c71 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Mar 2025 06:50:00 +0100 Subject: [PATCH 359/445] build(deps): Bump pytest-xvfb in /testing/plugins_integration (#13302) Bumps [pytest-xvfb](https://github.com/The-Compiler/pytest-xvfb) from 3.0.0 to 3.1.1. - [Changelog](https://github.com/The-Compiler/pytest-xvfb/blob/master/CHANGELOG.rst) - [Commits](https://github.com/The-Compiler/pytest-xvfb/compare/v3.0.0...v3.1.1) --- updated-dependencies: - dependency-name: pytest-xvfb dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index bf0a87129eb..66ed13a4b8a 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -12,4 +12,4 @@ pytest-sugar==1.0.0 pytest-trio==0.8.0 pytest-twisted==1.14.3 twisted==24.11.0 -pytest-xvfb==3.0.0 +pytest-xvfb==3.1.1 From e34fc6205a7c3397378e0d9a35ee2e7cfd531d9b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 21 Mar 2025 13:31:58 +0100 Subject: [PATCH 360/445] [pre-commit.ci] pre-commit autoupdate (#13306) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.9.10 → v0.11.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.10...v0.11.0) - [github.com/woodruffw/zizmor-pre-commit: v1.4.1 → v1.5.1](https://github.com/woodruffw/zizmor-pre-commit/compare/v1.4.1...v1.5.1) * [lint] Put noqa in pyproject.toml or locally if possible Co-authored-by: Pierre Sassoulas --- .pre-commit-config.yaml | 4 ++-- pyproject.toml | 4 ++++ src/_pytest/raises_group.py | 18 +++++++----------- testing/_py/test_local.py | 2 +- testing/code/test_source.py | 11 ++++------- 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index be0fa02399b..56ee45b4c61 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.9.10" + rev: "v0.11.0" hooks: - id: ruff args: ["--fix"] @@ -12,7 +12,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/woodruffw/zizmor-pre-commit - rev: v1.4.1 + rev: v1.5.1 hooks: - id: zizmor - repo: https://github.com/adamchainz/blacken-docs diff --git a/pyproject.toml b/pyproject.toml index 263e0c23836..0cbf0a26027 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -167,6 +167,10 @@ lint.per-file-ignores."src/_pytest/_py/**/*.py" = [ lint.per-file-ignores."src/_pytest/_version.py" = [ "I001", ] +# can't be disabled on a line-by-line basis in file +lint.per-file-ignores."testing/code/test_source.py" = [ + "F841", +] lint.per-file-ignores."testing/python/approx.py" = [ "B015", ] diff --git a/src/_pytest/raises_group.py b/src/_pytest/raises_group.py index 51ab8aafaf4..010b8b9f629 100644 --- a/src/_pytest/raises_group.py +++ b/src/_pytest/raises_group.py @@ -119,12 +119,9 @@ def _check_raw_type( def is_fully_escaped(s: str) -> bool: # we know we won't compile with re.VERBOSE, so whitespace doesn't need to be escaped metacharacters = "{}()+.*?^$[]" - - for i, c in enumerate(s): - if c in metacharacters and (i == 0 or s[i - 1] != "\\"): - return False - - return True + return not any( + c in metacharacters and (i == 0 or s[i - 1] != "\\") for (i, c) in enumerate(s) + ) def unescape(s: str) -> str: @@ -1198,8 +1195,7 @@ def possible_match(results: ResultHolder, used: set[int] | None = None) -> bool: curr_row = len(used) if curr_row == len(results.results): return True - - for i, val in enumerate(results.results[curr_row]): - if val is None and i not in used and possible_match(results, used | {i}): - return True - return False + return any( + val is None and i not in used and possible_match(results, used | {i}) + for (i, val) in enumerate(results.results[curr_row]) + ) diff --git a/testing/_py/test_local.py b/testing/_py/test_local.py index 461b0b599c1..03a828c64f0 100644 --- a/testing/_py/test_local.py +++ b/testing/_py/test_local.py @@ -215,7 +215,7 @@ def test_visit_filterfunc_is_string(self, path1, fil): lst = [] for i in path1.visit(fil): lst.append(i.relto(path1)) - assert len(lst), 2 + assert len(lst), 2 # noqa: PLC1802,RUF040 assert "sampledir" in lst assert "otherdir" in lst diff --git a/testing/code/test_source.py b/testing/code/test_source.py index 843233fe21e..321372d4b59 100644 --- a/testing/code/test_source.py +++ b/testing/code/test_source.py @@ -1,21 +1,19 @@ # mypy: allow-untyped-defs -# flake8: noqa -# disable flake check on this file because some constructs are strange -# or redundant on purpose and can't be disable on a line-by-line basis +from __future__ import annotations + import inspect import linecache +from pathlib import Path import sys import textwrap -from pathlib import Path from typing import Any -from typing import Dict -import pytest from _pytest._code import Code from _pytest._code import Frame from _pytest._code import getfslineno from _pytest._code import Source from _pytest.pathlib import import_path +import pytest def test_source_str_function() -> None: @@ -464,7 +462,6 @@ def test_comment_in_statement() -> None: def test_source_with_decorator() -> None: """Test behavior with Source / Code().source with regard to decorators.""" - from _pytest.compat import get_real_func @pytest.mark.foo def deco_mark(): From 8e772b90d409729e38863dc2e3bbc23b1e1ae3f4 Mon Sep 17 00:00:00 2001 From: Nick Murphy Date: Sat, 22 Mar 2025 15:55:01 -0400 Subject: [PATCH 361/445] Specify minimum requirements for dependencies (#13317) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Specifies minimum allowed versions of `colorama`, `iniconfig`, and `packaging`, and bumps the minimum requirement of `exceptiongroup` to no longer be a release candidate. This specifies minimum allowed versions that are several years old, but these can be changed to be more recent. ## Motivation [`uv`](https://docs.astral.sh/uv/) has multiple dependency [resolution strategies](https://docs.astral.sh/uv/concepts/resolution/#resolution-strategy): - `lowest` will install the lowest allowed version for _all_ dependencies, both direct and indirect (transitive). - `lowest-direct` will use the lowest compatible versions for all _direct_ dependencies, while using the latest compatible versions for all other dependencies. Up until now, `pytest` has not specified the minimum allowed versions of multiple dependencies in `pyproject.toml`. When I ran `uv pip install pytest==8.3.5 --resolution=lowest` in a fresh virtual environment, it installed `packaging==14.0` (released in 2014 👀) and `iniconfig==0.1` (released in 2010 😅). It's a fairly common practice in the scientific pythoniverse to run tests against the oldest versions of dependencies. In practice, using `uv`'s `lowest` dependency resolution strategy results the first release of certain indirect dependencies being installed, like `v0.0.0.1`. Specifying lower bounds will make it a lot more practical for `pytest` users to test against the oldest allowed versions of both indirect and direct dependencies. --- changelog/13317.packaging.rst | 4 ++++ pyproject.toml | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 changelog/13317.packaging.rst diff --git a/changelog/13317.packaging.rst b/changelog/13317.packaging.rst new file mode 100644 index 00000000000..94171cb1ef3 --- /dev/null +++ b/changelog/13317.packaging.rst @@ -0,0 +1,4 @@ +Specified minimum allowed versions of ``colorama``, ``iniconfig``, +and ``packaging``; and bumped the minimum allowed version +of ``exceptiongroup`` for ``python_version<'3.11'`` from a release +candidate to a full release. diff --git a/pyproject.toml b/pyproject.toml index 0cbf0a26027..c7db5947cf4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,10 +46,10 @@ dynamic = [ "version", ] dependencies = [ - "colorama; sys_platform=='win32'", - "exceptiongroup>=1.0.0rc8; python_version<'3.11'", - "iniconfig", - "packaging", + "colorama>=0.4; sys_platform=='win32'", + "exceptiongroup>=1; python_version<'3.11'", + "iniconfig>=1", + "packaging>=20", "pluggy>=1.5,<2", "pygments>=2.7.2", "tomli>=1; python_version<'3.11'", From 252cf3bf8f568e5a7a8b97e7cf1c2b98824c64bb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 23 Mar 2025 18:12:04 +0100 Subject: [PATCH 362/445] [automated] Update plugin list (#13323) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 200 ++++++++++++++++++++++++------- 1 file changed, 156 insertions(+), 44 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 6d587217dc8..3e653676d69 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =7.2 :pypi:`pytest-argus` pyest results colection plugin Jun 24, 2021 5 - Production/Stable pytest (>=6.2.4) + :pypi:`pytest-argus-server` A plugin that provides a running Argus API server for tests Mar 20, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-arraydiff` pytest plugin to help with comparing array output from tests Nov 27, 2023 4 - Beta pytest >=4.6 :pypi:`pytest-asgi-server` Convenient ASGI client/server fixtures for Pytest Dec 12, 2020 N/A pytest (>=5.4.1) :pypi:`pytest-aspec` A rspec format reporter for pytest Dec 20, 2023 4 - Beta N/A @@ -107,7 +108,7 @@ This list contains 1596 plugins. :pypi:`pytest-assertions` Pytest Assertions Apr 27, 2022 N/A N/A :pypi:`pytest-assertutil` pytest-assertutil May 10, 2019 N/A N/A :pypi:`pytest-assert-utils` Useful assertion utilities for use with pytest Apr 14, 2022 3 - Alpha N/A - :pypi:`pytest-assist` load testing library Jun 24, 2024 N/A pytest + :pypi:`pytest-assist` load testing library Mar 17, 2025 N/A pytest :pypi:`pytest-assume` A pytest plugin that allows multiple failures per test Jun 24, 2021 N/A pytest (>=2.7) :pypi:`pytest-assurka` A pytest plugin for Assurka Studio Aug 04, 2022 N/A N/A :pypi:`pytest-ast-back-to-python` A plugin for pytest devs to view how assertion rewriting recodes the AST Sep 29, 2019 4 - Beta N/A @@ -118,7 +119,7 @@ This list contains 1596 plugins. :pypi:`pytest_async` pytest-async - Run your coroutine in event loop without decorator Feb 26, 2020 N/A N/A :pypi:`pytest-async-generators` Pytest fixtures for async generators Jul 05, 2023 N/A N/A :pypi:`pytest-asyncio` Pytest support for asyncio Jan 28, 2025 4 - Beta pytest<9,>=8.2 - :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Mar 15, 2025 4 - Beta pytest>=6.2.0 + :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Mar 16, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Jul 04, 2024 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) :pypi:`pytest-async-mongodb` pytest plugin for async MongoDB Oct 18, 2017 5 - Production/Stable pytest (>=2.5.2) @@ -161,7 +162,7 @@ This list contains 1596 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Mar 14, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Mar 22, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -213,7 +214,7 @@ This list contains 1596 plugins. :pypi:`pytest-camel-collect` Enable CamelCase-aware pytest class collection Aug 02, 2020 N/A pytest (>=2.9) :pypi:`pytest-canonical-data` A plugin which allows to compare results with canonical results, based on previous runs May 08, 2020 2 - Pre-Alpha pytest (>=3.5.0) :pypi:`pytest-caprng` A plugin that replays pRNG state on failure. May 02, 2018 4 - Beta N/A - :pypi:`pytest-capsqlalchemy` Pytest plugin to allow capturing SQLAlchemy queries. Mar 14, 2025 4 - Beta N/A + :pypi:`pytest-capsqlalchemy` Pytest plugin to allow capturing SQLAlchemy queries. Mar 19, 2025 4 - Beta N/A :pypi:`pytest-capture-deprecatedwarnings` pytest plugin to capture all deprecatedwarnings and put them in one file Apr 30, 2019 N/A N/A :pypi:`pytest-capture-warnings` pytest plugin to capture all warnings and put them in one file of your choice May 03, 2022 N/A pytest :pypi:`pytest-case` A clean, modern, wrapper for pytest.mark.parametrize Nov 25, 2024 N/A pytest<9.0.0,>=8.3.3 @@ -231,7 +232,7 @@ This list contains 1596 plugins. :pypi:`pytest-change-report` turn . into √,turn F into x Sep 14, 2020 N/A pytest :pypi:`pytest-change-xds` turn . into √,turn F into x Apr 16, 2022 N/A pytest :pypi:`pytest-chdir` A pytest fixture for changing current working directory Jan 28, 2020 N/A pytest (>=5.0.0,<6.0.0) - :pypi:`pytest-check` A pytest plugin that allows multiple failures per test. Feb 13, 2025 5 - Production/Stable pytest>=7.0.0 + :pypi:`pytest-check` A pytest plugin that allows multiple failures per test. Mar 18, 2025 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-checkdocs` check the README when running tests Apr 30, 2024 5 - Production/Stable pytest!=8.1.*,>=6; extra == "testing" :pypi:`pytest-checkipdb` plugin to check if there are ipdb debugs left Dec 04, 2023 5 - Production/Stable pytest >=2.9.2 :pypi:`pytest-check-library` check your missing library Jul 17, 2022 N/A N/A @@ -239,9 +240,11 @@ This list contains 1596 plugins. :pypi:`pytest-check-links` Check links in files Jul 29, 2020 N/A pytest<9,>=7.0 :pypi:`pytest-checklist` Pytest plugin to track and report unit/function coverage. Jun 10, 2024 N/A N/A :pypi:`pytest-check-mk` pytest plugin to test Check_MK checks Nov 19, 2015 4 - Beta pytest + :pypi:`pytest-checkpoint` Restore a checkpoint in pytest Mar 22, 2025 N/A pytest>=8.3.5 :pypi:`pytest-check-requirements` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A :pypi:`pytest-ch-framework` My pytest framework Apr 17, 2024 N/A pytest==8.0.1 :pypi:`pytest-chic-report` Simple pytest plugin for generating and sending report to messengers. Nov 01, 2024 N/A pytest>=6.0 + :pypi:`pytest-chinesereport` Mar 19, 2025 4 - Beta pytest>=3.5.0 :pypi:`pytest-choose` Provide the pytest with the ability to collect use cases based on rules in text files Feb 04, 2024 N/A pytest >=7.0.0 :pypi:`pytest-chunks` Run only a chunk of your test suite Jul 05, 2022 N/A pytest (>=6.0.0) :pypi:`pytest_cid` Compare data structures containing matching CIDs of different versions and encoding Sep 01, 2023 4 - Beta pytest >= 5.0, < 7.0 @@ -268,6 +271,7 @@ This list contains 1596 plugins. :pypi:`pytest-cmake-presets` Execute CMake Presets via pytest Dec 26, 2022 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-cmdline-add-args` Pytest plugin for custom argument handling and Allure reporting. This plugin allows you to add arguments before running a test. Sep 01, 2024 N/A N/A :pypi:`pytest-cobra` PyTest plugin for testing Smart Contracts for Ethereum blockchain. Jun 29, 2019 3 - Alpha pytest (<4.0.0,>=3.7.1) + :pypi:`pytest-cocotb` Pytest plugin to integrate Cocotb Mar 15, 2025 5 - Production/Stable pytest; extra == "test" :pypi:`pytest_codeblocks` Test code blocks in your READMEs Sep 17, 2023 5 - Production/Stable pytest >= 7.0.0 :pypi:`pytest-codecarbon` Pytest plugin for measuring carbon emissions Jun 15, 2022 N/A pytest :pypi:`pytest-codecheckers` pytest plugin to add source code sanity checks (pep8 and friends) Feb 13, 2010 N/A N/A @@ -433,7 +437,7 @@ This list contains 1596 plugins. :pypi:`pytest-docker-registry-fixtures` Pytest fixtures for testing with docker registries. Aug 12, 2024 4 - Beta pytest :pypi:`pytest-docker-service` pytest plugin to start docker container Jan 03, 2024 3 - Alpha pytest (>=7.1.3) :pypi:`pytest-docker-squid-fixtures` Pytest fixtures for testing with squid. Aug 12, 2024 4 - Beta pytest - :pypi:`pytest-docker-tools` Docker integration tests for pytest Mar 15, 2025 4 - Beta pytest>=6.0.1 + :pypi:`pytest-docker-tools` Docker integration tests for pytest Mar 16, 2025 4 - Beta pytest>=6.0.1 :pypi:`pytest-docs` Documentation tool for pytest Nov 11, 2018 4 - Beta pytest (>=3.5.0) :pypi:`pytest-docstyle` pytest plugin to run pydocstyle Mar 23, 2020 3 - Alpha N/A :pypi:`pytest-doctest-custom` A py.test plugin for customizing string representations of doctest results. Jul 25, 2016 4 - Beta N/A @@ -460,7 +464,7 @@ This list contains 1596 plugins. :pypi:`pytest-dummynet` A py.test plugin providing access to a dummynet. Dec 15, 2021 5 - Production/Stable pytest :pypi:`pytest-dump2json` A pytest plugin for dumping test results to json. Jun 29, 2015 N/A N/A :pypi:`pytest-duration-insights` Jul 15, 2024 N/A N/A - :pypi:`pytest-durations` Pytest plugin reporting fixtures and test functions execution time. Sep 11, 2024 5 - Production/Stable pytest>=4.6 + :pypi:`pytest-durations` Pytest plugin reporting fixtures and test functions execution time. Mar 18, 2025 5 - Production/Stable pytest>=4.6 :pypi:`pytest-dynamicrerun` A pytest plugin to rerun tests dynamically based off of test outcome and output. Aug 15, 2020 4 - Beta N/A :pypi:`pytest-dynamodb` DynamoDB fixtures for pytest Oct 25, 2024 5 - Production/Stable pytest :pypi:`pytest-easy-addoption` pytest-easy-addoption: Easy way to work with pytest addoption Jan 22, 2020 N/A N/A @@ -607,7 +611,7 @@ This list contains 1596 plugins. :pypi:`pytest-flexreport` Apr 15, 2023 4 - Beta pytest :pypi:`pytest-fluent` A pytest plugin in order to provide logs via fluentd Aug 14, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-fluentbit` A pytest plugin in order to provide logs via fluentbit Jun 16, 2023 4 - Beta pytest (>=7.0.0) - :pypi:`pytest-fly` pytest runner and observer Mar 13, 2025 3 - Alpha pytest + :pypi:`pytest-fly` pytest runner and observer Mar 20, 2025 3 - Alpha pytest :pypi:`pytest-flyte` Pytest fixtures for simplifying Flyte integration testing May 03, 2021 N/A pytest :pypi:`pytest-focus` A pytest plugin that alerts user of failed test cases with screen notifications May 04, 2019 4 - Beta pytest :pypi:`pytest-forbid` Mar 07, 2023 N/A pytest (>=7.2.2,<8.0.0) @@ -622,6 +626,7 @@ This list contains 1596 plugins. :pypi:`pytest-freeze-reqs` Check if requirement files are frozen Apr 29, 2021 N/A N/A :pypi:`pytest-frozen-uuids` Deterministically frozen UUID's for your tests Apr 17, 2022 N/A pytest (>=3.0) :pypi:`pytest-func-cov` Pytest plugin for measuring function coverage Apr 15, 2021 3 - Alpha pytest (>=5) + :pypi:`pytest-funcnodes` Testing plugin for funcnodes Mar 19, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-funparam` An alternative way to parametrize test cases. Dec 02, 2021 4 - Beta pytest >=4.6.0 :pypi:`pytest-fv` pytest extensions to support running functional-verification jobs Feb 27, 2025 N/A pytest :pypi:`pytest-fxa` pytest plugin for Firefox Accounts Aug 28, 2018 5 - Production/Stable N/A @@ -638,7 +643,7 @@ This list contains 1596 plugins. :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Feb 20, 2025 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Mar 21, 2025 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -682,7 +687,7 @@ This list contains 1596 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Mar 15, 2025 3 - Alpha pytest==8.3.4 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Mar 22, 2025 3 - Alpha pytest==8.3.4 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -731,7 +736,7 @@ This list contains 1596 plugins. :pypi:`pytest-info-collector` pytest plugin to collect information from tests May 26, 2019 3 - Alpha N/A :pypi:`pytest-info-plugin` Get executed interface information in pytest interface automation framework Sep 14, 2023 N/A N/A :pypi:`pytest-informative-node` display more node ininformation. Apr 25, 2019 4 - Beta N/A - :pypi:`pytest-infrahouse` A set of fixtures to use with pytest Mar 06, 2025 4 - Beta pytest~=8.3 + :pypi:`pytest-infrahouse` A set of fixtures to use with pytest Mar 18, 2025 4 - Beta pytest~=8.3 :pypi:`pytest-infrastructure` pytest stack validation prior to testing executing Apr 12, 2020 4 - Beta N/A :pypi:`pytest-ini` Reuse pytest.ini to store env variables Apr 26, 2022 N/A N/A :pypi:`pytest-initry` Plugin for sending automation test data from Pytest to the initry Apr 30, 2024 N/A pytest<9.0.0,>=8.1.1 @@ -818,6 +823,7 @@ This list contains 1596 plugins. :pypi:`pytest-leak-finder` Find the test that's leaking before the one that fails Feb 15, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-leaks` A pytest plugin to trace resource leaks. Nov 27, 2019 1 - Planning N/A :pypi:`pytest-leaping` A simple plugin to use with pytest Mar 27, 2024 4 - Beta pytest>=6.2.0 + :pypi:`pytest-leo-interface` Pytest extension tool for leo projects. Mar 19, 2025 N/A N/A :pypi:`pytest-level` Select tests of a given level or lower Oct 21, 2019 N/A pytest :pypi:`pytest-libfaketime` A python-libfaketime plugin for pytest Apr 12, 2024 4 - Beta pytest>=3.0.0 :pypi:`pytest-libiio` A pytest plugin to manage interfacing with libiio contexts Oct 01, 2024 4 - Beta N/A @@ -831,6 +837,7 @@ This list contains 1596 plugins. :pypi:`pytest-litf` A pytest plugin that stream output in LITF format Jan 18, 2021 4 - Beta pytest (>=3.1.1) :pypi:`pytest-litter` Pytest plugin which verifies that tests do not modify file trees. Nov 23, 2023 4 - Beta pytest >=6.1 :pypi:`pytest-live` Live results for pytest Mar 08, 2020 N/A pytest + :pypi:`pytest-llmeval` A pytest plugin to evaluate/benchmark LLM prompts Mar 19, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-local-badge` Generate local badges (shields) reporting your test suite status. Jan 15, 2023 N/A pytest (>=6.1.0) :pypi:`pytest-localftpserver` A PyTest plugin which provides an FTP fixture for your tests May 19, 2024 5 - Production/Stable pytest :pypi:`pytest-localserver` pytest plugin to test server connections locally. Oct 06, 2024 4 - Beta N/A @@ -853,6 +860,7 @@ This list contains 1596 plugins. :pypi:`pytest-loop` pytest plugin for looping tests Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-lsp` A pytest plugin for end-to-end testing of language servers Nov 23, 2024 3 - Alpha pytest :pypi:`pytest-lw-realtime-result` Pytest plugin to generate realtime test results to a file Mar 13, 2025 N/A pytest>=3.5.0 + :pypi:`pytest-manifest` PyTest plugin for recording and asserting against a manifest file Mar 18, 2025 N/A pytest :pypi:`pytest-manual-marker` pytest marker for marking manual tests Aug 04, 2022 3 - Alpha pytest>=7 :pypi:`pytest-mark-count` Get a count of the number of tests marked, unmarked, and unique tests if tests have multiple markers Nov 13, 2024 4 - Beta pytest>=8.0.0 :pypi:`pytest-markdoctest` A pytest plugin to doctest your markdown files Jul 22, 2022 4 - Beta pytest (>=6) @@ -957,7 +965,7 @@ This list contains 1596 plugins. :pypi:`pytest-nginx-iplweb` nginx fixture for pytest - iplweb temporary fork Mar 01, 2019 5 - Production/Stable N/A :pypi:`pytest-ngrok` Jan 20, 2022 3 - Alpha pytest :pypi:`pytest-ngsfixtures` pytest ngs fixtures Sep 06, 2019 2 - Pre-Alpha pytest (>=5.0.0) - :pypi:`pytest-nhsd-apim` Pytest plugin accessing NHSDigital's APIM proxies Nov 28, 2024 N/A pytest<9.0.0,>=8.2.0 + :pypi:`pytest-nhsd-apim` Pytest plugin accessing NHSDigital's APIM proxies Mar 21, 2025 N/A pytest<9.0.0,>=8.2.0 :pypi:`pytest-nice` A pytest plugin that alerts user of failed test cases with screen notifications May 04, 2019 4 - Beta pytest :pypi:`pytest-nice-parametrize` A small snippet for nicer PyTest's Parametrize Apr 17, 2021 5 - Production/Stable N/A :pypi:`pytest_nlcov` Pytest plugin to get the coverage of the new lines (based on git diff) only Aug 05, 2024 N/A N/A @@ -1041,6 +1049,7 @@ This list contains 1596 plugins. :pypi:`pytest-pg` A tiny plugin for pytest which runs PostgreSQL in Docker May 21, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-pgsql` Pytest plugins and helpers for tests using a Postgres database. May 13, 2020 5 - Production/Stable pytest (>=3.0.0) :pypi:`pytest-phmdoctest` pytest plugin to test Python examples in Markdown using phmdoctest. Apr 15, 2022 4 - Beta pytest (>=5.4.3) + :pypi:`pytest-phoenix-interface` Pytest extension tool for phoenix projects. Mar 19, 2025 N/A N/A :pypi:`pytest-picked` Run the tests related to the changed files Nov 06, 2024 N/A pytest>=3.7.0 :pypi:`pytest-pickle-cache` A pytest plugin for caching test results using pickle. Feb 17, 2025 N/A pytest>=7 :pypi:`pytest-pigeonhole` Jun 25, 2018 5 - Production/Stable pytest (>=3.4) @@ -1082,7 +1091,7 @@ This list contains 1596 plugins. :pypi:`pytest-porcochu` Show surprise when tests are passing Nov 28, 2024 5 - Production/Stable N/A :pypi:`pytest-portion` Select a portion of the collected tests Jan 28, 2021 4 - Beta pytest (>=3.5.0) :pypi:`pytest-postgres` Run PostgreSQL in Docker container in Pytest. Mar 22, 2020 N/A pytest - :pypi:`pytest-postgresql` Postgresql fixtures and fixture factories for Pytest. Feb 23, 2025 5 - Production/Stable pytest>=6.2 + :pypi:`pytest-postgresql` Postgresql fixtures and fixture factories for Pytest. Mar 19, 2025 5 - Production/Stable pytest>=6.2 :pypi:`pytest-power` pytest plugin with powerful fixtures Dec 31, 2020 N/A pytest (>=5.4) :pypi:`pytest-powerpack` A plugin containing extra batteries for pytest Jan 04, 2025 N/A pytest<9.0.0,>=8.1.1 :pypi:`pytest-prefer-nested-dup-tests` A Pytest plugin to drop duplicated tests during collection, but will prefer keeping nested packages. Apr 27, 2022 4 - Beta pytest (>=7.1.1,<8.0.0) @@ -1136,7 +1145,7 @@ This list contains 1596 plugins. :pypi:`pytest-pyvenv` A package for create venv in tests Feb 27, 2024 N/A pytest ; extra == 'test' :pypi:`pytest-pyvista` Pytest-pyvista package Sep 29, 2023 4 - Beta pytest>=3.5.0 :pypi:`pytest-qanova` A pytest plugin to collect test information Sep 05, 2024 3 - Alpha pytest - :pypi:`pytest-qaseio` Pytest plugin for Qase.io integration Feb 11, 2025 5 - Production/Stable pytest<9.0.0,>=7.2.2 + :pypi:`pytest-qaseio` Pytest plugin for Qase.io integration Mar 18, 2025 5 - Production/Stable pytest<9.0.0,>=7.2.2 :pypi:`pytest-qasync` Pytest support for qasync. Jul 12, 2021 4 - Beta pytest (>=5.4.0) :pypi:`pytest-qatouch` Pytest plugin for uploading test results to your QA Touch Testrun. Feb 14, 2023 4 - Beta pytest (>=6.2.0) :pypi:`pytest-qgis` A pytest plugin for testing QGIS python plugins Jun 14, 2024 5 - Production/Stable pytest>=6.0 @@ -1192,7 +1201,7 @@ This list contains 1596 plugins. :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Oct 11, 2024 4 - Beta N/A :pypi:`pytest-reporter-html-dots` A basic HTML report for pytest using Jinja2 template engine. Jan 22, 2023 N/A N/A - :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots, webpage sources and attachments. Feb 19, 2025 N/A pytest>=8.0.0 + :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots, webpage sources and attachments. Mar 20, 2025 N/A pytest>=8.0.0 :pypi:`pytest-reportinfra` Pytest plugin for reportinfra Aug 11, 2019 3 - Alpha N/A :pypi:`pytest-reporting` A plugin to report summarized results in a table format Oct 25, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-reportlog` Replacement for the --resultlog option, focused in simplicity and extensibility May 22, 2023 3 - Alpha pytest @@ -1228,12 +1237,13 @@ This list contains 1596 plugins. :pypi:`pytest-result-sender` Apr 20, 2023 N/A pytest>=7.3.1 :pypi:`pytest-result-sender-lj` Default template for PDM package Dec 17, 2024 N/A pytest>=8.3.4 :pypi:`pytest-result-sender-lyt` Default template for PDM package Mar 14, 2025 N/A pytest>=8.3.5 + :pypi:`pytest-result-sender-misszhang` Default template for PDM package Mar 21, 2025 N/A pytest>=8.3.5 :pypi:`pytest-resume` A Pytest plugin to resuming from the last run test Apr 22, 2023 4 - Beta pytest (>=7.0) :pypi:`pytest-rethinkdb` A RethinkDB plugin for pytest. Jul 24, 2016 4 - Beta N/A :pypi:`pytest-retry` Adds the ability to retry flaky tests in CI environments Jan 19, 2025 N/A pytest>=7.0.0 :pypi:`pytest-retry-class` A pytest plugin to rerun entire class on failure Nov 24, 2024 N/A pytest>=5.3 :pypi:`pytest-reusable-testcases` Apr 28, 2023 N/A N/A - :pypi:`pytest-revealtype-injector` Pytest plugin for replacing reveal_type() calls inside test functions with static and runtime type checking result comparison, for confirming type annotation validity. Feb 27, 2025 4 - Beta pytest<9,>=7.0 + :pypi:`pytest-revealtype-injector` Pytest plugin for replacing reveal_type() calls inside test functions with static and runtime type checking result comparison, for confirming type annotation validity. Mar 18, 2025 4 - Beta pytest<9,>=7.0 :pypi:`pytest-reverse` Pytest plugin to reverse test order. Oct 25, 2024 5 - Production/Stable pytest :pypi:`pytest-rich` Leverage rich for richer test session output Dec 12, 2024 4 - Beta pytest>=7.0 :pypi:`pytest-richer` Pytest plugin providing a Rich based reporter. Oct 27, 2023 3 - Alpha pytest @@ -1266,10 +1276,11 @@ This list contains 1596 plugins. :pypi:`pytest-salt-runtests-bridge` Simple PyTest Plugin For Salt's Test Suite Specifically Dec 05, 2019 4 - Beta pytest (>=4.1) :pypi:`pytest-sample-argvalues` A utility function to help choose a random sample from your argvalues in pytest. May 07, 2024 N/A pytest :pypi:`pytest-sanic` a pytest plugin for Sanic Oct 25, 2021 N/A pytest (>=5.2) + :pypi:`pytest-sanitizer` A pytest plugin to sanitize output for LLMs (personal tool, no warranty or liability) Mar 16, 2025 3 - Alpha pytest>=6.0.0 :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Mar 12, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Mar 22, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1281,7 +1292,7 @@ This list contains 1596 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Mar 12, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Mar 22, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1323,7 +1334,7 @@ This list contains 1596 plugins. :pypi:`pytest-slow` A pytest plugin to skip \`@pytest.mark.slow\` tests by default. Sep 28, 2021 N/A N/A :pypi:`pytest-slowest-first` Sort tests by their last duration, slowest first Dec 11, 2022 4 - Beta N/A :pypi:`pytest-slow-first` Prioritize running the slowest tests first. Jan 30, 2024 4 - Beta pytest >=3.5.0 - :pypi:`pytest-slow-last` Run tests in order of execution time (faster tests first) Dec 10, 2022 4 - Beta pytest (>=3.5.0) + :pypi:`pytest-slow-last` Run tests in order of execution time (faster tests first) Mar 16, 2025 4 - Beta pytest>=3.5.0 :pypi:`pytest-smartcollect` A plugin for collecting tests that touch changed code Oct 04, 2018 N/A pytest (>=3.5.0) :pypi:`pytest-smartcov` Smart coverage plugin for pytest. Sep 30, 2017 3 - Alpha N/A :pypi:`pytest-smell` Automated bad smell detection tool for Pytest Jun 26, 2022 N/A N/A @@ -1349,7 +1360,7 @@ This list contains 1596 plugins. :pypi:`pytest-sorter` A simple plugin to first execute tests that historically failed more Apr 20, 2021 4 - Beta pytest (>=3.1.1) :pypi:`pytest-sosu` Unofficial PyTest plugin for Sauce Labs Aug 04, 2023 2 - Pre-Alpha pytest :pypi:`pytest-sourceorder` Test-ordering plugin for pytest Sep 01, 2021 4 - Beta pytest - :pypi:`pytest-spark` pytest plugin to run the tests with support of pyspark. Feb 23, 2020 4 - Beta pytest + :pypi:`pytest-spark` pytest plugin to run the tests with support of pyspark. Mar 21, 2025 4 - Beta pytest :pypi:`pytest-spawner` py.test plugin to spawn process and communicate with them. Jul 31, 2015 4 - Beta N/A :pypi:`pytest-spec` Library pytest-spec is a pytest plugin to display test execution output like a SPECIFICATION. Aug 04, 2024 N/A pytest; extra == "test" :pypi:`pytest-spec2md` Library pytest-spec2md is a pytest plugin to create a markdown specification while running pytest. Apr 10, 2024 N/A pytest>7.0 @@ -1364,7 +1375,7 @@ This list contains 1596 plugins. :pypi:`pytest-split-tests` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Forked from Mark Adams' original project pytest-test-groups. Jul 30, 2021 5 - Production/Stable pytest (>=2.5) :pypi:`pytest-split-tests-tresorit` Feb 22, 2021 1 - Planning N/A :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Mar 07, 2025 N/A pytest<8,>5.4.0 - :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Jan 03, 2025 N/A N/A + :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Mar 19, 2025 N/A N/A :pypi:`pytest-splunk-env` pytest fixtures for interaction with Splunk Enterprise and Splunk Cloud Oct 22, 2020 N/A pytest (>=6.1.1,<7.0.0) :pypi:`pytest-sqitch` sqitch for pytest Apr 06, 2020 4 - Beta N/A :pypi:`pytest-sqlalchemy` pytest plugin with sqlalchemy related fixtures Mar 13, 2018 3 - Alpha N/A @@ -1447,6 +1458,7 @@ This list contains 1596 plugins. :pypi:`pytest-testpluggy` set your encoding Jan 07, 2022 N/A pytest :pypi:`pytest-testrail` pytest plugin for creating TestRail runs and adding results Aug 27, 2020 N/A pytest (>=3.6) :pypi:`pytest-testrail2` A pytest plugin to upload results to TestRail. Feb 10, 2023 N/A pytest (<8.0,>=7.2.0) + :pypi:`pytest-testrail-api` TestRail Api Python Client Mar 17, 2025 N/A pytest :pypi:`pytest-testrail-api-client` TestRail Api Python Client Dec 14, 2021 N/A pytest :pypi:`pytest-testrail-appetize` pytest plugin for creating TestRail runs and adding results Sep 29, 2021 N/A N/A :pypi:`pytest-testrail-client` pytest plugin for Testrail Sep 29, 2020 5 - Production/Stable N/A @@ -1581,6 +1593,7 @@ This list contains 1596 plugins. :pypi:`pytest-win32consoletitle` Pytest progress in console title (Win32 only) Aug 08, 2021 N/A N/A :pypi:`pytest-winnotify` Windows tray notifications for py.test results. Apr 22, 2016 N/A N/A :pypi:`pytest-wiremock` A pytest plugin for programmatically using wiremock in integration tests Mar 27, 2022 N/A pytest (>=7.1.1,<8.0.0) + :pypi:`pytest-wiretap` \`pytest\` plugin for recording call stacks Mar 18, 2025 N/A pytest :pypi:`pytest-with-docker` pytest with docker helpers. Nov 09, 2021 N/A pytest :pypi:`pytest-workaround-12888` forces an import of readline early in the process to work around pytest bug #12888 Jan 15, 2025 N/A N/A :pypi:`pytest-workflow` A pytest plugin for configuring workflow/pipeline tests using YAML files Mar 18, 2024 5 - Production/Stable pytest >=7.0.0 @@ -1630,6 +1643,7 @@ This list contains 1596 plugins. :pypi:`pytest-zigzag` Extend py.test for RPC OpenStack testing. Feb 27, 2019 4 - Beta pytest (~=3.6) :pypi:`pytest-zulip` Pytest report plugin for Zulip May 07, 2022 5 - Production/Stable pytest :pypi:`pytest-zy` 接口自动化测试框架 Mar 24, 2024 N/A pytest~=7.2.0 + :pypi:`tursu` 🎬 A pytest plugin that transpiles Gherkin feature files to Python using AST, enforcing typing for ease of use and debugging. Mar 22, 2025 4 - Beta pytest>=8.3.5 =============================================== ====================================================================================================================================================================================================================================================================================================================================================================================== ============== ===================== ================================================ .. only:: latex @@ -2090,6 +2104,13 @@ This list contains 1596 plugins. pyest results colection plugin + :pypi:`pytest-argus-server` + *last release*: Mar 20, 2025, + *status*: 4 - Beta, + *requires*: pytest>=6.2.0 + + A plugin that provides a running Argus API server for tests + :pypi:`pytest-arraydiff` *last release*: Nov 27, 2023, *status*: 4 - Beta, @@ -2147,7 +2168,7 @@ This list contains 1596 plugins. Useful assertion utilities for use with pytest :pypi:`pytest-assist` - *last release*: Jun 24, 2024, + *last release*: Mar 17, 2025, *status*: N/A, *requires*: pytest @@ -2224,7 +2245,7 @@ This list contains 1596 plugins. Pytest support for asyncio :pypi:`pytest-asyncio-concurrent` - *last release*: Mar 15, 2025, + *last release*: Mar 16, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -2525,7 +2546,7 @@ This list contains 1596 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Mar 14, 2025, + *last release*: Mar 22, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -2889,7 +2910,7 @@ This list contains 1596 plugins. A plugin that replays pRNG state on failure. :pypi:`pytest-capsqlalchemy` - *last release*: Mar 14, 2025, + *last release*: Mar 19, 2025, *status*: 4 - Beta, *requires*: N/A @@ -3015,7 +3036,7 @@ This list contains 1596 plugins. A pytest fixture for changing current working directory :pypi:`pytest-check` - *last release*: Feb 13, 2025, + *last release*: Mar 18, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0.0 @@ -3070,6 +3091,13 @@ This list contains 1596 plugins. pytest plugin to test Check_MK checks + :pypi:`pytest-checkpoint` + *last release*: Mar 22, 2025, + *status*: N/A, + *requires*: pytest>=8.3.5 + + Restore a checkpoint in pytest + :pypi:`pytest-check-requirements` *last release*: Feb 20, 2024, *status*: N/A, @@ -3091,6 +3119,13 @@ This list contains 1596 plugins. Simple pytest plugin for generating and sending report to messengers. + :pypi:`pytest-chinesereport` + *last release*: Mar 19, 2025, + *status*: 4 - Beta, + *requires*: pytest>=3.5.0 + + + :pypi:`pytest-choose` *last release*: Feb 04, 2024, *status*: N/A, @@ -3273,6 +3308,13 @@ This list contains 1596 plugins. PyTest plugin for testing Smart Contracts for Ethereum blockchain. + :pypi:`pytest-cocotb` + *last release*: Mar 15, 2025, + *status*: 5 - Production/Stable, + *requires*: pytest; extra == "test" + + Pytest plugin to integrate Cocotb + :pypi:`pytest_codeblocks` *last release*: Sep 17, 2023, *status*: 5 - Production/Stable, @@ -4429,7 +4471,7 @@ This list contains 1596 plugins. Pytest fixtures for testing with squid. :pypi:`pytest-docker-tools` - *last release*: Mar 15, 2025, + *last release*: Mar 16, 2025, *status*: 4 - Beta, *requires*: pytest>=6.0.1 @@ -4618,7 +4660,7 @@ This list contains 1596 plugins. :pypi:`pytest-durations` - *last release*: Sep 11, 2024, + *last release*: Mar 18, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=4.6 @@ -5647,7 +5689,7 @@ This list contains 1596 plugins. A pytest plugin in order to provide logs via fluentbit :pypi:`pytest-fly` - *last release*: Mar 13, 2025, + *last release*: Mar 20, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -5751,6 +5793,13 @@ This list contains 1596 plugins. Pytest plugin for measuring function coverage + :pypi:`pytest-funcnodes` + *last release*: Mar 19, 2025, + *status*: 4 - Beta, + *requires*: pytest>=6.2.0 + + Testing plugin for funcnodes + :pypi:`pytest-funparam` *last release*: Dec 02, 2021, *status*: 4 - Beta, @@ -5864,7 +5913,7 @@ This list contains 1596 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Feb 20, 2025, + *last release*: Mar 21, 2025, *status*: N/A, *requires*: pytest>=3.6 @@ -6172,7 +6221,7 @@ This list contains 1596 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Mar 15, 2025, + *last release*: Mar 22, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.4 @@ -6515,7 +6564,7 @@ This list contains 1596 plugins. display more node ininformation. :pypi:`pytest-infrahouse` - *last release*: Mar 06, 2025, + *last release*: Mar 18, 2025, *status*: 4 - Beta, *requires*: pytest~=8.3 @@ -7123,6 +7172,13 @@ This list contains 1596 plugins. A simple plugin to use with pytest + :pypi:`pytest-leo-interface` + *last release*: Mar 19, 2025, + *status*: N/A, + *requires*: N/A + + Pytest extension tool for leo projects. + :pypi:`pytest-level` *last release*: Oct 21, 2019, *status*: N/A, @@ -7214,6 +7270,13 @@ This list contains 1596 plugins. Live results for pytest + :pypi:`pytest-llmeval` + *last release*: Mar 19, 2025, + *status*: 4 - Beta, + *requires*: pytest>=6.2.0 + + A pytest plugin to evaluate/benchmark LLM prompts + :pypi:`pytest-local-badge` *last release*: Jan 15, 2023, *status*: N/A, @@ -7368,6 +7431,13 @@ This list contains 1596 plugins. Pytest plugin to generate realtime test results to a file + :pypi:`pytest-manifest` + *last release*: Mar 18, 2025, + *status*: N/A, + *requires*: pytest + + PyTest plugin for recording and asserting against a manifest file + :pypi:`pytest-manual-marker` *last release*: Aug 04, 2022, *status*: 3 - Alpha, @@ -8097,7 +8167,7 @@ This list contains 1596 plugins. pytest ngs fixtures :pypi:`pytest-nhsd-apim` - *last release*: Nov 28, 2024, + *last release*: Mar 21, 2025, *status*: N/A, *requires*: pytest<9.0.0,>=8.2.0 @@ -8684,6 +8754,13 @@ This list contains 1596 plugins. pytest plugin to test Python examples in Markdown using phmdoctest. + :pypi:`pytest-phoenix-interface` + *last release*: Mar 19, 2025, + *status*: N/A, + *requires*: N/A + + Pytest extension tool for phoenix projects. + :pypi:`pytest-picked` *last release*: Nov 06, 2024, *status*: N/A, @@ -8972,7 +9049,7 @@ This list contains 1596 plugins. Run PostgreSQL in Docker container in Pytest. :pypi:`pytest-postgresql` - *last release*: Feb 23, 2025, + *last release*: Mar 19, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=6.2 @@ -9350,7 +9427,7 @@ This list contains 1596 plugins. A pytest plugin to collect test information :pypi:`pytest-qaseio` - *last release*: Feb 11, 2025, + *last release*: Mar 18, 2025, *status*: 5 - Production/Stable, *requires*: pytest<9.0.0,>=7.2.2 @@ -9742,7 +9819,7 @@ This list contains 1596 plugins. A basic HTML report for pytest using Jinja2 template engine. :pypi:`pytest-report-extras` - *last release*: Feb 19, 2025, + *last release*: Mar 20, 2025, *status*: N/A, *requires*: pytest>=8.0.0 @@ -9993,6 +10070,13 @@ This list contains 1596 plugins. Default template for PDM package + :pypi:`pytest-result-sender-misszhang` + *last release*: Mar 21, 2025, + *status*: N/A, + *requires*: pytest>=8.3.5 + + Default template for PDM package + :pypi:`pytest-resume` *last release*: Apr 22, 2023, *status*: 4 - Beta, @@ -10029,7 +10113,7 @@ This list contains 1596 plugins. :pypi:`pytest-revealtype-injector` - *last release*: Feb 27, 2025, + *last release*: Mar 18, 2025, *status*: 4 - Beta, *requires*: pytest<9,>=7.0 @@ -10259,6 +10343,13 @@ This list contains 1596 plugins. a pytest plugin for Sanic + :pypi:`pytest-sanitizer` + *last release*: Mar 16, 2025, + *status*: 3 - Alpha, + *requires*: pytest>=6.0.0 + + A pytest plugin to sanitize output for LLMs (personal tool, no warranty or liability) + :pypi:`pytest-sanity` *last release*: Dec 07, 2020, *status*: N/A, @@ -10281,7 +10372,7 @@ This list contains 1596 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Mar 12, 2025, + *last release*: Mar 22, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10365,7 +10456,7 @@ This list contains 1596 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Mar 12, 2025, + *last release*: Mar 22, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10659,9 +10750,9 @@ This list contains 1596 plugins. Prioritize running the slowest tests first. :pypi:`pytest-slow-last` - *last release*: Dec 10, 2022, + *last release*: Mar 16, 2025, *status*: 4 - Beta, - *requires*: pytest (>=3.5.0) + *requires*: pytest>=3.5.0 Run tests in order of execution time (faster tests first) @@ -10841,7 +10932,7 @@ This list contains 1596 plugins. Test-ordering plugin for pytest :pypi:`pytest-spark` - *last release*: Feb 23, 2020, + *last release*: Mar 21, 2025, *status*: 4 - Beta, *requires*: pytest @@ -10946,7 +11037,7 @@ This list contains 1596 plugins. A Dynamic test tool for Splunk Apps and Add-ons :pypi:`pytest-splunk-addon-ui-smartx` - *last release*: Jan 03, 2025, + *last release*: Mar 19, 2025, *status*: N/A, *requires*: N/A @@ -11526,6 +11617,13 @@ This list contains 1596 plugins. A pytest plugin to upload results to TestRail. + :pypi:`pytest-testrail-api` + *last release*: Mar 17, 2025, + *status*: N/A, + *requires*: pytest + + TestRail Api Python Client + :pypi:`pytest-testrail-api-client` *last release*: Dec 14, 2021, *status*: N/A, @@ -12464,6 +12562,13 @@ This list contains 1596 plugins. A pytest plugin for programmatically using wiremock in integration tests + :pypi:`pytest-wiretap` + *last release*: Mar 18, 2025, + *status*: N/A, + *requires*: pytest + + \`pytest\` plugin for recording call stacks + :pypi:`pytest-with-docker` *last release*: Nov 09, 2021, *status*: N/A, @@ -12806,3 +12911,10 @@ This list contains 1596 plugins. *requires*: pytest~=7.2.0 接口自动化测试框架 + + :pypi:`tursu` + *last release*: Mar 22, 2025, + *status*: 4 - Beta, + *requires*: pytest>=8.3.5 + + 🎬 A pytest plugin that transpiles Gherkin feature files to Python using AST, enforcing typing for ease of use and debugging. From 544f58995d03580e74890a8668802b285082a901 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 24 Mar 2025 22:11:36 +0100 Subject: [PATCH 363/445] [pre-commit.ci] pre-commit autoupdate (#13325) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.0 → v0.11.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.0...v0.11.2) - [github.com/woodruffw/zizmor-pre-commit: v1.5.1 → v1.5.2](https://github.com/woodruffw/zizmor-pre-commit/compare/v1.5.1...v1.5.2) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 56ee45b4c61..3741df6f51b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.11.0" + rev: "v0.11.2" hooks: - id: ruff args: ["--fix"] @@ -12,7 +12,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/woodruffw/zizmor-pre-commit - rev: v1.5.1 + rev: v1.5.2 hooks: - id: zizmor - repo: https://github.com/adamchainz/blacken-docs From 134b759e5def7fd2fd4c74bd2a4f00a4b56e5425 Mon Sep 17 00:00:00 2001 From: John Litborn <11260241+jakkdl@users.noreply.github.com> Date: Sat, 29 Mar 2025 14:08:12 +0100 Subject: [PATCH 364/445] raisesgroup followups (#13279) * raisesgroup followups * renames src/_pytest/raises_group.py to src/_pytest/raises.py * moves pytest.raises from src/_pytest/python_api.py to src/_pytest/raises.py * adds several newsfragments that should've been bundled with #13192 * add more detailed error message if you try to do RaisesGroup((ValueError, TypeError)) * mess around with ValueError vs TypeError on invalid expected exception * revert change in behaviour if raises has a type mismatch * add check example to raises, fix test after behaviour revert * made args to AbstractMatcher, RaisesExc and RaisesGroup pos/kw-only --------- Co-authored-by: Ran Benita Co-authored-by: Bruno Oliveira Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- changelog/13192.feature.1.rst | 1 + changelog/13192.feature.2.rst | 1 + changelog/13192.feature.rst | 1 + src/_pytest/mark/structures.py | 2 +- src/_pytest/python_api.py | 237 ------------ src/_pytest/{raises_group.py => raises.py} | 396 +++++++++++++++++++-- src/_pytest/skipping.py | 2 +- src/pytest/__init__.py | 6 +- testing/code/test_excinfo.py | 5 +- testing/python/raises.py | 30 +- testing/python/raises_group.py | 41 ++- testing/test_warning_types.py | 2 +- testing/typing_raises_group.py | 10 +- 13 files changed, 425 insertions(+), 309 deletions(-) create mode 100644 changelog/13192.feature.1.rst create mode 100644 changelog/13192.feature.2.rst create mode 100644 changelog/13192.feature.rst rename src/_pytest/{raises_group.py => raises.py} (75%) diff --git a/changelog/13192.feature.1.rst b/changelog/13192.feature.1.rst new file mode 100644 index 00000000000..71fb06f7d70 --- /dev/null +++ b/changelog/13192.feature.1.rst @@ -0,0 +1 @@ +:func:`pytest.raises` will now print a helpful string diff if matching fails and the match parameter has ``^`` and ``$`` and is otherwise escaped. diff --git a/changelog/13192.feature.2.rst b/changelog/13192.feature.2.rst new file mode 100644 index 00000000000..0ffa0e1496a --- /dev/null +++ b/changelog/13192.feature.2.rst @@ -0,0 +1 @@ +You can now pass :func:`with pytest.raises(check=fn): `, where ``fn`` is a function which takes a raised exception and returns a boolean. The ``raises`` fails if no exception was raised (as usual), passes if an exception is raised and ``fn`` returns ``True`` (as well as ``match`` and the type matching, if specified, which are checked before), and propagates the exception if ``fn`` returns ``False`` (which likely also fails the test). diff --git a/changelog/13192.feature.rst b/changelog/13192.feature.rst new file mode 100644 index 00000000000..97f31ce233c --- /dev/null +++ b/changelog/13192.feature.rst @@ -0,0 +1 @@ +:func:`pytest.raises` will now raise a warning when passing an empty string to ``match``, as this will match against any value. Use ``match="^$"`` if you want to check that an exception has no message. diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 81fed875ca0..7a49b1a9b0c 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -28,7 +28,7 @@ from _pytest.deprecated import check_ispytest from _pytest.deprecated import MARKED_FIXTURE from _pytest.outcomes import fail -from _pytest.raises_group import AbstractRaises +from _pytest.raises import AbstractRaises from _pytest.scope import _ScopeName from _pytest.warning_types import PytestUnknownMarkWarning diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 74ddd73005b..af078e25256 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -1,7 +1,6 @@ # mypy: allow-untyped-defs from __future__ import annotations -from collections.abc import Callable from collections.abc import Collection from collections.abc import Mapping from collections.abc import Sequence @@ -10,23 +9,14 @@ import math from numbers import Complex import pprint -import re import sys from typing import Any -from typing import overload from typing import TYPE_CHECKING -from typing import TypeVar - -from _pytest._code import ExceptionInfo -from _pytest.outcomes import fail -from _pytest.raises_group import RaisesExc if TYPE_CHECKING: from numpy import ndarray - E = TypeVar("E", bound=BaseException, default=BaseException) - def _compare_approx( full_object: object, @@ -778,230 +768,3 @@ def _as_numpy_array(obj: object) -> ndarray | None: elif hasattr(obj, "__array__") or hasattr("obj", "__array_interface__"): return np.asarray(obj) return None - - -# builtin pytest.raises helper -# FIXME: This should probably me moved to 'src/_pytest.raises_group.py' -# (and rename the file to 'raises.py') -# since it's much more closely tied to those than to the other stuff in this file. - - -@overload -def raises( - expected_exception: type[E] | tuple[type[E], ...], - *, - match: str | re.Pattern[str] | None = ..., - check: Callable[[E], bool] = ..., -) -> RaisesExc[E]: ... - - -@overload -def raises( - *, - match: str | re.Pattern[str], - # If exception_type is not provided, check() must do any typechecks itself. - check: Callable[[BaseException], bool] = ..., -) -> RaisesExc[BaseException]: ... - - -@overload -def raises(*, check: Callable[[BaseException], bool]) -> RaisesExc[BaseException]: ... - - -@overload -def raises( - expected_exception: type[E] | tuple[type[E], ...], - func: Callable[..., Any], - *args: Any, - **kwargs: Any, -) -> ExceptionInfo[E]: ... - - -def raises( - expected_exception: type[E] | tuple[type[E], ...] | None = None, - *args: Any, - **kwargs: Any, -) -> RaisesExc[BaseException] | ExceptionInfo[E]: - r"""Assert that a code block/function call raises an exception type, or one of its subclasses. - - :param expected_exception: - The expected exception type, or a tuple if one of multiple possible - exception types are expected. Note that subclasses of the passed exceptions - will also match. - - :kwparam str | re.Pattern[str] | None match: - If specified, a string containing a regular expression, - or a regular expression object, that is tested against the string - representation of the exception and its :pep:`678` `__notes__` - using :func:`re.search`. - - To match a literal string that may contain :ref:`special characters - `, the pattern can first be escaped with :func:`re.escape`. - - (This is only used when ``pytest.raises`` is used as a context manager, - and passed through to the function otherwise. - When using ``pytest.raises`` as a function, you can use: - ``pytest.raises(Exc, func, match="passed on").match("my pattern")``.) - - Use ``pytest.raises`` as a context manager, which will capture the exception of the given - type, or any of its subclasses:: - - >>> import pytest - >>> with pytest.raises(ZeroDivisionError): - ... 1/0 - - If the code block does not raise the expected exception (:class:`ZeroDivisionError` in the example - above), or no exception at all, the check will fail instead. - - You can also use the keyword argument ``match`` to assert that the - exception matches a text or regex:: - - >>> with pytest.raises(ValueError, match='must be 0 or None'): - ... raise ValueError("value must be 0 or None") - - >>> with pytest.raises(ValueError, match=r'must be \d+$'): - ... raise ValueError("value must be 42") - - The ``match`` argument searches the formatted exception string, which includes any - `PEP-678 `__ ``__notes__``: - - >>> with pytest.raises(ValueError, match=r"had a note added"): # doctest: +SKIP - ... e = ValueError("value must be 42") - ... e.add_note("had a note added") - ... raise e - - The context manager produces an :class:`ExceptionInfo` object which can be used to inspect the - details of the captured exception:: - - >>> with pytest.raises(ValueError) as exc_info: - ... raise ValueError("value must be 42") - >>> assert exc_info.type is ValueError - >>> assert exc_info.value.args[0] == "value must be 42" - - .. warning:: - - Given that ``pytest.raises`` matches subclasses, be wary of using it to match :class:`Exception` like this:: - - # Careful, this will catch ANY exception raised. - with pytest.raises(Exception): - some_function() - - Because :class:`Exception` is the base class of almost all exceptions, it is easy for this to hide - real bugs, where the user wrote this expecting a specific exception, but some other exception is being - raised due to a bug introduced during a refactoring. - - Avoid using ``pytest.raises`` to catch :class:`Exception` unless certain that you really want to catch - **any** exception raised. - - .. note:: - - When using ``pytest.raises`` as a context manager, it's worthwhile to - note that normal context manager rules apply and that the exception - raised *must* be the final line in the scope of the context manager. - Lines of code after that, within the scope of the context manager will - not be executed. For example:: - - >>> value = 15 - >>> with pytest.raises(ValueError) as exc_info: - ... if value > 10: - ... raise ValueError("value must be <= 10") - ... assert exc_info.type is ValueError # This will not execute. - - Instead, the following approach must be taken (note the difference in - scope):: - - >>> with pytest.raises(ValueError) as exc_info: - ... if value > 10: - ... raise ValueError("value must be <= 10") - ... - >>> assert exc_info.type is ValueError - - **Expecting exception groups** - - When expecting exceptions wrapped in :exc:`BaseExceptionGroup` or - :exc:`ExceptionGroup`, you should instead use :class:`pytest.RaisesGroup`. - - **Using with** ``pytest.mark.parametrize`` - - When using :ref:`pytest.mark.parametrize ref` - it is possible to parametrize tests such that - some runs raise an exception and others do not. - - See :ref:`parametrizing_conditional_raising` for an example. - - .. seealso:: - - :ref:`assertraises` for more examples and detailed discussion. - - **Legacy form** - - It is possible to specify a callable by passing a to-be-called lambda:: - - >>> raises(ZeroDivisionError, lambda: 1/0) - - - or you can specify an arbitrary callable with arguments:: - - >>> def f(x): return 1/x - ... - >>> raises(ZeroDivisionError, f, 0) - - >>> raises(ZeroDivisionError, f, x=0) - - - The form above is fully supported but discouraged for new code because the - context manager form is regarded as more readable and less error-prone. - - .. note:: - Similar to caught exception objects in Python, explicitly clearing - local references to returned ``ExceptionInfo`` objects can - help the Python interpreter speed up its garbage collection. - - Clearing those references breaks a reference cycle - (``ExceptionInfo`` --> caught exception --> frame stack raising - the exception --> current frame stack --> local variables --> - ``ExceptionInfo``) which makes Python keep all objects referenced - from that cycle (including all local variables in the current - frame) alive until the next cyclic garbage collection run. - More detailed information can be found in the official Python - documentation for :ref:`the try statement `. - """ - __tracebackhide__ = True - - if not args: - if set(kwargs) - {"match", "check", "expected_exception"}: - msg = "Unexpected keyword arguments passed to pytest.raises: " - msg += ", ".join(sorted(kwargs)) - msg += "\nUse context-manager form instead?" - raise TypeError(msg) - - if expected_exception is None: - return RaisesExc(**kwargs) - return RaisesExc(expected_exception, **kwargs) - - if not expected_exception: - raise ValueError( - f"Expected an exception type or a tuple of exception types, but got `{expected_exception!r}`. " - f"Raising exceptions is already understood as failing the test, so you don't need " - f"any special code to say 'this should never raise an exception'." - ) - func = args[0] - if not callable(func): - raise TypeError(f"{func!r} object (type: {type(func)}) must be callable") - with RaisesExc(expected_exception) as excinfo: - func(*args[1:], **kwargs) - try: - return excinfo - finally: - del excinfo - - -# note: RaisesExc/RaisesGroup uses fail() internally, so this alias -# indicates (to [internal] plugins?) that `pytest.raises` will -# raise `_pytest.outcomes.Failed`, where -# `outcomes.Failed is outcomes.fail.Exception is raises.Exception` -# note: this is *not* the same as `_pytest.main.Failed` -# note: mypy does not recognize this attribute, and it's not possible -# to use a protocol/decorator like the others in outcomes due to -# https://github.com/python/mypy/issues/18715 -raises.Exception = fail.Exception # type: ignore[attr-defined] diff --git a/src/_pytest/raises_group.py b/src/_pytest/raises.py similarity index 75% rename from src/_pytest/raises_group.py rename to src/_pytest/raises.py index 010b8b9f629..2eba53bf10b 100644 --- a/src/_pytest/raises_group.py +++ b/src/_pytest/raises.py @@ -43,6 +43,9 @@ default=BaseException, covariant=True, ) + + # Use short name because it shows up in docs. + E = TypeVar("E", bound=BaseException, default=BaseException) else: from typing import TypeVar @@ -66,6 +69,248 @@ _REGEX_NO_FLAGS = re.compile(r"").flags +# pytest.raises helper +@overload +def raises( + expected_exception: type[E] | tuple[type[E], ...], + *, + match: str | re.Pattern[str] | None = ..., + check: Callable[[E], bool] = ..., +) -> RaisesExc[E]: ... + + +@overload +def raises( + *, + match: str | re.Pattern[str], + # If exception_type is not provided, check() must do any typechecks itself. + check: Callable[[BaseException], bool] = ..., +) -> RaisesExc[BaseException]: ... + + +@overload +def raises(*, check: Callable[[BaseException], bool]) -> RaisesExc[BaseException]: ... + + +@overload +def raises( + expected_exception: type[E] | tuple[type[E], ...], + func: Callable[..., Any], + *args: Any, + **kwargs: Any, +) -> ExceptionInfo[E]: ... + + +def raises( + expected_exception: type[E] | tuple[type[E], ...] | None = None, + *args: Any, + **kwargs: Any, +) -> RaisesExc[BaseException] | ExceptionInfo[E]: + r"""Assert that a code block/function call raises an exception type, or one of its subclasses. + + :param expected_exception: + The expected exception type, or a tuple if one of multiple possible + exception types are expected. Note that subclasses of the passed exceptions + will also match. + + This is not a required parameter, you may opt to only use ``match`` and/or + ``check`` for verifying the raised exception. + + :kwparam str | re.Pattern[str] | None match: + If specified, a string containing a regular expression, + or a regular expression object, that is tested against the string + representation of the exception and its :pep:`678` `__notes__` + using :func:`re.search`. + + To match a literal string that may contain :ref:`special characters + `, the pattern can first be escaped with :func:`re.escape`. + + (This is only used when ``pytest.raises`` is used as a context manager, + and passed through to the function otherwise. + When using ``pytest.raises`` as a function, you can use: + ``pytest.raises(Exc, func, match="passed on").match("my pattern")``.) + + :kwparam Callable[[BaseException], bool] check: + + .. versionadded:: 8.4 + + If specified, a callable that will be called with the exception as a parameter + after checking the type and the match regex if specified. + If it returns ``True`` it will be considered a match, if not it will + be considered a failed match. + + + Use ``pytest.raises`` as a context manager, which will capture the exception of the given + type, or any of its subclasses:: + + >>> import pytest + >>> with pytest.raises(ZeroDivisionError): + ... 1/0 + + If the code block does not raise the expected exception (:class:`ZeroDivisionError` in the example + above), or no exception at all, the check will fail instead. + + You can also use the keyword argument ``match`` to assert that the + exception matches a text or regex:: + + >>> with pytest.raises(ValueError, match='must be 0 or None'): + ... raise ValueError("value must be 0 or None") + + >>> with pytest.raises(ValueError, match=r'must be \d+$'): + ... raise ValueError("value must be 42") + + The ``match`` argument searches the formatted exception string, which includes any + `PEP-678 `__ ``__notes__``: + + >>> with pytest.raises(ValueError, match=r"had a note added"): # doctest: +SKIP + ... e = ValueError("value must be 42") + ... e.add_note("had a note added") + ... raise e + + The ``check`` argument, if provided, must return True when passed the raised exception + for the match to be successful, otherwise an :exc:`AssertionError` is raised. + + >>> import errno + >>> with pytest.raises(OSError, check=lambda e: e.errno == errno.EACCES): + ... raise OSError(errno.EACCES, "no permission to view") + + The context manager produces an :class:`ExceptionInfo` object which can be used to inspect the + details of the captured exception:: + + >>> with pytest.raises(ValueError) as exc_info: + ... raise ValueError("value must be 42") + >>> assert exc_info.type is ValueError + >>> assert exc_info.value.args[0] == "value must be 42" + + .. warning:: + + Given that ``pytest.raises`` matches subclasses, be wary of using it to match :class:`Exception` like this:: + + # Careful, this will catch ANY exception raised. + with pytest.raises(Exception): + some_function() + + Because :class:`Exception` is the base class of almost all exceptions, it is easy for this to hide + real bugs, where the user wrote this expecting a specific exception, but some other exception is being + raised due to a bug introduced during a refactoring. + + Avoid using ``pytest.raises`` to catch :class:`Exception` unless certain that you really want to catch + **any** exception raised. + + .. note:: + + When using ``pytest.raises`` as a context manager, it's worthwhile to + note that normal context manager rules apply and that the exception + raised *must* be the final line in the scope of the context manager. + Lines of code after that, within the scope of the context manager will + not be executed. For example:: + + >>> value = 15 + >>> with pytest.raises(ValueError) as exc_info: + ... if value > 10: + ... raise ValueError("value must be <= 10") + ... assert exc_info.type is ValueError # This will not execute. + + Instead, the following approach must be taken (note the difference in + scope):: + + >>> with pytest.raises(ValueError) as exc_info: + ... if value > 10: + ... raise ValueError("value must be <= 10") + ... + >>> assert exc_info.type is ValueError + + **Expecting exception groups** + + When expecting exceptions wrapped in :exc:`BaseExceptionGroup` or + :exc:`ExceptionGroup`, you should instead use :class:`pytest.RaisesGroup`. + + **Using with** ``pytest.mark.parametrize`` + + When using :ref:`pytest.mark.parametrize ref` + it is possible to parametrize tests such that + some runs raise an exception and others do not. + + See :ref:`parametrizing_conditional_raising` for an example. + + .. seealso:: + + :ref:`assertraises` for more examples and detailed discussion. + + **Legacy form** + + It is possible to specify a callable by passing a to-be-called lambda:: + + >>> raises(ZeroDivisionError, lambda: 1/0) + + + or you can specify an arbitrary callable with arguments:: + + >>> def f(x): return 1/x + ... + >>> raises(ZeroDivisionError, f, 0) + + >>> raises(ZeroDivisionError, f, x=0) + + + The form above is fully supported but discouraged for new code because the + context manager form is regarded as more readable and less error-prone. + + .. note:: + Similar to caught exception objects in Python, explicitly clearing + local references to returned ``ExceptionInfo`` objects can + help the Python interpreter speed up its garbage collection. + + Clearing those references breaks a reference cycle + (``ExceptionInfo`` --> caught exception --> frame stack raising + the exception --> current frame stack --> local variables --> + ``ExceptionInfo``) which makes Python keep all objects referenced + from that cycle (including all local variables in the current + frame) alive until the next cyclic garbage collection run. + More detailed information can be found in the official Python + documentation for :ref:`the try statement `. + """ + __tracebackhide__ = True + + if not args: + if set(kwargs) - {"match", "check", "expected_exception"}: + msg = "Unexpected keyword arguments passed to pytest.raises: " + msg += ", ".join(sorted(kwargs)) + msg += "\nUse context-manager form instead?" + raise TypeError(msg) + + if expected_exception is None: + return RaisesExc(**kwargs) + return RaisesExc(expected_exception, **kwargs) + + if not expected_exception: + raise ValueError( + f"Expected an exception type or a tuple of exception types, but got `{expected_exception!r}`. " + f"Raising exceptions is already understood as failing the test, so you don't need " + f"any special code to say 'this should never raise an exception'." + ) + func = args[0] + if not callable(func): + raise TypeError(f"{func!r} object (type: {type(func)}) must be callable") + with RaisesExc(expected_exception) as excinfo: + func(*args[1:], **kwargs) + try: + return excinfo + finally: + del excinfo + + +# note: RaisesExc/RaisesGroup uses fail() internally, so this alias +# indicates (to [internal] plugins?) that `pytest.raises` will +# raise `_pytest.outcomes.Failed`, where +# `outcomes.Failed is outcomes.fail.Exception is raises.Exception` +# note: this is *not* the same as `_pytest.main.Failed` +# note: mypy does not recognize this attribute, and it's not possible +# to use a protocol/decorator like the others in outcomes due to +# https://github.com/python/mypy/issues/18715 +raises.Exception = fail.Exception # type: ignore[attr-defined] + + def _match_pattern(match: Pattern[str]) -> str | Pattern[str]: """Helper function to remove redundant `re.compile` calls when printing regex""" return match.pattern if match.flags == _REGEX_NO_FLAGS else match @@ -139,6 +384,7 @@ class AbstractRaises(ABC, Generic[BaseExcT_co]): def __init__( self, + *, match: str | Pattern[str] | None, check: Callable[[BaseExcT_co], bool] | None, ) -> None: @@ -217,9 +463,13 @@ def _parse_exc( f"generic argument specific nested exceptions has to be checked " f"with `RaisesGroup`." ) - not_a = exc.__name__ if isinstance(exc, type) else type(exc).__name__ - msg = f"expected exception must be {expected}, not {not_a}" - raise TypeError(msg) + # unclear if the Type/ValueError distinction is even helpful here + msg = f"expected exception must be {expected}, not " + if isinstance(exc, type): + raise ValueError(msg + f"{exc.__name__!r}") + if isinstance(exc, BaseException): + raise TypeError(msg + f"an exception instance ({type(exc).__name__})") + raise TypeError(msg + repr(type(exc).__name__)) @property def fail_reason(self) -> str | None: @@ -294,13 +544,29 @@ class RaisesExc(AbstractRaises[BaseExcT_co_default]): """ .. versionadded:: 8.4 - Helper class to be used together with RaisesGroup when you want to specify requirements on sub-exceptions. + + This is the class constructed when calling :func:`pytest.raises`, but may be used + directly as a helper class with :class:`RaisesGroup` when you want to specify + requirements on sub-exceptions. You don't need this if you only want to specify the type, since :class:`RaisesGroup` accepts ``type[BaseException]``. - The type is checked with :func:`isinstance`, and does not need to be an exact match. - If that is wanted you can use the ``check`` parameter. + :param type[BaseException] | tuple[type[BaseException]] | None expected_exception: + The expected type, or one of several possible types. + May be ``None`` in order to only make use of ``match`` and/or ``check`` + + The type is checked with :func:`isinstance`, and does not need to be an exact match. + If that is wanted you can use the ``check`` parameter. + + :kwparam str | Pattern[str] match + A regex to match. + + :kwparam Callable[[BaseException], bool] check: + If specified, a callable that will be called with the exception as a parameter + after checking the type and the match regex if specified. + If it returns ``True`` it will be considered a match, if not it will + be considered a failed match. :meth:`RaisesExc.matches` can also be used standalone to check individual exceptions. @@ -326,6 +592,8 @@ def __init__( expected_exception: ( type[BaseExcT_co_default] | tuple[type[BaseExcT_co_default], ...] ), + /, + *, match: str | Pattern[str] | None = ..., check: Callable[[BaseExcT_co_default], bool] | None = ..., ) -> None: ... @@ -333,6 +601,7 @@ def __init__( @overload def __init__( self: RaisesExc[BaseException], # Give E a value. + /, *, match: str | Pattern[str] | None, # If exception_type is not provided, check() must do any typechecks itself. @@ -340,17 +609,19 @@ def __init__( ) -> None: ... @overload - def __init__(self, *, check: Callable[[BaseException], bool]) -> None: ... + def __init__(self, /, *, check: Callable[[BaseException], bool]) -> None: ... def __init__( self, expected_exception: ( type[BaseExcT_co_default] | tuple[type[BaseExcT_co_default], ...] | None ) = None, + /, + *, match: str | Pattern[str] | None = None, check: Callable[[BaseExcT_co_default], bool] | None = None, ): - super().__init__(match, check) + super().__init__(match=match, check=check) if isinstance(expected_exception, tuple): expected_exceptions = expected_exception elif expected_exception is None: @@ -366,6 +637,8 @@ def __init__( for e in expected_exceptions ) + self._just_propagate = False + def matches( self, exception: BaseException | None, @@ -388,10 +661,12 @@ def matches( assert re.search("foo", str(excinfo.value.__cause__) """ + self._just_propagate = False if exception is None: self._fail_reason = "exception is None" return False if not self._check_type(exception): + self._just_propagate = True return False if not self._check_match(exception): @@ -441,6 +716,8 @@ def __exit__( ) if not self.matches(exc_val): + if self._just_propagate: + return False raise AssertionError(self._fail_reason) # Cast to narrow the exception type now that it's verified.... @@ -463,49 +740,77 @@ class RaisesGroup(AbstractRaises[BaseExceptionGroup[BaseExcT_co]]): :meth:`ExceptionInfo.group_contains` also tries to handle exception groups, but it is very bad at checking that you *didn't* get unexpected exceptions. - The catching behaviour differs from :ref:`except* `, being much stricter about the structure by default. By using ``allow_unwrapped=True`` and ``flatten_subgroups=True`` you can match :ref:`except* ` fully when expecting a single exception. - #. All specified exceptions must be present, *and no others*. - - * If you expect a variable number of exceptions you need to use - :func:`pytest.raises(ExceptionGroup) ` and manually check - the contained exceptions. Consider making use of :meth:`RaisesExc.matches`. - - #. It will only catch exceptions wrapped in an exceptiongroup by default. - - * With ``allow_unwrapped=True`` you can specify a single expected exception (or :class:`RaisesExc`) and it will - match the exception even if it is not inside an :exc:`ExceptionGroup`. - If you expect one of several different exception types you need to use a :class:`RaisesExc` object. - - #. By default it cares about the full structure with nested :exc:`ExceptionGroup`'s. You can specify nested - :exc:`ExceptionGroup`'s by passing :class:`RaisesGroup` objects as expected exceptions. - - * With ``flatten_subgroups=True`` it will "flatten" the raised :exc:`ExceptionGroup`, - extracting all exceptions inside any nested :exc:`ExceptionGroup`, before matching. - - It does not care about the order of the exceptions, so - ``RaisesGroup(ValueError, TypeError)`` - is equivalent to - ``RaisesGroup(TypeError, ValueError)``. + :param args: + Any number of exception types, :class:`RaisesGroup` or :class:`RaisesExc` + to specify the exceptions contained in this exception. + All specified exceptions must be present in the raised group, *and no others*. + + If you expect a variable number of exceptions you need to use + :func:`pytest.raises(ExceptionGroup) ` and manually check + the contained exceptions. Consider making use of :meth:`RaisesExc.matches`. + + It does not care about the order of the exceptions, so + ``RaisesGroup(ValueError, TypeError)`` + is equivalent to + ``RaisesGroup(TypeError, ValueError)``. + :kwparam str | re.Pattern[str] | None match: + If specified, a string containing a regular expression, + or a regular expression object, that is tested against the string + representation of the exception group and its :pep:`678` `__notes__` + using :func:`re.search`. + + To match a literal string that may contain :ref:`special characters + `, the pattern can first be escaped with :func:`re.escape`. + + Note that " (5 subgroups)" will be stripped from the ``repr`` before matching. + :kwparam Callable[[E], bool] check: + If specified, a callable that will be called with the group as a parameter + after successfully matching the expected exceptions. If it returns ``True`` + it will be considered a match, if not it will be considered a failed match. + :kwparam bool allow_unwrapped: + If expecting a single exception or :class:`RaisesExc` it will match even + if the exception is not inside an exceptiongroup. + + Using this together with ``match``, ``check`` or expecting multiple exceptions + will raise an error. + :kwparam bool flatten_subgroups: + "flatten" any groups inside the raised exception group, extracting all exceptions + inside any nested groups, before matching. Without this it expects you to + fully specify the nesting structure by passing :class:`RaisesGroup` as expected + parameter. Examples:: with RaisesGroup(ValueError): raise ExceptionGroup("", (ValueError(),)) + # match with RaisesGroup( - ValueError, ValueError, RaisesExc(TypeError, match="expected int") + ValueError, + ValueError, + RaisesExc(TypeError, match="^expected int$"), + match="^my group$", ): - ... + raise ExceptionGroup( + "my group", + [ + ValueError(), + TypeError("expected int"), + ValueError(), + ], + ) + # check with RaisesGroup( KeyboardInterrupt, - match="hello", - check=lambda x: type(x) is BaseExceptionGroup, + match="^hello$", + check=lambda x: isinstance(x.__cause__, ValueError), ): - ... + raise BaseExceptionGroup("hello", [KeyboardInterrupt()]) from ValueError + # nested groups with RaisesGroup(RaisesGroup(ValueError)): raise ExceptionGroup("", (ExceptionGroup("", (ValueError(),)),)) @@ -544,6 +849,7 @@ class RaisesGroup(AbstractRaises[BaseExceptionGroup[BaseExcT_co]]): def __init__( self, expected_exception: type[BaseExcT_co] | RaisesExc[BaseExcT_co], + /, *, allow_unwrapped: Literal[True], flatten_subgroups: bool = False, @@ -554,6 +860,7 @@ def __init__( def __init__( self, expected_exception: type[BaseExcT_co] | RaisesExc[BaseExcT_co], + /, *other_exceptions: type[BaseExcT_co] | RaisesExc[BaseExcT_co], flatten_subgroups: Literal[True], match: str | Pattern[str] | None = None, @@ -569,6 +876,7 @@ def __init__( def __init__( self: RaisesGroup[ExcT_1], expected_exception: type[ExcT_1] | RaisesExc[ExcT_1], + /, *other_exceptions: type[ExcT_1] | RaisesExc[ExcT_1], match: str | Pattern[str] | None = None, check: Callable[[ExceptionGroup[ExcT_1]], bool] | None = None, @@ -578,6 +886,7 @@ def __init__( def __init__( self: RaisesGroup[ExceptionGroup[ExcT_2]], expected_exception: RaisesGroup[ExcT_2], + /, *other_exceptions: RaisesGroup[ExcT_2], match: str | Pattern[str] | None = None, check: Callable[[ExceptionGroup[ExceptionGroup[ExcT_2]]], bool] | None = None, @@ -587,6 +896,7 @@ def __init__( def __init__( self: RaisesGroup[ExcT_1 | ExceptionGroup[ExcT_2]], expected_exception: type[ExcT_1] | RaisesExc[ExcT_1] | RaisesGroup[ExcT_2], + /, *other_exceptions: type[ExcT_1] | RaisesExc[ExcT_1] | RaisesGroup[ExcT_2], match: str | Pattern[str] | None = None, check: ( @@ -599,6 +909,7 @@ def __init__( def __init__( self: RaisesGroup[BaseExcT_1], expected_exception: type[BaseExcT_1] | RaisesExc[BaseExcT_1], + /, *other_exceptions: type[BaseExcT_1] | RaisesExc[BaseExcT_1], match: str | Pattern[str] | None = None, check: Callable[[BaseExceptionGroup[BaseExcT_1]], bool] | None = None, @@ -608,6 +919,7 @@ def __init__( def __init__( self: RaisesGroup[BaseExceptionGroup[BaseExcT_2]], expected_exception: RaisesGroup[BaseExcT_2], + /, *other_exceptions: RaisesGroup[BaseExcT_2], match: str | Pattern[str] | None = None, check: ( @@ -621,6 +933,7 @@ def __init__( expected_exception: type[BaseExcT_1] | RaisesExc[BaseExcT_1] | RaisesGroup[BaseExcT_2], + /, *other_exceptions: type[BaseExcT_1] | RaisesExc[BaseExcT_1] | RaisesGroup[BaseExcT_2], @@ -639,6 +952,7 @@ def __init__( expected_exception: type[BaseExcT_1] | RaisesExc[BaseExcT_1] | RaisesGroup[BaseExcT_2], + /, *other_exceptions: type[BaseExcT_1] | RaisesExc[BaseExcT_1] | RaisesGroup[BaseExcT_2], @@ -660,7 +974,7 @@ def __init__( "], bool]", check, ) - super().__init__(match, check) + super().__init__(match=match, check=check) self.allow_unwrapped = allow_unwrapped self.flatten_subgroups: bool = flatten_subgroups self.is_baseexception = False @@ -724,8 +1038,14 @@ def _parse_excgroup( self.is_baseexception |= exc.is_baseexception exc._nested = True return exc + elif isinstance(exc, tuple): + raise TypeError( + f"expected exception must be {expected}, not {type(exc).__name__!r}.\n" + "RaisesGroup does not support tuples of exception types when expecting one of " + "several possible exception types like RaisesExc.\n" + "If you meant to expect a group with multiple exceptions, list them as separate arguments." + ) else: - # validate_exc transforms GenericAlias ExceptionGroup[Exception] -> type[ExceptionGroup] return super()._parse_exc(exc, expected) @overload diff --git a/src/_pytest/skipping.py b/src/_pytest/skipping.py index 20efefb84df..96281faec97 100644 --- a/src/_pytest/skipping.py +++ b/src/_pytest/skipping.py @@ -20,7 +20,7 @@ from _pytest.outcomes import fail from _pytest.outcomes import skip from _pytest.outcomes import xfail -from _pytest.raises_group import AbstractRaises +from _pytest.raises import AbstractRaises from _pytest.reports import BaseReport from _pytest.reports import TestReport from _pytest.runner import CallInfo diff --git a/src/pytest/__init__.py b/src/pytest/__init__.py index e5098fe6e61..e36d3e704c1 100644 --- a/src/pytest/__init__.py +++ b/src/pytest/__init__.py @@ -60,9 +60,9 @@ from _pytest.python import Module from _pytest.python import Package from _pytest.python_api import approx -from _pytest.python_api import raises -from _pytest.raises_group import RaisesExc -from _pytest.raises_group import RaisesGroup +from _pytest.raises import raises +from _pytest.raises import RaisesExc +from _pytest.raises import RaisesGroup from _pytest.recwarn import deprecated_call from _pytest.recwarn import WarningsRecorder from _pytest.recwarn import warns diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 438a5259f20..89088576980 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -481,9 +481,8 @@ def test_raises_exception_escapes_generic_group() -> None: try: with pytest.raises(ExceptionGroup[Exception]): raise ValueError("my value error") - except AssertionError as e: - assert str(e) == "`ValueError()` is not an instance of `ExceptionGroup`" - assert str(e.__context__) == "my value error" + except ValueError as e: + assert str(e) == "my value error" else: pytest.fail("Expected ValueError to be raised") diff --git a/testing/python/raises.py b/testing/python/raises.py index 333e273db6a..3da260d1837 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -108,7 +108,7 @@ def test_noraise(): int() def test_raise_wrong_exception_passes_by(): - with pytest.raises(AssertionError): + with pytest.raises(ZeroDivisionError): with pytest.raises(ValueError): 1/0 """ @@ -310,8 +310,8 @@ def test_raises_match_wrong_type(self): really relevant if we got a different exception. """ with pytest.raises( - AssertionError, - match=wrap_escape("`ValueError()` is not an instance of `IndexError`"), + ValueError, + match=wrap_escape("invalid literal for int() with base 10: 'asdf'"), ): with pytest.raises(IndexError, match="nomatch"): int("asdf") @@ -361,23 +361,35 @@ def test_raises_context_manager_with_kwargs(self): pass def test_expected_exception_is_not_a_baseexception(self) -> None: - with pytest.raises(TypeError) as excinfo: + with pytest.raises( + TypeError, + match=wrap_escape( + "expected exception must be a BaseException type, not 'str'" + ), + ): with pytest.raises("hello"): # type: ignore[call-overload] pass # pragma: no cover - assert "must be a BaseException type, not str" in str(excinfo.value) class NotAnException: pass - with pytest.raises(TypeError) as excinfo: + with pytest.raises( + ValueError, + match=wrap_escape( + "expected exception must be a BaseException type, not 'NotAnException'" + ), + ): with pytest.raises(NotAnException): # type: ignore[type-var] pass # pragma: no cover - assert "must be a BaseException type, not NotAnException" in str(excinfo.value) - with pytest.raises(TypeError) as excinfo: + with pytest.raises( + TypeError, + match=wrap_escape( + "expected exception must be a BaseException type, not 'str'" + ), + ): with pytest.raises(("hello", NotAnException)): # type: ignore[arg-type] pass # pragma: no cover - assert "must be a BaseException type, not str" in str(excinfo.value) def test_issue_11872(self) -> None: """Regression test for #11872. diff --git a/testing/python/raises_group.py b/testing/python/raises_group.py index 0dc2a58a1da..04979c32e98 100644 --- a/testing/python/raises_group.py +++ b/testing/python/raises_group.py @@ -10,9 +10,9 @@ from _pytest._code import ExceptionInfo from _pytest.outcomes import Failed from _pytest.pytester import Pytester -from _pytest.raises_group import RaisesExc -from _pytest.raises_group import RaisesGroup -from _pytest.raises_group import repr_callable +from _pytest.raises import RaisesExc +from _pytest.raises import RaisesGroup +from _pytest.raises import repr_callable import pytest @@ -34,11 +34,21 @@ def fails_raises_group(msg: str, add_prefix: bool = True) -> RaisesExc[Failed]: def test_raises_group() -> None: + with pytest.raises( + TypeError, + match=wrap_escape("expected exception must be a BaseException type, not 'int'"), + ): + RaisesExc(5) # type: ignore[call-overload] + with pytest.raises( + ValueError, + match=wrap_escape("expected exception must be a BaseException type, not 'int'"), + ): + RaisesExc(int) # type: ignore[type-var] with pytest.raises( TypeError, # TODO: bad sentence structure match=wrap_escape( - "expected exception must be a BaseException type, RaisesExc, or RaisesGroup, not ValueError", + "expected exception must be a BaseException type, RaisesExc, or RaisesGroup, not an exception instance (ValueError)", ), ): RaisesGroup(ValueError()) # type: ignore[call-overload] @@ -499,7 +509,7 @@ def check_message( # RaisesExc check_message( "ExceptionGroup(RaisesExc(ValueError, match='my_str'))", - RaisesGroup(RaisesExc(ValueError, "my_str")), + RaisesGroup(RaisesExc(ValueError, match="my_str")), ) check_message( "ExceptionGroup(RaisesExc(match='my_str'))", @@ -1067,9 +1077,9 @@ def test_raisesexc() -> None: ): RaisesExc() # type: ignore[call-overload] with pytest.raises( - TypeError, + ValueError, match=wrap_escape( - "expected exception must be a BaseException type, not object" + "expected exception must be a BaseException type, not 'object'" ), ): RaisesExc(object) # type: ignore[type-var] @@ -1110,14 +1120,14 @@ def test_raisesexc() -> None: # currently RaisesGroup says "Raised exception did not match" but RaisesExc doesn't... with pytest.raises( AssertionError, - match=wrap_escape("`TypeError()` is not an instance of `ValueError`"), + match=wrap_escape("Regex pattern did not match.\n Regex: 'foo'\n Input: 'bar'"), ): - with RaisesExc(ValueError): - raise TypeError + with RaisesExc(TypeError, match="foo"): + raise TypeError("bar") def test_raisesexc_match() -> None: - with RaisesGroup(RaisesExc(ValueError, "foo")): + with RaisesGroup(RaisesExc(ValueError, match="foo")): raise ExceptionGroup("", (ValueError("foo"),)) with ( fails_raises_group( @@ -1125,7 +1135,7 @@ def test_raisesexc_match() -> None: " Regex: 'foo'\n" " Input: 'bar'" ), - RaisesGroup(RaisesExc(ValueError, "foo")), + RaisesGroup(RaisesExc(ValueError, match="foo")), ): raise ExceptionGroup("", (ValueError("bar"),)) @@ -1328,6 +1338,11 @@ def test_tuples() -> None: # RaisesGroup(ValueError, TypeError), and the former might be interpreted as the latter. with pytest.raises( TypeError, - match="expected exception must be a BaseException type, RaisesExc, or RaisesGroup, not tuple", + match=wrap_escape( + "expected exception must be a BaseException type, RaisesExc, or RaisesGroup, not 'tuple'.\n" + "RaisesGroup does not support tuples of exception types when expecting one of " + "several possible exception types like RaisesExc.\n" + "If you meant to expect a group with multiple exceptions, list them as separate arguments." + ), ): RaisesGroup((ValueError, IndexError)) # type: ignore[call-overload] diff --git a/testing/test_warning_types.py b/testing/test_warning_types.py index 19fe0f8a272..7cbc4703c26 100644 --- a/testing/test_warning_types.py +++ b/testing/test_warning_types.py @@ -43,7 +43,7 @@ def test(): @pytest.mark.filterwarnings("error") def test_warn_explicit_for_annotates_errors_with_location(): - with pytest.raises(Warning, match="(?m)test\n at .*python_api.py:\\d+"): + with pytest.raises(Warning, match="(?m)test\n at .*raises.py:\\d+"): warning_types.warn_explicit_for( pytest.raises, # type: ignore[arg-type] warning_types.PytestWarning("test"), diff --git a/testing/typing_raises_group.py b/testing/typing_raises_group.py index f27943e3a58..c7dd16991ac 100644 --- a/testing/typing_raises_group.py +++ b/testing/typing_raises_group.py @@ -70,9 +70,8 @@ def check_exc(exc: BaseException) -> bool: # At least 1 arg must be provided. RaisesExc() # type: ignore RaisesExc(ValueError) - RaisesExc(ValueError, "regex") - RaisesExc(ValueError, "regex", check_exc) - RaisesExc(expected_exception=ValueError) + RaisesExc(ValueError, match="regex") + RaisesExc(ValueError, match="regex", check=check_exc) RaisesExc(match="regex") RaisesExc(check=check_exc) RaisesExc(ValueError, match="regex") @@ -87,6 +86,11 @@ def check_filenotfound(exc: FileNotFoundError) -> bool: RaisesExc(check=check_filenotfound) # type: ignore RaisesExc(FileNotFoundError, match="regex", check=check_filenotfound) + # exceptions are pos-only + RaisesExc(expected_exception=ValueError) # type: ignore + # match and check are kw-only + RaisesExc(ValueError, "regex") # type: ignore + def raisesgroup_check_type_narrowing() -> None: """Check type narrowing on the `check` argument to `RaisesGroup`. From 88164320f517277d81a3a337fd5dbb60622691ae Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 30 Mar 2025 10:59:58 +0200 Subject: [PATCH 365/445] [automated] Update plugin list (#13335) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 128 ++++++++++++++++++------------- 1 file changed, 76 insertions(+), 52 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 3e653676d69..de1ae7f7595 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =7.2 :pypi:`pytest-argus` pyest results colection plugin Jun 24, 2021 5 - Production/Stable pytest (>=6.2.4) - :pypi:`pytest-argus-server` A plugin that provides a running Argus API server for tests Mar 20, 2025 4 - Beta pytest>=6.2.0 + :pypi:`pytest-argus-server` A plugin that provides a running Argus API server for tests Mar 24, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-arraydiff` pytest plugin to help with comparing array output from tests Nov 27, 2023 4 - Beta pytest >=4.6 :pypi:`pytest-asgi-server` Convenient ASGI client/server fixtures for Pytest Dec 12, 2020 N/A pytest (>=5.4.1) :pypi:`pytest-aspec` A rspec format reporter for pytest Dec 20, 2023 4 - Beta N/A @@ -118,7 +118,7 @@ This list contains 1610 plugins. :pypi:`pytest-ast-transformer` May 04, 2019 3 - Alpha pytest :pypi:`pytest_async` pytest-async - Run your coroutine in event loop without decorator Feb 26, 2020 N/A N/A :pypi:`pytest-async-generators` Pytest fixtures for async generators Jul 05, 2023 N/A N/A - :pypi:`pytest-asyncio` Pytest support for asyncio Jan 28, 2025 4 - Beta pytest<9,>=8.2 + :pypi:`pytest-asyncio` Pytest support for asyncio Mar 25, 2025 4 - Beta pytest<9,>=8.2 :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Mar 16, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Jul 04, 2024 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) @@ -162,7 +162,7 @@ This list contains 1610 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Mar 22, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Mar 27, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -275,7 +275,7 @@ This list contains 1610 plugins. :pypi:`pytest_codeblocks` Test code blocks in your READMEs Sep 17, 2023 5 - Production/Stable pytest >= 7.0.0 :pypi:`pytest-codecarbon` Pytest plugin for measuring carbon emissions Jun 15, 2022 N/A pytest :pypi:`pytest-codecheckers` pytest plugin to add source code sanity checks (pep8 and friends) Feb 13, 2010 N/A N/A - :pypi:`pytest-codecov` Pytest plugin for uploading pytest-cov results to codecov.io Dec 11, 2024 4 - Beta pytest>=4.6.0 + :pypi:`pytest-codecov` Pytest plugin for uploading pytest-cov results to codecov.io Mar 25, 2025 4 - Beta pytest>=4.6.0 :pypi:`pytest-codegen` Automatically create pytest test signatures Aug 23, 2020 2 - Pre-Alpha N/A :pypi:`pytest-codeowners` Pytest plugin for selecting tests by GitHub CODEOWNERS. Mar 30, 2022 4 - Beta pytest (>=6.0.0) :pypi:`pytest-codestyle` pytest plugin to run pycodestyle Mar 23, 2020 3 - Alpha N/A @@ -338,7 +338,7 @@ This list contains 1610 plugins. :pypi:`pytest-dash` pytest fixtures to run dash applications. Mar 18, 2019 N/A N/A :pypi:`pytest-dashboard` May 30, 2024 N/A pytest<8.0.0,>=7.4.3 :pypi:`pytest-data` Useful functions for managing data for pytest fixtures Nov 01, 2016 5 - Production/Stable N/A - :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Feb 11, 2025 4 - Beta pytest + :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Mar 23, 2025 4 - Beta pytest :pypi:`pytest-databricks` Pytest plugin for remote Databricks notebooks testing Jul 29, 2020 N/A pytest :pypi:`pytest-datadir` pytest plugin for test data directories and files Feb 07, 2025 5 - Production/Stable pytest>=7.0 :pypi:`pytest-datadir-mgr` Manager for test data: downloads, artifact caching, and a tmpdir context. Apr 06, 2023 5 - Production/Stable pytest (>=7.1) @@ -466,7 +466,7 @@ This list contains 1610 plugins. :pypi:`pytest-duration-insights` Jul 15, 2024 N/A N/A :pypi:`pytest-durations` Pytest plugin reporting fixtures and test functions execution time. Mar 18, 2025 5 - Production/Stable pytest>=4.6 :pypi:`pytest-dynamicrerun` A pytest plugin to rerun tests dynamically based off of test outcome and output. Aug 15, 2020 4 - Beta N/A - :pypi:`pytest-dynamodb` DynamoDB fixtures for pytest Oct 25, 2024 5 - Production/Stable pytest + :pypi:`pytest-dynamodb` DynamoDB fixtures for pytest Mar 23, 2025 5 - Production/Stable pytest :pypi:`pytest-easy-addoption` pytest-easy-addoption: Easy way to work with pytest addoption Jan 22, 2020 N/A N/A :pypi:`pytest-easy-api` A package to prevent Dependency Confusion attacks against Yandex. Feb 16, 2024 N/A N/A :pypi:`pytest-easyMPI` Package that supports mpi tests in pytest Oct 21, 2020 N/A N/A @@ -520,7 +520,7 @@ This list contains 1610 plugins. :pypi:`pytest-eventlet` Applies eventlet monkey-patch as a pytest plugin. Oct 04, 2021 N/A pytest ; extra == 'dev' :pypi:`pytest_evm` The testing package containing tools to test Web3-based projects Sep 23, 2024 4 - Beta pytest<9.0.0,>=8.1.1 :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A - :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Nov 20, 2024 N/A pytest>=7 + :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Mar 23, 2025 N/A pytest>=7 :pypi:`pytest-exasol-backend` Feb 11, 2025 N/A pytest<9,>=7 :pypi:`pytest-exasol-extension` Feb 11, 2025 N/A pytest<9,>=7 :pypi:`pytest-exasol-itde` Nov 22, 2024 N/A pytest<9,>=7 @@ -643,7 +643,7 @@ This list contains 1610 plugins. :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Mar 21, 2025 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Mar 28, 2025 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -687,7 +687,7 @@ This list contains 1610 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Mar 22, 2025 3 - Alpha pytest==8.3.4 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Mar 29, 2025 3 - Alpha pytest==8.3.5 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -852,7 +852,7 @@ This list contains 1610 plugins. :pypi:`pytest-logger` Plugin configuring handlers for loggers from Python logging module. Mar 10, 2024 5 - Production/Stable pytest (>=3.2) :pypi:`pytest-logging` Configures logging and allows tweaking the log level with a py.test flag Nov 04, 2015 4 - Beta N/A :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-logging-strict` pytest fixture logging configured from packaged YAML Jan 19, 2025 3 - Alpha pytest + :pypi:`pytest-logging-strict` pytest fixture logging configured from packaged YAML Mar 23, 2025 3 - Alpha pytest :pypi:`pytest-logikal` Common testing environment Mar 02, 2025 5 - Production/Stable pytest==8.3.4 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Sep 30, 2024 4 - Beta pytest>=8.2.2 @@ -891,7 +891,7 @@ This list contains 1610 plugins. :pypi:`pytest-memray` A simple plugin to use with pytest Jul 25, 2024 N/A pytest>=7.2 :pypi:`pytest-menu` A pytest plugin for console based interactive test selection just after the collection phase Oct 04, 2017 3 - Alpha pytest (>=2.4.2) :pypi:`pytest-mercurial` pytest plugin to write integration tests for projects using Mercurial Python internals Nov 21, 2020 1 - Planning N/A - :pypi:`pytest-mergify` Pytest plugin for Mergify Mar 14, 2025 N/A N/A + :pypi:`pytest-mergify` Pytest plugin for Mergify Mar 27, 2025 N/A N/A :pypi:`pytest-mesh` pytest_mesh插件 Aug 05, 2022 N/A pytest (==7.1.2) :pypi:`pytest-message` Pytest plugin for sending report message of marked tests execution Aug 04, 2022 N/A pytest (>=6.2.5) :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A @@ -945,7 +945,7 @@ This list contains 1610 plugins. :pypi:`pytest-mutagen` Add the mutation testing feature to pytest Jul 24, 2020 N/A pytest (>=5.4) :pypi:`pytest-my-cool-lib` Nov 02, 2023 N/A pytest (>=7.1.3,<8.0.0) :pypi:`pytest-my-plugin` A pytest plugin that does awesome things Jan 27, 2025 N/A pytest>=6.0 - :pypi:`pytest-mypy` Mypy static type checker plugin for Pytest Dec 18, 2022 4 - Beta pytest (>=6.2) ; python_version >= "3.10" + :pypi:`pytest-mypy` A Pytest Plugin for Mypy Mar 28, 2025 5 - Production/Stable pytest>=7.0 :pypi:`pytest-mypyd` Mypy static type checker plugin for Pytest Aug 20, 2019 4 - Beta pytest (<4.7,>=2.8) ; python_version < "3.5" :pypi:`pytest-mypy-plugins` pytest plugin for writing tests for mypy plugins Dec 21, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-mypy-plugins-shim` Substitute for "pytest-mypy-plugins" for Python implementations which aren't supported by mypy. Feb 14, 2025 N/A pytest>=6.0.0 @@ -998,7 +998,7 @@ This list contains 1610 plugins. :pypi:`pytest-oot` Run object-oriented tests in a simple format Sep 18, 2016 4 - Beta N/A :pypi:`pytest-openfiles` Pytest plugin for detecting inadvertent open file handles Jun 05, 2024 3 - Alpha pytest>=4.6 :pypi:`pytest-opentelemetry` A pytest plugin for instrumenting test runs via OpenTelemetry Nov 22, 2024 N/A pytest - :pypi:`pytest-opentmi` pytest plugin for publish results to opentmi Sep 05, 2024 5 - Production/Stable pytest>=5.0 + :pypi:`pytest-opentmi` pytest plugin for publish results to opentmi Mar 22, 2025 5 - Production/Stable pytest>=5.0 :pypi:`pytest-operator` Fixtures for Operators Sep 28, 2022 N/A pytest :pypi:`pytest-optional` include/exclude values of fixtures in pytest Oct 07, 2015 N/A N/A :pypi:`pytest-optional-tests` Easy declaration of optional tests (i.e., that are not run by default) Jul 09, 2019 4 - Beta pytest (>=4.5.0) @@ -1013,6 +1013,7 @@ This list contains 1610 plugins. :pypi:`pytest-override-env-var` Pytest mark to override a value of an environment variable. Feb 25, 2023 N/A N/A :pypi:`pytest-owner` Add owner mark for tests Aug 19, 2024 N/A pytest :pypi:`pytest-pact` A simple plugin to use with pytest Jan 07, 2019 4 - Beta N/A + :pypi:`pytest-pagerduty` Pytest plugin for PagerDuty integration via automation testing. Mar 22, 2025 N/A pytest<9.0.0,>=7.4.0 :pypi:`pytest-pahrametahrize` Parametrize your tests with a Boston accent. Nov 24, 2021 4 - Beta pytest (>=6.0,<7.0) :pypi:`pytest-parallel` a pytest plugin for parallel and concurrent testing Oct 10, 2021 3 - Alpha pytest (>=3.0.0) :pypi:`pytest-parallel-39` a pytest plugin for parallel and concurrent testing Jul 12, 2021 3 - Alpha pytest (>=3.0.0) @@ -1068,11 +1069,13 @@ This list contains 1610 plugins. :pypi:`pytest-playwright` A pytest wrapper with fixtures for Playwright to automate web browsers Jan 31, 2025 N/A pytest<9.0.0,>=6.2.4 :pypi:`pytest_playwright_async` ASYNC Pytest plugin for Playwright Sep 28, 2024 N/A N/A :pypi:`pytest-playwright-asyncio` A pytest wrapper with async fixtures for Playwright to automate web browsers Jan 31, 2025 N/A pytest<9.0.0,>=6.2.4 + :pypi:`pytest-playwright-axe` An axe-core integration for accessibility testing using Playwright Python. Mar 27, 2025 4 - Beta N/A :pypi:`pytest-playwright-enhanced` A pytest plugin for playwright python Mar 24, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-playwrights` A pytest wrapper with fixtures for Playwright to automate web browsers Dec 02, 2021 N/A N/A :pypi:`pytest-playwright-snapshot` A pytest wrapper for snapshot testing with playwright Aug 19, 2021 N/A N/A :pypi:`pytest-playwright-visual` A pytest fixture for visual testing with Playwright Apr 28, 2022 N/A N/A - :pypi:`pytest-plone` Pytest plugin to test Plone addons May 15, 2024 3 - Alpha pytest<8.0.0 + :pypi:`pytest-playwright-visual-snapshot` Easy pytest visual regression testing using playwright Mar 25, 2025 N/A N/A + :pypi:`pytest-plone` Pytest plugin to test Plone addons Mar 27, 2025 3 - Alpha pytest<8.0.0 :pypi:`pytest-plt` Fixtures for quickly making Matplotlib plots in tests Jan 17, 2024 5 - Production/Stable pytest :pypi:`pytest-plugin-helpers` A plugin to help developing and testing other plugins Nov 23, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-plus` PyTest Plus Plugin :: extends pytest functionality Feb 02, 2025 5 - Production/Stable pytest>=7.4.2 @@ -1253,7 +1256,7 @@ This list contains 1610 plugins. :pypi:`pytest-rmsis` Sycronise pytest results to Jira RMsis Aug 10, 2022 N/A pytest (>=5.3.5) :pypi:`pytest-rng` Fixtures for seeding tests and making randomness reproducible Aug 08, 2019 5 - Production/Stable pytest :pypi:`pytest-roast` pytest plugin for ROAST configuration override and fixtures Nov 09, 2022 5 - Production/Stable pytest - :pypi:`pytest_robotframework` a pytest plugin that can run both python and robotframework tests while generating robot reports for them Oct 15, 2024 N/A pytest<9,>=7 + :pypi:`pytest_robotframework` a pytest plugin that can run both python and robotframework tests while generating robot reports for them Mar 28, 2025 N/A pytest<9,>=7 :pypi:`pytest-rocketchat` Pytest to Rocket.Chat reporting plugin Apr 18, 2021 5 - Production/Stable N/A :pypi:`pytest-rotest` Pytest integration with rotest Sep 08, 2019 N/A pytest (>=3.5.0) :pypi:`pytest-rpc` Extend py.test for RPC OpenStack testing. Feb 22, 2019 4 - Beta pytest (~=3.6) @@ -1280,19 +1283,19 @@ This list contains 1610 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Mar 22, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Mar 29, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A :pypi:`pytest-schema` 👍 Validate return values against a schema-like object in testing Feb 16, 2024 5 - Production/Stable pytest >=3.5.0 - :pypi:`pytest-scim2-server` SCIM2 server fixture for Pytest Jan 27, 2025 N/A pytest>=8.3.4 + :pypi:`pytest-scim2-server` SCIM2 server fixture for Pytest Mar 28, 2025 N/A pytest>=8.3.4 :pypi:`pytest-screenshot-on-failure` Saves a screenshot when a test case from a pytest execution fails Jul 21, 2023 4 - Beta N/A :pypi:`pytest-scrutinize` Scrutinize your pytest test suites for slow fixtures, tests and more. Aug 19, 2024 4 - Beta pytest>=6 :pypi:`pytest-securestore` An encrypted password store for use within pytest cases Nov 08, 2021 4 - Beta N/A :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Mar 22, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Mar 29, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1338,7 +1341,7 @@ This list contains 1610 plugins. :pypi:`pytest-smartcollect` A plugin for collecting tests that touch changed code Oct 04, 2018 N/A pytest (>=3.5.0) :pypi:`pytest-smartcov` Smart coverage plugin for pytest. Sep 30, 2017 3 - Alpha N/A :pypi:`pytest-smell` Automated bad smell detection tool for Pytest Jun 26, 2022 N/A N/A - :pypi:`pytest-smoke` Pytest plugin for smoke testing Jan 30, 2025 4 - Beta pytest<9,>=7.0.0 + :pypi:`pytest-smoke` Pytest plugin for smoke testing Mar 25, 2025 4 - Beta pytest<9,>=7.0.0 :pypi:`pytest-smtp` Send email with pytest execution result Feb 20, 2021 N/A pytest :pypi:`pytest-smtp4dev` Plugin for smtp4dev API Jun 27, 2023 5 - Production/Stable N/A :pypi:`pytest-smtpd` An SMTP server for testing built on aiosmtpd May 15, 2023 N/A pytest @@ -1356,7 +1359,7 @@ This list contains 1610 plugins. :pypi:`pytest-soft-assertions` May 05, 2020 3 - Alpha pytest :pypi:`pytest-solidity` A PyTest library plugin for Solidity language. Jan 15, 2022 1 - Planning pytest (<7,>=6.0.1) ; extra == 'tests' :pypi:`pytest-solr` Solr process and client fixtures for py.test. May 11, 2020 3 - Alpha pytest (>=3.0.0) - :pypi:`pytest-sort` Tools for sorting test cases Jan 07, 2024 N/A pytest >=7.4.0 + :pypi:`pytest-sort` Tools for sorting test cases Mar 22, 2025 N/A pytest>=7.4.0 :pypi:`pytest-sorter` A simple plugin to first execute tests that historically failed more Apr 20, 2021 4 - Beta pytest (>=3.1.1) :pypi:`pytest-sosu` Unofficial PyTest plugin for Sauce Labs Aug 04, 2023 2 - Pre-Alpha pytest :pypi:`pytest-sourceorder` Test-ordering plugin for pytest Sep 01, 2021 4 - Beta pytest @@ -1444,7 +1447,7 @@ This list contains 1610 plugins. :pypi:`pytest-testdirectory` A py.test plugin providing temporary directories in unit tests. May 02, 2023 5 - Production/Stable pytest :pypi:`pytest-testdox` A testdox format reporter for pytest Jul 22, 2023 5 - Production/Stable pytest (>=4.6.0) :pypi:`pytest-test-grouping` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Feb 01, 2023 5 - Production/Stable pytest (>=2.5) - :pypi:`pytest-test-groups` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Nov 14, 2024 5 - Production/Stable pytest>=7.0.0 + :pypi:`pytest-test-groups` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Mar 28, 2025 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-testinfra` Test infrastructures May 26, 2024 5 - Production/Stable pytest>=6 :pypi:`pytest-testinfra-jpic` Test infrastructures Sep 21, 2023 5 - Production/Stable N/A :pypi:`pytest-testinfra-winrm-transport` Test infrastructures Sep 21, 2023 5 - Production/Stable N/A @@ -1543,7 +1546,7 @@ This list contains 1610 plugins. :pypi:`pytest-uncollect-if` A plugin to uncollect pytests tests rather than using skipif Dec 26, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-unflakable` Unflakable plugin for PyTest Apr 30, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-unhandled-exception-exit-code` Plugin for py.test set a different exit code on uncaught exceptions Jun 22, 2020 5 - Production/Stable pytest (>=2.3) - :pypi:`pytest-unique` Pytest fixture to generate unique values. Jan 03, 2025 N/A pytest<8.0.0,>=7.4.2 + :pypi:`pytest-unique` Pytest fixture to generate unique values. Mar 23, 2025 N/A pytest<8.0.0,>=7.4.2 :pypi:`pytest-unittest-filter` A pytest plugin for filtering unittest-based test classes Jan 12, 2019 4 - Beta pytest (>=3.1.0) :pypi:`pytest-unittest-id-runner` A pytest plugin to run tests using unittest-style test IDs Feb 09, 2025 N/A pytest>=6.0.0 :pypi:`pytest-unmagic` Pytest fixtures with conventional import semantics Oct 22, 2024 5 - Production/Stable pytest @@ -1602,7 +1605,7 @@ This list contains 1610 plugins. :pypi:`pytest-xdist-forked` forked from pytest-xdist Feb 10, 2020 5 - Production/Stable pytest (>=4.4.0) :pypi:`pytest-xdist-tracker` pytest plugin helps to reproduce failures for particular xdist node Nov 18, 2021 3 - Alpha pytest (>=3.5.1) :pypi:`pytest-xdist-worker-stats` A pytest plugin to list worker statistics after a xdist run. Mar 15, 2025 4 - Beta pytest>=7.0.0 - :pypi:`pytest-xdocker` Pytest fixture to run docker across test runs. Mar 07, 2025 N/A pytest<8.0.0,>=7.4.2 + :pypi:`pytest-xdocker` Pytest fixture to run docker across test runs. Mar 23, 2025 N/A pytest<8.0.0,>=7.4.2 :pypi:`pytest-xfaillist` Maintain a xfaillist in an additional file to avoid merge-conflicts. Sep 17, 2021 N/A pytest (>=6.2.2,<7.0.0) :pypi:`pytest-xfiles` Pytest fixtures providing data read from function, module or package related (x)files. Feb 27, 2018 N/A N/A :pypi:`pytest-xflaky` A simple plugin to use with pytest Oct 14, 2024 4 - Beta pytest>=8.2.1 @@ -2105,7 +2108,7 @@ This list contains 1610 plugins. pyest results colection plugin :pypi:`pytest-argus-server` - *last release*: Mar 20, 2025, + *last release*: Mar 24, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -2238,7 +2241,7 @@ This list contains 1610 plugins. Pytest fixtures for async generators :pypi:`pytest-asyncio` - *last release*: Jan 28, 2025, + *last release*: Mar 25, 2025, *status*: 4 - Beta, *requires*: pytest<9,>=8.2 @@ -2546,7 +2549,7 @@ This list contains 1610 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Mar 22, 2025, + *last release*: Mar 27, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -3337,7 +3340,7 @@ This list contains 1610 plugins. pytest plugin to add source code sanity checks (pep8 and friends) :pypi:`pytest-codecov` - *last release*: Dec 11, 2024, + *last release*: Mar 25, 2025, *status*: 4 - Beta, *requires*: pytest>=4.6.0 @@ -3778,7 +3781,7 @@ This list contains 1610 plugins. Useful functions for managing data for pytest fixtures :pypi:`pytest-databases` - *last release*: Feb 11, 2025, + *last release*: Mar 23, 2025, *status*: 4 - Beta, *requires*: pytest @@ -4674,7 +4677,7 @@ This list contains 1610 plugins. A pytest plugin to rerun tests dynamically based off of test outcome and output. :pypi:`pytest-dynamodb` - *last release*: Oct 25, 2024, + *last release*: Mar 23, 2025, *status*: 5 - Production/Stable, *requires*: pytest @@ -5052,7 +5055,7 @@ This list contains 1610 plugins. Parse queries in Lucene and Elasticsearch syntaxes :pypi:`pytest-examples` - *last release*: Nov 20, 2024, + *last release*: Mar 23, 2025, *status*: N/A, *requires*: pytest>=7 @@ -5913,7 +5916,7 @@ This list contains 1610 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Mar 21, 2025, + *last release*: Mar 28, 2025, *status*: N/A, *requires*: pytest>=3.6 @@ -6221,9 +6224,9 @@ This list contains 1610 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Mar 22, 2025, + *last release*: Mar 29, 2025, *status*: 3 - Alpha, - *requires*: pytest==8.3.4 + *requires*: pytest==8.3.5 Experimental package to automatically extract test plugins for Home Assistant custom components @@ -7376,7 +7379,7 @@ This list contains 1610 plugins. :pypi:`pytest-logging-strict` - *last release*: Jan 19, 2025, + *last release*: Mar 23, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -7649,7 +7652,7 @@ This list contains 1610 plugins. pytest plugin to write integration tests for projects using Mercurial Python internals :pypi:`pytest-mergify` - *last release*: Mar 14, 2025, + *last release*: Mar 27, 2025, *status*: N/A, *requires*: N/A @@ -8027,11 +8030,11 @@ This list contains 1610 plugins. A pytest plugin that does awesome things :pypi:`pytest-mypy` - *last release*: Dec 18, 2022, - *status*: 4 - Beta, - *requires*: pytest (>=6.2) ; python_version >= "3.10" + *last release*: Mar 28, 2025, + *status*: 5 - Production/Stable, + *requires*: pytest>=7.0 - Mypy static type checker plugin for Pytest + A Pytest Plugin for Mypy :pypi:`pytest-mypyd` *last release*: Aug 20, 2019, @@ -8398,7 +8401,7 @@ This list contains 1610 plugins. A pytest plugin for instrumenting test runs via OpenTelemetry :pypi:`pytest-opentmi` - *last release*: Sep 05, 2024, + *last release*: Mar 22, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=5.0 @@ -8502,6 +8505,13 @@ This list contains 1610 plugins. A simple plugin to use with pytest + :pypi:`pytest-pagerduty` + *last release*: Mar 22, 2025, + *status*: N/A, + *requires*: pytest<9.0.0,>=7.4.0 + + Pytest plugin for PagerDuty integration via automation testing. + :pypi:`pytest-pahrametahrize` *last release*: Nov 24, 2021, *status*: 4 - Beta, @@ -8887,6 +8897,13 @@ This list contains 1610 plugins. A pytest wrapper with async fixtures for Playwright to automate web browsers + :pypi:`pytest-playwright-axe` + *last release*: Mar 27, 2025, + *status*: 4 - Beta, + *requires*: N/A + + An axe-core integration for accessibility testing using Playwright Python. + :pypi:`pytest-playwright-enhanced` *last release*: Mar 24, 2024, *status*: N/A, @@ -8915,8 +8932,15 @@ This list contains 1610 plugins. A pytest fixture for visual testing with Playwright + :pypi:`pytest-playwright-visual-snapshot` + *last release*: Mar 25, 2025, + *status*: N/A, + *requires*: N/A + + Easy pytest visual regression testing using playwright + :pypi:`pytest-plone` - *last release*: May 15, 2024, + *last release*: Mar 27, 2025, *status*: 3 - Alpha, *requires*: pytest<8.0.0 @@ -10183,7 +10207,7 @@ This list contains 1610 plugins. pytest plugin for ROAST configuration override and fixtures :pypi:`pytest_robotframework` - *last release*: Oct 15, 2024, + *last release*: Mar 28, 2025, *status*: N/A, *requires*: pytest<9,>=7 @@ -10372,7 +10396,7 @@ This list contains 1610 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Mar 22, 2025, + *last release*: Mar 29, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10407,7 +10431,7 @@ This list contains 1610 plugins. 👍 Validate return values against a schema-like object in testing :pypi:`pytest-scim2-server` - *last release*: Jan 27, 2025, + *last release*: Mar 28, 2025, *status*: N/A, *requires*: pytest>=8.3.4 @@ -10456,7 +10480,7 @@ This list contains 1610 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Mar 22, 2025, + *last release*: Mar 29, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10778,7 +10802,7 @@ This list contains 1610 plugins. Automated bad smell detection tool for Pytest :pypi:`pytest-smoke` - *last release*: Jan 30, 2025, + *last release*: Mar 25, 2025, *status*: 4 - Beta, *requires*: pytest<9,>=7.0.0 @@ -10904,9 +10928,9 @@ This list contains 1610 plugins. Solr process and client fixtures for py.test. :pypi:`pytest-sort` - *last release*: Jan 07, 2024, + *last release*: Mar 22, 2025, *status*: N/A, - *requires*: pytest >=7.4.0 + *requires*: pytest>=7.4.0 Tools for sorting test cases @@ -11520,7 +11544,7 @@ This list contains 1610 plugins. A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. :pypi:`pytest-test-groups` - *last release*: Nov 14, 2024, + *last release*: Mar 28, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0.0 @@ -12213,7 +12237,7 @@ This list contains 1610 plugins. Plugin for py.test set a different exit code on uncaught exceptions :pypi:`pytest-unique` - *last release*: Jan 03, 2025, + *last release*: Mar 23, 2025, *status*: N/A, *requires*: pytest<8.0.0,>=7.4.2 @@ -12626,7 +12650,7 @@ This list contains 1610 plugins. A pytest plugin to list worker statistics after a xdist run. :pypi:`pytest-xdocker` - *last release*: Mar 07, 2025, + *last release*: Mar 23, 2025, *status*: N/A, *requires*: pytest<8.0.0,>=7.4.2 From 33e2e262d688ed2951ec5174e51545fda918e6f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Mar 2025 06:26:06 +0200 Subject: [PATCH 366/445] build(deps): Bump pytest-asyncio in /testing/plugins_integration (#13336) Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.25.3 to 0.26.0. - [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases) - [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.25.3...v0.26.0) --- updated-dependencies: - dependency-name: pytest-asyncio dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 66ed13a4b8a..05565fe89d4 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,6 +1,6 @@ anyio[trio]==4.9.0 django==5.1.7 -pytest-asyncio==0.25.3 +pytest-asyncio==0.26.0 pytest-bdd==8.1.0 pytest-cov==6.0.0 pytest-django==4.10.0 From 9eacaef044dcf2162b3c3396ffc755f7f1e83b3c Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 1 Apr 2025 08:33:12 -0300 Subject: [PATCH 367/445] Enable GitHub Sponsors in FUNDING.yml --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 5f2d1cf09c8..2db4a7f7e57 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,5 +1,6 @@ # info: # * https://help.github.com/en/articles/displaying-a-sponsor-button-in-your-repository # * https://tidelift.com/subscription/how-to-connect-tidelift-with-github +github: pytest-dev tidelift: pypi/pytest open_collective: pytest From 7ca1bc90400e10bd6f6968b16c39b3098ec8e450 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 1 Apr 2025 08:36:41 -0300 Subject: [PATCH 368/445] Enable thanks.dev in FUNDING.yml --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 2db4a7f7e57..88049407b45 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -4,3 +4,4 @@ github: pytest-dev tidelift: pypi/pytest open_collective: pytest +thanks_dev: u/gh/pytest-dev From 0c454979cc2038bc193eb037e80f658a9183641f Mon Sep 17 00:00:00 2001 From: Bahram Farahmand Date: Wed, 2 Apr 2025 13:31:53 +0300 Subject: [PATCH 369/445] Fix `approx` when mixing numpy.bool and bool (#13338) Fix #13047 --------- Co-authored-by: Bruno Oliveira --- AUTHORS | 1 + changelog/13047.bugfix.rst | 17 +++++++++++++++++ src/_pytest/python_api.py | 20 ++++++++++++++++---- testing/python/approx.py | 9 +++++++++ 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 changelog/13047.bugfix.rst diff --git a/AUTHORS b/AUTHORS index 95e6b13f11e..9004008bfa5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -58,6 +58,7 @@ Ashley Whetter Aviral Verma Aviv Palivoda Babak Keyvani +Bahram Farahmand Barney Gale Ben Brown Ben Gartner diff --git a/changelog/13047.bugfix.rst b/changelog/13047.bugfix.rst new file mode 100644 index 00000000000..399e860505c --- /dev/null +++ b/changelog/13047.bugfix.rst @@ -0,0 +1,17 @@ +Restore :func:`pytest.approx` handling of equality checks between `bool` and `numpy.bool_` types. + +Comparing `bool` and `numpy.bool_` using :func:`pytest.approx` accidentally changed in version `8.3.4` and `8.3.5` to no longer match: + +.. code-block:: pycon + + >>> import numpy as np + >>> from pytest import approx + >>> [np.True_, np.True_] == pytest.approx([True, True]) + False + +This has now been fixed: + +.. code-block:: pycon + + >>> [np.True_, np.True_] == pytest.approx([True, True]) + True diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index af078e25256..3f899a24ea8 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -421,14 +421,26 @@ def __repr__(self) -> str: def __eq__(self, actual) -> bool: """Return whether the given value is equal to the expected value within the pre-specified tolerance.""" + + def is_bool(val: Any) -> bool: + # Check if `val` is a native bool or numpy bool. + if isinstance(val, bool): + return True + try: + import numpy as np + + return isinstance(val, np.bool_) + except ImportError: + return False + asarray = _as_numpy_array(actual) if asarray is not None: # Call ``__eq__()`` manually to prevent infinite-recursion with # numpy<1.13. See #3748. return all(self.__eq__(a) for a in asarray.flat) - # Short-circuit exact equality, except for bool - if isinstance(self.expected, bool) and not isinstance(actual, bool): + # Short-circuit exact equality, except for bool and np.bool_ + if is_bool(self.expected) and not is_bool(actual): return False elif actual == self.expected: return True @@ -436,8 +448,8 @@ def __eq__(self, actual) -> bool: # If either type is non-numeric, fall back to strict equality. # NB: we need Complex, rather than just Number, to ensure that __abs__, # __sub__, and __float__ are defined. Also, consider bool to be - # nonnumeric, even though it has the required arithmetic. - if isinstance(self.expected, bool) or not ( + # non-numeric, even though it has the required arithmetic. + if is_bool(self.expected) or not ( isinstance(self.expected, (Complex, Decimal)) and isinstance(actual, (Complex, Decimal)) ): diff --git a/testing/python/approx.py b/testing/python/approx.py index 7eba4755c01..01b58782cdb 100644 --- a/testing/python/approx.py +++ b/testing/python/approx.py @@ -647,6 +647,15 @@ def test_expecting_bool(self) -> None: assert True != approx(False, abs=2) # noqa: E712 assert 1 != approx(True) + def test_expecting_bool_numpy(self) -> None: + """Check approx comparing with numpy.bool (#13047).""" + np = pytest.importorskip("numpy") + assert np.False_ != approx(True) + assert np.True_ != approx(False) + assert np.True_ == approx(True) + assert np.False_ == approx(False) + assert np.True_ != approx(False, abs=2) + def test_list(self): actual = [1 + 1e-7, 2 + 1e-8] expected = [1, 2] From 682013d200764b27659dd5eb60963bbb18779964 Mon Sep 17 00:00:00 2001 From: Harmin Parra Rueda Date: Wed, 2 Apr 2025 13:15:58 +0200 Subject: [PATCH 370/445] Make wasxfail consistent (#13328) Previously, xfailed tests via the marker would have a special `"reason: "` string prefixed to it. Removed the prefix so the `wasxfail` attribute is now consistent regardless the method used. Fix #11067 --------- Co-authored-by: Bruno Oliveira --- changelog/11067.bugfix.rst | 3 +++ src/_pytest/skipping.py | 2 +- testing/test_skipping.py | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 changelog/11067.bugfix.rst diff --git a/changelog/11067.bugfix.rst b/changelog/11067.bugfix.rst new file mode 100644 index 00000000000..4e3cb8e7dd7 --- /dev/null +++ b/changelog/11067.bugfix.rst @@ -0,0 +1,3 @@ +The test report is now consistent regardless if the test xfailed via :ref:`pytest.mark.xfail ` or :func:`pytest.fail`. + +Previously, *xfailed* tests via the marker would have the string ``"reason: "`` prefixed to the message, while those *xfailed* via the function did not. The prefix has been removed. diff --git a/src/_pytest/skipping.py b/src/_pytest/skipping.py index 96281faec97..ec118f2c92f 100644 --- a/src/_pytest/skipping.py +++ b/src/_pytest/skipping.py @@ -278,7 +278,7 @@ def pytest_runtest_makereport( pass # don't interfere elif call.excinfo and isinstance(call.excinfo.value, xfail.Exception): assert call.excinfo.value.msg is not None - rep.wasxfail = "reason: " + call.excinfo.value.msg + rep.wasxfail = call.excinfo.value.msg rep.outcome = "skipped" elif not rep.skipped and xfailed: if call.excinfo: diff --git a/testing/test_skipping.py b/testing/test_skipping.py index 57113ba93d5..9a6c2c4b6aa 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -448,8 +448,8 @@ def test_this_false(): result = pytester.runpytest(p, "-rx") result.stdout.fnmatch_lines( [ - "*test_one*test_this - reason: *NOTRUN* noway", - "*test_one*test_this_true - reason: *NOTRUN* condition: True", + "*test_one*test_this - *NOTRUN* noway", + "*test_one*test_this_true - *NOTRUN* condition: True", "*1 passed*", ] ) @@ -492,7 +492,7 @@ def test_this(): result = pytester.runpytest(p) result.stdout.fnmatch_lines(["*1 xfailed*"]) result = pytester.runpytest(p, "-rx") - result.stdout.fnmatch_lines(["*XFAIL*test_this*reason:*hello*"]) + result.stdout.fnmatch_lines(["*XFAIL*test_this*hello*"]) result = pytester.runpytest(p, "--runxfail") result.stdout.fnmatch_lines(["*1 pass*"]) @@ -510,7 +510,7 @@ def test_this(): result = pytester.runpytest(p) result.stdout.fnmatch_lines(["*1 xfailed*"]) result = pytester.runpytest(p, "-rx") - result.stdout.fnmatch_lines(["*XFAIL*test_this*reason:*hello*"]) + result.stdout.fnmatch_lines(["*XFAIL*test_this*hello*"]) result = pytester.runpytest(p, "--runxfail") result.stdout.fnmatch_lines( """ From 9a7dbd8a394bb47ee43be51d60ec3c4f4759789e Mon Sep 17 00:00:00 2001 From: Callum Scott <134177091+callummscott@users.noreply.github.com> Date: Thu, 3 Apr 2025 13:53:43 +0100 Subject: [PATCH 371/445] Add title and change spelling for use of approx with non-numerics (#13343) * Added title to draw attention to the easily-missed information on non-numeric types for approx. * Changed spelling of all cases of "nonnumeric" to "non-numeric" within docstrings for clarity and consistency with .rst files. Related to #13218 --- src/_pytest/python_api.py | 10 ++++++---- testing/python/approx.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 3f899a24ea8..655f53fd8ef 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -632,8 +632,10 @@ def approx(expected, rel=None, abs=None, nan_ok: bool = False) -> ApproxBase: >>> 1 + 1e-8 == approx(1, rel=1e-6, abs=1e-12) True - You can also use ``approx`` to compare nonnumeric types, or dicts and - sequences containing nonnumeric types, in which case it falls back to + **Non-numeric types** + + You can also use ``approx`` to compare non-numeric types, or dicts and + sequences containing non-numeric types, in which case it falls back to strict equality. This can be useful for comparing dicts and sequences that can contain optional values:: @@ -708,10 +710,10 @@ def approx(expected, rel=None, abs=None, nan_ok: bool = False) -> ApproxBase: .. versionchanged:: 3.7.1 ``approx`` raises ``TypeError`` when it encounters a dict value or - sequence element of nonnumeric type. + sequence element of non-numeric type. .. versionchanged:: 6.1.0 - ``approx`` falls back to strict equality for nonnumeric types instead + ``approx`` falls back to strict equality for non-numeric types instead of raising ``TypeError``. """ # Delegate the comparison to a class that knows how to deal with the type diff --git a/testing/python/approx.py b/testing/python/approx.py index 01b58782cdb..75b57b6965c 100644 --- a/testing/python/approx.py +++ b/testing/python/approx.py @@ -939,7 +939,7 @@ def test_nonnumeric_okay_if_equal(self, x): ], ) def test_nonnumeric_false_if_unequal(self, x): - """For nonnumeric types, x != pytest.approx(y) reduces to x != y""" + """For non-numeric types, x != pytest.approx(y) reduces to x != y""" assert "ab" != approx("abc") assert ["ab"] != approx(["abc"]) # in particular, both of these should return False From 40564337c789ec713dab38f83dea1b43620f5c61 Mon Sep 17 00:00:00 2001 From: Andy Freeland Date: Thu, 3 Apr 2025 06:07:08 -0700 Subject: [PATCH 372/445] Fix type hints for `TestReport.when` and `TestReport.location` (#13345) These are set in `TestReport.__init__` but weren't being picked up by type checkers because of the annotations on `BaseReport`. Fixes #12941. --- changelog/13345.bugfix.rst | 1 + src/_pytest/reports.py | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 changelog/13345.bugfix.rst diff --git a/changelog/13345.bugfix.rst b/changelog/13345.bugfix.rst new file mode 100644 index 00000000000..5010888aa08 --- /dev/null +++ b/changelog/13345.bugfix.rst @@ -0,0 +1 @@ +Fix type hints for :attr:`pytest.TestReport.when` and :attr:`pytest.TestReport.location`. diff --git a/src/_pytest/reports.py b/src/_pytest/reports.py index 746512285b4..c85bf78594f 100644 --- a/src/_pytest/reports.py +++ b/src/_pytest/reports.py @@ -260,6 +260,9 @@ class TestReport(BaseReport): """ __test__ = False + + when: Literal["setup", "call", "teardown"] + location: tuple[str, int | None, str] # Defined by skipping plugin. # xfail reason if xfailed, otherwise not defined. Use hasattr to distinguish. wasxfail: str From 636d956cdc117603b2e5f8c9cd558a207fdffc8c Mon Sep 17 00:00:00 2001 From: Andy Freeland Date: Thu, 3 Apr 2025 13:09:37 -0700 Subject: [PATCH 373/445] Clean up type hints and add a test (#13348) Based on discussion in #13345. --- src/_pytest/reports.py | 4 +--- testing/typing_checks.py | 8 ++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/_pytest/reports.py b/src/_pytest/reports.py index c85bf78594f..480ffae1f9c 100644 --- a/src/_pytest/reports.py +++ b/src/_pytest/reports.py @@ -261,8 +261,6 @@ class TestReport(BaseReport): __test__ = False - when: Literal["setup", "call", "teardown"] - location: tuple[str, int | None, str] # Defined by skipping plugin. # xfail reason if xfailed, otherwise not defined. Use hasattr to distinguish. wasxfail: str @@ -307,7 +305,7 @@ def __init__( self.longrepr = longrepr #: One of 'setup', 'call', 'teardown' to indicate runtest phase. - self.when = when + self.when: Literal["setup", "call", "teardown"] = when #: User properties is a list of tuples (name, value) that holds user #: defined properties of the test. diff --git a/testing/typing_checks.py b/testing/typing_checks.py index d4d6a97aea6..8a316580a25 100644 --- a/testing/typing_checks.py +++ b/testing/typing_checks.py @@ -8,12 +8,14 @@ from __future__ import annotations import contextlib +from typing import Literal from typing import Optional from typing_extensions import assert_type import pytest from pytest import MonkeyPatch +from pytest import TestReport # Issue #7488. @@ -51,3 +53,9 @@ def check_raises_is_a_context_manager(val: bool) -> None: with pytest.raises(RuntimeError) if val else contextlib.nullcontext() as excinfo: pass assert_type(excinfo, Optional[pytest.ExceptionInfo[RuntimeError]]) + + +# Issue #12941. +def check_testreport_attributes(report: TestReport) -> None: + assert_type(report.when, Literal["setup", "call", "teardown"]) + assert_type(report.location, tuple[str, Optional[int], str]) From 6964cf105e6256682271e5bc1ad32c08a58df4bc Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva <91160475+natmokval@users.noreply.github.com> Date: Fri, 4 Apr 2025 16:53:37 +0200 Subject: [PATCH 374/445] Doc: clarify `approx` behavior regarding int and bools (#13341) Fixes #13218 --- changelog/13218.doc.rst | 1 + src/_pytest/python_api.py | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 changelog/13218.doc.rst diff --git a/changelog/13218.doc.rst b/changelog/13218.doc.rst new file mode 100644 index 00000000000..907a817e895 --- /dev/null +++ b/changelog/13218.doc.rst @@ -0,0 +1 @@ +Pointed out in the :func:`pytest.approx` documentation that it considers booleans unequal to numeric zero or one. diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index 655f53fd8ef..77b0edc0ac5 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -692,6 +692,15 @@ def approx(expected, rel=None, abs=None, nan_ok: bool = False) -> ApproxBase: from the `re_assert package `_. + + .. note:: + + Unlike built-in equality, this function considers + booleans unequal to numeric zero or one. For example:: + + >>> 1 == approx(True) + False + .. warning:: .. versionchanged:: 3.2 From be83aa618c68ebb9080b537bbd8b19b97a7f4eb8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 6 Apr 2025 09:20:04 +0200 Subject: [PATCH 375/445] [automated] Update plugin list (#13356) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 144 ++++++++++++++++++------------- 1 file changed, 84 insertions(+), 60 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index de1ae7f7595..406ebe75dce 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =3.5.0) :pypi:`pytest-annotate` pytest-annotate: Generate PyAnnotate annotations from your pytest tests. Jun 07, 2022 3 - Alpha pytest (<8.0.0,>=3.2.0) :pypi:`pytest-annotated` Pytest plugin to allow use of Annotated in tests to resolve fixtures Sep 30, 2024 N/A pytest>=8.3.3 - :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures Jan 21, 2025 5 - Production/Stable pytest>=6 + :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures Apr 01, 2025 5 - Production/Stable pytest>=6 :pypi:`pytest-ansible-playbook` Pytest fixture which runs given ansible playbook file. Mar 08, 2019 4 - Beta N/A :pypi:`pytest-ansible-playbook-runner` Pytest fixture which runs given ansible playbook file. Dec 02, 2020 4 - Beta pytest (>=3.1.0) :pypi:`pytest-ansible-units` A pytest plugin for running unit tests within an ansible collection Apr 14, 2022 N/A N/A @@ -142,7 +142,7 @@ This list contains 1613 plugins. :pypi:`pytest-aws` pytest plugin for testing AWS resource configurations Oct 04, 2017 4 - Beta N/A :pypi:`pytest-aws-apigateway` pytest plugin for AWS ApiGateway May 24, 2024 4 - Beta pytest :pypi:`pytest-aws-config` Protect your AWS credentials in unit tests May 28, 2021 N/A N/A - :pypi:`pytest-aws-fixtures` A series of fixtures to use in integration tests involving actual AWS services. Oct 07, 2024 N/A pytest<9.0.0,>=8.0.0 + :pypi:`pytest-aws-fixtures` A series of fixtures to use in integration tests involving actual AWS services. Apr 04, 2025 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-axe` pytest plugin for axe-selenium-python Nov 12, 2018 N/A pytest (>=3.0.0) :pypi:`pytest-axe-playwright-snapshot` A pytest plugin that runs Axe-core on Playwright pages and takes snapshots of the results. Jul 25, 2023 N/A pytest :pypi:`pytest-azure` Pytest utilities and mocks for Azure Jan 18, 2023 3 - Alpha pytest @@ -162,7 +162,7 @@ This list contains 1613 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Mar 27, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Apr 01, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -232,7 +232,7 @@ This list contains 1613 plugins. :pypi:`pytest-change-report` turn . into √,turn F into x Sep 14, 2020 N/A pytest :pypi:`pytest-change-xds` turn . into √,turn F into x Apr 16, 2022 N/A pytest :pypi:`pytest-chdir` A pytest fixture for changing current working directory Jan 28, 2020 N/A pytest (>=5.0.0,<6.0.0) - :pypi:`pytest-check` A pytest plugin that allows multiple failures per test. Mar 18, 2025 5 - Production/Stable pytest>=7.0.0 + :pypi:`pytest-check` A pytest plugin that allows multiple failures per test. Apr 04, 2025 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-checkdocs` check the README when running tests Apr 30, 2024 5 - Production/Stable pytest!=8.1.*,>=6; extra == "testing" :pypi:`pytest-checkipdb` plugin to check if there are ipdb debugs left Dec 04, 2023 5 - Production/Stable pytest >=2.9.2 :pypi:`pytest-check-library` check your missing library Jul 17, 2022 N/A N/A @@ -240,7 +240,7 @@ This list contains 1613 plugins. :pypi:`pytest-check-links` Check links in files Jul 29, 2020 N/A pytest<9,>=7.0 :pypi:`pytest-checklist` Pytest plugin to track and report unit/function coverage. Jun 10, 2024 N/A N/A :pypi:`pytest-check-mk` pytest plugin to test Check_MK checks Nov 19, 2015 4 - Beta pytest - :pypi:`pytest-checkpoint` Restore a checkpoint in pytest Mar 22, 2025 N/A pytest>=8.3.5 + :pypi:`pytest-checkpoint` Restore a checkpoint in pytest Mar 30, 2025 N/A pytest>=8.0.0 :pypi:`pytest-check-requirements` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A :pypi:`pytest-ch-framework` My pytest framework Apr 17, 2024 N/A pytest==8.0.1 :pypi:`pytest-chic-report` Simple pytest plugin for generating and sending report to messengers. Nov 01, 2024 N/A pytest>=6.0 @@ -304,7 +304,7 @@ This list contains 1613 plugins. :pypi:`pytest-copier` A pytest plugin to help testing Copier templates Dec 11, 2023 4 - Beta pytest>=7.3.2 :pypi:`pytest-couchdbkit` py.test extension for per-test couchdb databases using couchdbkit Apr 17, 2012 N/A N/A :pypi:`pytest-count` count erros and send email Jan 12, 2018 4 - Beta N/A - :pypi:`pytest-cov` Pytest plugin for measuring coverage. Oct 29, 2024 5 - Production/Stable pytest>=4.6 + :pypi:`pytest-cov` Pytest plugin for measuring coverage. Apr 05, 2025 5 - Production/Stable pytest>=4.6 :pypi:`pytest-cover` Pytest plugin for measuring coverage. Forked from \`pytest-cov\`. Aug 01, 2015 5 - Production/Stable N/A :pypi:`pytest-coverage` Jun 17, 2015 N/A N/A :pypi:`pytest-coverage-context` Coverage dynamic context support for PyTest, including sub-processes Jun 28, 2023 4 - Beta N/A @@ -396,7 +396,7 @@ This list contains 1613 plugins. :pypi:`pytest-ditto` Snapshot testing pytest plugin with minimal ceremony and flexible persistence formats. Jun 09, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-ditto-pandas` pytest-ditto plugin for pandas snapshots. May 29, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-ditto-pyarrow` pytest-ditto plugin for pyarrow tables. Jun 09, 2024 4 - Beta pytest>=3.5.0 - :pypi:`pytest-django` A Django plugin for pytest. Feb 10, 2025 5 - Production/Stable pytest>=7.0.0 + :pypi:`pytest-django` A Django plugin for pytest. Apr 03, 2025 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-django-ahead` A Django plugin for pytest. Oct 27, 2016 5 - Production/Stable pytest (>=2.9) :pypi:`pytest-djangoapp` Nice pytest plugin to help you with Django pluggable application testing. May 19, 2023 4 - Beta pytest :pypi:`pytest-django-cache-xdist` A djangocachexdist plugin for pytest May 12, 2020 4 - Beta N/A @@ -466,7 +466,7 @@ This list contains 1613 plugins. :pypi:`pytest-duration-insights` Jul 15, 2024 N/A N/A :pypi:`pytest-durations` Pytest plugin reporting fixtures and test functions execution time. Mar 18, 2025 5 - Production/Stable pytest>=4.6 :pypi:`pytest-dynamicrerun` A pytest plugin to rerun tests dynamically based off of test outcome and output. Aug 15, 2020 4 - Beta N/A - :pypi:`pytest-dynamodb` DynamoDB fixtures for pytest Mar 23, 2025 5 - Production/Stable pytest + :pypi:`pytest-dynamodb` DynamoDB fixtures for pytest Apr 04, 2025 5 - Production/Stable pytest :pypi:`pytest-easy-addoption` pytest-easy-addoption: Easy way to work with pytest addoption Jan 22, 2020 N/A N/A :pypi:`pytest-easy-api` A package to prevent Dependency Confusion attacks against Yandex. Feb 16, 2024 N/A N/A :pypi:`pytest-easyMPI` Package that supports mpi tests in pytest Oct 21, 2020 N/A N/A @@ -474,7 +474,7 @@ This list contains 1613 plugins. :pypi:`pytest-easy-server` Pytest plugin for easy testing against servers May 01, 2021 4 - Beta pytest (<5.0.0,>=4.3.1) ; python_version < "3.5" :pypi:`pytest-ebics-sandbox` A pytest plugin for testing against an EBICS sandbox server. Requires docker. Aug 15, 2022 N/A N/A :pypi:`pytest-ec2` Pytest execution on EC2 instance Oct 22, 2019 3 - Alpha N/A - :pypi:`pytest-echo` pytest plugin with mechanisms for echoing environment variables, package version and generic attributes Feb 22, 2025 5 - Production/Stable pytest>=6.0 + :pypi:`pytest-echo` pytest plugin that allows to dump environment variables, package version and generic attributes Apr 01, 2025 5 - Production/Stable pytest>=8.3.3 :pypi:`pytest-edit` Edit the source code of a failed test with \`pytest --edit\`. Nov 17, 2024 N/A pytest :pypi:`pytest-ekstazi` Pytest plugin to select test using Ekstazi algorithm Sep 10, 2022 N/A pytest :pypi:`pytest-elasticsearch` Elasticsearch fixtures and fixture factories for Pytest. Dec 03, 2024 5 - Production/Stable pytest>=7.0 @@ -634,6 +634,7 @@ This list contains 1613 plugins. :pypi:`pytest-fxtest` Oct 27, 2020 N/A N/A :pypi:`pytest-fzf` fzf-based test selector for pytest Jan 06, 2025 4 - Beta pytest>=6.0.0 :pypi:`pytest_gae` pytest plugin for apps written with Google's AppEngine Aug 03, 2016 3 - Alpha N/A + :pypi:`pytest-gak` A Pytest plugin and command line tool for interactive testing with Pytest Mar 29, 2025 N/A N/A :pypi:`pytest-gather-fixtures` set up asynchronous pytest fixtures concurrently Aug 18, 2024 N/A pytest>=7.0.0 :pypi:`pytest-gc` The garbage collector plugin for py.test Feb 01, 2018 N/A N/A :pypi:`pytest-gcov` Uses gcov to measure test coverage of a C library Feb 01, 2018 3 - Alpha N/A @@ -643,7 +644,7 @@ This list contains 1613 plugins. :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Mar 28, 2025 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Apr 04, 2025 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -687,7 +688,7 @@ This list contains 1613 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Mar 29, 2025 3 - Alpha pytest==8.3.5 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Apr 05, 2025 3 - Alpha pytest==8.3.5 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -718,7 +719,7 @@ This list contains 1613 plugins. :pypi:`pytest-hue` Visualise PyTest status via your Phillips Hue lights May 09, 2019 N/A N/A :pypi:`pytest-hylang` Pytest plugin to allow running tests written in hylang Mar 28, 2021 N/A pytest :pypi:`pytest-hypo-25` help hypo module for pytest Jan 12, 2020 3 - Alpha N/A - :pypi:`pytest-iam` A fully functional OAUTH2 / OpenID Connect (OIDC) server to be used in your testsuite Jul 25, 2024 4 - Beta pytest>=7.0.0 + :pypi:`pytest-iam` A fully functional OAUTH2 / OpenID Connect (OIDC) server to be used in your testsuite Apr 04, 2025 4 - Beta pytest>=7.0.0 :pypi:`pytest-ibutsu` A plugin to sent pytest results to an Ibutsu server Feb 06, 2025 4 - Beta pytest>=7.1 :pypi:`pytest-icdiff` use icdiff for better error messages in pytest assertions Dec 05, 2023 4 - Beta pytest :pypi:`pytest-idapro` A pytest plugin for idapython. Allows a pytest setup to run tests outside and inside IDA in an automated manner by runnig pytest inside IDA and by mocking idapython api Nov 03, 2018 N/A N/A @@ -756,7 +757,7 @@ This list contains 1613 plugins. :pypi:`pytest-interactive` A pytest plugin for console based interactive test selection just after the collection phase Nov 30, 2017 3 - Alpha N/A :pypi:`pytest-intercept-remote` Pytest plugin for intercepting outgoing connection requests during pytest run. May 24, 2021 4 - Beta pytest (>=4.6) :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Feb 13, 2025 4 - Beta pytest - :pypi:`pytest-invenio` Pytest fixtures for Invenio. Mar 07, 2025 5 - Production/Stable pytest<9.0.0,>=6 + :pypi:`pytest-invenio` Pytest fixtures for Invenio. Apr 02, 2025 5 - Production/Stable pytest<9.0.0,>=6 :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-iovis` A Pytest plugin to enable Jupyter Notebook testing with Papermill Nov 06, 2024 4 - Beta pytest>=7.1.0 :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A @@ -853,20 +854,20 @@ This list contains 1613 plugins. :pypi:`pytest-logging` Configures logging and allows tweaking the log level with a py.test flag Nov 04, 2015 4 - Beta N/A :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) :pypi:`pytest-logging-strict` pytest fixture logging configured from packaged YAML Mar 23, 2025 3 - Alpha pytest - :pypi:`pytest-logikal` Common testing environment Mar 02, 2025 5 - Production/Stable pytest==8.3.4 + :pypi:`pytest-logikal` Common testing environment Apr 02, 2025 5 - Production/Stable pytest==8.3.5 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Sep 30, 2024 4 - Beta pytest>=8.2.2 :pypi:`pytest-loguru` Pytest Loguru Mar 20, 2024 5 - Production/Stable pytest; extra == "test" :pypi:`pytest-loop` pytest plugin for looping tests Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-lsp` A pytest plugin for end-to-end testing of language servers Nov 23, 2024 3 - Alpha pytest :pypi:`pytest-lw-realtime-result` Pytest plugin to generate realtime test results to a file Mar 13, 2025 N/A pytest>=3.5.0 - :pypi:`pytest-manifest` PyTest plugin for recording and asserting against a manifest file Mar 18, 2025 N/A pytest + :pypi:`pytest-manifest` PyTest plugin for recording and asserting against a manifest file Apr 01, 2025 N/A pytest :pypi:`pytest-manual-marker` pytest marker for marking manual tests Aug 04, 2022 3 - Alpha pytest>=7 :pypi:`pytest-mark-count` Get a count of the number of tests marked, unmarked, and unique tests if tests have multiple markers Nov 13, 2024 4 - Beta pytest>=8.0.0 :pypi:`pytest-markdoctest` A pytest plugin to doctest your markdown files Jul 22, 2022 4 - Beta pytest (>=6) :pypi:`pytest-markdown` Test your markdown docs with pytest Jan 15, 2021 4 - Beta pytest (>=6.0.1,<7.0.0) :pypi:`pytest-markdown-docs` Run markdown code fences through pytest Mar 13, 2025 N/A pytest>=7.0.0 - :pypi:`pytest-marker-bugzilla` py.test bugzilla integration plugin, using markers Jan 09, 2020 N/A N/A + :pypi:`pytest-marker-bugzilla` py.test bugzilla integration plugin, using markers Apr 02, 2025 5 - Production/Stable pytest>=2.2.4 :pypi:`pytest-markers-presence` A simple plugin to detect missed pytest tags and markers" Oct 30, 2024 4 - Beta pytest>=6.0 :pypi:`pytest-markfiltration` UNKNOWN Nov 08, 2011 3 - Alpha N/A :pypi:`pytest-mark-manage` 用例标签化管理 Aug 15, 2024 N/A pytest @@ -891,7 +892,7 @@ This list contains 1613 plugins. :pypi:`pytest-memray` A simple plugin to use with pytest Jul 25, 2024 N/A pytest>=7.2 :pypi:`pytest-menu` A pytest plugin for console based interactive test selection just after the collection phase Oct 04, 2017 3 - Alpha pytest (>=2.4.2) :pypi:`pytest-mercurial` pytest plugin to write integration tests for projects using Mercurial Python internals Nov 21, 2020 1 - Planning N/A - :pypi:`pytest-mergify` Pytest plugin for Mergify Mar 27, 2025 N/A N/A + :pypi:`pytest-mergify` Pytest plugin for Mergify Mar 31, 2025 N/A N/A :pypi:`pytest-mesh` pytest_mesh插件 Aug 05, 2022 N/A pytest (==7.1.2) :pypi:`pytest-message` Pytest plugin for sending report message of marked tests execution Aug 04, 2022 N/A pytest (>=6.2.5) :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A @@ -945,7 +946,7 @@ This list contains 1613 plugins. :pypi:`pytest-mutagen` Add the mutation testing feature to pytest Jul 24, 2020 N/A pytest (>=5.4) :pypi:`pytest-my-cool-lib` Nov 02, 2023 N/A pytest (>=7.1.3,<8.0.0) :pypi:`pytest-my-plugin` A pytest plugin that does awesome things Jan 27, 2025 N/A pytest>=6.0 - :pypi:`pytest-mypy` A Pytest Plugin for Mypy Mar 28, 2025 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-mypy` A Pytest Plugin for Mypy Apr 02, 2025 5 - Production/Stable pytest>=7.0 :pypi:`pytest-mypyd` Mypy static type checker plugin for Pytest Aug 20, 2019 4 - Beta pytest (<4.7,>=2.8) ; python_version < "3.5" :pypi:`pytest-mypy-plugins` pytest plugin for writing tests for mypy plugins Dec 21, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-mypy-plugins-shim` Substitute for "pytest-mypy-plugins" for Python implementations which aren't supported by mypy. Feb 14, 2025 N/A pytest>=6.0.0 @@ -965,7 +966,7 @@ This list contains 1613 plugins. :pypi:`pytest-nginx-iplweb` nginx fixture for pytest - iplweb temporary fork Mar 01, 2019 5 - Production/Stable N/A :pypi:`pytest-ngrok` Jan 20, 2022 3 - Alpha pytest :pypi:`pytest-ngsfixtures` pytest ngs fixtures Sep 06, 2019 2 - Pre-Alpha pytest (>=5.0.0) - :pypi:`pytest-nhsd-apim` Pytest plugin accessing NHSDigital's APIM proxies Mar 21, 2025 N/A pytest<9.0.0,>=8.2.0 + :pypi:`pytest-nhsd-apim` Pytest plugin accessing NHSDigital's APIM proxies Apr 01, 2025 N/A pytest<9.0.0,>=8.2.0 :pypi:`pytest-nice` A pytest plugin that alerts user of failed test cases with screen notifications May 04, 2019 4 - Beta pytest :pypi:`pytest-nice-parametrize` A small snippet for nicer PyTest's Parametrize Apr 17, 2021 5 - Production/Stable N/A :pypi:`pytest_nlcov` Pytest plugin to get the coverage of the new lines (based on git diff) only Aug 05, 2024 N/A N/A @@ -997,6 +998,7 @@ This list contains 1613 plugins. :pypi:`pytest-oof` A Pytest plugin providing structured, programmatic access to a test run's results Dec 11, 2023 4 - Beta N/A :pypi:`pytest-oot` Run object-oriented tests in a simple format Sep 18, 2016 4 - Beta N/A :pypi:`pytest-openfiles` Pytest plugin for detecting inadvertent open file handles Jun 05, 2024 3 - Alpha pytest>=4.6 + :pypi:`pytest-open-html` Auto-open HTML reports after pytest runs Mar 31, 2025 N/A pytest>=6.0 :pypi:`pytest-opentelemetry` A pytest plugin for instrumenting test runs via OpenTelemetry Nov 22, 2024 N/A pytest :pypi:`pytest-opentmi` pytest plugin for publish results to opentmi Mar 22, 2025 5 - Production/Stable pytest>=5.0 :pypi:`pytest-operator` Fixtures for Operators Sep 28, 2022 N/A pytest @@ -1047,7 +1049,7 @@ This list contains 1613 plugins. :pypi:`pytest-performancetotal` A performance plugin for pytest Feb 01, 2025 5 - Production/Stable N/A :pypi:`pytest-persistence` Pytest tool for persistent objects Aug 21, 2024 N/A N/A :pypi:`pytest-pexpect` Pytest pexpect plugin. Aug 13, 2024 4 - Beta pytest>=6.2.0 - :pypi:`pytest-pg` A tiny plugin for pytest which runs PostgreSQL in Docker May 21, 2024 5 - Production/Stable pytest>=6.0.0 + :pypi:`pytest-pg` A tiny plugin for pytest which runs PostgreSQL in Docker Apr 03, 2025 5 - Production/Stable pytest>=8.0.0 :pypi:`pytest-pgsql` Pytest plugins and helpers for tests using a Postgres database. May 13, 2020 5 - Production/Stable pytest (>=3.0.0) :pypi:`pytest-phmdoctest` pytest plugin to test Python examples in Markdown using phmdoctest. Apr 15, 2022 4 - Beta pytest (>=5.4.3) :pypi:`pytest-phoenix-interface` Pytest extension tool for phoenix projects. Mar 19, 2025 N/A N/A @@ -1175,7 +1177,7 @@ This list contains 1613 plugins. :pypi:`pytest-ranking` A Pytest plugin for automatically prioritizing/ranking tests to speed up failure detection Jan 14, 2025 4 - Beta pytest>=7.4.3 :pypi:`pytest-readme` Test your README.md file Sep 02, 2022 5 - Production/Stable N/A :pypi:`pytest-reana` Pytest fixtures for REANA. Sep 04, 2024 3 - Alpha N/A - :pypi:`pytest-recorder` Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. Jan 09, 2025 N/A N/A + :pypi:`pytest-recorder` Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. Mar 31, 2025 N/A N/A :pypi:`pytest-recording` A pytest plugin that allows you recording of network interactions via VCR.py Jul 09, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-recordings` Provides pytest plugins for reporting request/response traffic, screenshots, and more to ReportPortal Aug 13, 2020 N/A N/A :pypi:`pytest-record-video` 用例执行过程中录制视频 Oct 31, 2024 N/A N/A @@ -1204,7 +1206,7 @@ This list contains 1613 plugins. :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Oct 11, 2024 4 - Beta N/A :pypi:`pytest-reporter-html-dots` A basic HTML report for pytest using Jinja2 template engine. Jan 22, 2023 N/A N/A - :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots, webpage sources and attachments. Mar 20, 2025 N/A pytest>=8.0.0 + :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots, webpage sources and attachments. Apr 04, 2025 N/A pytest>=8.0.0 :pypi:`pytest-reportinfra` Pytest plugin for reportinfra Aug 11, 2019 3 - Alpha N/A :pypi:`pytest-reporting` A plugin to report summarized results in a table format Oct 25, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-reportlog` Replacement for the --resultlog option, focused in simplicity and extensibility May 22, 2023 3 - Alpha pytest @@ -1283,7 +1285,7 @@ This list contains 1613 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Mar 29, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Apr 04, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1295,7 +1297,7 @@ This list contains 1613 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Mar 29, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Apr 04, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1328,6 +1330,7 @@ This list contains 1613 plugins. :pypi:`pytest-simple-plugin` Simple pytest plugin Nov 27, 2019 N/A N/A :pypi:`pytest-simple-settings` simple-settings plugin for pytest Nov 17, 2020 4 - Beta pytest :pypi:`pytest-single-file-logging` Allow for multiple processes to log to a single file May 05, 2016 4 - Beta pytest (>=2.8.1) + :pypi:`pytest-skip` A pytest plugin which allows to (de-)select or skip tests from a file. Apr 04, 2025 3 - Alpha pytest :pypi:`pytest-skip-markers` Pytest Salt Plugin Aug 09, 2024 5 - Production/Stable pytest>=7.1.0 :pypi:`pytest-skipper` A plugin that selects only tests with changes in execution path Mar 26, 2017 3 - Alpha pytest (>=3.0.6) :pypi:`pytest-skippy` Automatically skip tests that don't need to run! Jan 27, 2018 3 - Alpha pytest (>=2.3.4) @@ -1448,7 +1451,7 @@ This list contains 1613 plugins. :pypi:`pytest-testdox` A testdox format reporter for pytest Jul 22, 2023 5 - Production/Stable pytest (>=4.6.0) :pypi:`pytest-test-grouping` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Feb 01, 2023 5 - Production/Stable pytest (>=2.5) :pypi:`pytest-test-groups` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Mar 28, 2025 5 - Production/Stable pytest>=7.0.0 - :pypi:`pytest-testinfra` Test infrastructures May 26, 2024 5 - Production/Stable pytest>=6 + :pypi:`pytest-testinfra` Test infrastructures Mar 30, 2025 5 - Production/Stable pytest>=6 :pypi:`pytest-testinfra-jpic` Test infrastructures Sep 21, 2023 5 - Production/Stable N/A :pypi:`pytest-testinfra-winrm-transport` Test infrastructures Sep 21, 2023 5 - Production/Stable N/A :pypi:`pytest-testit-parametrize` A pytest plugin for uploading parameterized tests parameters into TMS TestIT Dec 04, 2024 4 - Beta pytest>=8.3.3 @@ -1646,7 +1649,7 @@ This list contains 1613 plugins. :pypi:`pytest-zigzag` Extend py.test for RPC OpenStack testing. Feb 27, 2019 4 - Beta pytest (~=3.6) :pypi:`pytest-zulip` Pytest report plugin for Zulip May 07, 2022 5 - Production/Stable pytest :pypi:`pytest-zy` 接口自动化测试框架 Mar 24, 2024 N/A pytest~=7.2.0 - :pypi:`tursu` 🎬 A pytest plugin that transpiles Gherkin feature files to Python using AST, enforcing typing for ease of use and debugging. Mar 22, 2025 4 - Beta pytest>=8.3.5 + :pypi:`tursu` 🎬 A pytest plugin that transpiles Gherkin feature files to Python using AST, enforcing typing for ease of use and debugging. Apr 05, 2025 4 - Beta pytest>=8.3.5 =============================================== ====================================================================================================================================================================================================================================================================================================================================================================================== ============== ===================== ================================================ .. only:: latex @@ -1975,7 +1978,7 @@ This list contains 1613 plugins. Pytest plugin to allow use of Annotated in tests to resolve fixtures :pypi:`pytest-ansible` - *last release*: Jan 21, 2025, + *last release*: Apr 01, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=6 @@ -2409,7 +2412,7 @@ This list contains 1613 plugins. Protect your AWS credentials in unit tests :pypi:`pytest-aws-fixtures` - *last release*: Oct 07, 2024, + *last release*: Apr 04, 2025, *status*: N/A, *requires*: pytest<9.0.0,>=8.0.0 @@ -2549,7 +2552,7 @@ This list contains 1613 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Mar 27, 2025, + *last release*: Apr 01, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -3039,7 +3042,7 @@ This list contains 1613 plugins. A pytest fixture for changing current working directory :pypi:`pytest-check` - *last release*: Mar 18, 2025, + *last release*: Apr 04, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0.0 @@ -3095,9 +3098,9 @@ This list contains 1613 plugins. pytest plugin to test Check_MK checks :pypi:`pytest-checkpoint` - *last release*: Mar 22, 2025, + *last release*: Mar 30, 2025, *status*: N/A, - *requires*: pytest>=8.3.5 + *requires*: pytest>=8.0.0 Restore a checkpoint in pytest @@ -3543,7 +3546,7 @@ This list contains 1613 plugins. count erros and send email :pypi:`pytest-cov` - *last release*: Oct 29, 2024, + *last release*: Apr 05, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=4.6 @@ -4187,7 +4190,7 @@ This list contains 1613 plugins. pytest-ditto plugin for pyarrow tables. :pypi:`pytest-django` - *last release*: Feb 10, 2025, + *last release*: Apr 03, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0.0 @@ -4677,7 +4680,7 @@ This list contains 1613 plugins. A pytest plugin to rerun tests dynamically based off of test outcome and output. :pypi:`pytest-dynamodb` - *last release*: Mar 23, 2025, + *last release*: Apr 04, 2025, *status*: 5 - Production/Stable, *requires*: pytest @@ -4733,11 +4736,11 @@ This list contains 1613 plugins. Pytest execution on EC2 instance :pypi:`pytest-echo` - *last release*: Feb 22, 2025, + *last release*: Apr 01, 2025, *status*: 5 - Production/Stable, - *requires*: pytest>=6.0 + *requires*: pytest>=8.3.3 - pytest plugin with mechanisms for echoing environment variables, package version and generic attributes + pytest plugin that allows to dump environment variables, package version and generic attributes :pypi:`pytest-edit` *last release*: Nov 17, 2024, @@ -5852,6 +5855,13 @@ This list contains 1613 plugins. pytest plugin for apps written with Google's AppEngine + :pypi:`pytest-gak` + *last release*: Mar 29, 2025, + *status*: N/A, + *requires*: N/A + + A Pytest plugin and command line tool for interactive testing with Pytest + :pypi:`pytest-gather-fixtures` *last release*: Aug 18, 2024, *status*: N/A, @@ -5916,7 +5926,7 @@ This list contains 1613 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Mar 28, 2025, + *last release*: Apr 04, 2025, *status*: N/A, *requires*: pytest>=3.6 @@ -6224,7 +6234,7 @@ This list contains 1613 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Mar 29, 2025, + *last release*: Apr 05, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.5 @@ -6441,7 +6451,7 @@ This list contains 1613 plugins. help hypo module for pytest :pypi:`pytest-iam` - *last release*: Jul 25, 2024, + *last release*: Apr 04, 2025, *status*: 4 - Beta, *requires*: pytest>=7.0.0 @@ -6707,7 +6717,7 @@ This list contains 1613 plugins. Pytest plugin for checking charm relation interface protocol compliance. :pypi:`pytest-invenio` - *last release*: Mar 07, 2025, + *last release*: Apr 02, 2025, *status*: 5 - Production/Stable, *requires*: pytest<9.0.0,>=6 @@ -7386,9 +7396,9 @@ This list contains 1613 plugins. pytest fixture logging configured from packaged YAML :pypi:`pytest-logikal` - *last release*: Mar 02, 2025, + *last release*: Apr 02, 2025, *status*: 5 - Production/Stable, - *requires*: pytest==8.3.4 + *requires*: pytest==8.3.5 Common testing environment @@ -7435,7 +7445,7 @@ This list contains 1613 plugins. Pytest plugin to generate realtime test results to a file :pypi:`pytest-manifest` - *last release*: Mar 18, 2025, + *last release*: Apr 01, 2025, *status*: N/A, *requires*: pytest @@ -7477,9 +7487,9 @@ This list contains 1613 plugins. Run markdown code fences through pytest :pypi:`pytest-marker-bugzilla` - *last release*: Jan 09, 2020, - *status*: N/A, - *requires*: N/A + *last release*: Apr 02, 2025, + *status*: 5 - Production/Stable, + *requires*: pytest>=2.2.4 py.test bugzilla integration plugin, using markers @@ -7652,7 +7662,7 @@ This list contains 1613 plugins. pytest plugin to write integration tests for projects using Mercurial Python internals :pypi:`pytest-mergify` - *last release*: Mar 27, 2025, + *last release*: Mar 31, 2025, *status*: N/A, *requires*: N/A @@ -8030,7 +8040,7 @@ This list contains 1613 plugins. A pytest plugin that does awesome things :pypi:`pytest-mypy` - *last release*: Mar 28, 2025, + *last release*: Apr 02, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 @@ -8170,7 +8180,7 @@ This list contains 1613 plugins. pytest ngs fixtures :pypi:`pytest-nhsd-apim` - *last release*: Mar 21, 2025, + *last release*: Apr 01, 2025, *status*: N/A, *requires*: pytest<9.0.0,>=8.2.0 @@ -8393,6 +8403,13 @@ This list contains 1613 plugins. Pytest plugin for detecting inadvertent open file handles + :pypi:`pytest-open-html` + *last release*: Mar 31, 2025, + *status*: N/A, + *requires*: pytest>=6.0 + + Auto-open HTML reports after pytest runs + :pypi:`pytest-opentelemetry` *last release*: Nov 22, 2024, *status*: N/A, @@ -8744,9 +8761,9 @@ This list contains 1613 plugins. Pytest pexpect plugin. :pypi:`pytest-pg` - *last release*: May 21, 2024, + *last release*: Apr 03, 2025, *status*: 5 - Production/Stable, - *requires*: pytest>=6.0.0 + *requires*: pytest>=8.0.0 A tiny plugin for pytest which runs PostgreSQL in Docker @@ -9640,7 +9657,7 @@ This list contains 1613 plugins. Pytest fixtures for REANA. :pypi:`pytest-recorder` - *last release*: Jan 09, 2025, + *last release*: Mar 31, 2025, *status*: N/A, *requires*: N/A @@ -9843,7 +9860,7 @@ This list contains 1613 plugins. A basic HTML report for pytest using Jinja2 template engine. :pypi:`pytest-report-extras` - *last release*: Mar 20, 2025, + *last release*: Apr 04, 2025, *status*: N/A, *requires*: pytest>=8.0.0 @@ -10396,7 +10413,7 @@ This list contains 1613 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Mar 29, 2025, + *last release*: Apr 04, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10480,7 +10497,7 @@ This list contains 1613 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Mar 29, 2025, + *last release*: Apr 04, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10710,6 +10727,13 @@ This list contains 1613 plugins. Allow for multiple processes to log to a single file + :pypi:`pytest-skip` + *last release*: Apr 04, 2025, + *status*: 3 - Alpha, + *requires*: pytest + + A pytest plugin which allows to (de-)select or skip tests from a file. + :pypi:`pytest-skip-markers` *last release*: Aug 09, 2024, *status*: 5 - Production/Stable, @@ -11551,7 +11575,7 @@ This list contains 1613 plugins. A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. :pypi:`pytest-testinfra` - *last release*: May 26, 2024, + *last release*: Mar 30, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=6 @@ -12937,7 +12961,7 @@ This list contains 1613 plugins. 接口自动化测试框架 :pypi:`tursu` - *last release*: Mar 22, 2025, + *last release*: Apr 05, 2025, *status*: 4 - Beta, *requires*: pytest>=8.3.5 From 3f463206f7b484074910e71732d4f03449130320 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 06:18:23 +0200 Subject: [PATCH 376/445] build(deps): Bump pytest-django in /testing/plugins_integration (#13357) Bumps [pytest-django](https://github.com/pytest-dev/pytest-django) from 4.10.0 to 4.11.1. - [Release notes](https://github.com/pytest-dev/pytest-django/releases) - [Changelog](https://github.com/pytest-dev/pytest-django/blob/main/docs/changelog.rst) - [Commits](https://github.com/pytest-dev/pytest-django/compare/v4.10.0...v4.11.1) --- updated-dependencies: - dependency-name: pytest-django dependency-version: 4.11.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 05565fe89d4..fc604e1888d 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -3,7 +3,7 @@ django==5.1.7 pytest-asyncio==0.26.0 pytest-bdd==8.1.0 pytest-cov==6.0.0 -pytest-django==4.10.0 +pytest-django==4.11.1 pytest-flakes==4.0.5 pytest-html==4.1.1 pytest-mock==3.14.0 From 18439f52fd00bfa42a7ad1d66ca862bc62e36c59 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 04:53:01 +0000 Subject: [PATCH 377/445] build(deps): Bump pytest-cov in /testing/plugins_integration (#13358) Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 6.0.0 to 6.1.1. - [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest-cov/compare/v6.0.0...v6.1.1) --- updated-dependencies: - dependency-name: pytest-cov dependency-version: 6.1.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index fc604e1888d..93e3dc7d0b1 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -2,7 +2,7 @@ anyio[trio]==4.9.0 django==5.1.7 pytest-asyncio==0.26.0 pytest-bdd==8.1.0 -pytest-cov==6.0.0 +pytest-cov==6.1.1 pytest-django==4.11.1 pytest-flakes==4.0.5 pytest-html==4.1.1 From 46c94ee82ddbb4a541f5bd4fecd0b4071e1972ae Mon Sep 17 00:00:00 2001 From: Bahram Farahmand Date: Mon, 7 Apr 2025 14:02:21 +0300 Subject: [PATCH 378/445] Add note on using mixin classes for abstract test classes in documentation (#13346) --- changelog/8612.doc.rst | 5 +++++ doc/en/example/pythoncollection.rst | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 changelog/8612.doc.rst diff --git a/changelog/8612.doc.rst b/changelog/8612.doc.rst new file mode 100644 index 00000000000..6ab4102ace4 --- /dev/null +++ b/changelog/8612.doc.rst @@ -0,0 +1,5 @@ +Add a recipe for handling abstract test classes in the documentation. + +A new example has been added to the documentation to demonstrate how to use a mixin class to handle abstract +test classes without manually setting the ``__test__`` attribute for subclasses. +This ensures that subclasses of abstract test classes are automatically collected by pytest. diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 89d7ee42614..6a3b143d580 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -325,3 +325,30 @@ with ``Test`` by setting a boolean ``__test__`` attribute to ``False``. # Will not be discovered as a test class TestClass: __test__ = False + +.. note:: + + If you are working with abstract test classes and want to avoid manually setting + the ``__test__`` attribute for subclasses, you can use a mixin class to handle + this automatically. For example: + + .. code-block:: python + + # Mixin to handle abstract test classes + class NotATest: + def __init_subclass__(cls): + cls.__test__ = NotATest not in cls.__bases__ + + + # Abstract test class + class AbstractTest(NotATest): + pass + + + # Subclass that will be collected as a test + class RealTest(AbstractTest): + def test_example(self): + assert 1 + 1 == 2 + + This approach ensures that subclasses of abstract test classes are automatically + collected without needing to explicitly set the ``__test__`` attribute. From 0286f64602f4b3a5d64bdfd832595cecbe1738d1 Mon Sep 17 00:00:00 2001 From: TobiMcNamobi Date: Mon, 7 Apr 2025 20:33:28 +0200 Subject: [PATCH 379/445] Fix test suite when PYTEST_PLUGINS is set Fixes #12647 --- changelog/12647.contrib.rst | 1 + testing/test_helpconfig.py | 2 ++ testing/test_terminal.py | 1 + 3 files changed, 4 insertions(+) create mode 100644 changelog/12647.contrib.rst diff --git a/changelog/12647.contrib.rst b/changelog/12647.contrib.rst new file mode 100644 index 00000000000..1d7a3181778 --- /dev/null +++ b/changelog/12647.contrib.rst @@ -0,0 +1 @@ +Fixed running the test suite with the ``hypothesis`` pytest plugin. diff --git a/testing/test_helpconfig.py b/testing/test_helpconfig.py index 7fcf5804ace..dc7e709b65d 100644 --- a/testing/test_helpconfig.py +++ b/testing/test_helpconfig.py @@ -8,6 +8,7 @@ def test_version_verbose(pytester: Pytester, pytestconfig, monkeypatch) -> None: monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD") + monkeypatch.delenv("PYTEST_PLUGINS", raising=False) result = pytester.runpytest("--version", "--version") assert result.ret == 0 result.stdout.fnmatch_lines([f"*pytest*{pytest.__version__}*imported from*"]) @@ -17,6 +18,7 @@ def test_version_verbose(pytester: Pytester, pytestconfig, monkeypatch) -> None: def test_version_less_verbose(pytester: Pytester, pytestconfig, monkeypatch) -> None: monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD") + monkeypatch.delenv("PYTEST_PLUGINS", raising=False) result = pytester.runpytest("--version") assert result.ret == 0 result.stdout.fnmatch_lines([f"pytest {pytest.__version__}"]) diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 42638f2edd7..86feb33b3ec 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -859,6 +859,7 @@ def test_header_trailer_info( self, monkeypatch: MonkeyPatch, pytester: Pytester, request ) -> None: monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD") + monkeypatch.delenv("PYTEST_PLUGINS", raising=False) pytester.makepyfile( """ def test_passes(): From 9d7bf4e544f6e9d43ab0dd390a820d4dae140a53 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 06:18:52 +0200 Subject: [PATCH 380/445] [pre-commit.ci] pre-commit autoupdate (#13362) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.2 → v0.11.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.2...v0.11.4) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3741df6f51b..3573c876d9e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.11.2" + rev: "v0.11.4" hooks: - id: ruff args: ["--fix"] From b72f9a2d02f50b458970b8367b7d18de5baf0108 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 13 Apr 2025 04:48:41 +0000 Subject: [PATCH 381/445] [automated] Update plugin list (#13372) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 150 +++++++++++++++++++------------ 1 file changed, 91 insertions(+), 59 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 406ebe75dce..6690ad5196a 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =8.0.0 + :pypi:`pytest-aws-fixtures` A series of fixtures to use in integration tests involving actual AWS services. Apr 06, 2025 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-axe` pytest plugin for axe-selenium-python Nov 12, 2018 N/A pytest (>=3.0.0) :pypi:`pytest-axe-playwright-snapshot` A pytest plugin that runs Axe-core on Playwright pages and takes snapshots of the results. Jul 25, 2023 N/A pytest :pypi:`pytest-azure` Pytest utilities and mocks for Azure Jan 18, 2023 3 - Alpha pytest @@ -184,6 +184,7 @@ This list contains 1616 plugins. :pypi:`pytest-blue` A pytest plugin that adds a \`blue\` fixture for printing stuff in blue. Sep 05, 2022 N/A N/A :pypi:`pytest-board` Local continuous test runner with pytest and watchdog. Jan 20, 2019 N/A N/A :pypi:`pytest-boilerplate` The pytest plugin for your Django Boilerplate. Sep 12, 2024 5 - Production/Stable pytest>=4.0.0 + :pypi:`pytest-bonsai` Apr 08, 2025 N/A pytest>=6 :pypi:`pytest-boost-xml` Plugin for pytest to generate boost xml reports Nov 30, 2022 4 - Beta N/A :pypi:`pytest-bootstrap` Mar 04, 2022 N/A N/A :pypi:`pytest-boto-mock` Thin-wrapper around the mock package for easier use with pytest Jul 16, 2024 5 - Production/Stable pytest>=8.2.0 @@ -256,7 +257,7 @@ This list contains 1616 plugins. :pypi:`pytest-class-fixtures` Class as PyTest fixtures (and BDD steps) Nov 15, 2024 N/A pytest<9.0.0,>=8.3.3 :pypi:`pytest-cldf` Easy quality control for CLDF datasets using pytest Nov 07, 2022 N/A pytest (>=3.6) :pypi:`pytest-clean-database` A pytest plugin that cleans your database up after every test. Mar 14, 2025 3 - Alpha pytest<9,>=7.0 - :pypi:`pytest-cleanslate` Collects and executes pytest tests separately Sep 04, 2024 N/A pytest + :pypi:`pytest-cleanslate` Collects and executes pytest tests separately Apr 10, 2025 N/A pytest :pypi:`pytest_cleanup` Automated, comprehensive and well-organised pytest test cases. Jan 28, 2020 N/A N/A :pypi:`pytest-cleanuptotal` A cleanup plugin for pytest Nov 08, 2024 5 - Production/Stable N/A :pypi:`pytest-clerk` A set of pytest fixtures to help with integration testing with Clerk. Jan 30, 2025 N/A pytest<9.0.0,>=8.0.0 @@ -300,7 +301,7 @@ This list contains 1616 plugins. :pypi:`pytest-contexts` A plugin to run tests written with the Contexts framework using pytest May 19, 2021 4 - Beta N/A :pypi:`pytest-continuous` A pytest plugin to run tests continuously until failure or interruption. Apr 23, 2024 N/A N/A :pypi:`pytest-cookies` The pytest plugin for your Cookiecutter templates. 🍪 Mar 22, 2023 5 - Production/Stable pytest (>=3.9.0) - :pypi:`pytest-copie` The pytest plugin for your copier templates 📒 Jan 31, 2025 3 - Alpha pytest + :pypi:`pytest-copie` The pytest plugin for your copier templates 📒 Apr 09, 2025 3 - Alpha pytest :pypi:`pytest-copier` A pytest plugin to help testing Copier templates Dec 11, 2023 4 - Beta pytest>=7.3.2 :pypi:`pytest-couchdbkit` py.test extension for per-test couchdb databases using couchdbkit Apr 17, 2012 N/A N/A :pypi:`pytest-count` count erros and send email Jan 12, 2018 4 - Beta N/A @@ -338,7 +339,7 @@ This list contains 1616 plugins. :pypi:`pytest-dash` pytest fixtures to run dash applications. Mar 18, 2019 N/A N/A :pypi:`pytest-dashboard` May 30, 2024 N/A pytest<8.0.0,>=7.4.3 :pypi:`pytest-data` Useful functions for managing data for pytest fixtures Nov 01, 2016 5 - Production/Stable N/A - :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Mar 23, 2025 4 - Beta pytest + :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Apr 06, 2025 4 - Beta pytest :pypi:`pytest-databricks` Pytest plugin for remote Databricks notebooks testing Jul 29, 2020 N/A pytest :pypi:`pytest-datadir` pytest plugin for test data directories and files Feb 07, 2025 5 - Production/Stable pytest>=7.0 :pypi:`pytest-datadir-mgr` Manager for test data: downloads, artifact caching, and a tmpdir context. Apr 06, 2023 5 - Production/Stable pytest (>=7.1) @@ -421,7 +422,7 @@ This list contains 1616 plugins. :pypi:`pytest-doc` A documentation plugin for py.test. Jun 28, 2015 5 - Production/Stable N/A :pypi:`pytest-docfiles` pytest plugin to test codeblocks in your documentation. Dec 22, 2021 4 - Beta pytest (>=3.7.0) :pypi:`pytest-docgen` An RST Documentation Generator for pytest-based test suites Apr 17, 2020 N/A N/A - :pypi:`pytest-docker` Simple pytest fixtures for Docker and Docker Compose based tests Feb 06, 2025 N/A pytest<9.0,>=4.0 + :pypi:`pytest-docker` Simple pytest fixtures for Docker and Docker Compose based tests Apr 07, 2025 N/A pytest<9.0,>=4.0 :pypi:`pytest-docker-apache-fixtures` Pytest fixtures for testing with apache2 (httpd). Aug 12, 2024 4 - Beta pytest :pypi:`pytest-docker-butla` Jun 16, 2019 3 - Alpha N/A :pypi:`pytest-dockerc` Run, manage and stop Docker Compose project from Docker API Oct 09, 2020 5 - Production/Stable pytest (>=3.0) @@ -634,7 +635,7 @@ This list contains 1616 plugins. :pypi:`pytest-fxtest` Oct 27, 2020 N/A N/A :pypi:`pytest-fzf` fzf-based test selector for pytest Jan 06, 2025 4 - Beta pytest>=6.0.0 :pypi:`pytest_gae` pytest plugin for apps written with Google's AppEngine Aug 03, 2016 3 - Alpha N/A - :pypi:`pytest-gak` A Pytest plugin and command line tool for interactive testing with Pytest Mar 29, 2025 N/A N/A + :pypi:`pytest-gak` A Pytest plugin and command line tool for interactive testing with Pytest Apr 10, 2025 N/A N/A :pypi:`pytest-gather-fixtures` set up asynchronous pytest fixtures concurrently Aug 18, 2024 N/A pytest>=7.0.0 :pypi:`pytest-gc` The garbage collector plugin for py.test Feb 01, 2018 N/A N/A :pypi:`pytest-gcov` Uses gcov to measure test coverage of a C library Feb 01, 2018 3 - Alpha N/A @@ -644,7 +645,7 @@ This list contains 1616 plugins. :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Apr 04, 2025 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Apr 08, 2025 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -711,7 +712,7 @@ This list contains 1616 plugins. :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace. Feb 11, 2025 4 - Beta pytest>=7.0.0 :pypi:`pytest-http-mocker` Pytest plugin for http mocking (via https://github.com/vilus/mocker) Oct 20, 2019 N/A N/A :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A - :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Feb 24, 2025 3 - Alpha N/A + :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Apr 10, 2025 3 - Alpha N/A :pypi:`pytest-httptesting` http_testing framework on top of pytest Dec 19, 2024 N/A pytest>=8.2.0 :pypi:`pytest-httpx` Send responses to httpx. Nov 28, 2024 5 - Production/Stable pytest==8.* :pypi:`pytest-httpx-blockage` Disable httpx requests during a test run Feb 16, 2023 N/A pytest (>=7.2.1) @@ -742,9 +743,9 @@ This list contains 1616 plugins. :pypi:`pytest-ini` Reuse pytest.ini to store env variables Apr 26, 2022 N/A N/A :pypi:`pytest-initry` Plugin for sending automation test data from Pytest to the initry Apr 30, 2024 N/A pytest<9.0.0,>=8.1.1 :pypi:`pytest-inline` A pytest plugin for writing inline tests Oct 24, 2024 4 - Beta pytest<9.0,>=7.0 - :pypi:`pytest-inmanta` A py.test plugin providing fixtures to simplify inmanta modules testing. Oct 10, 2024 5 - Production/Stable pytest - :pypi:`pytest-inmanta-extensions` Inmanta tests package Jan 17, 2025 5 - Production/Stable N/A - :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Dec 13, 2024 5 - Production/Stable N/A + :pypi:`pytest-inmanta` A py.test plugin providing fixtures to simplify inmanta modules testing. Apr 09, 2025 5 - Production/Stable pytest + :pypi:`pytest-inmanta-extensions` Inmanta tests package Apr 10, 2025 5 - Production/Stable N/A + :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Apr 09, 2025 5 - Production/Stable N/A :pypi:`pytest-inmanta-yang` Common fixtures used in inmanta yang related modules Feb 22, 2024 4 - Beta pytest :pypi:`pytest-Inomaly` A simple image diff plugin for pytest Feb 13, 2018 4 - Beta N/A :pypi:`pytest-in-robotframework` The extension enables easy execution of pytest tests within the Robot Framework environment. Nov 23, 2024 N/A pytest @@ -853,7 +854,7 @@ This list contains 1616 plugins. :pypi:`pytest-logger` Plugin configuring handlers for loggers from Python logging module. Mar 10, 2024 5 - Production/Stable pytest (>=3.2) :pypi:`pytest-logging` Configures logging and allows tweaking the log level with a py.test flag Nov 04, 2015 4 - Beta N/A :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-logging-strict` pytest fixture logging configured from packaged YAML Mar 23, 2025 3 - Alpha pytest + :pypi:`pytest-logging-strict` pytest fixture logging configured from packaged YAML Apr 09, 2025 3 - Alpha pytest :pypi:`pytest-logikal` Common testing environment Apr 02, 2025 5 - Production/Stable pytest==8.3.5 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Sep 30, 2024 4 - Beta pytest>=8.2.2 @@ -861,12 +862,12 @@ This list contains 1616 plugins. :pypi:`pytest-loop` pytest plugin for looping tests Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-lsp` A pytest plugin for end-to-end testing of language servers Nov 23, 2024 3 - Alpha pytest :pypi:`pytest-lw-realtime-result` Pytest plugin to generate realtime test results to a file Mar 13, 2025 N/A pytest>=3.5.0 - :pypi:`pytest-manifest` PyTest plugin for recording and asserting against a manifest file Apr 01, 2025 N/A pytest + :pypi:`pytest-manifest` PyTest plugin for recording and asserting against a manifest file Apr 07, 2025 N/A pytest :pypi:`pytest-manual-marker` pytest marker for marking manual tests Aug 04, 2022 3 - Alpha pytest>=7 :pypi:`pytest-mark-count` Get a count of the number of tests marked, unmarked, and unique tests if tests have multiple markers Nov 13, 2024 4 - Beta pytest>=8.0.0 :pypi:`pytest-markdoctest` A pytest plugin to doctest your markdown files Jul 22, 2022 4 - Beta pytest (>=6) :pypi:`pytest-markdown` Test your markdown docs with pytest Jan 15, 2021 4 - Beta pytest (>=6.0.1,<7.0.0) - :pypi:`pytest-markdown-docs` Run markdown code fences through pytest Mar 13, 2025 N/A pytest>=7.0.0 + :pypi:`pytest-markdown-docs` Run markdown code fences through pytest Apr 09, 2025 N/A pytest>=7.0.0 :pypi:`pytest-marker-bugzilla` py.test bugzilla integration plugin, using markers Apr 02, 2025 5 - Production/Stable pytest>=2.2.4 :pypi:`pytest-markers-presence` A simple plugin to detect missed pytest tags and markers" Oct 30, 2024 4 - Beta pytest>=6.0 :pypi:`pytest-markfiltration` UNKNOWN Nov 08, 2011 3 - Alpha N/A @@ -892,7 +893,7 @@ This list contains 1616 plugins. :pypi:`pytest-memray` A simple plugin to use with pytest Jul 25, 2024 N/A pytest>=7.2 :pypi:`pytest-menu` A pytest plugin for console based interactive test selection just after the collection phase Oct 04, 2017 3 - Alpha pytest (>=2.4.2) :pypi:`pytest-mercurial` pytest plugin to write integration tests for projects using Mercurial Python internals Nov 21, 2020 1 - Planning N/A - :pypi:`pytest-mergify` Pytest plugin for Mergify Mar 31, 2025 N/A N/A + :pypi:`pytest-mergify` Pytest plugin for Mergify Apr 10, 2025 N/A N/A :pypi:`pytest-mesh` pytest_mesh插件 Aug 05, 2022 N/A pytest (==7.1.2) :pypi:`pytest-message` Pytest plugin for sending report message of marked tests execution Aug 04, 2022 N/A pytest (>=6.2.5) :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A @@ -900,12 +901,14 @@ This list contains 1616 plugins. :pypi:`pytest-metrics` Custom metrics report for pytest Apr 04, 2020 N/A pytest :pypi:`pytest-mh` Pytest multihost plugin Mar 06, 2025 N/A pytest :pypi:`pytest-mimesis` Mimesis integration with the pytest test runner Mar 21, 2020 5 - Production/Stable pytest (>=4.2) + :pypi:`pytest-mimic` Easily record function calls while testing Apr 11, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-minecraft` A pytest plugin for running tests against Minecraft releases Apr 06, 2022 N/A pytest (>=6.0.1) :pypi:`pytest-mini` A plugin to test mp Feb 06, 2023 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-minio-mock` A pytest plugin for mocking Minio S3 interactions Aug 27, 2024 N/A pytest>=5.0.0 :pypi:`pytest-missing-fixtures` Pytest plugin that creates missing fixtures Oct 14, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-missing-modules` Pytest plugin to easily fake missing modules Sep 03, 2024 N/A pytest>=8.3.2 :pypi:`pytest-mitmproxy` pytest plugin for mitmproxy tests Nov 13, 2024 N/A pytest>=7.0 + :pypi:`pytest-mitmproxy-plugin` Use MITM Proxy in autotests with full control from code Apr 10, 2025 4 - Beta pytest>=7.2.0 :pypi:`pytest-ml` Test your machine learning! May 04, 2019 4 - Beta N/A :pypi:`pytest-mocha` pytest plugin to display test execution output like a mochajs Apr 02, 2020 4 - Beta pytest (>=5.4.0) :pypi:`pytest-mock` Thin-wrapper around the mock package for easier use with pytest Mar 21, 2024 5 - Production/Stable pytest>=6.2.5 @@ -958,7 +961,7 @@ This list contains 1616 plugins. :pypi:`pytest-neo` pytest-neo is a plugin for pytest that shows tests like screen of Matrix. Jan 08, 2022 3 - Alpha pytest (>=6.2.0) :pypi:`pytest-neos` Pytest plugin for neos Sep 10, 2024 5 - Production/Stable pytest<8.0,>=7.2; extra == "dev" :pypi:`pytest-netconf` A pytest plugin that provides a mock NETCONF (RFC6241/RFC6242) server for local testing. Jan 06, 2025 N/A N/A - :pypi:`pytest-netdut` "Automated software testing for switches using pytest" Jul 05, 2024 N/A pytest<7.3,>=3.5.0 + :pypi:`pytest-netdut` "Automated software testing for switches using pytest" Apr 11, 2025 N/A pytest>=3.5.0 :pypi:`pytest-network` A simple plugin to disable network on socket level. May 07, 2020 N/A N/A :pypi:`pytest-network-endpoints` Network endpoints plugin for pytest Mar 06, 2022 N/A pytest :pypi:`pytest-never-sleep` pytest plugin helps to avoid adding tests without mock \`time.sleep\` May 05, 2021 3 - Alpha pytest (>=3.5.1) @@ -974,6 +977,7 @@ This list contains 1616 plugins. :pypi:`pytest-node-dependency` pytest plugin for controlling execution flow Apr 10, 2024 5 - Production/Stable N/A :pypi:`pytest-nodev` Test-driven source code search for Python. Jul 21, 2016 4 - Beta pytest (>=2.8.1) :pypi:`pytest-nogarbage` Ensure a test produces no garbage Feb 24, 2025 5 - Production/Stable pytest>=4.6.0 + :pypi:`pytest-no-problem` Pytest plugin to tell you when there's no problem Apr 05, 2025 N/A pytest>=7.0 :pypi:`pytest-nose-attrib` pytest plugin to use nose @attrib marks decorators and pick tests based on attributes and partially uses nose-attrib plugin approach Aug 13, 2023 N/A N/A :pypi:`pytest_notebook` A pytest plugin for testing Jupyter Notebooks. Nov 28, 2023 4 - Beta pytest>=3.5.0 :pypi:`pytest-notice` Send pytest execution result email Nov 05, 2020 N/A N/A @@ -1021,7 +1025,6 @@ This list contains 1616 plugins. :pypi:`pytest-parallel-39` a pytest plugin for parallel and concurrent testing Jul 12, 2021 3 - Alpha pytest (>=3.0.0) :pypi:`pytest-parallelize-tests` pytest plugin that parallelizes test execution across multiple hosts Jan 27, 2023 4 - Beta N/A :pypi:`pytest-param` pytest plugin to test all, first, last or random params Sep 11, 2016 4 - Beta pytest (>=2.6.0) - :pypi:`pytest-paramark` Configure pytest fixtures using a combination of"parametrize" and markers Jan 10, 2020 4 - Beta pytest (>=4.5.0) :pypi:`pytest-parametrization` Simpler PyTest parametrization May 22, 2022 5 - Production/Stable N/A :pypi:`pytest-parametrization-annotation` A pytest library for parametrizing tests using type hints. Dec 10, 2024 5 - Production/Stable pytest>=7 :pypi:`pytest-parametrize` pytest decorator for parametrizing test cases in a dict-way Nov 10, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.0 @@ -1049,7 +1052,7 @@ This list contains 1616 plugins. :pypi:`pytest-performancetotal` A performance plugin for pytest Feb 01, 2025 5 - Production/Stable N/A :pypi:`pytest-persistence` Pytest tool for persistent objects Aug 21, 2024 N/A N/A :pypi:`pytest-pexpect` Pytest pexpect plugin. Aug 13, 2024 4 - Beta pytest>=6.2.0 - :pypi:`pytest-pg` A tiny plugin for pytest which runs PostgreSQL in Docker Apr 03, 2025 5 - Production/Stable pytest>=8.0.0 + :pypi:`pytest-pg` A tiny plugin for pytest which runs PostgreSQL in Docker Apr 11, 2025 5 - Production/Stable pytest>=8.0.0 :pypi:`pytest-pgsql` Pytest plugins and helpers for tests using a Postgres database. May 13, 2020 5 - Production/Stable pytest (>=3.0.0) :pypi:`pytest-phmdoctest` pytest plugin to test Python examples in Markdown using phmdoctest. Apr 15, 2022 4 - Beta pytest (>=5.4.3) :pypi:`pytest-phoenix-interface` Pytest extension tool for phoenix projects. Mar 19, 2025 N/A N/A @@ -1174,7 +1177,7 @@ This list contains 1616 plugins. :pypi:`pytest-randomness` Pytest plugin about random seed management May 30, 2019 3 - Alpha N/A :pypi:`pytest-random-num` Randomise the order in which pytest tests are run with some control over the randomness Oct 19, 2020 5 - Production/Stable N/A :pypi:`pytest-random-order` Randomise the order in which pytest tests are run with some control over the randomness Jan 20, 2024 5 - Production/Stable pytest >=3.0.0 - :pypi:`pytest-ranking` A Pytest plugin for automatically prioritizing/ranking tests to speed up failure detection Jan 14, 2025 4 - Beta pytest>=7.4.3 + :pypi:`pytest-ranking` A Pytest plugin for faster fault detection via regression test prioritization Apr 08, 2025 4 - Beta pytest>=7.4.3 :pypi:`pytest-readme` Test your README.md file Sep 02, 2022 5 - Production/Stable N/A :pypi:`pytest-reana` Pytest fixtures for REANA. Sep 04, 2024 3 - Alpha N/A :pypi:`pytest-recorder` Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. Mar 31, 2025 N/A N/A @@ -1198,7 +1201,7 @@ This list contains 1616 plugins. :pypi:`pytest-remote-response` Pytest plugin for capturing and mocking connection requests. Apr 26, 2023 5 - Production/Stable pytest (>=4.6) :pypi:`pytest-remove-stale-bytecode` py.test plugin to remove stale byte code files. Jul 07, 2023 4 - Beta pytest :pypi:`pytest-reorder` Reorder tests depending on their paths and names. May 31, 2018 4 - Beta pytest - :pypi:`pytest-repeat` pytest plugin for repeating tests Oct 09, 2023 5 - Production/Stable pytest + :pypi:`pytest-repeat` pytest plugin for repeating tests Apr 07, 2025 5 - Production/Stable pytest :pypi:`pytest_repeater` py.test plugin for repeating single test multiple times. Feb 09, 2018 1 - Planning N/A :pypi:`pytest-replay` Saves previous test runs and allow re-execute previous pytest runs to reproduce crashes or flaky tests Feb 05, 2025 5 - Production/Stable pytest :pypi:`pytest-repo-health` A pytest plugin to report on repository standards conformance Mar 12, 2025 3 - Alpha pytest @@ -1285,7 +1288,7 @@ This list contains 1616 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Apr 04, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Apr 10, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1297,7 +1300,7 @@ This list contains 1616 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Apr 04, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Apr 10, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1432,7 +1435,7 @@ This list contains 1616 plugins. :pypi:`pytest-tap` Test Anything Protocol (TAP) reporting plugin for pytest Jan 30, 2025 5 - Production/Stable pytest>=3.0 :pypi:`pytest-tape` easy assertion with expected results saved to yaml files Mar 17, 2021 4 - Beta N/A :pypi:`pytest-target` Pytest plugin for remote target orchestration. Jan 21, 2021 3 - Alpha pytest (>=6.1.2,<7.0.0) - :pypi:`pytest-taskgraph` Add your description here Dec 12, 2024 N/A pytest + :pypi:`pytest-taskgraph` Add your description here Apr 09, 2025 N/A pytest :pypi:`pytest-tblineinfo` tblineinfo is a py.test plugin that insert the node id in the final py.test report when --tb=line option is used Dec 01, 2015 3 - Alpha pytest (>=2.0) :pypi:`pytest-tcpclient` A pytest plugin for testing TCP clients Nov 16, 2022 N/A pytest (<8,>=7.1.3) :pypi:`pytest-tdd` run pytest on a python module Aug 18, 2023 4 - Beta N/A @@ -1533,6 +1536,7 @@ This list contains 1616 plugins. :pypi:`pytest-tst` Customize pytest options, output and exit code to make it compatible with tst Apr 27, 2022 N/A pytest (>=5.0.0) :pypi:`pytest-tstcls` Test Class Base Mar 23, 2020 5 - Production/Stable N/A :pypi:`pytest-tui` Text User Interface (TUI) and HTML report for Pytest test runs Dec 08, 2023 4 - Beta N/A + :pypi:`pytest-tuitest` pytest plugin for testing TUI and regular command-line applications. Apr 11, 2025 N/A pytest>=7.4.0 :pypi:`pytest-tutorials` Mar 11, 2023 N/A N/A :pypi:`pytest-twilio-conversations-client-mock` Aug 02, 2022 N/A N/A :pypi:`pytest-twisted` A twisted plugin for pytest. Sep 10, 2024 5 - Production/Stable pytest>=2.3 @@ -1634,7 +1638,7 @@ This list contains 1616 plugins. :pypi:`pytest-yapf` Run yapf Jul 06, 2017 4 - Beta pytest (>=3.1.1) :pypi:`pytest-yapf3` Validate your Python file format with yapf Mar 29, 2023 5 - Production/Stable pytest (>=7) :pypi:`pytest-yield` PyTest plugin to run tests concurrently, each \`yield\` switch context to other one Jan 23, 2019 N/A N/A - :pypi:`pytest-yls` Pytest plugin to test the YLS as a whole. Oct 18, 2024 N/A pytest<9.0.0,>=8.3.3 + :pypi:`pytest-yls` Pytest plugin to test the YLS as a whole. Apr 09, 2025 N/A pytest<9.0.0,>=8.3.3 :pypi:`pytest-youqu-playwright` pytest-youqu-playwright Jun 12, 2024 N/A pytest :pypi:`pytest-yuk` Display tests you are uneasy with, using 🤢/🤮 for pass/fail of tests marked with yuk. Mar 26, 2021 N/A pytest>=5.0.0 :pypi:`pytest-zafira` A Zafira plugin for pytest Sep 18, 2019 5 - Production/Stable pytest (==4.1.1) @@ -1649,7 +1653,7 @@ This list contains 1616 plugins. :pypi:`pytest-zigzag` Extend py.test for RPC OpenStack testing. Feb 27, 2019 4 - Beta pytest (~=3.6) :pypi:`pytest-zulip` Pytest report plugin for Zulip May 07, 2022 5 - Production/Stable pytest :pypi:`pytest-zy` 接口自动化测试框架 Mar 24, 2024 N/A pytest~=7.2.0 - :pypi:`tursu` 🎬 A pytest plugin that transpiles Gherkin feature files to Python using AST, enforcing typing for ease of use and debugging. Apr 05, 2025 4 - Beta pytest>=8.3.5 + :pypi:`tursu` 🎬 A pytest plugin that transpiles Gherkin feature files to Python using AST, enforcing typing for ease of use and debugging. Apr 10, 2025 4 - Beta pytest>=8.3.5 =============================================== ====================================================================================================================================================================================================================================================================================================================================================================================== ============== ===================== ================================================ .. only:: latex @@ -2412,7 +2416,7 @@ This list contains 1616 plugins. Protect your AWS credentials in unit tests :pypi:`pytest-aws-fixtures` - *last release*: Apr 04, 2025, + *last release*: Apr 06, 2025, *status*: N/A, *requires*: pytest<9.0.0,>=8.0.0 @@ -2705,6 +2709,13 @@ This list contains 1616 plugins. The pytest plugin for your Django Boilerplate. + :pypi:`pytest-bonsai` + *last release*: Apr 08, 2025, + *status*: N/A, + *requires*: pytest>=6 + + + :pypi:`pytest-boost-xml` *last release*: Nov 30, 2022, *status*: 4 - Beta, @@ -3210,7 +3221,7 @@ This list contains 1616 plugins. A pytest plugin that cleans your database up after every test. :pypi:`pytest-cleanslate` - *last release*: Sep 04, 2024, + *last release*: Apr 10, 2025, *status*: N/A, *requires*: pytest @@ -3518,7 +3529,7 @@ This list contains 1616 plugins. The pytest plugin for your Cookiecutter templates. 🍪 :pypi:`pytest-copie` - *last release*: Jan 31, 2025, + *last release*: Apr 09, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -3784,7 +3795,7 @@ This list contains 1616 plugins. Useful functions for managing data for pytest fixtures :pypi:`pytest-databases` - *last release*: Mar 23, 2025, + *last release*: Apr 06, 2025, *status*: 4 - Beta, *requires*: pytest @@ -4365,7 +4376,7 @@ This list contains 1616 plugins. An RST Documentation Generator for pytest-based test suites :pypi:`pytest-docker` - *last release*: Feb 06, 2025, + *last release*: Apr 07, 2025, *status*: N/A, *requires*: pytest<9.0,>=4.0 @@ -5856,7 +5867,7 @@ This list contains 1616 plugins. pytest plugin for apps written with Google's AppEngine :pypi:`pytest-gak` - *last release*: Mar 29, 2025, + *last release*: Apr 10, 2025, *status*: N/A, *requires*: N/A @@ -5926,7 +5937,7 @@ This list contains 1616 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Apr 04, 2025, + *last release*: Apr 08, 2025, *status*: N/A, *requires*: pytest>=3.6 @@ -6395,7 +6406,7 @@ This list contains 1616 plugins. A thin wrapper of HTTPretty for pytest :pypi:`pytest_httpserver` - *last release*: Feb 24, 2025, + *last release*: Apr 10, 2025, *status*: 3 - Alpha, *requires*: N/A @@ -6612,21 +6623,21 @@ This list contains 1616 plugins. A pytest plugin for writing inline tests :pypi:`pytest-inmanta` - *last release*: Oct 10, 2024, + *last release*: Apr 09, 2025, *status*: 5 - Production/Stable, *requires*: pytest A py.test plugin providing fixtures to simplify inmanta modules testing. :pypi:`pytest-inmanta-extensions` - *last release*: Jan 17, 2025, + *last release*: Apr 10, 2025, *status*: 5 - Production/Stable, *requires*: N/A Inmanta tests package :pypi:`pytest-inmanta-lsm` - *last release*: Dec 13, 2024, + *last release*: Apr 09, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -7389,7 +7400,7 @@ This list contains 1616 plugins. :pypi:`pytest-logging-strict` - *last release*: Mar 23, 2025, + *last release*: Apr 09, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -7445,7 +7456,7 @@ This list contains 1616 plugins. Pytest plugin to generate realtime test results to a file :pypi:`pytest-manifest` - *last release*: Apr 01, 2025, + *last release*: Apr 07, 2025, *status*: N/A, *requires*: pytest @@ -7480,7 +7491,7 @@ This list contains 1616 plugins. Test your markdown docs with pytest :pypi:`pytest-markdown-docs` - *last release*: Mar 13, 2025, + *last release*: Apr 09, 2025, *status*: N/A, *requires*: pytest>=7.0.0 @@ -7662,7 +7673,7 @@ This list contains 1616 plugins. pytest plugin to write integration tests for projects using Mercurial Python internals :pypi:`pytest-mergify` - *last release*: Mar 31, 2025, + *last release*: Apr 10, 2025, *status*: N/A, *requires*: N/A @@ -7717,6 +7728,13 @@ This list contains 1616 plugins. Mimesis integration with the pytest test runner + :pypi:`pytest-mimic` + *last release*: Apr 11, 2025, + *status*: 4 - Beta, + *requires*: pytest>=6.2.0 + + Easily record function calls while testing + :pypi:`pytest-minecraft` *last release*: Apr 06, 2022, *status*: N/A, @@ -7759,6 +7777,13 @@ This list contains 1616 plugins. pytest plugin for mitmproxy tests + :pypi:`pytest-mitmproxy-plugin` + *last release*: Apr 10, 2025, + *status*: 4 - Beta, + *requires*: pytest>=7.2.0 + + Use MITM Proxy in autotests with full control from code + :pypi:`pytest-ml` *last release*: May 04, 2019, *status*: 4 - Beta, @@ -8124,9 +8149,9 @@ This list contains 1616 plugins. A pytest plugin that provides a mock NETCONF (RFC6241/RFC6242) server for local testing. :pypi:`pytest-netdut` - *last release*: Jul 05, 2024, + *last release*: Apr 11, 2025, *status*: N/A, - *requires*: pytest<7.3,>=3.5.0 + *requires*: pytest>=3.5.0 "Automated software testing for switches using pytest" @@ -8235,6 +8260,13 @@ This list contains 1616 plugins. Ensure a test produces no garbage + :pypi:`pytest-no-problem` + *last release*: Apr 05, 2025, + *status*: N/A, + *requires*: pytest>=7.0 + + Pytest plugin to tell you when there's no problem + :pypi:`pytest-nose-attrib` *last release*: Aug 13, 2023, *status*: N/A, @@ -8564,13 +8596,6 @@ This list contains 1616 plugins. pytest plugin to test all, first, last or random params - :pypi:`pytest-paramark` - *last release*: Jan 10, 2020, - *status*: 4 - Beta, - *requires*: pytest (>=4.5.0) - - Configure pytest fixtures using a combination of"parametrize" and markers - :pypi:`pytest-parametrization` *last release*: May 22, 2022, *status*: 5 - Production/Stable, @@ -8761,7 +8786,7 @@ This list contains 1616 plugins. Pytest pexpect plugin. :pypi:`pytest-pg` - *last release*: Apr 03, 2025, + *last release*: Apr 11, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=8.0.0 @@ -9636,11 +9661,11 @@ This list contains 1616 plugins. Randomise the order in which pytest tests are run with some control over the randomness :pypi:`pytest-ranking` - *last release*: Jan 14, 2025, + *last release*: Apr 08, 2025, *status*: 4 - Beta, *requires*: pytest>=7.4.3 - A Pytest plugin for automatically prioritizing/ranking tests to speed up failure detection + A Pytest plugin for faster fault detection via regression test prioritization :pypi:`pytest-readme` *last release*: Sep 02, 2022, @@ -9804,7 +9829,7 @@ This list contains 1616 plugins. Reorder tests depending on their paths and names. :pypi:`pytest-repeat` - *last release*: Oct 09, 2023, + *last release*: Apr 07, 2025, *status*: 5 - Production/Stable, *requires*: pytest @@ -10413,7 +10438,7 @@ This list contains 1616 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Apr 04, 2025, + *last release*: Apr 10, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10497,7 +10522,7 @@ This list contains 1616 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Apr 04, 2025, + *last release*: Apr 10, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -11442,7 +11467,7 @@ This list contains 1616 plugins. Pytest plugin for remote target orchestration. :pypi:`pytest-taskgraph` - *last release*: Dec 12, 2024, + *last release*: Apr 09, 2025, *status*: N/A, *requires*: pytest @@ -12148,6 +12173,13 @@ This list contains 1616 plugins. Text User Interface (TUI) and HTML report for Pytest test runs + :pypi:`pytest-tuitest` + *last release*: Apr 11, 2025, + *status*: N/A, + *requires*: pytest>=7.4.0 + + pytest plugin for testing TUI and regular command-line applications. + :pypi:`pytest-tutorials` *last release*: Mar 11, 2023, *status*: N/A, @@ -12856,7 +12888,7 @@ This list contains 1616 plugins. PyTest plugin to run tests concurrently, each \`yield\` switch context to other one :pypi:`pytest-yls` - *last release*: Oct 18, 2024, + *last release*: Apr 09, 2025, *status*: N/A, *requires*: pytest<9.0.0,>=8.3.3 @@ -12961,7 +12993,7 @@ This list contains 1616 plugins. 接口自动化测试框架 :pypi:`tursu` - *last release*: Apr 05, 2025, + *last release*: Apr 10, 2025, *status*: 4 - Beta, *requires*: pytest>=8.3.5 From 103b2b67b015b5f677eef471c3d34706b5efedaa Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 21:34:23 -0300 Subject: [PATCH 382/445] [pre-commit.ci] pre-commit autoupdate (#13375) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.4 → v0.11.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.4...v0.11.5) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3573c876d9e..a9d59e15551 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.11.4" + rev: "v0.11.5" hooks: - id: ruff args: ["--fix"] From 61c204a0355c89946cb0f3202820c5a0ec85e13d Mon Sep 17 00:00:00 2001 From: Stefan Zimmermann Date: Fri, 18 Apr 2025 23:18:36 +0200 Subject: [PATCH 383/445] Fix handling of positional-only parameters in test methods (#13377) Fixes #13376 --- changelog/13377.bugfix.rst | 12 ++++++++++++ src/_pytest/compat.py | 10 +++++----- testing/python/fixtures.py | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 changelog/13377.bugfix.rst diff --git a/changelog/13377.bugfix.rst b/changelog/13377.bugfix.rst new file mode 100644 index 00000000000..15755481f7f --- /dev/null +++ b/changelog/13377.bugfix.rst @@ -0,0 +1,12 @@ +Fixed handling of test methods with positional-only parameter syntax. + +Now, methods are supported that formally define ``self`` as positional-only +and/or fixture parameters as keyword-only, e.g.: + +.. code-block:: python + + class TestClass: + + def test_method(self, /, *, fixture): ... + +Before, this caused an internal error in pytest. diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index 2cbb17eca38..f113a2197f3 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -122,7 +122,7 @@ def getfuncargnames( # creates a tuple of the names of the parameters that don't have # defaults. try: - parameters = signature(function).parameters + parameters = signature(function).parameters.values() except (ValueError, TypeError) as e: from _pytest.outcomes import fail @@ -133,7 +133,7 @@ def getfuncargnames( arg_names = tuple( p.name - for p in parameters.values() + for p in parameters if ( p.kind is Parameter.POSITIONAL_OR_KEYWORD or p.kind is Parameter.KEYWORD_ONLY @@ -144,9 +144,9 @@ def getfuncargnames( name = function.__name__ # If this function should be treated as a bound method even though - # it's passed as an unbound method or function, remove the first - # parameter name. - if ( + # it's passed as an unbound method or function, and its first parameter + # wasn't defined as positional only, remove the first parameter name. + if not any(p.kind is Parameter.POSITIONAL_ONLY for p in parameters) and ( # Not using `getattr` because we don't want to resolve the staticmethod. # Not using `cls.__dict__` because we want to check the entire MRO. cls diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index 32453739e8c..fb76fe6cf96 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -48,7 +48,23 @@ class A: def f(self, arg1, arg2="hello"): raise NotImplementedError() + def g(self, /, arg1, arg2="hello"): + raise NotImplementedError() + + def h(self, *, arg1, arg2="hello"): + raise NotImplementedError() + + def j(self, arg1, *, arg2, arg3="hello"): + raise NotImplementedError() + + def k(self, /, arg1, *, arg2, arg3="hello"): + raise NotImplementedError() + assert getfuncargnames(A().f) == ("arg1",) + assert getfuncargnames(A().g) == ("arg1",) + assert getfuncargnames(A().h) == ("arg1",) + assert getfuncargnames(A().j) == ("arg1", "arg2") + assert getfuncargnames(A().k) == ("arg1", "arg2") def test_getfuncargnames_staticmethod(): @@ -5033,3 +5049,22 @@ def test_foo(another_fixture): ) result = pytester.runpytest() result.assert_outcomes(passed=1) + + +def test_collect_positional_only(pytester: Pytester) -> None: + """Support the collection of tests with positional-only arguments (#13376).""" + pytester.makepyfile( + """ + import pytest + + class Test: + @pytest.fixture + def fix(self): + return 1 + + def test_method(self, /, fix): + assert fix == 1 + """ + ) + result = pytester.runpytest() + result.assert_outcomes(passed=1) From 7e93d83df30478e0243c6887d998575d4bff4ce5 Mon Sep 17 00:00:00 2001 From: Peter Gessler Date: Sat, 19 Apr 2025 16:34:09 -0500 Subject: [PATCH 384/445] Fix `ExceptionGroup` traceback filtering of pytest internals (#13380) * init * + author * fix * Simplify the code a bit * Small refactor * Import functions from `traceback` directly, to allow free use of `traceback` as a variable name. * Extract `_filtered_traceback` into a function. * Inline `_repr_exception_group_traceback` given it is used only in one place. * Make a type alias for the type of `tbfilter`. * action rerun * + comment * fix docs * Revert "fix docs" This reverts commit fc505cbaecb1131f52f1db6e3b0614054d3cba9a. * fix --------- Co-authored-by: Bruno Oliveira --- AUTHORS | 1 + changelog/13380.improvement.rst | 1 + src/_pytest/_code/code.py | 64 +++++++++++++++++++++------------ testing/code/test_excinfo.py | 3 ++ 4 files changed, 47 insertions(+), 22 deletions(-) create mode 100644 changelog/13380.improvement.rst diff --git a/AUTHORS b/AUTHORS index 9004008bfa5..e19a0ae5871 100644 --- a/AUTHORS +++ b/AUTHORS @@ -346,6 +346,7 @@ Pavel Karateev Pavel Zhukov Paweł Adamczak Pedro Algarvio +Peter Gessler Petter Strandmark Philipp Loose Pierre Sassoulas diff --git a/changelog/13380.improvement.rst b/changelog/13380.improvement.rst new file mode 100644 index 00000000000..51f374fbf01 --- /dev/null +++ b/changelog/13380.improvement.rst @@ -0,0 +1 @@ +Fix :class:`ExceptionGroup` traceback filtering to exclude pytest internals. diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 2c872df3008..f1241f14136 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -15,8 +15,10 @@ from pathlib import Path import re import sys -import traceback +from traceback import extract_tb +from traceback import format_exception from traceback import format_exception_only +from traceback import FrameSummary from types import CodeType from types import FrameType from types import TracebackType @@ -28,6 +30,7 @@ from typing import Literal from typing import overload from typing import SupportsIndex +from typing import TYPE_CHECKING from typing import TypeVar from typing import Union @@ -208,10 +211,10 @@ def with_repr_style( def lineno(self) -> int: return self._rawentry.tb_lineno - 1 - def get_python_framesummary(self) -> traceback.FrameSummary: + def get_python_framesummary(self) -> FrameSummary: # Python's built-in traceback module implements all the nitty gritty # details to get column numbers of out frames. - stack_summary = traceback.extract_tb(self._rawentry, limit=1) + stack_summary = extract_tb(self._rawentry, limit=1) return stack_summary[0] # Column and end line numbers introduced in python 3.11 @@ -694,8 +697,7 @@ def getrepr( showlocals: bool = False, style: TracebackStyle = "long", abspath: bool = False, - tbfilter: bool - | Callable[[ExceptionInfo[BaseException]], _pytest._code.code.Traceback] = True, + tbfilter: bool | Callable[[ExceptionInfo[BaseException]], Traceback] = True, funcargs: bool = False, truncate_locals: bool = True, truncate_args: bool = True, @@ -742,7 +744,7 @@ def getrepr( if style == "native": return ReprExceptionInfo( reprtraceback=ReprTracebackNative( - traceback.format_exception( + format_exception( self.type, self.value, self.traceback[0]._rawentry if self.traceback else None, @@ -851,6 +853,17 @@ def group_contains( return self._group_contains(self.value, expected_exception, match, depth) +if TYPE_CHECKING: + from typing_extensions import TypeAlias + + # Type alias for the `tbfilter` setting: + # bool: If True, it should be filtered using Traceback.filter() + # callable: A callable that takes an ExceptionInfo and returns the filtered traceback. + TracebackFilter: TypeAlias = Union[ + bool, Callable[[ExceptionInfo[BaseException]], Traceback] + ] + + @dataclasses.dataclass class FormattedExcinfo: """Presenting information about failing Functions and Generators.""" @@ -862,7 +875,7 @@ class FormattedExcinfo: showlocals: bool = False style: TracebackStyle = "long" abspath: bool = True - tbfilter: bool | Callable[[ExceptionInfo[BaseException]], Traceback] = True + tbfilter: TracebackFilter = True funcargs: bool = False truncate_locals: bool = True truncate_args: bool = True @@ -1100,11 +1113,7 @@ def _makepath(self, path: Path | str) -> str: return str(path) def repr_traceback(self, excinfo: ExceptionInfo[BaseException]) -> ReprTraceback: - traceback = excinfo.traceback - if callable(self.tbfilter): - traceback = self.tbfilter(excinfo) - elif self.tbfilter: - traceback = traceback.filter(excinfo) + traceback = filter_excinfo_traceback(self.tbfilter, excinfo) if isinstance(excinfo.value, RecursionError): traceback, extraline = self._truncate_recursive_traceback(traceback) @@ -1178,14 +1187,15 @@ def repr_excinfo(self, excinfo: ExceptionInfo[BaseException]) -> ExceptionChainR # Fall back to native traceback as a temporary workaround until # full support for exception groups added to ExceptionInfo. # See https://github.com/pytest-dev/pytest/issues/9159 + reprtraceback: ReprTraceback | ReprTracebackNative if isinstance(e, BaseExceptionGroup): - reprtraceback: ReprTracebackNative | ReprTraceback = ( - ReprTracebackNative( - traceback.format_exception( - type(excinfo_.value), - excinfo_.value, - excinfo_.traceback[0]._rawentry, - ) + # don't filter any sub-exceptions since they shouldn't have any internal frames + traceback = filter_excinfo_traceback(self.tbfilter, excinfo) + reprtraceback = ReprTracebackNative( + format_exception( + type(excinfo.value), + excinfo.value, + traceback[0]._rawentry, ) ) else: @@ -1194,9 +1204,7 @@ def repr_excinfo(self, excinfo: ExceptionInfo[BaseException]) -> ExceptionChainR else: # Fallback to native repr if the exception doesn't have a traceback: # ExceptionInfo objects require a full traceback to work. - reprtraceback = ReprTracebackNative( - traceback.format_exception(type(e), e, None) - ) + reprtraceback = ReprTracebackNative(format_exception(type(e), e, None)) reprcrash = None repr_chain += [(reprtraceback, reprcrash, descr)] @@ -1545,3 +1553,15 @@ def filter_traceback(entry: TracebackEntry) -> bool: return False return True + + +def filter_excinfo_traceback( + tbfilter: TracebackFilter, excinfo: ExceptionInfo[BaseException] +) -> Traceback: + """Filter the exception traceback in ``excinfo`` according to ``tbfilter``.""" + if callable(tbfilter): + return tbfilter(excinfo) + elif tbfilter: + return excinfo.traceback.filter(excinfo) + else: + return excinfo.traceback diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py index 89088576980..555645030fc 100644 --- a/testing/code/test_excinfo.py +++ b/testing/code/test_excinfo.py @@ -1797,6 +1797,9 @@ def test(): rf"FAILED test_excgroup.py::test - {pre_catch}BaseExceptionGroup: Oops \(2.*" ) result.stdout.re_match_lines(match_lines) + # Check for traceback filtering of pytest internals. + result.stdout.no_fnmatch_line("*, line *, in pytest_pyfunc_call") + result.stdout.no_fnmatch_line("*, line *, in pytest_runtest_call") @pytest.mark.skipif( From 33b26e429817935af8eb0202aa1e5ef0476e1cad Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 20 Apr 2025 05:03:23 +0000 Subject: [PATCH 385/445] [automated] Update plugin list (#13385) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 78 +++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 27 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 6690ad5196a..6b5f7c7457a 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =6.0 - :pypi:`pytest-chinesereport` Mar 19, 2025 4 - Beta pytest>=3.5.0 + :pypi:`pytest-chinesereport` Apr 16, 2025 4 - Beta pytest>=3.5.0 :pypi:`pytest-choose` Provide the pytest with the ability to collect use cases based on rules in text files Feb 04, 2024 N/A pytest >=7.0.0 :pypi:`pytest-chunks` Run only a chunk of your test suite Jul 05, 2022 N/A pytest (>=6.0.0) :pypi:`pytest_cid` Compare data structures containing matching CIDs of different versions and encoding Sep 01, 2023 4 - Beta pytest >= 5.0, < 7.0 @@ -462,6 +462,7 @@ This list contains 1620 plugins. :pypi:`pytest-drop-dup-tests` A Pytest plugin to drop duplicated tests during collection Mar 04, 2024 5 - Production/Stable pytest >=7 :pypi:`pytest-dryci` Test caching plugin for pytest Sep 27, 2024 4 - Beta N/A :pypi:`pytest-dryrun` A Pytest plugin to ignore tests during collection without reporting them in the test summary. Jan 19, 2025 5 - Production/Stable pytest<9,>=7.40 + :pypi:`pytest-dsl` A DSL testing framework based on pytest Apr 14, 2025 N/A pytest>=7.0.0 :pypi:`pytest-dummynet` A py.test plugin providing access to a dummynet. Dec 15, 2021 5 - Production/Stable pytest :pypi:`pytest-dump2json` A pytest plugin for dumping test results to json. Jun 29, 2015 N/A N/A :pypi:`pytest-duration-insights` Jul 15, 2024 N/A N/A @@ -480,6 +481,7 @@ This list contains 1620 plugins. :pypi:`pytest-ekstazi` Pytest plugin to select test using Ekstazi algorithm Sep 10, 2022 N/A pytest :pypi:`pytest-elasticsearch` Elasticsearch fixtures and fixture factories for Pytest. Dec 03, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-elasticsearch-test` Elasticsearch fixtures and fixture factories for Pytest. Aug 21, 2024 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-elbase` Elbase pytest plugin Apr 15, 2025 N/A N/A :pypi:`pytest-elements` Tool to help automate user interfaces Jan 13, 2021 N/A pytest (>=5.4,<6.0) :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 @@ -645,7 +647,7 @@ This list contains 1620 plugins. :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Apr 08, 2025 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Apr 16, 2025 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -689,7 +691,7 @@ This list contains 1620 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Apr 05, 2025 3 - Alpha pytest==8.3.5 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Apr 13, 2025 3 - Alpha pytest==8.3.5 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -764,7 +766,7 @@ This list contains 1620 plugins. :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A :pypi:`pytest-ipynb2` Pytest plugin to run tests in Jupyter Notebooks Mar 09, 2025 N/A pytest - :pypi:`pytest-ipywidgets` Feb 18, 2025 N/A pytest + :pypi:`pytest-ipywidgets` Apr 15, 2025 N/A pytest :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Jan 16, 2025 4 - Beta pytest :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Feb 24, 2025 4 - Beta pytest>=5 :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) @@ -778,7 +780,7 @@ This list contains 1620 plugins. :pypi:`pytest-jelastic` Pytest plugin defining the necessary command-line options to pass to pytests testing a Jelastic environment. Nov 16, 2022 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-jest` A custom jest-pytest oriented Pytest reporter May 22, 2018 4 - Beta pytest (>=3.3.2) :pypi:`pytest-jinja` A plugin to generate customizable jinja-based HTML reports in pytest Oct 04, 2022 3 - Alpha pytest (>=6.2.5,<7.0.0) - :pypi:`pytest-jira` py.test JIRA integration plugin, using markers Apr 30, 2024 3 - Alpha N/A + :pypi:`pytest-jira` py.test JIRA integration plugin, using markers Apr 15, 2025 3 - Alpha N/A :pypi:`pytest-jira-xfail` Plugin skips (xfail) tests if unresolved Jira issue(s) linked Jul 09, 2024 N/A pytest>=7.2.0 :pypi:`pytest-jira-xray` pytest plugin to integrate tests with JIRA XRAY Oct 27, 2024 4 - Beta pytest>=6.2.4 :pypi:`pytest-job-selection` A pytest plugin for load balancing test suites Jan 30, 2023 4 - Beta pytest (>=3.5.0) @@ -827,6 +829,7 @@ This list contains 1620 plugins. :pypi:`pytest-leaping` A simple plugin to use with pytest Mar 27, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-leo-interface` Pytest extension tool for leo projects. Mar 19, 2025 N/A N/A :pypi:`pytest-level` Select tests of a given level or lower Oct 21, 2019 N/A pytest + :pypi:`pytest-lf-skip` A pytest plugin which makes \`--last-failed\` skip instead of deselect tests. Apr 16, 2025 N/A pytest>=8.3.5 :pypi:`pytest-libfaketime` A python-libfaketime plugin for pytest Apr 12, 2024 4 - Beta pytest>=3.0.0 :pypi:`pytest-libiio` A pytest plugin to manage interfacing with libiio contexts Oct 01, 2024 4 - Beta N/A :pypi:`pytest-libnotify` Pytest plugin that shows notifications about the test run Apr 02, 2021 3 - Alpha pytest @@ -1007,7 +1010,7 @@ This list contains 1620 plugins. :pypi:`pytest-opentmi` pytest plugin for publish results to opentmi Mar 22, 2025 5 - Production/Stable pytest>=5.0 :pypi:`pytest-operator` Fixtures for Operators Sep 28, 2022 N/A pytest :pypi:`pytest-optional` include/exclude values of fixtures in pytest Oct 07, 2015 N/A N/A - :pypi:`pytest-optional-tests` Easy declaration of optional tests (i.e., that are not run by default) Jul 09, 2019 4 - Beta pytest (>=4.5.0) + :pypi:`pytest-optional-tests` Easy declaration of optional tests (i.e., that are not run by default) Apr 15, 2025 4 - Beta pytest; extra == "dev" :pypi:`pytest-orchestration` A pytest plugin for orchestrating tests Jul 18, 2019 N/A N/A :pypi:`pytest-order` pytest plugin to run your tests in a specific order Aug 22, 2024 5 - Production/Stable pytest>=5.0; python_version < "3.10" :pypi:`pytest-ordered` Declare the order in which tests should run in your pytest.ini Oct 07, 2024 N/A pytest>=6.2.0 @@ -1079,7 +1082,7 @@ This list contains 1620 plugins. :pypi:`pytest-playwrights` A pytest wrapper with fixtures for Playwright to automate web browsers Dec 02, 2021 N/A N/A :pypi:`pytest-playwright-snapshot` A pytest wrapper for snapshot testing with playwright Aug 19, 2021 N/A N/A :pypi:`pytest-playwright-visual` A pytest fixture for visual testing with Playwright Apr 28, 2022 N/A N/A - :pypi:`pytest-playwright-visual-snapshot` Easy pytest visual regression testing using playwright Mar 25, 2025 N/A N/A + :pypi:`pytest-playwright-visual-snapshot` Easy pytest visual regression testing using playwright Apr 15, 2025 N/A N/A :pypi:`pytest-plone` Pytest plugin to test Plone addons Mar 27, 2025 3 - Alpha pytest<8.0.0 :pypi:`pytest-plt` Fixtures for quickly making Matplotlib plots in tests Jan 17, 2024 5 - Production/Stable pytest :pypi:`pytest-plugin-helpers` A plugin to help developing and testing other plugins Nov 23, 2019 4 - Beta pytest (>=3.5.0) @@ -1261,7 +1264,7 @@ This list contains 1620 plugins. :pypi:`pytest-rmsis` Sycronise pytest results to Jira RMsis Aug 10, 2022 N/A pytest (>=5.3.5) :pypi:`pytest-rng` Fixtures for seeding tests and making randomness reproducible Aug 08, 2019 5 - Production/Stable pytest :pypi:`pytest-roast` pytest plugin for ROAST configuration override and fixtures Nov 09, 2022 5 - Production/Stable pytest - :pypi:`pytest_robotframework` a pytest plugin that can run both python and robotframework tests while generating robot reports for them Mar 28, 2025 N/A pytest<9,>=7 + :pypi:`pytest_robotframework` a pytest plugin that can run both python and robotframework tests while generating robot reports for them Apr 13, 2025 N/A pytest<9,>=7 :pypi:`pytest-rocketchat` Pytest to Rocket.Chat reporting plugin Apr 18, 2021 5 - Production/Stable N/A :pypi:`pytest-rotest` Pytest integration with rotest Sep 08, 2019 N/A pytest (>=3.5.0) :pypi:`pytest-rpc` Extend py.test for RPC OpenStack testing. Feb 22, 2019 4 - Beta pytest (~=3.6) @@ -1271,7 +1274,7 @@ This list contains 1620 plugins. :pypi:`pytest-ruff` pytest plugin to check ruff requirements. Jul 21, 2024 4 - Beta pytest>=5 :pypi:`pytest-run-changed` Pytest plugin that runs changed tests only Apr 02, 2021 3 - Alpha pytest :pypi:`pytest-runfailed` implement a --failed option for pytest Mar 24, 2016 N/A N/A - :pypi:`pytest-run-parallel` A simple pytest plugin to run tests concurrently Feb 05, 2025 4 - Beta pytest>=6.2.0 + :pypi:`pytest-run-parallel` A simple pytest plugin to run tests concurrently Apr 17, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-run-subprocess` Pytest Plugin for running and testing subprocesses. Nov 12, 2022 5 - Production/Stable pytest :pypi:`pytest-runtime-types` Checks type annotations on runtime while running tests. Feb 09, 2023 N/A pytest :pypi:`pytest-runtime-xfail` Call runtime_xfail() to mark running test as xfail. Aug 26, 2021 N/A pytest>=5.0.0 @@ -1387,7 +1390,7 @@ This list contains 1620 plugins. :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Mar 19, 2025 N/A N/A :pypi:`pytest-splunk-env` pytest fixtures for interaction with Splunk Enterprise and Splunk Cloud Oct 22, 2020 N/A pytest (>=6.1.1,<7.0.0) :pypi:`pytest-sqitch` sqitch for pytest Apr 06, 2020 4 - Beta N/A - :pypi:`pytest-sqlalchemy` pytest plugin with sqlalchemy related fixtures Mar 13, 2018 3 - Alpha N/A + :pypi:`pytest-sqlalchemy` pytest plugin with sqlalchemy related fixtures Apr 19, 2025 3 - Alpha pytest>=8.0 :pypi:`pytest-sqlalchemy-mock` pytest sqlalchemy plugin for mock Aug 10, 2024 3 - Alpha pytest>=7.0.0 :pypi:`pytest-sqlalchemy-session` A pytest plugin for preserving test isolation that use SQLAlchemy. May 19, 2023 4 - Beta pytest (>=7.0) :pypi:`pytest-sql-bigquery` Yet another SQL-testing framework for BigQuery provided by pytest plugin Dec 19, 2019 N/A pytest @@ -1440,7 +1443,7 @@ This list contains 1620 plugins. :pypi:`pytest-tcpclient` A pytest plugin for testing TCP clients Nov 16, 2022 N/A pytest (<8,>=7.1.3) :pypi:`pytest-tdd` run pytest on a python module Aug 18, 2023 4 - Beta N/A :pypi:`pytest-teamcity-logblock` py.test plugin to introduce block structure in teamcity build log, if output is not captured May 15, 2018 4 - Beta N/A - :pypi:`pytest-teardown` Feb 03, 2025 N/A pytest<9.0.0,>=7.4.1 + :pypi:`pytest-teardown` Apr 15, 2025 N/A pytest<9.0.0,>=7.4.1 :pypi:`pytest-telegram` Pytest to Telegram reporting plugin Apr 25, 2024 5 - Production/Stable N/A :pypi:`pytest-telegram-notifier` Telegram notification plugin for Pytest Jun 27, 2023 5 - Production/Stable N/A :pypi:`pytest-tempdir` Predictable and repeatable tempdir support. Oct 11, 2019 4 - Beta pytest (>=2.8.1) @@ -1653,7 +1656,7 @@ This list contains 1620 plugins. :pypi:`pytest-zigzag` Extend py.test for RPC OpenStack testing. Feb 27, 2019 4 - Beta pytest (~=3.6) :pypi:`pytest-zulip` Pytest report plugin for Zulip May 07, 2022 5 - Production/Stable pytest :pypi:`pytest-zy` 接口自动化测试框架 Mar 24, 2024 N/A pytest~=7.2.0 - :pypi:`tursu` 🎬 A pytest plugin that transpiles Gherkin feature files to Python using AST, enforcing typing for ease of use and debugging. Apr 10, 2025 4 - Beta pytest>=8.3.5 + :pypi:`tursu` 🎬 A pytest plugin that transpiles Gherkin feature files to Python using AST, enforcing typing for ease of use and debugging. Apr 17, 2025 4 - Beta pytest>=8.3.5 =============================================== ====================================================================================================================================================================================================================================================================================================================================================================================== ============== ===================== ================================================ .. only:: latex @@ -3137,7 +3140,7 @@ This list contains 1620 plugins. Simple pytest plugin for generating and sending report to messengers. :pypi:`pytest-chinesereport` - *last release*: Mar 19, 2025, + *last release*: Apr 16, 2025, *status*: 4 - Beta, *requires*: pytest>=3.5.0 @@ -4655,6 +4658,13 @@ This list contains 1620 plugins. A Pytest plugin to ignore tests during collection without reporting them in the test summary. + :pypi:`pytest-dsl` + *last release*: Apr 14, 2025, + *status*: N/A, + *requires*: pytest>=7.0.0 + + A DSL testing framework based on pytest + :pypi:`pytest-dummynet` *last release*: Dec 15, 2021, *status*: 5 - Production/Stable, @@ -4781,6 +4791,13 @@ This list contains 1620 plugins. Elasticsearch fixtures and fixture factories for Pytest. + :pypi:`pytest-elbase` + *last release*: Apr 15, 2025, + *status*: N/A, + *requires*: N/A + + Elbase pytest plugin + :pypi:`pytest-elements` *last release*: Jan 13, 2021, *status*: N/A, @@ -5937,7 +5954,7 @@ This list contains 1620 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Apr 08, 2025, + *last release*: Apr 16, 2025, *status*: N/A, *requires*: pytest>=3.6 @@ -6245,7 +6262,7 @@ This list contains 1620 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Apr 05, 2025, + *last release*: Apr 13, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.5 @@ -6770,7 +6787,7 @@ This list contains 1620 plugins. Pytest plugin to run tests in Jupyter Notebooks :pypi:`pytest-ipywidgets` - *last release*: Feb 18, 2025, + *last release*: Apr 15, 2025, *status*: N/A, *requires*: pytest @@ -6868,7 +6885,7 @@ This list contains 1620 plugins. A plugin to generate customizable jinja-based HTML reports in pytest :pypi:`pytest-jira` - *last release*: Apr 30, 2024, + *last release*: Apr 15, 2025, *status*: 3 - Alpha, *requires*: N/A @@ -7210,6 +7227,13 @@ This list contains 1620 plugins. Select tests of a given level or lower + :pypi:`pytest-lf-skip` + *last release*: Apr 16, 2025, + *status*: N/A, + *requires*: pytest>=8.3.5 + + A pytest plugin which makes \`--last-failed\` skip instead of deselect tests. + :pypi:`pytest-libfaketime` *last release*: Apr 12, 2024, *status*: 4 - Beta, @@ -8471,9 +8495,9 @@ This list contains 1620 plugins. include/exclude values of fixtures in pytest :pypi:`pytest-optional-tests` - *last release*: Jul 09, 2019, + *last release*: Apr 15, 2025, *status*: 4 - Beta, - *requires*: pytest (>=4.5.0) + *requires*: pytest; extra == "dev" Easy declaration of optional tests (i.e., that are not run by default) @@ -8975,7 +8999,7 @@ This list contains 1620 plugins. A pytest fixture for visual testing with Playwright :pypi:`pytest-playwright-visual-snapshot` - *last release*: Mar 25, 2025, + *last release*: Apr 15, 2025, *status*: N/A, *requires*: N/A @@ -10249,7 +10273,7 @@ This list contains 1620 plugins. pytest plugin for ROAST configuration override and fixtures :pypi:`pytest_robotframework` - *last release*: Mar 28, 2025, + *last release*: Apr 13, 2025, *status*: N/A, *requires*: pytest<9,>=7 @@ -10319,7 +10343,7 @@ This list contains 1620 plugins. implement a --failed option for pytest :pypi:`pytest-run-parallel` - *last release*: Feb 05, 2025, + *last release*: Apr 17, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -11131,9 +11155,9 @@ This list contains 1620 plugins. sqitch for pytest :pypi:`pytest-sqlalchemy` - *last release*: Mar 13, 2018, + *last release*: Apr 19, 2025, *status*: 3 - Alpha, - *requires*: N/A + *requires*: pytest>=8.0 pytest plugin with sqlalchemy related fixtures @@ -11502,7 +11526,7 @@ This list contains 1620 plugins. py.test plugin to introduce block structure in teamcity build log, if output is not captured :pypi:`pytest-teardown` - *last release*: Feb 03, 2025, + *last release*: Apr 15, 2025, *status*: N/A, *requires*: pytest<9.0.0,>=7.4.1 @@ -12993,7 +13017,7 @@ This list contains 1620 plugins. 接口自动化测试框架 :pypi:`tursu` - *last release*: Apr 10, 2025, + *last release*: Apr 17, 2025, *status*: 4 - Beta, *requires*: pytest>=8.3.5 From ca3a1328075e5acf4e8816d08ae4a1bb0df54889 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 27 Apr 2025 09:05:34 -0300 Subject: [PATCH 386/445] [automated] Update plugin list (#13398) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 148 ++++++++++++++++++------------- 1 file changed, 86 insertions(+), 62 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 6b5f7c7457a..b5b9ac659d0 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =8.2 :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Mar 16, 2025 4 - Beta pytest>=6.2.0 - :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Jul 04, 2024 N/A N/A + :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Apr 26, 2025 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) :pypi:`pytest-async-mongodb` pytest plugin for async MongoDB Oct 18, 2017 5 - Production/Stable pytest (>=2.5.2) :pypi:`pytest-async-sqlalchemy` Database testing fixtures using the SQLAlchemy asyncio API Oct 07, 2021 4 - Beta pytest (>=6.0.0) @@ -162,7 +162,7 @@ This list contains 1623 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Apr 01, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Apr 25, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -339,7 +339,7 @@ This list contains 1623 plugins. :pypi:`pytest-dash` pytest fixtures to run dash applications. Mar 18, 2019 N/A N/A :pypi:`pytest-dashboard` May 30, 2024 N/A pytest<8.0.0,>=7.4.3 :pypi:`pytest-data` Useful functions for managing data for pytest fixtures Nov 01, 2016 5 - Production/Stable N/A - :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Apr 06, 2025 4 - Beta pytest + :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Apr 21, 2025 4 - Beta pytest :pypi:`pytest-databricks` Pytest plugin for remote Databricks notebooks testing Jul 29, 2020 N/A pytest :pypi:`pytest-datadir` pytest plugin for test data directories and files Feb 07, 2025 5 - Production/Stable pytest>=7.0 :pypi:`pytest-datadir-mgr` Manager for test data: downloads, artifact caching, and a tmpdir context. Apr 06, 2023 5 - Production/Stable pytest (>=7.1) @@ -480,21 +480,21 @@ This list contains 1623 plugins. :pypi:`pytest-edit` Edit the source code of a failed test with \`pytest --edit\`. Nov 17, 2024 N/A pytest :pypi:`pytest-ekstazi` Pytest plugin to select test using Ekstazi algorithm Sep 10, 2022 N/A pytest :pypi:`pytest-elasticsearch` Elasticsearch fixtures and fixture factories for Pytest. Dec 03, 2024 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-elasticsearch-test` Elasticsearch fixtures and fixture factories for Pytest. Aug 21, 2024 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-elasticsearch-test` Elasticsearch fixtures and fixture factories for Pytest. Apr 20, 2025 5 - Production/Stable pytest>=7.0 :pypi:`pytest-elbase` Elbase pytest plugin Apr 15, 2025 N/A N/A :pypi:`pytest-elements` Tool to help automate user interfaces Jan 13, 2021 N/A pytest (>=5.4,<6.0) :pypi:`pytest-eliot` An eliot plugin for pytest. Aug 31, 2022 1 - Planning pytest (>=5.4.0) :pypi:`pytest-elk-reporter` A simple plugin to use with pytest Jul 25, 2024 4 - Beta pytest>=3.5.0 :pypi:`pytest-email` Send execution result email Jul 08, 2020 N/A pytest - :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Mar 13, 2025 5 - Production/Stable pytest>=7.0 - :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Mar 13, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Mar 13, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Mar 13, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Mar 13, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Mar 13, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Mar 13, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Mar 13, 2025 5 - Production/Stable N/A - :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Mar 13, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded` A pytest plugin that designed for embedded testing. Apr 22, 2025 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-embedded-arduino` Make pytest-embedded plugin work with Arduino. Apr 22, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-idf` Make pytest-embedded plugin work with ESP-IDF. Apr 22, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-jtag` Make pytest-embedded plugin work with JTAG. Apr 22, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-nuttx` Make pytest-embedded plugin work with NuttX. Apr 22, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-qemu` Make pytest-embedded plugin work with QEMU. Apr 22, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial` Make pytest-embedded plugin work with Serial. Apr 22, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-serial-esp` Make pytest-embedded plugin work with Espressif target boards. Apr 22, 2025 5 - Production/Stable N/A + :pypi:`pytest-embedded-wokwi` Make pytest-embedded plugin work with the Wokwi CLI. Apr 22, 2025 5 - Production/Stable N/A :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) @@ -647,7 +647,7 @@ This list contains 1623 plugins. :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Apr 16, 2025 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Apr 24, 2025 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -691,7 +691,7 @@ This list contains 1623 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Apr 13, 2025 3 - Alpha pytest==8.3.5 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Apr 26, 2025 3 - Alpha pytest==8.3.5 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -722,7 +722,7 @@ This list contains 1623 plugins. :pypi:`pytest-hue` Visualise PyTest status via your Phillips Hue lights May 09, 2019 N/A N/A :pypi:`pytest-hylang` Pytest plugin to allow running tests written in hylang Mar 28, 2021 N/A pytest :pypi:`pytest-hypo-25` help hypo module for pytest Jan 12, 2020 3 - Alpha N/A - :pypi:`pytest-iam` A fully functional OAUTH2 / OpenID Connect (OIDC) server to be used in your testsuite Apr 04, 2025 4 - Beta pytest>=7.0.0 + :pypi:`pytest-iam` A fully functional OAUTH2 / OpenID Connect (OIDC) / SCIM server to be used in your testsuite Apr 24, 2025 4 - Beta pytest>=7.0.0 :pypi:`pytest-ibutsu` A plugin to sent pytest results to an Ibutsu server Feb 06, 2025 4 - Beta pytest>=7.1 :pypi:`pytest-icdiff` use icdiff for better error messages in pytest assertions Dec 05, 2023 4 - Beta pytest :pypi:`pytest-idapro` A pytest plugin for idapython. Allows a pytest setup to run tests outside and inside IDA in an automated manner by runnig pytest inside IDA and by mocking idapython api Nov 03, 2018 N/A N/A @@ -748,6 +748,7 @@ This list contains 1623 plugins. :pypi:`pytest-inmanta` A py.test plugin providing fixtures to simplify inmanta modules testing. Apr 09, 2025 5 - Production/Stable pytest :pypi:`pytest-inmanta-extensions` Inmanta tests package Apr 10, 2025 5 - Production/Stable N/A :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Apr 09, 2025 5 - Production/Stable N/A + :pypi:`pytest-inmanta-srlinux` Pytest library to facilitate end to end testing of inmanta projects Apr 22, 2025 3 - Alpha N/A :pypi:`pytest-inmanta-yang` Common fixtures used in inmanta yang related modules Feb 22, 2024 4 - Beta pytest :pypi:`pytest-Inomaly` A simple image diff plugin for pytest Feb 13, 2018 4 - Beta N/A :pypi:`pytest-in-robotframework` The extension enables easy execution of pytest tests within the Robot Framework environment. Nov 23, 2024 N/A pytest @@ -766,8 +767,8 @@ This list contains 1623 plugins. :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A :pypi:`pytest-ipynb2` Pytest plugin to run tests in Jupyter Notebooks Mar 09, 2025 N/A pytest - :pypi:`pytest-ipywidgets` Apr 15, 2025 N/A pytest - :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Jan 16, 2025 4 - Beta pytest + :pypi:`pytest-ipywidgets` Apr 25, 2025 N/A pytest + :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Apr 22, 2025 4 - Beta pytest :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Feb 24, 2025 4 - Beta pytest>=5 :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-it` Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it. Jan 29, 2024 4 - Beta N/A @@ -792,8 +793,9 @@ This list contains 1623 plugins. :pypi:`pytest-jsonlint` UNKNOWN Aug 04, 2016 N/A N/A :pypi:`pytest-json-report` A pytest plugin to report test results as JSON files Mar 15, 2022 4 - Beta pytest (>=3.8.0) :pypi:`pytest-json-report-wip` A pytest plugin to report test results as JSON files Oct 28, 2023 4 - Beta pytest >=3.8.0 - :pypi:`pytest-jsonschema` A pytest plugin to perform JSONSchema validations Mar 27, 2024 4 - Beta pytest>=6.2.0 + :pypi:`pytest-jsonschema` A pytest plugin to perform JSONSchema validations Apr 20, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-jtr` pytest plugin supporting json test report output Jul 21, 2024 N/A pytest<8.0.0,>=7.1.2 + :pypi:`pytest-jubilant` Add your description here Apr 25, 2025 N/A pytest>=8.3.5 :pypi:`pytest-junit-xray-xml` Export test results in an augmented JUnit format for usage with Xray () Jan 01, 2025 4 - Beta pytest :pypi:`pytest-jupyter` A pytest plugin for testing Jupyter libraries and extensions. Apr 04, 2024 4 - Beta pytest>=7.0 :pypi:`pytest-jupyterhub` A reusable JupyterHub pytest plugin Apr 25, 2023 5 - Production/Stable pytest @@ -829,7 +831,7 @@ This list contains 1623 plugins. :pypi:`pytest-leaping` A simple plugin to use with pytest Mar 27, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-leo-interface` Pytest extension tool for leo projects. Mar 19, 2025 N/A N/A :pypi:`pytest-level` Select tests of a given level or lower Oct 21, 2019 N/A pytest - :pypi:`pytest-lf-skip` A pytest plugin which makes \`--last-failed\` skip instead of deselect tests. Apr 16, 2025 N/A pytest>=8.3.5 + :pypi:`pytest-lf-skip` A pytest plugin which makes \`--last-failed\` skip instead of deselect tests. Apr 25, 2025 N/A pytest>=8.3.5 :pypi:`pytest-libfaketime` A python-libfaketime plugin for pytest Apr 12, 2024 4 - Beta pytest>=3.0.0 :pypi:`pytest-libiio` A pytest plugin to manage interfacing with libiio contexts Oct 01, 2024 4 - Beta N/A :pypi:`pytest-libnotify` Pytest plugin that shows notifications about the test run Apr 02, 2021 3 - Alpha pytest @@ -904,7 +906,7 @@ This list contains 1623 plugins. :pypi:`pytest-metrics` Custom metrics report for pytest Apr 04, 2020 N/A pytest :pypi:`pytest-mh` Pytest multihost plugin Mar 06, 2025 N/A pytest :pypi:`pytest-mimesis` Mimesis integration with the pytest test runner Mar 21, 2020 5 - Production/Stable pytest (>=4.2) - :pypi:`pytest-mimic` Easily record function calls while testing Apr 11, 2025 4 - Beta pytest>=6.2.0 + :pypi:`pytest-mimic` Easily record function calls while testing Apr 24, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-minecraft` A pytest plugin for running tests against Minecraft releases Apr 06, 2022 N/A pytest (>=6.0.1) :pypi:`pytest-mini` A plugin to test mp Feb 06, 2023 N/A pytest (>=7.2.0,<8.0.0) :pypi:`pytest-minio-mock` A pytest plugin for mocking Minio S3 interactions Aug 27, 2024 N/A pytest>=5.0.0 @@ -1006,7 +1008,7 @@ This list contains 1623 plugins. :pypi:`pytest-oot` Run object-oriented tests in a simple format Sep 18, 2016 4 - Beta N/A :pypi:`pytest-openfiles` Pytest plugin for detecting inadvertent open file handles Jun 05, 2024 3 - Alpha pytest>=4.6 :pypi:`pytest-open-html` Auto-open HTML reports after pytest runs Mar 31, 2025 N/A pytest>=6.0 - :pypi:`pytest-opentelemetry` A pytest plugin for instrumenting test runs via OpenTelemetry Nov 22, 2024 N/A pytest + :pypi:`pytest-opentelemetry` A pytest plugin for instrumenting test runs via OpenTelemetry Apr 25, 2025 N/A pytest :pypi:`pytest-opentmi` pytest plugin for publish results to opentmi Mar 22, 2025 5 - Production/Stable pytest>=5.0 :pypi:`pytest-operator` Fixtures for Operators Sep 28, 2022 N/A pytest :pypi:`pytest-optional` include/exclude values of fixtures in pytest Oct 07, 2015 N/A N/A @@ -1018,7 +1020,7 @@ This list contains 1623 plugins. :pypi:`pytest-order-modify` 新增run_marker 来自定义用例的执行顺序 Nov 04, 2022 N/A N/A :pypi:`pytest-osxnotify` OS X notifications for py.test results. May 15, 2015 N/A N/A :pypi:`pytest-ot` A pytest plugin for instrumenting test runs via OpenTelemetry Mar 21, 2024 N/A pytest; extra == "dev" - :pypi:`pytest-otel` OpenTelemetry plugin for Pytest Feb 10, 2025 N/A pytest==8.3.4 + :pypi:`pytest-otel` OpenTelemetry plugin for Pytest Apr 24, 2025 N/A pytest==8.3.5 :pypi:`pytest-override-env-var` Pytest mark to override a value of an environment variable. Feb 25, 2023 N/A N/A :pypi:`pytest-owner` Add owner mark for tests Aug 19, 2024 N/A pytest :pypi:`pytest-pact` A simple plugin to use with pytest Jan 07, 2019 4 - Beta N/A @@ -1184,7 +1186,7 @@ This list contains 1623 plugins. :pypi:`pytest-readme` Test your README.md file Sep 02, 2022 5 - Production/Stable N/A :pypi:`pytest-reana` Pytest fixtures for REANA. Sep 04, 2024 3 - Alpha N/A :pypi:`pytest-recorder` Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. Mar 31, 2025 N/A N/A - :pypi:`pytest-recording` A pytest plugin that allows you recording of network interactions via VCR.py Jul 09, 2024 4 - Beta pytest>=3.5.0 + :pypi:`pytest-recording` A pytest plugin powered by VCR.py to record and replay HTTP traffic Apr 24, 2025 4 - Beta pytest>=3.5.0 :pypi:`pytest-recordings` Provides pytest plugins for reporting request/response traffic, screenshots, and more to ReportPortal Aug 13, 2020 N/A N/A :pypi:`pytest-record-video` 用例执行过程中录制视频 Oct 31, 2024 N/A N/A :pypi:`pytest-redis` Redis fixtures and fixture factories for Pytest. Nov 27, 2024 5 - Production/Stable pytest>=6.2 @@ -1211,7 +1213,7 @@ This list contains 1623 plugins. :pypi:`pytest-report` Creates json report that is compatible with atom.io's linter message format May 11, 2016 4 - Beta N/A :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Oct 11, 2024 4 - Beta N/A - :pypi:`pytest-reporter-html-dots` A basic HTML report for pytest using Jinja2 template engine. Jan 22, 2023 N/A N/A + :pypi:`pytest-reporter-html-dots` A basic HTML report for pytest using Jinja2 template engine. Apr 26, 2025 N/A N/A :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots, webpage sources and attachments. Apr 04, 2025 N/A pytest>=8.0.0 :pypi:`pytest-reportinfra` Pytest plugin for reportinfra Aug 11, 2019 3 - Alpha N/A :pypi:`pytest-reporting` A plugin to report summarized results in a table format Oct 25, 2019 4 - Beta pytest (>=3.5.0) @@ -1274,7 +1276,7 @@ This list contains 1623 plugins. :pypi:`pytest-ruff` pytest plugin to check ruff requirements. Jul 21, 2024 4 - Beta pytest>=5 :pypi:`pytest-run-changed` Pytest plugin that runs changed tests only Apr 02, 2021 3 - Alpha pytest :pypi:`pytest-runfailed` implement a --failed option for pytest Mar 24, 2016 N/A N/A - :pypi:`pytest-run-parallel` A simple pytest plugin to run tests concurrently Apr 17, 2025 4 - Beta pytest>=6.2.0 + :pypi:`pytest-run-parallel` A simple pytest plugin to run tests concurrently Apr 22, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-run-subprocess` Pytest Plugin for running and testing subprocesses. Nov 12, 2022 5 - Production/Stable pytest :pypi:`pytest-runtime-types` Checks type annotations on runtime while running tests. Feb 09, 2023 N/A pytest :pypi:`pytest-runtime-xfail` Call runtime_xfail() to mark running test as xfail. Aug 26, 2021 N/A pytest>=5.0.0 @@ -1291,7 +1293,7 @@ This list contains 1623 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Apr 10, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Apr 25, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1303,7 +1305,7 @@ This list contains 1623 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Apr 10, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Apr 25, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1613,6 +1615,7 @@ This list contains 1623 plugins. :pypi:`pytest-xdist` pytest xdist plugin for distributed testing, most importantly across multiple CPUs Apr 28, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-xdist-debug-for-graingert` pytest xdist plugin for distributed testing and loop-on-failing modes Jul 24, 2019 5 - Production/Stable pytest (>=4.4.0) :pypi:`pytest-xdist-forked` forked from pytest-xdist Feb 10, 2020 5 - Production/Stable pytest (>=4.4.0) + :pypi:`pytest-xdist-lock` Extension for pytest-xdist adding test and resource group locks for local and distributed runs Apr 26, 2025 N/A pytest>=6.0 :pypi:`pytest-xdist-tracker` pytest plugin helps to reproduce failures for particular xdist node Nov 18, 2021 3 - Alpha pytest (>=3.5.1) :pypi:`pytest-xdist-worker-stats` A pytest plugin to list worker statistics after a xdist run. Mar 15, 2025 4 - Beta pytest>=7.0.0 :pypi:`pytest-xdocker` Pytest fixture to run docker across test runs. Mar 23, 2025 N/A pytest<8.0.0,>=7.4.2 @@ -1656,7 +1659,7 @@ This list contains 1623 plugins. :pypi:`pytest-zigzag` Extend py.test for RPC OpenStack testing. Feb 27, 2019 4 - Beta pytest (~=3.6) :pypi:`pytest-zulip` Pytest report plugin for Zulip May 07, 2022 5 - Production/Stable pytest :pypi:`pytest-zy` 接口自动化测试框架 Mar 24, 2024 N/A pytest~=7.2.0 - :pypi:`tursu` 🎬 A pytest plugin that transpiles Gherkin feature files to Python using AST, enforcing typing for ease of use and debugging. Apr 17, 2025 4 - Beta pytest>=8.3.5 + :pypi:`tursu` 🎬 A pytest plugin that transpiles Gherkin feature files to Python using AST, enforcing typing for ease of use and debugging. Apr 25, 2025 4 - Beta pytest>=8.3.5 =============================================== ====================================================================================================================================================================================================================================================================================================================================================================================== ============== ===================== ================================================ .. only:: latex @@ -2265,7 +2268,7 @@ This list contains 1623 plugins. Pytest plugin to execute python async tests concurrently. :pypi:`pytest-asyncio-cooperative` - *last release*: Jul 04, 2024, + *last release*: Apr 26, 2025, *status*: N/A, *requires*: N/A @@ -2559,7 +2562,7 @@ This list contains 1623 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Apr 01, 2025, + *last release*: Apr 25, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -3798,7 +3801,7 @@ This list contains 1623 plugins. Useful functions for managing data for pytest fixtures :pypi:`pytest-databases` - *last release*: Apr 06, 2025, + *last release*: Apr 21, 2025, *status*: 4 - Beta, *requires*: pytest @@ -4785,7 +4788,7 @@ This list contains 1623 plugins. Elasticsearch fixtures and fixture factories for Pytest. :pypi:`pytest-elasticsearch-test` - *last release*: Aug 21, 2024, + *last release*: Apr 20, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 @@ -4827,63 +4830,63 @@ This list contains 1623 plugins. Send execution result email :pypi:`pytest-embedded` - *last release*: Mar 13, 2025, + *last release*: Apr 22, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 A pytest plugin that designed for embedded testing. :pypi:`pytest-embedded-arduino` - *last release*: Mar 13, 2025, + *last release*: Apr 22, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Arduino. :pypi:`pytest-embedded-idf` - *last release*: Mar 13, 2025, + *last release*: Apr 22, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with ESP-IDF. :pypi:`pytest-embedded-jtag` - *last release*: Mar 13, 2025, + *last release*: Apr 22, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with JTAG. :pypi:`pytest-embedded-nuttx` - *last release*: Mar 13, 2025, + *last release*: Apr 22, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with NuttX. :pypi:`pytest-embedded-qemu` - *last release*: Mar 13, 2025, + *last release*: Apr 22, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with QEMU. :pypi:`pytest-embedded-serial` - *last release*: Mar 13, 2025, + *last release*: Apr 22, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Serial. :pypi:`pytest-embedded-serial-esp` - *last release*: Mar 13, 2025, + *last release*: Apr 22, 2025, *status*: 5 - Production/Stable, *requires*: N/A Make pytest-embedded plugin work with Espressif target boards. :pypi:`pytest-embedded-wokwi` - *last release*: Mar 13, 2025, + *last release*: Apr 22, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -5954,7 +5957,7 @@ This list contains 1623 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Apr 16, 2025, + *last release*: Apr 24, 2025, *status*: N/A, *requires*: pytest>=3.6 @@ -6262,7 +6265,7 @@ This list contains 1623 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Apr 13, 2025, + *last release*: Apr 26, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.5 @@ -6479,11 +6482,11 @@ This list contains 1623 plugins. help hypo module for pytest :pypi:`pytest-iam` - *last release*: Apr 04, 2025, + *last release*: Apr 24, 2025, *status*: 4 - Beta, *requires*: pytest>=7.0.0 - A fully functional OAUTH2 / OpenID Connect (OIDC) server to be used in your testsuite + A fully functional OAUTH2 / OpenID Connect (OIDC) / SCIM server to be used in your testsuite :pypi:`pytest-ibutsu` *last release*: Feb 06, 2025, @@ -6660,6 +6663,13 @@ This list contains 1623 plugins. Common fixtures for inmanta LSM related modules + :pypi:`pytest-inmanta-srlinux` + *last release*: Apr 22, 2025, + *status*: 3 - Alpha, + *requires*: N/A + + Pytest library to facilitate end to end testing of inmanta projects + :pypi:`pytest-inmanta-yang` *last release*: Feb 22, 2024, *status*: 4 - Beta, @@ -6787,14 +6797,14 @@ This list contains 1623 plugins. Pytest plugin to run tests in Jupyter Notebooks :pypi:`pytest-ipywidgets` - *last release*: Apr 15, 2025, + *last release*: Apr 25, 2025, *status*: N/A, *requires*: pytest :pypi:`pytest-isolate` - *last release*: Jan 16, 2025, + *last release*: Apr 22, 2025, *status*: 4 - Beta, *requires*: pytest @@ -6969,7 +6979,7 @@ This list contains 1623 plugins. A pytest plugin to report test results as JSON files :pypi:`pytest-jsonschema` - *last release*: Mar 27, 2024, + *last release*: Apr 20, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -6982,6 +6992,13 @@ This list contains 1623 plugins. pytest plugin supporting json test report output + :pypi:`pytest-jubilant` + *last release*: Apr 25, 2025, + *status*: N/A, + *requires*: pytest>=8.3.5 + + Add your description here + :pypi:`pytest-junit-xray-xml` *last release*: Jan 01, 2025, *status*: 4 - Beta, @@ -7228,7 +7245,7 @@ This list contains 1623 plugins. Select tests of a given level or lower :pypi:`pytest-lf-skip` - *last release*: Apr 16, 2025, + *last release*: Apr 25, 2025, *status*: N/A, *requires*: pytest>=8.3.5 @@ -7753,7 +7770,7 @@ This list contains 1623 plugins. Mimesis integration with the pytest test runner :pypi:`pytest-mimic` - *last release*: Apr 11, 2025, + *last release*: Apr 24, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -8467,7 +8484,7 @@ This list contains 1623 plugins. Auto-open HTML reports after pytest runs :pypi:`pytest-opentelemetry` - *last release*: Nov 22, 2024, + *last release*: Apr 25, 2025, *status*: N/A, *requires*: pytest @@ -8551,9 +8568,9 @@ This list contains 1623 plugins. A pytest plugin for instrumenting test runs via OpenTelemetry :pypi:`pytest-otel` - *last release*: Feb 10, 2025, + *last release*: Apr 24, 2025, *status*: N/A, - *requires*: pytest==8.3.4 + *requires*: pytest==8.3.5 OpenTelemetry plugin for Pytest @@ -9713,11 +9730,11 @@ This list contains 1623 plugins. Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. :pypi:`pytest-recording` - *last release*: Jul 09, 2024, + *last release*: Apr 24, 2025, *status*: 4 - Beta, *requires*: pytest>=3.5.0 - A pytest plugin that allows you recording of network interactions via VCR.py + A pytest plugin powered by VCR.py to record and replay HTTP traffic :pypi:`pytest-recordings` *last release*: Aug 13, 2020, @@ -9902,7 +9919,7 @@ This list contains 1623 plugins. A basic HTML report template for Pytest :pypi:`pytest-reporter-html-dots` - *last release*: Jan 22, 2023, + *last release*: Apr 26, 2025, *status*: N/A, *requires*: N/A @@ -10343,7 +10360,7 @@ This list contains 1623 plugins. implement a --failed option for pytest :pypi:`pytest-run-parallel` - *last release*: Apr 17, 2025, + *last release*: Apr 22, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -10462,7 +10479,7 @@ This list contains 1623 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Apr 10, 2025, + *last release*: Apr 25, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10546,7 +10563,7 @@ This list contains 1623 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Apr 10, 2025, + *last release*: Apr 25, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -12715,6 +12732,13 @@ This list contains 1623 plugins. forked from pytest-xdist + :pypi:`pytest-xdist-lock` + *last release*: Apr 26, 2025, + *status*: N/A, + *requires*: pytest>=6.0 + + Extension for pytest-xdist adding test and resource group locks for local and distributed runs + :pypi:`pytest-xdist-tracker` *last release*: Nov 18, 2021, *status*: 3 - Alpha, @@ -13017,7 +13041,7 @@ This list contains 1623 plugins. 接口自动化测试框架 :pypi:`tursu` - *last release*: Apr 17, 2025, + *last release*: Apr 25, 2025, *status*: 4 - Beta, *requires*: pytest>=8.3.5 From 8173aa812253aa263b43cd52c80d605470d0c13f Mon Sep 17 00:00:00 2001 From: Deysha Rivera <50204868+rivtechprojects@users.noreply.github.com> Date: Sun, 27 Apr 2025 08:19:55 -0400 Subject: [PATCH 387/445] Replace explicit time() calls with _pytest.timing (#13394) Fix #13384 --------- Co-authored-by: Bruno Oliveira --- AUTHORS | 1 + changelog/13384.bugfix.rst | 1 + src/_pytest/junitxml.py | 5 +++-- src/_pytest/pytester.py | 8 ++++---- src/_pytest/terminal.py | 8 ++++---- testing/_py/test_local.py | 8 ++++---- testing/test_pytester.py | 6 +++--- 7 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 changelog/13384.bugfix.rst diff --git a/AUTHORS b/AUTHORS index e19a0ae5871..7f742fb4083 100644 --- a/AUTHORS +++ b/AUTHORS @@ -130,6 +130,7 @@ Daw-Ran Liou Debi Mishra Denis Kirisov Denivy Braiam Rück +Deysha Rivera Dheeraj C K Dhiren Serai Diego Russo diff --git a/changelog/13384.bugfix.rst b/changelog/13384.bugfix.rst new file mode 100644 index 00000000000..e93d01dcab0 --- /dev/null +++ b/changelog/13384.bugfix.rst @@ -0,0 +1 @@ +Fixed an issue where pytest could report negative durations. diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py index d129cd295e7..06cab961ef5 100644 --- a/src/_pytest/junitxml.py +++ b/src/_pytest/junitxml.py @@ -637,6 +637,7 @@ def pytest_internalerror(self, excrepr: ExceptionRepr) -> None: def pytest_sessionstart(self) -> None: self.suite_start_time = timing.time() + self.suite_start_perf = timing.perf_counter() def pytest_sessionfinish(self) -> None: dirname = os.path.dirname(os.path.abspath(self.logfile)) @@ -644,8 +645,8 @@ def pytest_sessionfinish(self) -> None: os.makedirs(dirname, exist_ok=True) with open(self.logfile, "w", encoding="utf-8") as logfile: - suite_stop_time = timing.time() - suite_time_delta = suite_stop_time - self.suite_start_time + suite_stop_perf = timing.perf_counter() + suite_time_delta = suite_stop_perf - self.suite_start_perf numtests = ( self.stats["passed"] diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 59839562031..bb5f6a5787e 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -1150,7 +1150,7 @@ def runpytest_inprocess( if syspathinsert: self.syspathinsert() - now = timing.time() + now = timing.perf_counter() capture = _get_multicapture("sys") capture.start_capturing() try: @@ -1180,7 +1180,7 @@ class reprec: # type: ignore assert reprec.ret is not None res = RunResult( - reprec.ret, out.splitlines(), err.splitlines(), timing.time() - now + reprec.ret, out.splitlines(), err.splitlines(), timing.perf_counter() - now ) res.reprec = reprec # type: ignore return res @@ -1408,7 +1408,7 @@ def run( print(" in:", Path.cwd()) with p1.open("w", encoding="utf8") as f1, p2.open("w", encoding="utf8") as f2: - now = timing.time() + now = timing.perf_counter() popen = self.popen( cmdargs, stdin=stdin, @@ -1445,7 +1445,7 @@ def handle_timeout() -> None: with contextlib.suppress(ValueError): ret = ExitCode(ret) - return RunResult(ret, out, err, timing.time() - now) + return RunResult(ret, out, err, timing.perf_counter() - now) def _dump_lines(self, lines, fp): try: diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 3297c38e848..8415912e9ac 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -769,7 +769,7 @@ def pytest_collection(self) -> None: if self.isatty: if self.config.option.verbose >= 0: self.write("collecting ... ", flush=True, bold=True) - self._collect_report_last_write = timing.time() + self._collect_report_last_write = timing.perf_counter() elif self.config.option.verbose >= 1: self.write("collecting ... ", flush=True, bold=True) @@ -789,7 +789,7 @@ def report_collect(self, final: bool = False) -> None: if not final: # Only write "collecting" report every 0.5s. - t = timing.time() + t = timing.perf_counter() if ( self._collect_report_last_write is not None and self._collect_report_last_write > t - REPORT_COLLECTING_RESOLUTION @@ -823,7 +823,7 @@ def report_collect(self, final: bool = False) -> None: @hookimpl(trylast=True) def pytest_sessionstart(self, session: Session) -> None: self._session = session - self._sessionstarttime = timing.time() + self._sessionstarttime = timing.perf_counter() if not self.showheader: return self.write_sep("=", "test session starts", bold=True) @@ -1202,7 +1202,7 @@ def summary_stats(self) -> None: if self.verbosity < -1: return - session_duration = timing.time() - self._sessionstarttime + session_duration = timing.perf_counter() - self._sessionstarttime (parts, main_color) = self.build_summary_stats_line() line_parts = [] diff --git a/testing/_py/test_local.py b/testing/_py/test_local.py index 03a828c64f0..e4b011a9727 100644 --- a/testing/_py/test_local.py +++ b/testing/_py/test_local.py @@ -12,6 +12,7 @@ from py import error from py.path import local +import _pytest.timing import pytest @@ -738,7 +739,6 @@ def test_dump(self, tmpdir, bin): def test_setmtime(self): import tempfile - import time try: fd, name = tempfile.mkstemp() @@ -747,7 +747,7 @@ def test_setmtime(self): name = tempfile.mktemp() open(name, "w").close() try: - mtime = int(time.time()) - 100 + mtime = int(_pytest.timing.time()) - 100 path = local(name) assert path.mtime() != mtime path.setmtime(mtime) @@ -1405,7 +1405,7 @@ def test_atime(self, tmpdir): import time path = tmpdir.ensure("samplefile") - now = time.time() + now = _pytest.timing.perf_counter() atime1 = path.atime() # we could wait here but timer resolution is very # system dependent @@ -1413,7 +1413,7 @@ def test_atime(self, tmpdir): time.sleep(ATIME_RESOLUTION) atime2 = path.atime() time.sleep(ATIME_RESOLUTION) - duration = time.time() - now + duration = _pytest.timing.perf_counter() - now assert (atime2 - atime1) <= duration def test_commondir(self, path1): diff --git a/testing/test_pytester.py b/testing/test_pytester.py index 87714b4708f..555d73f9eaa 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -4,7 +4,6 @@ import os import subprocess import sys -import time from types import ModuleType from _pytest.config import ExitCode @@ -16,6 +15,7 @@ from _pytest.pytester import Pytester from _pytest.pytester import SysModulesSnapshot from _pytest.pytester import SysPathsSnapshot +import _pytest.timing import pytest @@ -451,9 +451,9 @@ def test_pytester_run_with_timeout(pytester: Pytester) -> None: timeout = 120 - start = time.time() + start = _pytest.timing.perf_counter() result = pytester.runpytest_subprocess(testfile, timeout=timeout) - end = time.time() + end = _pytest.timing.perf_counter() duration = end - start assert result.ret == ExitCode.OK From 20c51f70c99ecaa4745d622a69bbe93fbf59ad16 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 29 Apr 2025 08:00:08 -0300 Subject: [PATCH 388/445] Add `Instant` class to conveniently track elapsed and start/end times (#13397) Throughout the codebase we often need to track elapsed times, using a performance clock, and also start/end times that given seconds since epoch (via `time.time()`). `Instant` encapsulates both functionalities to simplify the code and ensure we are using the correct functions from `_pytest.timing`, which we can mock in tests for reliability. --- src/_pytest/junitxml.py | 14 ++++--------- src/_pytest/pytester.py | 8 ++++---- src/_pytest/runner.py | 14 +++++-------- src/_pytest/terminal.py | 18 ++++++++--------- src/_pytest/timing.py | 42 +++++++++++++++++++++++++++++++++++++++ testing/_py/test_local.py | 9 +++++---- testing/test_pytester.py | 7 +++---- 7 files changed, 71 insertions(+), 41 deletions(-) diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py index 06cab961ef5..ec9922ee7bd 100644 --- a/src/_pytest/junitxml.py +++ b/src/_pytest/junitxml.py @@ -11,8 +11,6 @@ from __future__ import annotations from collections.abc import Callable -from datetime import datetime -from datetime import timezone import functools import os import platform @@ -636,8 +634,7 @@ def pytest_internalerror(self, excrepr: ExceptionRepr) -> None: reporter._add_simple("error", "internal error", str(excrepr)) def pytest_sessionstart(self) -> None: - self.suite_start_time = timing.time() - self.suite_start_perf = timing.perf_counter() + self.suite_start = timing.Instant() def pytest_sessionfinish(self) -> None: dirname = os.path.dirname(os.path.abspath(self.logfile)) @@ -645,8 +642,7 @@ def pytest_sessionfinish(self) -> None: os.makedirs(dirname, exist_ok=True) with open(self.logfile, "w", encoding="utf-8") as logfile: - suite_stop_perf = timing.perf_counter() - suite_time_delta = suite_stop_perf - self.suite_start_perf + duration = self.suite_start.elapsed() numtests = ( self.stats["passed"] @@ -664,10 +660,8 @@ def pytest_sessionfinish(self) -> None: failures=str(self.stats["failure"]), skipped=str(self.stats["skipped"]), tests=str(numtests), - time=f"{suite_time_delta:.3f}", - timestamp=datetime.fromtimestamp(self.suite_start_time, timezone.utc) - .astimezone() - .isoformat(), + time=f"{duration.seconds:.3f}", + timestamp=self.suite_start.as_utc().astimezone().isoformat(), hostname=platform.node(), ) global_properties = self._get_global_properties_node() diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index bb5f6a5787e..11127a88bb8 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -1150,7 +1150,7 @@ def runpytest_inprocess( if syspathinsert: self.syspathinsert() - now = timing.perf_counter() + instant = timing.Instant() capture = _get_multicapture("sys") capture.start_capturing() try: @@ -1180,7 +1180,7 @@ class reprec: # type: ignore assert reprec.ret is not None res = RunResult( - reprec.ret, out.splitlines(), err.splitlines(), timing.perf_counter() - now + reprec.ret, out.splitlines(), err.splitlines(), instant.elapsed().seconds ) res.reprec = reprec # type: ignore return res @@ -1408,7 +1408,7 @@ def run( print(" in:", Path.cwd()) with p1.open("w", encoding="utf8") as f1, p2.open("w", encoding="utf8") as f2: - now = timing.perf_counter() + instant = timing.Instant() popen = self.popen( cmdargs, stdin=stdin, @@ -1445,7 +1445,7 @@ def handle_timeout() -> None: with contextlib.suppress(ValueError): ret = ExitCode(ret) - return RunResult(ret, out, err, timing.perf_counter() - now) + return RunResult(ret, out, err, instant.elapsed().seconds) def _dump_lines(self, lines, fp): try: diff --git a/src/_pytest/runner.py b/src/_pytest/runner.py index f0543289267..26e4e838b77 100644 --- a/src/_pytest/runner.py +++ b/src/_pytest/runner.py @@ -339,8 +339,7 @@ def from_call( function, instead of being wrapped in the CallInfo. """ excinfo = None - start = timing.time() - precise_start = timing.perf_counter() + instant = timing.Instant() try: result: TResult | None = func() except BaseException: @@ -348,14 +347,11 @@ def from_call( if reraise is not None and isinstance(excinfo.value, reraise): raise result = None - # use the perf counter - precise_stop = timing.perf_counter() - duration = precise_stop - precise_start - stop = timing.time() + duration = instant.elapsed() return cls( - start=start, - stop=stop, - duration=duration, + start=duration.start.time, + stop=duration.stop.time, + duration=duration.seconds, when=when, result=result, excinfo=excinfo, diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index 8415912e9ac..d5ccc4e4900 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -391,7 +391,7 @@ def __init__(self, config: Config, file: TextIO | None = None) -> None: self._progress_nodeids_reported: set[str] = set() self._timing_nodeids_reported: set[str] = set() self._show_progress_info = self._determine_show_progress_info() - self._collect_report_last_write: float | None = None + self._collect_report_last_write = timing.Instant() self._already_displayed_warnings: int | None = None self._keyboardinterrupt_memo: ExceptionRepr | None = None @@ -769,7 +769,6 @@ def pytest_collection(self) -> None: if self.isatty: if self.config.option.verbose >= 0: self.write("collecting ... ", flush=True, bold=True) - self._collect_report_last_write = timing.perf_counter() elif self.config.option.verbose >= 1: self.write("collecting ... ", flush=True, bold=True) @@ -788,14 +787,13 @@ def report_collect(self, final: bool = False) -> None: return if not final: - # Only write "collecting" report every 0.5s. - t = timing.perf_counter() + # Only write the "collecting" report every `REPORT_COLLECTING_RESOLUTION`. if ( - self._collect_report_last_write is not None - and self._collect_report_last_write > t - REPORT_COLLECTING_RESOLUTION + self._collect_report_last_write.elapsed().seconds + < REPORT_COLLECTING_RESOLUTION ): return - self._collect_report_last_write = t + self._collect_report_last_write = timing.Instant() errors = len(self.stats.get("error", [])) skipped = len(self.stats.get("skipped", [])) @@ -823,7 +821,7 @@ def report_collect(self, final: bool = False) -> None: @hookimpl(trylast=True) def pytest_sessionstart(self, session: Session) -> None: self._session = session - self._sessionstarttime = timing.perf_counter() + self._session_start = timing.Instant() if not self.showheader: return self.write_sep("=", "test session starts", bold=True) @@ -1202,7 +1200,7 @@ def summary_stats(self) -> None: if self.verbosity < -1: return - session_duration = timing.perf_counter() - self._sessionstarttime + session_duration = self._session_start.elapsed() (parts, main_color) = self.build_summary_stats_line() line_parts = [] @@ -1217,7 +1215,7 @@ def summary_stats(self) -> None: msg = ", ".join(line_parts) main_markup = {main_color: True} - duration = f" in {format_session_duration(session_duration)}" + duration = f" in {format_session_duration(session_duration.seconds)}" duration_with_markup = self._tw.markup(duration, **main_markup) if display_sep: fullwidth += len(duration_with_markup) - len(duration) diff --git a/src/_pytest/timing.py b/src/_pytest/timing.py index 4422037a9d9..221eeffc4fd 100644 --- a/src/_pytest/timing.py +++ b/src/_pytest/timing.py @@ -10,6 +10,7 @@ import dataclasses from datetime import datetime +from datetime import timezone from time import perf_counter from time import sleep from time import time @@ -20,6 +21,47 @@ from pytest import MonkeyPatch +@dataclasses.dataclass(frozen=True) +class Instant: + """ + Represents an instant in time, used to both get the timestamp value and to measure + the duration of a time span. + + Inspired by Rust's `std::time::Instant`. + """ + + # Creation time of this instant, using time.time(), to measure actual time. + # Note: using a `lambda` to correctly get the mocked time via `MockTiming`. + time: float = dataclasses.field(default_factory=lambda: time(), init=False) + + # Performance counter tick of the instant, used to measure precise elapsed time. + # Note: using a `lambda` to correctly get the mocked time via `MockTiming`. + perf_count: float = dataclasses.field( + default_factory=lambda: perf_counter(), init=False + ) + + def elapsed(self) -> Duration: + """Measure the duration since `Instant` was created.""" + return Duration(start=self, stop=Instant()) + + def as_utc(self) -> datetime: + """Instant as UTC datetime.""" + return datetime.fromtimestamp(self.time, timezone.utc) + + +@dataclasses.dataclass(frozen=True) +class Duration: + """A span of time as measured by `Instant.elapsed()`.""" + + start: Instant + stop: Instant + + @property + def seconds(self) -> float: + """Elapsed time of the duration in seconds, measured using a performance counter for precise timing.""" + return self.stop.perf_count - self.start.perf_count + + @dataclasses.dataclass class MockTiming: """Mocks _pytest.timing with a known object that can be used to control timing in tests diff --git a/testing/_py/test_local.py b/testing/_py/test_local.py index e4b011a9727..7064d1daa9b 100644 --- a/testing/_py/test_local.py +++ b/testing/_py/test_local.py @@ -12,7 +12,6 @@ from py import error from py.path import local -import _pytest.timing import pytest @@ -747,7 +746,8 @@ def test_setmtime(self): name = tempfile.mktemp() open(name, "w").close() try: - mtime = int(_pytest.timing.time()) - 100 + # Do not use _pytest.timing here, as we do not want time mocking to affect this test. + mtime = int(time.time()) - 100 path = local(name) assert path.mtime() != mtime path.setmtime(mtime) @@ -1405,7 +1405,8 @@ def test_atime(self, tmpdir): import time path = tmpdir.ensure("samplefile") - now = _pytest.timing.perf_counter() + # Do not use _pytest.timing here, as we do not want time mocking to affect this test. + now = time.time() atime1 = path.atime() # we could wait here but timer resolution is very # system dependent @@ -1413,7 +1414,7 @@ def test_atime(self, tmpdir): time.sleep(ATIME_RESOLUTION) atime2 = path.atime() time.sleep(ATIME_RESOLUTION) - duration = _pytest.timing.perf_counter() - now + duration = time.time() - now assert (atime2 - atime1) <= duration def test_commondir(self, path1): diff --git a/testing/test_pytester.py b/testing/test_pytester.py index 555d73f9eaa..721e8c19d8b 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -451,13 +451,12 @@ def test_pytester_run_with_timeout(pytester: Pytester) -> None: timeout = 120 - start = _pytest.timing.perf_counter() + instant = _pytest.timing.Instant() result = pytester.runpytest_subprocess(testfile, timeout=timeout) - end = _pytest.timing.perf_counter() - duration = end - start + duration = instant.elapsed() assert result.ret == ExitCode.OK - assert duration < timeout + assert duration.seconds < timeout def test_pytester_run_timeout_expires(pytester: Pytester) -> None: From a0f8a697fcafb7432d753784cc55860ebb939182 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 2 May 2025 17:54:14 +0200 Subject: [PATCH 389/445] doc: Update trainings --- doc/en/index.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/en/index.rst b/doc/en/index.rst index 6e04dbb9ed0..fb5d0482c0d 100644 --- a/doc/en/index.rst +++ b/doc/en/index.rst @@ -2,7 +2,8 @@ .. sidebar:: **Next Open Trainings and Events** - - `pytest - simple, rapid and fun testing with Python `_, at `PyConDE `_, **April 24th** (1.5), Darmstadt, Germany + - `pytest - simple, rapid and fun testing with Python `_, at `EuroPython 2025 `_, **July 14th** (3h), Prague, Czech Republic + - `Professional Testing with Python `_, via `Python Academy `_ (3 day in-depth training), **March 3th -- 5th 2026**, Leipzig (DE) / Remote Also see :doc:`previous talks and blogposts ` From 7746f4f21044627e77d9bf34d27238c1a4eb16b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Augustyn=C3=B3w?= <105516855+Alcares@users.noreply.github.com> Date: Fri, 2 May 2025 19:22:25 +0200 Subject: [PATCH 390/445] Add `name` attribute to `testsuites` root tag in junitxml (#13404) Fixes #12736 --------- Co-authored-by: maugu Co-authored-by: Bruno Oliveira --- AUTHORS | 1 + changelog/12736.improvement.rst | 3 +++ src/_pytest/junitxml.py | 1 + testing/test_junitxml.py | 1 + 4 files changed, 6 insertions(+) create mode 100644 changelog/12736.improvement.rst diff --git a/AUTHORS b/AUTHORS index 7f742fb4083..1dfa55b131f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -275,6 +275,7 @@ Manuel Krebber Marc Mueller Marc Schlaich Marcelo Duarte Trevisani +Marcin Augustynów Marcin Bachry Marc Bresson Marco Gorelli diff --git a/changelog/12736.improvement.rst b/changelog/12736.improvement.rst new file mode 100644 index 00000000000..5fdb14e2ef5 --- /dev/null +++ b/changelog/12736.improvement.rst @@ -0,0 +1,3 @@ +Added a new attribute `name` with the fixed value `"pytest tests"` to the root tag `testsuites` of the junit-xml generated by pytest. + +This attribute is part of many junit-xml specifications and is even part of the `junit-10.xsd` specification that pytest's implementation is based on. diff --git a/src/_pytest/junitxml.py b/src/_pytest/junitxml.py index ec9922ee7bd..dc35e3aac15 100644 --- a/src/_pytest/junitxml.py +++ b/src/_pytest/junitxml.py @@ -670,6 +670,7 @@ def pytest_sessionfinish(self) -> None: for node_reporter in self.node_reporters_ordered: suite_node.append(node_reporter.to_xml()) testsuites = ET.Element("testsuites") + testsuites.set("name", "pytest tests") testsuites.append(suite_node) logfile.write(ET.tostring(testsuites, encoding="unicode")) diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index 4145f34ab14..504e4969039 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -1451,6 +1451,7 @@ def test_x(): _, dom = run_and_parse(family=xunit_family) root = dom.get_unique_child assert root.tag == "testsuites" + root.assert_attr(name="pytest tests") suite_node = root.get_unique_child assert suite_node.tag == "testsuite" From 89b84cb56295c46e1d8834b599e858bc65c15a5b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 4 May 2025 05:41:56 +0000 Subject: [PATCH 391/445] [automated] Update plugin list (#13407) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 114 ++++++++++++++++++++----------- 1 file changed, 73 insertions(+), 41 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index b5b9ac659d0..bb34208872b 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =3.5.0) :pypi:`pytest-annotate` pytest-annotate: Generate PyAnnotate annotations from your pytest tests. Jun 07, 2022 3 - Alpha pytest (<8.0.0,>=3.2.0) :pypi:`pytest-annotated` Pytest plugin to allow use of Annotated in tests to resolve fixtures Sep 30, 2024 N/A pytest>=8.3.3 - :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures Apr 01, 2025 5 - Production/Stable pytest>=6 + :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures Apr 28, 2025 5 - Production/Stable pytest>=6 :pypi:`pytest-ansible-playbook` Pytest fixture which runs given ansible playbook file. Mar 08, 2019 4 - Beta N/A :pypi:`pytest-ansible-playbook-runner` Pytest fixture which runs given ansible playbook file. Dec 02, 2020 4 - Beta pytest (>=3.1.0) :pypi:`pytest-ansible-units` A pytest plugin for running unit tests within an ansible collection Apr 14, 2022 N/A N/A @@ -119,7 +119,7 @@ This list contains 1626 plugins. :pypi:`pytest_async` pytest-async - Run your coroutine in event loop without decorator Feb 26, 2020 N/A N/A :pypi:`pytest-async-generators` Pytest fixtures for async generators Jul 05, 2023 N/A N/A :pypi:`pytest-asyncio` Pytest support for asyncio Mar 25, 2025 4 - Beta pytest<9,>=8.2 - :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Mar 16, 2025 4 - Beta pytest>=6.2.0 + :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Apr 29, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Apr 26, 2025 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) :pypi:`pytest-async-mongodb` pytest plugin for async MongoDB Oct 18, 2017 5 - Production/Stable pytest (>=2.5.2) @@ -162,7 +162,7 @@ This list contains 1626 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests Apr 25, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests May 02, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -273,6 +273,7 @@ This list contains 1626 plugins. :pypi:`pytest-cmdline-add-args` Pytest plugin for custom argument handling and Allure reporting. This plugin allows you to add arguments before running a test. Sep 01, 2024 N/A N/A :pypi:`pytest-cobra` PyTest plugin for testing Smart Contracts for Ethereum blockchain. Jun 29, 2019 3 - Alpha pytest (<4.0.0,>=3.7.1) :pypi:`pytest-cocotb` Pytest plugin to integrate Cocotb Mar 15, 2025 5 - Production/Stable pytest; extra == "test" + :pypi:`pytest-codeblock` Pytest plugin to collect and test code blocks in reStructuredText and Markdown files. May 02, 2025 4 - Beta pytest :pypi:`pytest_codeblocks` Test code blocks in your READMEs Sep 17, 2023 5 - Production/Stable pytest >= 7.0.0 :pypi:`pytest-codecarbon` Pytest plugin for measuring carbon emissions Jun 15, 2022 N/A pytest :pypi:`pytest-codecheckers` pytest plugin to add source code sanity checks (pep8 and friends) Feb 13, 2010 N/A N/A @@ -409,7 +410,7 @@ This list contains 1626 plugins. :pypi:`pytest-django-filefield` Replaces FileField.storage with something you can patch globally. May 09, 2022 5 - Production/Stable pytest >= 5.2 :pypi:`pytest-django-gcir` A Django plugin for pytest. Mar 06, 2018 5 - Production/Stable N/A :pypi:`pytest-django-haystack` Cleanup your Haystack indexes between tests Sep 03, 2017 5 - Production/Stable pytest (>=2.3.4) - :pypi:`pytest-django-ifactory` A model instance factory for pytest-django Aug 27, 2023 5 - Production/Stable N/A + :pypi:`pytest-django-ifactory` A model instance factory for pytest-django Apr 30, 2025 5 - Production/Stable N/A :pypi:`pytest-django-lite` The bare minimum to integrate py.test with Django. Jan 30, 2014 N/A N/A :pypi:`pytest-django-liveserver-ssl` Jan 09, 2025 3 - Alpha N/A :pypi:`pytest-django-model` A Simple Way to Test your Django Models Feb 14, 2019 4 - Beta N/A @@ -462,11 +463,11 @@ This list contains 1626 plugins. :pypi:`pytest-drop-dup-tests` A Pytest plugin to drop duplicated tests during collection Mar 04, 2024 5 - Production/Stable pytest >=7 :pypi:`pytest-dryci` Test caching plugin for pytest Sep 27, 2024 4 - Beta N/A :pypi:`pytest-dryrun` A Pytest plugin to ignore tests during collection without reporting them in the test summary. Jan 19, 2025 5 - Production/Stable pytest<9,>=7.40 - :pypi:`pytest-dsl` A DSL testing framework based on pytest Apr 14, 2025 N/A pytest>=7.0.0 + :pypi:`pytest-dsl` A DSL testing framework based on pytest Apr 30, 2025 N/A pytest>=7.0.0 :pypi:`pytest-dummynet` A py.test plugin providing access to a dummynet. Dec 15, 2021 5 - Production/Stable pytest :pypi:`pytest-dump2json` A pytest plugin for dumping test results to json. Jun 29, 2015 N/A N/A :pypi:`pytest-duration-insights` Jul 15, 2024 N/A N/A - :pypi:`pytest-durations` Pytest plugin reporting fixtures and test functions execution time. Mar 18, 2025 5 - Production/Stable pytest>=4.6 + :pypi:`pytest-durations` Pytest plugin reporting fixtures and test functions execution time. Apr 29, 2025 5 - Production/Stable pytest>=4.6 :pypi:`pytest-dynamicrerun` A pytest plugin to rerun tests dynamically based off of test outcome and output. Aug 15, 2020 4 - Beta N/A :pypi:`pytest-dynamodb` DynamoDB fixtures for pytest Apr 04, 2025 5 - Production/Stable pytest :pypi:`pytest-easy-addoption` pytest-easy-addoption: Easy way to work with pytest addoption Jan 22, 2020 N/A N/A @@ -476,7 +477,7 @@ This list contains 1626 plugins. :pypi:`pytest-easy-server` Pytest plugin for easy testing against servers May 01, 2021 4 - Beta pytest (<5.0.0,>=4.3.1) ; python_version < "3.5" :pypi:`pytest-ebics-sandbox` A pytest plugin for testing against an EBICS sandbox server. Requires docker. Aug 15, 2022 N/A N/A :pypi:`pytest-ec2` Pytest execution on EC2 instance Oct 22, 2019 3 - Alpha N/A - :pypi:`pytest-echo` pytest plugin that allows to dump environment variables, package version and generic attributes Apr 01, 2025 5 - Production/Stable pytest>=8.3.3 + :pypi:`pytest-echo` pytest plugin that allows to dump environment variables, package version and generic attributes Apr 27, 2025 5 - Production/Stable pytest>=8.3.3 :pypi:`pytest-edit` Edit the source code of a failed test with \`pytest --edit\`. Nov 17, 2024 N/A pytest :pypi:`pytest-ekstazi` Pytest plugin to select test using Ekstazi algorithm Sep 10, 2022 N/A pytest :pypi:`pytest-elasticsearch` Elasticsearch fixtures and fixture factories for Pytest. Dec 03, 2024 5 - Production/Stable pytest>=7.0 @@ -521,6 +522,7 @@ This list contains 1626 plugins. :pypi:`pytest-eucalyptus` Pytest Plugin for BDD Jun 28, 2022 N/A pytest (>=4.2.0) :pypi:`pytest-evals` A pytest plugin for running and analyzing LLM evaluation tests Feb 02, 2025 N/A pytest>=7.0.0 :pypi:`pytest-eventlet` Applies eventlet monkey-patch as a pytest plugin. Oct 04, 2021 N/A pytest ; extra == 'dev' + :pypi:`pytest-everyfunc` A pytest plugin to detect completely untested functions using coverage Apr 30, 2025 4 - Beta pytest :pypi:`pytest_evm` The testing package containing tools to test Web3-based projects Sep 23, 2024 4 - Beta pytest<9.0.0,>=8.1.1 :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Mar 23, 2025 N/A pytest>=7 @@ -598,7 +600,7 @@ This list contains 1626 plugins. :pypi:`pytest-fixture-remover` A LibCST codemod to remove pytest fixtures applied via the usefixtures decorator, as well as its parametrizations. Feb 14, 2024 5 - Production/Stable N/A :pypi:`pytest-fixture-rtttg` Warn or fail on fixture name clash Feb 23, 2022 N/A pytest (>=7.0.1,<8.0.0) :pypi:`pytest-fixtures` Common fixtures for pytest May 01, 2019 5 - Production/Stable N/A - :pypi:`pytest-fixture-tools` Plugin for pytest which provides tools for fixtures Aug 15, 2024 6 - Mature pytest + :pypi:`pytest-fixture-tools` Plugin for pytest which provides tools for fixtures Apr 30, 2025 6 - Mature pytest :pypi:`pytest-fixture-typecheck` A pytest plugin to assert type annotations at runtime. Aug 24, 2021 N/A pytest :pypi:`pytest-flake8` pytest plugin to check FLAKE8 requirements Nov 09, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-flake8-path` A pytest fixture for testing flake8 plugins. Oct 25, 2024 5 - Production/Stable pytest @@ -647,7 +649,7 @@ This list contains 1626 plugins. :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Apr 24, 2025 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Apr 30, 2025 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -667,6 +669,7 @@ This list contains 1626 plugins. :pypi:`pytest-golden` Plugin for pytest that offloads expected outputs to data files Jul 18, 2022 N/A pytest (>=6.1.2) :pypi:`pytest-goldie` A plugin to support golden tests with pytest. May 23, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-google-chat` Notify google chat channel for test results Mar 27, 2022 4 - Beta pytest + :pypi:`pytest-gradescope` A pytest plugin for Gradescope integration Apr 29, 2025 N/A N/A :pypi:`pytest-graphql-schema` Get graphql schema as fixture for pytest Oct 18, 2019 N/A N/A :pypi:`pytest-greendots` Green progress dots Feb 08, 2014 3 - Alpha N/A :pypi:`pytest-group-by-class` A Pytest plugin for running a subset of your tests by splitting them in to groups of classes. Jun 27, 2023 5 - Production/Stable pytest (>=2.5) @@ -691,7 +694,7 @@ This list contains 1626 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components Apr 26, 2025 3 - Alpha pytest==8.3.5 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components May 02, 2025 3 - Alpha pytest==8.3.5 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -711,7 +714,7 @@ This list contains 1626 plugins. :pypi:`pytest-html-thread` pytest plugin for generating HTML reports Dec 29, 2020 5 - Production/Stable N/A :pypi:`pytest-http` Fixture "http" for http requests Aug 22, 2024 N/A pytest :pypi:`pytest-httpbin` Easily test your HTTP library against a local copy of httpbin Sep 18, 2024 5 - Production/Stable pytest; extra == "test" - :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace. Feb 11, 2025 4 - Beta pytest>=7.0.0 + :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace. Apr 27, 2025 4 - Beta pytest>=7.0.0 :pypi:`pytest-http-mocker` Pytest plugin for http mocking (via https://github.com/vilus/mocker) Oct 20, 2019 N/A N/A :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Apr 10, 2025 3 - Alpha N/A @@ -767,7 +770,7 @@ This list contains 1626 plugins. :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A :pypi:`pytest-ipynb2` Pytest plugin to run tests in Jupyter Notebooks Mar 09, 2025 N/A pytest - :pypi:`pytest-ipywidgets` Apr 25, 2025 N/A pytest + :pypi:`pytest-ipywidgets` Apr 30, 2025 N/A pytest :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Apr 22, 2025 4 - Beta pytest :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Feb 24, 2025 4 - Beta pytest>=5 :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) @@ -795,7 +798,7 @@ This list contains 1626 plugins. :pypi:`pytest-json-report-wip` A pytest plugin to report test results as JSON files Oct 28, 2023 4 - Beta pytest >=3.8.0 :pypi:`pytest-jsonschema` A pytest plugin to perform JSONSchema validations Apr 20, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-jtr` pytest plugin supporting json test report output Jul 21, 2024 N/A pytest<8.0.0,>=7.1.2 - :pypi:`pytest-jubilant` Add your description here Apr 25, 2025 N/A pytest>=8.3.5 + :pypi:`pytest-jubilant` Add your description here May 01, 2025 N/A pytest>=8.3.5 :pypi:`pytest-junit-xray-xml` Export test results in an augmented JUnit format for usage with Xray () Jan 01, 2025 4 - Beta pytest :pypi:`pytest-jupyter` A pytest plugin for testing Jupyter libraries and extensions. Apr 04, 2024 4 - Beta pytest>=7.0 :pypi:`pytest-jupyterhub` A reusable JupyterHub pytest plugin Apr 25, 2023 5 - Production/Stable pytest @@ -831,7 +834,7 @@ This list contains 1626 plugins. :pypi:`pytest-leaping` A simple plugin to use with pytest Mar 27, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-leo-interface` Pytest extension tool for leo projects. Mar 19, 2025 N/A N/A :pypi:`pytest-level` Select tests of a given level or lower Oct 21, 2019 N/A pytest - :pypi:`pytest-lf-skip` A pytest plugin which makes \`--last-failed\` skip instead of deselect tests. Apr 25, 2025 N/A pytest>=8.3.5 + :pypi:`pytest-lf-skip` A pytest plugin which makes \`--last-failed\` skip instead of deselect tests. Apr 30, 2025 4 - Beta pytest>=8.3.5 :pypi:`pytest-libfaketime` A python-libfaketime plugin for pytest Apr 12, 2024 4 - Beta pytest>=3.0.0 :pypi:`pytest-libiio` A pytest plugin to manage interfacing with libiio contexts Oct 01, 2024 4 - Beta N/A :pypi:`pytest-libnotify` Pytest plugin that shows notifications about the test run Apr 02, 2021 3 - Alpha pytest @@ -860,7 +863,7 @@ This list contains 1626 plugins. :pypi:`pytest-logging` Configures logging and allows tweaking the log level with a py.test flag Nov 04, 2015 4 - Beta N/A :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) :pypi:`pytest-logging-strict` pytest fixture logging configured from packaged YAML Apr 09, 2025 3 - Alpha pytest - :pypi:`pytest-logikal` Common testing environment Apr 02, 2025 5 - Production/Stable pytest==8.3.5 + :pypi:`pytest-logikal` Common testing environment Apr 30, 2025 5 - Production/Stable pytest==8.3.5 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Sep 30, 2024 4 - Beta pytest>=8.2.2 :pypi:`pytest-loguru` Pytest Loguru Mar 20, 2024 5 - Production/Stable pytest; extra == "test" @@ -891,7 +894,7 @@ This list contains 1626 plugins. :pypi:`pytest-maybe-raises` Pytest fixture for optional exception testing. May 27, 2022 N/A pytest ; extra == 'dev' :pypi:`pytest-mccabe` pytest plugin to run the mccabe code complexity checker. Jul 22, 2020 3 - Alpha pytest (>=5.4.0) :pypi:`pytest-md` Plugin for generating Markdown reports for pytest results Jul 11, 2019 3 - Alpha pytest (>=4.2.1) - :pypi:`pytest-md-report` A pytest plugin to generate test outcomes reports with markdown table format. Jan 02, 2025 4 - Beta pytest!=6.0.0,<9,>=3.3.2 + :pypi:`pytest-md-report` A pytest plugin to generate test outcomes reports with markdown table format. May 02, 2025 4 - Beta pytest!=6.0.0,<9,>=3.3.2 :pypi:`pytest-meilisearch` Pytest helpers for testing projects using Meilisearch Oct 08, 2024 N/A pytest>=7.4.3 :pypi:`pytest-memlog` Log memory usage during tests May 03, 2023 N/A pytest (>=7.3.0,<8.0.0) :pypi:`pytest-memprof` Estimates memory consumption of test functions Mar 29, 2019 4 - Beta N/A @@ -1037,7 +1040,7 @@ This list contains 1626 plugins. :pypi:`pytest-parametrized` Pytest decorator for parametrizing tests with default iterables. Dec 21, 2024 5 - Production/Stable pytest :pypi:`pytest-parametrize-suite` A simple pytest extension for creating a named test suite. Jan 19, 2023 5 - Production/Stable pytest :pypi:`pytest_param_files` Create pytest parametrize decorators from external files. Jul 29, 2023 N/A pytest - :pypi:`pytest-params` Simplified pytest test case parameters. Aug 05, 2024 N/A pytest>=7.0.0 + :pypi:`pytest-params` Simplified pytest test case parameters. Apr 27, 2025 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-param-scope` pytest parametrize scope fixture workaround Oct 18, 2023 N/A pytest :pypi:`pytest-parawtf` Finally spell paramete?ri[sz]e correctly Dec 03, 2018 4 - Beta pytest (>=3.6.0) :pypi:`pytest-pass` Check out https://github.com/elilutsky/pytest-pass Dec 04, 2019 N/A N/A @@ -1246,6 +1249,7 @@ This list contains 1626 plugins. :pypi:`pytest-rest-api` Aug 08, 2022 N/A pytest (>=7.1.2,<8.0.0) :pypi:`pytest-restrict` Pytest plugin to restrict the test types allowed Oct 24, 2024 5 - Production/Stable pytest :pypi:`pytest-result-log` A pytest plugin that records the start, end, and result information of each use case in a log file Jan 10, 2024 N/A pytest>=7.2.0 + :pypi:`pytest-result-notify` Default template for PDM package Apr 27, 2025 N/A pytest>=8.3.5 :pypi:`pytest-results` Easily spot regressions in your tests. Mar 14, 2025 4 - Beta pytest :pypi:`pytest-result-sender` Apr 20, 2023 N/A pytest>=7.3.1 :pypi:`pytest-result-sender-lj` Default template for PDM package Dec 17, 2024 N/A pytest>=8.3.4 @@ -1293,7 +1297,7 @@ This list contains 1626 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. Apr 25, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. May 02, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A @@ -1305,7 +1309,7 @@ This list contains 1626 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. Apr 25, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. May 02, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1988,7 +1992,7 @@ This list contains 1626 plugins. Pytest plugin to allow use of Annotated in tests to resolve fixtures :pypi:`pytest-ansible` - *last release*: Apr 01, 2025, + *last release*: Apr 28, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=6 @@ -2261,7 +2265,7 @@ This list contains 1626 plugins. Pytest support for asyncio :pypi:`pytest-asyncio-concurrent` - *last release*: Mar 16, 2025, + *last release*: Apr 29, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -2562,7 +2566,7 @@ This list contains 1626 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: Apr 25, 2025, + *last release*: May 02, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -3338,6 +3342,13 @@ This list contains 1626 plugins. Pytest plugin to integrate Cocotb + :pypi:`pytest-codeblock` + *last release*: May 02, 2025, + *status*: 4 - Beta, + *requires*: pytest + + Pytest plugin to collect and test code blocks in reStructuredText and Markdown files. + :pypi:`pytest_codeblocks` *last release*: Sep 17, 2023, *status*: 5 - Production/Stable, @@ -4291,7 +4302,7 @@ This list contains 1626 plugins. Cleanup your Haystack indexes between tests :pypi:`pytest-django-ifactory` - *last release*: Aug 27, 2023, + *last release*: Apr 30, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -4662,7 +4673,7 @@ This list contains 1626 plugins. A Pytest plugin to ignore tests during collection without reporting them in the test summary. :pypi:`pytest-dsl` - *last release*: Apr 14, 2025, + *last release*: Apr 30, 2025, *status*: N/A, *requires*: pytest>=7.0.0 @@ -4690,7 +4701,7 @@ This list contains 1626 plugins. :pypi:`pytest-durations` - *last release*: Mar 18, 2025, + *last release*: Apr 29, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=4.6 @@ -4760,7 +4771,7 @@ This list contains 1626 plugins. Pytest execution on EC2 instance :pypi:`pytest-echo` - *last release*: Apr 01, 2025, + *last release*: Apr 27, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=8.3.3 @@ -5074,6 +5085,13 @@ This list contains 1626 plugins. Applies eventlet monkey-patch as a pytest plugin. + :pypi:`pytest-everyfunc` + *last release*: Apr 30, 2025, + *status*: 4 - Beta, + *requires*: pytest + + A pytest plugin to detect completely untested functions using coverage + :pypi:`pytest_evm` *last release*: Sep 23, 2024, *status*: 4 - Beta, @@ -5614,7 +5632,7 @@ This list contains 1626 plugins. Common fixtures for pytest :pypi:`pytest-fixture-tools` - *last release*: Aug 15, 2024, + *last release*: Apr 30, 2025, *status*: 6 - Mature, *requires*: pytest @@ -5957,7 +5975,7 @@ This list contains 1626 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Apr 24, 2025, + *last release*: Apr 30, 2025, *status*: N/A, *requires*: pytest>=3.6 @@ -6096,6 +6114,13 @@ This list contains 1626 plugins. Notify google chat channel for test results + :pypi:`pytest-gradescope` + *last release*: Apr 29, 2025, + *status*: N/A, + *requires*: N/A + + A pytest plugin for Gradescope integration + :pypi:`pytest-graphql-schema` *last release*: Oct 18, 2019, *status*: N/A, @@ -6265,7 +6290,7 @@ This list contains 1626 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: Apr 26, 2025, + *last release*: May 02, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.5 @@ -6405,7 +6430,7 @@ This list contains 1626 plugins. Easily test your HTTP library against a local copy of httpbin :pypi:`pytest-httpdbg` - *last release*: Feb 11, 2025, + *last release*: Apr 27, 2025, *status*: 4 - Beta, *requires*: pytest>=7.0.0 @@ -6797,7 +6822,7 @@ This list contains 1626 plugins. Pytest plugin to run tests in Jupyter Notebooks :pypi:`pytest-ipywidgets` - *last release*: Apr 25, 2025, + *last release*: Apr 30, 2025, *status*: N/A, *requires*: pytest @@ -6993,7 +7018,7 @@ This list contains 1626 plugins. pytest plugin supporting json test report output :pypi:`pytest-jubilant` - *last release*: Apr 25, 2025, + *last release*: May 01, 2025, *status*: N/A, *requires*: pytest>=8.3.5 @@ -7245,8 +7270,8 @@ This list contains 1626 plugins. Select tests of a given level or lower :pypi:`pytest-lf-skip` - *last release*: Apr 25, 2025, - *status*: N/A, + *last release*: Apr 30, 2025, + *status*: 4 - Beta, *requires*: pytest>=8.3.5 A pytest plugin which makes \`--last-failed\` skip instead of deselect tests. @@ -7448,7 +7473,7 @@ This list contains 1626 plugins. pytest fixture logging configured from packaged YAML :pypi:`pytest-logikal` - *last release*: Apr 02, 2025, + *last release*: Apr 30, 2025, *status*: 5 - Production/Stable, *requires*: pytest==8.3.5 @@ -7665,7 +7690,7 @@ This list contains 1626 plugins. Plugin for generating Markdown reports for pytest results :pypi:`pytest-md-report` - *last release*: Jan 02, 2025, + *last release*: May 02, 2025, *status*: 4 - Beta, *requires*: pytest!=6.0.0,<9,>=3.3.2 @@ -8687,8 +8712,8 @@ This list contains 1626 plugins. Create pytest parametrize decorators from external files. :pypi:`pytest-params` - *last release*: Aug 05, 2024, - *status*: N/A, + *last release*: Apr 27, 2025, + *status*: 5 - Production/Stable, *requires*: pytest>=7.0.0 Simplified pytest test case parameters. @@ -10149,6 +10174,13 @@ This list contains 1626 plugins. A pytest plugin that records the start, end, and result information of each use case in a log file + :pypi:`pytest-result-notify` + *last release*: Apr 27, 2025, + *status*: N/A, + *requires*: pytest>=8.3.5 + + Default template for PDM package + :pypi:`pytest-results` *last release*: Mar 14, 2025, *status*: 4 - Beta, @@ -10479,7 +10511,7 @@ This list contains 1626 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: Apr 25, 2025, + *last release*: May 02, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10563,7 +10595,7 @@ This list contains 1626 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: Apr 25, 2025, + *last release*: May 02, 2025, *status*: 5 - Production/Stable, *requires*: N/A From 44deff97cde6ea2847c4d9da6dc057189cdb4358 Mon Sep 17 00:00:00 2001 From: Will Riley Date: Sat, 10 May 2025 13:24:40 +0200 Subject: [PATCH 392/445] Update citation files (#13416) * The author metadata of the BibTex example is now correctly formatted with last names following first names. * An example of BibLaTex has been added. * BibTex and BibLaTex examples now clearly indicate that what is cited is software. Closes #13415 --- AUTHORS | 1 + CITATION | 24 ++++++++++++++++++------ changelog/13415.improvement.rst | 5 +++++ 3 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 changelog/13415.improvement.rst diff --git a/AUTHORS b/AUTHORS index 1dfa55b131f..9be48958485 100644 --- a/AUTHORS +++ b/AUTHORS @@ -472,6 +472,7 @@ Volodymyr Kochetkov Volodymyr Piskun Wei Lin Wil Cooley +Will Riley William Lee Wim Glenn Wouter van Ackooy diff --git a/CITATION b/CITATION index d4e9d8ec7a1..98beee72209 100644 --- a/CITATION +++ b/CITATION @@ -1,16 +1,28 @@ NOTE: Change "x.y" by the version you use. If you are unsure about which version -you are using run: `pip show pytest`. +you are using run: `pip show pytest`. Do not include the patch number (i.e., z in x.y.z) Text: [pytest] pytest x.y, 2004 Krekel et al., https://github.com/pytest-dev/pytest +BibLaTeX: + +@software{pytest, + title = {pytest x.y}, + author = {Holger Krekel and Bruno Oliveira and Ronny Pfannschmidt and Floris Bruynooghe and Brianna Laugher and Florian Bruhin}, + year = {2004}, + version = {x.y}, + url = {https://github.com/pytest-dev/pytest}, + note = {Contributors: Holger Krekel and Bruno Oliveira and Ronny Pfannschmidt and Floris Bruynooghe and Brianna Laugher and Florian Bruhin and others} +} + BibTeX: -@misc{pytestx.y, - title = {pytest x.y}, - author = {Krekel, Holger and Oliveira, Bruno and Pfannschmidt, Ronny and Bruynooghe, Floris and Laugher, Brianna and Bruhin, Florian}, - year = {2004}, - url = {https://github.com/pytest-dev/pytest}, +@misc{pytest, + author = {Holger Krekel and Bruno Oliveira and Ronny Pfannschmidt and Floris Bruynooghe and Brianna Laugher and Florian Bruhin}, + title = {pytest x.y}, + year = {2004}, + howpublished = {\url{https://github.com/pytest-dev/pytest}}, + note = {Version x.y. Contributors include Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin, and others.} } diff --git a/changelog/13415.improvement.rst b/changelog/13415.improvement.rst new file mode 100644 index 00000000000..61667f15c7b --- /dev/null +++ b/changelog/13415.improvement.rst @@ -0,0 +1,5 @@ +The author metadata of the BibTex example is now correctly formatted with last names following first names. +An example of BibLaTex has been added. +BibTex and BibLaTex examples now clearly indicate that what is cited is software. + +-- by :user:`willynilly` From ba2ec223f4321d3bd0c370177c6a37671ea9a8de Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 11 May 2025 10:05:17 -0300 Subject: [PATCH 393/445] [automated] Update plugin list (#13418) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 188 ++++++++++++------------------- 1 file changed, 74 insertions(+), 114 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index bb34208872b..383cc7d6562 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =8.3 :pypi:`logassert` Simple but powerful assertion and verification of logged lines Jan 29, 2025 5 - Production/Stable pytest; extra == "dev" - :pypi:`logot` Test whether your code is logging correctly 🪵 Mar 23, 2024 5 - Production/Stable pytest<9,>=7; extra == "pytest" - :pypi:`nuts` Network Unit Testing System Jul 19, 2024 N/A pytest<8,>=7 + :pypi:`logot` Test whether your code is logging correctly 🪵 May 05, 2025 5 - Production/Stable pytest; extra == "pytest" + :pypi:`nuts` Network Unit Testing System May 10, 2025 N/A pytest<8,>=7 :pypi:`pytest-abq` Pytest integration for the ABQ universal test runner. Apr 07, 2023 N/A N/A :pypi:`pytest-abstracts` A contextmanager pytest fixture for handling multiple mock abstracts May 25, 2022 N/A N/A :pypi:`pytest-accept` A pytest-plugin for updating doctest outputs Dec 08, 2024 N/A pytest>=7 @@ -118,7 +118,7 @@ This list contains 1630 plugins. :pypi:`pytest-ast-transformer` May 04, 2019 3 - Alpha pytest :pypi:`pytest_async` pytest-async - Run your coroutine in event loop without decorator Feb 26, 2020 N/A N/A :pypi:`pytest-async-generators` Pytest fixtures for async generators Jul 05, 2023 N/A N/A - :pypi:`pytest-asyncio` Pytest support for asyncio Mar 25, 2025 4 - Beta pytest<9,>=8.2 + :pypi:`pytest-asyncio` Pytest support for asyncio May 09, 2025 4 - Beta pytest<9,>=8.2 :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Apr 29, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Apr 26, 2025 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) @@ -162,7 +162,7 @@ This list contains 1630 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests May 02, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests May 09, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -239,10 +239,9 @@ This list contains 1630 plugins. :pypi:`pytest-check-library` check your missing library Jul 17, 2022 N/A N/A :pypi:`pytest-check-libs` check your missing library Jul 17, 2022 N/A N/A :pypi:`pytest-check-links` Check links in files Jul 29, 2020 N/A pytest<9,>=7.0 - :pypi:`pytest-checklist` Pytest plugin to track and report unit/function coverage. Jun 10, 2024 N/A N/A + :pypi:`pytest-checklist` Pytest plugin to track and report unit/function coverage. May 07, 2025 N/A N/A :pypi:`pytest-check-mk` pytest plugin to test Check_MK checks Nov 19, 2015 4 - Beta pytest :pypi:`pytest-checkpoint` Restore a checkpoint in pytest Mar 30, 2025 N/A pytest>=8.0.0 - :pypi:`pytest-check-requirements` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A :pypi:`pytest-ch-framework` My pytest framework Apr 17, 2024 N/A pytest==8.0.1 :pypi:`pytest-chic-report` Simple pytest plugin for generating and sending report to messengers. Nov 01, 2024 N/A pytest>=6.0 :pypi:`pytest-chinesereport` Apr 16, 2025 4 - Beta pytest>=3.5.0 @@ -273,7 +272,7 @@ This list contains 1630 plugins. :pypi:`pytest-cmdline-add-args` Pytest plugin for custom argument handling and Allure reporting. This plugin allows you to add arguments before running a test. Sep 01, 2024 N/A N/A :pypi:`pytest-cobra` PyTest plugin for testing Smart Contracts for Ethereum blockchain. Jun 29, 2019 3 - Alpha pytest (<4.0.0,>=3.7.1) :pypi:`pytest-cocotb` Pytest plugin to integrate Cocotb Mar 15, 2025 5 - Production/Stable pytest; extra == "test" - :pypi:`pytest-codeblock` Pytest plugin to collect and test code blocks in reStructuredText and Markdown files. May 02, 2025 4 - Beta pytest + :pypi:`pytest-codeblock` Pytest plugin to collect and test code blocks in reStructuredText and Markdown files. May 10, 2025 4 - Beta pytest :pypi:`pytest_codeblocks` Test code blocks in your READMEs Sep 17, 2023 5 - Production/Stable pytest >= 7.0.0 :pypi:`pytest-codecarbon` Pytest plugin for measuring carbon emissions Jun 15, 2022 N/A pytest :pypi:`pytest-codecheckers` pytest plugin to add source code sanity checks (pep8 and friends) Feb 13, 2010 N/A N/A @@ -381,12 +380,12 @@ This list contains 1630 plugins. :pypi:`pytest-describe-it` plugin for rich text descriptions Jul 19, 2019 4 - Beta pytest :pypi:`pytest-deselect-if` A plugin to deselect pytests tests rather than using skipif Dec 26, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-devpi-server` DevPI server fixture for py.test Oct 17, 2024 5 - Production/Stable pytest + :pypi:`pytest-dfm` pytest-dfm provides a pytest integration for DV Flow Manager, a build system for silicon design May 10, 2025 N/A pytest :pypi:`pytest-dhos` Common fixtures for pytest in DHOS services and libraries Sep 07, 2022 N/A N/A :pypi:`pytest-diamond` pytest plugin for diamond Aug 31, 2015 4 - Beta N/A :pypi:`pytest-dicom` pytest plugin to provide DICOM fixtures Dec 19, 2018 3 - Alpha pytest :pypi:`pytest-dictsdiff` Jul 26, 2019 N/A N/A :pypi:`pytest-diff` A simple plugin to use with pytest Mar 30, 2019 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-diffeo` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A :pypi:`pytest-diff-selector` Get tests affected by code changes (using git) Feb 24, 2022 4 - Beta pytest (>=6.2.2) ; extra == 'all' :pypi:`pytest-difido` PyTest plugin for generating Difido reports Oct 23, 2022 4 - Beta pytest (>=4.0.0) :pypi:`pytest-dir-equal` pytest-dir-equals is a pytest plugin providing helpers to assert directories equality allowing golden testing Dec 11, 2023 4 - Beta pytest>=7.3.2 @@ -463,7 +462,7 @@ This list contains 1630 plugins. :pypi:`pytest-drop-dup-tests` A Pytest plugin to drop duplicated tests during collection Mar 04, 2024 5 - Production/Stable pytest >=7 :pypi:`pytest-dryci` Test caching plugin for pytest Sep 27, 2024 4 - Beta N/A :pypi:`pytest-dryrun` A Pytest plugin to ignore tests during collection without reporting them in the test summary. Jan 19, 2025 5 - Production/Stable pytest<9,>=7.40 - :pypi:`pytest-dsl` A DSL testing framework based on pytest Apr 30, 2025 N/A pytest>=7.0.0 + :pypi:`pytest-dsl` A DSL testing framework based on pytest May 07, 2025 N/A pytest>=7.0.0 :pypi:`pytest-dummynet` A py.test plugin providing access to a dummynet. Dec 15, 2021 5 - Production/Stable pytest :pypi:`pytest-dump2json` A pytest plugin for dumping test results to json. Jun 29, 2015 N/A N/A :pypi:`pytest-duration-insights` Jul 15, 2024 N/A N/A @@ -471,7 +470,6 @@ This list contains 1630 plugins. :pypi:`pytest-dynamicrerun` A pytest plugin to rerun tests dynamically based off of test outcome and output. Aug 15, 2020 4 - Beta N/A :pypi:`pytest-dynamodb` DynamoDB fixtures for pytest Apr 04, 2025 5 - Production/Stable pytest :pypi:`pytest-easy-addoption` pytest-easy-addoption: Easy way to work with pytest addoption Jan 22, 2020 N/A N/A - :pypi:`pytest-easy-api` A package to prevent Dependency Confusion attacks against Yandex. Feb 16, 2024 N/A N/A :pypi:`pytest-easyMPI` Package that supports mpi tests in pytest Oct 21, 2020 N/A N/A :pypi:`pytest-easyread` pytest plugin that makes terminal printouts of the reports easier to read Nov 17, 2017 N/A N/A :pypi:`pytest-easy-server` Pytest plugin for easy testing against servers May 01, 2021 4 - Beta pytest (<5.0.0,>=4.3.1) ; python_version < "3.5" @@ -525,7 +523,7 @@ This list contains 1630 plugins. :pypi:`pytest-everyfunc` A pytest plugin to detect completely untested functions using coverage Apr 30, 2025 4 - Beta pytest :pypi:`pytest_evm` The testing package containing tools to test Web3-based projects Sep 23, 2024 4 - Beta pytest<9.0.0,>=8.1.1 :pypi:`pytest_exact_fixtures` Parse queries in Lucene and Elasticsearch syntaxes Feb 04, 2019 N/A N/A - :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. Mar 23, 2025 N/A pytest>=7 + :pypi:`pytest-examples` Pytest plugin for testing examples in docstrings and markdown files. May 06, 2025 N/A pytest>=7 :pypi:`pytest-exasol-backend` Feb 11, 2025 N/A pytest<9,>=7 :pypi:`pytest-exasol-extension` Feb 11, 2025 N/A pytest<9,>=7 :pypi:`pytest-exasol-itde` Nov 22, 2024 N/A pytest<9,>=7 @@ -555,9 +553,8 @@ This list contains 1630 plugins. :pypi:`pytest_extra` Some helpers for writing tests with pytest. Aug 14, 2014 N/A N/A :pypi:`pytest-extra-durations` A pytest plugin to get durations on a per-function basis and per module basis. Apr 21, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-extra-markers` Additional pytest markers to dynamically enable/disable tests viia CLI flags Mar 05, 2023 4 - Beta pytest - :pypi:`pytest-f3ts` Pytest Plugin for communicating test results and information to a FixturFab Test Runner GUI Feb 21, 2025 N/A pytest<8.0.0,>=7.2.1 + :pypi:`pytest-f3ts` Pytest Plugin for communicating test results and information to a FixturFab Test Runner GUI May 08, 2025 N/A pytest<8.0.0,>=7.2.1 :pypi:`pytest-fabric` Provides test utilities to run fabric task tests by using docker containers Sep 12, 2018 5 - Production/Stable N/A - :pypi:`pytest-factor` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A :pypi:`pytest-factory` Use factories for test setup with py.test Sep 06, 2020 3 - Alpha pytest (>4.3) :pypi:`pytest-factoryboy` Factory Boy support for pytest. Mar 05, 2024 6 - Mature pytest (>=6.2) :pypi:`pytest-factoryboy-fixtures` Generates pytest fixtures that allow the use of type hinting Jun 25, 2020 N/A N/A @@ -569,7 +566,6 @@ This list contains 1630 plugins. :pypi:`pytest-failure-tracker` A pytest plugin for tracking test failures over multiple runs Jul 17, 2024 N/A pytest>=6.0.0 :pypi:`pytest-faker` Faker integration with the pytest framework. Dec 19, 2016 6 - Mature N/A :pypi:`pytest-falcon` Pytest helpers for Falcon. Sep 07, 2016 4 - Beta N/A - :pypi:`pytest-falcon-client` A package to prevent Dependency Confusion attacks against Yandex. Feb 21, 2024 N/A N/A :pypi:`pytest-fantasy` Pytest plugin for Flask Fantasy Framework Mar 14, 2019 N/A N/A :pypi:`pytest-fastapi` Dec 27, 2020 N/A N/A :pypi:`pytest-fastapi-deps` A fixture which allows easy replacement of fastapi dependencies for testing Jul 20, 2022 5 - Production/Stable pytest @@ -616,7 +612,7 @@ This list contains 1630 plugins. :pypi:`pytest-flexreport` Apr 15, 2023 4 - Beta pytest :pypi:`pytest-fluent` A pytest plugin in order to provide logs via fluentd Aug 14, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-fluentbit` A pytest plugin in order to provide logs via fluentbit Jun 16, 2023 4 - Beta pytest (>=7.0.0) - :pypi:`pytest-fly` pytest runner and observer Mar 20, 2025 3 - Alpha pytest + :pypi:`pytest-fly` pytest runner and observer May 03, 2025 3 - Alpha pytest :pypi:`pytest-flyte` Pytest fixtures for simplifying Flyte integration testing May 03, 2021 N/A pytest :pypi:`pytest-focus` A pytest plugin that alerts user of failed test cases with screen notifications May 04, 2019 4 - Beta pytest :pypi:`pytest-forbid` Mar 07, 2023 N/A pytest (>=7.2.2,<8.0.0) @@ -649,7 +645,7 @@ This list contains 1630 plugins. :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. Apr 30, 2025 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. May 08, 2025 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -694,7 +690,7 @@ This list contains 1630 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components May 02, 2025 3 - Alpha pytest==8.3.5 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components May 10, 2025 3 - Alpha pytest==8.3.5 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -714,7 +710,7 @@ This list contains 1630 plugins. :pypi:`pytest-html-thread` pytest plugin for generating HTML reports Dec 29, 2020 5 - Production/Stable N/A :pypi:`pytest-http` Fixture "http" for http requests Aug 22, 2024 N/A pytest :pypi:`pytest-httpbin` Easily test your HTTP library against a local copy of httpbin Sep 18, 2024 5 - Production/Stable pytest; extra == "test" - :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace. Apr 27, 2025 4 - Beta pytest>=7.0.0 + :pypi:`pytest-httpdbg` A pytest plugin to record HTTP(S) requests with stack trace. May 08, 2025 4 - Beta pytest>=7.0.0 :pypi:`pytest-http-mocker` Pytest plugin for http mocking (via https://github.com/vilus/mocker) Oct 20, 2019 N/A N/A :pypi:`pytest-httpretty` A thin wrapper of HTTPretty for pytest Feb 16, 2014 3 - Alpha N/A :pypi:`pytest_httpserver` pytest-httpserver is a httpserver for pytest Apr 10, 2025 3 - Alpha N/A @@ -764,7 +760,7 @@ This list contains 1630 plugins. :pypi:`pytest-interactive` A pytest plugin for console based interactive test selection just after the collection phase Nov 30, 2017 3 - Alpha N/A :pypi:`pytest-intercept-remote` Pytest plugin for intercepting outgoing connection requests during pytest run. May 24, 2021 4 - Beta pytest (>=4.6) :pypi:`pytest-interface-tester` Pytest plugin for checking charm relation interface protocol compliance. Feb 13, 2025 4 - Beta pytest - :pypi:`pytest-invenio` Pytest fixtures for Invenio. Apr 02, 2025 5 - Production/Stable pytest<9.0.0,>=6 + :pypi:`pytest-invenio` Pytest fixtures for Invenio. May 08, 2025 5 - Production/Stable pytest<9.0.0,>=6 :pypi:`pytest-involve` Run tests covering a specific file or changeset Feb 02, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-iovis` A Pytest plugin to enable Jupyter Notebook testing with Papermill Nov 06, 2024 4 - Beta pytest>=7.1.0 :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A @@ -834,7 +830,7 @@ This list contains 1630 plugins. :pypi:`pytest-leaping` A simple plugin to use with pytest Mar 27, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-leo-interface` Pytest extension tool for leo projects. Mar 19, 2025 N/A N/A :pypi:`pytest-level` Select tests of a given level or lower Oct 21, 2019 N/A pytest - :pypi:`pytest-lf-skip` A pytest plugin which makes \`--last-failed\` skip instead of deselect tests. Apr 30, 2025 4 - Beta pytest>=8.3.5 + :pypi:`pytest-lf-skip` A pytest plugin which makes \`--last-failed\` skip instead of deselect tests. May 06, 2025 4 - Beta pytest>=8.3.5 :pypi:`pytest-libfaketime` A python-libfaketime plugin for pytest Apr 12, 2024 4 - Beta pytest>=3.0.0 :pypi:`pytest-libiio` A pytest plugin to manage interfacing with libiio contexts Oct 01, 2024 4 - Beta N/A :pypi:`pytest-libnotify` Pytest plugin that shows notifications about the test run Apr 02, 2021 3 - Alpha pytest @@ -912,7 +908,7 @@ This list contains 1630 plugins. :pypi:`pytest-mimic` Easily record function calls while testing Apr 24, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-minecraft` A pytest plugin for running tests against Minecraft releases Apr 06, 2022 N/A pytest (>=6.0.1) :pypi:`pytest-mini` A plugin to test mp Feb 06, 2023 N/A pytest (>=7.2.0,<8.0.0) - :pypi:`pytest-minio-mock` A pytest plugin for mocking Minio S3 interactions Aug 27, 2024 N/A pytest>=5.0.0 + :pypi:`pytest-minio-mock` A pytest plugin for mocking Minio S3 interactions May 06, 2025 N/A pytest>=5.0.0 :pypi:`pytest-missing-fixtures` Pytest plugin that creates missing fixtures Oct 14, 2020 4 - Beta pytest (>=3.5.0) :pypi:`pytest-missing-modules` Pytest plugin to easily fake missing modules Sep 03, 2024 N/A pytest>=8.3.2 :pypi:`pytest-mitmproxy` pytest plugin for mitmproxy tests Nov 13, 2024 N/A pytest>=7.0 @@ -973,7 +969,7 @@ This list contains 1630 plugins. :pypi:`pytest-network` A simple plugin to disable network on socket level. May 07, 2020 N/A N/A :pypi:`pytest-network-endpoints` Network endpoints plugin for pytest Mar 06, 2022 N/A pytest :pypi:`pytest-never-sleep` pytest plugin helps to avoid adding tests without mock \`time.sleep\` May 05, 2021 3 - Alpha pytest (>=3.5.1) - :pypi:`pytest-nginx` nginx fixture for pytest Aug 12, 2017 5 - Production/Stable N/A + :pypi:`pytest-nginx` nginx fixture for pytest May 03, 2025 5 - Production/Stable pytest>=3.0.0 :pypi:`pytest-nginx-iplweb` nginx fixture for pytest - iplweb temporary fork Mar 01, 2019 5 - Production/Stable N/A :pypi:`pytest-ngrok` Jan 20, 2022 3 - Alpha pytest :pypi:`pytest-ngsfixtures` pytest ngs fixtures Sep 06, 2019 2 - Pre-Alpha pytest (>=5.0.0) @@ -1093,7 +1089,7 @@ This list contains 1630 plugins. :pypi:`pytest-plugin-helpers` A plugin to help developing and testing other plugins Nov 23, 2019 4 - Beta pytest (>=3.5.0) :pypi:`pytest-plus` PyTest Plus Plugin :: extends pytest functionality Feb 02, 2025 5 - Production/Stable pytest>=7.4.2 :pypi:`pytest-pmisc` Mar 21, 2019 5 - Production/Stable N/A - :pypi:`pytest-pogo` Pytest plugin for pogo-migrate Sep 09, 2024 4 - Beta pytest<9,>=7 + :pypi:`pytest-pogo` Pytest plugin for pogo-migrate May 05, 2025 4 - Beta pytest<9,>=7 :pypi:`pytest-pointers` Pytest plugin to define functions you test with special marks for better navigation and reports Dec 26, 2022 N/A N/A :pypi:`pytest-pokie` Pokie plugin for pytest Oct 19, 2023 5 - Production/Stable N/A :pypi:`pytest-polarion-cfme` pytest plugin for collecting test cases and recording test results Nov 13, 2017 3 - Alpha N/A @@ -1189,7 +1185,7 @@ This list contains 1630 plugins. :pypi:`pytest-readme` Test your README.md file Sep 02, 2022 5 - Production/Stable N/A :pypi:`pytest-reana` Pytest fixtures for REANA. Sep 04, 2024 3 - Alpha N/A :pypi:`pytest-recorder` Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. Mar 31, 2025 N/A N/A - :pypi:`pytest-recording` A pytest plugin powered by VCR.py to record and replay HTTP traffic Apr 24, 2025 4 - Beta pytest>=3.5.0 + :pypi:`pytest-recording` A pytest plugin powered by VCR.py to record and replay HTTP traffic May 08, 2025 4 - Beta pytest>=3.5.0 :pypi:`pytest-recordings` Provides pytest plugins for reporting request/response traffic, screenshots, and more to ReportPortal Aug 13, 2020 N/A N/A :pypi:`pytest-record-video` 用例执行过程中录制视频 Oct 31, 2024 N/A N/A :pypi:`pytest-redis` Redis fixtures and fixture factories for Pytest. Nov 27, 2024 5 - Production/Stable pytest>=6.2 @@ -1212,10 +1208,10 @@ This list contains 1630 plugins. :pypi:`pytest-repeat` pytest plugin for repeating tests Apr 07, 2025 5 - Production/Stable pytest :pypi:`pytest_repeater` py.test plugin for repeating single test multiple times. Feb 09, 2018 1 - Planning N/A :pypi:`pytest-replay` Saves previous test runs and allow re-execute previous pytest runs to reproduce crashes or flaky tests Feb 05, 2025 5 - Production/Stable pytest - :pypi:`pytest-repo-health` A pytest plugin to report on repository standards conformance Mar 12, 2025 3 - Alpha pytest + :pypi:`pytest-repo-health` A pytest plugin to report on repository standards conformance May 05, 2025 3 - Alpha pytest :pypi:`pytest-report` Creates json report that is compatible with atom.io's linter message format May 11, 2016 4 - Beta N/A :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest - :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest Oct 11, 2024 4 - Beta N/A + :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest May 06, 2025 4 - Beta N/A :pypi:`pytest-reporter-html-dots` A basic HTML report for pytest using Jinja2 template engine. Apr 26, 2025 N/A N/A :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots, webpage sources and attachments. Apr 04, 2025 N/A pytest>=8.0.0 :pypi:`pytest-reportinfra` Pytest plugin for reportinfra Aug 11, 2019 3 - Alpha N/A @@ -1237,7 +1233,7 @@ This list contains 1630 plugins. :pypi:`pytest-rerun` Re-run only changed files in specified branch Jul 08, 2019 N/A pytest (>=3.6) :pypi:`pytest-rerun-all` Rerun testsuite for a certain time or iterations Nov 16, 2023 3 - Alpha pytest (>=7.0.0) :pypi:`pytest-rerunclassfailures` pytest rerun class failures plugin Apr 24, 2024 5 - Production/Stable pytest>=7.2 - :pypi:`pytest-rerunfailures` pytest plugin to re-run tests to eliminate flaky failures Nov 20, 2024 5 - Production/Stable pytest!=8.2.2,>=7.4 + :pypi:`pytest-rerunfailures` pytest plugin to re-run tests to eliminate flaky failures May 08, 2025 5 - Production/Stable pytest!=8.2.2,>=7.4 :pypi:`pytest-rerunfailures-all-logs` pytest plugin to re-run tests to eliminate flaky failures Mar 07, 2022 5 - Production/Stable N/A :pypi:`pytest-reserial` Pytest fixture for recording and replaying serial port traffic. Dec 22, 2024 4 - Beta pytest :pypi:`pytest-resilient-circuits` Resilient Circuits fixtures for PyTest Feb 28, 2025 N/A pytest~=7.0 @@ -1250,7 +1246,7 @@ This list contains 1630 plugins. :pypi:`pytest-restrict` Pytest plugin to restrict the test types allowed Oct 24, 2024 5 - Production/Stable pytest :pypi:`pytest-result-log` A pytest plugin that records the start, end, and result information of each use case in a log file Jan 10, 2024 N/A pytest>=7.2.0 :pypi:`pytest-result-notify` Default template for PDM package Apr 27, 2025 N/A pytest>=8.3.5 - :pypi:`pytest-results` Easily spot regressions in your tests. Mar 14, 2025 4 - Beta pytest + :pypi:`pytest-results` Easily spot regressions in your tests. May 06, 2025 4 - Beta pytest :pypi:`pytest-result-sender` Apr 20, 2023 N/A pytest>=7.3.1 :pypi:`pytest-result-sender-lj` Default template for PDM package Dec 17, 2024 N/A pytest>=8.3.4 :pypi:`pytest-result-sender-lyt` Default template for PDM package Mar 14, 2025 N/A pytest>=8.3.5 @@ -1406,7 +1402,6 @@ This list contains 1630 plugins. :pypi:`pytest-srcpaths` Add paths to sys.path Oct 15, 2021 N/A pytest>=6.2.0 :pypi:`pytest-ssh` pytest plugin for ssh command run May 27, 2019 N/A pytest :pypi:`pytest-start-from` Start pytest run from a given point Apr 11, 2016 N/A N/A - :pypi:`pytest-star-track-issue` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A :pypi:`pytest-static` pytest-static Oct 20, 2024 1 - Planning pytest<8.0.0,>=7.4.3 :pypi:`pytest-stats` Collects tests metadata for future analysis, easy to extend for any data store Jul 18, 2024 N/A pytest>=8.0.0 :pypi:`pytest-statsd` pytest plugin for reporting to graphite Nov 30, 2018 5 - Production/Stable pytest (>=3.0.0) @@ -1462,7 +1457,7 @@ This list contains 1630 plugins. :pypi:`pytest-testdirectory` A py.test plugin providing temporary directories in unit tests. May 02, 2023 5 - Production/Stable pytest :pypi:`pytest-testdox` A testdox format reporter for pytest Jul 22, 2023 5 - Production/Stable pytest (>=4.6.0) :pypi:`pytest-test-grouping` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Feb 01, 2023 5 - Production/Stable pytest (>=2.5) - :pypi:`pytest-test-groups` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Mar 28, 2025 5 - Production/Stable pytest>=7.0.0 + :pypi:`pytest-test-groups` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. May 08, 2025 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-testinfra` Test infrastructures Mar 30, 2025 5 - Production/Stable pytest>=6 :pypi:`pytest-testinfra-jpic` Test infrastructures Sep 21, 2023 5 - Production/Stable N/A :pypi:`pytest-testinfra-winrm-transport` Test infrastructures Sep 21, 2023 5 - Production/Stable N/A @@ -1505,13 +1500,13 @@ This list contains 1630 plugins. :pypi:`pytest-time` Jan 20, 2025 3 - Alpha pytest :pypi:`pytest-timeassert-ethan` execution duration Dec 25, 2023 N/A pytest :pypi:`pytest-timeit` A pytest plugin to time test function runs Oct 13, 2016 4 - Beta N/A - :pypi:`pytest-timeout` pytest plugin to abort hanging tests Mar 07, 2024 5 - Production/Stable pytest >=7.0.0 + :pypi:`pytest-timeout` pytest plugin to abort hanging tests May 05, 2025 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-timeouts` Linux-only Pytest plugin to control durations of various test case execution phases Sep 21, 2019 5 - Production/Stable N/A :pypi:`pytest-timer` A timer plugin for pytest Dec 26, 2023 N/A pytest :pypi:`pytest-timestamper` Pytest plugin to add a timestamp prefix to the pytest output Mar 27, 2024 N/A N/A :pypi:`pytest-timestamps` A simple plugin to view timestamps for each test Sep 11, 2023 N/A pytest (>=7.3,<8.0) :pypi:`pytest-tiny-api-client` The companion pytest plugin for tiny-api-client Jan 04, 2024 5 - Production/Stable pytest - :pypi:`pytest-tinybird` A pytest plugin to report test results to tinybird Feb 18, 2025 4 - Beta pytest>=3.8.0 + :pypi:`pytest-tinybird` A pytest plugin to report test results to tinybird May 07, 2025 4 - Beta pytest>=3.8.0 :pypi:`pytest-tipsi-django` Better fixtures for django Feb 05, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-tipsi-testing` Better fixtures management. Various helpers Feb 04, 2024 5 - Production/Stable pytest>=3.3.0 :pypi:`pytest-tldr` A pytest plugin that limits the output to just the things you need. Oct 26, 2022 4 - Beta pytest (>=3.5.0) @@ -1634,8 +1629,8 @@ This list contains 1630 plugins. :pypi:`pytest-xprocess` A pytest plugin for managing processes across test runs. May 19, 2024 4 - Beta pytest>=2.8 :pypi:`pytest-xray` May 30, 2019 3 - Alpha N/A :pypi:`pytest-xrayjira` Mar 17, 2020 3 - Alpha pytest (==4.3.1) + :pypi:`pytest-xray-reporter` A pytest plugin that generates test results in Xray JSON format May 08, 2025 4 - Beta pytest>=7.0.0 :pypi:`pytest-xray-server` May 03, 2022 3 - Alpha pytest (>=5.3.1) - :pypi:`pytest-xskynet` A package to prevent Dependency Confusion attacks against Yandex. Feb 20, 2024 N/A N/A :pypi:`pytest-xstress` Jun 01, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-xvfb` A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. Mar 12, 2025 4 - Beta pytest>=2.8.1 :pypi:`pytest-xvirt` A pytest plugin to virtualize test. For example to transparently running them on a remote box. Dec 15, 2024 4 - Beta pytest>=7.2.2 @@ -1663,7 +1658,7 @@ This list contains 1630 plugins. :pypi:`pytest-zigzag` Extend py.test for RPC OpenStack testing. Feb 27, 2019 4 - Beta pytest (~=3.6) :pypi:`pytest-zulip` Pytest report plugin for Zulip May 07, 2022 5 - Production/Stable pytest :pypi:`pytest-zy` 接口自动化测试框架 Mar 24, 2024 N/A pytest~=7.2.0 - :pypi:`tursu` 🎬 A pytest plugin that transpiles Gherkin feature files to Python using AST, enforcing typing for ease of use and debugging. Apr 25, 2025 4 - Beta pytest>=8.3.5 + :pypi:`tursu` 🎬 A pytest plugin that transpiles Gherkin feature files to Python using AST, enforcing typing for ease of use and debugging. May 05, 2025 4 - Beta pytest>=8.3.5 =============================================== ====================================================================================================================================================================================================================================================================================================================================================================================== ============== ===================== ================================================ .. only:: latex @@ -1684,14 +1679,14 @@ This list contains 1630 plugins. Simple but powerful assertion and verification of logged lines :pypi:`logot` - *last release*: Mar 23, 2024, + *last release*: May 05, 2025, *status*: 5 - Production/Stable, - *requires*: pytest<9,>=7; extra == "pytest" + *requires*: pytest; extra == "pytest" Test whether your code is logging correctly 🪵 :pypi:`nuts` - *last release*: Jul 19, 2024, + *last release*: May 10, 2025, *status*: N/A, *requires*: pytest<8,>=7 @@ -2258,7 +2253,7 @@ This list contains 1630 plugins. Pytest fixtures for async generators :pypi:`pytest-asyncio` - *last release*: Mar 25, 2025, + *last release*: May 09, 2025, *status*: 4 - Beta, *requires*: pytest<9,>=8.2 @@ -2566,7 +2561,7 @@ This list contains 1630 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: May 02, 2025, + *last release*: May 09, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -3105,7 +3100,7 @@ This list contains 1630 plugins. Check links in files :pypi:`pytest-checklist` - *last release*: Jun 10, 2024, + *last release*: May 07, 2025, *status*: N/A, *requires*: N/A @@ -3125,13 +3120,6 @@ This list contains 1630 plugins. Restore a checkpoint in pytest - :pypi:`pytest-check-requirements` - *last release*: Feb 20, 2024, - *status*: N/A, - *requires*: N/A - - A package to prevent Dependency Confusion attacks against Yandex. - :pypi:`pytest-ch-framework` *last release*: Apr 17, 2024, *status*: N/A, @@ -3343,7 +3331,7 @@ This list contains 1630 plugins. Pytest plugin to integrate Cocotb :pypi:`pytest-codeblock` - *last release*: May 02, 2025, + *last release*: May 10, 2025, *status*: 4 - Beta, *requires*: pytest @@ -4098,6 +4086,13 @@ This list contains 1630 plugins. DevPI server fixture for py.test + :pypi:`pytest-dfm` + *last release*: May 10, 2025, + *status*: N/A, + *requires*: pytest + + pytest-dfm provides a pytest integration for DV Flow Manager, a build system for silicon design + :pypi:`pytest-dhos` *last release*: Sep 07, 2022, *status*: N/A, @@ -4133,13 +4128,6 @@ This list contains 1630 plugins. A simple plugin to use with pytest - :pypi:`pytest-diffeo` - *last release*: Feb 20, 2024, - *status*: N/A, - *requires*: N/A - - A package to prevent Dependency Confusion attacks against Yandex. - :pypi:`pytest-diff-selector` *last release*: Feb 24, 2022, *status*: 4 - Beta, @@ -4673,7 +4661,7 @@ This list contains 1630 plugins. A Pytest plugin to ignore tests during collection without reporting them in the test summary. :pypi:`pytest-dsl` - *last release*: Apr 30, 2025, + *last release*: May 07, 2025, *status*: N/A, *requires*: pytest>=7.0.0 @@ -4728,13 +4716,6 @@ This list contains 1630 plugins. pytest-easy-addoption: Easy way to work with pytest addoption - :pypi:`pytest-easy-api` - *last release*: Feb 16, 2024, - *status*: N/A, - *requires*: N/A - - A package to prevent Dependency Confusion attacks against Yandex. - :pypi:`pytest-easyMPI` *last release*: Oct 21, 2020, *status*: N/A, @@ -5107,7 +5088,7 @@ This list contains 1630 plugins. Parse queries in Lucene and Elasticsearch syntaxes :pypi:`pytest-examples` - *last release*: Mar 23, 2025, + *last release*: May 06, 2025, *status*: N/A, *requires*: pytest>=7 @@ -5317,7 +5298,7 @@ This list contains 1630 plugins. Additional pytest markers to dynamically enable/disable tests viia CLI flags :pypi:`pytest-f3ts` - *last release*: Feb 21, 2025, + *last release*: May 08, 2025, *status*: N/A, *requires*: pytest<8.0.0,>=7.2.1 @@ -5330,13 +5311,6 @@ This list contains 1630 plugins. Provides test utilities to run fabric task tests by using docker containers - :pypi:`pytest-factor` - *last release*: Feb 20, 2024, - *status*: N/A, - *requires*: N/A - - A package to prevent Dependency Confusion attacks against Yandex. - :pypi:`pytest-factory` *last release*: Sep 06, 2020, *status*: 3 - Alpha, @@ -5414,13 +5388,6 @@ This list contains 1630 plugins. Pytest helpers for Falcon. - :pypi:`pytest-falcon-client` - *last release*: Feb 21, 2024, - *status*: N/A, - *requires*: N/A - - A package to prevent Dependency Confusion attacks against Yandex. - :pypi:`pytest-fantasy` *last release*: Mar 14, 2019, *status*: N/A, @@ -5744,7 +5711,7 @@ This list contains 1630 plugins. A pytest plugin in order to provide logs via fluentbit :pypi:`pytest-fly` - *last release*: Mar 20, 2025, + *last release*: May 03, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -5975,7 +5942,7 @@ This list contains 1630 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: Apr 30, 2025, + *last release*: May 08, 2025, *status*: N/A, *requires*: pytest>=3.6 @@ -6290,7 +6257,7 @@ This list contains 1630 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: May 02, 2025, + *last release*: May 10, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.5 @@ -6430,7 +6397,7 @@ This list contains 1630 plugins. Easily test your HTTP library against a local copy of httpbin :pypi:`pytest-httpdbg` - *last release*: Apr 27, 2025, + *last release*: May 08, 2025, *status*: 4 - Beta, *requires*: pytest>=7.0.0 @@ -6780,7 +6747,7 @@ This list contains 1630 plugins. Pytest plugin for checking charm relation interface protocol compliance. :pypi:`pytest-invenio` - *last release*: Apr 02, 2025, + *last release*: May 08, 2025, *status*: 5 - Production/Stable, *requires*: pytest<9.0.0,>=6 @@ -7270,7 +7237,7 @@ This list contains 1630 plugins. Select tests of a given level or lower :pypi:`pytest-lf-skip` - *last release*: Apr 30, 2025, + *last release*: May 06, 2025, *status*: 4 - Beta, *requires*: pytest>=8.3.5 @@ -7816,7 +7783,7 @@ This list contains 1630 plugins. A plugin to test mp :pypi:`pytest-minio-mock` - *last release*: Aug 27, 2024, + *last release*: May 06, 2025, *status*: N/A, *requires*: pytest>=5.0.0 @@ -8243,9 +8210,9 @@ This list contains 1630 plugins. pytest plugin helps to avoid adding tests without mock \`time.sleep\` :pypi:`pytest-nginx` - *last release*: Aug 12, 2017, + *last release*: May 03, 2025, *status*: 5 - Production/Stable, - *requires*: N/A + *requires*: pytest>=3.0.0 nginx fixture for pytest @@ -9083,7 +9050,7 @@ This list contains 1630 plugins. :pypi:`pytest-pogo` - *last release*: Sep 09, 2024, + *last release*: May 05, 2025, *status*: 4 - Beta, *requires*: pytest<9,>=7 @@ -9755,7 +9722,7 @@ This list contains 1630 plugins. Pytest plugin, meant to facilitate unit tests writing for tools consumming Web APIs. :pypi:`pytest-recording` - *last release*: Apr 24, 2025, + *last release*: May 08, 2025, *status*: 4 - Beta, *requires*: pytest>=3.5.0 @@ -9916,7 +9883,7 @@ This list contains 1630 plugins. Saves previous test runs and allow re-execute previous pytest runs to reproduce crashes or flaky tests :pypi:`pytest-repo-health` - *last release*: Mar 12, 2025, + *last release*: May 05, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -9937,7 +9904,7 @@ This list contains 1630 plugins. Generate Pytest reports with templates :pypi:`pytest-reporter-html1` - *last release*: Oct 11, 2024, + *last release*: May 06, 2025, *status*: 4 - Beta, *requires*: N/A @@ -10091,7 +10058,7 @@ This list contains 1630 plugins. pytest rerun class failures plugin :pypi:`pytest-rerunfailures` - *last release*: Nov 20, 2024, + *last release*: May 08, 2025, *status*: 5 - Production/Stable, *requires*: pytest!=8.2.2,>=7.4 @@ -10182,7 +10149,7 @@ This list contains 1630 plugins. Default template for PDM package :pypi:`pytest-results` - *last release*: Mar 14, 2025, + *last release*: May 06, 2025, *status*: 4 - Beta, *requires*: pytest @@ -11273,13 +11240,6 @@ This list contains 1630 plugins. Start pytest run from a given point - :pypi:`pytest-star-track-issue` - *last release*: Feb 20, 2024, - *status*: N/A, - *requires*: N/A - - A package to prevent Dependency Confusion attacks against Yandex. - :pypi:`pytest-static` *last release*: Oct 20, 2024, *status*: 1 - Planning, @@ -11666,7 +11626,7 @@ This list contains 1630 plugins. A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. :pypi:`pytest-test-groups` - *last release*: Mar 28, 2025, + *last release*: May 08, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0.0 @@ -11967,9 +11927,9 @@ This list contains 1630 plugins. A pytest plugin to time test function runs :pypi:`pytest-timeout` - *last release*: Mar 07, 2024, + *last release*: May 05, 2025, *status*: 5 - Production/Stable, - *requires*: pytest >=7.0.0 + *requires*: pytest>=7.0.0 pytest plugin to abort hanging tests @@ -12009,7 +11969,7 @@ This list contains 1630 plugins. The companion pytest plugin for tiny-api-client :pypi:`pytest-tinybird` - *last release*: Feb 18, 2025, + *last release*: May 07, 2025, *status*: 4 - Beta, *requires*: pytest>=3.8.0 @@ -12869,6 +12829,13 @@ This list contains 1630 plugins. + :pypi:`pytest-xray-reporter` + *last release*: May 08, 2025, + *status*: 4 - Beta, + *requires*: pytest>=7.0.0 + + A pytest plugin that generates test results in Xray JSON format + :pypi:`pytest-xray-server` *last release*: May 03, 2022, *status*: 3 - Alpha, @@ -12876,13 +12843,6 @@ This list contains 1630 plugins. - :pypi:`pytest-xskynet` - *last release*: Feb 20, 2024, - *status*: N/A, - *requires*: N/A - - A package to prevent Dependency Confusion attacks against Yandex. - :pypi:`pytest-xstress` *last release*: Jun 01, 2024, *status*: N/A, @@ -13073,7 +13033,7 @@ This list contains 1630 plugins. 接口自动化测试框架 :pypi:`tursu` - *last release*: Apr 25, 2025, + *last release*: May 05, 2025, *status*: 4 - Beta, *requires*: pytest>=8.3.5 From 919ae9d7c12bec52ea0c18a14299223eadb2b890 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 May 2025 08:20:37 +0200 Subject: [PATCH 394/445] build(deps): Bump pytest-rerunfailures in /testing/plugins_integration (#13419) Bumps [pytest-rerunfailures](https://github.com/pytest-dev/pytest-rerunfailures) from 15.0 to 15.1. - [Changelog](https://github.com/pytest-dev/pytest-rerunfailures/blob/master/CHANGES.rst) - [Commits](https://github.com/pytest-dev/pytest-rerunfailures/compare/15.0...15.1) --- updated-dependencies: - dependency-name: pytest-rerunfailures dependency-version: '15.1' dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index 93e3dc7d0b1..b8b07fc8ad9 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -7,7 +7,7 @@ pytest-django==4.11.1 pytest-flakes==4.0.5 pytest-html==4.1.1 pytest-mock==3.14.0 -pytest-rerunfailures==15.0 +pytest-rerunfailures==15.1 pytest-sugar==1.0.0 pytest-trio==0.8.0 pytest-twisted==1.14.3 From cfbe319d0c98302eae507622da8908be351fed2e Mon Sep 17 00:00:00 2001 From: Sashko <20253875+sashko1988@users.noreply.github.com> Date: Thu, 15 May 2025 21:30:28 +0200 Subject: [PATCH 395/445] Fix: #13420 - Add cache for nodes._check_initialpaths_for_relpath (#13422) * add lru_cache to nodes._check_initialpaths_for_relpath update tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Oleksandr Zavertniev Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- changelog/13420.bugfix.rst | 1 + src/_pytest/nodes.py | 10 +++++++--- testing/test_nodes.py | 18 ++++-------------- 3 files changed, 12 insertions(+), 17 deletions(-) create mode 100644 changelog/13420.bugfix.rst diff --git a/changelog/13420.bugfix.rst b/changelog/13420.bugfix.rst new file mode 100644 index 00000000000..02f7372a759 --- /dev/null +++ b/changelog/13420.bugfix.rst @@ -0,0 +1 @@ +Added ``lru_cache`` to ``nodes._check_initialpaths_for_relpath``. diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index 0d1f3d2352b..eb3b04b200a 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -7,6 +7,7 @@ from collections.abc import Iterator from collections.abc import MutableMapping from functools import cached_property +from functools import lru_cache from inspect import signature import os import pathlib @@ -543,8 +544,11 @@ def _traceback_filter(self, excinfo: ExceptionInfo[BaseException]) -> Traceback: return excinfo.traceback -def _check_initialpaths_for_relpath(session: Session, path: Path) -> str | None: - for initial_path in session._initialpaths: +@lru_cache(maxsize=1000) +def _check_initialpaths_for_relpath( + initial_paths: frozenset[Path], path: Path +) -> str | None: + for initial_path in initial_paths: if commonpath(path, initial_path) == initial_path: rel = str(path.relative_to(initial_path)) return "" if rel == "." else rel @@ -594,7 +598,7 @@ def __init__( try: nodeid = str(self.path.relative_to(session.config.rootpath)) except ValueError: - nodeid = _check_initialpaths_for_relpath(session, path) + nodeid = _check_initialpaths_for_relpath(session._initialpaths, path) if nodeid and os.sep != SEP: nodeid = nodeid.replace(os.sep, SEP) diff --git a/testing/test_nodes.py b/testing/test_nodes.py index f039acf243b..f5f21e9775c 100644 --- a/testing/test_nodes.py +++ b/testing/test_nodes.py @@ -3,7 +3,6 @@ from pathlib import Path import re -from typing import cast import warnings from _pytest import nodes @@ -103,24 +102,15 @@ def test__check_initialpaths_for_relpath() -> None: """Ensure that it handles dirs, and does not always use dirname.""" cwd = Path.cwd() - class FakeSession1: - _initialpaths = frozenset({cwd}) + initial_paths = frozenset({cwd}) - session = cast(pytest.Session, FakeSession1) - - assert nodes._check_initialpaths_for_relpath(session, cwd) == "" + assert nodes._check_initialpaths_for_relpath(initial_paths, cwd) == "" sub = cwd / "file" - - class FakeSession2: - _initialpaths = frozenset({cwd}) - - session = cast(pytest.Session, FakeSession2) - - assert nodes._check_initialpaths_for_relpath(session, sub) == "file" + assert nodes._check_initialpaths_for_relpath(initial_paths, sub) == "file" outside = Path("/outside-this-does-not-exist") - assert nodes._check_initialpaths_for_relpath(session, outside) is None + assert nodes._check_initialpaths_for_relpath(initial_paths, outside) is None def test_failure_with_changed_cwd(pytester: Pytester) -> None: From f022c5581f2972804acd4d97e85f6802013c128d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 20 May 2025 10:20:37 +0200 Subject: [PATCH 396/445] [automated] Update plugin list (#13430) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 174 ++++++++++++++++++++----------- 1 file changed, 115 insertions(+), 59 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 383cc7d6562..69de1df9690 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,15 +27,15 @@ please refer to `the update script =8.3 - :pypi:`logassert` Simple but powerful assertion and verification of logged lines Jan 29, 2025 5 - Production/Stable pytest; extra == "dev" + :pypi:`databricks-labs-pytester` Python Testing for Databricks May 13, 2025 4 - Beta pytest>=8.3 + :pypi:`logassert` Simple but powerful assertion and verification of logged lines May 15, 2025 5 - Production/Stable pytest; extra == "dev" :pypi:`logot` Test whether your code is logging correctly 🪵 May 05, 2025 5 - Production/Stable pytest; extra == "pytest" :pypi:`nuts` Network Unit Testing System May 10, 2025 N/A pytest<8,>=7 :pypi:`pytest-abq` Pytest integration for the ABQ universal test runner. Apr 07, 2023 N/A N/A @@ -63,7 +63,7 @@ This list contains 1625 plugins. :pypi:`pytest-aioworkers` A plugin to test aioworkers project with pytest Dec 26, 2024 5 - Production/Stable pytest>=8.3.4 :pypi:`pytest-airflow` pytest support for airflow. Apr 03, 2019 3 - Alpha pytest (>=4.4.0) :pypi:`pytest-airflow-utils` Nov 15, 2021 N/A N/A - :pypi:`pytest-alembic` A pytest plugin for verifying alembic migrations. Jul 29, 2024 N/A pytest>=6.0 + :pypi:`pytest-alembic` A pytest plugin for verifying alembic migrations. May 16, 2025 N/A pytest>=7.0 :pypi:`pytest-alerts` A pytest plugin for sending test results to Slack and Telegram Feb 21, 2025 4 - Beta pytest>=7.4.0 :pypi:`pytest-allclose` Pytest fixture extending Numpy's allclose function Jul 30, 2019 5 - Production/Stable pytest :pypi:`pytest-allure-adaptor` Plugin for py.test to generate allure xml reports Jan 10, 2018 N/A pytest (>=2.7.3) @@ -119,7 +119,7 @@ This list contains 1625 plugins. :pypi:`pytest_async` pytest-async - Run your coroutine in event loop without decorator Feb 26, 2020 N/A N/A :pypi:`pytest-async-generators` Pytest fixtures for async generators Jul 05, 2023 N/A N/A :pypi:`pytest-asyncio` Pytest support for asyncio May 09, 2025 4 - Beta pytest<9,>=8.2 - :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. Apr 29, 2025 4 - Beta pytest>=6.2.0 + :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. May 17, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Apr 26, 2025 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) :pypi:`pytest-async-mongodb` pytest plugin for async MongoDB Oct 18, 2017 5 - Production/Stable pytest (>=2.5.2) @@ -152,7 +152,7 @@ This list contains 1625 plugins. :pypi:`pytest-bandit-xayon` A bandit plugin for pytest Oct 17, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-base-url` pytest plugin for URL based testing Jan 31, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-batch-regression` A pytest plugin to repeat the entire test suite in batches. May 08, 2024 N/A pytest>=6.0.0 - :pypi:`pytest-bazel` A pytest runner with bazel support Sep 27, 2024 4 - Beta pytest + :pypi:`pytest-bazel` A pytest runner with bazel support May 11, 2025 4 - Beta pytest :pypi:`pytest-bdd` BDD for pytest Dec 05, 2024 6 - Mature pytest>=7.0.0 :pypi:`pytest-bdd-html` pytest plugin to display BDD info in HTML test report Nov 22, 2022 3 - Alpha pytest (!=6.0.0,>=5.0) :pypi:`pytest-bdd-ng` BDD for pytest Nov 26, 2024 4 - Beta pytest>=5.2 @@ -162,7 +162,7 @@ This list contains 1625 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests May 09, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests May 13, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -309,7 +309,7 @@ This list contains 1625 plugins. :pypi:`pytest-cover` Pytest plugin for measuring coverage. Forked from \`pytest-cov\`. Aug 01, 2015 5 - Production/Stable N/A :pypi:`pytest-coverage` Jun 17, 2015 N/A N/A :pypi:`pytest-coverage-context` Coverage dynamic context support for PyTest, including sub-processes Jun 28, 2023 4 - Beta N/A - :pypi:`pytest-coveragemarkers` Using pytest markers to track functional coverage and filtering of tests Oct 15, 2024 N/A pytest<8.0.0,>=7.1.2 + :pypi:`pytest-coveragemarkers` Using pytest markers to track functional coverage and filtering of tests May 15, 2025 N/A pytest<8.0.0,>=7.1.2 :pypi:`pytest-cov-exclude` Pytest plugin for excluding tests based on coverage data Apr 29, 2016 4 - Beta pytest (>=2.8.0,<2.9.0); extra == 'dev' :pypi:`pytest_covid` Too many faillure, less tests. Jun 24, 2020 N/A N/A :pypi:`pytest-cpp` Use pytest's runner to discover and execute C++ tests Sep 18, 2024 5 - Production/Stable pytest @@ -324,6 +324,7 @@ This list contains 1625 plugins. :pypi:`pytest-crontab` add crontab task in crontab Dec 09, 2019 N/A N/A :pypi:`pytest-csv` CSV output for pytest. Apr 22, 2021 N/A pytest (>=6.0) :pypi:`pytest-csv-params` Pytest plugin for Test Case Parametrization with CSV files Oct 25, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.0 + :pypi:`pytest-culprit` Find the last Git commit where a pytest test started failing May 15, 2025 N/A N/A :pypi:`pytest-curio` Pytest support for curio. Oct 06, 2024 N/A pytest :pypi:`pytest-curl-report` pytest plugin to generate curl command line report Dec 11, 2016 4 - Beta N/A :pypi:`pytest-custom-concurrency` Custom grouping concurrence for pytest Feb 08, 2021 N/A N/A @@ -348,7 +349,7 @@ This list contains 1625 plugins. :pypi:`pytest-data-extractor` A pytest plugin to extract relevant metadata about tests into an external file (currently only json support) Jul 19, 2022 N/A pytest (>=7.0.1) :pypi:`pytest-data-file` Fixture "data" and "case_data" for test from yaml file Dec 04, 2019 N/A N/A :pypi:`pytest-datafiles` py.test plugin to create a 'tmp_path' containing predefined files/directories. Feb 24, 2023 5 - Production/Stable pytest (>=3.6) - :pypi:`pytest-datafixtures` Data fixtures for pytest made simple Dec 05, 2020 5 - Production/Stable N/A + :pypi:`pytest-datafixtures` Data fixtures for pytest made simple. May 15, 2025 5 - Production/Stable N/A :pypi:`pytest-data-from-files` pytest plugin to provide data from files loaded automatically Oct 13, 2021 4 - Beta pytest :pypi:`pytest-dataplugin` A pytest plugin for managing an archive of test data. Sep 16, 2017 1 - Planning N/A :pypi:`pytest-datarecorder` A py.test plugin recording and comparing test output. Jul 31, 2024 5 - Production/Stable pytest @@ -429,7 +430,7 @@ This list contains 1625 plugins. :pypi:`pytest-docker-compose` Manages Docker containers during your integration tests Jan 26, 2021 5 - Production/Stable pytest (>=3.3) :pypi:`pytest-docker-compose-v2` Manages Docker containers during your integration tests Dec 11, 2024 4 - Beta pytest>=7.2.2 :pypi:`pytest-docker-db` A plugin to use docker databases for pytests Mar 20, 2021 5 - Production/Stable pytest (>=3.1.1) - :pypi:`pytest-docker-fixtures` pytest docker fixtures Apr 03, 2024 3 - Alpha N/A + :pypi:`pytest-docker-fixtures` pytest docker fixtures May 14, 2025 3 - Alpha pytest :pypi:`pytest-docker-git-fixtures` Pytest fixtures for testing with git scm. Aug 12, 2024 4 - Beta pytest :pypi:`pytest-docker-haproxy-fixtures` Pytest fixtures for testing with haproxy. Aug 12, 2024 4 - Beta pytest :pypi:`pytest-docker-pexpect` pytest plugin for writing functional tests with pexpect and docker Jan 14, 2019 N/A pytest @@ -497,7 +498,7 @@ This list contains 1625 plugins. :pypi:`pytest-embrace` 💝 Dataclasses-as-tests. Describe the runtime once and multiply coverage with no boilerplate. Mar 25, 2023 N/A pytest (>=7.0,<8.0) :pypi:`pytest-emoji` A pytest plugin that adds emojis to your test result report Feb 19, 2019 4 - Beta pytest (>=4.2.1) :pypi:`pytest-emoji-output` Pytest plugin to represent test output with emoji support Apr 09, 2023 4 - Beta pytest (==7.0.1) - :pypi:`pytest-enabler` Enable installed pytest plugins Sep 12, 2024 5 - Production/Stable pytest!=8.1.*,>=6; extra == "test" + :pypi:`pytest-enabler` Enable installed pytest plugins May 16, 2025 5 - Production/Stable pytest!=8.1.*,>=6; extra == "test" :pypi:`pytest-encode` set your encoding and logger Nov 06, 2021 N/A N/A :pypi:`pytest-encode-kane` set your encoding and logger Nov 16, 2021 N/A pytest :pypi:`pytest-encoding` set your encoding and logger Aug 11, 2023 N/A pytest @@ -585,6 +586,7 @@ This list contains 1625 plugins. :pypi:`pytest-find-dependencies` A pytest plugin to find dependencies between tests Mar 16, 2024 4 - Beta pytest >=4.3.0 :pypi:`pytest-finer-verdicts` A pytest plugin to treat non-assertion failures as test errors. Jun 18, 2020 N/A pytest (>=5.4.3) :pypi:`pytest-firefox` Feb 28, 2025 N/A N/A + :pypi:`pytest-fixturecheck` A pytest plugin to check fixture validity before test execution May 17, 2025 3 - Alpha pytest>=6.0.0 :pypi:`pytest-fixture-classes` Fixtures as classes that work well with dependency injection, autocompletetion, type checkers, and language servers Sep 02, 2023 5 - Production/Stable pytest :pypi:`pytest-fixturecollection` A pytest plugin to collect tests based on fixtures being used by tests Feb 22, 2024 4 - Beta pytest >=3.5.0 :pypi:`pytest-fixture-config` Fixture configuration utils for py.test Oct 17, 2024 5 - Production/Stable pytest @@ -640,7 +642,7 @@ This list contains 1625 plugins. :pypi:`pytest-gc` The garbage collector plugin for py.test Feb 01, 2018 N/A N/A :pypi:`pytest-gcov` Uses gcov to measure test coverage of a C library Feb 01, 2018 3 - Alpha N/A :pypi:`pytest-gcs` GCS fixtures and fixture factories for Pytest. Jan 24, 2025 5 - Production/Stable pytest>=6.2 - :pypi:`pytest-gee` The Python plugin for your GEE based packages. Feb 20, 2025 3 - Alpha pytest + :pypi:`pytest-gee` The Python plugin for your GEE based packages. May 11, 2025 3 - Alpha pytest :pypi:`pytest-gevent` Ensure that gevent is properly patched when invoking pytest Feb 25, 2020 N/A pytest :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest @@ -690,7 +692,7 @@ This list contains 1625 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components May 10, 2025 3 - Alpha pytest==8.3.5 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components May 17, 2025 3 - Alpha pytest==8.3.5 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -731,6 +733,7 @@ This list contains 1625 plugins. :pypi:`pytest-ignore-test-results` A pytest plugin to ignore test results. Feb 03, 2025 5 - Production/Stable pytest>=7.0 :pypi:`pytest-image-diff` Dec 31, 2024 3 - Alpha pytest :pypi:`pytest-image-snapshot` A pytest plugin for image snapshot management and comparison. Jul 01, 2024 4 - Beta pytest>=3.5.0 + :pypi:`pytest-impacted` A pytest plugin that selectively runs tests impacted by codechanges via git introspection, ASL parsing, and dependency graph analysis. May 15, 2025 4 - Beta pytest>=8.0.0 :pypi:`pytest-import-check` pytest plugin to check whether Python modules can be imported Jul 19, 2024 3 - Alpha pytest>=8.1 :pypi:`pytest-incremental` an incremental test runner (pytest plugin) Apr 24, 2021 5 - Production/Stable N/A :pypi:`pytest-infinity` Jun 09, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -767,6 +770,7 @@ This list contains 1625 plugins. :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A :pypi:`pytest-ipynb2` Pytest plugin to run tests in Jupyter Notebooks Mar 09, 2025 N/A pytest :pypi:`pytest-ipywidgets` Apr 30, 2025 N/A pytest + :pypi:`pytest-iso` Plugin for pytest to produce test documentation for code audits. May 15, 2025 4 - Beta pytest<9.0.0,>=7.4.0 :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Apr 22, 2025 4 - Beta pytest :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Feb 24, 2025 4 - Beta pytest>=5 :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) @@ -794,7 +798,7 @@ This list contains 1625 plugins. :pypi:`pytest-json-report-wip` A pytest plugin to report test results as JSON files Oct 28, 2023 4 - Beta pytest >=3.8.0 :pypi:`pytest-jsonschema` A pytest plugin to perform JSONSchema validations Apr 20, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-jtr` pytest plugin supporting json test report output Jul 21, 2024 N/A pytest<8.0.0,>=7.1.2 - :pypi:`pytest-jubilant` Add your description here May 01, 2025 N/A pytest>=8.3.5 + :pypi:`pytest-jubilant` Add your description here May 14, 2025 N/A pytest>=8.3.5 :pypi:`pytest-junit-xray-xml` Export test results in an augmented JUnit format for usage with Xray () Jan 01, 2025 4 - Beta pytest :pypi:`pytest-jupyter` A pytest plugin for testing Jupyter libraries and extensions. Apr 04, 2024 4 - Beta pytest>=7.0 :pypi:`pytest-jupyterhub` A reusable JupyterHub pytest plugin Apr 25, 2023 5 - Production/Stable pytest @@ -874,6 +878,7 @@ This list contains 1625 plugins. :pypi:`pytest-markdown-docs` Run markdown code fences through pytest Apr 09, 2025 N/A pytest>=7.0.0 :pypi:`pytest-marker-bugzilla` py.test bugzilla integration plugin, using markers Apr 02, 2025 5 - Production/Stable pytest>=2.2.4 :pypi:`pytest-markers-presence` A simple plugin to detect missed pytest tags and markers" Oct 30, 2024 4 - Beta pytest>=6.0 + :pypi:`pytest-mark-filter` Filter pytest marks by name using match kw May 11, 2025 N/A pytest>=8.3.0 :pypi:`pytest-markfiltration` UNKNOWN Nov 08, 2011 3 - Alpha N/A :pypi:`pytest-mark-manage` 用例标签化管理 Aug 15, 2024 N/A pytest :pypi:`pytest-mark-no-py3` pytest plugin and bowler codemod to help migrate tests to Python 3 May 17, 2019 N/A pytest @@ -897,13 +902,13 @@ This list contains 1625 plugins. :pypi:`pytest-memray` A simple plugin to use with pytest Jul 25, 2024 N/A pytest>=7.2 :pypi:`pytest-menu` A pytest plugin for console based interactive test selection just after the collection phase Oct 04, 2017 3 - Alpha pytest (>=2.4.2) :pypi:`pytest-mercurial` pytest plugin to write integration tests for projects using Mercurial Python internals Nov 21, 2020 1 - Planning N/A - :pypi:`pytest-mergify` Pytest plugin for Mergify Apr 10, 2025 N/A N/A + :pypi:`pytest-mergify` Pytest plugin for Mergify May 13, 2025 N/A pytest>=6.0.0 :pypi:`pytest-mesh` pytest_mesh插件 Aug 05, 2022 N/A pytest (==7.1.2) :pypi:`pytest-message` Pytest plugin for sending report message of marked tests execution Aug 04, 2022 N/A pytest (>=6.2.5) :pypi:`pytest-messenger` Pytest to Slack reporting plugin Nov 24, 2022 5 - Production/Stable N/A :pypi:`pytest-metadata` pytest plugin for test session metadata Feb 12, 2024 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-metrics` Custom metrics report for pytest Apr 04, 2020 N/A pytest - :pypi:`pytest-mh` Pytest multihost plugin Mar 06, 2025 N/A pytest + :pypi:`pytest-mh` Pytest multihost plugin May 15, 2025 N/A pytest :pypi:`pytest-mimesis` Mimesis integration with the pytest test runner Mar 21, 2020 5 - Production/Stable pytest (>=4.2) :pypi:`pytest-mimic` Easily record function calls while testing Apr 24, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-minecraft` A pytest plugin for running tests against Minecraft releases Apr 06, 2022 N/A pytest (>=6.0.1) @@ -991,7 +996,7 @@ This list contains 1625 plugins. :pypi:`pytest-notimplemented` Pytest markers for not implemented features and tests. Aug 27, 2019 N/A pytest (>=5.1,<6.0) :pypi:`pytest-notion` A PyTest Reporter to send test runs to Notion.so Aug 07, 2019 N/A N/A :pypi:`pytest-nunit` A pytest plugin for generating NUnit3 test result XML output Feb 26, 2024 5 - Production/Stable N/A - :pypi:`pytest-oar` PyTest plugin for the OAR testing framework May 02, 2023 N/A pytest>=6.0.1 + :pypi:`pytest-oar` PyTest plugin for the OAR testing framework May 12, 2025 N/A pytest>=6.0.1 :pypi:`pytest-oarepo` Feb 14, 2025 N/A pytest>=7.1.2; extra == "base" :pypi:`pytest-object-getter` Import any object from a 3rd party module while mocking its namespace on demand. Jul 31, 2022 5 - Production/Stable pytest :pypi:`pytest-ochrus` pytest results data-base and HTML reporter Feb 21, 2018 4 - Beta N/A @@ -1056,7 +1061,7 @@ This list contains 1625 plugins. :pypi:`pytest-performancetotal` A performance plugin for pytest Feb 01, 2025 5 - Production/Stable N/A :pypi:`pytest-persistence` Pytest tool for persistent objects Aug 21, 2024 N/A N/A :pypi:`pytest-pexpect` Pytest pexpect plugin. Aug 13, 2024 4 - Beta pytest>=6.2.0 - :pypi:`pytest-pg` A tiny plugin for pytest which runs PostgreSQL in Docker Apr 11, 2025 5 - Production/Stable pytest>=8.0.0 + :pypi:`pytest-pg` A tiny plugin for pytest which runs PostgreSQL in Docker May 11, 2025 5 - Production/Stable pytest>=7.4 :pypi:`pytest-pgsql` Pytest plugins and helpers for tests using a Postgres database. May 13, 2020 5 - Production/Stable pytest (>=3.0.0) :pypi:`pytest-phmdoctest` pytest plugin to test Python examples in Markdown using phmdoctest. Apr 15, 2022 4 - Beta pytest (>=5.4.3) :pypi:`pytest-phoenix-interface` Pytest extension tool for phoenix projects. Mar 19, 2025 N/A N/A @@ -1103,7 +1108,7 @@ This list contains 1625 plugins. :pypi:`pytest-porcochu` Show surprise when tests are passing Nov 28, 2024 5 - Production/Stable N/A :pypi:`pytest-portion` Select a portion of the collected tests Jan 28, 2021 4 - Beta pytest (>=3.5.0) :pypi:`pytest-postgres` Run PostgreSQL in Docker container in Pytest. Mar 22, 2020 N/A pytest - :pypi:`pytest-postgresql` Postgresql fixtures and fixture factories for Pytest. Mar 19, 2025 5 - Production/Stable pytest>=6.2 + :pypi:`pytest-postgresql` Postgresql fixtures and fixture factories for Pytest. May 17, 2025 5 - Production/Stable pytest>=7.2 :pypi:`pytest-power` pytest plugin with powerful fixtures Dec 31, 2020 N/A pytest (>=5.4) :pypi:`pytest-powerpack` A plugin containing extra batteries for pytest Jan 04, 2025 N/A pytest<9.0.0,>=8.1.1 :pypi:`pytest-prefer-nested-dup-tests` A Pytest plugin to drop duplicated tests during collection, but will prefer keeping nested packages. Apr 27, 2022 4 - Beta pytest (>=7.1.1,<8.0.0) @@ -1238,7 +1243,7 @@ This list contains 1625 plugins. :pypi:`pytest-reserial` Pytest fixture for recording and replaying serial port traffic. Dec 22, 2024 4 - Beta pytest :pypi:`pytest-resilient-circuits` Resilient Circuits fixtures for PyTest Feb 28, 2025 N/A pytest~=7.0 :pypi:`pytest-resource` Load resource fixture plugin to use with pytest Nov 14, 2018 4 - Beta N/A - :pypi:`pytest-resource-path` Provides path for uniform access to test resources in isolated directory May 01, 2021 5 - Production/Stable pytest (>=3.5.0) + :pypi:`pytest-resource-path` Provides path for uniform access to test resources in isolated directory May 15, 2025 5 - Production/Stable pytest>=3.5.0 :pypi:`pytest-resource-usage` Pytest plugin for reporting running time and peak memory usage Nov 06, 2022 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-responsemock` Simplified requests calls mocking for pytest Mar 10, 2022 5 - Production/Stable N/A :pypi:`pytest-responses` py.test integration for responses Oct 11, 2022 N/A pytest (>=2.5) @@ -1293,19 +1298,19 @@ This list contains 1625 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. May 02, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. May 13, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A - :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. Nov 21, 2024 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 13, 2025 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A :pypi:`pytest-schema` 👍 Validate return values against a schema-like object in testing Feb 16, 2024 5 - Production/Stable pytest >=3.5.0 - :pypi:`pytest-scim2-server` SCIM2 server fixture for Pytest Mar 28, 2025 N/A pytest>=8.3.4 + :pypi:`pytest-scim2-server` SCIM2 server fixture for Pytest May 14, 2025 4 - Beta pytest>=8.3.4 :pypi:`pytest-screenshot-on-failure` Saves a screenshot when a test case from a pytest execution fails Jul 21, 2023 4 - Beta N/A :pypi:`pytest-scrutinize` Scrutinize your pytest test suites for slow fixtures, tests and more. Aug 19, 2024 4 - Beta pytest>=6 :pypi:`pytest-securestore` An encrypted password store for use within pytest cases Nov 08, 2021 4 - Beta N/A :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. May 02, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. May 13, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 @@ -1324,6 +1329,7 @@ This list contains 1625 plugins. :pypi:`pytest-setupinfo` Displaying setup info during pytest command run Jan 23, 2023 N/A N/A :pypi:`pytest-sftpserver` py.test plugin to locally test sftp server connections. Sep 16, 2019 4 - Beta N/A :pypi:`pytest-shard` Dec 11, 2020 4 - Beta pytest + :pypi:`pytest-shard-fork` Shard tests to support parallelism across multiple machines May 17, 2025 4 - Beta pytest :pypi:`pytest-shared-session-scope` Pytest session-scoped fixture that works with xdist Sep 22, 2024 N/A pytest>=7.0.0 :pypi:`pytest-share-hdf` Plugin to save test data in HDF files and retrieve them for comparison Sep 21, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-sharkreport` this is pytest report plugin. Jul 11, 2022 N/A pytest (>=3.5) @@ -1388,7 +1394,7 @@ This list contains 1625 plugins. :pypi:`pytest-splitio` Split.io SDK integration for e2e tests Sep 22, 2020 N/A pytest (<7,>=5.0) :pypi:`pytest-split-tests` A Pytest plugin for running a subset of your tests by splitting them in to equally sized groups. Forked from Mark Adams' original project pytest-test-groups. Jul 30, 2021 5 - Production/Stable pytest (>=2.5) :pypi:`pytest-split-tests-tresorit` Feb 22, 2021 1 - Planning N/A - :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons Mar 07, 2025 N/A pytest<8,>5.4.0 + :pypi:`pytest-splunk-addon` A Dynamic test tool for Splunk Apps and Add-ons May 14, 2025 N/A pytest<8,>5.4.0 :pypi:`pytest-splunk-addon-ui-smartx` Library to support testing Splunk Add-on UX Mar 19, 2025 N/A N/A :pypi:`pytest-splunk-env` pytest fixtures for interaction with Splunk Enterprise and Splunk Cloud Oct 22, 2020 N/A pytest (>=6.1.1,<7.0.0) :pypi:`pytest-sqitch` sqitch for pytest Apr 06, 2020 4 - Beta N/A @@ -1413,6 +1419,7 @@ This list contains 1625 plugins. :pypi:`pytest-stochastics` pytest plugin that allows selectively running tests several times and accepting \*some\* failures. Dec 01, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-stoq` A plugin to pytest stoq Feb 09, 2021 4 - Beta N/A :pypi:`pytest-store` Pytest plugin to store values from test runs Sep 04, 2024 3 - Alpha pytest>=7.0.0 + :pypi:`pytest-streaming` Plugin for testing pubsub, pulsar, and kafka systems with pytest locally and in ci/cd May 16, 2025 N/A pytest>=8.3.5 :pypi:`pytest-stress` A Pytest plugin that allows you to loop tests for a user defined amount of time. Dec 07, 2019 4 - Beta pytest (>=3.6.0) :pypi:`pytest-structlog` Structured logging assertions Jul 25, 2024 N/A pytest :pypi:`pytest-structmpd` provide structured temporary directory Oct 17, 2018 N/A N/A @@ -1651,7 +1658,7 @@ This list contains 1625 plugins. :pypi:`pytest-zcc` eee Jun 02, 2024 N/A N/A :pypi:`pytest-zebrunner` Pytest connector for Zebrunner reporting Jul 04, 2024 5 - Production/Stable pytest>=4.5.0 :pypi:`pytest-zeebe` Pytest fixtures for testing Camunda 8 processes using a Zeebe test engine. Feb 01, 2024 N/A pytest (>=7.4.2,<8.0.0) - :pypi:`pytest-zephyr-scale-integration` A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest Oct 15, 2024 N/A pytest + :pypi:`pytest-zephyr-scale-integration` A library for integrating Jira Zephyr Scale (Adaptavist\TM4J) with pytest May 15, 2025 N/A pytest :pypi:`pytest-zephyr-telegram` Плагин для отправки данных автотестов в Телеграм и Зефир Sep 30, 2024 N/A pytest==8.3.2 :pypi:`pytest-zest` Zesty additions to pytest. Nov 17, 2022 N/A N/A :pypi:`pytest-zhongwen-wendang` PyTest 中文文档 Mar 04, 2024 4 - Beta N/A @@ -1665,14 +1672,14 @@ This list contains 1625 plugins. :pypi:`databricks-labs-pytester` - *last release*: Feb 27, 2025, + *last release*: May 13, 2025, *status*: 4 - Beta, *requires*: pytest>=8.3 Python Testing for Databricks :pypi:`logassert` - *last release*: Jan 29, 2025, + *last release*: May 15, 2025, *status*: 5 - Production/Stable, *requires*: pytest; extra == "dev" @@ -1868,9 +1875,9 @@ This list contains 1625 plugins. :pypi:`pytest-alembic` - *last release*: Jul 29, 2024, + *last release*: May 16, 2025, *status*: N/A, - *requires*: pytest>=6.0 + *requires*: pytest>=7.0 A pytest plugin for verifying alembic migrations. @@ -2260,7 +2267,7 @@ This list contains 1625 plugins. Pytest support for asyncio :pypi:`pytest-asyncio-concurrent` - *last release*: Apr 29, 2025, + *last release*: May 17, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -2491,7 +2498,7 @@ This list contains 1625 plugins. A pytest plugin to repeat the entire test suite in batches. :pypi:`pytest-bazel` - *last release*: Sep 27, 2024, + *last release*: May 11, 2025, *status*: 4 - Beta, *requires*: pytest @@ -2561,7 +2568,7 @@ This list contains 1625 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: May 09, 2025, + *last release*: May 13, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -3590,7 +3597,7 @@ This list contains 1625 plugins. Coverage dynamic context support for PyTest, including sub-processes :pypi:`pytest-coveragemarkers` - *last release*: Oct 15, 2024, + *last release*: May 15, 2025, *status*: N/A, *requires*: pytest<8.0.0,>=7.1.2 @@ -3694,6 +3701,13 @@ This list contains 1625 plugins. Pytest plugin for Test Case Parametrization with CSV files + :pypi:`pytest-culprit` + *last release*: May 15, 2025, + *status*: N/A, + *requires*: N/A + + Find the last Git commit where a pytest test started failing + :pypi:`pytest-curio` *last release*: Oct 06, 2024, *status*: N/A, @@ -3863,11 +3877,11 @@ This list contains 1625 plugins. py.test plugin to create a 'tmp_path' containing predefined files/directories. :pypi:`pytest-datafixtures` - *last release*: Dec 05, 2020, + *last release*: May 15, 2025, *status*: 5 - Production/Stable, *requires*: N/A - Data fixtures for pytest made simple + Data fixtures for pytest made simple. :pypi:`pytest-data-from-files` *last release*: Oct 13, 2021, @@ -4430,9 +4444,9 @@ This list contains 1625 plugins. A plugin to use docker databases for pytests :pypi:`pytest-docker-fixtures` - *last release*: Apr 03, 2024, + *last release*: May 14, 2025, *status*: 3 - Alpha, - *requires*: N/A + *requires*: pytest pytest docker fixtures @@ -4906,7 +4920,7 @@ This list contains 1625 plugins. Pytest plugin to represent test output with emoji support :pypi:`pytest-enabler` - *last release*: Sep 12, 2024, + *last release*: May 16, 2025, *status*: 5 - Production/Stable, *requires*: pytest!=8.1.*,>=6; extra == "test" @@ -5521,6 +5535,13 @@ This list contains 1625 plugins. + :pypi:`pytest-fixturecheck` + *last release*: May 17, 2025, + *status*: 3 - Alpha, + *requires*: pytest>=6.0.0 + + A pytest plugin to check fixture validity before test execution + :pypi:`pytest-fixture-classes` *last release*: Sep 02, 2023, *status*: 5 - Production/Stable, @@ -5907,7 +5928,7 @@ This list contains 1625 plugins. GCS fixtures and fixture factories for Pytest. :pypi:`pytest-gee` - *last release*: Feb 20, 2025, + *last release*: May 11, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -6257,7 +6278,7 @@ This list contains 1625 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: May 10, 2025, + *last release*: May 17, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.5 @@ -6543,6 +6564,13 @@ This list contains 1625 plugins. A pytest plugin for image snapshot management and comparison. + :pypi:`pytest-impacted` + *last release*: May 15, 2025, + *status*: 4 - Beta, + *requires*: pytest>=8.0.0 + + A pytest plugin that selectively runs tests impacted by codechanges via git introspection, ASL parsing, and dependency graph analysis. + :pypi:`pytest-import-check` *last release*: Jul 19, 2024, *status*: 3 - Alpha, @@ -6795,6 +6823,13 @@ This list contains 1625 plugins. + :pypi:`pytest-iso` + *last release*: May 15, 2025, + *status*: 4 - Beta, + *requires*: pytest<9.0.0,>=7.4.0 + + Plugin for pytest to produce test documentation for code audits. + :pypi:`pytest-isolate` *last release*: Apr 22, 2025, *status*: 4 - Beta, @@ -6985,7 +7020,7 @@ This list contains 1625 plugins. pytest plugin supporting json test report output :pypi:`pytest-jubilant` - *last release*: May 01, 2025, + *last release*: May 14, 2025, *status*: N/A, *requires*: pytest>=8.3.5 @@ -7544,6 +7579,13 @@ This list contains 1625 plugins. A simple plugin to detect missed pytest tags and markers" + :pypi:`pytest-mark-filter` + *last release*: May 11, 2025, + *status*: N/A, + *requires*: pytest>=8.3.0 + + Filter pytest marks by name using match kw + :pypi:`pytest-markfiltration` *last release*: Nov 08, 2011, *status*: 3 - Alpha, @@ -7706,9 +7748,9 @@ This list contains 1625 plugins. pytest plugin to write integration tests for projects using Mercurial Python internals :pypi:`pytest-mergify` - *last release*: Apr 10, 2025, + *last release*: May 13, 2025, *status*: N/A, - *requires*: N/A + *requires*: pytest>=6.0.0 Pytest plugin for Mergify @@ -7748,7 +7790,7 @@ This list contains 1625 plugins. Custom metrics report for pytest :pypi:`pytest-mh` - *last release*: Mar 06, 2025, + *last release*: May 15, 2025, *status*: N/A, *requires*: pytest @@ -8364,7 +8406,7 @@ This list contains 1625 plugins. A pytest plugin for generating NUnit3 test result XML output :pypi:`pytest-oar` - *last release*: May 02, 2023, + *last release*: May 12, 2025, *status*: N/A, *requires*: pytest>=6.0.1 @@ -8819,9 +8861,9 @@ This list contains 1625 plugins. Pytest pexpect plugin. :pypi:`pytest-pg` - *last release*: Apr 11, 2025, + *last release*: May 11, 2025, *status*: 5 - Production/Stable, - *requires*: pytest>=8.0.0 + *requires*: pytest>=7.4 A tiny plugin for pytest which runs PostgreSQL in Docker @@ -9148,9 +9190,9 @@ This list contains 1625 plugins. Run PostgreSQL in Docker container in Pytest. :pypi:`pytest-postgresql` - *last release*: Mar 19, 2025, + *last release*: May 17, 2025, *status*: 5 - Production/Stable, - *requires*: pytest>=6.2 + *requires*: pytest>=7.2 Postgresql fixtures and fixture factories for Pytest. @@ -10093,9 +10135,9 @@ This list contains 1625 plugins. Load resource fixture plugin to use with pytest :pypi:`pytest-resource-path` - *last release*: May 01, 2021, + *last release*: May 15, 2025, *status*: 5 - Production/Stable, - *requires*: pytest (>=3.5.0) + *requires*: pytest>=3.5.0 Provides path for uniform access to test resources in isolated directory @@ -10478,7 +10520,7 @@ This list contains 1625 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: May 02, 2025, + *last release*: May 13, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10492,7 +10534,7 @@ This list contains 1625 plugins. pytest plugin for test scenarios :pypi:`pytest-scenario-files` - *last release*: Nov 21, 2024, + *last release*: May 13, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 @@ -10513,8 +10555,8 @@ This list contains 1625 plugins. 👍 Validate return values against a schema-like object in testing :pypi:`pytest-scim2-server` - *last release*: Mar 28, 2025, - *status*: N/A, + *last release*: May 14, 2025, + *status*: 4 - Beta, *requires*: pytest>=8.3.4 SCIM2 server fixture for Pytest @@ -10562,7 +10604,7 @@ This list contains 1625 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: May 02, 2025, + *last release*: May 13, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10694,6 +10736,13 @@ This list contains 1625 plugins. + :pypi:`pytest-shard-fork` + *last release*: May 17, 2025, + *status*: 4 - Beta, + *requires*: pytest + + Shard tests to support parallelism across multiple machines + :pypi:`pytest-shared-session-scope` *last release*: Sep 22, 2024, *status*: N/A, @@ -11143,7 +11192,7 @@ This list contains 1625 plugins. :pypi:`pytest-splunk-addon` - *last release*: Mar 07, 2025, + *last release*: May 14, 2025, *status*: N/A, *requires*: pytest<8,>5.4.0 @@ -11317,6 +11366,13 @@ This list contains 1625 plugins. Pytest plugin to store values from test runs + :pypi:`pytest-streaming` + *last release*: May 16, 2025, + *status*: N/A, + *requires*: pytest>=8.3.5 + + Plugin for testing pubsub, pulsar, and kafka systems with pytest locally and in ci/cd + :pypi:`pytest-stress` *last release*: Dec 07, 2019, *status*: 4 - Beta, @@ -12984,7 +13040,7 @@ This list contains 1625 plugins. Pytest fixtures for testing Camunda 8 processes using a Zeebe test engine. :pypi:`pytest-zephyr-scale-integration` - *last release*: Oct 15, 2024, + *last release*: May 15, 2025, *status*: N/A, *requires*: pytest From 8a66a9ed0bc3b82e7458e36823d3ae0496d1082a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 May 2025 20:08:42 +0000 Subject: [PATCH 397/445] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.5 → v0.11.10](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.5...v0.11.10) - [github.com/woodruffw/zizmor-pre-commit: v1.5.2 → v1.7.0](https://github.com/woodruffw/zizmor-pre-commit/compare/v1.5.2...v1.7.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a9d59e15551..2a4543841f3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.11.5" + rev: "v0.11.10" hooks: - id: ruff args: ["--fix"] @@ -12,7 +12,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/woodruffw/zizmor-pre-commit - rev: v1.5.2 + rev: v1.7.0 hooks: - id: zizmor - repo: https://github.com/adamchainz/blacken-docs From 76ee187a4469552bfa314c247bab67a0dde1747b Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Mon, 12 May 2025 22:48:36 +0200 Subject: [PATCH 398/445] [ci] Pin all action to a precise hash to appease zizmor --- .github/workflows/deploy.yml | 6 +++--- .github/workflows/test.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2ad6e9d5054..9e63bc68cfd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,7 +31,7 @@ jobs: persist-credentials: false - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v2.12.0 + uses: hynek/build-and-inspect-python-package@b5076c307dc91924a82ad150cdd1533b444d3310 with: attest-build-provenance-github: 'true' @@ -56,7 +56,7 @@ jobs: path: dist - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@v1.12.4 + uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc with: attestations: true @@ -109,7 +109,7 @@ jobs: tox -e generate-gh-release-notes -- "$VERSION" scripts/latest-release-notes.md - name: Publish GitHub Release - uses: softprops/action-gh-release@v2 + uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 with: body_path: scripts/latest-release-notes.md files: dist/* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 44c9d68c03d..5f6bdf60849 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,7 +40,7 @@ jobs: fetch-depth: 0 persist-credentials: false - name: Build and Check Package - uses: hynek/build-and-inspect-python-package@v2.12.0 + uses: hynek/build-and-inspect-python-package@b5076c307dc91924a82ad150cdd1533b444d3310 build: needs: [package] @@ -262,7 +262,7 @@ jobs: - name: Upload coverage to Codecov if: "matrix.use_coverage" - uses: codecov/codecov-action@v5 + uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d with: fail_ci_if_error: false files: ./coverage.xml From c77995bb910bed278c98323574dc54ca2d032216 Mon Sep 17 00:00:00 2001 From: ikappaki <34983288+ikappaki@users.noreply.github.com> Date: Thu, 22 May 2025 13:55:12 +0100 Subject: [PATCH 399/445] Replace `:` with `;` in the assertion rewrite warning message (#13429) This makes it possible to filter them using standard Python warning filters. --- Co-authored-by: ikappaki --- changelog/5473.improvement.rst | 1 + src/_pytest/assertion/rewrite.py | 2 +- testing/test_assertrewrite.py | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 changelog/5473.improvement.rst diff --git a/changelog/5473.improvement.rst b/changelog/5473.improvement.rst new file mode 100644 index 00000000000..1b9ab006d49 --- /dev/null +++ b/changelog/5473.improvement.rst @@ -0,0 +1 @@ +Replace `:` with `;` in the assertion rewrite warning message so it can be filtered using standard Python warning filters before calling :func:`pytest.main`. diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index 2e606d1903a..c4782c7c5a8 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -281,7 +281,7 @@ def _warn_already_imported(self, name: str) -> None: self.config.issue_config_time_warning( PytestAssertRewriteWarning( - f"Module already imported so cannot be rewritten: {name}" + f"Module already imported so cannot be rewritten; {name}" ), stacklevel=5, ) diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index 02d1c3e52ff..e2e448fe5e6 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -1197,7 +1197,23 @@ def test_rewrite_warning(self, pytester: Pytester) -> None: ) # needs to be a subprocess because pytester explicitly disables this warning result = pytester.runpytest_subprocess() - result.stdout.fnmatch_lines(["*Module already imported*: _pytest"]) + result.stdout.fnmatch_lines(["*Module already imported*; _pytest"]) + + def test_rewrite_warning_ignore(self, pytester: Pytester) -> None: + pytester.makeconftest( + """ + import pytest + pytest.register_assert_rewrite("_pytest") + """ + ) + # needs to be a subprocess because pytester explicitly disables this warning + result = pytester.runpytest_subprocess( + "-W", + "ignore:Module already imported so cannot be rewritten; _pytest:pytest.PytestAssertRewriteWarning", + ) + # Previously, when the message pattern used to contain an extra `:`, an error was raised. + assert not result.stderr.str().strip() + result.stdout.no_fnmatch_line("*Module already imported*; _pytest") def test_rewrite_module_imported_from_conftest(self, pytester: Pytester) -> None: pytester.makeconftest( From 433f3a6f01b3fd90d6bf00a077c869094d5e6589 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 May 2025 06:24:16 +0200 Subject: [PATCH 400/445] build(deps): Bump codecov/codecov-action from 5.4.2 to 5.4.3 (#13439) Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.4.2 to 5.4.3. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/ad3126e916f78f00edff4ed0317cf185271ccc2d...18283e04ce6e62d37312384ff67231eb8fd56d24) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-version: 5.4.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5f6bdf60849..99ca032db9d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -262,7 +262,7 @@ jobs: - name: Upload coverage to Codecov if: "matrix.use_coverage" - uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d + uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 with: fail_ci_if_error: false files: ./coverage.xml From 58d7aa90196976b59f98ba072d3ecf1c19c1f5ca Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 25 May 2025 19:22:07 +0300 Subject: [PATCH 401/445] python: fix confusing note in `Metafunc.parametrize`'s docstring `indirect` is useful for doing stuff at setup time, the current phrasing makes it sound like the opposite. Perhaps the `than` was meant to be omitted. But rephrase it anyway. --- src/_pytest/python.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 902bcfade9f..90b64bc1b24 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1168,7 +1168,7 @@ def parametrize( """Add new invocations to the underlying test function using the list of argvalues for the given argnames. Parametrization is performed during the collection phase. If you need to setup expensive resources - see about setting indirect to do it rather than at test setup time. + see about setting ``indirect`` to do it at test setup time instead. Can be called multiple times per test function (but only on different argument names), in which case each call parametrizes all previous From 19bc2cb2e4860606d8dd67262daa256bfd03238f Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 25 May 2025 19:27:32 +0300 Subject: [PATCH 402/445] python: remove redundant `:type` docstring Sphinx gets it from the type annotation. --- src/_pytest/python.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 90b64bc1b24..64154d123b7 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1192,7 +1192,7 @@ def parametrize( If N argnames were specified, argvalues must be a list of N-tuples, where each tuple-element specifies a value for its respective argname. - :type argvalues: Iterable[_pytest.mark.structures.ParameterSet | Sequence[object] | object] + :param indirect: A list of arguments' names (subset of argnames) or a boolean. If True the list contains all names from the argnames. Each From fe64939eaad50fb55b4547ade0c63a8b78585d3e Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 25 May 2025 19:57:28 +0300 Subject: [PATCH 403/445] python: clarify a bit two comments --- src/_pytest/python.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 64154d123b7..fde68baf2e8 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1270,14 +1270,13 @@ def parametrize( if _param_mark and _param_mark._param_ids_from and generated_ids is None: object.__setattr__(_param_mark._param_ids_from, "_param_ids_generated", ids) - # Add funcargs as fixturedefs to fixtureinfo.arg2fixturedefs by registering - # artificial "pseudo" FixtureDef's so that later at test execution time we can - # rely on a proper FixtureDef to exist for fixture setup. + # Add direct parametrizations as fixturedefs to arg2fixturedefs by + # registering artificial "pseudo" FixtureDef's such that later at test + # setup time we can rely on FixtureDefs to exist for all argnames. node = None - # If we have a scope that is higher than function, we need - # to make sure we only ever create an according fixturedef on - # a per-scope basis. We thus store and cache the fixturedef on the - # node related to the scope. + # For scopes higher than function, a "pseudo" FixtureDef might have + # already been created for the scope. We thus store and cache the + # FixtureDef on the node related to the scope. if scope_ is not Scope.Function: collector = self.definition.parent assert collector is not None From 0910c35c4225ca5a568c979f993641b06d805e46 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 25 May 2025 20:12:28 +0300 Subject: [PATCH 404/445] fixtures: add docstring for internal function `get_scope_node` --- src/_pytest/fixtures.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index bb50b014dd1..3fb7dcd230d 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -132,6 +132,12 @@ def get_scope_package( def get_scope_node(node: nodes.Node, scope: Scope) -> nodes.Node | None: + """Get the closest parent node (including self) which matches the given + scope. + + If there is no parent node for the scope (e.g. asking for class scope on a + Module, or on a Function when not defined in a class), returns None. + """ import _pytest.python if scope is Scope.Function: From 1c45c2073dd86280ff4dbf271d4ae8174a8403e5 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 25 May 2025 20:24:55 +0300 Subject: [PATCH 405/445] python: slight refactor to make code read better --- src/_pytest/python.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index fde68baf2e8..f46c34d84c5 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1270,6 +1270,10 @@ def parametrize( if _param_mark and _param_mark._param_ids_from and generated_ids is None: object.__setattr__(_param_mark._param_ids_from, "_param_ids_generated", ids) + # Calculate directness. + arg_directness = self._resolve_args_directness(argnames, indirect) + self._params_directness.update(arg_directness) + # Add direct parametrizations as fixturedefs to arg2fixturedefs by # registering artificial "pseudo" FixtureDef's such that later at test # setup time we can rely on FixtureDefs to exist for all argnames. @@ -1277,7 +1281,9 @@ def parametrize( # For scopes higher than function, a "pseudo" FixtureDef might have # already been created for the scope. We thus store and cache the # FixtureDef on the node related to the scope. - if scope_ is not Scope.Function: + if scope_ is Scope.Function: + name2pseudofixturedef = None + else: collector = self.definition.parent assert collector is not None node = get_scope_node(collector, scope_) @@ -1293,15 +1299,10 @@ def parametrize( node = collector.session else: assert False, f"Unhandled missing scope: {scope}" - if node is None: - name2pseudofixturedef = None - else: default: dict[str, FixtureDef[Any]] = {} name2pseudofixturedef = node.stash.setdefault( name2pseudofixturedef_key, default ) - arg_directness = self._resolve_args_directness(argnames, indirect) - self._params_directness.update(arg_directness) for argname in argnames: if arg_directness[argname] == "indirect": continue From dbec145dee42d8e69b8f1431f31ba9ef2c1e519f Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 25 May 2025 19:01:14 +0300 Subject: [PATCH 406/445] fixtures: rename `FixtureArgKey` -> `ParamArgKey` Rename `FixtureArgKey` to `ParamArgKey` because it's not really about fixtures but about parametrization parameters (which can come from either `@pytest.parametrize` or from `pytest.fixture(params=...)`). Also added a few more comments. --- src/_pytest/fixtures.py | 36 +++++++++++++++++++++--------------- src/_pytest/python.py | 1 + 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 3fb7dcd230d..3f35428b432 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -171,10 +171,21 @@ def getfixturemarker(obj: object) -> FixtureFunctionMarker | None: @dataclasses.dataclass(frozen=True) -class FixtureArgKey: +class ParamArgKey: + """A key for a high-scoped parameter used by an item. + + For use as a hashable key in `reorder_items`. The combination of fields + is meant to uniquely identify a particular "instance" of a param, + potentially shared by multiple items in a scope. + """ + + #: The param name. argname: str param_index: int + #: For scopes Package, Module, Class, the path to the file (directory in + #: Package's case) of the package/module/class where the item is defined. scoped_item_path: Path | None + #: For Class scope, the class where the item is defined. item_cls: type | None @@ -182,11 +193,8 @@ class FixtureArgKey: OrderedSet = dict[_V, None] -def get_parametrized_fixture_argkeys( - item: nodes.Item, scope: Scope -) -> Iterator[FixtureArgKey]: - """Return list of keys for all parametrized arguments which match - the specified scope.""" +def get_param_argkeys(item: nodes.Item, scope: Scope) -> Iterator[ParamArgKey]: + """Return all ParamArgKeys for item matching the specified high scope.""" assert scope is not Scope.Function try: @@ -212,19 +220,17 @@ def get_parametrized_fixture_argkeys( if callspec._arg2scope[argname] != scope: continue param_index = callspec.indices[argname] - yield FixtureArgKey(argname, param_index, scoped_item_path, item_cls) + yield ParamArgKey(argname, param_index, scoped_item_path, item_cls) def reorder_items(items: Sequence[nodes.Item]) -> list[nodes.Item]: - argkeys_by_item: dict[Scope, dict[nodes.Item, OrderedSet[FixtureArgKey]]] = {} - items_by_argkey: dict[ - Scope, dict[FixtureArgKey, OrderedDict[nodes.Item, None]] - ] = {} + argkeys_by_item: dict[Scope, dict[nodes.Item, OrderedSet[ParamArgKey]]] = {} + items_by_argkey: dict[Scope, dict[ParamArgKey, OrderedDict[nodes.Item, None]]] = {} for scope in HIGH_SCOPES: scoped_argkeys_by_item = argkeys_by_item[scope] = {} scoped_items_by_argkey = items_by_argkey[scope] = defaultdict(OrderedDict) for item in items: - argkeys = dict.fromkeys(get_parametrized_fixture_argkeys(item, scope)) + argkeys = dict.fromkeys(get_param_argkeys(item, scope)) if argkeys: scoped_argkeys_by_item[item] = argkeys for argkey in argkeys: @@ -240,9 +246,9 @@ def reorder_items(items: Sequence[nodes.Item]) -> list[nodes.Item]: def reorder_items_atscope( items: OrderedSet[nodes.Item], - argkeys_by_item: Mapping[Scope, Mapping[nodes.Item, OrderedSet[FixtureArgKey]]], + argkeys_by_item: Mapping[Scope, Mapping[nodes.Item, OrderedSet[ParamArgKey]]], items_by_argkey: Mapping[ - Scope, Mapping[FixtureArgKey, OrderedDict[nodes.Item, None]] + Scope, Mapping[ParamArgKey, OrderedDict[nodes.Item, None]] ], scope: Scope, ) -> OrderedSet[nodes.Item]: @@ -252,7 +258,7 @@ def reorder_items_atscope( scoped_items_by_argkey = items_by_argkey[scope] scoped_argkeys_by_item = argkeys_by_item[scope] - ignore: set[FixtureArgKey] = set() + ignore: set[ParamArgKey] = set() items_deque = deque(items) items_done: OrderedSet[nodes.Item] = {} while items_deque: diff --git a/src/_pytest/python.py b/src/_pytest/python.py index f46c34d84c5..1e085a80529 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1056,6 +1056,7 @@ class CallSpec2: params: dict[str, object] = dataclasses.field(default_factory=dict) # arg name -> arg index. indices: dict[str, int] = dataclasses.field(default_factory=dict) + # arg name -> parameter scope. # Used for sorting parametrized resources. _arg2scope: Mapping[str, Scope] = dataclasses.field(default_factory=dict) # Parts which will be added to the item's name in `[..]` separated by "-". From 7ac5c18864502693ab0dd6e212e7dfb8d05de291 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Mon, 26 May 2025 09:56:38 +0300 Subject: [PATCH 407/445] mark: add docstring for `ParameterSet` This is not an exported type, adding a doc mostly so I can quickly remember what it is when reading code. --- src/_pytest/mark/structures.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 7a49b1a9b0c..f9261076ad0 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -78,6 +78,33 @@ def get_empty_parameterset_mark( class ParameterSet(NamedTuple): + """A set of values for a set of parameters along with associated marks and + an optional ID for the set. + + Examples:: + + pytest.param(1, 2, 3) + # ParameterSet(values=(1, 2, 3), marks=(), id=None) + + pytest.param("hello", id="greeting") + # ParameterSet(values=("hello",), marks=(), id="greeting") + + # Parameter set with marks + pytest.param(42, marks=pytest.mark.xfail) + # ParameterSet(values=(42,), marks=(MarkDecorator(...),), id=None) + + # From parametrize mark (parameter names + list of parameter sets) + pytest.mark.parametrize( + ("a", "b", "expected"), + [ + (1, 2, 3), + pytest.param(40, 2, 42, id="everything"), + ], + ) + # ParameterSet(values=(1, 2, 3), marks=(), id=None) + # ParameterSet(values=(2, 2, 3), marks=(), id="everything") + """ + values: Sequence[object | NotSetType] marks: Collection[MarkDecorator | Mark] id: str | _HiddenParam | None From 83536b4b0074ca35d90933d3ad46cb6efe7f5145 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 26 May 2025 21:09:17 +0000 Subject: [PATCH 408/445] [pre-commit.ci] pre-commit autoupdate (#13441) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.10 → v0.11.11](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.10...v0.11.11) - [github.com/woodruffw/zizmor-pre-commit: v1.7.0 → v1.8.0](https://github.com/woodruffw/zizmor-pre-commit/compare/v1.7.0...v1.8.0) - [github.com/tox-dev/pyproject-fmt: v2.5.1 → v2.6.0](https://github.com/tox-dev/pyproject-fmt/compare/v2.5.1...v2.6.0) - [github.com/asottile/pyupgrade: v3.19.1 → v3.20.0](https://github.com/asottile/pyupgrade/compare/v3.19.1...v3.20.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2a4543841f3..a07475da467 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.11.10" + rev: "v0.11.11" hooks: - id: ruff args: ["--fix"] @@ -12,7 +12,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/woodruffw/zizmor-pre-commit - rev: v1.7.0 + rev: v1.8.0 hooks: - id: zizmor - repo: https://github.com/adamchainz/blacken-docs @@ -48,13 +48,13 @@ repos: # on <3.11 - exceptiongroup>=1.0.0rc8 - repo: https://github.com/tox-dev/pyproject-fmt - rev: "v2.5.1" + rev: "v2.6.0" hooks: - id: pyproject-fmt # https://pyproject-fmt.readthedocs.io/en/latest/#calculating-max-supported-python-version additional_dependencies: ["tox>=4.9"] - repo: https://github.com/asottile/pyupgrade - rev: v3.19.1 + rev: v3.20.0 hooks: - id: pyupgrade args: From 0010bfa4bf2bf7680e80de5262de5a37b8ae3150 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Tue, 27 May 2025 21:42:20 +0300 Subject: [PATCH 409/445] testing: skip `pkg_resources` tests if modern setuptools setuptools is intending to remove `pkg_resources` at the end of the year. Version 80.9.0 changed the deprecation to a UserMessage which broke the test. Instead of making them compatible, just skip them on versions >= 80 in preparation for the final removal. --- testing/acceptance_test.py | 10 ++++++++-- testing/test_monkeypatch.py | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 50ea4ff44d2..2d653b8e2a5 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -10,6 +10,8 @@ import sys import types +import setuptools + from _pytest.config import ExitCode from _pytest.pathlib import symlink_or_skip from _pytest.pytester import Pytester @@ -722,10 +724,14 @@ def test_cmdline_python_package(self, pytester: Pytester, monkeypatch) -> None: assert result.ret != 0 result.stderr.fnmatch_lines(["*not*found*test_missing*"]) - def test_cmdline_python_namespace_package( + @pytest.mark.skipif( + int(setuptools.__version__.split(".")[0]) >= 80, + reason="modern setuptools removing pkg_resources", + ) + def test_cmdline_python_legacy_namespace_package( self, pytester: Pytester, monkeypatch ) -> None: - """Test --pyargs option with namespace packages (#1567). + """Test --pyargs option with legacy namespace packages (#1567). Ref: https://packaging.python.org/guides/packaging-namespace-packages/ """ diff --git a/testing/test_monkeypatch.py b/testing/test_monkeypatch.py index ad75273d703..0e992e298ec 100644 --- a/testing/test_monkeypatch.py +++ b/testing/test_monkeypatch.py @@ -8,6 +8,8 @@ import sys import textwrap +import setuptools + from _pytest.monkeypatch import MonkeyPatch from _pytest.pytester import Pytester import pytest @@ -429,6 +431,10 @@ class A: @pytest.mark.filterwarnings(r"ignore:.*\bpkg_resources\b:DeprecationWarning") +@pytest.mark.skipif( + int(setuptools.__version__.split(".")[0]) >= 80, + reason="modern setuptools removing pkg_resources", +) def test_syspath_prepend_with_namespace_packages( pytester: Pytester, monkeypatch: MonkeyPatch ) -> None: From 1fdcf68e4a43240eb6310b4b204a845bf72df9c6 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Mon, 26 May 2025 23:28:42 +0300 Subject: [PATCH 410/445] fixtures: workaround PyPy bug which sometimes causes a `KeyError` crash during collection Fix #13312. --- changelog/13312.bugfix.rst | 1 + src/_pytest/fixtures.py | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 changelog/13312.bugfix.rst diff --git a/changelog/13312.bugfix.rst b/changelog/13312.bugfix.rst new file mode 100644 index 00000000000..62ad36879f5 --- /dev/null +++ b/changelog/13312.bugfix.rst @@ -0,0 +1 @@ +Fixed a possible ``KeyError`` crash on PyPy during collection of tests involving higher-scoped parameters. diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 3f35428b432..92a301e79db 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -286,10 +286,18 @@ def reorder_items_atscope( for other_scope in HIGH_SCOPES: other_scoped_items_by_argkey = items_by_argkey[other_scope] for argkey in argkeys_by_item[other_scope].get(i, ()): - other_scoped_items_by_argkey[argkey][i] = None - other_scoped_items_by_argkey[argkey].move_to_end( - i, last=False - ) + argkey_dict = other_scoped_items_by_argkey[argkey] + if not hasattr(sys, "pypy_version_info"): + argkey_dict[i] = None + argkey_dict.move_to_end(i, last=False) + else: + # Work around a bug in PyPy: + # https://github.com/pypy/pypy/issues/5257 + # https://github.com/pytest-dev/pytest/issues/13312 + bkp = argkey_dict.copy() + argkey_dict.clear() + argkey_dict[i] = None + argkey_dict.update(bkp) break if no_argkey_items: reordered_no_argkey_items = reorder_items_atscope( From 6f8681342bf2d41aea3fbc252b4abcb475ed2d9c Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 28 May 2025 18:33:50 -0300 Subject: [PATCH 411/445] Sunset the mailing list contact information (#13449) As discussed recently in https://mail.python.org/archives/list/pytest-dev@python.org/thread/Y2HCDCXAAN6PLY63KLLY7FSUFDR6G5LC/, we will archive the mailing in favor of GitHub Discussions. --- CONTRIBUTING.rst | 5 ++--- doc/en/contact.rst | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 56824a43ff4..b79955e1c01 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -139,9 +139,8 @@ The objectives of the ``pytest-dev`` organisation are: * Sharing some of the maintenance responsibility (in case a maintainer no longer wishes to maintain a plugin) -You can submit your plugin by subscribing to the `pytest-dev mail list -`_ and writing a -mail pointing to your existing pytest plugin repository which must have +You can submit your plugin by posting a new topic in the `pytest-dev GitHub Discussions +`_ pointing to your existing pytest plugin repository which must have the following: - PyPI presence with packaging metadata that contains a ``pytest-`` diff --git a/doc/en/contact.rst b/doc/en/contact.rst index cd34f548e99..b2a1368eaba 100644 --- a/doc/en/contact.rst +++ b/doc/en/contact.rst @@ -35,7 +35,6 @@ Mail ---- - `Testing In Python`_: a mailing list for Python testing tools and discussion. -- `pytest-dev at python.org`_ a mailing list for pytest specific announcements and discussions. - Mail to `core@pytest.org `_ for topics that cannot be discussed in public. Mails sent there will be distributed among the members in the pytest core team, who can also be contacted individually: @@ -58,4 +57,3 @@ Other .. _`pytest issue tracker`: https://github.com/pytest-dev/pytest/issues .. _`pytest discussions`: https://github.com/pytest-dev/pytest/discussions .. _`Testing in Python`: http://lists.idyll.org/listinfo/testing-in-python -.. _`pytest-dev at python.org`: http://mail.python.org/mailman/listinfo/pytest-dev From bd6877e5874b50ee57d0f63b342a67298ee9a1c3 Mon Sep 17 00:00:00 2001 From: Sashko <20253875+sashko1988@users.noreply.github.com> Date: Thu, 29 May 2025 15:21:52 +0200 Subject: [PATCH 412/445] Improve `nodes._check_initialpaths_for_relpath` performance (#13448) Use `Path` facilities to greatly improve performance of `nodes._check_initialpaths_for_relpath` (see #13448 for performance comparison). Related: #13420, #13413. --------- Co-authored-by: Bruno Oliveira --- AUTHORS | 1 + changelog/13420.improvement.rst | 1 + src/_pytest/nodes.py | 12 +++++++----- 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 changelog/13420.improvement.rst diff --git a/AUTHORS b/AUTHORS index 9be48958485..e5b863e71f1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -332,6 +332,7 @@ Nikolay Kondratyev Nipunn Koorapati Oleg Pidsadnyi Oleg Sushchenko +Oleksandr Zavertniev Olga Matoula Oliver Bestwalter Omar Kohl diff --git a/changelog/13420.improvement.rst b/changelog/13420.improvement.rst new file mode 100644 index 00000000000..54fe50a72b0 --- /dev/null +++ b/changelog/13420.improvement.rst @@ -0,0 +1 @@ +Improved test collection performance by optimizing path resolution used in ``FSCollector``. diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index eb3b04b200a..6d39de95f5b 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -38,7 +38,6 @@ from _pytest.mark.structures import NodeKeywords from _pytest.outcomes import fail from _pytest.pathlib import absolutepath -from _pytest.pathlib import commonpath from _pytest.stash import Stash from _pytest.warning_types import PytestWarning @@ -548,10 +547,13 @@ def _traceback_filter(self, excinfo: ExceptionInfo[BaseException]) -> Traceback: def _check_initialpaths_for_relpath( initial_paths: frozenset[Path], path: Path ) -> str | None: - for initial_path in initial_paths: - if commonpath(path, initial_path) == initial_path: - rel = str(path.relative_to(initial_path)) - return "" if rel == "." else rel + if path in initial_paths: + return "" + + for parent in path.parents: + if parent in initial_paths: + return str(path.relative_to(parent)) + return None From 1d59ddfb4df278a47bbd4e3673d3390c50a8dc01 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sat, 31 May 2025 10:46:15 +0100 Subject: [PATCH 413/445] officially support python 3.14 (#13440) * test on py3.14 * add news * add 314 to tox.ini * fix ResourceWarning on pastebin http failures * fix ResourceWarning on pytest.raises with urllib.error * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * pass real types for HTTPError so it works in cmgr * xfail test_raises_bdbquit_with_eoferror * fix message for unraisable exceptions * use improved prog default value for argparse.ArgumentParser * Update testing/python/raises.py * Update testing/test_debugging.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * be more explicit in debugging xfail * Update changelog/13308.improvement.rst Co-authored-by: Bruno Oliveira * Update src/_pytest/pastebin.py * add 3.14 trove classifier * patch coverage * Update .github/workflows/test.yml --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: jakkdl Co-authored-by: Bruno Oliveira --- .github/workflows/test.yml | 17 ++++++++++- changelog/13308.improvement.rst | 1 + pyproject.toml | 3 +- src/_pytest/pastebin.py | 8 +++-- testing/python/raises.py | 9 ++++-- testing/test_debugging.py | 5 +++ testing/test_parseopt.py | 2 +- testing/test_pastebin.py | 47 +++++++++++++++++------------ testing/test_unraisableexception.py | 33 ++++++++++++++------ tox.ini | 1 + 10 files changed, 90 insertions(+), 36 deletions(-) create mode 100644 changelog/13308.improvement.rst diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 99ca032db9d..73c2892575b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -118,6 +118,10 @@ jobs: os: windows-latest tox_env: "py313" + - name: "windows-py314" + python: "3.14" + os: windows-latest + tox_env: "py314" - name: "ubuntu-py39-lsof-numpy-pexpect" python: "3.9" @@ -163,6 +167,12 @@ jobs: tox_env: "py313-pexpect" use_coverage: true + - name: "ubuntu-py314" + python: "3.14" + os: ubuntu-latest + tox_env: "py314" + use_coverage: true + - name: "ubuntu-pypy3-xdist" python: "pypy-3.9" os: ubuntu-latest @@ -190,6 +200,10 @@ jobs: os: macos-latest tox_env: "py313-xdist" + - name: "macos-py314" + python: "3.14" + os: macos-latest + tox_env: "py314-xdist" - name: "plugins" python: "3.12" @@ -239,7 +253,8 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} - check-latest: ${{ endsWith(matrix.python, '-dev') }} + check-latest: true + allow-prereleases: true - name: Install dependencies run: | diff --git a/changelog/13308.improvement.rst b/changelog/13308.improvement.rst new file mode 100644 index 00000000000..70018c66d59 --- /dev/null +++ b/changelog/13308.improvement.rst @@ -0,0 +1 @@ +Added official support for Python 3.14. diff --git a/pyproject.toml b/pyproject.toml index c7db5947cf4..4d4055147d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Testing", "Topic :: Utilities", @@ -349,7 +350,7 @@ ignore = "W009" [tool.pyproject-fmt] indent = 4 -max_supported_python = "3.13" +max_supported_python = "3.14" [tool.pytest.ini_options] minversion = "2.0" diff --git a/src/_pytest/pastebin.py b/src/_pytest/pastebin.py index d5c4f29c4c3..c7b39d96f02 100644 --- a/src/_pytest/pastebin.py +++ b/src/_pytest/pastebin.py @@ -76,6 +76,7 @@ def create_new_paste(contents: str | bytes) -> str: :returns: URL to the pasted contents, or an error message. """ import re + from urllib.error import HTTPError from urllib.parse import urlencode from urllib.request import urlopen @@ -85,8 +86,11 @@ def create_new_paste(contents: str | bytes) -> str: response: str = ( urlopen(url, data=urlencode(params).encode("ascii")).read().decode("utf-8") ) - except OSError as exc_info: # urllib errors - return f"bad response: {exc_info}" + except HTTPError as e: + with e: # HTTPErrors are also http responses that must be closed! + return f"bad response: {e}" + except OSError as e: # eg urllib.error.URLError + return f"bad response: {e}" m = re.search(r'href="/raw/(\w+)"', response) if m: return f"{url}/show/{m.group(1)}" diff --git a/testing/python/raises.py b/testing/python/raises.py index 3da260d1837..40f9afea3ba 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -1,6 +1,7 @@ # mypy: allow-untyped-defs from __future__ import annotations +import io import re import sys @@ -399,7 +400,11 @@ def test_issue_11872(self) -> None: https://github.com/python/cpython/issues/98778 """ + from email.message import Message from urllib.error import HTTPError - with pytest.raises(HTTPError, match="Not Found"): - raise HTTPError(code=404, msg="Not Found", fp=None, hdrs=None, url="") # type: ignore [arg-type] + with pytest.raises(HTTPError, match="Not Found") as exc_info: + raise HTTPError( + code=404, msg="Not Found", fp=io.BytesIO(), hdrs=Message(), url="" + ) + exc_info.value.close() # avoid a resource warning diff --git a/testing/test_debugging.py b/testing/test_debugging.py index 45883568b11..08ebf600253 100644 --- a/testing/test_debugging.py +++ b/testing/test_debugging.py @@ -1373,6 +1373,10 @@ def do_quit(self, *args): result.stdout.fnmatch_lines(["*runcall_called*", "* 1 passed in *"]) +@pytest.mark.xfail( + sys.version_info >= (3, 14), + reason="C-D now quits the test session, rather than failing the test. See https://github.com/python/cpython/issues/124703", +) def test_raises_bdbquit_with_eoferror(pytester: Pytester) -> None: """It is not guaranteed that DontReadFromInput's read is called.""" p1 = pytester.makepyfile( @@ -1387,6 +1391,7 @@ def test(monkeypatch): """ ) result = pytester.runpytest(str(p1)) + result.assert_outcomes(failed=1) result.stdout.fnmatch_lines(["E *BdbQuit", "*= 1 failed in*"]) assert result.ret == 1 diff --git a/testing/test_parseopt.py b/testing/test_parseopt.py index 14e2b5f69fb..36db7b13989 100644 --- a/testing/test_parseopt.py +++ b/testing/test_parseopt.py @@ -28,7 +28,7 @@ def test_no_help_by_default(self) -> None: def test_custom_prog(self, parser: parseopt.Parser) -> None: """Custom prog can be set for `argparse.ArgumentParser`.""" - assert parser._getparser().prog == os.path.basename(sys.argv[0]) + assert parser._getparser().prog == argparse.ArgumentParser().prog parser.prog = "custom-prog" assert parser._getparser().prog == "custom-prog" diff --git a/testing/test_pastebin.py b/testing/test_pastebin.py index 8fdd60bac75..9b928e00c06 100644 --- a/testing/test_pastebin.py +++ b/testing/test_pastebin.py @@ -3,6 +3,7 @@ import email.message import io +from unittest import mock from _pytest.monkeypatch import MonkeyPatch from _pytest.pytester import Pytester @@ -90,23 +91,6 @@ class TestPaste: def pastebin(self, request): return request.config.pluginmanager.getplugin("pastebin") - @pytest.fixture - def mocked_urlopen_fail(self, monkeypatch: MonkeyPatch): - """Monkeypatch the actual urlopen call to emulate a HTTP Error 400.""" - calls = [] - - import urllib.error - import urllib.request - - def mocked(url, data): - calls.append((url, data)) - raise urllib.error.HTTPError( - url, 400, "Bad request", email.message.Message(), io.BytesIO() - ) - - monkeypatch.setattr(urllib.request, "urlopen", mocked) - return calls - @pytest.fixture def mocked_urlopen_invalid(self, monkeypatch: MonkeyPatch): """Monkeypatch the actual urlopen calls done by the internal plugin @@ -158,10 +142,33 @@ def test_pastebin_invalid_url(self, pastebin, mocked_urlopen_invalid) -> None: ) assert len(mocked_urlopen_invalid) == 1 - def test_pastebin_http_error(self, pastebin, mocked_urlopen_fail) -> None: - result = pastebin.create_new_paste(b"full-paste-contents") + def test_pastebin_http_error(self, pastebin) -> None: + import urllib.error + + with mock.patch( + "urllib.request.urlopen", + side_effect=urllib.error.HTTPError( + url="https://bpa.st", + code=400, + msg="Bad request", + hdrs=email.message.Message(), + fp=io.BytesIO(), + ), + ) as mock_urlopen: + result = pastebin.create_new_paste(b"full-paste-contents") assert result == "bad response: HTTP Error 400: Bad request" - assert len(mocked_urlopen_fail) == 1 + assert len(mock_urlopen.mock_calls) == 1 + + def test_pastebin_url_error(self, pastebin) -> None: + import urllib.error + + with mock.patch( + "urllib.request.urlopen", + side_effect=urllib.error.URLError("the url was bad"), + ) as mock_urlopen: + result = pastebin.create_new_paste(b"full-paste-contents") + assert result == "bad response: " + assert len(mock_urlopen.mock_calls) == 1 def test_create_new_paste(self, pastebin, mocked_urlopen) -> None: result = pastebin.create_new_paste(b"full-paste-contents") diff --git a/testing/test_unraisableexception.py b/testing/test_unraisableexception.py index 328177a7ba3..6c0dc542e93 100644 --- a/testing/test_unraisableexception.py +++ b/testing/test_unraisableexception.py @@ -12,6 +12,24 @@ PYPY = hasattr(sys, "pypy_version_info") +UNRAISABLE_LINE = ( + ( + " * PytestUnraisableExceptionWarning: Exception ignored while calling " + "deallocator : None" + ) + if sys.version_info >= (3, 14) + else " * PytestUnraisableExceptionWarning: Exception ignored in: " +) + +TRACEMALLOC_LINES = ( + () + if sys.version_info >= (3, 14) + else ( + " Enable tracemalloc to get traceback where the object was allocated.", + " See https* for more info.", + ) +) + @pytest.mark.skipif(PYPY, reason="garbage-collection differences make this flaky") @pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning") @@ -36,13 +54,12 @@ def test_2(): pass [ "*= warnings summary =*", "test_it.py::test_it", - " * PytestUnraisableExceptionWarning: Exception ignored in: ", + UNRAISABLE_LINE, " ", " Traceback (most recent call last):", " ValueError: del is broken", " ", - " Enable tracemalloc to get traceback where the object was allocated.", - " See https* for more info.", + *TRACEMALLOC_LINES, " warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))", ] ) @@ -75,13 +92,12 @@ def test_2(): pass [ "*= warnings summary =*", "test_it.py::test_it", - " * PytestUnraisableExceptionWarning: Exception ignored in: ", + UNRAISABLE_LINE, " ", " Traceback (most recent call last):", " ValueError: del is broken", " ", - " Enable tracemalloc to get traceback where the object was allocated.", - " See https* for more info.", + *TRACEMALLOC_LINES, " warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))", ] ) @@ -115,13 +131,12 @@ def test_2(): pass [ "*= warnings summary =*", "test_it.py::test_it", - " * PytestUnraisableExceptionWarning: Exception ignored in: ", + UNRAISABLE_LINE, " ", " Traceback (most recent call last):", " ValueError: del is broken", " ", - " Enable tracemalloc to get traceback where the object was allocated.", - " See https* for more info.", + *TRACEMALLOC_LINES, " warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))", ] ) diff --git a/tox.ini b/tox.ini index 850def411cb..8f7d8495285 100644 --- a/tox.ini +++ b/tox.ini @@ -9,6 +9,7 @@ envlist = py311 py312 py313 + py314 pypy3 py39-{pexpect,xdist,unittestextras,numpy,pluggymain,pylib} doctesting From ca8b6f213617904fda04412391a3f00249dcf81e Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sat, 31 May 2025 19:44:27 +0100 Subject: [PATCH 414/445] fix GH ci jobs having the wrong name (#13454) * fix GH ci jobs having the wrong name * add news * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Delete changelog/13454.misc.rst --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 73c2892575b..3ecc133878f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -61,6 +61,7 @@ jobs: "windows-py311", "windows-py312", "windows-py313", + "windows-py314", "ubuntu-py39-lsof-numpy-pexpect", "ubuntu-py39-pluggy", @@ -70,12 +71,14 @@ jobs: "ubuntu-py311", "ubuntu-py312", "ubuntu-py313-pexpect", + "ubuntu-py314", "ubuntu-pypy3-xdist", "macos-py39", "macos-py310", "macos-py312", "macos-py313", + "macos-py314", "doctesting", "plugins", From 075c5efb1f0e752bd75543008f16c69cb9c60294 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Sat, 31 May 2025 22:10:04 +0200 Subject: [PATCH 415/445] use Contextmanagers to handle StopIteration in generators (#12934) * prepare example test for stopiteration passover issue * WIP: use contextmanagers instead of yield from as it turns out, StopIteration is not transparent on the boundaries of generators # Conflicts: # src/_pytest/threadexception.py # src/_pytest/unraisableexception.py * fixup rebase * rebase fixup more * add tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove hook_exceptions examples - these are tests now * add changelog * handle different numbers of === * handle different numbers of !!! --------- Co-authored-by: Thomas Grainger Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- changelog/12929.bugfix.rst | 1 + src/_pytest/logging.py | 10 ++++++--- testing/acceptance_test.py | 46 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 changelog/12929.bugfix.rst diff --git a/changelog/12929.bugfix.rst b/changelog/12929.bugfix.rst new file mode 100644 index 00000000000..fcf490d83e2 --- /dev/null +++ b/changelog/12929.bugfix.rst @@ -0,0 +1 @@ +Handle StopIteration from test cases, setup and teardown correctly. diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index ca5fbda6fcc..e4fed579d21 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -809,6 +809,7 @@ def pytest_runtest_logstart(self) -> None: def pytest_runtest_logreport(self) -> None: self.log_cli_handler.set_when("logreport") + @contextmanager def _runtest_for(self, item: nodes.Item, when: str) -> Generator[None]: """Implement the internals of the pytest_runtest_xxx() hooks.""" with ( @@ -838,20 +839,23 @@ def pytest_runtest_setup(self, item: nodes.Item) -> Generator[None]: empty: dict[str, list[logging.LogRecord]] = {} item.stash[caplog_records_key] = empty - yield from self._runtest_for(item, "setup") + with self._runtest_for(item, "setup"): + yield @hookimpl(wrapper=True) def pytest_runtest_call(self, item: nodes.Item) -> Generator[None]: self.log_cli_handler.set_when("call") - yield from self._runtest_for(item, "call") + with self._runtest_for(item, "call"): + yield @hookimpl(wrapper=True) def pytest_runtest_teardown(self, item: nodes.Item) -> Generator[None]: self.log_cli_handler.set_when("teardown") try: - yield from self._runtest_for(item, "teardown") + with self._runtest_for(item, "teardown"): + yield finally: del item.stash[caplog_records_key] del item.stash[caplog_handler_key] diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 2d653b8e2a5..4948e3ff8ae 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1606,3 +1606,49 @@ def test_no_terminal_plugin(pytester: Pytester) -> None: pytester.makepyfile("def test(): assert 1 == 2") result = pytester.runpytest("-pno:terminal", "-s") assert result.ret == ExitCode.TESTS_FAILED + + +def test_stop_iteration_from_collect(pytester: Pytester) -> None: + pytester.makepyfile(test_it="raise StopIteration('hello')") + result = pytester.runpytest() + assert result.ret == ExitCode.INTERRUPTED + result.assert_outcomes(failed=0, passed=0, errors=1) + result.stdout.fnmatch_lines( + [ + "=* short test summary info =*", + "ERROR test_it.py - StopIteration: hello", + "!* Interrupted: 1 error during collection !*", + "=* 1 error in * =*", + ] + ) + + +def test_stop_iteration_runtest_protocol(pytester: Pytester) -> None: + pytester.makepyfile( + test_it=""" + import pytest + @pytest.fixture + def fail_setup(): + raise StopIteration(1) + def test_fail_setup(fail_setup): + pass + def test_fail_teardown(request): + def stop_iteration(): + raise StopIteration(2) + request.addfinalizer(stop_iteration) + def test_fail_call(): + raise StopIteration(3) + """ + ) + result = pytester.runpytest() + assert result.ret == ExitCode.TESTS_FAILED + result.assert_outcomes(failed=1, passed=1, errors=2) + result.stdout.fnmatch_lines( + [ + "=* short test summary info =*", + "FAILED test_it.py::test_fail_call - StopIteration: 3", + "ERROR test_it.py::test_fail_setup - StopIteration: 1", + "ERROR test_it.py::test_fail_teardown - StopIteration: 2", + "=* 1 failed, 1 passed, 2 errors in * =*", + ] + ) From 261e7f15721a02cdc7361c60183b86fa36d0f72f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 1 Jun 2025 04:56:52 +0000 Subject: [PATCH 416/445] [automated] Update plugin list (#13455) Co-authored-by: pytest bot --- doc/en/reference/plugin_list.rst | 238 ++++++++++++++++++++----------- 1 file changed, 155 insertions(+), 83 deletions(-) diff --git a/doc/en/reference/plugin_list.rst b/doc/en/reference/plugin_list.rst index 69de1df9690..d0bf2083fe3 100644 --- a/doc/en/reference/plugin_list.rst +++ b/doc/en/reference/plugin_list.rst @@ -27,7 +27,7 @@ please refer to `the update script =8.3.4 :pypi:`pytest-airflow` pytest support for airflow. Apr 03, 2019 3 - Alpha pytest (>=4.4.0) :pypi:`pytest-airflow-utils` Nov 15, 2021 N/A N/A - :pypi:`pytest-alembic` A pytest plugin for verifying alembic migrations. May 16, 2025 N/A pytest>=7.0 + :pypi:`pytest-alembic` A pytest plugin for verifying alembic migrations. May 27, 2025 N/A pytest>=7.0 :pypi:`pytest-alerts` A pytest plugin for sending test results to Slack and Telegram Feb 21, 2025 4 - Beta pytest>=7.4.0 :pypi:`pytest-allclose` Pytest fixture extending Numpy's allclose function Jul 30, 2019 5 - Production/Stable pytest :pypi:`pytest-allure-adaptor` Plugin for py.test to generate allure xml reports Jan 10, 2018 N/A pytest (>=2.7.3) @@ -80,7 +80,7 @@ This list contains 1632 plugins. :pypi:`pytest-anki` A pytest plugin for testing Anki add-ons Jul 31, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-annotate` pytest-annotate: Generate PyAnnotate annotations from your pytest tests. Jun 07, 2022 3 - Alpha pytest (<8.0.0,>=3.2.0) :pypi:`pytest-annotated` Pytest plugin to allow use of Annotated in tests to resolve fixtures Sep 30, 2024 N/A pytest>=8.3.3 - :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures Apr 28, 2025 5 - Production/Stable pytest>=6 + :pypi:`pytest-ansible` Plugin for pytest to simplify calling ansible modules from tests or fixtures May 26, 2025 5 - Production/Stable pytest>=6 :pypi:`pytest-ansible-playbook` Pytest fixture which runs given ansible playbook file. Mar 08, 2019 4 - Beta N/A :pypi:`pytest-ansible-playbook-runner` Pytest fixture which runs given ansible playbook file. Dec 02, 2020 4 - Beta pytest (>=3.1.0) :pypi:`pytest-ansible-units` A pytest plugin for running unit tests within an ansible collection Apr 14, 2022 N/A N/A @@ -117,8 +117,9 @@ This list contains 1632 plugins. :pypi:`pytest-astropy-header` pytest plugin to add diagnostic information to the header of the test output Sep 06, 2022 3 - Alpha pytest (>=4.6) :pypi:`pytest-ast-transformer` May 04, 2019 3 - Alpha pytest :pypi:`pytest_async` pytest-async - Run your coroutine in event loop without decorator Feb 26, 2020 N/A N/A + :pypi:`pytest-async-benchmark` pytest-async-benchmark: Modern pytest benchmarking for async code. 🚀 May 28, 2025 N/A pytest>=8.3.5 :pypi:`pytest-async-generators` Pytest fixtures for async generators Jul 05, 2023 N/A N/A - :pypi:`pytest-asyncio` Pytest support for asyncio May 09, 2025 4 - Beta pytest<9,>=8.2 + :pypi:`pytest-asyncio` Pytest support for asyncio May 26, 2025 4 - Beta pytest<9,>=8.2 :pypi:`pytest-asyncio-concurrent` Pytest plugin to execute python async tests concurrently. May 17, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-asyncio-cooperative` Run all your asynchronous tests cooperatively. Apr 26, 2025 N/A N/A :pypi:`pytest-asyncio-network-simulator` pytest-asyncio-network-simulator: Plugin for pytest for simulator the network in tests Jul 31, 2018 3 - Alpha pytest (<3.7.0,>=3.3.2) @@ -162,7 +163,7 @@ This list contains 1632 plugins. :pypi:`pytest-bdd-wrappers` Feb 11, 2020 2 - Pre-Alpha N/A :pypi:`pytest-beakerlib` A pytest plugin that reports test results to the BeakerLib framework Mar 17, 2017 5 - Production/Stable pytest :pypi:`pytest-beartype` Pytest plugin to run your tests with beartype checking enabled. Oct 31, 2024 N/A pytest - :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests May 13, 2025 3 - Alpha pytest + :pypi:`pytest-bec-e2e` BEC pytest plugin for end-to-end tests May 30, 2025 3 - Alpha pytest :pypi:`pytest-beds` Fixtures for testing Google Appengine (GAE) apps Jun 07, 2016 4 - Beta N/A :pypi:`pytest-beeprint` use icdiff for better error messages in pytest assertions Jul 04, 2023 4 - Beta N/A :pypi:`pytest-bench` Benchmark utility that plugs into pytest. Jul 21, 2014 3 - Alpha N/A @@ -217,6 +218,7 @@ This list contains 1632 plugins. :pypi:`pytest-caprng` A plugin that replays pRNG state on failure. May 02, 2018 4 - Beta N/A :pypi:`pytest-capsqlalchemy` Pytest plugin to allow capturing SQLAlchemy queries. Mar 19, 2025 4 - Beta N/A :pypi:`pytest-capture-deprecatedwarnings` pytest plugin to capture all deprecatedwarnings and put them in one file Apr 30, 2019 N/A N/A + :pypi:`pytest-capture-sysout` An academic experiment package May 21, 2025 2 - Pre-Alpha N/A :pypi:`pytest-capture-warnings` pytest plugin to capture all warnings and put them in one file of your choice May 03, 2022 N/A pytest :pypi:`pytest-case` A clean, modern, wrapper for pytest.mark.parametrize Nov 25, 2024 N/A pytest<9.0.0,>=8.3.3 :pypi:`pytest-cases` Separate test code from test cases in pytest. Sep 26, 2024 5 - Production/Stable N/A @@ -225,6 +227,7 @@ This list contains 1632 plugins. :pypi:`pytest-catch-server` Pytest plugin with server for catching HTTP requests. Dec 12, 2019 5 - Production/Stable N/A :pypi:`pytest-cdist` A pytest plugin to split your test suite into multiple parts Jan 30, 2025 N/A pytest>=7 :pypi:`pytest-celery` Pytest plugin for Celery Feb 21, 2025 5 - Production/Stable N/A + :pypi:`pytest-celery-py37` Pytest plugin for Celery (compatible with python 3.7) May 23, 2025 5 - Production/Stable N/A :pypi:`pytest-cfg-fetcher` Pass config options to your unit tests. Feb 26, 2024 N/A N/A :pypi:`pytest-chainmaker` pytest plugin for chainmaker Oct 15, 2021 N/A N/A :pypi:`pytest-chalice` A set of py.test fixtures for AWS Chalice Jul 01, 2020 4 - Beta N/A @@ -239,7 +242,7 @@ This list contains 1632 plugins. :pypi:`pytest-check-library` check your missing library Jul 17, 2022 N/A N/A :pypi:`pytest-check-libs` check your missing library Jul 17, 2022 N/A N/A :pypi:`pytest-check-links` Check links in files Jul 29, 2020 N/A pytest<9,>=7.0 - :pypi:`pytest-checklist` Pytest plugin to track and report unit/function coverage. May 07, 2025 N/A N/A + :pypi:`pytest-checklist` Pytest plugin to track and report unit/function coverage. May 23, 2025 N/A N/A :pypi:`pytest-check-mk` pytest plugin to test Check_MK checks Nov 19, 2015 4 - Beta pytest :pypi:`pytest-checkpoint` Restore a checkpoint in pytest Mar 30, 2025 N/A pytest>=8.0.0 :pypi:`pytest-ch-framework` My pytest framework Apr 17, 2024 N/A pytest==8.0.1 @@ -280,7 +283,7 @@ This list contains 1632 plugins. :pypi:`pytest-codegen` Automatically create pytest test signatures Aug 23, 2020 2 - Pre-Alpha N/A :pypi:`pytest-codeowners` Pytest plugin for selecting tests by GitHub CODEOWNERS. Mar 30, 2022 4 - Beta pytest (>=6.0.0) :pypi:`pytest-codestyle` pytest plugin to run pycodestyle Mar 23, 2020 3 - Alpha N/A - :pypi:`pytest-codspeed` Pytest plugin to create CodSpeed benchmarks Jan 31, 2025 5 - Production/Stable pytest>=3.8 + :pypi:`pytest-codspeed` Pytest plugin to create CodSpeed benchmarks May 27, 2025 5 - Production/Stable pytest>=3.8 :pypi:`pytest-collect-appoint-info` set your encoding Aug 03, 2023 N/A pytest :pypi:`pytest-collect-formatter` Formatter for pytest collect output Mar 29, 2021 5 - Production/Stable N/A :pypi:`pytest-collect-formatter2` Formatter for pytest collect output May 31, 2021 5 - Production/Stable N/A @@ -323,7 +326,7 @@ This list contains 1632 plugins. :pypi:`pytest-cricri` A Cricri plugin for pytest. Jan 27, 2018 N/A pytest :pypi:`pytest-crontab` add crontab task in crontab Dec 09, 2019 N/A N/A :pypi:`pytest-csv` CSV output for pytest. Apr 22, 2021 N/A pytest (>=6.0) - :pypi:`pytest-csv-params` Pytest plugin for Test Case Parametrization with CSV files Oct 25, 2024 5 - Production/Stable pytest<9.0.0,>=8.3.0 + :pypi:`pytest-csv-params` Pytest plugin for Test Case Parametrization with CSV files May 29, 2025 5 - Production/Stable pytest<9,>=8.3 :pypi:`pytest-culprit` Find the last Git commit where a pytest test started failing May 15, 2025 N/A N/A :pypi:`pytest-curio` Pytest support for curio. Oct 06, 2024 N/A pytest :pypi:`pytest-curl-report` pytest plugin to generate curl command line report Dec 11, 2016 4 - Beta N/A @@ -338,11 +341,11 @@ This list contains 1632 plugins. :pypi:`pytest-cython-collect` Jun 17, 2022 N/A pytest :pypi:`pytest-darker` A pytest plugin for checking of modified code using Darker Feb 25, 2024 N/A pytest <7,>=6.0.1 :pypi:`pytest-dash` pytest fixtures to run dash applications. Mar 18, 2019 N/A N/A - :pypi:`pytest-dashboard` May 30, 2024 N/A pytest<8.0.0,>=7.4.3 + :pypi:`pytest-dashboard` May 20, 2025 N/A pytest<8.0.0,>=7.4.3 :pypi:`pytest-data` Useful functions for managing data for pytest fixtures Nov 01, 2016 5 - Production/Stable N/A - :pypi:`pytest-databases` Reusable database fixtures for any and all databases. Apr 21, 2025 4 - Beta pytest + :pypi:`pytest-databases` Reusable database fixtures for any and all databases. May 25, 2025 4 - Beta pytest :pypi:`pytest-databricks` Pytest plugin for remote Databricks notebooks testing Jul 29, 2020 N/A pytest - :pypi:`pytest-datadir` pytest plugin for test data directories and files Feb 07, 2025 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-datadir` pytest plugin for test data directories and files May 30, 2025 5 - Production/Stable pytest>=7.0 :pypi:`pytest-datadir-mgr` Manager for test data: downloads, artifact caching, and a tmpdir context. Apr 06, 2023 5 - Production/Stable pytest (>=7.1) :pypi:`pytest-datadir-ng` Fixtures for pytest allowing test functions/methods to easily retrieve test resources from the local filesystem. Dec 25, 2019 5 - Production/Stable pytest :pypi:`pytest-datadir-nng` Fixtures for pytest allowing test functions/methods to easily retrieve test resources from the local filesystem. Nov 09, 2022 5 - Production/Stable pytest (>=7.0.0,<8.0.0) @@ -423,7 +426,7 @@ This list contains 1632 plugins. :pypi:`pytest-doc` A documentation plugin for py.test. Jun 28, 2015 5 - Production/Stable N/A :pypi:`pytest-docfiles` pytest plugin to test codeblocks in your documentation. Dec 22, 2021 4 - Beta pytest (>=3.7.0) :pypi:`pytest-docgen` An RST Documentation Generator for pytest-based test suites Apr 17, 2020 N/A N/A - :pypi:`pytest-docker` Simple pytest fixtures for Docker and Docker Compose based tests Apr 07, 2025 N/A pytest<9.0,>=4.0 + :pypi:`pytest-docker` Simple pytest fixtures for Docker and Docker Compose based tests May 26, 2025 N/A pytest<9.0,>=4.0 :pypi:`pytest-docker-apache-fixtures` Pytest fixtures for testing with apache2 (httpd). Aug 12, 2024 4 - Beta pytest :pypi:`pytest-docker-butla` Jun 16, 2019 3 - Alpha N/A :pypi:`pytest-dockerc` Run, manage and stop Docker Compose project from Docker API Oct 09, 2020 5 - Production/Stable pytest (>=3.0) @@ -463,7 +466,7 @@ This list contains 1632 plugins. :pypi:`pytest-drop-dup-tests` A Pytest plugin to drop duplicated tests during collection Mar 04, 2024 5 - Production/Stable pytest >=7 :pypi:`pytest-dryci` Test caching plugin for pytest Sep 27, 2024 4 - Beta N/A :pypi:`pytest-dryrun` A Pytest plugin to ignore tests during collection without reporting them in the test summary. Jan 19, 2025 5 - Production/Stable pytest<9,>=7.40 - :pypi:`pytest-dsl` A DSL testing framework based on pytest May 07, 2025 N/A pytest>=7.0.0 + :pypi:`pytest-dsl` A DSL testing framework based on pytest May 29, 2025 N/A pytest>=7.0.0 :pypi:`pytest-dummynet` A py.test plugin providing access to a dummynet. Dec 15, 2021 5 - Production/Stable pytest :pypi:`pytest-dump2json` A pytest plugin for dumping test results to json. Jun 29, 2015 N/A N/A :pypi:`pytest-duration-insights` Jul 15, 2024 N/A N/A @@ -516,6 +519,7 @@ This list contains 1632 plugins. :pypi:`pytest_erp` py.test plugin to send test info to report portal dynamically Jan 13, 2015 N/A N/A :pypi:`pytest-error-for-skips` Pytest plugin to treat skipped tests a test failure Dec 19, 2019 4 - Beta pytest (>=4.6) :pypi:`pytest-errxfail` pytest plugin to mark a test as xfailed if it fails with the specified error message in the captured output Jan 06, 2025 4 - Beta pytest>=6.2.0 + :pypi:`pytest-essentials` A Pytest plugin providing essential utilities like soft assertions. May 19, 2025 3 - Alpha pytest>=7.0 :pypi:`pytest-eth` PyTest plugin for testing Smart Contracts for Ethereum Virtual Machine (EVM). Aug 14, 2020 1 - Planning N/A :pypi:`pytest-ethereum` pytest-ethereum: Pytest library for ethereum projects. Jun 24, 2019 3 - Alpha pytest (==3.3.2); extra == 'dev' :pypi:`pytest-eucalyptus` Pytest Plugin for BDD Jun 28, 2022 N/A pytest (>=4.2.0) @@ -614,7 +618,7 @@ This list contains 1632 plugins. :pypi:`pytest-flexreport` Apr 15, 2023 4 - Beta pytest :pypi:`pytest-fluent` A pytest plugin in order to provide logs via fluentd Aug 14, 2024 4 - Beta pytest>=7.0.0 :pypi:`pytest-fluentbit` A pytest plugin in order to provide logs via fluentbit Jun 16, 2023 4 - Beta pytest (>=7.0.0) - :pypi:`pytest-fly` pytest runner and observer May 03, 2025 3 - Alpha pytest + :pypi:`pytest-fly` pytest runner and observer May 19, 2025 3 - Alpha pytest :pypi:`pytest-flyte` Pytest fixtures for simplifying Flyte integration testing May 03, 2021 N/A pytest :pypi:`pytest-focus` A pytest plugin that alerts user of failed test cases with screen notifications May 04, 2019 4 - Beta pytest :pypi:`pytest-forbid` Mar 07, 2023 N/A pytest (>=7.2.2,<8.0.0) @@ -647,7 +651,7 @@ This list contains 1632 plugins. :pypi:`pytest-gherkin` A flexible framework for executing BDD gherkin tests Jul 27, 2019 3 - Alpha pytest (>=5.0.0) :pypi:`pytest-gh-log-group` pytest plugin for gh actions Jan 11, 2022 3 - Alpha pytest :pypi:`pytest-ghostinspector` For finding/executing Ghost Inspector tests May 17, 2016 3 - Alpha N/A - :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. May 08, 2025 N/A pytest>=3.6 + :pypi:`pytest-girder` A set of pytest fixtures for testing Girder applications. May 29, 2025 N/A pytest>=3.6 :pypi:`pytest-git` Git repository fixture for py.test Oct 17, 2024 5 - Production/Stable pytest :pypi:`pytest-gitconfig` Provide a Git config sandbox for testing Aug 11, 2024 4 - Beta pytest>=7.1.2 :pypi:`pytest-gitcov` Pytest plugin for reporting on coverage of the last git commit. Jan 11, 2020 2 - Pre-Alpha N/A @@ -667,6 +671,7 @@ This list contains 1632 plugins. :pypi:`pytest-golden` Plugin for pytest that offloads expected outputs to data files Jul 18, 2022 N/A pytest (>=6.1.2) :pypi:`pytest-goldie` A plugin to support golden tests with pytest. May 23, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-google-chat` Notify google chat channel for test results Mar 27, 2022 4 - Beta pytest + :pypi:`pytest-google-cloud-storage` Pytest custom features, e.g. fixtures and various tests. Aimed to emulate Google Cloud Storage service May 22, 2025 N/A pytest==8.3.5 :pypi:`pytest-gradescope` A pytest plugin for Gradescope integration Apr 29, 2025 N/A N/A :pypi:`pytest-graphql-schema` Get graphql schema as fixture for pytest Oct 18, 2019 N/A N/A :pypi:`pytest-greendots` Green progress dots Feb 08, 2014 3 - Alpha N/A @@ -692,7 +697,7 @@ This list contains 1632 plugins. :pypi:`pytest-history` Pytest plugin to keep a history of your pytest runs Jan 14, 2024 N/A pytest (>=7.4.3,<8.0.0) :pypi:`pytest-home` Home directory fixtures Jul 28, 2024 5 - Production/Stable pytest :pypi:`pytest-homeassistant` A pytest plugin for use with homeassistant custom components. Aug 12, 2020 4 - Beta N/A - :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components May 17, 2025 3 - Alpha pytest==8.3.5 + :pypi:`pytest-homeassistant-custom-component` Experimental package to automatically extract test plugins for Home Assistant custom components May 30, 2025 3 - Alpha pytest==8.3.5 :pypi:`pytest-honey` A simple plugin to use with pytest Jan 07, 2022 4 - Beta pytest (>=3.5.0) :pypi:`pytest-honors` Report on tests that honor constraints, and guard against regressions Mar 06, 2020 4 - Beta N/A :pypi:`pytest-hot-reloading` Sep 23, 2024 N/A N/A @@ -733,7 +738,7 @@ This list contains 1632 plugins. :pypi:`pytest-ignore-test-results` A pytest plugin to ignore test results. Feb 03, 2025 5 - Production/Stable pytest>=7.0 :pypi:`pytest-image-diff` Dec 31, 2024 3 - Alpha pytest :pypi:`pytest-image-snapshot` A pytest plugin for image snapshot management and comparison. Jul 01, 2024 4 - Beta pytest>=3.5.0 - :pypi:`pytest-impacted` A pytest plugin that selectively runs tests impacted by codechanges via git introspection, ASL parsing, and dependency graph analysis. May 15, 2025 4 - Beta pytest>=8.0.0 + :pypi:`pytest-impacted` A pytest plugin that selectively runs tests impacted by codechanges via git introspection, ASL parsing, and dependency graph analysis. May 31, 2025 4 - Beta pytest>=8.0.0 :pypi:`pytest-import-check` pytest plugin to check whether Python modules can be imported Jul 19, 2024 3 - Alpha pytest>=8.1 :pypi:`pytest-incremental` an incremental test runner (pytest plugin) Apr 24, 2021 5 - Production/Stable N/A :pypi:`pytest-infinity` Jun 09, 2024 N/A pytest<9.0.0,>=8.0.0 @@ -748,7 +753,7 @@ This list contains 1632 plugins. :pypi:`pytest-initry` Plugin for sending automation test data from Pytest to the initry Apr 30, 2024 N/A pytest<9.0.0,>=8.1.1 :pypi:`pytest-inline` A pytest plugin for writing inline tests Oct 24, 2024 4 - Beta pytest<9.0,>=7.0 :pypi:`pytest-inmanta` A py.test plugin providing fixtures to simplify inmanta modules testing. Apr 09, 2025 5 - Production/Stable pytest - :pypi:`pytest-inmanta-extensions` Inmanta tests package Apr 10, 2025 5 - Production/Stable N/A + :pypi:`pytest-inmanta-extensions` Inmanta tests package May 27, 2025 5 - Production/Stable N/A :pypi:`pytest-inmanta-lsm` Common fixtures for inmanta LSM related modules Apr 09, 2025 5 - Production/Stable N/A :pypi:`pytest-inmanta-srlinux` Pytest library to facilitate end to end testing of inmanta projects Apr 22, 2025 3 - Alpha N/A :pypi:`pytest-inmanta-yang` Common fixtures used in inmanta yang related modules Feb 22, 2024 4 - Beta pytest @@ -769,9 +774,9 @@ This list contains 1632 plugins. :pypi:`pytest-ipdb` A py.test plug-in to enable drop to ipdb debugger on test failure. Mar 20, 2013 2 - Pre-Alpha N/A :pypi:`pytest-ipynb` THIS PROJECT IS ABANDONED Jan 29, 2019 3 - Alpha N/A :pypi:`pytest-ipynb2` Pytest plugin to run tests in Jupyter Notebooks Mar 09, 2025 N/A pytest - :pypi:`pytest-ipywidgets` Apr 30, 2025 N/A pytest + :pypi:`pytest-ipywidgets` May 30, 2025 N/A pytest :pypi:`pytest-iso` Plugin for pytest to produce test documentation for code audits. May 15, 2025 4 - Beta pytest<9.0.0,>=7.4.0 - :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses Apr 22, 2025 4 - Beta pytest + :pypi:`pytest-isolate` Run pytest tests in isolated subprocesses May 22, 2025 4 - Beta pytest :pypi:`pytest-isolate-mpi` pytest-isolate-mpi allows for MPI-parallel tests being executed in a segfault and MPI_Abort safe manner Feb 24, 2025 4 - Beta pytest>=5 :pypi:`pytest-isort` py.test plugin to check import ordering using isort Mar 05, 2024 5 - Production/Stable pytest (>=5.0) :pypi:`pytest-it` Pytest plugin to display test reports as a plaintext spec, inspired by Rspec: https://github.com/mattduck/pytest-it. Jan 29, 2024 4 - Beta N/A @@ -786,7 +791,7 @@ This list contains 1632 plugins. :pypi:`pytest-jinja` A plugin to generate customizable jinja-based HTML reports in pytest Oct 04, 2022 3 - Alpha pytest (>=6.2.5,<7.0.0) :pypi:`pytest-jira` py.test JIRA integration plugin, using markers Apr 15, 2025 3 - Alpha N/A :pypi:`pytest-jira-xfail` Plugin skips (xfail) tests if unresolved Jira issue(s) linked Jul 09, 2024 N/A pytest>=7.2.0 - :pypi:`pytest-jira-xray` pytest plugin to integrate tests with JIRA XRAY Oct 27, 2024 4 - Beta pytest>=6.2.4 + :pypi:`pytest-jira-xray` pytest plugin to integrate tests with JIRA XRAY May 24, 2025 4 - Beta pytest>=6.2.4 :pypi:`pytest-job-selection` A pytest plugin for load balancing test suites Jan 30, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-jobserver` Limit parallel tests with posix jobserver. May 15, 2019 5 - Production/Stable pytest :pypi:`pytest-joke` Test failures are better served with humor. Oct 08, 2019 4 - Beta pytest (>=4.2.1) @@ -827,14 +832,14 @@ This list contains 1632 plugins. :pypi:`pytest-launchable` Launchable Pytest Plugin Apr 05, 2023 N/A pytest (>=4.2.0) :pypi:`pytest-layab` Pytest fixtures for layab. Oct 05, 2020 5 - Production/Stable N/A :pypi:`pytest-lazy-fixture` It helps to use fixtures in pytest.mark.parametrize Feb 01, 2020 4 - Beta pytest (>=3.2.5) - :pypi:`pytest-lazy-fixtures` Allows you to use fixtures in @pytest.mark.parametrize. Jan 25, 2025 N/A pytest>=7 + :pypi:`pytest-lazy-fixtures` Allows you to use fixtures in @pytest.mark.parametrize. May 27, 2025 N/A pytest>=7 :pypi:`pytest-ldap` python-ldap fixtures for pytest Aug 18, 2020 N/A pytest :pypi:`pytest-leak-finder` Find the test that's leaking before the one that fails Feb 15, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-leaks` A pytest plugin to trace resource leaks. Nov 27, 2019 1 - Planning N/A :pypi:`pytest-leaping` A simple plugin to use with pytest Mar 27, 2024 4 - Beta pytest>=6.2.0 :pypi:`pytest-leo-interface` Pytest extension tool for leo projects. Mar 19, 2025 N/A N/A :pypi:`pytest-level` Select tests of a given level or lower Oct 21, 2019 N/A pytest - :pypi:`pytest-lf-skip` A pytest plugin which makes \`--last-failed\` skip instead of deselect tests. May 06, 2025 4 - Beta pytest>=8.3.5 + :pypi:`pytest-lf-skip` A pytest plugin which makes \`--last-failed\` skip instead of deselect tests. May 26, 2025 4 - Beta pytest>=8.3.5 :pypi:`pytest-libfaketime` A python-libfaketime plugin for pytest Apr 12, 2024 4 - Beta pytest>=3.0.0 :pypi:`pytest-libiio` A pytest plugin to manage interfacing with libiio contexts Oct 01, 2024 4 - Beta N/A :pypi:`pytest-libnotify` Pytest plugin that shows notifications about the test run Apr 02, 2021 3 - Alpha pytest @@ -862,7 +867,7 @@ This list contains 1632 plugins. :pypi:`pytest-logger` Plugin configuring handlers for loggers from Python logging module. Mar 10, 2024 5 - Production/Stable pytest (>=3.2) :pypi:`pytest-logging` Configures logging and allows tweaking the log level with a py.test flag Nov 04, 2015 4 - Beta N/A :pypi:`pytest-logging-end-to-end-test-tool` Sep 23, 2022 N/A pytest (>=7.1.2,<8.0.0) - :pypi:`pytest-logging-strict` pytest fixture logging configured from packaged YAML Apr 09, 2025 3 - Alpha pytest + :pypi:`pytest-logging-strict` pytest fixture logging configured from packaged YAML May 20, 2025 3 - Alpha pytest :pypi:`pytest-logikal` Common testing environment Apr 30, 2025 5 - Production/Stable pytest==8.3.5 :pypi:`pytest-log-report` Package for creating a pytest test run reprot Dec 26, 2019 N/A N/A :pypi:`pytest-logscanner` Pytest plugin for logscanner (A logger for python logging outputting to easily viewable (and filterable) html files. Good for people not grep savey, and color higlighting and quickly changing filters might even bye useful for commandline wizards.) Sep 30, 2024 4 - Beta pytest>=8.2.2 @@ -920,7 +925,7 @@ This list contains 1632 plugins. :pypi:`pytest-mitmproxy-plugin` Use MITM Proxy in autotests with full control from code Apr 10, 2025 4 - Beta pytest>=7.2.0 :pypi:`pytest-ml` Test your machine learning! May 04, 2019 4 - Beta N/A :pypi:`pytest-mocha` pytest plugin to display test execution output like a mochajs Apr 02, 2020 4 - Beta pytest (>=5.4.0) - :pypi:`pytest-mock` Thin-wrapper around the mock package for easier use with pytest Mar 21, 2024 5 - Production/Stable pytest>=6.2.5 + :pypi:`pytest-mock` Thin-wrapper around the mock package for easier use with pytest May 26, 2025 5 - Production/Stable pytest>=6.2.5 :pypi:`pytest-mock-api` A mock API server with configurable routes and responses available as a fixture. Feb 13, 2019 1 - Planning pytest (>=4.0.0) :pypi:`pytest-mock-generator` A pytest fixture wrapper for https://pypi.org/project/mock-generator May 16, 2022 5 - Production/Stable N/A :pypi:`pytest-mock-helper` Help you mock HTTP call and generate mock code Jan 24, 2018 N/A pytest @@ -1001,7 +1006,7 @@ This list contains 1632 plugins. :pypi:`pytest-object-getter` Import any object from a 3rd party module while mocking its namespace on demand. Jul 31, 2022 5 - Production/Stable pytest :pypi:`pytest-ochrus` pytest results data-base and HTML reporter Feb 21, 2018 4 - Beta N/A :pypi:`pytest-odc` A pytest plugin for simplifying ODC database tests Aug 04, 2023 4 - Beta pytest (>=3.5.0) - :pypi:`pytest-odoo` py.test plugin to run Odoo tests Mar 12, 2025 5 - Production/Stable pytest>=8 + :pypi:`pytest-odoo` py.test plugin to run Odoo tests May 20, 2025 5 - Production/Stable pytest>=8 :pypi:`pytest-odoo-fixtures` Project description Jun 25, 2019 N/A N/A :pypi:`pytest-oerp` pytest plugin to test OpenERP modules Feb 28, 2012 3 - Alpha N/A :pypi:`pytest-offline` Mar 09, 2023 1 - Planning pytest (>=7.0.0,<8.0.0) @@ -1061,7 +1066,7 @@ This list contains 1632 plugins. :pypi:`pytest-performancetotal` A performance plugin for pytest Feb 01, 2025 5 - Production/Stable N/A :pypi:`pytest-persistence` Pytest tool for persistent objects Aug 21, 2024 N/A N/A :pypi:`pytest-pexpect` Pytest pexpect plugin. Aug 13, 2024 4 - Beta pytest>=6.2.0 - :pypi:`pytest-pg` A tiny plugin for pytest which runs PostgreSQL in Docker May 11, 2025 5 - Production/Stable pytest>=7.4 + :pypi:`pytest-pg` A tiny plugin for pytest which runs PostgreSQL in Docker May 18, 2025 5 - Production/Stable pytest>=7.4 :pypi:`pytest-pgsql` Pytest plugins and helpers for tests using a Postgres database. May 13, 2020 5 - Production/Stable pytest (>=3.0.0) :pypi:`pytest-phmdoctest` pytest plugin to test Python examples in Markdown using phmdoctest. Apr 15, 2022 4 - Beta pytest (>=5.4.3) :pypi:`pytest-phoenix-interface` Pytest extension tool for phoenix projects. Mar 19, 2025 N/A N/A @@ -1123,6 +1128,7 @@ This list contains 1632 plugins. :pypi:`pytest-progress` pytest plugin for instant test progress status Jun 18, 2024 5 - Production/Stable pytest>=2.7 :pypi:`pytest-prometheus` Report test pass / failures to a Prometheus PushGateway Oct 03, 2017 N/A N/A :pypi:`pytest-prometheus-pushgateway` Pytest report plugin for Zulip Sep 27, 2022 5 - Production/Stable pytest + :pypi:`pytest-prometheus-pushgw` Pytest plugin to export test metrics to Prometheus Pushgateway May 19, 2025 N/A pytest>=6.0.0 :pypi:`pytest-prosper` Test helpers for Prosper projects Sep 24, 2018 N/A N/A :pypi:`pytest-prysk` Pytest plugin for prysk Dec 10, 2024 4 - Beta pytest>=7.3.2 :pypi:`pytest-pspec` A rspec format reporter for Python ptest Jun 02, 2020 4 - Beta pytest (>=3.0.0) @@ -1200,7 +1206,7 @@ This list contains 1632 plugins. :pypi:`pytest-reference-formatter` Conveniently run pytest with a dot-formatted test reference. Oct 01, 2019 4 - Beta N/A :pypi:`pytest-regex` Select pytest tests with regular expressions May 29, 2023 4 - Beta pytest (>=3.5.0) :pypi:`pytest-regex-dependency` Management of Pytest dependencies via regex patterns Jun 12, 2022 N/A pytest - :pypi:`pytest-regressions` Easy to use fixtures to write regression tests. Jan 10, 2025 5 - Production/Stable pytest>=6.2.0 + :pypi:`pytest-regressions` Easy to use fixtures to write regression tests. May 30, 2025 5 - Production/Stable pytest>=6.2.0 :pypi:`pytest-regtest` pytest plugin for snapshot regression testing Nov 12, 2024 N/A pytest>7.2 :pypi:`pytest-relative-order` a pytest plugin that sorts tests using "before" and "after" markers May 17, 2021 4 - Beta N/A :pypi:`pytest-relative-path` Handle relative path in pytest options or ini configs Aug 30, 2024 N/A pytest @@ -1218,6 +1224,7 @@ This list contains 1632 plugins. :pypi:`pytest-reporter` Generate Pytest reports with templates Feb 28, 2024 4 - Beta pytest :pypi:`pytest-reporter-html1` A basic HTML report template for Pytest May 06, 2025 4 - Beta N/A :pypi:`pytest-reporter-html-dots` A basic HTML report for pytest using Jinja2 template engine. Apr 26, 2025 N/A N/A + :pypi:`pytest-reporter-plus` Lightweight enhanced HTML reporter for Pytest May 31, 2025 N/A N/A :pypi:`pytest-report-extras` Pytest plugin to enhance pytest-html and allure reports by adding comments, screenshots, webpage sources and attachments. Apr 04, 2025 N/A pytest>=8.0.0 :pypi:`pytest-reportinfra` Pytest plugin for reportinfra Aug 11, 2019 3 - Alpha N/A :pypi:`pytest-reporting` A plugin to report summarized results in a table format Oct 25, 2019 4 - Beta pytest (>=3.5.0) @@ -1253,6 +1260,7 @@ This list contains 1632 plugins. :pypi:`pytest-result-notify` Default template for PDM package Apr 27, 2025 N/A pytest>=8.3.5 :pypi:`pytest-results` Easily spot regressions in your tests. May 06, 2025 4 - Beta pytest :pypi:`pytest-result-sender` Apr 20, 2023 N/A pytest>=7.3.1 + :pypi:`pytest-result-sender-jms` Default template for PDM package May 22, 2025 N/A pytest>=8.3.5 :pypi:`pytest-result-sender-lj` Default template for PDM package Dec 17, 2024 N/A pytest>=8.3.4 :pypi:`pytest-result-sender-lyt` Default template for PDM package Mar 14, 2025 N/A pytest>=8.3.5 :pypi:`pytest-result-sender-misszhang` Default template for PDM package Mar 21, 2025 N/A pytest>=8.3.5 @@ -1281,7 +1289,7 @@ This list contains 1632 plugins. :pypi:`pytest-ruff` pytest plugin to check ruff requirements. Jul 21, 2024 4 - Beta pytest>=5 :pypi:`pytest-run-changed` Pytest plugin that runs changed tests only Apr 02, 2021 3 - Alpha pytest :pypi:`pytest-runfailed` implement a --failed option for pytest Mar 24, 2016 N/A N/A - :pypi:`pytest-run-parallel` A simple pytest plugin to run tests concurrently Apr 22, 2025 4 - Beta pytest>=6.2.0 + :pypi:`pytest-run-parallel` A simple pytest plugin to run tests concurrently May 27, 2025 4 - Beta pytest>=6.2.0 :pypi:`pytest-run-subprocess` Pytest Plugin for running and testing subprocesses. Nov 12, 2022 5 - Production/Stable pytest :pypi:`pytest-runtime-types` Checks type annotations on runtime while running tests. Feb 09, 2023 N/A pytest :pypi:`pytest-runtime-xfail` Call runtime_xfail() to mark running test as xfail. Aug 26, 2021 N/A pytest>=5.0.0 @@ -1298,9 +1306,9 @@ This list contains 1632 plugins. :pypi:`pytest-sanity` Dec 07, 2020 N/A N/A :pypi:`pytest-sa-pg` May 14, 2019 N/A N/A :pypi:`pytest_sauce` pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs Jul 14, 2014 3 - Alpha N/A - :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. May 13, 2025 5 - Production/Stable N/A + :pypi:`pytest-sbase` A complete web automation framework for end-to-end testing. May 27, 2025 5 - Production/Stable N/A :pypi:`pytest-scenario` pytest plugin for test scenarios Feb 06, 2017 3 - Alpha N/A - :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 13, 2025 5 - Production/Stable pytest>=7.0 + :pypi:`pytest-scenario-files` A pytest plugin that generates unit test scenarios from data files. May 21, 2025 5 - Production/Stable pytest>=7.0 :pypi:`pytest-schedule` Automate and customize test scheduling effortlessly on local machines. Oct 31, 2024 N/A N/A :pypi:`pytest-schema` 👍 Validate return values against a schema-like object in testing Feb 16, 2024 5 - Production/Stable pytest >=3.5.0 :pypi:`pytest-scim2-server` SCIM2 server fixture for Pytest May 14, 2025 4 - Beta pytest>=8.3.4 @@ -1310,12 +1318,12 @@ This list contains 1632 plugins. :pypi:`pytest-select` A pytest plugin which allows to (de-)select tests from a file. Jan 18, 2019 3 - Alpha pytest (>=3.0) :pypi:`pytest-selenium` pytest plugin for Selenium Feb 01, 2024 5 - Production/Stable pytest>=6.0.0 :pypi:`pytest-selenium-auto` pytest plugin to automatically capture screenshots upon selenium webdriver events Nov 07, 2023 N/A pytest >= 7.0.0 - :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. May 13, 2025 5 - Production/Stable N/A + :pypi:`pytest-seleniumbase` A complete web automation framework for end-to-end testing. May 27, 2025 5 - Production/Stable N/A :pypi:`pytest-selenium-enhancer` pytest plugin for Selenium Apr 29, 2022 5 - Production/Stable N/A :pypi:`pytest-selenium-pdiff` A pytest package implementing perceptualdiff for Selenium tests. Apr 06, 2017 2 - Pre-Alpha N/A :pypi:`pytest-selfie` A pytest plugin for selfie snapshot testing. Dec 16, 2024 N/A pytest>=8.0.0 :pypi:`pytest-send-email` Send pytest execution result email Sep 02, 2024 N/A pytest - :pypi:`pytest-sentry` A pytest plugin to send testrun information to Sentry.io Feb 24, 2025 N/A pytest + :pypi:`pytest-sentry` A pytest plugin to send testrun information to Sentry.io May 23, 2025 N/A pytest :pypi:`pytest-sequence-markers` Pytest plugin for sequencing markers for execution of tests May 23, 2023 5 - Production/Stable N/A :pypi:`pytest-server` test server exec cmd Sep 09, 2024 N/A N/A :pypi:`pytest-server-fixtures` Extensible server fixtures for py.test Nov 29, 2024 5 - Production/Stable pytest @@ -1358,7 +1366,7 @@ This list contains 1632 plugins. :pypi:`pytest-smartcollect` A plugin for collecting tests that touch changed code Oct 04, 2018 N/A pytest (>=3.5.0) :pypi:`pytest-smartcov` Smart coverage plugin for pytest. Sep 30, 2017 3 - Alpha N/A :pypi:`pytest-smell` Automated bad smell detection tool for Pytest Jun 26, 2022 N/A N/A - :pypi:`pytest-smoke` Pytest plugin for smoke testing Mar 25, 2025 4 - Beta pytest<9,>=7.0.0 + :pypi:`pytest-smoke` Pytest plugin for smoke testing May 23, 2025 4 - Beta pytest<9,>=7.0.0 :pypi:`pytest-smtp` Send email with pytest execution result Feb 20, 2021 N/A pytest :pypi:`pytest-smtp4dev` Plugin for smtp4dev API Jun 27, 2023 5 - Production/Stable N/A :pypi:`pytest-smtpd` An SMTP server for testing built on aiosmtpd May 15, 2023 N/A pytest @@ -1380,7 +1388,7 @@ This list contains 1632 plugins. :pypi:`pytest-sorter` A simple plugin to first execute tests that historically failed more Apr 20, 2021 4 - Beta pytest (>=3.1.1) :pypi:`pytest-sosu` Unofficial PyTest plugin for Sauce Labs Aug 04, 2023 2 - Pre-Alpha pytest :pypi:`pytest-sourceorder` Test-ordering plugin for pytest Sep 01, 2021 4 - Beta pytest - :pypi:`pytest-spark` pytest plugin to run the tests with support of pyspark. Mar 21, 2025 4 - Beta pytest + :pypi:`pytest-spark` pytest plugin to run the tests with support of pyspark. May 21, 2025 4 - Beta pytest :pypi:`pytest-spawner` py.test plugin to spawn process and communicate with them. Jul 31, 2015 4 - Beta N/A :pypi:`pytest-spec` Library pytest-spec is a pytest plugin to display test execution output like a SPECIFICATION. Aug 04, 2024 N/A pytest; extra == "test" :pypi:`pytest-spec2md` Library pytest-spec2md is a pytest plugin to create a markdown specification while running pytest. Apr 10, 2024 N/A pytest>7.0 @@ -1408,7 +1416,7 @@ This list contains 1632 plugins. :pypi:`pytest-srcpaths` Add paths to sys.path Oct 15, 2021 N/A pytest>=6.2.0 :pypi:`pytest-ssh` pytest plugin for ssh command run May 27, 2019 N/A pytest :pypi:`pytest-start-from` Start pytest run from a given point Apr 11, 2016 N/A N/A - :pypi:`pytest-static` pytest-static Oct 20, 2024 1 - Planning pytest<8.0.0,>=7.4.3 + :pypi:`pytest-static` pytest-static May 25, 2025 3 - Alpha pytest<8.0.0,>=7.4.3 :pypi:`pytest-stats` Collects tests metadata for future analysis, easy to extend for any data store Jul 18, 2024 N/A pytest>=8.0.0 :pypi:`pytest-statsd` pytest plugin for reporting to graphite Nov 30, 2018 5 - Production/Stable pytest (>=3.0.0) :pypi:`pytest-status` Add status mark for tests Aug 22, 2024 N/A pytest @@ -1419,7 +1427,7 @@ This list contains 1632 plugins. :pypi:`pytest-stochastics` pytest plugin that allows selectively running tests several times and accepting \*some\* failures. Dec 01, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-stoq` A plugin to pytest stoq Feb 09, 2021 4 - Beta N/A :pypi:`pytest-store` Pytest plugin to store values from test runs Sep 04, 2024 3 - Alpha pytest>=7.0.0 - :pypi:`pytest-streaming` Plugin for testing pubsub, pulsar, and kafka systems with pytest locally and in ci/cd May 16, 2025 N/A pytest>=8.3.5 + :pypi:`pytest-streaming` Plugin for testing pubsub, pulsar, and kafka systems with pytest locally and in ci/cd May 28, 2025 5 - Production/Stable pytest>=8.3.5 :pypi:`pytest-stress` A Pytest plugin that allows you to loop tests for a user defined amount of time. Dec 07, 2019 4 - Beta pytest (>=3.6.0) :pypi:`pytest-structlog` Structured logging assertions Jul 25, 2024 N/A pytest :pypi:`pytest-structmpd` provide structured temporary directory Oct 17, 2018 N/A N/A @@ -1552,10 +1560,11 @@ This list contains 1632 plugins. :pypi:`pytest-twilio-conversations-client-mock` Aug 02, 2022 N/A N/A :pypi:`pytest-twisted` A twisted plugin for pytest. Sep 10, 2024 5 - Production/Stable pytest>=2.3 :pypi:`pytest-typechecker` Run type checkers on specified test files Feb 04, 2022 N/A pytest (>=6.2.5,<7.0.0) + :pypi:`pytest-typed-schema-shot` Pytest plugin for automatic JSON Schema generation and validation from examples May 24, 2025 N/A pytest :pypi:`pytest-typhoon-config` A Typhoon HIL plugin that facilitates test parameter configuration at runtime Apr 07, 2022 5 - Production/Stable N/A :pypi:`pytest-typhoon-polarion` Typhoontest plugin for Siemens Polarion Feb 01, 2024 4 - Beta N/A :pypi:`pytest-typhoon-xray` Typhoon HIL plugin for pytest Aug 15, 2023 4 - Beta N/A - :pypi:`pytest-typing-runner` Pytest plugin to make it easier to run and check python code against static type checkers Oct 27, 2024 N/A N/A + :pypi:`pytest-typing-runner` Pytest plugin to make it easier to run and check python code against static type checkers May 31, 2025 N/A N/A :pypi:`pytest-tytest` Typhoon HIL plugin for pytest May 25, 2020 4 - Beta pytest (>=5.4.2) :pypi:`pytest-ubersmith` Easily mock calls to ubersmith at the \`requests\` level. Apr 13, 2015 N/A N/A :pypi:`pytest-ui` Text User Interface for running python tests Jul 05, 2021 4 - Beta pytest @@ -1618,7 +1627,7 @@ This list contains 1632 plugins. :pypi:`pytest-with-docker` pytest with docker helpers. Nov 09, 2021 N/A pytest :pypi:`pytest-workaround-12888` forces an import of readline early in the process to work around pytest bug #12888 Jan 15, 2025 N/A N/A :pypi:`pytest-workflow` A pytest plugin for configuring workflow/pipeline tests using YAML files Mar 18, 2024 5 - Production/Stable pytest >=7.0.0 - :pypi:`pytest-xdist` pytest xdist plugin for distributed testing, most importantly across multiple CPUs Apr 28, 2024 5 - Production/Stable pytest>=7.0.0 + :pypi:`pytest-xdist` pytest xdist plugin for distributed testing, most importantly across multiple CPUs May 26, 2025 5 - Production/Stable pytest>=7.0.0 :pypi:`pytest-xdist-debug-for-graingert` pytest xdist plugin for distributed testing and loop-on-failing modes Jul 24, 2019 5 - Production/Stable pytest (>=4.4.0) :pypi:`pytest-xdist-forked` forked from pytest-xdist Feb 10, 2020 5 - Production/Stable pytest (>=4.4.0) :pypi:`pytest-xdist-lock` Extension for pytest-xdist adding test and resource group locks for local and distributed runs Apr 26, 2025 N/A pytest>=6.0 @@ -1636,7 +1645,7 @@ This list contains 1632 plugins. :pypi:`pytest-xprocess` A pytest plugin for managing processes across test runs. May 19, 2024 4 - Beta pytest>=2.8 :pypi:`pytest-xray` May 30, 2019 3 - Alpha N/A :pypi:`pytest-xrayjira` Mar 17, 2020 3 - Alpha pytest (==4.3.1) - :pypi:`pytest-xray-reporter` A pytest plugin that generates test results in Xray JSON format May 08, 2025 4 - Beta pytest>=7.0.0 + :pypi:`pytest-xray-reporter` Pytest plugin for generating Xray JSON reports May 21, 2025 4 - Beta pytest>=7.0.0 :pypi:`pytest-xray-server` May 03, 2022 3 - Alpha pytest (>=5.3.1) :pypi:`pytest-xstress` Jun 01, 2024 N/A pytest<9.0.0,>=8.0.0 :pypi:`pytest-xvfb` A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests. Mar 12, 2025 4 - Beta pytest>=2.8.1 @@ -1875,7 +1884,7 @@ This list contains 1632 plugins. :pypi:`pytest-alembic` - *last release*: May 16, 2025, + *last release*: May 27, 2025, *status*: N/A, *requires*: pytest>=7.0 @@ -1994,7 +2003,7 @@ This list contains 1632 plugins. Pytest plugin to allow use of Annotated in tests to resolve fixtures :pypi:`pytest-ansible` - *last release*: Apr 28, 2025, + *last release*: May 26, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=6 @@ -2252,6 +2261,13 @@ This list contains 1632 plugins. pytest-async - Run your coroutine in event loop without decorator + :pypi:`pytest-async-benchmark` + *last release*: May 28, 2025, + *status*: N/A, + *requires*: pytest>=8.3.5 + + pytest-async-benchmark: Modern pytest benchmarking for async code. 🚀 + :pypi:`pytest-async-generators` *last release*: Jul 05, 2023, *status*: N/A, @@ -2260,7 +2276,7 @@ This list contains 1632 plugins. Pytest fixtures for async generators :pypi:`pytest-asyncio` - *last release*: May 09, 2025, + *last release*: May 26, 2025, *status*: 4 - Beta, *requires*: pytest<9,>=8.2 @@ -2568,7 +2584,7 @@ This list contains 1632 plugins. Pytest plugin to run your tests with beartype checking enabled. :pypi:`pytest-bec-e2e` - *last release*: May 13, 2025, + *last release*: May 30, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -2952,6 +2968,13 @@ This list contains 1632 plugins. pytest plugin to capture all deprecatedwarnings and put them in one file + :pypi:`pytest-capture-sysout` + *last release*: May 21, 2025, + *status*: 2 - Pre-Alpha, + *requires*: N/A + + An academic experiment package + :pypi:`pytest-capture-warnings` *last release*: May 03, 2022, *status*: N/A, @@ -3008,6 +3031,13 @@ This list contains 1632 plugins. Pytest plugin for Celery + :pypi:`pytest-celery-py37` + *last release*: May 23, 2025, + *status*: 5 - Production/Stable, + *requires*: N/A + + Pytest plugin for Celery (compatible with python 3.7) + :pypi:`pytest-cfg-fetcher` *last release*: Feb 26, 2024, *status*: N/A, @@ -3107,7 +3137,7 @@ This list contains 1632 plugins. Check links in files :pypi:`pytest-checklist` - *last release*: May 07, 2025, + *last release*: May 23, 2025, *status*: N/A, *requires*: N/A @@ -3394,7 +3424,7 @@ This list contains 1632 plugins. pytest plugin to run pycodestyle :pypi:`pytest-codspeed` - *last release*: Jan 31, 2025, + *last release*: May 27, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=3.8 @@ -3695,9 +3725,9 @@ This list contains 1632 plugins. CSV output for pytest. :pypi:`pytest-csv-params` - *last release*: Oct 25, 2024, + *last release*: May 29, 2025, *status*: 5 - Production/Stable, - *requires*: pytest<9.0.0,>=8.3.0 + *requires*: pytest<9,>=8.3 Pytest plugin for Test Case Parametrization with CSV files @@ -3800,7 +3830,7 @@ This list contains 1632 plugins. pytest fixtures to run dash applications. :pypi:`pytest-dashboard` - *last release*: May 30, 2024, + *last release*: May 20, 2025, *status*: N/A, *requires*: pytest<8.0.0,>=7.4.3 @@ -3814,7 +3844,7 @@ This list contains 1632 plugins. Useful functions for managing data for pytest fixtures :pypi:`pytest-databases` - *last release*: Apr 21, 2025, + *last release*: May 25, 2025, *status*: 4 - Beta, *requires*: pytest @@ -3828,7 +3858,7 @@ This list contains 1632 plugins. Pytest plugin for remote Databricks notebooks testing :pypi:`pytest-datadir` - *last release*: Feb 07, 2025, + *last release*: May 30, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 @@ -4395,7 +4425,7 @@ This list contains 1632 plugins. An RST Documentation Generator for pytest-based test suites :pypi:`pytest-docker` - *last release*: Apr 07, 2025, + *last release*: May 26, 2025, *status*: N/A, *requires*: pytest<9.0,>=4.0 @@ -4675,7 +4705,7 @@ This list contains 1632 plugins. A Pytest plugin to ignore tests during collection without reporting them in the test summary. :pypi:`pytest-dsl` - *last release*: May 07, 2025, + *last release*: May 29, 2025, *status*: N/A, *requires*: pytest>=7.0.0 @@ -5045,6 +5075,13 @@ This list contains 1632 plugins. pytest plugin to mark a test as xfailed if it fails with the specified error message in the captured output + :pypi:`pytest-essentials` + *last release*: May 19, 2025, + *status*: 3 - Alpha, + *requires*: pytest>=7.0 + + A Pytest plugin providing essential utilities like soft assertions. + :pypi:`pytest-eth` *last release*: Aug 14, 2020, *status*: 1 - Planning, @@ -5732,7 +5769,7 @@ This list contains 1632 plugins. A pytest plugin in order to provide logs via fluentbit :pypi:`pytest-fly` - *last release*: May 03, 2025, + *last release*: May 19, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -5963,7 +6000,7 @@ This list contains 1632 plugins. For finding/executing Ghost Inspector tests :pypi:`pytest-girder` - *last release*: May 08, 2025, + *last release*: May 29, 2025, *status*: N/A, *requires*: pytest>=3.6 @@ -6102,6 +6139,13 @@ This list contains 1632 plugins. Notify google chat channel for test results + :pypi:`pytest-google-cloud-storage` + *last release*: May 22, 2025, + *status*: N/A, + *requires*: pytest==8.3.5 + + Pytest custom features, e.g. fixtures and various tests. Aimed to emulate Google Cloud Storage service + :pypi:`pytest-gradescope` *last release*: Apr 29, 2025, *status*: N/A, @@ -6278,7 +6322,7 @@ This list contains 1632 plugins. A pytest plugin for use with homeassistant custom components. :pypi:`pytest-homeassistant-custom-component` - *last release*: May 17, 2025, + *last release*: May 30, 2025, *status*: 3 - Alpha, *requires*: pytest==8.3.5 @@ -6565,7 +6609,7 @@ This list contains 1632 plugins. A pytest plugin for image snapshot management and comparison. :pypi:`pytest-impacted` - *last release*: May 15, 2025, + *last release*: May 31, 2025, *status*: 4 - Beta, *requires*: pytest>=8.0.0 @@ -6670,7 +6714,7 @@ This list contains 1632 plugins. A py.test plugin providing fixtures to simplify inmanta modules testing. :pypi:`pytest-inmanta-extensions` - *last release*: Apr 10, 2025, + *last release*: May 27, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -6817,7 +6861,7 @@ This list contains 1632 plugins. Pytest plugin to run tests in Jupyter Notebooks :pypi:`pytest-ipywidgets` - *last release*: Apr 30, 2025, + *last release*: May 30, 2025, *status*: N/A, *requires*: pytest @@ -6831,7 +6875,7 @@ This list contains 1632 plugins. Plugin for pytest to produce test documentation for code audits. :pypi:`pytest-isolate` - *last release*: Apr 22, 2025, + *last release*: May 22, 2025, *status*: 4 - Beta, *requires*: pytest @@ -6936,7 +6980,7 @@ This list contains 1632 plugins. Plugin skips (xfail) tests if unresolved Jira issue(s) linked :pypi:`pytest-jira-xray` - *last release*: Oct 27, 2024, + *last release*: May 24, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.4 @@ -7223,7 +7267,7 @@ This list contains 1632 plugins. It helps to use fixtures in pytest.mark.parametrize :pypi:`pytest-lazy-fixtures` - *last release*: Jan 25, 2025, + *last release*: May 27, 2025, *status*: N/A, *requires*: pytest>=7 @@ -7272,7 +7316,7 @@ This list contains 1632 plugins. Select tests of a given level or lower :pypi:`pytest-lf-skip` - *last release*: May 06, 2025, + *last release*: May 26, 2025, *status*: 4 - Beta, *requires*: pytest>=8.3.5 @@ -7468,7 +7512,7 @@ This list contains 1632 plugins. :pypi:`pytest-logging-strict` - *last release*: Apr 09, 2025, + *last release*: May 20, 2025, *status*: 3 - Alpha, *requires*: pytest @@ -7874,7 +7918,7 @@ This list contains 1632 plugins. pytest plugin to display test execution output like a mochajs :pypi:`pytest-mock` - *last release*: Mar 21, 2024, + *last release*: May 26, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=6.2.5 @@ -8441,7 +8485,7 @@ This list contains 1632 plugins. A pytest plugin for simplifying ODC database tests :pypi:`pytest-odoo` - *last release*: Mar 12, 2025, + *last release*: May 20, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=8 @@ -8861,7 +8905,7 @@ This list contains 1632 plugins. Pytest pexpect plugin. :pypi:`pytest-pg` - *last release*: May 11, 2025, + *last release*: May 18, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.4 @@ -9294,6 +9338,13 @@ This list contains 1632 plugins. Pytest report plugin for Zulip + :pypi:`pytest-prometheus-pushgw` + *last release*: May 19, 2025, + *status*: N/A, + *requires*: pytest>=6.0.0 + + Pytest plugin to export test metrics to Prometheus Pushgateway + :pypi:`pytest-prosper` *last release*: Sep 24, 2018, *status*: N/A, @@ -9834,7 +9885,7 @@ This list contains 1632 plugins. Management of Pytest dependencies via regex patterns :pypi:`pytest-regressions` - *last release*: Jan 10, 2025, + *last release*: May 30, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=6.2.0 @@ -9959,6 +10010,13 @@ This list contains 1632 plugins. A basic HTML report for pytest using Jinja2 template engine. + :pypi:`pytest-reporter-plus` + *last release*: May 31, 2025, + *status*: N/A, + *requires*: N/A + + Lightweight enhanced HTML reporter for Pytest + :pypi:`pytest-report-extras` *last release*: Apr 04, 2025, *status*: N/A, @@ -10204,6 +10262,13 @@ This list contains 1632 plugins. + :pypi:`pytest-result-sender-jms` + *last release*: May 22, 2025, + *status*: N/A, + *requires*: pytest>=8.3.5 + + Default template for PDM package + :pypi:`pytest-result-sender-lj` *last release*: Dec 17, 2024, *status*: N/A, @@ -10401,7 +10466,7 @@ This list contains 1632 plugins. implement a --failed option for pytest :pypi:`pytest-run-parallel` - *last release*: Apr 22, 2025, + *last release*: May 27, 2025, *status*: 4 - Beta, *requires*: pytest>=6.2.0 @@ -10520,7 +10585,7 @@ This list contains 1632 plugins. pytest_sauce provides sane and helpful methods worked out in clearcode to run py.test tests with selenium/saucelabs :pypi:`pytest-sbase` - *last release*: May 13, 2025, + *last release*: May 27, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10534,7 +10599,7 @@ This list contains 1632 plugins. pytest plugin for test scenarios :pypi:`pytest-scenario-files` - *last release*: May 13, 2025, + *last release*: May 21, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0 @@ -10604,7 +10669,7 @@ This list contains 1632 plugins. pytest plugin to automatically capture screenshots upon selenium webdriver events :pypi:`pytest-seleniumbase` - *last release*: May 13, 2025, + *last release*: May 27, 2025, *status*: 5 - Production/Stable, *requires*: N/A @@ -10639,7 +10704,7 @@ This list contains 1632 plugins. Send pytest execution result email :pypi:`pytest-sentry` - *last release*: Feb 24, 2025, + *last release*: May 23, 2025, *status*: N/A, *requires*: pytest @@ -10940,7 +11005,7 @@ This list contains 1632 plugins. Automated bad smell detection tool for Pytest :pypi:`pytest-smoke` - *last release*: Mar 25, 2025, + *last release*: May 23, 2025, *status*: 4 - Beta, *requires*: pytest<9,>=7.0.0 @@ -11094,7 +11159,7 @@ This list contains 1632 plugins. Test-ordering plugin for pytest :pypi:`pytest-spark` - *last release*: Mar 21, 2025, + *last release*: May 21, 2025, *status*: 4 - Beta, *requires*: pytest @@ -11290,8 +11355,8 @@ This list contains 1632 plugins. Start pytest run from a given point :pypi:`pytest-static` - *last release*: Oct 20, 2024, - *status*: 1 - Planning, + *last release*: May 25, 2025, + *status*: 3 - Alpha, *requires*: pytest<8.0.0,>=7.4.3 pytest-static @@ -11367,8 +11432,8 @@ This list contains 1632 plugins. Pytest plugin to store values from test runs :pypi:`pytest-streaming` - *last release*: May 16, 2025, - *status*: N/A, + *last release*: May 28, 2025, + *status*: 5 - Production/Stable, *requires*: pytest>=8.3.5 Plugin for testing pubsub, pulsar, and kafka systems with pytest locally and in ci/cd @@ -12297,6 +12362,13 @@ This list contains 1632 plugins. Run type checkers on specified test files + :pypi:`pytest-typed-schema-shot` + *last release*: May 24, 2025, + *status*: N/A, + *requires*: pytest + + Pytest plugin for automatic JSON Schema generation and validation from examples + :pypi:`pytest-typhoon-config` *last release*: Apr 07, 2022, *status*: 5 - Production/Stable, @@ -12319,7 +12391,7 @@ This list contains 1632 plugins. Typhoon HIL plugin for pytest :pypi:`pytest-typing-runner` - *last release*: Oct 27, 2024, + *last release*: May 31, 2025, *status*: N/A, *requires*: N/A @@ -12760,7 +12832,7 @@ This list contains 1632 plugins. A pytest plugin for configuring workflow/pipeline tests using YAML files :pypi:`pytest-xdist` - *last release*: Apr 28, 2024, + *last release*: May 26, 2025, *status*: 5 - Production/Stable, *requires*: pytest>=7.0.0 @@ -12886,11 +12958,11 @@ This list contains 1632 plugins. :pypi:`pytest-xray-reporter` - *last release*: May 08, 2025, + *last release*: May 21, 2025, *status*: 4 - Beta, *requires*: pytest>=7.0.0 - A pytest plugin that generates test results in Xray JSON format + Pytest plugin for generating Xray JSON reports :pypi:`pytest-xray-server` *last release*: May 03, 2022, From 0ccb57904fea0a179ff4c2ae8195fc65d08d10eb Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 1 Jun 2025 22:14:02 +0300 Subject: [PATCH 417/445] python: a bit nicer error on duplicate parametrization Raising `ValueError` dumps all of the internal stacktrace to the user, which is not helpful. Raising `CollectError` is handled specially to just print the message. It would be nice to show source location or such - maybe another time. Fix #13457 --- changelog/13457.improvement.rst | 1 + src/_pytest/python.py | 4 +++- testing/python/metafunc.py | 12 ++++++++---- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 changelog/13457.improvement.rst diff --git a/changelog/13457.improvement.rst b/changelog/13457.improvement.rst new file mode 100644 index 00000000000..3937384b322 --- /dev/null +++ b/changelog/13457.improvement.rst @@ -0,0 +1 @@ +The error message about duplicate parametrization no longer displays an internal stack trace. diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 1e085a80529..02b71767dc2 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1079,7 +1079,9 @@ def setmulti( arg2scope = dict(self._arg2scope) for arg, val in zip(argnames, valset): if arg in params: - raise ValueError(f"duplicate parametrization of {arg!r}") + raise nodes.Collector.CollectError( + f"duplicate parametrization of {arg!r}" + ) params[arg] = val indices[arg] = param_index arg2scope[arg] = scope diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index e8b345aecc6..7ae26de3a18 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -82,11 +82,15 @@ def func(x, y): metafunc = self.Metafunc(func) metafunc.parametrize("x", [1, 2]) - pytest.raises(ValueError, lambda: metafunc.parametrize("x", [5, 6])) - pytest.raises(ValueError, lambda: metafunc.parametrize("x", [5, 6])) + with pytest.raises(pytest.Collector.CollectError): + metafunc.parametrize("x", [5, 6]) + with pytest.raises(pytest.Collector.CollectError): + metafunc.parametrize("x", [5, 6]) metafunc.parametrize("y", [1, 2]) - pytest.raises(ValueError, lambda: metafunc.parametrize("y", [5, 6])) - pytest.raises(ValueError, lambda: metafunc.parametrize("y", [5, 6])) + with pytest.raises(pytest.Collector.CollectError): + metafunc.parametrize("y", [5, 6]) + with pytest.raises(pytest.Collector.CollectError): + metafunc.parametrize("y", [5, 6]) with pytest.raises(TypeError, match="^ids must be a callable or an iterable$"): metafunc.parametrize("y", [5, 6], ids=42) # type: ignore[arg-type] From b6e81441b35a94852c554ec7433a1f88e7235eb1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Jun 2025 06:20:21 +0200 Subject: [PATCH 418/445] build(deps): Bump pytest-mock in /testing/plugins_integration (#13460) Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock) from 3.14.0 to 3.14.1. - [Release notes](https://github.com/pytest-dev/pytest-mock/releases) - [Changelog](https://github.com/pytest-dev/pytest-mock/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest-mock/compare/v3.14.0...v3.14.1) --- updated-dependencies: - dependency-name: pytest-mock dependency-version: 3.14.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index b8b07fc8ad9..d467e481f58 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -6,7 +6,7 @@ pytest-cov==6.1.1 pytest-django==4.11.1 pytest-flakes==4.0.5 pytest-html==4.1.1 -pytest-mock==3.14.0 +pytest-mock==3.14.1 pytest-rerunfailures==15.1 pytest-sugar==1.0.0 pytest-trio==0.8.0 From 30407eb7613bcafd8651beb047a8a2fc215409ab Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Mon, 2 Jun 2025 11:22:07 +0300 Subject: [PATCH 419/445] python: pinpoint nodeid in a couple of parametrization errors --- src/_pytest/python.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 02b71767dc2..82aab85a300 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -1073,6 +1073,7 @@ def setmulti( marks: Iterable[Mark | MarkDecorator], scope: Scope, param_index: int, + nodeid: str, ) -> CallSpec2: params = self.params.copy() indices = self.indices.copy() @@ -1080,7 +1081,7 @@ def setmulti( for arg, val in zip(argnames, valset): if arg in params: raise nodes.Collector.CollectError( - f"duplicate parametrization of {arg!r}" + f"{nodeid}: duplicate parametrization of {arg!r}" ) params[arg] = val indices[arg] = param_index @@ -1235,6 +1236,8 @@ def parametrize( It will also override any fixture-function defined scope, allowing to set a dynamic scope using test context or configuration. """ + nodeid = self.definition.nodeid + argnames, parametersets = ParameterSet._for_parametrize( argnames, argvalues, @@ -1246,7 +1249,7 @@ def parametrize( if "request" in argnames: fail( - "'request' is a reserved name and cannot be used in @pytest.mark.parametrize", + f"{nodeid}: 'request' is a reserved name and cannot be used in @pytest.mark.parametrize", pytrace=False, ) @@ -1341,6 +1344,7 @@ def parametrize( marks=param_set.marks, scope=scope_, param_index=param_index, + nodeid=nodeid, ) newcalls.append(newcallspec) self._calls = newcalls From 52dccfd2a8c32a7dd869c5bb7eeba0d1a0858a65 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Mon, 2 Jun 2025 12:01:37 +0300 Subject: [PATCH 420/445] coverage: ignore `def foo(): ...` lines These often appear in Protocols and ABCs and are never executed so not expected to be covered. --- .coveragerc | 1 + 1 file changed, 1 insertion(+) diff --git a/.coveragerc b/.coveragerc index b810471417f..d39d3d5f02b 100644 --- a/.coveragerc +++ b/.coveragerc @@ -29,5 +29,6 @@ exclude_lines = ^\s*if TYPE_CHECKING: ^\s*@overload( |$) + ^\s*def .+: \.\.\.$ ^\s*@pytest\.mark\.xfail From 3b0e463febb416af622ac5a01eeb79d379177553 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 1 Jun 2025 22:12:34 +0300 Subject: [PATCH 421/445] assertion: add a Protocol for rewrite hook Mostly to fix the TODO, doesn't have much semantic meaning. Also fixes a related typo in import inside `TYPE_CHECKING` block. --- src/_pytest/assertion/__init__.py | 14 +++++++++----- src/_pytest/config/__init__.py | 7 ++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/_pytest/assertion/__init__.py b/src/_pytest/assertion/__init__.py index 532b96fe431..22f3ca8e258 100644 --- a/src/_pytest/assertion/__init__.py +++ b/src/_pytest/assertion/__init__.py @@ -6,6 +6,7 @@ from collections.abc import Generator import sys from typing import Any +from typing import Protocol from typing import TYPE_CHECKING from _pytest.assertion import rewrite @@ -82,15 +83,18 @@ def register_assert_rewrite(*names: str) -> None: if not isinstance(name, str): msg = "expected module names as *args, got {0} instead" # type: ignore[unreachable] raise TypeError(msg.format(repr(names))) + rewrite_hook: RewriteHook for hook in sys.meta_path: if isinstance(hook, rewrite.AssertionRewritingHook): - importhook = hook + rewrite_hook = hook break else: - # TODO(typing): Add a protocol for mark_rewrite() and use it - # for importhook and for PytestPluginManager.rewrite_hook. - importhook = DummyRewriteHook() # type: ignore - importhook.mark_rewrite(*names) + rewrite_hook = DummyRewriteHook() + rewrite_hook.mark_rewrite(*names) + + +class RewriteHook(Protocol): + def mark_rewrite(self, *names: str) -> None: ... class DummyRewriteHook: diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 56b04719641..2ad613308b7 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -70,7 +70,7 @@ if TYPE_CHECKING: - from _pytest.assertions.rewrite import AssertionRewritingHook + from _pytest.assertion.rewrite import AssertionRewritingHook from _pytest.cacheprovider import Cache from _pytest.terminal import TerminalReporter @@ -397,7 +397,8 @@ class PytestPluginManager(PluginManager): """ def __init__(self) -> None: - import _pytest.assertion + from _pytest.assertion import DummyRewriteHook + from _pytest.assertion import RewriteHook super().__init__("pytest") @@ -443,7 +444,7 @@ def __init__(self) -> None: self.enable_tracing() # Config._consider_importhook will set a real object if required. - self.rewrite_hook = _pytest.assertion.DummyRewriteHook() + self.rewrite_hook: RewriteHook = DummyRewriteHook() # Used to know when we are importing conftests after the pytest_configure stage. self._configured = False From 69c47cea4d5725328a79e4ec648c6cd044c44e7d Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 1 Jun 2025 22:28:47 +0300 Subject: [PATCH 422/445] tmpdir: remove an unneeded assignment It's not different from the `tmp_path_factory` already requested via fixture. --- src/_pytest/tmpdir.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/_pytest/tmpdir.py b/src/_pytest/tmpdir.py index c5b51c87741..dcd5784f88f 100644 --- a/src/_pytest/tmpdir.py +++ b/src/_pytest/tmpdir.py @@ -265,7 +265,6 @@ def tmp_path( yield path # Remove the tmpdir if the policy is "failed" and the test passed. - tmp_path_factory: TempPathFactory = request.session.config._tmp_path_factory # type: ignore policy = tmp_path_factory._retention_policy result_dict = request.node.stash[tmppath_result_key] From 0e734c734a28102bf2d4489b0a200f545bfcaebf Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 1 Jun 2025 22:44:01 +0300 Subject: [PATCH 423/445] config: add a couple of explicit `Any`s pyright (somewhat annoyingly IMO) infers unannotated function types, unlike mypy which treats them as `Any`. In these 2 cases it causes some follow on type errors, so add explicit `Any`s to prevent pyright from inferring some big union. --- src/_pytest/config/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 2ad613308b7..db5d898ee35 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1582,7 +1582,7 @@ def addinivalue_line(self, name: str, line: str) -> None: assert isinstance(x, list) x.append(line) # modifies the cached list inline - def getini(self, name: str): + def getini(self, name: str) -> Any: """Return configuration value from an :ref:`ini file `. If a configuration value is not defined in an @@ -1726,7 +1726,7 @@ def _get_override_ini_value(self, name: str) -> str | None: value = user_ini_value return value - def getoption(self, name: str, default=notset, skip: bool = False): + def getoption(self, name: str, default: Any = notset, skip: bool = False): """Return command line option value. :param name: Name of the option. You may also specify From b5c0b8537932e8dbd62787cef9b3113402885478 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 1 Jun 2025 22:58:59 +0300 Subject: [PATCH 424/445] config: fix a type error in pyright due to different narrowing rules For some reason pyright infers the type of `essential_plugins` and `default_plugins` as `tuple[Literal[...], ...]` even if they are explicitly annotated as `tuple[str, ...]`. This then causes an error in the `builtin_plugins.add` calls. Replace with one-shot initialization appeases pyright and is nicer regardless. --- src/_pytest/config/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index db5d898ee35..796beee3266 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -273,9 +273,11 @@ def directory_arg(path: str, optname: str) -> str: "faulthandler", ) -builtin_plugins = set(default_plugins) -builtin_plugins.add("pytester") -builtin_plugins.add("pytester_assertions") +builtin_plugins = { + *default_plugins, + "pytester", + "pytester_assertions", +} def get_config( From b42a5d2f3ebba21dc26b329637e8beb1826d7ac5 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 1 Jun 2025 23:11:34 +0300 Subject: [PATCH 425/445] config: use casts for legacy hook marks instead of type ignores This is the expected case for casts -- the correct type is ensured dynamically, just too complicated for a type checker to understand. --- src/_pytest/config/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 796beee3266..468018fadc0 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -472,9 +472,10 @@ def parse_hookimpl_opts( if not inspect.isroutine(method): return None # Collect unmarked hooks as long as they have the `pytest_' prefix. - return _get_legacy_hook_marks( # type: ignore[return-value] + legacy = _get_legacy_hook_marks( method, "impl", ("tryfirst", "trylast", "optionalhook", "hookwrapper") ) + return cast(HookimplOpts, legacy) def parse_hookspec_opts(self, module_or_class, name: str) -> HookspecOpts | None: """:meta private:""" @@ -482,11 +483,10 @@ def parse_hookspec_opts(self, module_or_class, name: str) -> HookspecOpts | None if opts is None: method = getattr(module_or_class, name) if name.startswith("pytest_"): - opts = _get_legacy_hook_marks( # type: ignore[assignment] - method, - "spec", - ("firstresult", "historic"), + legacy = _get_legacy_hook_marks( + method, "spec", ("firstresult", "historic") ) + opts = cast(HookspecOpts, legacy) return opts def register(self, plugin: _PluggyPlugin, name: str | None = None) -> str | None: From 0c4ed3133fdbda112275a6602a4a99f4c0d6fbc7 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 1 Jun 2025 23:37:36 +0300 Subject: [PATCH 426/445] raises: remove redundant type annotation Pyright complains: Type annotation for "self" parameter of "__init__" method cannot contain class-scoped type variables (reportInvalidTypeVarUse) and I figure it's not needed since it's already the type of `self`. --- src/_pytest/raises.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/raises.py b/src/_pytest/raises.py index 2eba53bf10b..8c2fca9f919 100644 --- a/src/_pytest/raises.py +++ b/src/_pytest/raises.py @@ -588,7 +588,7 @@ class RaisesExc(AbstractRaises[BaseExcT_co_default]): # At least one of the three parameters must be passed. @overload def __init__( - self: RaisesExc[BaseExcT_co_default], + self, expected_exception: ( type[BaseExcT_co_default] | tuple[type[BaseExcT_co_default], ...] ), From 513c5ebd89c952e8b0437fab714f47ecbb5d4822 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 1 Jun 2025 23:40:07 +0300 Subject: [PATCH 427/445] raises: avoid breaking type string to multiple lines Pyright doesn't handle this. --- src/_pytest/raises.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/_pytest/raises.py b/src/_pytest/raises.py index 8c2fca9f919..d896564ddcc 100644 --- a/src/_pytest/raises.py +++ b/src/_pytest/raises.py @@ -969,9 +969,7 @@ def __init__( # that are *very* hard to reconcile while adhering to the overloads, so we cast # it to avoid an error when passing it to super().__init__ check = cast( - "Callable[[" - "BaseExceptionGroup[ExcT_1|BaseExcT_1|BaseExceptionGroup[BaseExcT_2]]" - "], bool]", + "Callable[[BaseExceptionGroup[ExcT_1|BaseExcT_1|BaseExceptionGroup[BaseExcT_2]]], bool]", check, ) super().__init__(match=match, check=check) From b256fc448b744f3b1a5fb027143f1555b677d30b Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 1 Jun 2025 23:47:10 +0300 Subject: [PATCH 428/445] raises: replace ineffective type annotations There is not much reason to use `TypeGuard` on the implementation function of an `@overload`ed function, since only the types of the overloads are used. This fixes a pyright "Overloaded implementation is not consistent with signature of overload" error. --- src/_pytest/raises.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_pytest/raises.py b/src/_pytest/raises.py index d896564ddcc..480ae33647f 100644 --- a/src/_pytest/raises.py +++ b/src/_pytest/raises.py @@ -1105,7 +1105,7 @@ def matches( def matches( self, exception: BaseException | None, - ) -> TypeGuard[BaseExceptionGroup[BaseExcT_co]]: + ) -> bool: """Check if an exception matches the requirements of this RaisesGroup. If it fails, `RaisesGroup.fail_reason` will be set. @@ -1269,7 +1269,7 @@ def _check_exceptions( self, _exception: BaseException, actual_exceptions: Sequence[BaseException], - ) -> TypeGuard[BaseExceptionGroup[BaseExcT_co]]: + ) -> bool: """Helper method for RaisesGroup.matches that attempts to pair up expected and actual exceptions""" # The _exception parameter is not used, but necessary for the TypeGuard From 9aa198bdef285d007305fb14c25d81e9996be518 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 1 Jun 2025 23:58:19 +0300 Subject: [PATCH 429/445] mark/expression: fix self -> cls --- src/_pytest/mark/expression.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/mark/expression.py b/src/_pytest/mark/expression.py index b71ed29c62f..743a46bcc17 100644 --- a/src/_pytest/mark/expression.py +++ b/src/_pytest/mark/expression.py @@ -305,7 +305,7 @@ def __init__(self, code: types.CodeType) -> None: self.code = code @classmethod - def compile(self, input: str) -> Expression: + def compile(cls, input: str) -> Expression: """Compile a match expression. :param input: The input expression - one line. From 9fc6db9a550544ce4fb1f889dde3cf1165e7e337 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 1 Jun 2025 23:58:45 +0300 Subject: [PATCH 430/445] pytester: avoid confusing `x` self parameter --- src/_pytest/pytester.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 11127a88bb8..38f4643bd8b 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -1116,7 +1116,8 @@ def inline_run( rec = [] class Collect: - def pytest_configure(x, config: Config) -> None: + @staticmethod + def pytest_configure(config: Config) -> None: rec.append(self.make_hook_recorder(config.pluginmanager)) plugins.append(Collect()) From 7a481812a28b141171141abf39cc9bf351e0cbe1 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sun, 1 Jun 2025 22:25:13 +0300 Subject: [PATCH 431/445] Add pyright configuration For manual testing, as we are not yet passing. --- .pre-commit-config.yaml | 18 ++++++++++++++++++ pyproject.toml | 14 ++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a07475da467..149f7e6af59 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -47,6 +47,24 @@ repos: # for mypy running on python>=3.11 since exceptiongroup is only a dependency # on <3.11 - exceptiongroup>=1.0.0rc8 +- repo: https://github.com/RobertCraigie/pyright-python + rev: v1.1.401 + hooks: + - id: pyright + files: ^(src/|scripts/) + additional_dependencies: + - iniconfig>=1.1.0 + - attrs>=19.2.0 + - pluggy>=1.5.0 + - packaging + - tomli + - types-setuptools + - types-tabulate + # for mypy running on python>=3.11 since exceptiongroup is only a dependency + # on <3.11 + - exceptiongroup>=1.0.0rc8 + # Manual because passing pyright is a work in progress. + stages: [manual] - repo: https://github.com/tox-dev/pyproject-fmt rev: "v2.6.0" hooks: diff --git a/pyproject.toml b/pyproject.toml index 4d4055147d8..1e9665add02 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -528,3 +528,17 @@ warn_unreachable = true warn_unused_configs = true no_implicit_reexport = true warn_unused_ignores = true + +[tool.pyright] +include = [ + "src", + "testing", + "scripts", +] +extraPaths = [ + "src", +] +pythonVersion = "3.9" +typeCheckingMode = "basic" +reportMissingImports = "none" +reportMissingModuleSource = "none" From 4c205cfcb08083a2893e07b6d994bd38d183b64a Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Mon, 2 Jun 2025 14:52:08 +0300 Subject: [PATCH 432/445] testing/plugins_integration: update Django (#13463) Fix some dependabot security notices. For some reason dependabot doesn't manage to create a PR for it on its own. --- testing/plugins_integration/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/plugins_integration/requirements.txt b/testing/plugins_integration/requirements.txt index d467e481f58..e8010b23113 100644 --- a/testing/plugins_integration/requirements.txt +++ b/testing/plugins_integration/requirements.txt @@ -1,5 +1,5 @@ anyio[trio]==4.9.0 -django==5.1.7 +django==5.2.1 pytest-asyncio==0.26.0 pytest-bdd==8.1.0 pytest-cov==6.1.1 From 64b230119cb7c260e1e6ec6887ebc5b3851d39fc Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Mon, 2 Jun 2025 15:43:30 +0300 Subject: [PATCH 433/445] scripts/release: add missing `build` to `towncrier` call Probably a new thing, but without it it just succeeds without doing anything. --- scripts/release.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release.py b/scripts/release.py index aef5d6d5f73..6549cd00a3d 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -121,7 +121,7 @@ def pre_release( def changelog(version: str, write_out: bool = False) -> None: addopts = [] if write_out else ["--draft"] - check_call(["towncrier", "--yes", "--version", version, *addopts]) + check_call(["towncrier", "build", "--yes", "--version", version, *addopts]) def main() -> None: From e4389acb4d650f349a728cc42067d8c1a246bdcb Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 2 Jun 2025 09:53:44 -0300 Subject: [PATCH 434/445] Remove resultlog from the docs (#13465) It was removed by https://github.com/pytest-dev/pytest/commit/d69abff2c7de8bc65b7f1ef867dec5b5b9c564bd in version `6.1.0`. Fixes #13464 --- doc/en/how-to/output.rst | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/doc/en/how-to/output.rst b/doc/en/how-to/output.rst index d53dd4b8ec7..cb9276c7ea0 100644 --- a/doc/en/how-to/output.rst +++ b/doc/en/how-to/output.rst @@ -571,29 +571,6 @@ That will cause pytest to truncate the assertions to 10 lines or 90 characters, Setting both :confval:`truncation_limit_lines` and :confval:`truncation_limit_chars` to ``0`` will disable the truncation. However, setting only one of those values will disable one truncation mode, but will leave the other one intact. -Creating resultlog format files --------------------------------------------------- - -To create plain-text machine-readable result files you can issue: - -.. code-block:: bash - - pytest --resultlog=path - -and look at the content at the ``path`` location. Such files are used e.g. -by the `PyPy-test`_ web page to show test results over several revisions. - -.. warning:: - - This option is rarely used and is scheduled for removal in pytest 6.0. - - If you use this option, consider using the new `pytest-reportlog `__ plugin instead. - - See :ref:`the deprecation docs ` for more information. - - -.. _`PyPy-test`: http://buildbot.pypy.org/summary - Creating JUnitXML format files ---------------------------------------------------- From 315b3ae798fe38264b3ab2312dced212c46f1e21 Mon Sep 17 00:00:00 2001 From: pytest bot Date: Mon, 2 Jun 2025 14:57:38 +0000 Subject: [PATCH 435/445] Prepare release version 8.4.0 --- changelog/10224.improvement.rst | 18 -- changelog/10404.bugfix.rst | 7 - changelog/10839.deprecation.rst | 1 - changelog/11067.bugfix.rst | 3 - changelog/11118.improvement.rst | 3 - changelog/11372.breaking.rst | 1 - changelog/11381.improvement.rst | 17 -- changelog/11525.improvement.rst | 3 - changelog/11538.feature.rst | 1 - changelog/12008.bugfix.rst | 1 - changelog/12017.contrib.rst | 7 - changelog/12081.feature.rst | 1 - changelog/12346.breaking.rst | 1 - changelog/12426.improvement.rst | 1 - changelog/12504.feature.rst | 1 - changelog/12535.doc.rst | 4 - changelog/12647.contrib.rst | 1 - changelog/12707.improvement.rst | 1 - changelog/12713.feature.rst | 3 - changelog/12736.improvement.rst | 3 - changelog/12749.feature.rst | 21 -- changelog/12765.feature.rst | 3 - changelog/12863.bugfix.rst | 1 - changelog/12874.breaking.rst | 1 - changelog/12929.bugfix.rst | 1 - changelog/12938.bugfix.rst | 1 - changelog/12943.improvement.rst | 1 - changelog/12946.bugfix.rst | 1 - changelog/12958.improvement.rst | 9 - changelog/12960.breaking.rst | 3 - changelog/12981.bugfix.rst | 1 - changelog/13010.improvement.rst | 1 - changelog/13016.improvement.rst | 8 - changelog/13031.improvement.rst | 1 - changelog/13047.bugfix.rst | 17 -- changelog/13115.improvement.rst | 8 - changelog/13119.bugfix.rst | 1 - changelog/13122.improvement.rst | 15 - changelog/13125.feature.rst | 1 - changelog/13175.bugfix.rst | 1 - changelog/13192.feature.1.rst | 1 - changelog/13192.feature.2.rst | 1 - changelog/13192.feature.rst | 1 - changelog/13218.doc.rst | 1 - changelog/13221.doc.rst | 1 - changelog/13228.feature.rst | 3 - changelog/13248.bugfix.rst | 2 - changelog/13253.feature.rst | 1 - changelog/13291.bugfix.rst | 1 - changelog/13308.improvement.rst | 1 - changelog/13312.bugfix.rst | 1 - changelog/13317.packaging.rst | 4 - changelog/13345.bugfix.rst | 1 - changelog/13377.bugfix.rst | 12 - changelog/13380.improvement.rst | 1 - changelog/13384.bugfix.rst | 1 - changelog/13415.improvement.rst | 5 - changelog/13420.bugfix.rst | 1 - changelog/13420.improvement.rst | 1 - changelog/13457.improvement.rst | 1 - changelog/4112.improvement.rst | 1 - changelog/5473.improvement.rst | 1 - changelog/6649.doc.rst | 1 - changelog/6649.misc.rst | 1 - changelog/6985.improvement.rst | 21 -- changelog/7683.improvement.rst | 1 - changelog/8612.doc.rst | 5 - changelog/9037.bugfix.rst | 1 - doc/en/announce/index.rst | 1 + doc/en/announce/release-8.4.0.rst | 106 +++++++ doc/en/builtin.rst | 85 ++++-- doc/en/changelog.rst | 421 ++++++++++++++++++++++++++++ doc/en/example/parametrize.rst | 6 +- doc/en/example/pythoncollection.rst | 4 +- doc/en/example/reportingdemo.rst | 30 +- doc/en/example/simple.rst | 10 +- doc/en/getting-started.rst | 2 +- doc/en/how-to/cache.rst | 2 - doc/en/how-to/capture-warnings.rst | 1 + doc/en/how-to/fixtures.rst | 7 +- doc/en/how-to/output.rst | 2 +- doc/en/how-to/parametrize.rst | 2 +- doc/en/how-to/unittest.rst | 2 + doc/en/reference/reference.rst | 65 +++-- 84 files changed, 667 insertions(+), 326 deletions(-) delete mode 100644 changelog/10224.improvement.rst delete mode 100644 changelog/10404.bugfix.rst delete mode 100644 changelog/10839.deprecation.rst delete mode 100644 changelog/11067.bugfix.rst delete mode 100644 changelog/11118.improvement.rst delete mode 100644 changelog/11372.breaking.rst delete mode 100644 changelog/11381.improvement.rst delete mode 100644 changelog/11525.improvement.rst delete mode 100644 changelog/11538.feature.rst delete mode 100644 changelog/12008.bugfix.rst delete mode 100644 changelog/12017.contrib.rst delete mode 100644 changelog/12081.feature.rst delete mode 100644 changelog/12346.breaking.rst delete mode 100644 changelog/12426.improvement.rst delete mode 100644 changelog/12504.feature.rst delete mode 100644 changelog/12535.doc.rst delete mode 100644 changelog/12647.contrib.rst delete mode 100644 changelog/12707.improvement.rst delete mode 100644 changelog/12713.feature.rst delete mode 100644 changelog/12736.improvement.rst delete mode 100644 changelog/12749.feature.rst delete mode 100644 changelog/12765.feature.rst delete mode 100644 changelog/12863.bugfix.rst delete mode 100644 changelog/12874.breaking.rst delete mode 100644 changelog/12929.bugfix.rst delete mode 100644 changelog/12938.bugfix.rst delete mode 100644 changelog/12943.improvement.rst delete mode 100644 changelog/12946.bugfix.rst delete mode 100644 changelog/12958.improvement.rst delete mode 100644 changelog/12960.breaking.rst delete mode 100644 changelog/12981.bugfix.rst delete mode 100644 changelog/13010.improvement.rst delete mode 100644 changelog/13016.improvement.rst delete mode 100644 changelog/13031.improvement.rst delete mode 100644 changelog/13047.bugfix.rst delete mode 100644 changelog/13115.improvement.rst delete mode 100644 changelog/13119.bugfix.rst delete mode 100644 changelog/13122.improvement.rst delete mode 100644 changelog/13125.feature.rst delete mode 100644 changelog/13175.bugfix.rst delete mode 100644 changelog/13192.feature.1.rst delete mode 100644 changelog/13192.feature.2.rst delete mode 100644 changelog/13192.feature.rst delete mode 100644 changelog/13218.doc.rst delete mode 100644 changelog/13221.doc.rst delete mode 100644 changelog/13228.feature.rst delete mode 100644 changelog/13248.bugfix.rst delete mode 100644 changelog/13253.feature.rst delete mode 100644 changelog/13291.bugfix.rst delete mode 100644 changelog/13308.improvement.rst delete mode 100644 changelog/13312.bugfix.rst delete mode 100644 changelog/13317.packaging.rst delete mode 100644 changelog/13345.bugfix.rst delete mode 100644 changelog/13377.bugfix.rst delete mode 100644 changelog/13380.improvement.rst delete mode 100644 changelog/13384.bugfix.rst delete mode 100644 changelog/13415.improvement.rst delete mode 100644 changelog/13420.bugfix.rst delete mode 100644 changelog/13420.improvement.rst delete mode 100644 changelog/13457.improvement.rst delete mode 100644 changelog/4112.improvement.rst delete mode 100644 changelog/5473.improvement.rst delete mode 100644 changelog/6649.doc.rst delete mode 100644 changelog/6649.misc.rst delete mode 100644 changelog/6985.improvement.rst delete mode 100644 changelog/7683.improvement.rst delete mode 100644 changelog/8612.doc.rst delete mode 100644 changelog/9037.bugfix.rst create mode 100644 doc/en/announce/release-8.4.0.rst diff --git a/changelog/10224.improvement.rst b/changelog/10224.improvement.rst deleted file mode 100644 index 93afe9e2c1e..00000000000 --- a/changelog/10224.improvement.rst +++ /dev/null @@ -1,18 +0,0 @@ -pytest's ``short`` and ``long`` traceback styles (:ref:`how-to-modifying-python-tb-printing`) -now have partial :pep:`657` support and will show specific code segments in the -traceback. - -.. code-block:: pytest - - ================================= FAILURES ================================= - _______________________ test_gets_correct_tracebacks _______________________ - - test_tracebacks.py:12: in test_gets_correct_tracebacks - assert manhattan_distance(p1, p2) == 1 - ^^^^^^^^^^^^^^^^^^^^^^^^^^ - test_tracebacks.py:6: in manhattan_distance - return abs(point_1.x - point_2.x) + abs(point_1.y - point_2.y) - ^^^^^^^^^ - E AttributeError: 'NoneType' object has no attribute 'x' - --- by :user:`ammaraskar` diff --git a/changelog/10404.bugfix.rst b/changelog/10404.bugfix.rst deleted file mode 100644 index 4c98ea03d64..00000000000 --- a/changelog/10404.bugfix.rst +++ /dev/null @@ -1,7 +0,0 @@ -Apply filterwarnings from config/cli as soon as possible, and revert them as late as possible -so that warnings as errors are collected throughout the pytest run and before the -unraisable and threadexcept hooks are removed. - -This allows very late warnings and unraisable/threadexcept exceptions to fail the test suite. - -This also changes the warning that the lsof plugin issues from PytestWarning to the new warning PytestFDWarning so it can be more easily filtered. diff --git a/changelog/10839.deprecation.rst b/changelog/10839.deprecation.rst deleted file mode 100644 index a3e2cbf51d0..00000000000 --- a/changelog/10839.deprecation.rst +++ /dev/null @@ -1 +0,0 @@ -Requesting an asynchronous fixture without a `pytest_fixture_setup` hook that resolves it will now give a DeprecationWarning. This most commonly happens if a sync test requests an async fixture. This should have no effect on a majority of users with async tests or fixtures using async pytest plugins, but may affect non-standard hook setups or ``autouse=True``. For guidance on how to work around this warning see :ref:`sync-test-async-fixture`. diff --git a/changelog/11067.bugfix.rst b/changelog/11067.bugfix.rst deleted file mode 100644 index 4e3cb8e7dd7..00000000000 --- a/changelog/11067.bugfix.rst +++ /dev/null @@ -1,3 +0,0 @@ -The test report is now consistent regardless if the test xfailed via :ref:`pytest.mark.xfail ` or :func:`pytest.fail`. - -Previously, *xfailed* tests via the marker would have the string ``"reason: "`` prefixed to the message, while those *xfailed* via the function did not. The prefix has been removed. diff --git a/changelog/11118.improvement.rst b/changelog/11118.improvement.rst deleted file mode 100644 index 4760dbe9d64..00000000000 --- a/changelog/11118.improvement.rst +++ /dev/null @@ -1,3 +0,0 @@ -Now :confval:`pythonpath` configures `$PYTHONPATH` earlier than before during the initialization process, which now also affects plugins loaded via the `-p` command-line option. - --- by :user:`millerdev` diff --git a/changelog/11372.breaking.rst b/changelog/11372.breaking.rst deleted file mode 100644 index f4b5c3c6f6b..00000000000 --- a/changelog/11372.breaking.rst +++ /dev/null @@ -1 +0,0 @@ -Async tests will now fail, instead of warning+skipping, if you don't have any suitable plugin installed. diff --git a/changelog/11381.improvement.rst b/changelog/11381.improvement.rst deleted file mode 100644 index 74c080cc188..00000000000 --- a/changelog/11381.improvement.rst +++ /dev/null @@ -1,17 +0,0 @@ -The ``type`` parameter of the ``parser.addini`` method now accepts `"int"` and ``"float"`` parameters, facilitating the parsing of configuration values in the configuration file. - -Example: - -.. code-block:: python - - def pytest_addoption(parser): - parser.addini("int_value", type="int", default=2, help="my int value") - parser.addini("float_value", type="float", default=4.2, help="my float value") - -The `pytest.ini` file: - -.. code-block:: ini - - [pytest] - int_value = 3 - float_value = 5.4 diff --git a/changelog/11525.improvement.rst b/changelog/11525.improvement.rst deleted file mode 100644 index 1935ce59343..00000000000 --- a/changelog/11525.improvement.rst +++ /dev/null @@ -1,3 +0,0 @@ -Fixtures are now clearly represented in the output as a "fixture object", not as a normal function as before, making it easy for beginners to catch mistakes such as referencing a fixture declared in the same module but not requested in the test function. - --- by :user:`the-compiler` and :user:`glyphack` diff --git a/changelog/11538.feature.rst b/changelog/11538.feature.rst deleted file mode 100644 index d6473b8fe73..00000000000 --- a/changelog/11538.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Added :class:`pytest.RaisesGroup` as an equivalent to :func:`pytest.raises` for expecting :exc:`ExceptionGroup`. Also adds :class:`pytest.RaisesExc` which is now the logic behind :func:`pytest.raises` and used as parameter to :class:`pytest.RaisesGroup`. ``RaisesGroup`` includes the ability to specify multiple different expected exceptions, the structure of nested exception groups, and flags for emulating :ref:`except* `. See :ref:`assert-matching-exception-groups` and docstrings for more information. diff --git a/changelog/12008.bugfix.rst b/changelog/12008.bugfix.rst deleted file mode 100644 index b9680b89236..00000000000 --- a/changelog/12008.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -In :pr:`11220`, an unintended change in reordering was introduced by changing the way indices were assigned to direct params. More specifically, before that change, the indices of direct params to metafunc's callspecs were assigned after all parametrizations took place. Now, that change is reverted. diff --git a/changelog/12017.contrib.rst b/changelog/12017.contrib.rst deleted file mode 100644 index ec1861893b3..00000000000 --- a/changelog/12017.contrib.rst +++ /dev/null @@ -1,7 +0,0 @@ -Mixed internal improvements: - -* Migrate formatting to f-strings in some tests. -* Use type-safe constructs in JUnitXML tests. -* Moved`` MockTiming`` into ``_pytest.timing``. - --- by :user:`RonnyPfannschmidt` diff --git a/changelog/12081.feature.rst b/changelog/12081.feature.rst deleted file mode 100644 index 6538fbf30f8..00000000000 --- a/changelog/12081.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Added :fixture:`capteesys` to capture AND pass output to next handler set by ``--capture=``. diff --git a/changelog/12346.breaking.rst b/changelog/12346.breaking.rst deleted file mode 100644 index 7013cf734c8..00000000000 --- a/changelog/12346.breaking.rst +++ /dev/null @@ -1 +0,0 @@ -Tests will now fail, instead of raising a warning, if they return any value other than None. diff --git a/changelog/12426.improvement.rst b/changelog/12426.improvement.rst deleted file mode 100644 index 0da1f838aea..00000000000 --- a/changelog/12426.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -A warning is now issued when :ref:`pytest.mark.usefixtures ref` is used without specifying any fixtures. Previously, empty usefixtures markers were silently ignored. diff --git a/changelog/12504.feature.rst b/changelog/12504.feature.rst deleted file mode 100644 index d72b97958c2..00000000000 --- a/changelog/12504.feature.rst +++ /dev/null @@ -1 +0,0 @@ -:func:`pytest.mark.xfail` now accepts :class:`pytest.RaisesGroup` for the ``raises`` parameter when you expect an exception group. You can also pass a :class:`pytest.RaisesExc` if you e.g. want to make use of the ``check`` parameter. diff --git a/changelog/12535.doc.rst b/changelog/12535.doc.rst deleted file mode 100644 index d43c1c822ea..00000000000 --- a/changelog/12535.doc.rst +++ /dev/null @@ -1,4 +0,0 @@ -`This -example` -showed ``print`` statements that do not exactly reflect what the -different branches actually do. The fix makes the example more precise. diff --git a/changelog/12647.contrib.rst b/changelog/12647.contrib.rst deleted file mode 100644 index 1d7a3181778..00000000000 --- a/changelog/12647.contrib.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed running the test suite with the ``hypothesis`` pytest plugin. diff --git a/changelog/12707.improvement.rst b/changelog/12707.improvement.rst deleted file mode 100644 index 4684b6561c8..00000000000 --- a/changelog/12707.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Exception chains can be navigated when dropped into Pdb in Python 3.13+. diff --git a/changelog/12713.feature.rst b/changelog/12713.feature.rst deleted file mode 100644 index 90867b87eae..00000000000 --- a/changelog/12713.feature.rst +++ /dev/null @@ -1,3 +0,0 @@ -New `--force-short-summary` option to force condensed summary output regardless of verbosity level. - -This lets users still see condensed summary output of failures for quick reference in log files from job outputs, being especially useful if non-condensed output is very verbose. diff --git a/changelog/12736.improvement.rst b/changelog/12736.improvement.rst deleted file mode 100644 index 5fdb14e2ef5..00000000000 --- a/changelog/12736.improvement.rst +++ /dev/null @@ -1,3 +0,0 @@ -Added a new attribute `name` with the fixed value `"pytest tests"` to the root tag `testsuites` of the junit-xml generated by pytest. - -This attribute is part of many junit-xml specifications and is even part of the `junit-10.xsd` specification that pytest's implementation is based on. diff --git a/changelog/12749.feature.rst b/changelog/12749.feature.rst deleted file mode 100644 index c3b7ca5d321..00000000000 --- a/changelog/12749.feature.rst +++ /dev/null @@ -1,21 +0,0 @@ -pytest traditionally collects classes/functions in the test module namespace even if they are imported from another file. - -For example: - -.. code-block:: python - - # contents of src/domain.py - class Testament: ... - - - # contents of tests/test_testament.py - from domain import Testament - - - def test_testament(): ... - -In this scenario with the default options, pytest will collect the class `Testament` from `tests/test_testament.py` because it starts with `Test`, even though in this case it is a production class being imported in the test module namespace. - -This behavior can now be prevented by setting the new :confval:`collect_imported_tests` configuration option to ``false``, which will make pytest collect classes/functions from test files **only** if they are defined in that file. - --- by :user:`FreerGit` diff --git a/changelog/12765.feature.rst b/changelog/12765.feature.rst deleted file mode 100644 index 193c75621f7..00000000000 --- a/changelog/12765.feature.rst +++ /dev/null @@ -1,3 +0,0 @@ -Thresholds to trigger snippet truncation can now be set with :confval:`truncation_limit_lines` and :confval:`truncation_limit_chars`. - -See :ref:`truncation-params` for more information. diff --git a/changelog/12863.bugfix.rst b/changelog/12863.bugfix.rst deleted file mode 100644 index 0b1c397a08e..00000000000 --- a/changelog/12863.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix applying markers, including :ref:`pytest.mark.parametrize ` when placed above `@staticmethod` or `@classmethod`. diff --git a/changelog/12874.breaking.rst b/changelog/12874.breaking.rst deleted file mode 100644 index a442586eeb5..00000000000 --- a/changelog/12874.breaking.rst +++ /dev/null @@ -1 +0,0 @@ -We dropped support for Python 3.8 following its end of life (2024-10-07). diff --git a/changelog/12929.bugfix.rst b/changelog/12929.bugfix.rst deleted file mode 100644 index fcf490d83e2..00000000000 --- a/changelog/12929.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Handle StopIteration from test cases, setup and teardown correctly. diff --git a/changelog/12938.bugfix.rst b/changelog/12938.bugfix.rst deleted file mode 100644 index d54d73bdbf5..00000000000 --- a/changelog/12938.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed ``--durations-min`` argument not respected if ``-vv`` is used. diff --git a/changelog/12943.improvement.rst b/changelog/12943.improvement.rst deleted file mode 100644 index eb8ac63650a..00000000000 --- a/changelog/12943.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -If a test fails with an exceptiongroup with a single exception, the contained exception will now be displayed in the short test summary info. diff --git a/changelog/12946.bugfix.rst b/changelog/12946.bugfix.rst deleted file mode 100644 index b11da09e7ae..00000000000 --- a/changelog/12946.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed missing help for :mod:`pdb` commands wrapped by pytest -- by :user:`adamchainz`. diff --git a/changelog/12958.improvement.rst b/changelog/12958.improvement.rst deleted file mode 100644 index ee8dc8c0710..00000000000 --- a/changelog/12958.improvement.rst +++ /dev/null @@ -1,9 +0,0 @@ -A number of :ref:`unraisable ` enhancements: - -* Set the unraisable hook as early as possible and unset it as late as possible, to collect the most possible number of unraisable exceptions. -* Call the garbage collector just before unsetting the unraisable hook, to collect any straggling exceptions. -* Collect multiple unraisable exceptions per test phase. -* Report the :mod:`tracemalloc` allocation traceback (if available). -* Avoid using a generator based hook to allow handling :class:`StopIteration` in test failures. -* Report the unraisable exception as the cause of the :class:`pytest.PytestUnraisableExceptionWarning` exception if raised. -* Compute the ``repr`` of the unraisable object in the unraisable hook so you get the latest information if available, and should help with resurrection of the object. diff --git a/changelog/12960.breaking.rst b/changelog/12960.breaking.rst deleted file mode 100644 index 3ab87e6fe23..00000000000 --- a/changelog/12960.breaking.rst +++ /dev/null @@ -1,3 +0,0 @@ -Test functions containing a yield now cause an explicit error. They have not been run since pytest 4.0, and were previously marked as an expected failure and deprecation warning. - -See :ref:`the docs ` for more information. diff --git a/changelog/12981.bugfix.rst b/changelog/12981.bugfix.rst deleted file mode 100644 index 5fc8e29656f..00000000000 --- a/changelog/12981.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Prevent exceptions in :func:`pytest.Config.add_cleanup` callbacks preventing further cleanups. diff --git a/changelog/13010.improvement.rst b/changelog/13010.improvement.rst deleted file mode 100644 index d6b814f090e..00000000000 --- a/changelog/13010.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -:func:`pytest.approx` now can compare collections that contain numbers and non-numbers mixed. diff --git a/changelog/13016.improvement.rst b/changelog/13016.improvement.rst deleted file mode 100644 index 634672ab69b..00000000000 --- a/changelog/13016.improvement.rst +++ /dev/null @@ -1,8 +0,0 @@ -A number of :ref:`threadexception ` enhancements: - -* Set the excepthook as early as possible and unset it as late as possible, to collect the most possible number of unhandled exceptions from threads. -* Collect multiple thread exceptions per test phase. -* Report the :mod:`tracemalloc` allocation traceback (if available). -* Avoid using a generator based hook to allow handling :class:`StopIteration` in test failures. -* Report the thread exception as the cause of the :class:`pytest.PytestUnhandledThreadExceptionWarning` exception if raised. -* Extract the ``name`` of the thread object in the excepthook which should help with resurrection of the thread. diff --git a/changelog/13031.improvement.rst b/changelog/13031.improvement.rst deleted file mode 100644 index c6c64c4673a..00000000000 --- a/changelog/13031.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -An empty parameter set as in ``pytest.mark.parametrize([], ids=idfunc)`` will no longer trigger a call to ``idfunc`` with internal objects. diff --git a/changelog/13047.bugfix.rst b/changelog/13047.bugfix.rst deleted file mode 100644 index 399e860505c..00000000000 --- a/changelog/13047.bugfix.rst +++ /dev/null @@ -1,17 +0,0 @@ -Restore :func:`pytest.approx` handling of equality checks between `bool` and `numpy.bool_` types. - -Comparing `bool` and `numpy.bool_` using :func:`pytest.approx` accidentally changed in version `8.3.4` and `8.3.5` to no longer match: - -.. code-block:: pycon - - >>> import numpy as np - >>> from pytest import approx - >>> [np.True_, np.True_] == pytest.approx([True, True]) - False - -This has now been fixed: - -.. code-block:: pycon - - >>> [np.True_, np.True_] == pytest.approx([True, True]) - True diff --git a/changelog/13115.improvement.rst b/changelog/13115.improvement.rst deleted file mode 100644 index 9ac45820917..00000000000 --- a/changelog/13115.improvement.rst +++ /dev/null @@ -1,8 +0,0 @@ -Allows supplying ``ExceptionGroup[Exception]`` and ``BaseExceptionGroup[BaseException]`` to ``pytest.raises`` to keep full typing on :class:`ExceptionInfo `: - -.. code-block:: python - - with pytest.raises(ExceptionGroup[Exception]) as exc_info: - some_function() - -Parametrizing with other exception types remains an error - we do not check the types of child exceptions and thus do not permit code that might look like we do. diff --git a/changelog/13119.bugfix.rst b/changelog/13119.bugfix.rst deleted file mode 100644 index b7e56af9bb8..00000000000 --- a/changelog/13119.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Improved handling of invalid regex patterns for filter warnings by providing a clear error message. diff --git a/changelog/13122.improvement.rst b/changelog/13122.improvement.rst deleted file mode 100644 index c302713b320..00000000000 --- a/changelog/13122.improvement.rst +++ /dev/null @@ -1,15 +0,0 @@ -The ``--stepwise`` mode received a number of improvements: - -* It no longer forgets the last failed test in case pytest is executed later without the flag. - - This enables the following workflow: - - 1. Execute pytest with ``--stepwise``, pytest then stops at the first failing test; - 2. Iteratively update the code and run the test in isolation, without the ``--stepwise`` flag (for example in an IDE), until it is fixed. - 3. Execute pytest with ``--stepwise`` again and pytest will continue from the previously failed test, and if it passes, continue on to the next tests. - - Previously, at step 3, pytest would start from the beginning, forgetting the previously failed test. - - This change however might cause issues if the ``--stepwise`` mode is used far apart in time, as the state might get stale, so the internal state will be reset automatically in case the test suite changes (for now only the number of tests are considered for this, we might change/improve this on the future). - -* New ``--stepwise-reset``/``--sw-reset`` flag, allowing the user to explicitly reset the stepwise state and restart the workflow from the beginning. diff --git a/changelog/13125.feature.rst b/changelog/13125.feature.rst deleted file mode 100644 index 0c7d66c1169..00000000000 --- a/changelog/13125.feature.rst +++ /dev/null @@ -1 +0,0 @@ -:confval:`console_output_style` now supports ``times`` to show execution time of each test. diff --git a/changelog/13175.bugfix.rst b/changelog/13175.bugfix.rst deleted file mode 100644 index bdbb72b41e1..00000000000 --- a/changelog/13175.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -The diff is now also highlighted correctly when comparing two strings. diff --git a/changelog/13192.feature.1.rst b/changelog/13192.feature.1.rst deleted file mode 100644 index 71fb06f7d70..00000000000 --- a/changelog/13192.feature.1.rst +++ /dev/null @@ -1 +0,0 @@ -:func:`pytest.raises` will now print a helpful string diff if matching fails and the match parameter has ``^`` and ``$`` and is otherwise escaped. diff --git a/changelog/13192.feature.2.rst b/changelog/13192.feature.2.rst deleted file mode 100644 index 0ffa0e1496a..00000000000 --- a/changelog/13192.feature.2.rst +++ /dev/null @@ -1 +0,0 @@ -You can now pass :func:`with pytest.raises(check=fn): `, where ``fn`` is a function which takes a raised exception and returns a boolean. The ``raises`` fails if no exception was raised (as usual), passes if an exception is raised and ``fn`` returns ``True`` (as well as ``match`` and the type matching, if specified, which are checked before), and propagates the exception if ``fn`` returns ``False`` (which likely also fails the test). diff --git a/changelog/13192.feature.rst b/changelog/13192.feature.rst deleted file mode 100644 index 97f31ce233c..00000000000 --- a/changelog/13192.feature.rst +++ /dev/null @@ -1 +0,0 @@ -:func:`pytest.raises` will now raise a warning when passing an empty string to ``match``, as this will match against any value. Use ``match="^$"`` if you want to check that an exception has no message. diff --git a/changelog/13218.doc.rst b/changelog/13218.doc.rst deleted file mode 100644 index 907a817e895..00000000000 --- a/changelog/13218.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Pointed out in the :func:`pytest.approx` documentation that it considers booleans unequal to numeric zero or one. diff --git a/changelog/13221.doc.rst b/changelog/13221.doc.rst deleted file mode 100644 index cfd35f821b4..00000000000 --- a/changelog/13221.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Improved grouping of CLI options in the ``--help`` output. diff --git a/changelog/13228.feature.rst b/changelog/13228.feature.rst deleted file mode 100644 index c5d84182313..00000000000 --- a/changelog/13228.feature.rst +++ /dev/null @@ -1,3 +0,0 @@ -:ref:`hidden-param` can now be used in ``id`` of :func:`pytest.param` or in -``ids`` of :py:func:`Metafunc.parametrize `. -It hides the parameter set from the test name. diff --git a/changelog/13248.bugfix.rst b/changelog/13248.bugfix.rst deleted file mode 100644 index 2ebb102fd07..00000000000 --- a/changelog/13248.bugfix.rst +++ /dev/null @@ -1,2 +0,0 @@ -Fixed an issue where passing a ``scope`` in :py:func:`Metafunc.parametrize ` with ``indirect=True`` -could result in other fixtures being unable to depend on the parametrized fixture. diff --git a/changelog/13253.feature.rst b/changelog/13253.feature.rst deleted file mode 100644 index e497c207223..00000000000 --- a/changelog/13253.feature.rst +++ /dev/null @@ -1 +0,0 @@ -New flag: :ref:`--disable-plugin-autoload ` which works as an alternative to :envvar:`PYTEST_DISABLE_PLUGIN_AUTOLOAD` when setting environment variables is inconvenient; and allows setting it in config files with :confval:`addopts`. diff --git a/changelog/13291.bugfix.rst b/changelog/13291.bugfix.rst deleted file mode 100644 index 03ce06b697a..00000000000 --- a/changelog/13291.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed ``repr`` of ``attrs`` objects in assertion failure messages when using ``attrs>=25.2``. diff --git a/changelog/13308.improvement.rst b/changelog/13308.improvement.rst deleted file mode 100644 index 70018c66d59..00000000000 --- a/changelog/13308.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Added official support for Python 3.14. diff --git a/changelog/13312.bugfix.rst b/changelog/13312.bugfix.rst deleted file mode 100644 index 62ad36879f5..00000000000 --- a/changelog/13312.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed a possible ``KeyError`` crash on PyPy during collection of tests involving higher-scoped parameters. diff --git a/changelog/13317.packaging.rst b/changelog/13317.packaging.rst deleted file mode 100644 index 94171cb1ef3..00000000000 --- a/changelog/13317.packaging.rst +++ /dev/null @@ -1,4 +0,0 @@ -Specified minimum allowed versions of ``colorama``, ``iniconfig``, -and ``packaging``; and bumped the minimum allowed version -of ``exceptiongroup`` for ``python_version<'3.11'`` from a release -candidate to a full release. diff --git a/changelog/13345.bugfix.rst b/changelog/13345.bugfix.rst deleted file mode 100644 index 5010888aa08..00000000000 --- a/changelog/13345.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix type hints for :attr:`pytest.TestReport.when` and :attr:`pytest.TestReport.location`. diff --git a/changelog/13377.bugfix.rst b/changelog/13377.bugfix.rst deleted file mode 100644 index 15755481f7f..00000000000 --- a/changelog/13377.bugfix.rst +++ /dev/null @@ -1,12 +0,0 @@ -Fixed handling of test methods with positional-only parameter syntax. - -Now, methods are supported that formally define ``self`` as positional-only -and/or fixture parameters as keyword-only, e.g.: - -.. code-block:: python - - class TestClass: - - def test_method(self, /, *, fixture): ... - -Before, this caused an internal error in pytest. diff --git a/changelog/13380.improvement.rst b/changelog/13380.improvement.rst deleted file mode 100644 index 51f374fbf01..00000000000 --- a/changelog/13380.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Fix :class:`ExceptionGroup` traceback filtering to exclude pytest internals. diff --git a/changelog/13384.bugfix.rst b/changelog/13384.bugfix.rst deleted file mode 100644 index e93d01dcab0..00000000000 --- a/changelog/13384.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed an issue where pytest could report negative durations. diff --git a/changelog/13415.improvement.rst b/changelog/13415.improvement.rst deleted file mode 100644 index 61667f15c7b..00000000000 --- a/changelog/13415.improvement.rst +++ /dev/null @@ -1,5 +0,0 @@ -The author metadata of the BibTex example is now correctly formatted with last names following first names. -An example of BibLaTex has been added. -BibTex and BibLaTex examples now clearly indicate that what is cited is software. - --- by :user:`willynilly` diff --git a/changelog/13420.bugfix.rst b/changelog/13420.bugfix.rst deleted file mode 100644 index 02f7372a759..00000000000 --- a/changelog/13420.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Added ``lru_cache`` to ``nodes._check_initialpaths_for_relpath``. diff --git a/changelog/13420.improvement.rst b/changelog/13420.improvement.rst deleted file mode 100644 index 54fe50a72b0..00000000000 --- a/changelog/13420.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Improved test collection performance by optimizing path resolution used in ``FSCollector``. diff --git a/changelog/13457.improvement.rst b/changelog/13457.improvement.rst deleted file mode 100644 index 3937384b322..00000000000 --- a/changelog/13457.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -The error message about duplicate parametrization no longer displays an internal stack trace. diff --git a/changelog/4112.improvement.rst b/changelog/4112.improvement.rst deleted file mode 100644 index 426b87ffa19..00000000000 --- a/changelog/4112.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Using :ref:`pytest.mark.usefixtures ` on :func:`pytest.param` now produces an error instead of silently doing nothing. diff --git a/changelog/5473.improvement.rst b/changelog/5473.improvement.rst deleted file mode 100644 index 1b9ab006d49..00000000000 --- a/changelog/5473.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Replace `:` with `;` in the assertion rewrite warning message so it can be filtered using standard Python warning filters before calling :func:`pytest.main`. diff --git a/changelog/6649.doc.rst b/changelog/6649.doc.rst deleted file mode 100644 index cf5bb781b87..00000000000 --- a/changelog/6649.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Added :class:`~pytest.TerminalReporter` to the :ref:`api-reference` documentation page. diff --git a/changelog/6649.misc.rst b/changelog/6649.misc.rst deleted file mode 100644 index cec8c3f4506..00000000000 --- a/changelog/6649.misc.rst +++ /dev/null @@ -1 +0,0 @@ -Added :class:`~pytest.TerminalReporter` to the public pytest API, as it is part of the signature of the :hook:`pytest_terminal_summary` hook. diff --git a/changelog/6985.improvement.rst b/changelog/6985.improvement.rst deleted file mode 100644 index 34ee8edc77d..00000000000 --- a/changelog/6985.improvement.rst +++ /dev/null @@ -1,21 +0,0 @@ -Improved :func:`pytest.approx` to enhance the readability of value ranges and tolerances between 0.001 and 1000. - * The `repr` method now provides clearer output for values within those ranges, making it easier to interpret the results. - * Previously, the output for those ranges of values and tolerances was displayed in scientific notation (e.g., `42 ± 1.0e+00`). The updated method now presents the tolerance as a decimal for better readability (e.g., `42 ± 1`). - - Example: - - **Previous Output:** - - .. code-block:: console - - >>> pytest.approx(42, abs=1) - 42 ± 1.0e+00 - - **Current Output:** - - .. code-block:: console - - >>> pytest.approx(42, abs=1) - 42 ± 1 - - -- by :user:`fazeelghafoor` diff --git a/changelog/7683.improvement.rst b/changelog/7683.improvement.rst deleted file mode 100644 index 311abe4df93..00000000000 --- a/changelog/7683.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -The formerly optional ``pygments`` dependency is now required, causing output always to be source-highlighted (unless disabled via the ``--code-highlight=no`` CLI option). diff --git a/changelog/8612.doc.rst b/changelog/8612.doc.rst deleted file mode 100644 index 6ab4102ace4..00000000000 --- a/changelog/8612.doc.rst +++ /dev/null @@ -1,5 +0,0 @@ -Add a recipe for handling abstract test classes in the documentation. - -A new example has been added to the documentation to demonstrate how to use a mixin class to handle abstract -test classes without manually setting the ``__test__`` attribute for subclasses. -This ensures that subclasses of abstract test classes are automatically collected by pytest. diff --git a/changelog/9037.bugfix.rst b/changelog/9037.bugfix.rst deleted file mode 100644 index 5367452337e..00000000000 --- a/changelog/9037.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Honor :confval:`disable_test_id_escaping_and_forfeit_all_rights_to_community_support` when escaping ids in parametrized tests. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index 51edc964a0c..702fd26dd0d 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-8.4.0 release-8.3.5 release-8.3.4 release-8.3.3 diff --git a/doc/en/announce/release-8.4.0.rst b/doc/en/announce/release-8.4.0.rst new file mode 100644 index 00000000000..65e80a55919 --- /dev/null +++ b/doc/en/announce/release-8.4.0.rst @@ -0,0 +1,106 @@ +pytest-8.4.0 +======================================= + +The pytest team is proud to announce the 8.4.0 release! + +This release contains new features, improvements, and bug fixes, +the full list of changes is available in the changelog: + + https://docs.pytest.org/en/stable/changelog.html + +For complete documentation, please visit: + + https://docs.pytest.org/en/stable/ + +As usual, you can upgrade from PyPI via: + + pip install -U pytest + +Thanks to all of the contributors to this release: + +* Adam Johnson +* Ammar Askar +* Andrew Pikul +* Andy Freeland +* Anthony Sottile +* Anton Zhilin +* Arpit Gupta +* Ashley Whetter +* Avasam +* Bahram Farahmand +* Brigitta Sipőcz +* Bruno Oliveira +* Callum Scott +* Christian Clauss +* Christopher Head +* Daara +* Daniel Miller +* Deysha Rivera +* Emil Hjelm +* Eugene Mwangi +* Florian Bruhin +* Frank Hoffmann +* GTowers1 +* Guillaume Gauvrit +* Gupta Arpit +* Harmin Parra Rueda +* Jakob van Santen +* Jason N. White +* Jiajun Xu +* John Litborn +* Julian Valentin +* JulianJvn +* Kenny Y +* Leonardus Chen +* Marcelo Duarte Trevisani +* Marcin Augustynów +* Natalia Mokeeva +* Nathan Rousseau +* Nauman Ahmed +* Nick Murphy +* Oleksandr Zavertniev +* Pavel Zhukov +* Peter Gessler +* Pierre Sassoulas +* Pradeep Kumar +* Ran Benita +* Reagan Lee +* Rob Arrow +* Ronny Pfannschmidt +* Sadra Barikbin +* Sam Bull +* Samuel Bronson +* Sashko +* Serge Smertin +* Shaygan Hooshyari +* Stefaan Lippens +* Stefan Zimmermann +* Stephen McDowell +* Sviatoslav Sydorenko +* Sviatoslav Sydorenko (Святослав Сидоренко) +* Thomas Grainger +* TobiMcNamobi +* Tobias Alex-Petersen +* Tony Narlock +* Vincent (Wen Yu) Ge +* Virendra Patil +* Will Riley +* Yann Dirson +* Zac Hatfield-Dodds +* delta87 +* dongfangtianyu +* eitanwass +* fazeelghafoor +* ikappaki +* jakkdl +* maugu +* moajo +* mwychung +* polkapolka +* suspe +* sven +* 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) + + +Happy testing, +The pytest Development Team diff --git a/doc/en/builtin.rst b/doc/en/builtin.rst index 8aa6fef681c..b129d0a763f 100644 --- a/doc/en/builtin.rst +++ b/doc/en/builtin.rst @@ -22,7 +22,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a cachedir: .pytest_cache rootdir: /home/sweet/project collected 0 items - cache -- .../_pytest/cacheprovider.py:556 + cache -- .../_pytest/cacheprovider.py:555 Return a cache object that can persist state between testing sessions. cache.get(key, default) @@ -33,7 +33,48 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a Values can be any object handled by the json stdlib module. - capsysbinary -- .../_pytest/capture.py:1024 + capsys -- .../_pytest/capture.py:1000 + Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``. + + The captured output is made available via ``capsys.readouterr()`` method + calls, which return a ``(out, err)`` namedtuple. + ``out`` and ``err`` will be ``text`` objects. + + Returns an instance of :class:`CaptureFixture[str] `. + + Example: + + .. code-block:: python + + def test_output(capsys): + print("hello") + captured = capsys.readouterr() + assert captured.out == "hello\n" + + capteesys -- .../_pytest/capture.py:1028 + Enable simultaneous text capturing and pass-through of writes + to ``sys.stdout`` and ``sys.stderr`` as defined by ``--capture=``. + + + The captured output is made available via ``capteesys.readouterr()`` method + calls, which return a ``(out, err)`` namedtuple. + ``out`` and ``err`` will be ``text`` objects. + + The output is also passed-through, allowing it to be "live-printed", + reported, or both as defined by ``--capture=``. + + Returns an instance of :class:`CaptureFixture[str] `. + + Example: + + .. code-block:: python + + def test_output(capsys): + print("hello") + captured = capteesys.readouterr() + assert captured.out == "hello\n" + + capsysbinary -- .../_pytest/capture.py:1063 Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``. The captured output is made available via ``capsysbinary.readouterr()`` @@ -51,7 +92,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capsysbinary.readouterr() assert captured.out == b"hello\n" - capfd -- .../_pytest/capture.py:1052 + capfd -- .../_pytest/capture.py:1091 Enable text capturing of writes to file descriptors ``1`` and ``2``. The captured output is made available via ``capfd.readouterr()`` method @@ -69,7 +110,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capfd.readouterr() assert captured.out == "hello\n" - capfdbinary -- .../_pytest/capture.py:1080 + capfdbinary -- .../_pytest/capture.py:1119 Enable bytes capturing of writes to file descriptors ``1`` and ``2``. The captured output is made available via ``capfd.readouterr()`` method @@ -87,25 +128,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a captured = capfdbinary.readouterr() assert captured.out == b"hello\n" - capsys -- .../_pytest/capture.py:996 - Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``. - - The captured output is made available via ``capsys.readouterr()`` method - calls, which return a ``(out, err)`` namedtuple. - ``out`` and ``err`` will be ``text`` objects. - - Returns an instance of :class:`CaptureFixture[str] `. - - Example: - - .. code-block:: python - - def test_output(capsys): - print("hello") - captured = capsys.readouterr() - assert captured.out == "hello\n" - - doctest_namespace [session scope] -- .../_pytest/doctest.py:741 + doctest_namespace [session scope] -- .../_pytest/doctest.py:740 Fixture that returns a :py:class:`dict` that will be injected into the namespace of doctests. @@ -119,7 +142,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a For more details: :ref:`doctest_namespace`. - pytestconfig [session scope] -- .../_pytest/fixtures.py:1345 + pytestconfig [session scope] -- .../_pytest/fixtures.py:1424 Session-scoped fixture that returns the session's :class:`pytest.Config` object. @@ -129,7 +152,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a if pytestconfig.get_verbosity() > 0: ... - record_property -- .../_pytest/junitxml.py:280 + record_property -- .../_pytest/junitxml.py:277 Add extra properties to the calling test. User properties become part of the test report and are available to the @@ -143,13 +166,13 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a def test_function(record_property): record_property("example_key", 1) - record_xml_attribute -- .../_pytest/junitxml.py:303 + record_xml_attribute -- .../_pytest/junitxml.py:300 Add extra xml attributes to the tag for the calling test. The fixture is callable with ``name, value``. The value is automatically XML-encoded. - record_testsuite_property [session scope] -- .../_pytest/junitxml.py:341 + record_testsuite_property [session scope] -- .../_pytest/junitxml.py:338 Record a new ```` tag as child of the root ````. This is suitable to writing global information regarding the entire test @@ -191,7 +214,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a .. _legacy_path: https://py.readthedocs.io/en/latest/path.html - caplog -- .../_pytest/logging.py:598 + caplog -- .../_pytest/logging.py:596 Access and control log capturing. Captured logs are available through the following properties/methods:: @@ -226,15 +249,15 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a To undo modifications done by the fixture in a contained scope, use :meth:`context() `. - recwarn -- .../_pytest/recwarn.py:35 + recwarn -- .../_pytest/recwarn.py:34 Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions. See :ref:`warnings` for information on warning categories. - tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:241 + tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:240 Return a :class:`pytest.TempPathFactory` instance for the test session. - tmp_path -- .../_pytest/tmpdir.py:256 + tmp_path -- .../_pytest/tmpdir.py:255 Return a temporary directory (as :class:`pathlib.Path` object) which is unique to each test function invocation. The temporary directory is created as a subdirectory diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index c92cd7d4263..73073ffca1c 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -31,6 +31,427 @@ with advance notice in the **Deprecations** section of releases. .. towncrier release notes start +pytest 8.4.0 (2025-06-02) +========================= + +Removals and backward incompatible breaking changes +--------------------------------------------------- + +- `#11372 `_: Async tests will now fail, instead of warning+skipping, if you don't have any suitable plugin installed. + + +- `#12346 `_: Tests will now fail, instead of raising a warning, if they return any value other than None. + + +- `#12874 `_: We dropped support for Python 3.8 following its end of life (2024-10-07). + + +- `#12960 `_: Test functions containing a yield now cause an explicit error. They have not been run since pytest 4.0, and were previously marked as an expected failure and deprecation warning. + + See :ref:`the docs ` for more information. + + + +Deprecations (removal in next major release) +-------------------------------------------- + +- `#10839 `_: Requesting an asynchronous fixture without a `pytest_fixture_setup` hook that resolves it will now give a DeprecationWarning. This most commonly happens if a sync test requests an async fixture. This should have no effect on a majority of users with async tests or fixtures using async pytest plugins, but may affect non-standard hook setups or ``autouse=True``. For guidance on how to work around this warning see :ref:`sync-test-async-fixture`. + + + +New features +------------ + +- `#11538 `_: Added :class:`pytest.RaisesGroup` as an equivalent to :func:`pytest.raises` for expecting :exc:`ExceptionGroup`. Also adds :class:`pytest.RaisesExc` which is now the logic behind :func:`pytest.raises` and used as parameter to :class:`pytest.RaisesGroup`. ``RaisesGroup`` includes the ability to specify multiple different expected exceptions, the structure of nested exception groups, and flags for emulating :ref:`except* `. See :ref:`assert-matching-exception-groups` and docstrings for more information. + + +- `#12081 `_: Added :fixture:`capteesys` to capture AND pass output to next handler set by ``--capture=``. + + +- `#12504 `_: :func:`pytest.mark.xfail` now accepts :class:`pytest.RaisesGroup` for the ``raises`` parameter when you expect an exception group. You can also pass a :class:`pytest.RaisesExc` if you e.g. want to make use of the ``check`` parameter. + + +- `#12713 `_: New `--force-short-summary` option to force condensed summary output regardless of verbosity level. + + This lets users still see condensed summary output of failures for quick reference in log files from job outputs, being especially useful if non-condensed output is very verbose. + + +- `#12749 `_: pytest traditionally collects classes/functions in the test module namespace even if they are imported from another file. + + For example: + + .. code-block:: python + + # contents of src/domain.py + class Testament: ... + + + # contents of tests/test_testament.py + from domain import Testament + + + def test_testament(): ... + + In this scenario with the default options, pytest will collect the class `Testament` from `tests/test_testament.py` because it starts with `Test`, even though in this case it is a production class being imported in the test module namespace. + + This behavior can now be prevented by setting the new :confval:`collect_imported_tests` configuration option to ``false``, which will make pytest collect classes/functions from test files **only** if they are defined in that file. + + -- by :user:`FreerGit` + + +- `#12765 `_: Thresholds to trigger snippet truncation can now be set with :confval:`truncation_limit_lines` and :confval:`truncation_limit_chars`. + + See :ref:`truncation-params` for more information. + + +- `#13125 `_: :confval:`console_output_style` now supports ``times`` to show execution time of each test. + + +- `#13192 `_: :func:`pytest.raises` will now raise a warning when passing an empty string to ``match``, as this will match against any value. Use ``match="^$"`` if you want to check that an exception has no message. + + +- `#13192 `_: :func:`pytest.raises` will now print a helpful string diff if matching fails and the match parameter has ``^`` and ``$`` and is otherwise escaped. + + +- `#13192 `_: You can now pass :func:`with pytest.raises(check=fn): `, where ``fn`` is a function which takes a raised exception and returns a boolean. The ``raises`` fails if no exception was raised (as usual), passes if an exception is raised and ``fn`` returns ``True`` (as well as ``match`` and the type matching, if specified, which are checked before), and propagates the exception if ``fn`` returns ``False`` (which likely also fails the test). + + +- `#13228 `_: :ref:`hidden-param` can now be used in ``id`` of :func:`pytest.param` or in + ``ids`` of :py:func:`Metafunc.parametrize `. + It hides the parameter set from the test name. + + +- `#13253 `_: New flag: :ref:`--disable-plugin-autoload ` which works as an alternative to :envvar:`PYTEST_DISABLE_PLUGIN_AUTOLOAD` when setting environment variables is inconvenient; and allows setting it in config files with :confval:`addopts`. + + + +Improvements in existing functionality +-------------------------------------- + +- `#10224 `_: pytest's ``short`` and ``long`` traceback styles (:ref:`how-to-modifying-python-tb-printing`) + now have partial :pep:`657` support and will show specific code segments in the + traceback. + + .. code-block:: pytest + + ================================= FAILURES ================================= + _______________________ test_gets_correct_tracebacks _______________________ + + test_tracebacks.py:12: in test_gets_correct_tracebacks + assert manhattan_distance(p1, p2) == 1 + ^^^^^^^^^^^^^^^^^^^^^^^^^^ + test_tracebacks.py:6: in manhattan_distance + return abs(point_1.x - point_2.x) + abs(point_1.y - point_2.y) + ^^^^^^^^^ + E AttributeError: 'NoneType' object has no attribute 'x' + + -- by :user:`ammaraskar` + + +- `#11118 `_: Now :confval:`pythonpath` configures `$PYTHONPATH` earlier than before during the initialization process, which now also affects plugins loaded via the `-p` command-line option. + + -- by :user:`millerdev` + + +- `#11381 `_: The ``type`` parameter of the ``parser.addini`` method now accepts `"int"` and ``"float"`` parameters, facilitating the parsing of configuration values in the configuration file. + + Example: + + .. code-block:: python + + def pytest_addoption(parser): + parser.addini("int_value", type="int", default=2, help="my int value") + parser.addini("float_value", type="float", default=4.2, help="my float value") + + The `pytest.ini` file: + + .. code-block:: ini + + [pytest] + int_value = 3 + float_value = 5.4 + + +- `#11525 `_: Fixtures are now clearly represented in the output as a "fixture object", not as a normal function as before, making it easy for beginners to catch mistakes such as referencing a fixture declared in the same module but not requested in the test function. + + -- by :user:`the-compiler` and :user:`glyphack` + + +- `#12426 `_: A warning is now issued when :ref:`pytest.mark.usefixtures ref` is used without specifying any fixtures. Previously, empty usefixtures markers were silently ignored. + + +- `#12707 `_: Exception chains can be navigated when dropped into Pdb in Python 3.13+. + + +- `#12736 `_: Added a new attribute `name` with the fixed value `"pytest tests"` to the root tag `testsuites` of the junit-xml generated by pytest. + + This attribute is part of many junit-xml specifications and is even part of the `junit-10.xsd` specification that pytest's implementation is based on. + + +- `#12943 `_: If a test fails with an exceptiongroup with a single exception, the contained exception will now be displayed in the short test summary info. + + +- `#12958 `_: A number of :ref:`unraisable ` enhancements: + + * Set the unraisable hook as early as possible and unset it as late as possible, to collect the most possible number of unraisable exceptions. + * Call the garbage collector just before unsetting the unraisable hook, to collect any straggling exceptions. + * Collect multiple unraisable exceptions per test phase. + * Report the :mod:`tracemalloc` allocation traceback (if available). + * Avoid using a generator based hook to allow handling :class:`StopIteration` in test failures. + * Report the unraisable exception as the cause of the :class:`pytest.PytestUnraisableExceptionWarning` exception if raised. + * Compute the ``repr`` of the unraisable object in the unraisable hook so you get the latest information if available, and should help with resurrection of the object. + + +- `#13010 `_: :func:`pytest.approx` now can compare collections that contain numbers and non-numbers mixed. + + +- `#13016 `_: A number of :ref:`threadexception ` enhancements: + + * Set the excepthook as early as possible and unset it as late as possible, to collect the most possible number of unhandled exceptions from threads. + * Collect multiple thread exceptions per test phase. + * Report the :mod:`tracemalloc` allocation traceback (if available). + * Avoid using a generator based hook to allow handling :class:`StopIteration` in test failures. + * Report the thread exception as the cause of the :class:`pytest.PytestUnhandledThreadExceptionWarning` exception if raised. + * Extract the ``name`` of the thread object in the excepthook which should help with resurrection of the thread. + + +- `#13031 `_: An empty parameter set as in ``pytest.mark.parametrize([], ids=idfunc)`` will no longer trigger a call to ``idfunc`` with internal objects. + + +- `#13115 `_: Allows supplying ``ExceptionGroup[Exception]`` and ``BaseExceptionGroup[BaseException]`` to ``pytest.raises`` to keep full typing on :class:`ExceptionInfo `: + + .. code-block:: python + + with pytest.raises(ExceptionGroup[Exception]) as exc_info: + some_function() + + Parametrizing with other exception types remains an error - we do not check the types of child exceptions and thus do not permit code that might look like we do. + + +- `#13122 `_: The ``--stepwise`` mode received a number of improvements: + + * It no longer forgets the last failed test in case pytest is executed later without the flag. + + This enables the following workflow: + + 1. Execute pytest with ``--stepwise``, pytest then stops at the first failing test; + 2. Iteratively update the code and run the test in isolation, without the ``--stepwise`` flag (for example in an IDE), until it is fixed. + 3. Execute pytest with ``--stepwise`` again and pytest will continue from the previously failed test, and if it passes, continue on to the next tests. + + Previously, at step 3, pytest would start from the beginning, forgetting the previously failed test. + + This change however might cause issues if the ``--stepwise`` mode is used far apart in time, as the state might get stale, so the internal state will be reset automatically in case the test suite changes (for now only the number of tests are considered for this, we might change/improve this on the future). + + * New ``--stepwise-reset``/``--sw-reset`` flag, allowing the user to explicitly reset the stepwise state and restart the workflow from the beginning. + + +- `#13308 `_: Added official support for Python 3.14. + + +- `#13380 `_: Fix :class:`ExceptionGroup` traceback filtering to exclude pytest internals. + + +- `#13415 `_: The author metadata of the BibTex example is now correctly formatted with last names following first names. + An example of BibLaTex has been added. + BibTex and BibLaTex examples now clearly indicate that what is cited is software. + + -- by :user:`willynilly` + + +- `#13420 `_: Improved test collection performance by optimizing path resolution used in ``FSCollector``. + + +- `#13457 `_: The error message about duplicate parametrization no longer displays an internal stack trace. + + +- `#4112 `_: Using :ref:`pytest.mark.usefixtures ` on :func:`pytest.param` now produces an error instead of silently doing nothing. + + +- `#5473 `_: Replace `:` with `;` in the assertion rewrite warning message so it can be filtered using standard Python warning filters before calling :func:`pytest.main`. + + +- `#6985 `_: Improved :func:`pytest.approx` to enhance the readability of value ranges and tolerances between 0.001 and 1000. + * The `repr` method now provides clearer output for values within those ranges, making it easier to interpret the results. + * Previously, the output for those ranges of values and tolerances was displayed in scientific notation (e.g., `42 ± 1.0e+00`). The updated method now presents the tolerance as a decimal for better readability (e.g., `42 ± 1`). + + Example: + + **Previous Output:** + + .. code-block:: console + + >>> pytest.approx(42, abs=1) + 42 ± 1.0e+00 + + **Current Output:** + + .. code-block:: console + + >>> pytest.approx(42, abs=1) + 42 ± 1 + + -- by :user:`fazeelghafoor` + + +- `#7683 `_: The formerly optional ``pygments`` dependency is now required, causing output always to be source-highlighted (unless disabled via the ``--code-highlight=no`` CLI option). + + + +Bug fixes +--------- + +- `#10404 `_: Apply filterwarnings from config/cli as soon as possible, and revert them as late as possible + so that warnings as errors are collected throughout the pytest run and before the + unraisable and threadexcept hooks are removed. + + This allows very late warnings and unraisable/threadexcept exceptions to fail the test suite. + + This also changes the warning that the lsof plugin issues from PytestWarning to the new warning PytestFDWarning so it can be more easily filtered. + + +- `#11067 `_: The test report is now consistent regardless if the test xfailed via :ref:`pytest.mark.xfail ` or :func:`pytest.fail`. + + Previously, *xfailed* tests via the marker would have the string ``"reason: "`` prefixed to the message, while those *xfailed* via the function did not. The prefix has been removed. + + +- `#12008 `_: In :pr:`11220`, an unintended change in reordering was introduced by changing the way indices were assigned to direct params. More specifically, before that change, the indices of direct params to metafunc's callspecs were assigned after all parametrizations took place. Now, that change is reverted. + + +- `#12863 `_: Fix applying markers, including :ref:`pytest.mark.parametrize ` when placed above `@staticmethod` or `@classmethod`. + + +- `#12929 `_: Handle StopIteration from test cases, setup and teardown correctly. + + +- `#12938 `_: Fixed ``--durations-min`` argument not respected if ``-vv`` is used. + + +- `#12946 `_: Fixed missing help for :mod:`pdb` commands wrapped by pytest -- by :user:`adamchainz`. + + +- `#12981 `_: Prevent exceptions in :func:`pytest.Config.add_cleanup` callbacks preventing further cleanups. + + +- `#13047 `_: Restore :func:`pytest.approx` handling of equality checks between `bool` and `numpy.bool_` types. + + Comparing `bool` and `numpy.bool_` using :func:`pytest.approx` accidentally changed in version `8.3.4` and `8.3.5` to no longer match: + + .. code-block:: pycon + + >>> import numpy as np + >>> from pytest import approx + >>> [np.True_, np.True_] == pytest.approx([True, True]) + False + + This has now been fixed: + + .. code-block:: pycon + + >>> [np.True_, np.True_] == pytest.approx([True, True]) + True + + +- `#13119 `_: Improved handling of invalid regex patterns for filter warnings by providing a clear error message. + + +- `#13175 `_: The diff is now also highlighted correctly when comparing two strings. + + +- `#13248 `_: Fixed an issue where passing a ``scope`` in :py:func:`Metafunc.parametrize ` with ``indirect=True`` + could result in other fixtures being unable to depend on the parametrized fixture. + + +- `#13291 `_: Fixed ``repr`` of ``attrs`` objects in assertion failure messages when using ``attrs>=25.2``. + + +- `#13312 `_: Fixed a possible ``KeyError`` crash on PyPy during collection of tests involving higher-scoped parameters. + + +- `#13345 `_: Fix type hints for :attr:`pytest.TestReport.when` and :attr:`pytest.TestReport.location`. + + +- `#13377 `_: Fixed handling of test methods with positional-only parameter syntax. + + Now, methods are supported that formally define ``self`` as positional-only + and/or fixture parameters as keyword-only, e.g.: + + .. code-block:: python + + class TestClass: + + def test_method(self, /, *, fixture): ... + + Before, this caused an internal error in pytest. + + +- `#13384 `_: Fixed an issue where pytest could report negative durations. + + +- `#13420 `_: Added ``lru_cache`` to ``nodes._check_initialpaths_for_relpath``. + + +- `#9037 `_: Honor :confval:`disable_test_id_escaping_and_forfeit_all_rights_to_community_support` when escaping ids in parametrized tests. + + + +Improved documentation +---------------------- + +- `#12535 `_: `This + example` + showed ``print`` statements that do not exactly reflect what the + different branches actually do. The fix makes the example more precise. + + +- `#13218 `_: Pointed out in the :func:`pytest.approx` documentation that it considers booleans unequal to numeric zero or one. + + +- `#13221 `_: Improved grouping of CLI options in the ``--help`` output. + + +- `#6649 `_: Added :class:`~pytest.TerminalReporter` to the :ref:`api-reference` documentation page. + + +- `#8612 `_: Add a recipe for handling abstract test classes in the documentation. + + A new example has been added to the documentation to demonstrate how to use a mixin class to handle abstract + test classes without manually setting the ``__test__`` attribute for subclasses. + This ensures that subclasses of abstract test classes are automatically collected by pytest. + + + +Packaging updates and notes for downstreams +------------------------------------------- + +- `#13317 `_: Specified minimum allowed versions of ``colorama``, ``iniconfig``, + and ``packaging``; and bumped the minimum allowed version + of ``exceptiongroup`` for ``python_version<'3.11'`` from a release + candidate to a full release. + + + +Contributor-facing changes +-------------------------- + +- `#12017 `_: Mixed internal improvements: + + * Migrate formatting to f-strings in some tests. + * Use type-safe constructs in JUnitXML tests. + * Moved`` MockTiming`` into ``_pytest.timing``. + + -- by :user:`RonnyPfannschmidt` + + +- `#12647 `_: Fixed running the test suite with the ``hypothesis`` pytest plugin. + + + +Miscellaneous internal changes +------------------------------ + +- `#6649 `_: Added :class:`~pytest.TerminalReporter` to the public pytest API, as it is part of the signature of the :hook:`pytest_terminal_summary` hook. + + pytest 8.3.5 (2025-03-02) ========================= diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index 69e715c9db1..c3848db5112 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -162,7 +162,7 @@ objects, they are still using the default pytest representation: rootdir: /home/sweet/project collected 8 items - + @@ -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 - + @@ -318,7 +318,7 @@ Let's first see how it looks like at collection time: rootdir: /home/sweet/project collected 2 items - + diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 6a3b143d580..760140390cb 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -152,7 +152,7 @@ The test collection would look like this: configfile: pytest.ini collected 2 items - + @@ -215,7 +215,7 @@ You can always peek at the collection tree without running tests like this: configfile: pytest.ini collected 3 items - + diff --git a/doc/en/example/reportingdemo.rst b/doc/en/example/reportingdemo.rst index 5e48815bbc9..8040ee9b957 100644 --- a/doc/en/example/reportingdemo.rst +++ b/doc/en/example/reportingdemo.rst @@ -384,6 +384,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: i = Foo() > assert i.b == 2 + ^^^ failure_demo.py:148: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @@ -446,6 +447,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: def test_tupleerror(self): > a, b = [1] # noqa: F841 + ^^^^ E ValueError: not enough values to unpack (expected 2, got 1) failure_demo.py:177: ValueError @@ -457,6 +459,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: items = [1, 2, 3] print(f"items is {items!r}") > a, b = items.pop() + ^^^^ E TypeError: cannot unpack non-iterable int object failure_demo.py:182: TypeError @@ -468,6 +471,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: def test_some_error(self): > if namenotexi: # noqa: F821 + ^^^^^^^^^^ E NameError: name 'namenotexi' is not defined failure_demo.py:185: NameError @@ -526,6 +530,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: def test_z1_unpack_error(self): items = [] > a, b = items + ^^^^ E ValueError: not enough values to unpack (expected 2, got 0) failure_demo.py:219: ValueError @@ -536,6 +541,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: def test_z2_type_error(self): items = 3 > a, b = items + ^^^^ E TypeError: cannot unpack non-iterable int object failure_demo.py:223: TypeError @@ -568,12 +574,12 @@ Here is a nice run of several failures and how ``pytest`` presents things: E + where False = ('456') E + where = '123'.startswith E + where '123' = .f at 0xdeadbeef0029>() - E + and '456' = .g at 0xdeadbeef0003>() + E + and '456' = .g at 0xdeadbeef002a>() failure_demo.py:237: AssertionError _____________________ TestMoreErrors.test_global_func ______________________ - self = + self = def test_global_func(self): > assert isinstance(globf(42), float) @@ -584,18 +590,18 @@ Here is a nice run of several failures and how ``pytest`` presents things: failure_demo.py:240: AssertionError _______________________ TestMoreErrors.test_instance _______________________ - self = + self = def test_instance(self): self.x = 6 * 7 > assert self.x != 42 E assert 42 != 42 - E + where 42 = .x + E + where 42 = .x failure_demo.py:244: AssertionError _______________________ TestMoreErrors.test_compare ________________________ - self = + self = def test_compare(self): > assert globf(10) < 5 @@ -605,7 +611,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: failure_demo.py:247: AssertionError _____________________ TestMoreErrors.test_try_finally ______________________ - self = + self = def test_try_finally(self): x = 1 @@ -616,7 +622,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: failure_demo.py:252: AssertionError ___________________ TestCustomAssertMsg.test_single_line ___________________ - self = + self = def test_single_line(self): class A: @@ -631,16 +637,16 @@ Here is a nice run of several failures and how ``pytest`` presents things: failure_demo.py:263: AssertionError ____________________ TestCustomAssertMsg.test_multiline ____________________ - self = + self = def test_multiline(self): class A: a = 1 b = 2 - > assert ( - A.a == b - ), "A.a appears not to be b\nor does not appear to be b\none of those" + > assert A.a == b, ( + "A.a appears not to be b\nor does not appear to be b\none of those" + ) E AssertionError: A.a appears not to be b E or does not appear to be b E one of those @@ -650,7 +656,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: failure_demo.py:270: AssertionError ___________________ TestCustomAssertMsg.test_custom_repr ___________________ - self = + self = def test_custom_repr(self): class JSON: diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index 69d973e51d0..c1a444bea18 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -104,6 +104,7 @@ Let's run this without supplying our new option: elif cmdopt == "type2": print("second") > assert 0 # to see what was printed + ^^^^^^^^ E assert 0 test_sample.py:6: AssertionError @@ -130,6 +131,7 @@ And now with supplying a command line option: elif cmdopt == "type2": print("second") > assert 0 # to see what was printed + ^^^^^^^^ E assert 0 test_sample.py:6: AssertionError @@ -646,7 +648,7 @@ If we run this: test_step.py:11: AssertionError ========================= short test summary info ========================== - XFAIL test_step.py::TestUserHandling::test_deletion - reason: previous test failed (test_modification) + XFAIL test_step.py::TestUserHandling::test_deletion - previous test failed (test_modification) ================== 1 failed, 2 passed, 1 xfailed in 0.12s ================== We'll see that ``test_deletion`` was not executed because ``test_modification`` @@ -725,7 +727,7 @@ We can run this: file /home/sweet/project/b/test_error.py, line 1 def test_root(db): # no db here, will error out E fixture 'db' not found - > available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory + > available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, capteesys, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory > use 'pytest --fixtures [testpath]' for help on them. /home/sweet/project/b/test_error.py:1 @@ -736,6 +738,7 @@ We can run this: def test_a1(db): > assert 0, db # to show value + ^^^^^^^^^^^^ E AssertionError: E assert 0 @@ -746,6 +749,7 @@ We can run this: def test_a2(db): > assert 0, db # to show value + ^^^^^^^^^^^^ E AssertionError: E assert 0 @@ -946,7 +950,7 @@ and run it: rootdir: /home/sweet/project collected 3 items - test_module.py Esetting up a test failed or skipped test_module.py::test_setup_fails + test_module.py Esetting up a test failed test_module.py::test_setup_fails Fexecuting test failed or skipped test_module.py::test_call_fails F diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 41469de3864..c92e97f556e 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -22,7 +22,7 @@ Install ``pytest`` .. code-block:: bash $ pytest --version - pytest 8.3.5 + pytest 8.4.0 .. _`simpletest`: diff --git a/doc/en/how-to/cache.rst b/doc/en/how-to/cache.rst index a3b2a862534..e3209b79359 100644 --- a/doc/en/how-to/cache.rst +++ b/doc/en/how-to/cache.rst @@ -289,8 +289,6 @@ You can always peek at the content of the cache using the {'test_caching.py::test_function': True} cache/nodeids contains: ['test_caching.py::test_function'] - cache/stepwise contains: - [] example/value contains: 42 diff --git a/doc/en/how-to/capture-warnings.rst b/doc/en/how-to/capture-warnings.rst index 4b1de6f3704..a9bd894b6fd 100644 --- a/doc/en/how-to/capture-warnings.rst +++ b/doc/en/how-to/capture-warnings.rst @@ -66,6 +66,7 @@ as an error: def test_one(): > assert api_v1() == 1 + ^^^^^^^^ test_show_warnings.py:10: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ diff --git a/doc/en/how-to/fixtures.rst b/doc/en/how-to/fixtures.rst index 8f84e4867a6..a86fd1065fd 100644 --- a/doc/en/how-to/fixtures.rst +++ b/doc/en/how-to/fixtures.rst @@ -449,6 +449,7 @@ marked ``smtp_connection`` fixture function. Running the test looks like this: assert response == 250 assert b"smtp.gmail.com" in msg > assert 0 # for demo purposes + ^^^^^^^^ E assert 0 test_module.py:7: AssertionError @@ -460,6 +461,7 @@ marked ``smtp_connection`` fixture function. Running the test looks like this: response, msg = smtp_connection.noop() assert response == 250 > assert 0 # for demo purposes + ^^^^^^^^ E assert 0 test_module.py:13: AssertionError @@ -1308,6 +1310,7 @@ So let's just do another run: assert response == 250 assert b"smtp.gmail.com" in msg > assert 0 # for demo purposes + ^^^^^^^^ E assert 0 test_module.py:7: AssertionError @@ -1319,6 +1322,7 @@ So let's just do another run: response, msg = smtp_connection.noop() assert response == 250 > assert 0 # for demo purposes + ^^^^^^^^ E assert 0 test_module.py:13: AssertionError @@ -1343,6 +1347,7 @@ So let's just do another run: response, msg = smtp_connection.noop() assert response == 250 > assert 0 # for demo purposes + ^^^^^^^^ E assert 0 test_module.py:13: AssertionError @@ -1418,7 +1423,7 @@ Running the above tests results in the following test IDs being used: rootdir: /home/sweet/project collected 12 items - + diff --git a/doc/en/how-to/output.rst b/doc/en/how-to/output.rst index cb9276c7ea0..bc98b816484 100644 --- a/doc/en/how-to/output.rst +++ b/doc/en/how-to/output.rst @@ -447,7 +447,7 @@ Example: ================================= XPASSES ================================== ========================= short test summary info ========================== SKIPPED [1] test_example.py:22: skipping this test - XFAIL test_example.py::test_xfail - reason: xfailing this test + XFAIL test_example.py::test_xfail - xfailing this test XPASS test_example.py::test_xpass - always xfail ERROR test_example.py::test_error - assert 0 FAILED test_example.py::test_fail - assert 0 diff --git a/doc/en/how-to/parametrize.rst b/doc/en/how-to/parametrize.rst index 5a16684eb96..d7c12c1a1f4 100644 --- a/doc/en/how-to/parametrize.rst +++ b/doc/en/how-to/parametrize.rst @@ -281,7 +281,7 @@ list: $ pytest -q -rs test_strings.py s [100%] ========================= short test summary info ========================== - SKIPPED [1] test_strings.py: got empty parameter set ['stringinput'], function test_valid_string at /home/sweet/project/test_strings.py:2 + SKIPPED [1] test_strings.py: got empty parameter set for (stringinput) 1 skipped in 0.12s Note that when calling ``metafunc.parametrize`` multiple times with different parameter sets, all parameter names across diff --git a/doc/en/how-to/unittest.rst b/doc/en/how-to/unittest.rst index 62e32b6d28f..ba98b366d04 100644 --- a/doc/en/how-to/unittest.rst +++ b/doc/en/how-to/unittest.rst @@ -154,6 +154,7 @@ the ``self.db`` values in the traceback: def test_method1(self): assert hasattr(self, "db") > assert 0, self.db # fail for demo purposes + ^^^^^^^^^^^^^^^^^ E AssertionError: .DummyDB object at 0xdeadbeef0001> E assert 0 @@ -164,6 +165,7 @@ the ``self.db`` values in the traceback: def test_method2(self): > assert 0, self.db # fail for demo purposes + ^^^^^^^^^^^^^^^^^ E AssertionError: .DummyDB object at 0xdeadbeef0001> E assert 0 diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index d3dd14a8681..b0535ef6589 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -2093,6 +2093,12 @@ All the command-line flags can be obtained by running ``pytest --help``:: example: -m 'mark1 and not mark2'. --markers show markers (builtin, plugin and per-project ones). -x, --exitfirst Exit instantly on first error or failed test + --maxfail=num Exit after first num failures or errors + --strict-config Any warnings encountered while parsing the `pytest` + section of the configuration file raise errors + --strict-markers Markers not registered in the `markers` section of + the configuration file raise errors + --strict (Deprecated) alias to --strict-markers --fixtures, --funcargs Show available fixtures, sorted by plugin appearance (fixtures with leading '_' are only shown with '-v') @@ -2131,15 +2137,21 @@ All the command-line flags can be obtained by running ``pytest --help``:: --sw-skip, --stepwise-skip Ignore the first failing test but stop on the next failing test. Implicitly enables --stepwise. + --sw-reset, --stepwise-reset + Resets stepwise state, restarting the stepwise + workflow. Implicitly enables --stepwise. Reporting: --durations=N Show N slowest setup/test durations (N=0 for all) --durations-min=N Minimal duration in seconds for inclusion in slowest - list. Default: 0.005. + list. Default: 0.005 (or 0.0 if -vv is given). -v, --verbose Increase verbosity --no-header Disable header --no-summary Disable summary --no-fold-skipped Do not fold skipped tests in short summary. + --force-short-summary + Force condensed summary output regardless of + verbosity level. -q, --quiet Decrease verbosity --verbosity=VERBOSE Set verbosity. Default: 0. -r chars Show extra test summary info as specified by chars: @@ -2174,22 +2186,6 @@ All the command-line flags can be obtained by running ``pytest --help``:: -W, --pythonwarnings PYTHONWARNINGS Set which warnings to report, see -W option of Python itself - --maxfail=num Exit after first num failures or errors - --strict-config Any warnings encountered while parsing the `pytest` - section of the configuration file raise errors - --strict-markers Markers not registered in the `markers` section of - the configuration file raise errors - --strict (Deprecated) alias to --strict-markers - -c, --config-file FILE - Load configuration from `FILE` instead of trying to - locate one of the implicit configuration files. - --continue-on-collection-errors - Force test execution even if collection errors occur - --rootdir=ROOTDIR Define root directory for tests. Can be relative - path: 'root_dir', './root_dir', - 'root_dir/another_dir/'; absolute path: - '/home/user/root_dir'; path with variables: - '$HOME/root_dir'. collection: --collect-only, --co Only collect tests, don't execute them @@ -2205,6 +2201,8 @@ All the command-line flags can be obtained by running ``pytest --help``:: --keep-duplicates Keep duplicate tests --collect-in-virtualenv Don't ignore tests in a local virtualenv directory + --continue-on-collection-errors + Force test execution even if collection errors occur --import-mode={prepend,append,importlib} Prepend/append to sys.path when importing test modules and conftest files. Default: prepend. @@ -2220,6 +2218,14 @@ All the command-line flags can be obtained by running ``pytest --help``:: failure test session debugging and configuration: + -c, --config-file FILE + Load configuration from `FILE` instead of trying to + locate one of the implicit configuration files. + --rootdir=ROOTDIR Define root directory for tests. Can be relative + path: 'root_dir', './root_dir', + 'root_dir/another_dir/'; absolute path: + '/home/user/root_dir'; path with variables: + '$HOME/root_dir'. --basetemp=dir Base temporary directory for this test run. (Warning: this directory is removed if it exists.) -V, --version Display pytest version and information about @@ -2228,7 +2234,13 @@ All the command-line flags can be obtained by running ``pytest --help``:: -h, --help Show help message and configuration info -p name Early-load given plugin module name or entry point (multi-allowed). To avoid loading of plugins, use - the `no:` prefix, e.g. `no:doctest`. + the `no:` prefix, e.g. `no:doctest`. See also + --disable-plugin-autoload. + --disable-plugin-autoload + Disable plugin auto-loading through entry point + packaging metadata. Only plugins explicitly + specified in -p or env var PYTEST_PLUGINS will be + loaded. --trace-config Trace considerations of conftest.py files --debug=[DEBUG_FILE_NAME] Store internal tracing debug information in this log @@ -2283,13 +2295,16 @@ All the command-line flags can be obtained by running ``pytest --help``:: markers (linelist): Register new markers for test functions empty_parameter_set_mark (string): Default marker for empty parametersets - norecursedirs (args): Directory patterns to avoid for recursion - testpaths (args): Directories to search for tests when no files or - directories are given on the command line filterwarnings (linelist): Each line specifies a pattern for warnings.filterwarnings. Processed after -W/--pythonwarnings. + norecursedirs (args): Directory patterns to avoid for recursion + testpaths (args): Directories to search for tests when no files or + directories are given on the command line + collect_imported_tests (bool): + Whether to collect tests in imported modules outside + `testpaths` consider_namespace_packages (bool): Consider namespace packages when resolving module names during import @@ -2329,6 +2344,12 @@ All the command-line flags can be obtained by running ``pytest --help``:: enable_assertion_pass_hook (bool): Enables the pytest_assertion_pass hook. Make sure to delete any previously generated pyc cache files. + truncation_limit_lines (string): + Set threshold of LINES after which truncation will + take effect + truncation_limit_chars (string): + Set threshold of CHARS after which truncation will + take effect verbosity_assertions (string): Specify a verbosity level for assertions, overriding the main level. Higher levels will provide more @@ -2373,12 +2394,12 @@ All the command-line flags can be obtained by running ``pytest --help``:: Default value for --log-file-date-format log_auto_indent (string): Default value for --log-auto-indent - pythonpath (paths): Add paths to sys.path faulthandler_timeout (string): Dump the traceback of all threads if a test takes more than TIMEOUT seconds to finish addopts (args): Extra command line options minversion (string): Minimally required pytest version + pythonpath (paths): Add paths to sys.path required_plugins (args): Plugins that must be present for pytest to run From cc5ceed916d0c63696da33c67e035917194a4e87 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 2 Jun 2025 19:58:49 +0000 Subject: [PATCH 436/445] RELEASING: remove pytest mailing list (#13472) (#13473) It is no longer. (cherry picked from commit 80dfa2db8e6157bf706c2f2656ba0fd7bc13195a) Co-authored-by: Ran Benita --- RELEASING.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/RELEASING.rst b/RELEASING.rst index 0ca63ee4fbf..76c41d83a58 100644 --- a/RELEASING.rst +++ b/RELEASING.rst @@ -168,7 +168,6 @@ Both automatic and manual processes described above follow the same steps from t To the following mailing lists: - * pytest-dev@python.org (all releases) * python-announce-list@python.org (all releases) * testing-in-python@lists.idyll.org (only major/minor releases) From b49745ec529f06edfbbe531b766839763b2be3c2 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 3 Jun 2025 19:25:38 -0300 Subject: [PATCH 437/445] fix: support TerminalReporter.isatty being called (#13462) (#13483) Fixes #13461. (cherry picked from commit cba5c4a98f65fdcfa484749bc06bcde1fb0865bc) Co-authored-by: Martin Fischer --- changelog/13461.bugfix.rst | 3 +++ src/_pytest/compat.py | 20 ++++++++++++++++++++ src/_pytest/terminal.py | 11 +++++++---- testing/test_terminal.py | 10 ++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 changelog/13461.bugfix.rst diff --git a/changelog/13461.bugfix.rst b/changelog/13461.bugfix.rst new file mode 100644 index 00000000000..4b45f7cc9da --- /dev/null +++ b/changelog/13461.bugfix.rst @@ -0,0 +1,3 @@ +Corrected ``_pytest.terminal.TerminalReporter.isatty`` to support +being called as a method. Before it was just a boolean which could +break correct code when using ``-o log_cli=true``). diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index f113a2197f3..7d71838be51 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -300,3 +300,23 @@ def get_user_id() -> int | None: # This also work for Enums (if you use `is` to compare) and Literals. def assert_never(value: NoReturn) -> NoReturn: assert False, f"Unhandled value: {value} ({type(value).__name__})" + + +class CallableBool: + """ + A bool-like object that can also be called, returning its true/false value. + + Used for backwards compatibility in cases where something was supposed to be a method + but was implemented as a simple attribute by mistake (see `TerminalReporter.isatty`). + + Do not use in new code. + """ + + def __init__(self, value: bool) -> None: + self._value = value + + def __bool__(self) -> bool: + return self._value + + def __call__(self) -> bool: + return self._value diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index d5ccc4e4900..5f27c46b41e 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -31,6 +31,7 @@ import pluggy +from _pytest import compat from _pytest import nodes from _pytest import timing from _pytest._code import ExceptionInfo @@ -387,7 +388,9 @@ def __init__(self, config: Config, file: TextIO | None = None) -> None: self.reportchars = getreportopt(config) self.foldskipped = config.option.fold_skipped self.hasmarkup = self._tw.hasmarkup - self.isatty = file.isatty() + # isatty should be a method but was wrongly implemented as a boolean. + # We use CallableBool here to support both. + self.isatty = compat.CallableBool(file.isatty()) self._progress_nodeids_reported: set[str] = set() self._timing_nodeids_reported: set[str] = set() self._show_progress_info = self._determine_show_progress_info() @@ -766,7 +769,7 @@ def _width_of_current_line(self) -> int: return self._tw.width_of_current_line def pytest_collection(self) -> None: - if self.isatty: + if self.isatty(): if self.config.option.verbose >= 0: self.write("collecting ... ", flush=True, bold=True) elif self.config.option.verbose >= 1: @@ -779,7 +782,7 @@ def pytest_collectreport(self, report: CollectReport) -> None: self._add_stats("skipped", [report]) items = [x for x in report.result if isinstance(x, Item)] self._numcollected += len(items) - if self.isatty: + if self.isatty(): self.report_collect() def report_collect(self, final: bool = False) -> None: @@ -811,7 +814,7 @@ def report_collect(self, final: bool = False) -> None: line += f" / {skipped} skipped" if self._numcollected > selected: line += f" / {selected} selected" - if self.isatty: + if self.isatty(): self.rewrite(line, bold=True, erase=True) if final: self.write("\n") diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 86feb33b3ec..3ea10195c6b 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -442,6 +442,16 @@ def test_long_xfail(): ] ) + @pytest.mark.parametrize("isatty", [True, False]) + def test_isatty(self, pytester: Pytester, monkeypatch, isatty: bool) -> None: + config = pytester.parseconfig() + f = StringIO() + monkeypatch.setattr(f, "isatty", lambda: isatty) + tr = TerminalReporter(config, f) + assert tr.isatty() == isatty + # It was incorrectly implemented as a boolean so we still support using it as one. + assert bool(tr.isatty) == isatty + class TestCollectonly: def test_collectonly_basic(self, pytester: Pytester) -> None: From 4e631a71484c2fa49e3fd9f884546af411a4888d Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 3 Jun 2025 22:53:48 +0000 Subject: [PATCH 438/445] Merge pull request #13486 from hosmir/fixtypo (#13487) Fix typo in docs regarding capsys/capteesys (cherry picked from commit 8f93ae9f38b2b1d6fd2d602e099d8907f34cf0a0) Co-authored-by: John Litborn <11260241+jakkdl@users.noreply.github.com> --- doc/en/builtin.rst | 2 +- src/_pytest/capture.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/en/builtin.rst b/doc/en/builtin.rst index b129d0a763f..31c2fa9df06 100644 --- a/doc/en/builtin.rst +++ b/doc/en/builtin.rst @@ -69,7 +69,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a .. code-block:: python - def test_output(capsys): + def test_output(capteesys): print("hello") captured = capteesys.readouterr() assert captured.out == "hello\n" diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index 3812d88176a..6d98676be5f 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -1043,7 +1043,7 @@ def capteesys(request: SubRequest) -> Generator[CaptureFixture[str]]: .. code-block:: python - def test_output(capsys): + def test_output(capteesys): print("hello") captured = capteesys.readouterr() assert captured.out == "hello\n" From 1a0581b0227fa07afd1f2c4c6215aec3862cf1ab Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 6 Jun 2025 13:50:26 +0000 Subject: [PATCH 439/445] Remove outdated warning about faulthandler_timeout on Windows (#13492) (#13493) --------- (cherry picked from commit 216c7ec882b2aa30fb8a35e100c990c34fca12c1) Co-authored-by: Iwithyou2025 Co-authored-by: Bruno Oliveira --- changelog/13492.doc.rst | 1 + doc/en/how-to/failures.rst | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog/13492.doc.rst diff --git a/changelog/13492.doc.rst b/changelog/13492.doc.rst new file mode 100644 index 00000000000..6e3f72a860e --- /dev/null +++ b/changelog/13492.doc.rst @@ -0,0 +1 @@ +Fixed outdated warning about ``faulthandler`` not working on Windows. diff --git a/doc/en/how-to/failures.rst b/doc/en/how-to/failures.rst index b3d0c155b48..0c45cd7b118 100644 --- a/doc/en/how-to/failures.rst +++ b/doc/en/how-to/failures.rst @@ -112,7 +112,7 @@ on the command-line. Also the :confval:`faulthandler_timeout=X` configuration option can be used to dump the traceback of all threads if a test takes longer than ``X`` -seconds to finish (not available on Windows). +seconds to finish. .. note:: From a86ee09291f913b36fdeec14c42356515b91c979 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sat, 14 Jun 2025 21:51:35 -0300 Subject: [PATCH 440/445] Fix typo in parametrize.rst (#13514) (#13516) (cherry picked from commit 64c1173df4f897a8880a25a29eff67d45dbc41b2) Co-authored-by: SarahPythonista <4283226+SarahPythonista@users.noreply.github.com> --- doc/en/example/parametrize.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index c3848db5112..a7ec55dff0a 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -352,7 +352,7 @@ The first invocation with ``db == "DB1"`` passed while the second with ``db == " Indirect parametrization --------------------------------------------------- -Using the ``indirect=True`` parameter when parametrizing a test allows to +Using the ``indirect=True`` parameter when parametrizing a test allows one to parametrize a test with a fixture receiving the values before passing them to a test: From 4c161aba8ecaab9940040702369025595d26564c Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 18:52:02 -0300 Subject: [PATCH 441/445] pytester: avoid unraisableexception gc collects in inline runs to speed up test suite (#13525) (#13526) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because `pytester.runpytest()` executes the full session cycle (including `pytest_unconfigure`), it was calling `gc.collect()` in a loop multiple times—even for small, fast tests. This significantly increased the total test suite runtime. To optimize performance, disable the gc runs in inline pytester runs entirely, matching the behavior before #12958. Locally the test suite runtime improved dramatically, dropping from 425s to 160s. Fixes #13482. (cherry picked from commit 391324e13a6589f5d824d053240d4b9a4139a115) Co-authored-by: Ran Benita Co-authored-by: Bruno Oliveira --- src/_pytest/pytester.py | 10 ++++-- src/_pytest/unraisableexception.py | 15 ++++++--- testing/test_config.py | 3 +- testing/test_unraisableexception.py | 51 +++++++++++++---------------- 4 files changed, 43 insertions(+), 36 deletions(-) diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 38f4643bd8b..59d2b0befe9 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -1092,6 +1092,8 @@ def inline_run( Typically we reraise keyboard interrupts from the child run. If True, the KeyboardInterrupt exception is captured. """ + from _pytest.unraisableexception import gc_collect_iterations_key + # (maybe a cpython bug?) the importlib cache sometimes isn't updated # properly between file creation and inline_run (especially if imports # are interspersed with file creation) @@ -1115,12 +1117,16 @@ def inline_run( rec = [] - class Collect: + class PytesterHelperPlugin: @staticmethod def pytest_configure(config: Config) -> None: rec.append(self.make_hook_recorder(config.pluginmanager)) - plugins.append(Collect()) + # The unraisable plugin GC collect slows down inline + # pytester runs too much. + config.stash[gc_collect_iterations_key] = 0 + + plugins.append(PytesterHelperPlugin()) ret = main([str(x) for x in args], plugins=plugins) if len(rec) == 1: reprec = rec.pop() diff --git a/src/_pytest/unraisableexception.py b/src/_pytest/unraisableexception.py index 7826aeccd12..0faca36aa00 100644 --- a/src/_pytest/unraisableexception.py +++ b/src/_pytest/unraisableexception.py @@ -24,10 +24,12 @@ from exceptiongroup import ExceptionGroup -def gc_collect_harder() -> None: - # A single collection doesn't necessarily collect everything. - # Constant determined experimentally by the Trio project. - for _ in range(5): +# This is a stash item and not a simple constant to allow pytester to override it. +gc_collect_iterations_key = StashKey[int]() + + +def gc_collect_harder(iterations: int) -> None: + for _ in range(iterations): gc.collect() @@ -84,9 +86,12 @@ def collect_unraisable(config: Config) -> None: def cleanup( *, config: Config, prev_hook: Callable[[sys.UnraisableHookArgs], object] ) -> None: + # A single collection doesn't necessarily collect everything. + # Constant determined experimentally by the Trio project. + gc_collect_iterations = config.stash.get(gc_collect_iterations_key, 5) try: try: - gc_collect_harder() + gc_collect_harder(gc_collect_iterations) collect_unraisable(config) finally: sys.unraisablehook = prev_hook diff --git a/testing/test_config.py b/testing/test_config.py index bb08c40fef4..3e8635fd1fc 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -2175,7 +2175,8 @@ class DummyPlugin: plugins = config.invocation_params.plugins assert len(plugins) == 2 assert plugins[0] is plugin - assert type(plugins[1]).__name__ == "Collect" # installed by pytester.inline_run() + # Installed by pytester.inline_run(). + assert type(plugins[1]).__name__ == "PytesterHelperPlugin" # args cannot be None with pytest.raises(TypeError): diff --git a/testing/test_unraisableexception.py b/testing/test_unraisableexception.py index 6c0dc542e93..a6a4d6f35e8 100644 --- a/testing/test_unraisableexception.py +++ b/testing/test_unraisableexception.py @@ -1,7 +1,5 @@ from __future__ import annotations -from collections.abc import Generator -import contextlib import gc import sys from unittest import mock @@ -229,19 +227,13 @@ def _set_gc_state(enabled: bool) -> bool: return was_enabled -@contextlib.contextmanager -def _disable_gc() -> Generator[None]: - was_enabled = _set_gc_state(enabled=False) - try: - yield - finally: - _set_gc_state(enabled=was_enabled) - - def test_refcycle_unraisable(pytester: Pytester) -> None: # see: https://github.com/pytest-dev/pytest/issues/10404 pytester.makepyfile( test_it=""" + # Should catch the unraisable exception even if gc is disabled. + import gc; gc.disable() + import pytest class BrokenDel: @@ -256,23 +248,22 @@ def test_it(): """ ) - with _disable_gc(): - result = pytester.runpytest() + result = pytester.runpytest_subprocess( + "-Wdefault::pytest.PytestUnraisableExceptionWarning" + ) - # TODO: should be a test failure or error - assert result.ret == pytest.ExitCode.INTERNAL_ERROR + assert result.ret == 0 result.assert_outcomes(passed=1) result.stderr.fnmatch_lines("ValueError: del is broken") -@pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning") def test_refcycle_unraisable_warning_filter(pytester: Pytester) -> None: - # note that the host pytest warning filter is disabled and the pytester - # warning filter applies during config teardown of unraisablehook. - # see: https://github.com/pytest-dev/pytest/issues/10404 pytester.makepyfile( test_it=""" + # Should catch the unraisable exception even if gc is disabled. + import gc; gc.disable() + import pytest class BrokenDel: @@ -287,17 +278,18 @@ def test_it(): """ ) - with _disable_gc(): - result = pytester.runpytest("-Werror") + result = pytester.runpytest_subprocess( + "-Werror::pytest.PytestUnraisableExceptionWarning" + ) - # TODO: should be a test failure or error - assert result.ret == pytest.ExitCode.INTERNAL_ERROR + # TODO: Should be a test failure or error. Currently the exception + # propagates all the way to the top resulting in exit code 1. + assert result.ret == 1 result.assert_outcomes(passed=1) result.stderr.fnmatch_lines("ValueError: del is broken") -@pytest.mark.filterwarnings("default::pytest.PytestUnraisableExceptionWarning") def test_create_task_raises_unraisable_warning_filter(pytester: Pytester) -> None: # note that the host pytest warning filter is disabled and the pytester # warning filter applies during config teardown of unraisablehook. @@ -306,6 +298,9 @@ def test_create_task_raises_unraisable_warning_filter(pytester: Pytester) -> Non # the issue pytester.makepyfile( test_it=""" + # Should catch the unraisable exception even if gc is disabled. + import gc; gc.disable() + import asyncio import pytest @@ -318,11 +313,11 @@ def test_scheduler_must_be_created_within_running_loop() -> None: """ ) - with _disable_gc(): - result = pytester.runpytest("-Werror") + result = pytester.runpytest_subprocess("-Werror") - # TODO: should be a test failure or error - assert result.ret == pytest.ExitCode.INTERNAL_ERROR + # TODO: Should be a test failure or error. Currently the exception + # propagates all the way to the top resulting in exit code 1. + assert result.ret == 1 result.assert_outcomes(passed=1) result.stderr.fnmatch_lines("RuntimeWarning: coroutine 'my_task' was never awaited") From a1b3a7879589eb437e4fd97c169b228c3ed58c63 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 18:11:56 -0300 Subject: [PATCH 442/445] Fix compatibility with Twisted 25 (#13502) (#13531) As discussed in https://github.com/pytest-dev/pytest/pull/13502, the fix for compatibility with Twisted 25+ is simpler. Therefore, it makes sense to implement both fixes (for Twisted 24 and Twisted 25) in parallel. This way, we can eventually drop support for Twisted <25 and keep only the simpler workaround. In addition, the `unittestextras` tox environment has been replaced with dedicated test environments for `asynctest`, `Twisted 24`, and `Twisted 25`. Fixes #13497 (cherry picked from commit 01dce85a89eb0b3e881303784267f14b94d9691f) Co-authored-by: Bruno Oliveira --- .github/workflows/test.yml | 43 +++++++++- changelog/13497.bugfix.rst | 1 + src/_pytest/unittest.py | 155 ++++++++++++++++++++++++++++--------- tox.ini | 19 +++-- 4 files changed, 174 insertions(+), 44 deletions(-) create mode 100644 changelog/13497.bugfix.rst diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3ecc133878f..7873b66a49a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,7 +54,9 @@ jobs: fail-fast: false matrix: name: [ - "windows-py39-unittestextras", + "windows-py39-unittest-asynctest", + "windows-py39-unittest-twisted24", + "windows-py39-unittest-twisted25", "windows-py39-pluggy", "windows-py39-xdist", "windows-py310", @@ -63,6 +65,9 @@ jobs: "windows-py313", "windows-py314", + "ubuntu-py39-unittest-asynctest", + "ubuntu-py39-unittest-twisted24", + "ubuntu-py39-unittest-twisted25", "ubuntu-py39-lsof-numpy-pexpect", "ubuntu-py39-pluggy", "ubuntu-py39-freeze", @@ -85,10 +90,23 @@ jobs: ] include: - - name: "windows-py39-unittestextras" + # Use separate jobs for different unittest flavors (twisted, asynctest) to ensure proper coverage. + - name: "windows-py39-unittest-asynctest" python: "3.9" os: windows-latest - tox_env: "py39-unittestextras" + tox_env: "py39-asynctest" + use_coverage: true + + - name: "windows-py39-unittest-twisted24" + python: "3.9" + os: windows-latest + tox_env: "py39-twisted24" + use_coverage: true + + - name: "windows-py39-unittest-twisted25" + python: "3.9" + os: windows-latest + tox_env: "py39-twisted25" use_coverage: true - name: "windows-py39-pluggy" @@ -126,6 +144,25 @@ jobs: os: windows-latest tox_env: "py314" + # Use separate jobs for different unittest flavors (twisted, asynctest) to ensure proper coverage. + - name: "ubuntu-py39-unittest-asynctest" + python: "3.9" + os: ubuntu-latest + tox_env: "py39-asynctest" + use_coverage: true + + - name: "ubuntu-py39-unittest-twisted24" + python: "3.9" + os: ubuntu-latest + tox_env: "py39-twisted24" + use_coverage: true + + - name: "ubuntu-py39-unittest-twisted25" + python: "3.9" + os: ubuntu-latest + tox_env: "py39-twisted25" + use_coverage: true + - name: "ubuntu-py39-lsof-numpy-pexpect" python: "3.9" os: ubuntu-latest diff --git a/changelog/13497.bugfix.rst b/changelog/13497.bugfix.rst new file mode 100644 index 00000000000..75b4996e5af --- /dev/null +++ b/changelog/13497.bugfix.rst @@ -0,0 +1 @@ +Fixed compatibility with ``Twisted 25+``. diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py index 04d50b53090..ef6ef64a062 100644 --- a/src/_pytest/unittest.py +++ b/src/_pytest/unittest.py @@ -6,11 +6,13 @@ from collections.abc import Callable from collections.abc import Generator from collections.abc import Iterable +from collections.abc import Iterator +from enum import auto +from enum import Enum import inspect import sys import traceback import types -from typing import Any from typing import TYPE_CHECKING from typing import Union @@ -18,6 +20,7 @@ from _pytest.compat import is_async_function from _pytest.config import hookimpl from _pytest.fixtures import FixtureRequest +from _pytest.monkeypatch import MonkeyPatch from _pytest.nodes import Collector from _pytest.nodes import Item from _pytest.outcomes import exit @@ -228,8 +231,7 @@ def startTest(self, testcase: unittest.TestCase) -> None: pass def _addexcinfo(self, rawexcinfo: _SysExcInfoType) -> None: - # Unwrap potential exception info (see twisted trial support below). - rawexcinfo = getattr(rawexcinfo, "_rawexcinfo", rawexcinfo) + rawexcinfo = _handle_twisted_exc_info(rawexcinfo) try: excinfo = _pytest._code.ExceptionInfo[BaseException].from_exc_info( rawexcinfo # type: ignore[arg-type] @@ -385,49 +387,130 @@ def pytest_runtest_makereport(item: Item, call: CallInfo[None]) -> None: call.excinfo = call2.excinfo -# Twisted trial support. -classImplements_has_run = False +def _is_skipped(obj) -> bool: + """Return True if the given object has been marked with @unittest.skip.""" + return bool(getattr(obj, "__unittest_skip__", False)) + + +def pytest_configure() -> None: + """Register the TestCaseFunction class as an IReporter if twisted.trial is available.""" + if _get_twisted_version() is not TwistedVersion.NotInstalled: + from twisted.trial.itrial import IReporter + from zope.interface import classImplements + + classImplements(TestCaseFunction, IReporter) + + +class TwistedVersion(Enum): + """ + The Twisted version installed in the environment. + + We have different workarounds in place for different versions of Twisted. + """ + + # Twisted version 24 or prior. + Version24 = auto() + # Twisted version 25 or later. + Version25 = auto() + # Twisted version is not available. + NotInstalled = auto() + + +def _get_twisted_version() -> TwistedVersion: + # We need to check if "twisted.trial.unittest" is specifically present in sys.modules. + # This is because we intend to integrate with Trial only when it's actively running + # the test suite, but not needed when only other Twisted components are in use. + if "twisted.trial.unittest" not in sys.modules: + return TwistedVersion.NotInstalled + + import importlib.metadata + + import packaging.version + + version_str = importlib.metadata.version("twisted") + version = packaging.version.parse(version_str) + if version.major <= 24: + return TwistedVersion.Version24 + else: + return TwistedVersion.Version25 + + +# Name of the attribute in `twisted.python.Failure` instances that stores +# the `sys.exc_info()` tuple. +# See twisted.trial support in `pytest_runtest_protocol`. +TWISTED_RAW_EXCINFO_ATTR = "_twisted_raw_excinfo" @hookimpl(wrapper=True) -def pytest_runtest_protocol(item: Item) -> Generator[None, object, object]: - if isinstance(item, TestCaseFunction) and "twisted.trial.unittest" in sys.modules: - ut: Any = sys.modules["twisted.python.failure"] - global classImplements_has_run - Failure__init__ = ut.Failure.__init__ - if not classImplements_has_run: - from twisted.trial.itrial import IReporter - from zope.interface import classImplements - - classImplements(TestCaseFunction, IReporter) - classImplements_has_run = True - - def excstore( +def pytest_runtest_protocol(item: Item) -> Iterator[None]: + if _get_twisted_version() is TwistedVersion.Version24: + import twisted.python.failure as ut + + # Monkeypatch `Failure.__init__` to store the raw exception info. + original__init__ = ut.Failure.__init__ + + def store_raw_exception_info( self, exc_value=None, exc_type=None, exc_tb=None, captureVars=None - ): + ): # pragma: no cover if exc_value is None: - self._rawexcinfo = sys.exc_info() + raw_exc_info = sys.exc_info() else: if exc_type is None: exc_type = type(exc_value) - self._rawexcinfo = (exc_type, exc_value, exc_tb) + if exc_tb is None: + exc_tb = sys.exc_info()[2] + raw_exc_info = (exc_type, exc_value, exc_tb) + setattr(self, TWISTED_RAW_EXCINFO_ATTR, tuple(raw_exc_info)) try: - Failure__init__( + original__init__( self, exc_value, exc_type, exc_tb, captureVars=captureVars ) - except TypeError: - Failure__init__(self, exc_value, exc_type, exc_tb) + except TypeError: # pragma: no cover + original__init__(self, exc_value, exc_type, exc_tb) - ut.Failure.__init__ = excstore - try: - res = yield - finally: - ut.Failure.__init__ = Failure__init__ + with MonkeyPatch.context() as patcher: + patcher.setattr(ut.Failure, "__init__", store_raw_exception_info) + return (yield) else: - res = yield - return res - - -def _is_skipped(obj) -> bool: - """Return True if the given object has been marked with @unittest.skip.""" - return bool(getattr(obj, "__unittest_skip__", False)) + return (yield) + + +def _handle_twisted_exc_info( + rawexcinfo: _SysExcInfoType | BaseException, +) -> _SysExcInfoType: + """ + Twisted passes a custom Failure instance to `addError()` instead of using `sys.exc_info()`. + Therefore, if `rawexcinfo` is a `Failure` instance, convert it into the equivalent `sys.exc_info()` tuple + as expected by pytest. + """ + twisted_version = _get_twisted_version() + if twisted_version is TwistedVersion.NotInstalled: + # Unfortunately, because we cannot import `twisted.python.failure` at the top of the file + # and use it in the signature, we need to use `type:ignore` here because we cannot narrow + # the type properly in the `if` statement above. + return rawexcinfo # type:ignore[return-value] + elif twisted_version is TwistedVersion.Version24: + # Twisted calls addError() passing its own classes (like `twisted.python.Failure`), which violates + # the `addError()` signature, so we extract the original `sys.exc_info()` tuple which is stored + # in the object. + if hasattr(rawexcinfo, TWISTED_RAW_EXCINFO_ATTR): + saved_exc_info = getattr(rawexcinfo, TWISTED_RAW_EXCINFO_ATTR) + # Delete the attribute from the original object to avoid leaks. + delattr(rawexcinfo, TWISTED_RAW_EXCINFO_ATTR) + return saved_exc_info # type:ignore[no-any-return] + return rawexcinfo # type:ignore[return-value] + elif twisted_version is TwistedVersion.Version25: + if isinstance(rawexcinfo, BaseException): + import twisted.python.failure + + if isinstance(rawexcinfo, twisted.python.failure.Failure): + tb = rawexcinfo.__traceback__ + if tb is None: + tb = sys.exc_info()[2] + return type(rawexcinfo.value), rawexcinfo.value, tb + + return rawexcinfo # type:ignore[return-value] + else: + # Ideally we would use assert_never() here, but it is not available in all Python versions + # we support, plus we do not require `type_extensions` currently. + assert False, f"Unexpected Twisted version: {twisted_version}" diff --git a/tox.ini b/tox.ini index 8f7d8495285..f1283aa8260 100644 --- a/tox.ini +++ b/tox.ini @@ -11,7 +11,7 @@ envlist = py313 py314 pypy3 - py39-{pexpect,xdist,unittestextras,numpy,pluggymain,pylib} + py39-{pexpect,xdist,twisted24,twisted25,asynctest,numpy,pluggymain,pylib} doctesting doctesting-coverage plugins @@ -36,7 +36,9 @@ description = pexpect: against `pexpect` pluggymain: against the bleeding edge `pluggy` from Git pylib: against `py` lib - unittestextras: against the unit test extras + twisted24: against the unit test extras with twisted prior to 24.0 + twisted25: against the unit test extras with twisted 25.0 or later + asynctest: against the unit test extras with asynctest xdist: with pytest in parallel mode under `{basepython}` doctesting: including doctests @@ -51,7 +53,7 @@ passenv = TERM SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST setenv = - _PYTEST_TOX_DEFAULT_POSARGS={env:_PYTEST_TOX_POSARGS_DOCTESTING:} {env:_PYTEST_TOX_POSARGS_LSOF:} {env:_PYTEST_TOX_POSARGS_XDIST:} + _PYTEST_TOX_DEFAULT_POSARGS={env:_PYTEST_TOX_POSARGS_DOCTESTING:} {env:_PYTEST_TOX_POSARGS_LSOF:} {env:_PYTEST_TOX_POSARGS_XDIST:} {env:_PYTEST_FILES:} # See https://docs.python.org/3/library/io.html#io-encoding-warning # If we don't enable this, neither can any of our downstream users! @@ -66,6 +68,12 @@ setenv = doctesting: _PYTEST_TOX_POSARGS_DOCTESTING=doc/en + # The configurations below are related only to standard unittest support. + # Run only tests from test_unittest.py. + asynctest: _PYTEST_FILES=testing/test_unittest.py + twisted24: _PYTEST_FILES=testing/test_unittest.py + twisted25: _PYTEST_FILES=testing/test_unittest.py + nobyte: PYTHONDONTWRITEBYTECODE=1 lsof: _PYTEST_TOX_POSARGS_LSOF=--lsof @@ -79,8 +87,9 @@ deps = pexpect: pexpect>=4.8.0 pluggymain: pluggy @ git+https://github.com/pytest-dev/pluggy.git pylib: py>=1.8.2 - unittestextras: twisted - unittestextras: asynctest + twisted24: twisted<25 + twisted25: twisted>=25 + asynctest: asynctest xdist: pytest-xdist>=2.1.0 xdist: -e . {env:_PYTEST_TOX_EXTRA_DEP:} From d0c7ed0bfae5a5f1f9153cd1e464a421d701e925 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 21:35:14 +0000 Subject: [PATCH 443/445] Reintroduce PytestReturnNotNoneWarning (#13495) (#13527) Since this warning is meant to be permanent, added proper documentation to the `assert` section in the docs. Fixes #13477 (cherry picked from commit 53f05c44d9530c4ac5ce5804ef75fe61713d46d8) Co-authored-by: Bruno Oliveira --- changelog/13477.bugfix.rst | 5 ++++ doc/en/deprecations.rst | 40 ------------------------------- doc/en/how-to/assert.rst | 44 ++++++++++++++++++++++++++++++++++ doc/en/reference/reference.rst | 3 +++ src/_pytest/python.py | 13 +++++----- src/_pytest/warning_types.py | 11 +++++++++ src/pytest/__init__.py | 2 ++ testing/acceptance_test.py | 4 ++-- 8 files changed, 74 insertions(+), 48 deletions(-) create mode 100644 changelog/13477.bugfix.rst diff --git a/changelog/13477.bugfix.rst b/changelog/13477.bugfix.rst new file mode 100644 index 00000000000..7b7f875df09 --- /dev/null +++ b/changelog/13477.bugfix.rst @@ -0,0 +1,5 @@ +Reintroduced :class:`pytest.PytestReturnNotNoneWarning` which was removed by accident in pytest `8.4`. + +This warning is raised when a test functions returns a value other than ``None``, which is often a mistake made by beginners. + +See :ref:`return-not-none` for more information. diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index 18df64c9204..6897fb28fc1 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -316,46 +316,6 @@ Users expected in this case that the ``usefixtures`` mark would have its intende Now pytest will issue a warning when it encounters this problem, and will raise an error in the future versions. -Returning non-None value in test functions -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. deprecated:: 7.2 - -A ``pytest.PytestReturnNotNoneWarning`` is now emitted if a test function returns something other than `None`. - -This prevents a common mistake among beginners that expect that returning a `bool` would cause a test to pass or fail, for example: - -.. code-block:: python - - @pytest.mark.parametrize( - ["a", "b", "result"], - [ - [1, 2, 5], - [2, 3, 8], - [5, 3, 18], - ], - ) - def test_foo(a, b, result): - return foo(a, b) == result - -Given that pytest ignores the return value, this might be surprising that it will never fail. - -The proper fix is to change the `return` to an `assert`: - -.. code-block:: python - - @pytest.mark.parametrize( - ["a", "b", "result"], - [ - [1, 2, 5], - [2, 3, 8], - [5, 3, 18], - ], - ) - def test_foo(a, b, result): - assert foo(a, b) == result - - The ``yield_fixture`` function/decorator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/en/how-to/assert.rst b/doc/en/how-to/assert.rst index 6bc8f6fed33..c83fb93c4b1 100644 --- a/doc/en/how-to/assert.rst +++ b/doc/en/how-to/assert.rst @@ -476,6 +476,50 @@ the conftest file: FAILED test_foocompare.py::test_compare - assert Comparing Foo instances: 1 failed in 0.12s +.. _`return-not-none`: + +Returning non-None value in test functions +------------------------------------------ + +A :class:`pytest.PytestReturnNotNoneWarning` is emitted when a test function returns a value other than ``None``. + +This helps prevent a common mistake made by beginners who assume that returning a ``bool`` (e.g., ``True`` or ``False``) will determine whether a test passes or fails. + +Example: + +.. code-block:: python + + @pytest.mark.parametrize( + ["a", "b", "result"], + [ + [1, 2, 5], + [2, 3, 8], + [5, 3, 18], + ], + ) + def test_foo(a, b, result): + return foo(a, b) == result # Incorrect usage, do not do this. + +Since pytest ignores return values, it might be surprising that the test will never fail based on the returned value. + +The correct fix is to replace the ``return`` statement with an ``assert``: + +.. code-block:: python + + @pytest.mark.parametrize( + ["a", "b", "result"], + [ + [1, 2, 5], + [2, 3, 8], + [5, 3, 18], + ], + ) + def test_foo(a, b, result): + assert foo(a, b) == result + + + + .. _assert-details: .. _`assert introspection`: diff --git a/doc/en/reference/reference.rst b/doc/en/reference/reference.rst index b0535ef6589..cfdc3eb3421 100644 --- a/doc/en/reference/reference.rst +++ b/doc/en/reference/reference.rst @@ -1274,6 +1274,9 @@ Custom warnings generated in some situations such as improper usage or deprecate .. autoclass:: pytest.PytestExperimentalApiWarning :show-inheritance: +.. autoclass:: pytest.PytestReturnNotNoneWarning + :show-inheritance: + .. autoclass:: pytest.PytestRemovedIn9Warning :show-inheritance: diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 82aab85a300..8e4fb041532 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -73,6 +73,7 @@ from _pytest.scope import Scope from _pytest.stash import StashKey from _pytest.warning_types import PytestCollectionWarning +from _pytest.warning_types import PytestReturnNotNoneWarning if TYPE_CHECKING: @@ -157,12 +158,12 @@ def pytest_pyfunc_call(pyfuncitem: Function) -> object | None: if hasattr(result, "__await__") or hasattr(result, "__aiter__"): async_fail(pyfuncitem.nodeid) elif result is not None: - fail( - ( - f"Expected None, but test returned {result!r}. " - "Did you mean to use `assert` instead of `return`?" - ), - pytrace=False, + warnings.warn( + PytestReturnNotNoneWarning( + f"Test functions should return None, but {pyfuncitem.nodeid} returned {type(result)!r}.\n" + "Did you mean to use `assert` instead of `return`?\n" + "See https://docs.pytest.org/en/stable/how-to/assert.html#return-not-none for more information." + ) ) return True diff --git a/src/_pytest/warning_types.py b/src/_pytest/warning_types.py index 8c9ff2d9a36..5e78debb682 100644 --- a/src/_pytest/warning_types.py +++ b/src/_pytest/warning_types.py @@ -71,6 +71,17 @@ def simple(cls, apiname: str) -> PytestExperimentalApiWarning: return cls(f"{apiname} is an experimental api that may change over time") +@final +class PytestReturnNotNoneWarning(PytestWarning): + """ + Warning emitted when a test function returns a value other than ``None``. + + See :ref:`return-not-none` for details. + """ + + __module__ = "pytest" + + @final class PytestUnknownMarkWarning(PytestWarning): """Warning emitted on use of unknown markers. diff --git a/src/pytest/__init__.py b/src/pytest/__init__.py index e36d3e704c1..297b524bcc2 100644 --- a/src/pytest/__init__.py +++ b/src/pytest/__init__.py @@ -82,6 +82,7 @@ from _pytest.warning_types import PytestExperimentalApiWarning from _pytest.warning_types import PytestFDWarning from _pytest.warning_types import PytestRemovedIn9Warning +from _pytest.warning_types import PytestReturnNotNoneWarning from _pytest.warning_types import PytestUnhandledThreadExceptionWarning from _pytest.warning_types import PytestUnknownMarkWarning from _pytest.warning_types import PytestUnraisableExceptionWarning @@ -132,6 +133,7 @@ "PytestFDWarning", "PytestPluginManager", "PytestRemovedIn9Warning", + "PytestReturnNotNoneWarning", "PytestUnhandledThreadExceptionWarning", "PytestUnknownMarkWarning", "PytestUnraisableExceptionWarning", diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 4948e3ff8ae..2101fe9ad76 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -1489,7 +1489,8 @@ def test_no_brokenpipeerror_message(pytester: Pytester) -> None: popen.stderr.close() -def test_function_return_non_none_error(pytester: Pytester) -> None: +@pytest.mark.filterwarnings("default") +def test_function_return_non_none_warning(pytester: Pytester) -> None: pytester.makepyfile( """ def test_stuff(): @@ -1497,7 +1498,6 @@ def test_stuff(): """ ) res = pytester.runpytest() - res.assert_outcomes(failed=1) res.stdout.fnmatch_lines(["*Did you mean to use `assert` instead of `return`?*"]) From 5dc5880715633c97310c0593f0ae356de27fa933 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 21:39:34 +0000 Subject: [PATCH 444/445] docs: update pytest.ini addopts example to use separate -p entries (#13529) (#13532) (cherry picked from commit 40a1713d42187732d0095dd1623b1424fb2bc489) Co-authored-by: Iwithyou2025 --- doc/en/how-to/plugins.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/en/how-to/plugins.rst b/doc/en/how-to/plugins.rst index fca8ab54e63..b2cb1cda5c3 100644 --- a/doc/en/how-to/plugins.rst +++ b/doc/en/how-to/plugins.rst @@ -154,7 +154,10 @@ manually specify each plugin with ``-p`` or :envvar:`PYTEST_PLUGINS`, you can us .. code-block:: ini [pytest] - addopts = --disable-plugin-autoload -p NAME,NAME2 + addopts = + --disable-plugin-autoload + -p NAME + -p NAME2 .. versionadded:: 8.4 From 8d99211f0ce3927eb7ee579f7b4f969da06dc787 Mon Sep 17 00:00:00 2001 From: pytest bot Date: Tue, 17 Jun 2025 21:56:14 +0000 Subject: [PATCH 445/445] Prepare release version 8.4.1 --- changelog/13461.bugfix.rst | 3 --- changelog/13477.bugfix.rst | 5 ----- changelog/13492.doc.rst | 1 - changelog/13497.bugfix.rst | 1 - doc/en/announce/index.rst | 1 + doc/en/announce/release-8.4.1.rst | 21 +++++++++++++++++++++ doc/en/changelog.rst | 28 ++++++++++++++++++++++++++++ doc/en/example/parametrize.rst | 6 +++--- doc/en/example/pythoncollection.rst | 4 ++-- doc/en/getting-started.rst | 2 +- doc/en/how-to/fixtures.rst | 2 +- 11 files changed, 57 insertions(+), 17 deletions(-) delete mode 100644 changelog/13461.bugfix.rst delete mode 100644 changelog/13477.bugfix.rst delete mode 100644 changelog/13492.doc.rst delete mode 100644 changelog/13497.bugfix.rst create mode 100644 doc/en/announce/release-8.4.1.rst diff --git a/changelog/13461.bugfix.rst b/changelog/13461.bugfix.rst deleted file mode 100644 index 4b45f7cc9da..00000000000 --- a/changelog/13461.bugfix.rst +++ /dev/null @@ -1,3 +0,0 @@ -Corrected ``_pytest.terminal.TerminalReporter.isatty`` to support -being called as a method. Before it was just a boolean which could -break correct code when using ``-o log_cli=true``). diff --git a/changelog/13477.bugfix.rst b/changelog/13477.bugfix.rst deleted file mode 100644 index 7b7f875df09..00000000000 --- a/changelog/13477.bugfix.rst +++ /dev/null @@ -1,5 +0,0 @@ -Reintroduced :class:`pytest.PytestReturnNotNoneWarning` which was removed by accident in pytest `8.4`. - -This warning is raised when a test functions returns a value other than ``None``, which is often a mistake made by beginners. - -See :ref:`return-not-none` for more information. diff --git a/changelog/13492.doc.rst b/changelog/13492.doc.rst deleted file mode 100644 index 6e3f72a860e..00000000000 --- a/changelog/13492.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed outdated warning about ``faulthandler`` not working on Windows. diff --git a/changelog/13497.bugfix.rst b/changelog/13497.bugfix.rst deleted file mode 100644 index 75b4996e5af..00000000000 --- a/changelog/13497.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed compatibility with ``Twisted 25+``. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index 702fd26dd0d..2ed23eb1fbb 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-8.4.1 release-8.4.0 release-8.3.5 release-8.3.4 diff --git a/doc/en/announce/release-8.4.1.rst b/doc/en/announce/release-8.4.1.rst new file mode 100644 index 00000000000..07ee26187a7 --- /dev/null +++ b/doc/en/announce/release-8.4.1.rst @@ -0,0 +1,21 @@ +pytest-8.4.1 +======================================= + +pytest 8.4.1 has just been released to PyPI. + +This is a bug-fix release, being a drop-in replacement. + +The full changelog is available at https://docs.pytest.org/en/stable/changelog.html. + +Thanks to all of the contributors to this release: + +* Bruno Oliveira +* Iwithyou2025 +* John Litborn +* Martin Fischer +* Ran Benita +* SarahPythonista + + +Happy testing, +The pytest Development Team diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index 73073ffca1c..63623de8aad 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -31,6 +31,34 @@ with advance notice in the **Deprecations** section of releases. .. towncrier release notes start +pytest 8.4.1 (2025-06-17) +========================= + +Bug fixes +--------- + +- `#13461 `_: Corrected ``_pytest.terminal.TerminalReporter.isatty`` to support + being called as a method. Before it was just a boolean which could + break correct code when using ``-o log_cli=true``). + + +- `#13477 `_: Reintroduced :class:`pytest.PytestReturnNotNoneWarning` which was removed by accident in pytest `8.4`. + + This warning is raised when a test functions returns a value other than ``None``, which is often a mistake made by beginners. + + See :ref:`return-not-none` for more information. + + +- `#13497 `_: Fixed compatibility with ``Twisted 25+``. + + + +Improved documentation +---------------------- + +- `#13492 `_: Fixed outdated warning about ``faulthandler`` not working on Windows. + + pytest 8.4.0 (2025-06-02) ========================= diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index a7ec55dff0a..8e6479254bb 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -162,7 +162,7 @@ objects, they are still using the default pytest representation: rootdir: /home/sweet/project collected 8 items - + @@ -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 - + @@ -318,7 +318,7 @@ Let's first see how it looks like at collection time: rootdir: /home/sweet/project collected 2 items - + diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 760140390cb..01a8f48fdbf 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -152,7 +152,7 @@ The test collection would look like this: configfile: pytest.ini collected 2 items - + @@ -215,7 +215,7 @@ You can always peek at the collection tree without running tests like this: configfile: pytest.ini collected 3 items - + diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index c92e97f556e..c5e9f708828 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -22,7 +22,7 @@ Install ``pytest`` .. code-block:: bash $ pytest --version - pytest 8.4.0 + pytest 8.4.1 .. _`simpletest`: diff --git a/doc/en/how-to/fixtures.rst b/doc/en/how-to/fixtures.rst index a86fd1065fd..62ace745d43 100644 --- a/doc/en/how-to/fixtures.rst +++ b/doc/en/how-to/fixtures.rst @@ -1423,7 +1423,7 @@ Running the above tests results in the following test IDs being used: rootdir: /home/sweet/project collected 12 items - +