From 71ad5b0fbb9ade8f298af83722ba4b910acc6813 Mon Sep 17 00:00:00 2001 From: Oliver Bestwalter Date: Thu, 10 Oct 2019 12:11:16 +0200 Subject: [PATCH 01/18] remove cancelled training sidebar --- doc/en/talks.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/doc/en/talks.rst b/doc/en/talks.rst index eb1eadbe1..04eb97c7f 100644 --- a/doc/en/talks.rst +++ b/doc/en/talks.rst @@ -2,10 +2,6 @@ Talks and Tutorials ========================== -.. sidebar:: Next Open Trainings - - - `3 day hands-on workshop covering pytest, tox and devpi: "Professional Testing with Python" `_ (English), October 21 - 23, 2019, Leipzig, Germany. - .. _`funcargs`: funcargs.html Books From 57141dc7085dd83a0692e82a4946b60b6e5f0f43 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 11 Oct 2019 08:50:38 -0300 Subject: [PATCH 02/18] Add link to technical aspects issue to the py27-py34 docs --- doc/en/py27-py34-deprecation.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/en/py27-py34-deprecation.rst b/doc/en/py27-py34-deprecation.rst index 541197843..06a731962 100644 --- a/doc/en/py27-py34-deprecation.rst +++ b/doc/en/py27-py34-deprecation.rst @@ -24,3 +24,8 @@ branch will continue to exist so the community itself can contribute patches. Th be happy to accept those patches and make new ``4.6`` releases **until mid-2020**. .. _`python_requires`: https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires + +Technical Aspects +----------------- + +The technical aspects of the Python 2.7 and 3.4 support plan (such as when releases will occurr, how to backport fixes, etc) is described in issue `#5275 `__. From d07c5ba4ae03aab3048f4a77f9303d663b34cd22 Mon Sep 17 00:00:00 2001 From: Nattaphoom Chaipreecha Date: Sat, 12 Oct 2019 08:09:49 +0700 Subject: [PATCH 03/18] Update pdb++ link (moved to GitHub) --- doc/en/projects.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/projects.rst b/doc/en/projects.rst index 226358596..5b3449945 100644 --- a/doc/en/projects.rst +++ b/doc/en/projects.rst @@ -38,7 +38,7 @@ Here are some examples of projects using ``pytest`` (please send notes via :ref: * `execnet `_ rapid multi-Python deployment * `pylib `_ cross-platform path, IO, dynamic code library * `bbfreeze `_ create standalone executables from Python scripts -* `pdb++ `_ a fancier version of PDB +* `pdb++ `_ a fancier version of PDB * `py-s3fuse `_ Amazon S3 FUSE based filesystem * `waskr `_ WSGI Stats Middleware * `guachi `_ global persistent configs for Python modules From 83ba5eb58af42287a29a7834b3ff7d144566f901 Mon Sep 17 00:00:00 2001 From: Nattaphoom Chaipreecha Date: Sat, 12 Oct 2019 08:10:04 +0700 Subject: [PATCH 04/18] Add pudb to project examples --- doc/en/projects.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/en/projects.rst b/doc/en/projects.rst index 5b3449945..751d0abe9 100644 --- a/doc/en/projects.rst +++ b/doc/en/projects.rst @@ -39,6 +39,7 @@ Here are some examples of projects using ``pytest`` (please send notes via :ref: * `pylib `_ cross-platform path, IO, dynamic code library * `bbfreeze `_ create standalone executables from Python scripts * `pdb++ `_ a fancier version of PDB +* `pudb `_ full-screen console debugger for python * `py-s3fuse `_ Amazon S3 FUSE based filesystem * `waskr `_ WSGI Stats Middleware * `guachi `_ global persistent configs for Python modules From 1f639e2c22ca92f85521db7dd05f743e946ff338 Mon Sep 17 00:00:00 2001 From: Victor Maryama Date: Sat, 12 Oct 2019 14:33:43 +0200 Subject: [PATCH 05/18] Casting fixture parameter to list at the beginning of parameter parsing. --- setup.py | 1 + src/_pytest/fixtures.py | 5 +++-- testing/python/fixtures.py | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index dcf63f6fd..be38857b0 100644 --- a/setup.py +++ b/setup.py @@ -28,6 +28,7 @@ def main(): "mock", "nose", "requests", + "numpy", "xmlschema", ] }, diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index b4b10fcd2..ed7e715de 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1113,6 +1113,9 @@ def fixture( ``fixture_`` and then use ``@pytest.fixture(name='')``. """ + if params is not None and not isinstance(params, (list, tuple)): + params = list(params) + fixture_function, arguments = _parse_fixture_args( callable_or_scope, *args, @@ -1134,8 +1137,6 @@ def fixture( fixture_function ) - if params is not None and not isinstance(params, (list, tuple)): - params = list(params) return FixtureFunctionMarker(scope, params, autouse, ids=ids, name=name) diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index f4dbfdf09..e0b464c96 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -4187,3 +4187,21 @@ def test_indirect_fixture_does_not_break_scope(testdir): ) result = testdir.runpytest() result.assert_outcomes(passed=7) + + +def test_fixture_parametrization_nparray(testdir): + testdir.makepyfile( + """ + from numpy import linspace + from pytest import fixture + + @fixture(params=linspace(1, 10, 10)) + def value(request): + return request.param + + def test_bug(value): + assert value == value + """ + ) + result = testdir.runpytest() + result.assert_outcomes(passed=10) From 122748a6cf12e6853c8b2ee2576f91f2b722706d Mon Sep 17 00:00:00 2001 From: Victor Maryama Date: Sat, 12 Oct 2019 14:38:58 +0200 Subject: [PATCH 06/18] Added changelog file. --- changelog/5946.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/5946.bugfix.rst diff --git a/changelog/5946.bugfix.rst b/changelog/5946.bugfix.rst new file mode 100644 index 000000000..07bf23e44 --- /dev/null +++ b/changelog/5946.bugfix.rst @@ -0,0 +1 @@ +Fixed issue when parametrizing fixtures with numpy arrays (and possibly other sequence-like types). \ No newline at end of file From 63e3d89647499b7c28bde50391fa9313edb21c5d Mon Sep 17 00:00:00 2001 From: Victor Maryama Date: Sat, 12 Oct 2019 15:08:47 +0200 Subject: [PATCH 07/18] Fixed linting. --- changelog/5946.bugfix.rst | 2 +- testing/python/fixtures.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog/5946.bugfix.rst b/changelog/5946.bugfix.rst index 07bf23e44..62f012ccd 100644 --- a/changelog/5946.bugfix.rst +++ b/changelog/5946.bugfix.rst @@ -1 +1 @@ -Fixed issue when parametrizing fixtures with numpy arrays (and possibly other sequence-like types). \ No newline at end of file +Fixed issue when parametrizing fixtures with numpy arrays (and possibly other sequence-like types). diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index e0b464c96..4fcab0245 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -4191,7 +4191,7 @@ def test_indirect_fixture_does_not_break_scope(testdir): def test_fixture_parametrization_nparray(testdir): testdir.makepyfile( - """ + """ from numpy import linspace from pytest import fixture From 122cf60b2789487efec2b725f429eaa59baf3ea2 Mon Sep 17 00:00:00 2001 From: Victor Maryama Date: Sat, 12 Oct 2019 15:46:28 +0200 Subject: [PATCH 08/18] Always creating list for consistency. Co-Authored-By: Bruno Oliveira --- src/_pytest/fixtures.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index ed7e715de..7dc919235 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1113,7 +1113,7 @@ def fixture( ``fixture_`` and then use ``@pytest.fixture(name='')``. """ - if params is not None and not isinstance(params, (list, tuple)): + if params is not None: params = list(params) fixture_function, arguments = _parse_fixture_args( From 7678f891f96e1c741af4b619bc02c9a918b72f29 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 12 Oct 2019 21:50:33 +0300 Subject: [PATCH 09/18] Workaround curl bug which makes retries of fetching codecov.io/bash not work --- scripts/report-coverage.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/report-coverage.sh b/scripts/report-coverage.sh index 7fdeda464..165426a11 100755 --- a/scripts/report-coverage.sh +++ b/scripts/report-coverage.sh @@ -13,5 +13,6 @@ fi python -m coverage combine python -m coverage xml python -m coverage report -m -curl -S -L --retry 6 -s https://codecov.io/bash -o codecov-upload.sh +# Set --connect-timeout to work around https://github.com/curl/curl/issues/4461 +curl -S -L --connect-timeout 5 --retry 6 -s https://codecov.io/bash -o codecov-upload.sh bash codecov-upload.sh -Z -X fix -f coverage.xml From ae9465215ef87ff150a295c7956590afa3efc11e Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 13 Oct 2019 11:54:02 -0300 Subject: [PATCH 10/18] Port CHANGELOG from 4.6.6 release --- CHANGELOG.rst | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c03fa631e..08126f203 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -27,6 +27,33 @@ Bug Fixes - `#5902 `_: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``. +pytest 4.6.6 (2019-10-11) +========================= + +Bug Fixes +--------- + +- `#5523 `_: Fixed using multiple short options together in the command-line (for example ``-vs``) in Python 3.8+. + + +- `#5537 `_: Replace ``importlib_metadata`` backport with ``importlib.metadata`` from the + standard library on Python 3.8+. + + +- `#5806 `_: Fix "lexer" being used when uploading to bpaste.net from ``--pastebin`` to "text". + + +- `#5902 `_: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``. + + + +Trivial/Internal Changes +------------------------ + +- `#5801 `_: Fixes python version checks (detected by ``flake8-2020``) in case python4 becomes a thing. + + + pytest 5.2.0 (2019-09-28) ========================= From dee8d948766493c61861a84a3b879c743c902886 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 14 Oct 2019 19:20:57 +0200 Subject: [PATCH 11/18] changelog: #5523 was fixed in 5.0.1 already Ref: https://github.com/pytest-dev/pytest/pull/5952#issuecomment-541801883 --- CHANGELOG.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 08126f203..2d27b5e65 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -241,9 +241,6 @@ Bug Fixes - `#5477 `_: The XML file produced by ``--junitxml`` now correctly contain a ```` root element. -- `#5523 `_: Fixed using multiple short options together in the command-line (for example ``-vs``) in Python 3.8+. - - - `#5524 `_: Fix issue where ``tmp_path`` and ``tmpdir`` would not remove directories containing files marked as read-only, which could lead to pytest crashing when executed a second time with the ``--basetemp`` option. From 71a7fd02a574120ef9c1e9d6aeeb65d186cc756a Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 15 Oct 2019 16:18:30 +0200 Subject: [PATCH 12/18] doc: caplog: add caplog.messages --- src/_pytest/logging.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index 2861baefd..054bfc866 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -356,6 +356,7 @@ def caplog(request): Captured logs are available through the following properties/methods:: + * caplog.messages -> list of format-interpolated log messages * caplog.text -> string containing formatted log output * caplog.records -> list of logging.LogRecord instances * caplog.record_tuples -> list of (logger_name, level, message) tuples From 0383d4364584a32899f73efd4c4e0d2a6b30a03e Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 15 Oct 2019 19:45:58 -0300 Subject: [PATCH 13/18] Add missing version added/changed markers to docs Notice some features since 5.0 were not being properly marked in which version they have been added/changed. --- doc/en/doctest.rst | 2 ++ doc/en/fixture.rst | 4 ++++ doc/en/usage.rst | 5 +++++ src/_pytest/config/__init__.py | 2 ++ src/_pytest/fixtures.py | 8 ++++++-- src/_pytest/hookspec.py | 2 ++ src/_pytest/main.py | 2 ++ 7 files changed, 23 insertions(+), 2 deletions(-) diff --git a/doc/en/doctest.rst b/doc/en/doctest.rst index 9ffd5285a..b73cc994a 100644 --- a/doc/en/doctest.rst +++ b/doc/en/doctest.rst @@ -156,6 +156,8 @@ pytest also introduces new options: a string! This means that it may not be appropriate to enable globally in ``doctest_optionflags`` in your configuration file. + .. versionadded:: 5.1 + Continue on failure ------------------- diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index d5f4a85e3..6e1e554bf 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -301,9 +301,13 @@ are finalized when the last test of a *package* finishes. Use this new feature sparingly and please make sure to report any issues you find. +.. _dynamic scope: + Dynamic scope ^^^^^^^^^^^^^ +.. versionadded:: 5.2 + In some cases, you might want to change the scope of the fixture without changing the code. To do that, pass a callable to ``scope``. The callable must return a string with a valid scope and will be executed only once - during the fixture definition. It will be called with two diff --git a/doc/en/usage.rst b/doc/en/usage.rst index 777c14be2..167c7fa9b 100644 --- a/doc/en/usage.rst +++ b/doc/en/usage.rst @@ -718,6 +718,11 @@ for example ``-x`` if you only want to send one particular failure. Currently only pasting to the http://bpaste.net service is implemented. +.. versionchanged:: 5.2 + +If creating the URL fails for any reason, a warning is generated instead of failing the +entire test suite. + Early loading plugins --------------------- diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 3164c81ba..39c8d2cdf 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -663,6 +663,8 @@ class Config: class InvocationParams: """Holds parameters passed during ``pytest.main()`` + .. versionadded:: 5.1 + .. note:: Currently the environment variable PYTEST_ADDOPTS is also handled by diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index 7dc919235..aae1371ec 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1088,9 +1088,13 @@ def fixture( :arg scope: the scope for which this fixture is shared, one of ``"function"`` (default), ``"class"``, ``"module"``, - ``"package"`` or ``"session"``. + ``"package"`` or ``"session"`` (``"package"`` is considered **experimental** + at this time). - ``"package"`` is considered **experimental** at this time. + This parameter may also be a callable which receives ``(fixture_name, config)`` + as parameters, and must return a ``str`` with one of the values mentioned above. + + See :ref:`dynamic scope` in the docs for more information. :arg params: an optional list of parameters which will cause multiple invocations of the fixture function and all of the tests diff --git a/src/_pytest/hookspec.py b/src/_pytest/hookspec.py index 59fc569f4..10a9857d7 100644 --- a/src/_pytest/hookspec.py +++ b/src/_pytest/hookspec.py @@ -488,6 +488,8 @@ def pytest_assertion_pass(item, lineno, orig, expl): """ **(Experimental)** + .. versionadded:: 5.0 + Hook called whenever an assertion *passes*. Use this hook to do some processing after a passing assertion. diff --git a/src/_pytest/main.py b/src/_pytest/main.py index 23eff52dd..ad65ed299 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -20,6 +20,8 @@ from _pytest.runner import collect_one_node class ExitCode(enum.IntEnum): """ + .. versionadded:: 5.0 + Encodes the valid exit codes by pytest. Currently users and plugins may supply other exit codes as well. From 90dfee5da55f4b2e55a92568186dc435624d5499 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 16 Oct 2019 23:45:01 +0200 Subject: [PATCH 14/18] tests: keep numpy being optional Ref: https://github.com/pytest-dev/pytest/pull/5950#discussion_r335254774 --- setup.py | 1 - testing/python/fixtures.py | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index be38857b0..dcf63f6fd 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,6 @@ def main(): "mock", "nose", "requests", - "numpy", "xmlschema", ] }, diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index 4fcab0245..45c56f9a8 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -4190,6 +4190,8 @@ def test_indirect_fixture_does_not_break_scope(testdir): def test_fixture_parametrization_nparray(testdir): + pytest.importorskip("numpy") + testdir.makepyfile( """ from numpy import linspace From a73d0151a68cf516ed6c36b6e7e086b91c8ccbc9 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 17 Oct 2019 00:07:52 +0200 Subject: [PATCH 15/18] ci: Travis: move py37-pexpect to another job It does not have to run all tests again by itself. --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c713a19a1..b77c3f595 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,7 +35,9 @@ jobs: - test $(python -c 'import sys; print("%d%d" % sys.version_info[0:2])') = 37 # Full run of latest supported version, without xdist. - - env: TOXENV=py37 + # Coverage for: + # - test_sys_breakpoint_interception (via pexpect). + - env: TOXENV=py37-pexpect PYTEST_COVERAGE=1 python: '3.7' # Coverage tracking is slow with pypy, skip it. @@ -54,9 +56,6 @@ jobs: - env: TOXENV=py37-lsof-oldattrs-numpy-twisted-xdist PYTEST_COVERAGE=1 PYTEST_ADDOPTS= # Specialized factors for py37. - # Coverage for: - # - test_sys_breakpoint_interception (via pexpect). - - env: TOXENV=py37-pexpect PYTEST_COVERAGE=1 - env: TOXENV=py37-pluggymaster-xdist - env: TOXENV=py37-freeze From f2dd9cc63efa937582638c0bebdeb702f243f49e Mon Sep 17 00:00:00 2001 From: Andrzej Klajnert Date: Thu, 17 Oct 2019 13:17:34 +0200 Subject: [PATCH 16/18] Remove redundant mention from 5.2.0 release notes. --- doc/en/announce/release-5.2.0.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/en/announce/release-5.2.0.rst b/doc/en/announce/release-5.2.0.rst index f61d70222..8eae6dd73 100644 --- a/doc/en/announce/release-5.2.0.rst +++ b/doc/en/announce/release-5.2.0.rst @@ -29,7 +29,6 @@ Thanks to all who contributed to this release, among them: * Michael Goerz * Ran Benita * Tomáš Chvátal -* aklajnert Happy testing, From 7ef44913a1ee5c79c966372e613ce3ea06a68090 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 18 Oct 2019 17:08:39 +0200 Subject: [PATCH 17/18] tests: debugging: disable pdb++ within inner tests Ref: https://github.com/pytest-dev/pytest/pull/5306#issuecomment-495690643 --- testing/test_pdb.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/testing/test_pdb.py b/testing/test_pdb.py index 3c56f40e1..924c2f4af 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -17,6 +17,14 @@ else: _ENVIRON_PYTHONBREAKPOINT = os.environ.get("PYTHONBREAKPOINT", "") +@pytest.fixture(autouse=True) +def pdb_env(request): + if "testdir" in request.fixturenames: + # Disable pdb++ with inner tests. + testdir = request.getfixturevalue("testdir") + testdir._env_run_update["PDBPP_HIJACK_PDB"] = "0" + + def runpdb_and_get_report(testdir, source): p = testdir.makepyfile(source) result = testdir.runpytest_inprocess("--pdb", p) From 6b2bae9392f4fdbf295fbca8082e58f280c90aac Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 18 Oct 2019 17:22:56 +0200 Subject: [PATCH 18/18] tests: filterwarnings: do not crash with "(rm_rf)" warning Ref: https://github.com/pytest-dev/pytest/issues/5974 --- tox.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tox.ini b/tox.ini index e1b611f58..b03941657 100644 --- a/tox.ini +++ b/tox.ini @@ -142,6 +142,8 @@ filterwarnings = error default:Using or importing the ABCs:DeprecationWarning:unittest2.* ignore:Module already imported so cannot be rewritten:pytest.PytestWarning + # https://github.com/pytest-dev/pytest/issues/5974 + default:\(rm_rf\) error removing.*:pytest.PytestWarning # produced by python3.6/site.py itself (3.6.7 on Travis, could not trigger it with 3.6.8). ignore:.*U.*mode is deprecated:DeprecationWarning:(?!(pytest|_pytest)) # produced by pytest-xdist