Skip to content

Commit 4947eb8

Browse files
authored
Merge pull request #4645 from blueyed/merge-master-into-features
Merge master into features
2 parents 5bb0be1 + 1a358df commit 4947eb8

23 files changed

+278
-66
lines changed

.github/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rtd:
2+
project: pytest

AUTHORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Andy Freeland
2424
Anthon van der Neut
2525
Anthony Shaw
2626
Anthony Sottile
27+
Anton Lodder
2728
Antony Lee
2829
Armin Rigo
2930
Aron Coyle
@@ -176,6 +177,7 @@ Oliver Bestwalter
176177
Omar Kohl
177178
Omer Hadari
178179
Ondřej Súkup
180+
Oscar Benjamin
179181
Patrick Hayes
180182
Paweł Adamczak
181183
Pedro Algarvio

CHANGELOG.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,38 @@ with advance notice in the **Deprecations** section of releases.
1818
1919
.. towncrier release notes start
2020
21+
pytest 4.1.1 (2019-01-12)
22+
=========================
23+
24+
Bug Fixes
25+
---------
26+
27+
- `#2256 <https://github.com/pytest-dev/pytest/issues/2256>`_: Show full repr with ``assert a==b`` and ``-vv``.
28+
29+
30+
- `#3456 <https://github.com/pytest-dev/pytest/issues/3456>`_: Extend Doctest-modules to ignore mock objects.
31+
32+
33+
- `#4617 <https://github.com/pytest-dev/pytest/issues/4617>`_: Fixed ``pytest.warns`` bug when context manager is reused (e.g. multiple parametrization).
34+
35+
36+
- `#4631 <https://github.com/pytest-dev/pytest/issues/4631>`_: Don't rewrite assertion when ``__getattr__`` is broken
37+
38+
39+
40+
Improved Documentation
41+
----------------------
42+
43+
- `#3375 <https://github.com/pytest-dev/pytest/issues/3375>`_: Document that using ``setup.cfg`` may crash other tools or cause hard to track down problems because it uses a different parser than ``pytest.ini`` or ``tox.ini`` files.
44+
45+
46+
47+
Trivial/Internal Changes
48+
------------------------
49+
50+
- `#4602 <https://github.com/pytest-dev/pytest/issues/4602>`_: Uninstall ``hypothesis`` in regen tox env.
51+
52+
2153
pytest 4.1.0 (2019-01-05)
2254
=========================
2355

changelog/4602.trivial.rst

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

changelog/4617.bugfix.rst

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

changelog/4643.trivial.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Use ``a.item()`` instead of the deprecated ``np.asscalar(a)`` in ``pytest.approx``.
2+
3+
``np.asscalar`` has been `deprecated <https://github.com/numpy/numpy/blob/master/doc/release/1.16.0-notes.rst#new-deprecations>`__ in ``numpy 1.16.``.

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.1
910
release-4.1.0
1011
release-4.0.2
1112
release-4.0.1

doc/en/announce/release-4.1.1.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
pytest-4.1.1
2+
=======================================
3+
4+
pytest 4.1.1 has just been released to PyPI.
5+
6+
This is a bug-fix release, being a drop-in replacement. To upgrade::
7+
8+
pip install --upgrade pytest
9+
10+
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
11+
12+
Thanks to all who contributed to this release, among them:
13+
14+
* Anthony Sottile
15+
* Anton Lodder
16+
* Bruno Oliveira
17+
* Daniel Hahler
18+
* David Vo
19+
* Oscar Benjamin
20+
* Ronny Pfannschmidt
21+
* Victor Maryama
22+
* Yoav Caspi
23+
* dmitry.dygalo
24+
25+
26+
Happy testing,
27+
The pytest Development Team

