Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
9275012
fix bug with nonskipped first test in package
Sep 8, 2019
b94eb4c
disable _ALLOW_MARKERS in module __init__.py
Sep 11, 2019
5cefcb2
refactor disabling markers
Sep 27, 2019
85288b5
fix bug with nonskipped first test in package (#5831)
nicoddemus Nov 6, 2019
41604ee
setup.cfg: fix check-manifest ignore [ci skip]
blueyed Nov 8, 2019
adccb63
setup.cfg: fix check-manifest ignore [ci skip] (#6156)
nicoddemus Nov 12, 2019
0b40749
Delineate syntactically that the 'match' argument to 'raises' is keyw…
brettcannon Nov 12, 2019
55a58bc
Merge pull request #6173 from brettcannon/patch-1
Zac-HD Nov 12, 2019
6f2c0fd
Show a better message when 'request' is used in parametrize
nicoddemus Nov 13, 2019
92d6a05
Show a better message when 'request' is used in parametrize (#6184)
nicoddemus Nov 13, 2019
350c27c
Update text in PR template
hugovk Nov 14, 2019
48ec7d2
Make whole checklist a comment to avoid incomplete TODOs in PRs
hugovk Nov 14, 2019
5e8c47f
Preparing release version 5.2.3
nicoddemus Nov 14, 2019
bd68c2a
Update advice about _called_from_test.
shields-fn Nov 12, 2019
e2a0987
Update advice about _called_from_test. (#6168)
nicoddemus Nov 14, 2019
d4e4ab5
Update text in PR template (#6188)
blueyed Nov 14, 2019
dd9a27c
Adjust CHANGELOG
nicoddemus Nov 14, 2019
e856638
Preparing release version 5.2.3 (#6190)
nicoddemus Nov 14, 2019
176c777
Revert "fix bug with nonskipped first test in package (#5831)"
asottile Nov 15, 2019
4e0f992
Add regression tests for __init__.py breakage
asottile Nov 15, 2019
19a15a9
Merge pull request #6197 from asottile/fix_init_py_discovery
asottile Nov 15, 2019
c9a96cd
Preparing release version 5.2.4
asottile Nov 15, 2019
3a668ea
Merge pull request #6198 from asottile/release-5.2.4
asottile Nov 15, 2019
cc78444
Merge remote-tracking branch 'origin/master' into mm
asottile Nov 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
Thanks for submitting a PR, your contribution is really appreciated!

Here is a quick checklist that should be present in PRs.
(please delete this text from the final description, this is just a guideline)
-->

- [ ] Target the `master` branch for bug fixes, documentation updates and trivial changes.
- [ ] Target the `features` branch for new features, improvements, and removals/deprecations.
- [ ] Include documentation when adding new features.
- [ ] Include new tests or update existing tests when applicable.

Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:
Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:

- [ ] 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.
- [ ] Add yourself to `AUTHORS` in alphabetical order;
- [ ] Add yourself to `AUTHORS` in alphabetical order.
-->
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Daniel Hahler
Daniel Nuri
Daniel Wandschneider
Danielle Jenkins
Daniil Galiev
Dave Hunt
David Díaz-Barquero
David Mohr
Expand Down
28 changes: 28 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,34 @@ with advance notice in the **Deprecations** section of releases.

.. towncrier release notes start

pytest 5.2.4 (2019-11-15)
=========================

Bug Fixes
---------

- `#6194 <https://github.com/pytest-dev/pytest/issues/6194>`_: Fix incorrect discovery of non-test ``__init__.py`` files.


- `#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.".


pytest 5.2.3 (2019-11-14)
=========================

Bug Fixes
---------

- `#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.


- `#6099 <https://github.com/pytest-dev/pytest/issues/6099>`_: Fix ``--trace`` when used with parametrized functions.


- `#6183 <https://github.com/pytest-dev/pytest/issues/6183>`_: Using ``request`` as a parameter name in ``@pytest.mark.parametrize`` now produces a more
user-friendly error.


pytest 5.2.2 (2019-10-24)
=========================

Expand Down
1 change: 0 additions & 1 deletion changelog/6099.bugfix.rst

This file was deleted.

2 changes: 2 additions & 0 deletions doc/en/announce/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Release announcements
:maxdepth: 2


release-5.2.4
release-5.2.3
release-5.2.2
release-5.2.1
release-5.2.0
Expand Down
28 changes: 28 additions & 0 deletions doc/en/announce/release-5.2.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
pytest-5.2.3
=======================================

pytest 5.2.3 has just been released to PyPI.

This is a bug-fix release, being a drop-in replacement. To upgrade::

pip install --upgrade pytest

The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.

Thanks to all who contributed to this release, among them:

* Anthony Sottile
* Brett Cannon
* Bruno Oliveira
* Daniel Hahler
* Daniil Galiev
* David Szotten
* Florian Bruhin
* Patrick Harmon
* Ran Benita
* Zac Hatfield-Dodds
* Zak Hassan


Happy testing,
The pytest Development Team
22 changes: 22 additions & 0 deletions doc/en/announce/release-5.2.4.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
pytest-5.2.4
=======================================

pytest 5.2.4 has just been released to PyPI.

This is a bug-fix release, being a drop-in replacement. To upgrade::

pip install --upgrade pytest

The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.

Thanks to all who contributed to this release, among them:

* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* Hugo
* Michael Shields


Happy testing,
The pytest Development Team
7 changes: 3 additions & 4 deletions doc/en/example/parametrize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,10 @@ Running it results in some skips if we don't have all the python interpreters in
.. code-block:: pytest

. $ pytest -rs -q multipython.py
ssssssssssssssssssssssss... [100%]
ssssssssssss......sss...... [100%]
========================= short test summary info ==========================
SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.5' not found
SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.6' not found
3 passed, 24 skipped in 0.12s
SKIPPED [15] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.5' not found
12 passed, 15 skipped in 0.12s

Indirect parametrization of optional implementations/imports
--------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions doc/en/example/reportingdemo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
items = [1, 2, 3]
print("items is {!r}".format(items))
> a, b = items.pop()
E TypeError: cannot unpack non-iterable int object
E TypeError: 'int' object is not iterable

failure_demo.py:181: TypeError
--------------------------- Captured stdout call ---------------------------
Expand Down Expand Up @@ -516,7 +516,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
def test_z2_type_error(self):
items = 3
> a, b = items
E TypeError: cannot unpack non-iterable int object
E TypeError: 'int' object is not iterable

failure_demo.py:222: TypeError
______________________ TestMoreErrors.test_startswith ______________________
Expand Down
21 changes: 9 additions & 12 deletions doc/en/example/simple.rst
Original file line number Diff line number Diff line change
Expand Up @@ -302,34 +302,31 @@ running from a test you can do something like this:

.. code-block:: python

# content of conftest.py
# content of your_module.py


def pytest_configure(config):
import sys
_called_from_test = False

sys._called_from_test = True
.. code-block:: python

# content of conftest.py

def pytest_unconfigure(config):
import sys

del sys._called_from_test
def pytest_configure(config):
your_module._called_from_test = True

and then check for the ``sys._called_from_test`` flag:
and then check for the ``your_module._called_from_test`` flag:

.. code-block:: python

if hasattr(sys, "_called_from_test"):
if your_module._called_from_test:
# called from within a test run
...
else:
# called "normally"
...

accordingly in your application. It's also a good idea
to use your own application module rather than ``sys``
for handling flag.
accordingly in your application.

Adding info to test report header
--------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion doc/en/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Install ``pytest``
.. code-block:: bash

$ pytest --version
This is pytest version 5.x.y, imported from $PYTHON_PREFIX/lib/python3.7/site-packages/pytest.py
This is pytest version 5.x.y, imported from $PYTHON_PREFIX/lib/python3.6/site-packages/pytest.py

.. _`simpletest`:

Expand Down
2 changes: 1 addition & 1 deletion doc/en/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pytest.raises

**Tutorial**: :ref:`assertraises`.

.. autofunction:: pytest.raises(expected_exception: Exception, [match])
.. autofunction:: pytest.raises(expected_exception: Exception [, *, match])
:with: excinfo

pytest.deprecated_call
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ upload-dir = doc/en/build/html

[check-manifest]
ignore =
_pytest/_version.py
src/_pytest/_version.py

[devpi:upload]
formats = sdist.tgz,bdist_wheel
Expand Down
6 changes: 6 additions & 0 deletions src/_pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,12 @@ def parametrize(self, argnames, argvalues, indirect=False, ids=None, scope=None)
)
del argvalues

if "request" in argnames:
fail(
"'request' is a reserved name and cannot be used in @pytest.mark.parametrize",
pytrace=False,
)

if scope is None:
scope = _find_parametrized_scope(argnames, self._arg2fixturedefs, indirect)

Expand Down
13 changes: 13 additions & 0 deletions testing/python/metafunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ def func(x):
):
metafunc.parametrize("x", [1], scope="doggy")

def test_parametrize_request_name(self, testdir):
"""Show proper error when 'request' is used as a parameter name in parametrize (#6183)"""

def func(request):
raise NotImplementedError()

metafunc = self.Metafunc(func)
with pytest.raises(
pytest.fail.Exception,
match=r"'request' is a reserved name and cannot be used in @pytest.mark.parametrize",
):
metafunc.parametrize("request", [1])

def test_find_parametrized_scope(self):
"""unittest for _find_parametrized_scope (#3941)"""
from _pytest.python import _find_parametrized_scope
Expand Down
21 changes: 21 additions & 0 deletions testing/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,3 +1262,24 @@ def test_collector_respects_tbstyle(testdir):
"*= 1 error in *",
]
)


def test_does_not_eagerly_collect_packages(testdir):
testdir.makepyfile("def test(): pass")
pydir = testdir.mkpydir("foopkg")
pydir.join("__init__.py").write("assert False")
result = testdir.runpytest()
assert result.ret == ExitCode.OK


def test_does_not_put_src_on_path(testdir):
# `src` is not on sys.path so it should not be importable
testdir.tmpdir.join("src/nope/__init__.py").ensure()
testdir.makepyfile(
"import pytest\n"
"def test():\n"
" with pytest.raises(ImportError):\n"
" import nope\n"
)
result = testdir.runpytest()
assert result.ret == ExitCode.OK