Skip to content

Commit a2d4833

Browse files
authored
Merge pull request #6201 from asottile/mm
Merge master into features
2 parents bac6eeb + cc78444 commit a2d4833

File tree

16 files changed

+141
-26
lines changed

16 files changed

+141
-26
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
Thanks for submitting a PR, your contribution is really appreciated!
33
44
Here is a quick checklist that should be present in PRs.
5-
(please delete this text from the final description, this is just a guideline)
6-
-->
75
86
- [ ] Target the `master` branch for bug fixes, documentation updates and trivial changes.
97
- [ ] Target the `features` branch for new features, improvements, and removals/deprecations.
108
- [ ] Include documentation when adding new features.
119
- [ ] Include new tests or update existing tests when applicable.
1210
13-
Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:
11+
Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:
1412
1513
- [ ] Create a new changelog file in the `changelog` folder, with a name like `<ISSUE NUMBER>.<TYPE>.rst`. See [changelog/README.rst](https://github.com/pytest-dev/pytest/blob/master/changelog/README.rst) for details.
16-
- [ ] Add yourself to `AUTHORS` in alphabetical order;
14+
- [ ] Add yourself to `AUTHORS` in alphabetical order.
15+
-->

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Daniel Hahler
7070
Daniel Nuri
7171
Daniel Wandschneider
7272
Danielle Jenkins
73+
Daniil Galiev
7374
Dave Hunt
7475
David Díaz-Barquero
7576
David Mohr

CHANGELOG.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,34 @@ with advance notice in the **Deprecations** section of releases.
1818
1919
.. towncrier release notes start
2020
21+
pytest 5.2.4 (2019-11-15)
22+
=========================
23+
24+
Bug Fixes
25+
---------
26+
27+
- `#6194 <https://github.com/pytest-dev/pytest/issues/6194>`_: Fix incorrect discovery of non-test ``__init__.py`` files.
28+
29+
30+
- `#6197 <https://github.com/pytest-dev/pytest/issues/6197>`_: Revert "The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped.".
31+
32+
33+
pytest 5.2.3 (2019-11-14)
34+
=========================
35+
36+
Bug Fixes
37+
---------
38+
39+
- `#5830 <https://github.com/pytest-dev/pytest/issues/5830>`_: The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped.
40+
41+
42+
- `#6099 <https://github.com/pytest-dev/pytest/issues/6099>`_: Fix ``--trace`` when used with parametrized functions.
43+
44+
45+
- `#6183 <https://github.com/pytest-dev/pytest/issues/6183>`_: Using ``request`` as a parameter name in ``@pytest.mark.parametrize`` now produces a more
46+
user-friendly error.
47+
48+
2149
pytest 5.2.2 (2019-10-24)
2250
=========================
2351

changelog/6099.bugfix.rst

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

doc/en/announce/index.rst

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

88

9+
release-5.2.4
10+
release-5.2.3
911
release-5.2.2
1012
release-5.2.1
1113
release-5.2.0

doc/en/announce/release-5.2.3.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
pytest-5.2.3
2+
=======================================
3+
4+
pytest 5.2.3 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+
* Brett Cannon
16+
* Bruno Oliveira
17+
* Daniel Hahler
18+
* Daniil Galiev
19+
* David Szotten
20+
* Florian Bruhin
21+
* Patrick Harmon
22+
* Ran Benita
23+
* Zac Hatfield-Dodds
24+
* Zak Hassan
25+
26+
27+
Happy testing,
28+
The pytest Development Team

doc/en/announce/release-5.2.4.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
pytest-5.2.4
2+
=======================================
3+
4+
pytest 5.2.4 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+
* Bruno Oliveira
16+
* Daniel Hahler
17+
* Hugo
18+
* Michael Shields
19+
20+
21+
Happy testing,
22+
The pytest Development Team

doc/en/example/parametrize.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,11 +475,10 @@ Running it results in some skips if we don't have all the python interpreters in
475475
.. code-block:: pytest
476476
477477
. $ pytest -rs -q multipython.py
478-
ssssssssssssssssssssssss... [100%]
478+
ssssssssssss......sss...... [100%]
479479
========================= short test summary info ==========================
480-
SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.5' not found
481-
SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.6' not found
482-
3 passed, 24 skipped in 0.12s
480+
SKIPPED [15] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.5' not found
481+
12 passed, 15 skipped in 0.12s
483482
484483
Indirect parametrization of optional implementations/imports
485484
--------------------------------------------------------------------

doc/en/example/reportingdemo.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
436436
items = [1, 2, 3]
437437
print("items is {!r}".format(items))
438438
> a, b = items.pop()
439-
E TypeError: cannot unpack non-iterable int object
439+
E TypeError: 'int' object is not iterable
440440
441441
failure_demo.py:181: TypeError
442442
--------------------------- Captured stdout call ---------------------------
@@ -516,7 +516,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
516516
def test_z2_type_error(self):
517517
items = 3
518518
> a, b = items
519-
E TypeError: cannot unpack non-iterable int object
519+
E TypeError: 'int' object is not iterable
520520
521521
failure_demo.py:222: TypeError
522522
______________________ TestMoreErrors.test_startswith ______________________

doc/en/example/simple.rst

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -302,34 +302,31 @@ running from a test you can do something like this:
302302

303303
.. code-block:: python
304304
305-
# content of conftest.py
305+
# content of your_module.py
306306
307307
308-
def pytest_configure(config):
309-
import sys
308+
_called_from_test = False
310309
311-
sys._called_from_test = True
310+
.. code-block:: python
312311
312+
# content of conftest.py
313313
314-
def pytest_unconfigure(config):
315-
import sys
316314
317-
del sys._called_from_test
315+
def pytest_configure(config):
316+
your_module._called_from_test = True
318317
319-
and then check for the ``sys._called_from_test`` flag:
318+
and then check for the ``your_module._called_from_test`` flag:
320319

321320
.. code-block:: python
322321
323-
if hasattr(sys, "_called_from_test"):
322+
if your_module._called_from_test:
324323
# called from within a test run
325324
...
326325
else:
327326
# called "normally"
328327
...
329328
330-
accordingly in your application. It's also a good idea
331-
to use your own application module rather than ``sys``
332-
for handling flag.
329+
accordingly in your application.
333330

334331
Adding info to test report header
335332
--------------------------------------------------------------

doc/en/getting-started.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Install ``pytest``
2828
.. code-block:: bash
2929
3030
$ pytest --version
31-
This is pytest version 5.x.y, imported from $PYTHON_PREFIX/lib/python3.7/site-packages/pytest.py
31+
This is pytest version 5.x.y, imported from $PYTHON_PREFIX/lib/python3.6/site-packages/pytest.py
3232
3333
.. _`simpletest`:
3434

doc/en/reference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pytest.raises
5959

6060
**Tutorial**: :ref:`assertraises`.
6161

62-
.. autofunction:: pytest.raises(expected_exception: Exception, [match])
62+
.. autofunction:: pytest.raises(expected_exception: Exception [, *, match])
6363
:with: excinfo
6464

6565
pytest.deprecated_call

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ upload-dir = doc/en/build/html
5757

5858
[check-manifest]
5959
ignore =
60-
_pytest/_version.py
60+
src/_pytest/_version.py
6161

6262
[devpi:upload]
6363
formats = sdist.tgz,bdist_wheel

src/_pytest/python.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,12 @@ def parametrize(self, argnames, argvalues, indirect=False, ids=None, scope=None)
973973
)
974974
del argvalues
975975

