Skip to content

Commit 6a43c8c

Browse files
authored
Release 4.5.0 (#5246)
Release 4.5.0
2 parents 4ccaa98 + 63fe547 commit 6a43c8c

Some content is hidden

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

70 files changed

+1763
-591
lines changed

AUTHORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ Paweł Adamczak
194194
Pedro Algarvio
195195
Pieter Mulder
196196
Piotr Banaszkiewicz
197+
Pulkit Goyal
197198
Punyashloka Biswal
198199
Quentin Pradet
199200
Ralf Schmitt
@@ -211,6 +212,7 @@ Ross Lawley
211212
Russel Winder
212213
Ryan Wooden
213214
Samuel Dion-Girardeau
215+
Samuel Searles-Bryant
214216
Samuele Pedroni
215217
Sankt Petersbug
216218
Segev Finer

CHANGELOG.rst

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,139 @@ with advance notice in the **Deprecations** section of releases.
1818
1919
.. towncrier release notes start
2020
21+
pytest 4.5.0 (2019-05-11)
22+
=========================
23+
24+
Features
25+
--------
26+
27+
- `#4826 <https://github.com/pytest-dev/pytest/issues/4826>`_: A warning is now emitted when unknown marks are used as a decorator.
28+
This is often due to a typo, which can lead to silently broken tests.
29+
30+
31+
- `#4907 <https://github.com/pytest-dev/pytest/issues/4907>`_: Show XFail reason as part of JUnitXML message field.
32+
33+
34+
- `#5013 <https://github.com/pytest-dev/pytest/issues/5013>`_: Messages from crash reports are displayed within test summaries now, truncated to the terminal width.
35+
36+
37+
- `#5023 <https://github.com/pytest-dev/pytest/issues/5023>`_: New flag ``--strict-markers`` that triggers an error when unknown markers (e.g. those not registered using the `markers option`_ in the configuration file) are used in the test suite.
38+
39+
The existing ``--strict`` option has the same behavior currently, but can be augmented in the future for additional checks.
40+
41+
.. _`markers option`: https://docs.pytest.org/en/latest/reference.html#confval-markers
42+
43+
44+
- `#5026 <https://github.com/pytest-dev/pytest/issues/5026>`_: Assertion failure messages for sequences and dicts contain the number of different items now.
45+
46+
47+
- `#5034 <https://github.com/pytest-dev/pytest/issues/5034>`_: Improve reporting with ``--lf`` and ``--ff`` (run-last-failure).
48+
49+
50+
- `#5035 <https://github.com/pytest-dev/pytest/issues/5035>`_: The ``--cache-show`` option/action accepts an optional glob to show only matching cache entries.
51+
52+
53+
- `#5059 <https://github.com/pytest-dev/pytest/issues/5059>`_: Standard input (stdin) can be given to pytester's ``Testdir.run()`` and ``Testdir.popen()``.
54+
55+
56+
- `#5068 <https://github.com/pytest-dev/pytest/issues/5068>`_: The ``-r`` option learnt about ``A`` to display all reports (including passed ones) in the short test summary.
57+
58+
59+
- `#5108 <https://github.com/pytest-dev/pytest/issues/5108>`_: The short test summary is displayed after passes with output (``-rP``).
60+
61+
62+
- `#5172 <https://github.com/pytest-dev/pytest/issues/5172>`_: The ``--last-failed`` (``--lf``) option got smarter and will now skip entire files if all tests
63+
of that test file have passed in previous runs, greatly speeding up collection.
64+
65+
66+
- `#5177 <https://github.com/pytest-dev/pytest/issues/5177>`_: Introduce new specific warning ``PytestWarning`` subclasses to make it easier to filter warnings based on the class, rather than on the message. The new subclasses are:
67+
68+
69+
* ``PytestAssertRewriteWarning``
70+
71+
* ``PytestCacheWarning``
72+
73+
* ``PytestCollectionWarning``
74+
75+
* ``PytestConfigWarning``
76+
77+
* ``PytestUnhandledCoroutineWarning``
78+
79+
* ``PytestUnknownMarkWarning``
80+
81+
82+
- `#5202 <https://github.com/pytest-dev/pytest/issues/5202>`_: New ``record_testsuite_property`` session-scoped fixture allows users to log ``<property>`` tags at the ``testsuite``
83+
level with the ``junitxml`` plugin.
84+
85+
The generated XML is compatible with the latest xunit standard, contrary to
86+
the properties recorded by ``record_property`` and ``record_xml_attribute``.
87+
88+
89+
- `#5214 <https://github.com/pytest-dev/pytest/issues/5214>`_: The default logging format has been changed to improve readability. Here is an
90+
example of a previous logging message::
91+
92+
test_log_cli_enabled_disabled.py 3 CRITICAL critical message logged by test
93+
94+
This has now become::
95+
96+
CRITICAL root:test_log_cli_enabled_disabled.py:3 critical message logged by test
97+
98+
The formatting can be changed through the `log_format <https://docs.pytest.org/en/latest/reference.html#confval-log_format>`__ configuration option.
99+
100+
101+
- `#5220 <https://github.com/pytest-dev/pytest/issues/5220>`_: ``--fixtures`` now also shows fixture scope for scopes other than ``"function"``.
102+
103+
104+
105+
Bug Fixes
106+
---------
107+
108+
- `#5113 <https://github.com/pytest-dev/pytest/issues/5113>`_: Deselected items from plugins using ``pytest_collect_modifyitems`` as a hookwrapper are correctly reported now.
109+
110+
111+
- `#5144 <https://github.com/pytest-dev/pytest/issues/5144>`_: With usage errors ``exitstatus`` is set to ``EXIT_USAGEERROR`` in the ``pytest_sessionfinish`` hook now as expected.
112+
113+
114+
- `#5235 <https://github.com/pytest-dev/pytest/issues/5235>`_: ``outcome.exit`` is not used with ``EOF`` in the pdb wrapper anymore, but only with ``quit``.
115+
116+
117+
118+
Improved Documentation
119+
----------------------
120+
121+
- `#4935 <https://github.com/pytest-dev/pytest/issues/4935>`_: Expand docs on registering marks and the effect of ``--strict``.
122+
123+
124+
125+
Trivial/Internal Changes
126+
------------------------
127+
128+
- `#4942 <https://github.com/pytest-dev/pytest/issues/4942>`_: ``logging.raiseExceptions`` is not set to ``False`` anymore.
129+
130+
131+
- `#5013 <https://github.com/pytest-dev/pytest/issues/5013>`_: pytest now depends on `wcwidth <https://pypi.org/project/wcwidth>`__ to properly track unicode character sizes for more precise terminal output.
132+
133+
134+
- `#5059 <https://github.com/pytest-dev/pytest/issues/5059>`_: pytester's ``Testdir.popen()`` uses ``stdout`` and ``stderr`` via keyword arguments with defaults now (``subprocess.PIPE``).
135+
136+
137+
- `#5069 <https://github.com/pytest-dev/pytest/issues/5069>`_: The code for the short test summary in the terminal was moved to the terminal plugin.
138+
139+
140+
- `#5082 <https://github.com/pytest-dev/pytest/issues/5082>`_: Improved validation of kwargs for various methods in the pytester plugin.
141+
142+
143+
- `#5202 <https://github.com/pytest-dev/pytest/issues/5202>`_: ``record_property`` now emits a ``PytestWarning`` when used with ``junit_family=xunit2``: the fixture generates
144+
``property`` tags as children of ``testcase``, which is not permitted according to the most
145+
`recent schema <https://github.com/jenkinsci/xunit-plugin/blob/master/
146+
src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd>`__.
147+
148+
149+
- `#5239 <https://github.com/pytest-dev/pytest/issues/5239>`_: Pin ``pluggy`` to ``< 1.0`` so we don't update to ``1.0`` automatically when
150+
it gets released: there are planned breaking changes, and we want to ensure
151+
pytest properly supports ``pluggy 1.0``.
152+
153+
21154
pytest 4.4.2 (2019-05-08)
22155
=========================
23156

changelog/5239.trivial.rst

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

doc/en/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ clean:
4343

4444
regen: REGENDOC_FILES:=*.rst */*.rst
4545
regen:
46-
PYTHONDONTWRITEBYTECODE=1 PYTEST_ADDOPTS=-pno:hypothesis COLUMNS=76 regendoc --update ${REGENDOC_FILES} ${REGENDOC_ARGS}
46+
PYTHONDONTWRITEBYTECODE=1 PYTEST_ADDOPTS="-pno:hypothesis -Wignore::pytest.PytestUnknownMarkWarning" COLUMNS=76 regendoc --update ${REGENDOC_FILES} ${REGENDOC_ARGS}
4747

4848
html:
4949
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html

doc/en/announce/index.rst

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

88

9+
release-4.5.0
910
release-4.4.2
1011
release-4.4.1
1112
release-4.4.0

doc/en/announce/release-4.5.0.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
pytest-4.5.0
2+
=======================================
3+
4+
The pytest team is proud to announce the 4.5.0 release!
5+
6+
pytest is a mature Python testing tool with more than a 2000 tests
7+
against itself, passing on many different interpreters and platforms.
8+
9+
This release contains a number of bugs fixes and improvements, so users are encouraged
10+
to take a look at the CHANGELOG:
11+
12+
https://docs.pytest.org/en/latest/changelog.html
13+
14+
For complete documentation, please visit:
15+
16+
https://docs.pytest.org/en/latest/
17+
18+
As usual, you can upgrade from pypi via:
19+
20+
pip install -U pytest
21+
22+
Thanks to all who contributed to this release, among them:
23+
24+
* Anthony Sottile
25+
* Bruno Oliveira
26+
* Daniel Hahler
27+
* Floris Bruynooghe
28+
* Pulkit Goyal
29+
* Samuel Searles-Bryant
30+
* Zac Hatfield-Dodds
31+
* Zac-HD
32+
33+
34+
Happy testing,
35+
The Pytest Development Team

doc/en/builtin.rst

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,40 +27,47 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
2727
name of your plugin or application to avoid clashes with other cache users.
2828
2929
Values can be any object handled by the json stdlib module.
30+
3031
capsys
3132
Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.
3233
3334
The captured output is made available via ``capsys.readouterr()`` method
3435
calls, which return a ``(out, err)`` namedtuple.
3536
``out`` and ``err`` will be ``text`` objects.
37+
3638
capsysbinary
3739
Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.
3840
3941
The captured output is made available via ``capsysbinary.readouterr()``
4042
method calls, which return a ``(out, err)`` namedtuple.
4143
``out`` and ``err`` will be ``bytes`` objects.
44+
4245
capfd
4346
Enable text capturing of writes to file descriptors ``1`` and ``2``.
4447
4548
The captured output is made available via ``capfd.readouterr()`` method
4649
calls, which return a ``(out, err)`` namedtuple.
4750
``out`` and ``err`` will be ``text`` objects.
51+
4852
capfdbinary
4953
Enable bytes capturing of writes to file descriptors ``1`` and ``2``.
5054
5155
The captured output is made available via ``capfd.readouterr()`` method
5256
calls, which return a ``(out, err)`` namedtuple.
5357
``out`` and ``err`` will be ``byte`` objects.
54-
doctest_namespace
58+
59+
doctest_namespace [session scope]
5560
Fixture that returns a :py:class:`dict` that will be injected into the namespace of doctests.
56-
pytestconfig
61+
62+
pytestconfig [session scope]
5763
Session-scoped fixture that returns the :class:`_pytest.config.Config` object.
5864
5965
Example::
6066
6167
def test_foo(pytestconfig):
6268
if pytestconfig.getoption("verbose") > 0:
6369
...
70+
6471
record_property
6572
Add an extra properties the calling test.
6673
User properties become part of the test report and are available to the
@@ -72,10 +79,26 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
7279
7380
def test_function(record_property):
7481
record_property("example_key", 1)
82+
7583
record_xml_attribute
7684
Add extra xml attributes to the tag for the calling test.
7785
The fixture is callable with ``(name, value)``, with value being
7886
automatically xml-encoded
87+
88+
record_testsuite_property [session scope]
89+
Records a new ``<property>`` tag as child of the root ``<testsuite>``. This is suitable to
90+
writing global information regarding the entire test suite, and is compatible with ``xunit2`` JUnit family.
91+
92+
This is a ``session``-scoped fixture which is called with ``(name, value)``. Example:
93+
94+
.. code-block:: python
95+
96+
def test_foo(record_testsuite_property):
97+
record_testsuite_property("ARCH", "PPC")
98+
record_testsuite_property("STORAGE_TYPE", "CEPH")
99+
100+
``name`` must be a string, ``value`` will be converted to a string and properly xml-escaped.
101+
79102
caplog
80103
Access and control log capturing.
81104
@@ -85,6 +108,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
85108
* caplog.records -> list of logging.LogRecord instances
86109
* caplog.record_tuples -> list of (logger_name, level, message) tuples
87110
* caplog.clear() -> clear captured records and formatted log output string
111+
88112
monkeypatch
89113
The returned ``monkeypatch`` fixture provides these
90114
helper methods to modify objects, dictionaries or os.environ::
@@ -102,15 +126,19 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
102126
test function or fixture has finished. The ``raising``
103127
parameter determines if a KeyError or AttributeError
104128
will be raised if the set/deletion operation has no target.
129+
105130
recwarn
106131
Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.
107132
108133
See http://docs.python.org/library/warnings.html for information
109134
on warning categories.
110-
tmpdir_factory
135+
136+
tmpdir_factory [session scope]
111137
Return a :class:`_pytest.tmpdir.TempdirFactory` instance for the test session.
112-
tmp_path_factory
138+
139+
tmp_path_factory [session scope]
113140
Return a :class:`_pytest.tmpdir.TempPathFactory` instance for the test session.
141+
114142
tmpdir
115143
Return a temporary directory path object
116144
which is unique to each test function invocation,
@@ -119,6 +147,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
119147
path object.
120148
121149
.. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html
150+
122151
tmp_path
123152
Return a temporary directory path object
124153
which is unique to each test function invocation,
@@ -130,6 +159,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
130159
131160
in python < 3.6 this is a pathlib2.Path
132161
162+
133163
no tests ran in 0.12 seconds
134164
135165
You can also interactively ask for help, e.g. by typing on the Python interactive prompt something like::

doc/en/cache.rst

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ See the :ref:`cache-api` for more details.
247247

248248

249249
Inspecting Cache content
250-
-------------------------------
250+
------------------------
251251

252252
You can always peek at the content of the cache using the
253253
``--cache-show`` command line option:
@@ -260,7 +260,7 @@ You can always peek at the content of the cache using the
260260
cachedir: $PYTHON_PREFIX/.pytest_cache
261261
rootdir: $REGENDOC_TMPDIR
262262
cachedir: $PYTHON_PREFIX/.pytest_cache
263-
------------------------------- cache values -------------------------------
263+
--------------------------- cache values for '*' ---------------------------
264264
cache/lastfailed contains:
265265
{'test_50.py::test_num[17]': True,
266266
'test_50.py::test_num[25]': True,
@@ -277,8 +277,25 @@ You can always peek at the content of the cache using the
277277
278278
======================= no tests ran in 0.12 seconds =======================
279279
280+
``--cache-show`` takes an optional argument to specify a glob pattern for
281+
filtering:
282+
283+
.. code-block:: pytest
284+
285+
$ pytest --cache-show example/*
286+
=========================== test session starts ============================
287+
platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y
288+
cachedir: $PYTHON_PREFIX/.pytest_cache
289+
rootdir: $REGENDOC_TMPDIR
290+
cachedir: $PYTHON_PREFIX/.pytest_cache
291+
----------------------- cache values for 'example/*' -----------------------
292+
example/value contains:
293+
42
294+
295+
======================= no tests ran in 0.12 seconds =======================
296+
280297
Clearing Cache content
281-
-------------------------------
298+
----------------------
282299

283300
You can instruct pytest to clear all cache files and values
284301
by adding the ``--cache-clear`` option like this:

0 commit comments

Comments
 (0)