From 16df4da1f7af6e2a4b06e46b9b3263feee2821a5 Mon Sep 17 00:00:00 2001 From: Antoine Legrand <2t.antoine@gmail.com> Date: Tue, 6 Jun 2017 04:21:29 +0200 Subject: [PATCH 1/5] Fix exclude_path check --- _pytest/main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/_pytest/main.py b/_pytest/main.py index 480810cc8..79bdc4006 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -168,14 +168,13 @@ def pytest_runtestloop(session): def pytest_ignore_collect(path, config): - p = path.dirpath() - ignore_paths = config._getconftest_pathlist("collect_ignore", path=p) + ignore_paths = config._getconftest_pathlist("collect_ignore", path=path.dirpath()) ignore_paths = ignore_paths or [] excludeopt = config.getoption("ignore") if excludeopt: ignore_paths.extend([py.path.local(x) for x in excludeopt]) - if path in ignore_paths: + if py.path.local(path) in ignore_paths: return True # Skip duplicate paths. From c578418791466341f7b1ebce5152182ef966e239 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 3 Jul 2017 12:39:17 -0300 Subject: [PATCH 2/5] Add changelog for triple leading '/' problem. --- changelog/2475.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/2475.bugfix diff --git a/changelog/2475.bugfix b/changelog/2475.bugfix new file mode 100644 index 000000000..a7144d8a8 --- /dev/null +++ b/changelog/2475.bugfix @@ -0,0 +1 @@ +Fix issue where paths collected by pytest could have triple leading ``/`` characters. From 7277fbdb2048655ff1d52d9ca046a14aa05e5f90 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 28 Jun 2017 23:00:14 -0400 Subject: [PATCH 3/5] Fix SMTP port in fixture docs Also add timeout to avoid regen getting stuck due to connection problems Fix #2509 --- doc/en/fixture.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index c5bf67053..e9fe4be18 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -57,7 +57,7 @@ using it:: @pytest.fixture def smtp(): import smtplib - return smtplib.SMTP("smtp.gmail.com") + return smtplib.SMTP("smtp.gmail.com", 587, timeout=5) def test_ehlo(smtp): response, msg = smtp.ehlo() @@ -157,7 +157,7 @@ access the fixture function:: @pytest.fixture(scope="module") def smtp(): - return smtplib.SMTP("smtp.gmail.com") + return smtplib.SMTP("smtp.gmail.com", 587, timeout=5) The name of the fixture again is ``smtp`` and you can access its result by listing the name ``smtp`` as an input parameter in any test or fixture @@ -247,7 +247,7 @@ the code after the *yield* statement serves as the teardown code: @pytest.fixture(scope="module") def smtp(): - smtp = smtplib.SMTP("smtp.gmail.com") + smtp = smtplib.SMTP("smtp.gmail.com", 587, timeout=5) yield smtp # provide the fixture value print("teardown smtp") smtp.close() @@ -281,7 +281,7 @@ Note that we can also seamlessly use the ``yield`` syntax with ``with`` statemen @pytest.fixture(scope="module") def smtp(): - with smtplib.SMTP("smtp.gmail.com") as smtp: + with smtplib.SMTP("smtp.gmail.com", 587, timeout=5) as smtp: yield smtp # provide the fixture value @@ -314,7 +314,7 @@ Here's the ``smtp`` fixture changed to use ``addfinalizer`` for cleanup: @pytest.fixture(scope="module") def smtp(request): - smtp = smtplib.SMTP("smtp.gmail.com") + smtp = smtplib.SMTP("smtp.gmail.com", 587, timeout=5) def fin(): print ("teardown smtp") smtp.close() @@ -362,7 +362,7 @@ read an optional server URL from the test module which uses our fixture:: @pytest.fixture(scope="module") def smtp(request): server = getattr(request.module, "smtpserver", "smtp.gmail.com") - smtp = smtplib.SMTP(server) + smtp = smtplib.SMTP(server, 587, timeout=5) yield smtp print ("finalizing %s (%s)" % (smtp, server)) smtp.close() @@ -426,7 +426,7 @@ through the special :py:class:`request ` object:: @pytest.fixture(scope="module", params=["smtp.gmail.com", "mail.python.org"]) def smtp(request): - smtp = smtplib.SMTP(request.param) + smtp = smtplib.SMTP(request.param, 587, timeout=5) yield smtp print ("finalizing %s" % smtp) smtp.close() From 8a8687122d964d97ab9d1dc16fa1cf51028dbee9 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 3 Jul 2017 23:28:29 +0000 Subject: [PATCH 4/5] Add wheel to tasks/requirements.txt: required for package creation --- tasks/requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks/requirements.txt b/tasks/requirements.txt index eb12df3e9..6392de0cc 100644 --- a/tasks/requirements.txt +++ b/tasks/requirements.txt @@ -1,4 +1,5 @@ invoke tox gitpython -towncrier \ No newline at end of file +towncrier +wheel From b63f6770a17a122850ddc7902e16ce0c2f6af1ea Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 3 Jul 2017 23:29:13 +0000 Subject: [PATCH 5/5] Preparing release version 3.1.3 --- CHANGELOG.rst | 46 ++++++++++++++++++ changelog/2434.bugfix | 1 - changelog/2440.bugfix | 1 - changelog/2464.bugfix | 1 - changelog/2469.bugfix | 4 -- changelog/2474.trivial | 1 - changelog/2475.bugfix | 1 - changelog/2486.bugfix | 1 - changelog/2493.doc | 1 - changelog/2499.trivial | 1 - doc/en/announce/index.rst | 1 + doc/en/announce/release-3.1.3.rst | 23 +++++++++ doc/en/assert.rst | 4 +- doc/en/doctest.rst | 2 +- doc/en/example/markers.rst | 10 ++-- doc/en/example/parametrize.rst | 2 +- doc/en/fixture.rst | 80 +++++++++++++++---------------- doc/en/getting-started.rst | 2 +- doc/en/index.rst | 2 +- doc/en/tmpdir.rst | 2 +- doc/en/warnings.rst | 2 +- 21 files changed, 123 insertions(+), 65 deletions(-) delete mode 100644 changelog/2434.bugfix delete mode 100644 changelog/2440.bugfix delete mode 100644 changelog/2464.bugfix delete mode 100644 changelog/2469.bugfix delete mode 100644 changelog/2474.trivial delete mode 100644 changelog/2475.bugfix delete mode 100644 changelog/2486.bugfix delete mode 100644 changelog/2493.doc delete mode 100644 changelog/2499.trivial create mode 100644 doc/en/announce/release-3.1.3.rst diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 87af5d72a..1c1185dc0 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,52 @@ .. towncrier release notes start +Pytest 3.1.3 (2017-07-03) +========================= + +Bug Fixes +--------- + +- Fix decode error in Python 2 for doctests in docstrings. (`#2434 + `_) + +- Exceptions raised during teardown by finalizers are now suppressed until all + finalizers are called, with the initial exception reraised. (`#2440 + `_) + +- Fix incorrect "collected items" report when specifying tests on the command- + line. (`#2464 `_) + +- ``deprecated_call`` in context-manager form now captures deprecation warnings + even if the same warning has already been raised. Also, ``deprecated_call`` + will always produce the same error message (previously it would produce + different messages in context-manager vs. function-call mode). (`#2469 + `_) + +- Fix issue where paths collected by pytest could have triple leading ``/`` + characters. (`#2475 `_) + +- Fix internal error when trying to detect the start of a recursive traceback. + (`#2486 `_) + + +Improved Documentation +---------------------- + +- Explicitly state for which hooks the calls stop after the first non-None + result. (`#2493 `_) + + +Trivial/Internal Changes +------------------------ + +- Create invoke tasks for updating the vendored packages. (`#2474 + `_) + +- Update copyright dates in LICENSE, README.rst and in the documentation. + (`#2499 `_) + + Pytest 3.1.2 (2017-06-08) ========================= diff --git a/changelog/2434.bugfix b/changelog/2434.bugfix deleted file mode 100644 index 172a992c4..000000000 --- a/changelog/2434.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix decode error in Python 2 for doctests in docstrings. diff --git a/changelog/2440.bugfix b/changelog/2440.bugfix deleted file mode 100644 index 7f1f7d504..000000000 --- a/changelog/2440.bugfix +++ /dev/null @@ -1 +0,0 @@ -Exceptions raised during teardown by finalizers are now suppressed until all finalizers are called, with the initial exception reraised. diff --git a/changelog/2464.bugfix b/changelog/2464.bugfix deleted file mode 100644 index 12062fd9e..000000000 --- a/changelog/2464.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix incorrect "collected items" report when specifying tests on the command-line. diff --git a/changelog/2469.bugfix b/changelog/2469.bugfix deleted file mode 100644 index 492c62e08..000000000 --- a/changelog/2469.bugfix +++ /dev/null @@ -1,4 +0,0 @@ -``deprecated_call`` in context-manager form now captures deprecation warnings even if -the same warning has already been raised. Also, ``deprecated_call`` will always produce -the same error message (previously it would produce different messages in context-manager vs. -function-call mode). diff --git a/changelog/2474.trivial b/changelog/2474.trivial deleted file mode 100644 index 9ea3fb651..000000000 --- a/changelog/2474.trivial +++ /dev/null @@ -1 +0,0 @@ -Create invoke tasks for updating the vendored packages. \ No newline at end of file diff --git a/changelog/2475.bugfix b/changelog/2475.bugfix deleted file mode 100644 index a7144d8a8..000000000 --- a/changelog/2475.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix issue where paths collected by pytest could have triple leading ``/`` characters. diff --git a/changelog/2486.bugfix b/changelog/2486.bugfix deleted file mode 100644 index 97917197c..000000000 --- a/changelog/2486.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix internal error when trying to detect the start of a recursive traceback. diff --git a/changelog/2493.doc b/changelog/2493.doc deleted file mode 100644 index 619963041..000000000 --- a/changelog/2493.doc +++ /dev/null @@ -1 +0,0 @@ -Explicitly state for which hooks the calls stop after the first non-None result. \ No newline at end of file diff --git a/changelog/2499.trivial b/changelog/2499.trivial deleted file mode 100644 index 1b4341725..000000000 --- a/changelog/2499.trivial +++ /dev/null @@ -1 +0,0 @@ -Update copyright dates in LICENSE, README.rst and in the documentation. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index dbb4e24d6..5061f4870 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-3.1.3 release-3.1.2 release-3.1.1 release-3.1.0 diff --git a/doc/en/announce/release-3.1.3.rst b/doc/en/announce/release-3.1.3.rst new file mode 100644 index 000000000..a55280626 --- /dev/null +++ b/doc/en/announce/release-3.1.3.rst @@ -0,0 +1,23 @@ +pytest-3.1.3 +======================================= + +pytest 3.1.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 http://doc.pytest.org/en/latest/changelog.html. + +Thanks to all who contributed to this release, among them: + +* Antoine Legrand +* Bruno Oliveira +* Max Moroz +* Raphael Pierzina +* Ronny Pfannschmidt +* Ryan Fitzpatrick + + +Happy testing, +The pytest Development Team diff --git a/doc/en/assert.rst b/doc/en/assert.rst index d3d06804e..406be7e9e 100644 --- a/doc/en/assert.rst +++ b/doc/en/assert.rst @@ -28,7 +28,7 @@ you will see the return value of the function call:: ======= test session starts ======== platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: - collected 1 items + collected 1 item test_assert1.py F @@ -172,7 +172,7 @@ if you run this module:: ======= test session starts ======== platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: - collected 1 items + collected 1 item test_assert2.py F diff --git a/doc/en/doctest.rst b/doc/en/doctest.rst index 24c068a86..f5800fec2 100644 --- a/doc/en/doctest.rst +++ b/doc/en/doctest.rst @@ -64,7 +64,7 @@ then you can just invoke ``pytest`` without command line options:: ======= test session starts ======== platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini - collected 1 items + collected 1 item mymodule.py . diff --git a/doc/en/example/markers.rst b/doc/en/example/markers.rst index 338f707a5..d74d16e9d 100644 --- a/doc/en/example/markers.rst +++ b/doc/en/example/markers.rst @@ -69,7 +69,7 @@ tests based on their module, class, method, or function name:: platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.5 cachedir: .cache rootdir: $REGENDOC_TMPDIR, inifile: - collecting ... collected 5 items + collecting ... collected 1 item test_server.py::TestClass::test_method PASSED @@ -82,7 +82,7 @@ You can also select on the class:: platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.5 cachedir: .cache rootdir: $REGENDOC_TMPDIR, inifile: - collecting ... collected 4 items + collecting ... collected 1 item test_server.py::TestClass::test_method PASSED @@ -95,7 +95,7 @@ Or select multiple nodes:: platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.5 cachedir: .cache rootdir: $REGENDOC_TMPDIR, inifile: - collecting ... collected 8 items + collecting ... collected 2 items test_server.py::TestClass::test_method PASSED test_server.py::test_send_http PASSED @@ -354,7 +354,7 @@ the test needs:: ======= test session starts ======== platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: - collected 1 items + collected 1 item test_someenv.py s @@ -366,7 +366,7 @@ and here is one that specifies exactly the environment needed:: ======= test session starts ======== platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: - collected 1 items + collected 1 item test_someenv.py . diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index bb286b472..ca1d34d1b 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -336,7 +336,7 @@ The result of this test will be successful:: ======= test session starts ======== platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: - collected 1 items + collected 1 item diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index e9fe4be18..a53f78c3f 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -72,21 +72,21 @@ marked ``smtp`` fixture function. Running the test looks like this:: ======= test session starts ======== platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: - collected 1 items - + collected 1 item + test_smtpsimple.py F - + ======= FAILURES ======== _______ test_ehlo ________ - + smtp = - + def test_ehlo(smtp): response, msg = smtp.ehlo() assert response == 250 > assert 0 # for demo purposes E assert 0 - + test_smtpsimple.py:11: AssertionError ======= 1 failed in 0.12 seconds ======== @@ -184,32 +184,32 @@ inspect what is going on and can now run the tests:: platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: collected 2 items - + test_module.py FF - + ======= FAILURES ======== _______ test_ehlo ________ - + smtp = - + def test_ehlo(smtp): response, msg = smtp.ehlo() assert response == 250 assert b"smtp.gmail.com" in msg > assert 0 # for demo purposes E assert 0 - + test_module.py:6: AssertionError _______ test_noop ________ - + smtp = - + def test_noop(smtp): response, msg = smtp.noop() assert response == 250 > assert 0 # for demo purposes E assert 0 - + test_module.py:11: AssertionError ======= 2 failed in 0.12 seconds ======== @@ -260,7 +260,7 @@ Let's execute it:: $ pytest -s -q --tb=no FFteardown smtp - + 2 failed in 0.12 seconds We see that the ``smtp`` instance is finalized after the two @@ -373,7 +373,7 @@ again, nothing much has changed:: $ pytest -s -q --tb=no FFfinalizing (smtp.gmail.com) - + 2 failed in 0.12 seconds Let's quickly create another test module that actually sets the @@ -441,51 +441,51 @@ So let's just do another run:: FFFF ======= FAILURES ======== _______ test_ehlo[smtp.gmail.com] ________ - + smtp = - + def test_ehlo(smtp): response, msg = smtp.ehlo() assert response == 250 assert b"smtp.gmail.com" in msg > assert 0 # for demo purposes E assert 0 - + test_module.py:6: AssertionError _______ test_noop[smtp.gmail.com] ________ - + smtp = - + def test_noop(smtp): response, msg = smtp.noop() assert response == 250 > assert 0 # for demo purposes E assert 0 - + test_module.py:11: AssertionError _______ test_ehlo[mail.python.org] ________ - + smtp = - + def test_ehlo(smtp): response, msg = smtp.ehlo() assert response == 250 > assert b"smtp.gmail.com" in msg - E AssertionError: assert b'smtp.gmail.com' in b'mail.python.org\nSIZE 51200000\nETRN\nSTARTTLS\nENHANCEDSTATUSCODES\n8BITMIME\nDSN\nSMTPUTF8' - + E AssertionError: assert b'smtp.gmail.com' in b'mail.python.org\nPIPELINING\nSIZE 51200000\nETRN\nSTARTTLS\nAUTH DIGEST-MD5 NTLM CRAM-MD5\nENHANCEDSTATUSCODES\n8BITMIME\nDSN\nSMTPUTF8' + test_module.py:5: AssertionError -------------------------- Captured stdout setup --------------------------- finalizing _______ test_noop[mail.python.org] ________ - + smtp = - + def test_noop(smtp): response, msg = smtp.noop() assert response == 250 > assert 0 # for demo purposes E assert 0 - + test_module.py:11: AssertionError ------------------------- Captured stdout teardown ------------------------- finalizing @@ -557,7 +557,7 @@ Running the above tests results in the following test IDs being used:: - + ======= no tests ran in 0.12 seconds ======== .. _`interdependent fixtures`: @@ -596,10 +596,10 @@ Here we declare an ``app`` fixture which receives the previously defined cachedir: .cache rootdir: $REGENDOC_TMPDIR, inifile: collecting ... collected 2 items - + test_appsetup.py::test_smtp_exists[smtp.gmail.com] PASSED test_appsetup.py::test_smtp_exists[mail.python.org] PASSED - + ======= 2 passed in 0.12 seconds ======== Due to the parametrization of ``smtp`` the test will run twice with two @@ -665,26 +665,26 @@ Let's run the tests in verbose mode and with looking at the print-output:: cachedir: .cache rootdir: $REGENDOC_TMPDIR, inifile: collecting ... collected 8 items - + test_module.py::test_0[1] SETUP otherarg 1 RUN test0 with otherarg 1 PASSED TEARDOWN otherarg 1 - + test_module.py::test_0[2] SETUP otherarg 2 RUN test0 with otherarg 2 PASSED TEARDOWN otherarg 2 - + test_module.py::test_1[mod1] SETUP modarg mod1 RUN test1 with modarg mod1 PASSED test_module.py::test_2[1-mod1] SETUP otherarg 1 RUN test2 with otherarg 1 and modarg mod1 PASSED TEARDOWN otherarg 1 - + test_module.py::test_2[2-mod1] SETUP otherarg 2 RUN test2 with otherarg 2 and modarg mod1 PASSED TEARDOWN otherarg 2 - + test_module.py::test_1[mod2] TEARDOWN modarg mod1 SETUP modarg mod2 RUN test1 with modarg mod2 @@ -692,13 +692,13 @@ Let's run the tests in verbose mode and with looking at the print-output:: test_module.py::test_2[1-mod2] SETUP otherarg 1 RUN test2 with otherarg 1 and modarg mod2 PASSED TEARDOWN otherarg 1 - + test_module.py::test_2[2-mod2] SETUP otherarg 2 RUN test2 with otherarg 2 and modarg mod2 PASSED TEARDOWN otherarg 2 TEARDOWN modarg mod2 - - + + ======= 8 passed in 0.12 seconds ======== You can see that the parametrized module-scoped ``modarg`` resource caused an diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 59abd4c79..fb863e4e0 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -48,7 +48,7 @@ That's it. You can execute the test function now:: ======= test session starts ======== platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: - collected 1 items + collected 1 item test_sample.py F diff --git a/doc/en/index.rst b/doc/en/index.rst index 77e019d70..ad02d8684 100644 --- a/doc/en/index.rst +++ b/doc/en/index.rst @@ -27,7 +27,7 @@ To execute it:: ======= test session starts ======== platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: - collected 1 items + collected 1 item test_sample.py F diff --git a/doc/en/tmpdir.rst b/doc/en/tmpdir.rst index 642bb0814..56a347619 100644 --- a/doc/en/tmpdir.rst +++ b/doc/en/tmpdir.rst @@ -31,7 +31,7 @@ Running this would result in a passed test except for the last ======= test session starts ======== platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: - collected 1 items + collected 1 item test_tmpdir.py F diff --git a/doc/en/warnings.rst b/doc/en/warnings.rst index c807167ef..34dc1ece0 100644 --- a/doc/en/warnings.rst +++ b/doc/en/warnings.rst @@ -24,7 +24,7 @@ Running pytest now produces this output:: ======= test session starts ======== platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: - collected 1 items + collected 1 item test_show_warnings.py .