commit
5b3867fd65
2
AUTHORS
2
AUTHORS
|
@ -135,6 +135,7 @@ Jordan Guymon
|
|||
Jordan Moldow
|
||||
Jordan Speicher
|
||||
Joseph Hunkeler
|
||||
Josh Karpel
|
||||
Joshua Bronson
|
||||
Jurko Gospodnetić
|
||||
Justyna Janczyszyn
|
||||
|
@ -264,6 +265,7 @@ Virgil Dupras
|
|||
Vitaly Lashmanov
|
||||
Vlad Dragos
|
||||
Volodymyr Piskun
|
||||
Wei Lin
|
||||
Wil Cooley
|
||||
William Lee
|
||||
Wim Glenn
|
||||
|
|
205
CHANGELOG.rst
205
CHANGELOG.rst
|
@ -18,6 +18,208 @@ with advance notice in the **Deprecations** section of releases.
|
|||
|
||||
.. towncrier release notes start
|
||||
|
||||
pytest 5.3.0 (2019-11-19)
|
||||
=========================
|
||||
|
||||
Deprecations
|
||||
------------
|
||||
|
||||
- `#6179 <https://github.com/pytest-dev/pytest/issues/6179>`_: The default value of ``junit_family`` option will change to ``xunit2`` in pytest 6.0, given
|
||||
that this is the version supported by default in modern tools that manipulate this type of file.
|
||||
|
||||
In order to smooth the transition, pytest will issue a warning in case the ``--junitxml`` option
|
||||
is given in the command line but ``junit_family`` is not explicitly configured in ``pytest.ini``.
|
||||
|
||||
For more information, `see the docs <https://docs.pytest.org/en/latest/deprecations.html#junit-family-default-value-change-to-xunit2>`__.
|
||||
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- `#4488 <https://github.com/pytest-dev/pytest/issues/4488>`_: The pytest team has created the `pytest-reportlog <https://github.com/pytest-dev/pytest-reportlog>`__
|
||||
plugin, which provides a new ``--report-log=FILE`` option that writes *report logs* into a file as the test session executes.
|
||||
|
||||
Each line of the report log contains a self contained JSON object corresponding to a testing event,
|
||||
such as a collection or a test result report. The file is guaranteed to be flushed after writing
|
||||
each line, so systems can read and process events in real-time.
|
||||
|
||||
The plugin is meant to replace the ``--resultlog`` option, which is deprecated and meant to be removed
|
||||
in a future release. If you use ``--resultlog``, please try out ``pytest-reportlog`` and
|
||||
provide feedback.
|
||||
|
||||
|
||||
- `#4730 <https://github.com/pytest-dev/pytest/issues/4730>`_: When ``sys.pycache_prefix`` (Python 3.8+) is set, it will be used by pytest to cache test files changed by the assertion rewriting mechanism.
|
||||
|
||||
This makes it easier to benefit of cached ``.pyc`` files even on file systems without permissions.
|
||||
|
||||
|
||||
- `#5515 <https://github.com/pytest-dev/pytest/issues/5515>`_: Allow selective auto-indentation of multiline log messages.
|
||||
|
||||
Adds command line option ``--log-auto-indent``, config option
|
||||
``log_auto_indent`` and support for per-entry configuration of
|
||||
indentation behavior on calls to ``logging.log()``.
|
||||
|
||||
Alters the default for auto-indention from ``on`` to ``off``. This
|
||||
restores the older behavior that existed prior to v4.6.0. This
|
||||
reversion to earlier behavior was done because it is better to
|
||||
activate new features that may lead to broken tests explicitly
|
||||
rather than implicitly.
|
||||
|
||||
|
||||
- `#5914 <https://github.com/pytest-dev/pytest/issues/5914>`_: ``pytester`` learned two new functions, `no_fnmatch_line <https://docs.pytest.org/en/latest/reference.html#_pytest.pytester.LineMatcher.no_fnmatch_line>`_ and
|
||||
`no_re_match_line <https://docs.pytest.org/en/latest/reference.html#_pytest.pytester.LineMatcher.no_re_match_line>`_.
|
||||
|
||||
The functions are used to ensure the captured text *does not* match the given
|
||||
pattern.
|
||||
|
||||
The previous idiom was to use ``re.match``:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
assert re.match(pat, result.stdout.str()) is None
|
||||
|
||||
Or the ``in`` operator:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
assert text in result.stdout.str()
|
||||
|
||||
But the new functions produce best output on failure.
|
||||
|
||||
|
||||
- `#6057 <https://github.com/pytest-dev/pytest/issues/6057>`_: Added tolerances to complex values when printing ``pytest.approx``.
|
||||
|
||||
For example, ``repr(pytest.approx(3+4j))`` returns ``(3+4j) ± 5e-06 ∠ ±180°``. This is polar notation indicating a circle around the expected value, with a radius of 5e-06. For ``approx`` comparisons to return ``True``, the actual value should fall within this circle.
|
||||
|
||||
|
||||
- `#6061 <https://github.com/pytest-dev/pytest/issues/6061>`_: Added the pluginmanager as an argument to ``pytest_addoption``
|
||||
so that hooks can be invoked when setting up command line options. This is
|
||||
useful for having one plugin communicate things to another plugin,
|
||||
such as default values or which set of command line options to add.
|
||||
|
||||
|
||||
|
||||
Improvements
|
||||
------------
|
||||
|
||||
- `#5061 <https://github.com/pytest-dev/pytest/issues/5061>`_: Use multiple colors with terminal summary statistics.
|
||||
|
||||
|
||||
- `#5630 <https://github.com/pytest-dev/pytest/issues/5630>`_: Quitting from debuggers is now properly handled in ``doctest`` items.
|
||||
|
||||
|
||||
- `#5924 <https://github.com/pytest-dev/pytest/issues/5924>`_: Improved verbose diff output with sequences.
|
||||
|
||||
Before:
|
||||
|
||||
.. code-block::
|
||||
|
||||
E AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...]
|
||||
E Right contains 3 more items, first extra item: ' '
|
||||
E Full diff:
|
||||
E - ['version', 'version_info', 'sys.version', 'sys.version_info']
|
||||
E + ['version',
|
||||
E + 'version_info',
|
||||
E + 'sys.version',
|
||||
E + 'sys.version_info',
|
||||
E + ' ',
|
||||
E + 'sys.version',
|
||||
E + 'sys.version_info']
|
||||
|
||||
After:
|
||||
|
||||
.. code-block::
|
||||
|
||||
E AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...]
|
||||
E Right contains 3 more items, first extra item: ' '
|
||||
E Full diff:
|
||||
E [
|
||||
E 'version',
|
||||
E 'version_info',
|
||||
E 'sys.version',
|
||||
E 'sys.version_info',
|
||||
E + ' ',
|
||||
E + 'sys.version',
|
||||
E + 'sys.version_info',
|
||||
E ]
|
||||
|
||||
|
||||
- `#5936 <https://github.com/pytest-dev/pytest/issues/5936>`_: Display untruncated assertion message with ``-vv``.
|
||||
|
||||
|
||||
- `#5990 <https://github.com/pytest-dev/pytest/issues/5990>`_: Fixed plurality mismatch in test summary (e.g. display "1 error" instead of "1 errors").
|
||||
|
||||
|
||||
- `#6008 <https://github.com/pytest-dev/pytest/issues/6008>`_: ``Config.InvocationParams.args`` is now always a ``tuple`` to better convey that it should be
|
||||
immutable and avoid accidental modifications.
|
||||
|
||||
|
||||
- `#6023 <https://github.com/pytest-dev/pytest/issues/6023>`_: ``pytest.main`` now returns a ``pytest.ExitCode`` instance now, except for when custom exit codes are used (where it returns ``int`` then still).
|
||||
|
||||
|
||||
- `#6026 <https://github.com/pytest-dev/pytest/issues/6026>`_: Align prefixes in output of pytester's ``LineMatcher``.
|
||||
|
||||
|
||||
- `#6059 <https://github.com/pytest-dev/pytest/issues/6059>`_: Collection errors are reported as errors (and not failures like before) in the terminal's short test summary.
|
||||
|
||||
|
||||
- `#6069 <https://github.com/pytest-dev/pytest/issues/6069>`_: ``pytester.spawn`` does not skip/xfail tests on FreeBSD anymore unconditionally.
|
||||
|
||||
|
||||
- `#6097 <https://github.com/pytest-dev/pytest/issues/6097>`_: The "[XXX%]" indicator in the test summary is now colored according to the final (new) multi-colored line's main color.
|
||||
|
||||
|
||||
- `#6116 <https://github.com/pytest-dev/pytest/issues/6116>`_: Added ``--co`` as a synonym to ``--collect-only``.
|
||||
|
||||
|
||||
- `#6148 <https://github.com/pytest-dev/pytest/issues/6148>`_: ``atomicwrites`` is now only used on Windows, fixing a performance regression with assertion rewriting on Unix.
|
||||
|
||||
|
||||
- `#6152 <https://github.com/pytest-dev/pytest/issues/6152>`_: Now parametrization will use the ``__name__`` attribute of any object for the id, if present. Previously it would only use ``__name__`` for functions and classes.
|
||||
|
||||
|
||||
- `#6176 <https://github.com/pytest-dev/pytest/issues/6176>`_: Improved failure reporting with pytester's ``Hookrecorder.assertoutcome``.
|
||||
|
||||
|
||||
- `#6181 <https://github.com/pytest-dev/pytest/issues/6181>`_: The reason for a stopped session, e.g. with ``--maxfail`` / ``-x``, now gets reported in the test summary.
|
||||
|
||||
|
||||
- `#6206 <https://github.com/pytest-dev/pytest/issues/6206>`_: Improved ``cache.set`` robustness and performance.
|
||||
|
||||
|
||||
|
||||
Bug Fixes
|
||||
---------
|
||||
|
||||
- `#2049 <https://github.com/pytest-dev/pytest/issues/2049>`_: Fixed ``--setup-plan`` showing inaccurate information about fixture lifetimes.
|
||||
|
||||
|
||||
- `#2548 <https://github.com/pytest-dev/pytest/issues/2548>`_: Fixed line offset mismatch of skipped tests in terminal summary.
|
||||
|
||||
|
||||
- `#6039 <https://github.com/pytest-dev/pytest/issues/6039>`_: The ``PytestDoctestRunner`` is now properly invalidated when unconfiguring the doctest plugin.
|
||||
|
||||
This is important when used with ``pytester``'s ``runpytest_inprocess``.
|
||||
|
||||
|
||||
- `#6047 <https://github.com/pytest-dev/pytest/issues/6047>`_: BaseExceptions are now handled in ``saferepr``, which includes ``pytest.fail.Exception`` etc.
|
||||
|
||||
|
||||
- `#6074 <https://github.com/pytest-dev/pytest/issues/6074>`_: pytester: fixed order of arguments in ``rm_rf`` warning when cleaning up temporary directories, and do not emit warnings for errors with ``os.open``.
|
||||
|
||||
|
||||
- `#6189 <https://github.com/pytest-dev/pytest/issues/6189>`_: Fixed result of ``getmodpath`` method.
|
||||
|
||||
|
||||
|
||||
Trivial/Internal Changes
|
||||
------------------------
|
||||
|
||||
- `#4901 <https://github.com/pytest-dev/pytest/issues/4901>`_: ``RunResult`` from ``pytester`` now displays the mnemonic of the ``ret`` attribute when it is a
|
||||
valid ``pytest.ExitCode`` value.
|
||||
|
||||
|
||||
pytest 5.2.4 (2019-11-15)
|
||||
=========================
|
||||
|
||||
|
@ -1901,7 +2103,8 @@ Features
|
|||
live-logging is enabled and/or when they are logged to a file.
|
||||
|
||||
|
||||
- `#3985 <https://github.com/pytest-dev/pytest/issues/3985>`_: Introduce ``tmp_path`` as a fixture providing a Path object.
|
||||
- `#3985 <https://github.com/pytest-dev/pytest/issues/3985>`_: Introduce ``tmp_path`` as a fixture providing a Path object. Also introduce ``tmp_path_factory`` as
|
||||
a session-scoped fixture for creating arbitrary temporary directories from any other fixture or test.
|
||||
|
||||
|
||||
- `#4013 <https://github.com/pytest-dev/pytest/issues/4013>`_: Deprecation warnings are now shown even if you customize the warnings filters yourself. In the previous version
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Fix line offset mismatch with skipped tests in terminal summary.
|
|
@ -1,10 +0,0 @@
|
|||
The pytest team has created the `pytest-reportlog <https://github.com/pytest-dev/pytest-reportlog>`__
|
||||
plugin, which provides a new ``--report-log=FILE`` option that writes *report logs* into a file as the test session executes.
|
||||
|
||||
Each line of the report log contains a self contained JSON object corresponding to a testing event,
|
||||
such as a collection or a test result report. The file is guaranteed to be flushed after writing
|
||||
each line, so systems can read and process events in real-time.
|
||||
|
||||
The plugin is meant to replace the ``--resultlog`` option, which is deprecated and meant to be removed
|
||||
in a future release. If you use ``--resultlog``, please try out ``pytest-reportlog`` and
|
||||
provide feedback.
|
|
@ -1,3 +0,0 @@
|
|||
When ``sys.pycache_prefix`` (Python 3.8+) is set, it will be used by pytest to cache test files changed by the assertion rewriting mechanism.
|
||||
|
||||
This makes it easier to benefit of cached ``.pyc`` files even on file systems without permissions.
|
|
@ -1,2 +0,0 @@
|
|||
``RunResult`` from ``pytester`` now displays the mnemonic of the ``ret`` attribute when it is a
|
||||
valid ``pytest.ExitCode`` value.
|
|
@ -1 +0,0 @@
|
|||
Use multiple colors with terminal summary statistics.
|
|
@ -1,11 +0,0 @@
|
|||
Allow selective auto-indentation of multiline log messages.
|
||||
|
||||
Adds command line option ``--log-auto-indent``, config option
|
||||
``log_auto_indent`` and support for per-entry configuration of
|
||||
indentation behavior on calls to ``logging.log()``.
|
||||
|
||||
Alters the default for auto-indention from ``on`` to ``off``. This
|
||||
restores the older behavior that existed prior to v4.6.0. This
|
||||
reversion to earlier behavior was done because it is better to
|
||||
activate new features that may lead to broken tests explicitly
|
||||
rather than implicitly.
|
|
@ -1 +0,0 @@
|
|||
Quitting from debuggers is now properly handled in ``doctest`` items.
|
|
@ -1,19 +0,0 @@
|
|||
``pytester`` learned two new functions, `no_fnmatch_line <https://docs.pytest.org/en/latest/reference.html#_pytest.pytester.LineMatcher.no_fnmatch_line>`_ and
|
||||
`no_re_match_line <https://docs.pytest.org/en/latest/reference.html#_pytest.pytester.LineMatcher.no_re_match_line>`_.
|
||||
|
||||
The functions are used to ensure the captured text *does not* match the given
|
||||
pattern.
|
||||
|
||||
The previous idiom was to use ``re.match``:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
assert re.match(pat, result.stdout.str()) is None
|
||||
|
||||
Or the ``in`` operator:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
assert text in result.stdout.str()
|
||||
|
||||
But the new functions produce best output on failure.
|
|
@ -1,34 +0,0 @@
|
|||
Improve verbose diff output with sequences.
|
||||
|
||||
Before:
|
||||
|
||||
.. code-block::
|
||||
|
||||
E AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...]
|
||||
E Right contains 3 more items, first extra item: ' '
|
||||
E Full diff:
|
||||
E - ['version', 'version_info', 'sys.version', 'sys.version_info']
|
||||
E + ['version',
|
||||
E + 'version_info',
|
||||
E + 'sys.version',
|
||||
E + 'sys.version_info',
|
||||
E + ' ',
|
||||
E + 'sys.version',
|
||||
E + 'sys.version_info']
|
||||
|
||||
After:
|
||||
|
||||
.. code-block::
|
||||
|
||||
E AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...]
|
||||
E Right contains 3 more items, first extra item: ' '
|
||||
E Full diff:
|
||||
E [
|
||||
E 'version',
|
||||
E 'version_info',
|
||||
E 'sys.version',
|
||||
E 'sys.version_info',
|
||||
E + ' ',
|
||||
E + 'sys.version',
|
||||
E + 'sys.version_info',
|
||||
E ]
|
|
@ -1 +0,0 @@
|
|||
Display untruncated assertion message with ``-vv``.
|
|
@ -1 +0,0 @@
|
|||
Fix plurality mismatch in test summary (e.g. display "1 error" instead of "1 errors").
|
|
@ -1,2 +0,0 @@
|
|||
``Config.InvocationParams.args`` is now always a ``tuple`` to better convey that it should be
|
||||
immutable and avoid accidental modifications.
|
|
@ -1 +0,0 @@
|
|||
``pytest.main`` returns a ``pytest.ExitCode`` instance now, except for when custom exit codes are used (where it returns ``int`` then still).
|
|
@ -1 +0,0 @@
|
|||
Align prefixes in output of pytester's ``LineMatcher``.
|
|
@ -1,3 +0,0 @@
|
|||
The ``PytestDoctestRunner`` is properly invalidated when unconfiguring the doctest plugin.
|
||||
|
||||
This is important when used with ``pytester``'s ``runpytest_inprocess``.
|
|
@ -1 +0,0 @@
|
|||
BaseExceptions are handled in ``saferepr``, which includes ``pytest.fail.Exception`` etc.
|
|
@ -1,3 +0,0 @@
|
|||
Add tolerances to complex values when printing ``pytest.approx``.
|
||||
|
||||
For example, ``repr(pytest.approx(3+4j))`` returns ``(3+4j) ± 5e-06 ∠ ±180°``. This is polar notation indicating a circle around the expected value, with a radius of 5e-06. For ``approx`` comparisons to return ``True``, the actual value should fall within this circle.
|
|
@ -1 +0,0 @@
|
|||
Collection errors are reported as errors (and not failures like before) in the terminal's short test summary.
|
|
@ -1,4 +0,0 @@
|
|||
Adding the pluginmanager as an option ``pytest_addoption``
|
||||
so that hooks can be invoked when setting up command line options. This is
|
||||
useful for having one plugin communicate things to another plugin,
|
||||
such as default values or which set of command line options to add.
|
|
@ -1 +0,0 @@
|
|||
``pytester.spawn`` does not skip/xfail tests on FreeBSD anymore unconditionally.
|
|
@ -1 +0,0 @@
|
|||
pytester: fix order of arguments in ``rm_rf`` warning when cleaning up temporary directories, and do not emit warnings for errors with ``os.open``.
|
|
@ -1 +0,0 @@
|
|||
The "[XXX%]" indicator in the test summary is colored according to the final (new) multi-colored line's main color.
|
|
@ -1 +0,0 @@
|
|||
Add ``--co`` as a synonym to ``--collect-only``.
|
|
@ -1 +0,0 @@
|
|||
``atomicwrites`` is now only used on Windows, fixing a performance regression with assertion rewriting on Unix.
|
|
@ -1 +0,0 @@
|
|||
Now parametrization will use the ``__name__`` attribute of any object for the id, if present. Previously it would only use ``__name__`` for functions and classes.
|
|
@ -1 +0,0 @@
|
|||
Improved failure reporting with pytester's ``Hookrecorder.assertoutcome``.
|
|
@ -1,7 +0,0 @@
|
|||
The default value of ``junit_family`` option will change to ``xunit2`` in pytest 6.0, given
|
||||
that this is the version supported by default in modern tools that manipulate this type of file.
|
||||
|
||||
In order to smooth the transition, pytest will issue a warning in case the ``--junitxml`` option
|
||||
is given in the command line but ``junit_family`` is not explicitly configured in ``pytest.ini``.
|
||||
|
||||
For more information, `see the docs <https://docs.pytest.org/en/latest/deprecations.html#junit-family-default-value-change-to-xunit2>`__.
|
|
@ -1 +0,0 @@
|
|||
The reason for a stopped session, e.g. with ``--maxfail`` / ``-x`` gets reported.
|
|
@ -1 +0,0 @@
|
|||
cacheprovider: improved robustness and performance with ``cache.set``.
|
|
@ -6,6 +6,7 @@ Release announcements
|
|||
:maxdepth: 2
|
||||
|
||||
|
||||
release-5.3.0
|
||||
release-5.2.4
|
||||
release-5.2.3
|
||||
release-5.2.2
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
pytest-5.3.0
|
||||
=======================================
|
||||
|
||||
The pytest team is proud to announce the 5.3.0 release!
|
||||
|
||||
pytest is a mature Python testing tool with more than a 2000 tests
|
||||
against itself, passing on many different interpreters and platforms.
|
||||
|
||||
This release contains a number of bugs fixes and improvements, so users are encouraged
|
||||
to take a look at the CHANGELOG:
|
||||
|
||||
https://docs.pytest.org/en/latest/changelog.html
|
||||
|
||||
For complete documentation, please visit:
|
||||
|
||||
https://docs.pytest.org/en/latest/
|
||||
|
||||
As usual, you can upgrade from pypi via:
|
||||
|
||||
pip install -U pytest
|
||||
|
||||
Thanks to all who contributed to this release, among them:
|
||||
|
||||
* AnjoMan
|
||||
* Anthony Sottile
|
||||
* Anton Lodder
|
||||
* Bruno Oliveira
|
||||
* Daniel Hahler
|
||||
* Gregory Lee
|
||||
* Josh Karpel
|
||||
* JoshKarpel
|
||||
* Joshua Storck
|
||||
* Kale Kundert
|
||||
* MarcoGorelli
|
||||
* Michael Krebs
|
||||
* NNRepos
|
||||
* Ran Benita
|
||||
* TH3CHARLie
|
||||
* Tibor Arpas
|
||||
* Zac Hatfield-Dodds
|
||||
* 林玮
|
||||
|
||||
|
||||
Happy testing,
|
||||
The Pytest Development Team
|
|
@ -622,7 +622,7 @@ then you will see two tests skipped and two executed tests as expected:
|
|||
test_plat.py s.s. [100%]
|
||||
|
||||
========================= short test summary info ==========================
|
||||
SKIPPED [2] $REGENDOC_TMPDIR/conftest.py:13: cannot run on platform linux
|
||||
SKIPPED [2] $REGENDOC_TMPDIR/conftest.py:12: cannot run on platform linux
|
||||
======================= 2 passed, 2 skipped in 0.12s =======================
|
||||
|
||||
Note that if you specify a platform via the marker-command line option like this:
|
||||
|
|
|
@ -475,10 +475,11 @@ 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......sss...... [100%]
|
||||
ssssssssssss...ssssssssssss [100%]
|
||||
========================= short test summary info ==========================
|
||||
SKIPPED [15] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.5' not found
|
||||
12 passed, 15 skipped in 0.12s
|
||||
SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:29: 'python3.5' not found
|
||||
SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:29: 'python3.7' not found
|
||||
3 passed, 24 skipped in 0.12s
|
||||
|
||||
Indirect parametrization of optional implementations/imports
|
||||
--------------------------------------------------------------------
|
||||
|
@ -546,7 +547,7 @@ If you run this with reporting for skips enabled:
|
|||
test_module.py .s [100%]
|
||||
|
||||
========================= short test summary info ==========================
|
||||
SKIPPED [1] $REGENDOC_TMPDIR/conftest.py:13: could not import 'opt2': No module named 'opt2'
|
||||
SKIPPED [1] $REGENDOC_TMPDIR/conftest.py:12: could not import 'opt2': No module named 'opt2'
|
||||
======================= 1 passed, 1 skipped in 0.12s =======================
|
||||
|
||||
You'll see that we don't have an ``opt2`` module and thus the second test run
|
||||
|
|
|
@ -443,7 +443,7 @@ Now we can profile which test functions execute the slowest:
|
|||
========================= slowest 3 test durations =========================
|
||||
0.30s call test_some_are_slow.py::test_funcslow2
|
||||
0.20s call test_some_are_slow.py::test_funcslow1
|
||||
0.10s call test_some_are_slow.py::test_funcfast
|
||||
0.11s call test_some_are_slow.py::test_funcfast
|
||||
============================ 3 passed in 0.12s =============================
|
||||
|
||||
incremental testing - test steps
|
||||
|
|
|
@ -241,7 +241,7 @@ Example:
|
|||
|
||||
test_example.py:14: AssertionError
|
||||
========================= short test summary info ==========================
|
||||
SKIPPED [1] $REGENDOC_TMPDIR/test_example.py:23: skipping this test
|
||||
SKIPPED [1] $REGENDOC_TMPDIR/test_example.py:22: skipping this test
|
||||
XFAIL test_example.py::test_xfail
|
||||
reason: xfailing this test
|
||||
XPASS test_example.py::test_xpass always xfail
|
||||
|
@ -296,7 +296,7 @@ More than one character can be used, so for example to only see failed and skipp
|
|||
test_example.py:14: AssertionError
|
||||
========================= short test summary info ==========================
|
||||
FAILED test_example.py::test_fail - assert 0
|
||||
SKIPPED [1] $REGENDOC_TMPDIR/test_example.py:23: skipping this test
|
||||
SKIPPED [1] $REGENDOC_TMPDIR/test_example.py:22: skipping this test
|
||||
== 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12s ===
|
||||
|
||||
Using ``p`` lists the passing tests, whilst ``P`` adds an extra section "PASSES" with those tests that passed but had
|
||||
|
|
|
@ -41,7 +41,7 @@ Running pytest now produces this output:
|
|||
warnings.warn(UserWarning("api v1, should use functions from v2"))
|
||||
|
||||
-- Docs: https://docs.pytest.org/en/latest/warnings.html
|
||||
====================== 1 passed, 1 warnings in 0.12s =======================
|
||||
======================= 1 passed, 1 warning in 0.12s =======================
|
||||
|
||||
The ``-W`` flag can be passed to control which warnings will be displayed or even turn
|
||||
them into errors:
|
||||
|
@ -407,7 +407,7 @@ defines an ``__init__`` constructor, as this prevents the class from being insta
|
|||
class Test:
|
||||
|
||||
-- Docs: https://docs.pytest.org/en/latest/warnings.html
|
||||
1 warnings in 0.12s
|
||||
1 warning in 0.12s
|
||||
|
||||
These warnings might be filtered using the same builtin mechanisms used to filter other types of warnings.
|
||||
|
||||
|
|
|
@ -442,7 +442,7 @@ additionally it is possible to copy examples for an example folder before runnin
|
|||
testdir.copy_example("test_example.py")
|
||||
|
||||
-- Docs: https://docs.pytest.org/en/latest/warnings.html
|
||||
====================== 2 passed, 1 warnings in 0.12s =======================
|
||||
======================= 2 passed, 1 warning in 0.12s =======================
|
||||
|
||||
For more information about the result object that ``runpytest()`` returns, and
|
||||
the methods that it provides please check out the :py:class:`RunResult
|
||||
|
|
|
@ -277,8 +277,7 @@ class PyobjMixin(PyobjContext):
|
|||
break
|
||||
parts.append(name)
|
||||
parts.reverse()
|
||||
s = ".".join(parts)
|
||||
return s.replace(".[", "[")
|
||||
return ".".join(parts)
|
||||
|
||||
def reportinfo(self) -> Tuple[str, int, str]:
|
||||
# XXX caching?
|
||||
|
|
|
@ -16,7 +16,8 @@ def pytest_addoption(parser):
|
|||
def pytest_fixture_setup(fixturedef, request):
|
||||
# Will return a dummy fixture if the setuponly option is provided.
|
||||
if request.config.option.setupplan:
|
||||
fixturedef.cached_result = (None, None, None)
|
||||
my_cache_key = fixturedef.cache_key(request)
|
||||
fixturedef.cached_result = (None, my_cache_key, None)
|
||||
return fixturedef.cached_result
|
||||
|
||||
|
||||
|
|
|
@ -760,7 +760,6 @@ class TestInvocationVariants:
|
|||
result = testdir.runpytest(str(p) + "::test", "--doctest-modules")
|
||||
result.stdout.fnmatch_lines(["*1 passed*"])
|
||||
|
||||
@pytest.mark.skipif(not hasattr(os, "symlink"), reason="requires symlinks")
|
||||
def test_cmdline_python_package_symlink(self, testdir, monkeypatch):
|
||||
"""
|
||||
test --pyargs option with packages with path containing symlink can
|
||||
|
|
|
@ -685,6 +685,8 @@ class Test_genitems:
|
|||
def test_example_items1(self, testdir):
|
||||
p = testdir.makepyfile(
|
||||
"""
|
||||
import pytest
|
||||
|
||||
def testone():
|
||||
pass
|
||||
|
||||
|
@ -693,19 +695,24 @@ class Test_genitems:
|
|||
pass
|
||||
|
||||
class TestY(TestX):
|
||||
pass
|
||||
@pytest.mark.parametrize("arg0", [".["])
|
||||
def testmethod_two(self, arg0):
|
||||
pass
|
||||
"""
|
||||
)
|
||||
items, reprec = testdir.inline_genitems(p)
|
||||
assert len(items) == 3
|
||||
assert len(items) == 4
|
||||
assert items[0].name == "testone"
|
||||
assert items[1].name == "testmethod_one"
|
||||
assert items[2].name == "testmethod_one"
|
||||
assert items[3].name == "testmethod_two[.[]"
|
||||
|
||||
# let's also test getmodpath here
|
||||
assert items[0].getmodpath() == "testone"
|
||||
assert items[1].getmodpath() == "TestX.testmethod_one"
|
||||
assert items[2].getmodpath() == "TestY.testmethod_one"
|
||||
# PR #6202: Fix incorrect result of getmodpath method. (Resolves issue #6189)
|
||||
assert items[3].getmodpath() == "TestY.testmethod_two[.[]"
|
||||
|
||||
s = items[0].getmodpath(stopatmodule=False)
|
||||
assert s.endswith("test_example_items1.testone")
|
||||
|
|
|
@ -17,3 +17,94 @@ def test_show_fixtures_and_test(testdir, dummy_yaml_custom_test):
|
|||
result.stdout.fnmatch_lines(
|
||||
["*SETUP F arg*", "*test_arg (fixtures used: arg)", "*TEARDOWN F arg*"]
|
||||
)
|
||||
|
||||
|
||||
def test_show_multi_test_fixture_setup_and_teardown_correctly_simple(testdir):
|
||||
"""
|
||||
Verify that when a fixture lives for longer than a single test, --setup-plan
|
||||
correctly displays the SETUP/TEARDOWN indicators the right number of times.
|
||||
|
||||
As reported in https://github.com/pytest-dev/pytest/issues/2049
|
||||
--setup-plan was showing SETUP/TEARDOWN on every test, even when the fixture
|
||||
should persist through multiple tests.
|
||||
|
||||
(Note that this bug never affected actual test execution, which used the
|
||||
correct fixture lifetimes. It was purely a display bug for --setup-plan, and
|
||||
did not affect the related --setup-show or --setup-only.)
|
||||
"""
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
import pytest
|
||||
@pytest.fixture(scope = 'class')
|
||||
def fix():
|
||||
return object()
|
||||
class TestClass:
|
||||
def test_one(self, fix):
|
||||
assert False
|
||||
def test_two(self, fix):
|
||||
assert False
|
||||
"""
|
||||
)
|
||||
|
||||
result = testdir.runpytest("--setup-plan")
|
||||
assert result.ret == 0
|
||||
|
||||
setup_fragment = "SETUP C fix"
|
||||
setup_count = 0
|
||||
|
||||
teardown_fragment = "TEARDOWN C fix"
|
||||
teardown_count = 0
|
||||
|
||||
for line in result.stdout.lines:
|
||||
if setup_fragment in line:
|
||||
setup_count += 1
|
||||
if teardown_fragment in line:
|
||||
teardown_count += 1
|
||||
|
||||
# before the fix this tests, there would have been a setup/teardown
|
||||
# message for each test, so the counts would each have been 2
|
||||
assert setup_count == 1
|
||||
assert teardown_count == 1
|
||||
|
||||
|
||||
def test_show_multi_test_fixture_setup_and_teardown_same_as_setup_show(testdir):
|
||||
"""
|
||||
Verify that SETUP/TEARDOWN messages match what comes out of --setup-show.
|
||||
"""
|
||||
testdir.makepyfile(
|
||||
"""
|
||||
import pytest
|
||||
@pytest.fixture(scope = 'session')
|
||||
def sess():
|
||||
return True
|
||||
@pytest.fixture(scope = 'module')
|
||||
def mod():
|
||||
return True
|
||||
@pytest.fixture(scope = 'class')
|
||||
def cls():
|
||||
return True
|
||||
@pytest.fixture(scope = 'function')
|
||||
def func():
|
||||
return True
|
||||
def test_outside(sess, mod, cls, func):
|
||||
assert True
|
||||
class TestCls:
|
||||
def test_one(self, sess, mod, cls, func):
|
||||
assert True
|
||||
def test_two(self, sess, mod, cls, func):
|
||||
assert True
|
||||
"""
|
||||
)
|
||||
|
||||
plan_result = testdir.runpytest("--setup-plan")
|
||||
show_result = testdir.runpytest("--setup-show")
|
||||
|
||||
# the number and text of these lines should be identical
|
||||
plan_lines = [
|
||||
l for l in plan_result.stdout.lines if "SETUP" in l or "TEARDOWN" in l
|
||||
]
|
||||
show_lines = [
|
||||
l for l in show_result.stdout.lines if "SETUP" in l or "TEARDOWN" in l
|
||||
]
|
||||
|
||||
assert plan_lines == show_lines
|
||||
|
|
Loading…
Reference in New Issue