doc/en/cache.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ If you run this command for the first time, you can see the print statement:
214214
def test_function(mydata):
215215
> assert mydata == 23
216216
E assert 42 == 23
217+
E -42
218+
E +23
217219
218220
test_caching.py:17: AssertionError
219221
-------------------------- Captured stdout setup ---------------------------
@@ -235,6 +237,8 @@ the cache and nothing will be printed:
235237
def test_function(mydata):
236238
> assert mydata == 23
237239
E assert 42 == 23
240+
E -42
241+
E +23
238242
239243
test_caching.py:17: AssertionError
240244
1 failed in 0.12 seconds

doc/en/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@
4242
extensions = [
4343
"pygments_pytest",
4444
"sphinx.ext.autodoc",
45-
"sphinx.ext.todo",
4645
"sphinx.ext.autosummary",
4746
"sphinx.ext.intersphinx",
47+
"sphinx.ext.todo",
4848
"sphinx.ext.viewcode",
49+
"sphinx_removed_in",
4950
"sphinxcontrib_trio",
5051
]
5152

doc/en/deprecations.rst

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ an appropriate period of deprecation has passed.
101101
Using ``Class`` in custom Collectors
102102
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
103103

104-
*Removed in version 4.0.*
104+
.. versionremoved:: 4.0
105105

106106
Using objects named ``"Class"`` as a way to customize the type of nodes that are collected in ``Collector``
107107
subclasses has been deprecated. Users instead should use ``pytest_pycollect_makeitem`` to customize node types during
@@ -114,7 +114,7 @@ message please contact the authors so they can change the code.
114114
marks in ``pytest.mark.parametrize``
115115
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116116

117-
*Removed in version 4.0.*
117+
.. versionremoved:: 4.0
118118

119119
Applying marks to values of a ``pytest.mark.parametrize`` call is now deprecated. For example:
120120

@@ -162,7 +162,7 @@ To update the code, use ``pytest.param``:
162162
``pytest_funcarg__`` prefix
163163
~~~~~~~~~~~~~~~~~~~~~~~~~~~
164164

165-
*Removed in version 4.0.*
165+
.. versionremoved:: 4.0
166166

167167
In very early pytest versions fixtures could be defined using the ``pytest_funcarg__`` prefix:
168168

@@ -184,7 +184,7 @@ Switch over to the ``@pytest.fixture`` decorator:
184184
[pytest] section in setup.cfg files
185185
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
186186

187-
*Removed in version 4.0.*
187+
.. versionremoved:: 4.0
188188

189189
``[pytest]`` sections in ``setup.cfg`` files should now be named ``[tool:pytest]``
190190
to avoid conflicts with other distutils commands.
@@ -193,7 +193,7 @@ to avoid conflicts with other distutils commands.
193193
Metafunc.addcall
194194
~~~~~~~~~~~~~~~~
195195

196-
*Removed in version 4.0.*
196+
.. versionremoved:: 4.0
197197

198198
:meth:`_pytest.python.Metafunc.addcall` was a precursor to the current parametrized mechanism. Users should use
199199
:meth:`_pytest.python.Metafunc.parametrize` instead.
@@ -217,7 +217,7 @@ Becomes:
217217
``cached_setup``
218218
~~~~~~~~~~~~~~~~
219219

220-
*Removed in version 4.0.*
220+
.. versionremoved:: 4.0
221221

222222
``request.cached_setup`` was the precursor of the setup/teardown mechanism available to fixtures.
223223

@@ -249,7 +249,7 @@ more information.
249249
pytest_plugins in non-top-level conftest files
250250
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
251251

252-
*Removed in version 4.0.*
252+
.. versionremoved:: 4.0
253253

254254
Defining ``pytest_plugins`` is now deprecated in non-top-level conftest.py
255255
files because they will activate referenced plugins *globally*, which is surprising because for all other pytest
@@ -259,7 +259,7 @@ features ``conftest.py`` files are only *active* for tests at or below it.
259259
``Config.warn`` and ``Node.warn``
260260
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
261261

262-
*Removed in version 4.0.*
262+
.. versionremoved:: 4.0
263263