976+
if "request" in argnames:
977+
fail(
978+
"'request' is a reserved name and cannot be used in @pytest.mark.parametrize",
979+
pytrace=False,
980+
)
981+
976982
if scope is None:
977983
scope = _find_parametrized_scope(argnames, self._arg2fixturedefs, indirect)
978984

testing/python/metafunc.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ def func(x):
7272
):
7373
metafunc.parametrize("x", [1], scope="doggy")
7474

75+
def test_parametrize_request_name(self, testdir):
76+
"""Show proper error when 'request' is used as a parameter name in parametrize (#6183)"""
77+
78+
def func(request):
79+
raise NotImplementedError()
80+
81+
metafunc = self.Metafunc(func)
82+
with pytest.raises(
83+
pytest.fail.Exception,
84+
match=r"'request' is a reserved name and cannot be used in @pytest.mark.parametrize",
85+
):
86+
metafunc.parametrize("request", [1])
87+
7588
def test_find_parametrized_scope(self):
7689
"""unittest for _find_parametrized_scope (#3941)"""
7790
from _pytest.python import _find_parametrized_scope

testing/test_collection.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,3 +1262,24 @@ def test_collector_respects_tbstyle(testdir):
12621262
"*= 1 error in *",
12631263
]
12641264
)
1265+
1266+
1267+
def test_does_not_eagerly_collect_packages(testdir):
1268+
testdir.makepyfile("def test(): pass")
1269+
pydir = testdir.mkpydir("foopkg")
1270+
pydir.join("__init__.py").write("assert False")
1271+
result = testdir.runpytest()
1272+
assert result.ret == ExitCode.OK
1273+
1274+
1275+
def test_does_not_put_src_on_path(testdir):
1276+
# `src` is not on sys.path so it should not be importable
1277+
testdir.tmpdir.join("src/nope/__init__.py").ensure()
1278+
testdir.makepyfile(
1279+
"import pytest\n"
1280+
"def test():\n"
1281+
" with pytest.raises(ImportError):\n"
1282+
" import nope\n"
1283+
)
1284+
result = testdir.runpytest()
1285+
assert result.ret == ExitCode.OK

0 commit comments

Comments
 (0)