Skip to content

Commit 38adb23

Browse files
authored
Merge pull request #4600 from nicoddemus/release-4.1.0
Release 4.1.0
2 parents e815220 + e24031f commit 38adb23

Some content is hidden

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

90 files changed

+2176
-2917
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ coverage.xml
4444
.pydevproject
4545
.project
4646
.settings
47+
.vscode

AUTHORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ Alan Velasco
1212
Alexander Johnson
1313
Alexei Kozlenok
1414
Allan Feldman
15+
Aly Sivji
1516
Anatoly Bubenkoff
1617
Anders Hovmöller
1718
Andras Tim
1819
Andrea Cimatoribus
1920
Andreas Zeidler
21+
Andrey Paramonov
2022
Andrzej Ostrowski
2123
Andy Freeland
2224
Anthon van der Neut
@@ -165,6 +167,7 @@ Miro Hrončok
165167
Nathaniel Waisbrot
166168
Ned Batchelder
167169
Neven Mundar
170+
Nicholas Devenish
168171
Niclas Olofsson
169172
Nicolas Delaby
170173
Oleg Pidsadnyi

CHANGELOG.rst

Lines changed: 227 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,232 @@ with advance notice in the **Deprecations** section of releases.
1818
1919
.. towncrier release notes start
2020
21+
pytest 4.1.0 (2019-01-05)
22+
=========================
23+
24+
Removals
25+
--------
26+
27+
- `#2169 <https://github.com/pytest-dev/pytest/issues/2169>`_: ``pytest.mark.parametrize``: in previous versions, errors raised by id functions were suppressed and changed into warnings. Now the exceptions are propagated, along with a pytest message informing the node, parameter value and index where the exception occurred.
28+
29+
30+
- `#3078 <https://github.com/pytest-dev/pytest/issues/3078>`_: Remove legacy internal warnings system: ``config.warn``, ``Node.warn``. The ``pytest_logwarning`` now issues a warning when implemented.
31+
32+
See our `docs <https://docs.pytest.org/en/latest/deprecations.html#config-warn-and-node-warn>`__ on information on how to update your code.
33+
34+
35+
- `#3079 <https://github.com/pytest-dev/pytest/issues/3079>`_: Removed support for yield tests - they are fundamentally broken because they don't support fixtures properly since collection and test execution were separated.
36+
37+
See our `docs <https://docs.pytest.org/en/latest/deprecations.html#yield-tests>`__ on information on how to update your code.
38+
39+
40+
- `#3082 <https://github.com/pytest-dev/pytest/issues/3082>`_: Removed support for applying marks directly to values in ``@pytest.mark.parametrize``. Use ``pytest.param`` instead.
41+
42+
See our `docs <https://docs.pytest.org/en/latest/deprecations.html#marks-in-pytest-mark-parametrize>`__ on information on how to update your code.
43+
44+
45+
- `#3083 <https://github.com/pytest-dev/pytest/issues/3083>`_: Removed ``Metafunc.addcall``. This was the predecessor mechanism to ``@pytest.mark.parametrize``.
46+
47+
See our `docs <https://docs.pytest.org/en/latest/deprecations.html#metafunc-addcall>`__ on information on how to update your code.
48+
49+
50+
- `#3085 <https://github.com/pytest-dev/pytest/issues/3085>`_: Removed support for passing strings to ``pytest.main``. Now, always pass a list of strings instead.
51+
52+
See our `docs <https://docs.pytest.org/en/latest/deprecations.html#passing-command-line-string-to-pytest-main>`__ on information on how to update your code.
53+
54+
55+
- `#3086 <https://github.com/pytest-dev/pytest/issues/3086>`_: ``[pytest]`` section in **setup.cfg** files is not longer supported, use ``[tool:pytest]`` instead. ``setup.cfg`` files
56+
are meant for use with ``distutils``, and a section named ``pytest`` has notoriously been a source of conflicts and bugs.
57+
58+
Note that for **pytest.ini** and **tox.ini** files the section remains ``[pytest]``.
59+
60+
61+
- `#3616 <https://github.com/pytest-dev/pytest/issues/3616>`_: Removed the deprecated compat properties for ``node.Class/Function/Module`` - use ``pytest.Class/Function/Module`` now.
62+
63+
See our `docs <https://docs.pytest.org/en/latest/deprecations.html#internal-classes-accessed-through-node>`__ on information on how to update your code.
64+
65+
66+
- `#4421 <https://github.com/pytest-dev/pytest/issues/4421>`_: Removed the implementation of the ``pytest_namespace`` hook.
67+
68+
See our `docs <https://docs.pytest.org/en/latest/deprecations.html#pytest-namespace>`__ on information on how to update your code.
69+
70+
71+
- `#4489 <https://github.com/pytest-dev/pytest/issues/4489>`_: Removed ``request.cached_setup``. This was the predecessor mechanism to modern fixtures.
72+
73+
See our `docs <https://docs.pytest.org/en/latest/deprecations.html#cached-setup>`__ on information on how to update your code.
74+
75+
76+
- `#4535 <https://github.com/pytest-dev/pytest/issues/4535>`_: Removed the deprecated ``PyCollector.makeitem`` method. This method was made public by mistake a long time ago.
77+
78+
79+
- `#4543 <https://github.com/pytest-dev/pytest/issues/4543>`_: Removed support to define fixtures using the ``pytest_funcarg__`` prefix. Use the ``@pytest.fixture`` decorator instead.
80+
81+
See our `docs <https://docs.pytest.org/en/latest/deprecations.html#pytest-funcarg-prefix>`__ on information on how to update your code.
82+
83+
84+
- `#4545 <https://github.com/pytest-dev/pytest/issues/4545>`_: Calling fixtures directly is now always an error instead of a warning.
85+
86+
See our `docs <https://docs.pytest.org/en/latest/deprecations.html#calling-fixtures-directly>`__ on information on how to update your code.
87+
88+
89+
- `#4546 <https://github.com/pytest-dev/pytest/issues/4546>`_: Remove ``Node.get_marker(name)`` the return value was not usable for more than a existence check.
90+
91+
Use ``Node.get_closest_marker(name)`` as a replacement.
92+
93+
94+
- `#4547 <https://github.com/pytest-dev/pytest/issues/4547>`_: The deprecated ``record_xml_property`` fixture has been removed, use the more generic ``record_property`` instead.
95+
96+
See our `docs <https://docs.pytest.org/en/latest/deprecations.html#record-xml-property>`__ for more information.
97+
98+
99+
- `#4548 <https://github.com/pytest-dev/pytest/issues/4548>`_: An error is now raised if the ``pytest_plugins`` variable is defined in a non-top-level ``conftest.py`` file (i.e., not residing in the ``rootdir``).
100+
101+
See our `docs <https://docs.pytest.org/en/latest/deprecations.html#pytest-plugins-in-non-top-level-conftest-files>`__ for more information.
102+
103+
104+
- `#891 <https://github.com/pytest-dev/pytest/issues/891>`_: Remove ``testfunction.markername`` attributes - use ``Node.iter_markers(name=None)`` to iterate them.
105+
106+
107+
108+
Deprecations
109+
------------
110+
111+
- `#3050 <https://github.com/pytest-dev/pytest/issues/3050>`_: Deprecated the ``pytest.config`` global.
112+
113+
See https://docs.pytest.org/en/latest/deprecations.html#pytest-config-global for rationale.
114+
115+
116+
- `#3974 <https://github.com/pytest-dev/pytest/issues/3974>`_: Passing the ``message`` parameter of ``pytest.raises`` now issues a ``DeprecationWarning``.
117+
118+
It is a common mistake to think this parameter will match the exception message, while in fact
119+
it only serves to provide a custom message in case the ``pytest.raises`` check fails. To avoid this
120+
mistake and because it is believed to be little used, pytest is deprecating it without providing
121+
an alternative for the moment.
122+
123+
If you have concerns about this, please comment on `issue #3974 <https://github.com/pytest-dev/pytest/issues/3974>`__.
124+
125+
126+
- `#4435 <https://github.com/pytest-dev/pytest/issues/4435>`_: Deprecated ``raises(..., 'code(as_a_string)')`` and ``warns(..., 'code(as_a_string)')``.
127+
128+
See https://docs.pytest.org/en/latest/deprecations.html#raises-warns-exec for rationale and examples.
129+
130+
131+
132+
Features
133+
--------
134+
135+
- `#3191 <https://github.com/pytest-dev/pytest/issues/3191>`_: A warning is now issued when assertions are made for ``None``.
136+
137+
This is a common source of confusion among new users, which write:
138+
139+
.. code-block:: python
140+
141+
assert mocked_object.assert_called_with(3, 4, 5, key="value")
142+
143+
When they should write:
144+
145+
.. code-block:: python
146+
147+
mocked_object.assert_called_with(3, 4, 5, key="value")
148+
149+
Because the ``assert_called_with`` method of mock objects already executes an assertion.
150+
151+
This warning will not be issued when ``None`` is explicitly checked. An assertion like:
152+
153+
.. code-block:: python
154+
155+
assert variable is None
156+
157+
will not issue the warning.
158+
159+
160+
- `#3632 <https://github.com/pytest-dev/pytest/issues/3632>`_: Richer equality comparison introspection on ``AssertionError`` for objects created using `attrs <http://www.attrs.org/en/stable/>`__ or `dataclasses <https://docs.python.org/3/library/dataclasses.html>`_ (Python 3.7+, `backported to 3.6 <https://pypi.org/project/dataclasses>`__).
161+
162+
163+
- `#4278 <https://github.com/pytest-dev/pytest/issues/4278>`_: ``CACHEDIR.TAG`` files are now created inside cache directories.
164+
165+
Those files are part of the `Cache Directory Tagging Standard <http://www.bford.info/cachedir/spec.html>`__, and can
166+
be used by backup or synchronization programs to identify pytest's cache directory as such.
167+
168+
169+
- `#4292 <https://github.com/pytest-dev/pytest/issues/4292>`_: ``pytest.outcomes.Exit`` is derived from ``SystemExit`` instead of ``KeyboardInterrupt``. This allows us to better handle ``pdb`` exiting.
170+
171+
172+
- `#4371 <https://github.com/pytest-dev/pytest/issues/4371>`_: Updated the ``--collect-only`` option to display test descriptions when ran using ``--verbose``.
173+
174+
175+
- `#4386 <https://github.com/pytest-dev/pytest/issues/4386>`_: Restructured ``ExceptionInfo`` object construction and ensure incomplete instances have a ``repr``/``str``.
176+
177+
178+
- `#4416 <https://github.com/pytest-dev/pytest/issues/4416>`_: pdb: added support for keyword arguments with ``pdb.set_trace``.
179+
180+
It handles ``header`` similar to Python 3.7 does it, and forwards any
181+
other keyword arguments to the ``Pdb`` constructor.
182+
183+
This allows for ``__import__("pdb").set_trace(skip=["foo.*"])``.
184+
185+
186+
- `#4483 <https://github.com/pytest-dev/pytest/issues/4483>`_: Added ini parameter ``junit_duration_report`` to optionally report test call durations, excluding setup and teardown times.
187+
188+
The JUnit XML specification and the default pytest behavior is to include setup and teardown times in the test duration
189+
report. You can include just the call durations instead (excluding setup and teardown) by adding this to your ``pytest.ini`` file:
190+
191+
.. code-block:: ini
192+
193+
[pytest]
194+
junit_duration_report = call
195+
196+
197+
- `#4532 <https://github.com/pytest-dev/pytest/issues/4532>`_: ``-ra`` now will show errors and failures last, instead of as the first items in the summary.
198+
199+
This makes it easier to obtain a list of errors and failures to run tests selectively.
200+
201+
202+
- `#4599 <https://github.com/pytest-dev/pytest/issues/4599>`_: ``pytest.importorskip`` now supports a ``reason`` parameter, which will be shown when the
203+
requested module cannot be imported.
204+
205+
206+
207+
Bug Fixes
208+
---------
209+
210+
- `#3532 <https://github.com/pytest-dev/pytest/issues/3532>`_: ``-p`` now accepts its argument without a space between the value, for example ``-pmyplugin``.
211+
212+
213+
- `#4327 <https://github.com/pytest-dev/pytest/issues/4327>`_: ``approx`` again works with more generic containers, more precisely instances of ``Iterable`` and ``Sized`` instead of more restrictive ``Sequence``.
214+
215+
216+
- `#4397 <https://github.com/pytest-dev/pytest/issues/4397>`_: Ensure that node ids are printable.
217+
218+
219+
- `#4435 <https://github.com/pytest-dev/pytest/issues/4435>`_: Fixed ``raises(..., 'code(string)')`` frame filename.
220+
221+
222+
- `#4458 <https://github.com/pytest-dev/pytest/issues/4458>`_: Display actual test ids in ``--collect-only``.
223+
224+
225+
226+
Improved Documentation
227+
----------------------
228+
229+
- `#4557 <https://github.com/pytest-dev/pytest/issues/4557>`_: Markers example documentation page updated to support latest pytest version.
230+
231+
232+
- `#4558 <https://github.com/pytest-dev/pytest/issues/4558>`_: Update cache documentation example to correctly show cache hit and miss.
233+
234+
235+
- `#4580 <https://github.com/pytest-dev/pytest/issues/4580>`_: Improved detailed summary report documentation.
236+
237+
238+
239+
Trivial/Internal Changes
240+
------------------------
241+
242+
- `#4447 <https://github.com/pytest-dev/pytest/issues/4447>`_: Changed the deprecation type of ``--result-log`` to ``PytestDeprecationWarning``.
243+
244+
It was decided to remove this feature at the next major revision.
245+
246+
21247
pytest 4.0.2 (2018-12-13)
22248
=========================
23249