264264
Those methods were part of the internal pytest warnings system, but since ``3.8`` pytest is using the builtin warning
265265
system for its own warnings, so those two functions are now deprecated.
@@ -286,7 +286,7 @@ Becomes:
286286
record_xml_property
287287
~~~~~~~~~~~~~~~~~~~
288288

289-
*Removed in version 4.0.*
289+
.. versionremoved:: 4.0
290290

291291
The ``record_xml_property`` fixture is now deprecated in favor of the more generic ``record_property``, which
292292
can be used by other consumers (for example ``pytest-html``) to obtain custom information about the test run.
@@ -309,7 +309,7 @@ Change to:
309309
Passing command-line string to ``pytest.main()``
310310
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
311311

312-
*Removed in version 4.0.*
312+
.. versionremoved:: 4.0
313313

314314
Passing a command-line string to ``pytest.main()`` is deprecated:
315315

@@ -331,7 +331,7 @@ on (for example ``bash`` or ``Powershell``), but this is very hard/impossible to
331331
Calling fixtures directly
332332
~~~~~~~~~~~~~~~~~~~~~~~~~
333333

334-
*Removed in version 4.0.*
334+
.. versionremoved:: 4.0
335335

336336
Calling a fixture function directly, as opposed to request them in a test function, is deprecated.
337337

@@ -384,7 +384,7 @@ with the ``name`` parameter:
384384
``yield`` tests
385385
~~~~~~~~~~~~~~~
386386

387-
*Removed in version 4.0.*
387+
.. versionremoved:: 4.0
388388

389389
pytest supported ``yield``-style tests, where a test function actually ``yield`` functions and values
390390
that are then turned into proper test methods. Example:
@@ -412,7 +412,7 @@ This form of test function doesn't support fixtures properly, and users should s
412412
Internal classes accessed through ``Node``
413413
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
414414

415-
*Removed in version 4.0.*
415+
.. versionremoved:: 4.0
416416

