diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index f516959bc..7436f7146 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -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 `..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. +--> diff --git a/AUTHORS b/AUTHORS index 763d904a4..ee275083a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -70,6 +70,7 @@ Daniel Hahler Daniel Nuri Daniel Wandschneider Danielle Jenkins +Daniil Galiev Dave Hunt David Díaz-Barquero David Mohr diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 375b5dabf..b1a988de8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 `_: Fix incorrect discovery of non-test ``__init__.py`` files. + + +- `#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 `_: The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped. + + +- `#6099 `_: Fix ``--trace`` when used with parametrized functions. + + +- `#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) ========================= diff --git a/changelog/6099.bugfix.rst b/changelog/6099.bugfix.rst deleted file mode 100644 index 77f33cde1..000000000 --- a/changelog/6099.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix ``--trace`` when used with parametrized functions. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index f7a634b31..e7c011411 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -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 diff --git a/doc/en/announce/release-5.2.3.rst b/doc/en/announce/release-5.2.3.rst new file mode 100644 index 000000000..bfb62a1b8 --- /dev/null +++ b/doc/en/announce/release-5.2.3.rst @@ -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 diff --git a/doc/en/announce/release-5.2.4.rst b/doc/en/announce/release-5.2.4.rst new file mode 100644 index 000000000..05677e77f --- /dev/null +++ b/doc/en/announce/release-5.2.4.rst @@ -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 diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index 1220cfb4d..0e131dace 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -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 -------------------------------------------------------------------- diff --git a/doc/en/example/reportingdemo.rst b/doc/en/example/reportingdemo.rst index eb978c5ea..1c06782f6 100644 --- a/doc/en/example/reportingdemo.rst +++ b/doc/en/example/reportingdemo.rst @@ -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 --------------------------- @@ -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 ______________________ diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index a7cd06d31..05ccbc9b2 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -300,36 +300,33 @@ behave differently if called from a test. But if you absolutely must find out if your application code is running from a test you can do something like this: +.. code-block:: python + + # content of your_module.py + + + _called_from_test = False + .. code-block:: python # content of conftest.py def pytest_configure(config): - import sys + your_module._called_from_test = True - sys._called_from_test = True - - - def pytest_unconfigure(config): - import sys - - del sys._called_from_test - -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 -------------------------------------------------------------- diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 97347f126..2bdd68ea3 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -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`: diff --git a/doc/en/reference.rst b/doc/en/reference.rst index f90efc3a5..9986d1129 100644 --- a/doc/en/reference.rst +++ b/doc/en/reference.rst @@ -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 diff --git a/setup.cfg b/setup.cfg index 60e866562..0c0cb4861 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/src/_pytest/python.py b/src/_pytest/python.py index c1654b1c9..7b2a3de59 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -966,6 +966,12 @@ class Metafunc(fixtures.FuncargnamesCompatAttr): ) 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) diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py index 15c146e90..0c3c2aed3 100644 --- a/testing/python/metafunc.py +++ b/testing/python/metafunc.py @@ -72,6 +72,19 @@ class TestMetafunc: ): 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 diff --git a/testing/test_collection.py b/testing/test_collection.py index f18d36d24..3e256eae6 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -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