@@ -1757,7 +1983,7 @@ Bug Fixes
17571983
Trivial/Internal Changes
17581984
------------------------
17591985

1760-
- pytest now depends on `attrs <https://pypi.org/project/attrs/>`_ for internal
1986+
- pytest now depends on `attrs <https://pypi.org/project/attrs/>`__ for internal
17611987
structures to ease code maintainability. (`#2641
17621988
<https://github.com/pytest-dev/pytest/issues/2641>`_)
17631989

changelog/4557.doc.rst

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

changelog/4558.doc.rst

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

changelog/4580.doc.rst

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

doc/en/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ clean:
3939
-rm -rf $(BUILDDIR)/*
4040

4141
regen:
42-
PYTHONDONTWRITEBYTECODE=1 PYTEST_ADDOPT=-pno:hypothesis COLUMNS=76 regendoc --update *.rst */*.rst ${REGENDOC_ARGS}
42+
PYTHONDONTWRITEBYTECODE=1 PYTEST_ADDOPTS=-pno:hypothesis COLUMNS=76 regendoc --update *.rst */*.rst ${REGENDOC_ARGS}
4343

4444
html:
4545
$(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.1.0
910
release-4.0.2
1011
release-4.0.1
1112
release-4.0.0

doc/en/announce/release-4.1.0.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
pytest-4.1.0
2+
=======================================
3+
4+
The pytest team is proud to announce the 4.1.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+
* Adam Johnson
25+
* Aly Sivji
26+
* Andrey Paramonov
27+
* Anthony Sottile
28+
* Bruno Oliveira
29+
* Daniel Hahler
30+
* David Vo
31+
* Hyunchel Kim
32+
* Jeffrey Rackauckas
33+
* Kanguros
34+
* Nicholas Devenish
35+
* Pedro Algarvio
36+
* Randy Barlow
37+
* Ronny Pfannschmidt
38+
* Tomer Keren
39+
* feuillemorte
40+
* wim glenn
41+
42+
43+
Happy testing,
44+
The Pytest Development Team

doc/en/assert.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,9 @@ If you want to write test code that works on Python 2.4 as well,
100100
you may also use two other ways to test for an expected exception::
101101

102102
pytest.raises(ExpectedException, func, *args, **kwargs)
103-
pytest.raises(ExpectedException, "func(*args, **kwargs)")
104103

105-
both of which execute the specified function with args and kwargs and
106-
asserts that the given ``ExpectedException`` is raised. The reporter will
104+
which will execute the specified function with args and kwargs and
105+
assert that the given ``ExpectedException`` is raised. The reporter will
107106
provide you with helpful output in case of failures such as *no
108107
exception* or *wrong exception*.
109108

doc/en/builtin.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
6868
6969
def test_function(record_property):
7070
record_property("example_key", 1)
71-
record_xml_property
72-
(Deprecated) use record_property.
7371
record_xml_attribute
7472
Add extra xml attributes to the tag for the calling test.
7573
The fixture is callable with ``(name, value)``, with value being

doc/en/cache.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ If you run this command for the first time, you can see the print statement:
215215
> assert mydata == 23
216216
E assert 42 == 23
217217
218-
test_caching.py:14: AssertionError
218+
test_caching.py:17: AssertionError
219+
-------------------------- Captured stdout setup ---------------------------
220+
running expensive computation...
219221
1 failed in 0.12 seconds
220222
221223
If you run it a second time the value will be retrieved from
@@ -234,7 +236,7 @@ the cache and nothing will be printed:
234236
> assert mydata == 23
235237
E assert 42 == 23
236238
237-
test_caching.py:14: AssertionError
239+
test_caching.py:17: AssertionError
238240
1 failed in 0.12 seconds
239241
240242
See the :ref:`cache-api` for more details.

0 commit comments

Comments
 (0)