417417
Access of ``Module``, ``Function``, ``Class``, ``Instance``, ``File`` and ``Item`` through ``Node`` instances now issue
418418
this warning::
@@ -423,10 +423,28 @@ Users should just ``import pytest`` and access those objects using the ``pytest`
423423

424424
This has been documented as deprecated for years, but only now we are actually emitting deprecation warnings.
425425

426+
``Node.get_marker``
427+
~~~~~~~~~~~~~~~~~~~
428+
429+
.. versionremoved:: 4.0
430+
431+
As part of a large :ref:`marker-revamp`, :meth:`_pytest.nodes.Node.get_marker` is deprecated. See
432+
:ref:`the documentation <update marker code>` on tips on how to update your code.
433+
434+
435+
``somefunction.markname``
436+
~~~~~~~~~~~~~~~~~~~~~~~~~
437+
438+
.. versionremoved:: 4.0
439+
440+
As part of a large :ref:`marker-revamp` we already deprecated using ``MarkInfo``
441+
the only correct way to get markers of an element is via ``node.iter_markers(name)``.
442+
443+
426444
``pytest_namespace``
427445
~~~~~~~~~~~~~~~~~~~~
428446

429-
*Removed in version 4.0.*
447+
.. versionremoved:: 4.0
430448

431449
This hook is deprecated because it greatly complicates the pytest internals regarding configuration and initialization, making some
432450
bug fixes and refactorings impossible.
@@ -461,7 +479,7 @@ As a stopgap measure, plugin authors may still inject their names into pytest's
461479
Reinterpretation mode (``--assert=reinterp``)
462480
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
463481

464-
*Removed in version 3.0.*
482+
.. versionremoved:: 3.0
465483

466484
Reinterpretation mode has now been removed and only plain and rewrite
467485
mode are available, consequently the ``--assert=reinterp`` option is
@@ -473,7 +491,7 @@ explicitly turn on assertion rewriting for those files.
473491
Removed command-line options
474492
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
475493

476-
*Removed in version 3.0.*
494+
.. versionremoved:: 3.0
477495

478496
The following deprecated commandline options were removed:
479497

@@ -485,27 +503,9 @@ The following deprecated commandline options were removed:
485503
py.test-X* entry points
486504
~~~~~~~~~~~~~~~~~~~~~~~
487505

488-
*Removed in version 3.0.*
506+
.. versionremoved:: 3.0
489507

490508
Removed all ``py.test-X*`` entry points. The versioned, suffixed entry points
491509
were never documented and a leftover from a pre-virtualenv era. These entry
492510
points also created broken entry points in wheels, so removing them also
493511
removes a source of confusion for users.
494-
495-
496-
``Node.get_marker``
497-
~~~~~~~~~~~~~~~~~~~
498-
499-
*Removed in version 4.0*
500-
501-
As part of a large :ref:`marker-revamp`, :meth:`_pytest.nodes.Node.get_marker` is deprecated. See
502-
:ref:`the documentation <update marker code>` on tips on how to update your code.
503-
504-
505-
``somefunction.markname``
506-
~~~~~~~~~~~~~~~~~~~~~~~~~
507-
508-
*Removed in version 4.0*
509-
510-
As part of a large :ref:`marker-revamp` we already deprecated using ``MarkInfo``
511-
the only correct way to get markers of an element is via ``node.iter_markers(name)``.

doc/en/example/parametrize.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ argument sets to use for each test function. Let's run it:
406406
def test_equals(self, a, b):
407407
> assert a == b
408408
E assert 1 == 2
409+
E -1
410+
E +2
409411
410412
test_parametrize.py:18: AssertionError
411413
1 failed, 2 passed in 0.12 seconds

doc/en/goodpractices.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,18 @@ to keep tests separate from actual application code (often a good idea)::
7272
test_view.py
7373
...
7474

75-
This way your tests can run easily against an installed version
76-
of ``mypkg``.
75+
This has the following benefits:
76+
77+
* Your tests can run against an installed version after executing ``pip install .``.
78+
* Your tests can run against the local copy with an editable install after executing ``pip install --editable .``.
79+
* If you don't have a ``setup.py`` file and are relying on the fact that Python by default puts the current
80+
directory in ``sys.path`` to import your package, you can execute ``python -m pytest`` to execute the tests against the
81+
local copy directly, without using ``pip``.
82+
83+
.. note::
84+
85+
See :ref:`pythonpath` for more information about the difference between calling ``pytest`` and
86+
``python -m pytest``.
7787

7888
Note that using this scheme your test files must have **unique names**, because
7989
``pytest`` will import them as *top-level* modules since there are no packages

doc/en/reference.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,12 @@ Here is a list of builtin configuration options that may be written in a ``pytes
889889
file, usually located at the root of your repository. All options must be under a ``[pytest]`` section
890890
(``[tool:pytest]`` for ``setup.cfg`` files).
891891

892+
.. warning::
893+
Usage of ``setup.cfg`` is not recommended unless for very simple use cases. ``.cfg``
894+
files use a different parser than ``pytest.ini`` and ``tox.ini`` which might cause hard to track
895+
down problems.
896+
When possible, it is recommended to use the latter files to hold your pytest configuration.
897+
892898
Configuration file options may be overwritten in the command-line by using ``-o/--override``, which can also be
893899
passed multiple times. The expected format is ``name=value``. For example::
894900

doc/en/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pygments-pytest>=1.1.0
22
sphinx>=1.8.2
33
sphinxcontrib-trio
4+
sphinx-removed-in>=0.1.3

src/_pytest/assertion/rewrite.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,13 @@ def _format_assertmsg(obj):
512512

513513

514514
def _should_repr_global_name(obj):
515-
return not hasattr(obj, "__name__") and not callable(obj)
515+
if callable(obj):
516+
return False
517+
518+
try:
519+
return not hasattr(obj, "__name__")
520+
except Exception:
521+
return True
516522

517523

518524
def _format_boolop(explanations, is_or):

0 commit comments

Comments
 (0)