From 4a0aea2debfdd0ed2584221128fed891d0bc727d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 14 Nov 2017 22:03:34 -0200 Subject: [PATCH 1/8] Add missing entry to CHANGELOG for 3.2.4 --- CHANGELOG.rst | 2 ++ changelog/2836.bug | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) delete mode 100644 changelog/2836.bug diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f75e83bbe..026290208 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -28,6 +28,8 @@ Bug Fixes failed example in the docstring is < 9. (`#2882 `_) +- Match fixture paths against actual path segments in order to avoid matching folders which share a prefix. + (`#2836 `_) Improved Documentation ---------------------- diff --git a/changelog/2836.bug b/changelog/2836.bug deleted file mode 100644 index afa1961d7..000000000 --- a/changelog/2836.bug +++ /dev/null @@ -1 +0,0 @@ -Match fixture paths against actual path segments in order to avoid matching folders which share a prefix. From dd6c5344681809a7509e45acdf3e28d03b728144 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 14 Nov 2017 22:08:03 -0200 Subject: [PATCH 2/8] Remove py<1.5 restriction Fix #2926 --- changelog/2926.bugfix | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog/2926.bugfix diff --git a/changelog/2926.bugfix b/changelog/2926.bugfix new file mode 100644 index 000000000..09644b276 --- /dev/null +++ b/changelog/2926.bugfix @@ -0,0 +1 @@ +Remove ``py<1.5`` restriction from ``pytest`` as this can cause version conflicts in some installations. diff --git a/setup.py b/setup.py index c279ddf2d..55607912b 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ def has_environment_marker_support(): def main(): - install_requires = ['py>=1.4.33,<1.5', 'setuptools'] # pluggy is vendored in _pytest.vendored_packages + install_requires = ['py>=1.4.33', 'setuptools'] # pluggy is vendored in _pytest.vendored_packages extras_require = {} if has_environment_marker_support(): extras_require[':python_version=="2.6"'] = ['argparse', 'ordereddict'] From a220a40350a8a81c0f0e1986aa184e4c33da29d6 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 15 Nov 2017 00:12:42 +0000 Subject: [PATCH 3/8] Preparing release version 3.2.5 --- CHANGELOG.rst | 11 +++++++++++ changelog/2926.bugfix | 1 - doc/en/announce/index.rst | 1 + doc/en/announce/release-3.2.5.rst | 18 ++++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) delete mode 100644 changelog/2926.bugfix create mode 100644 doc/en/announce/release-3.2.5.rst diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 026290208..4146670f2 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,17 @@ .. towncrier release notes start +Pytest 3.2.5 (2017-11-15) +========================= + +Bug Fixes +--------- + +- Remove ``py<1.5`` restriction from ``pytest`` as this can cause version + conflicts in some installations. (`#2926 + `_) + + Pytest 3.2.4 (2017-11-13) ========================= diff --git a/changelog/2926.bugfix b/changelog/2926.bugfix deleted file mode 100644 index 09644b276..000000000 --- a/changelog/2926.bugfix +++ /dev/null @@ -1 +0,0 @@ -Remove ``py<1.5`` restriction from ``pytest`` as this can cause version conflicts in some installations. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index 2e3b45805..d340f5d46 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-3.2.5 release-3.2.4 release-3.2.3 release-3.2.2 diff --git a/doc/en/announce/release-3.2.5.rst b/doc/en/announce/release-3.2.5.rst new file mode 100644 index 000000000..a520ce2b3 --- /dev/null +++ b/doc/en/announce/release-3.2.5.rst @@ -0,0 +1,18 @@ +pytest-3.2.5 +======================================= + +pytest 3.2.5 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: + +* Bruno Oliveira + + +Happy testing, +The pytest Development Team From f9029f11af078bb6cb4cc3b8039fa2f256e86cd1 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 15 Nov 2017 13:53:43 -0200 Subject: [PATCH 4/8] Add Deprecation Roadmap to backward compatibility document We should replace the wiki document to a link to this document now --- doc/en/backwards-compatibility.rst | 64 ++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/doc/en/backwards-compatibility.rst b/doc/en/backwards-compatibility.rst index 8ceada52d..4daa33303 100644 --- a/doc/en/backwards-compatibility.rst +++ b/doc/en/backwards-compatibility.rst @@ -10,3 +10,67 @@ With the pytest 3.0 release we introduced a clear communication scheme for when To communicate changes we are already issuing deprecation warnings, but they are not displayed by default. In pytest 3.0 we changed the default setting so that pytest deprecation warnings are displayed if not explicitly silenced (with ``--disable-pytest-warnings``). We will only remove deprecated functionality in major releases (e.g. if we deprecate something in 3.0 we will remove it in 4.0), and keep it around for at least two minor releases (e.g. if we deprecate something in 3.9 and 4.0 is the next release, we will not remove it in 4.0 but in 5.0). + + +Deprecation Roadmap +------------------- + +This page lists deprecated features and when we plan to remove them. It is important to list the feature, the version where it got deprecated and the version we plan to remove it. + +Following our deprecation policy, we should aim to keep features for *at least* two minor versions after it was considered deprecated. + +3.4 +~~~ + +**Old style classes** + +Issue: `#2147 `_. + +Deprecated in ``3.2``. + +4.0 +~~~ + +**Yield tests** + +Deprecated in ``3.0``. + +**pytest-namespace hook** + +deprecated in ``3.2``. + +**Marks in parameter sets** + +Deprecated in ``3.2``. + +**--result-log** + +Deprecated in ``3.0``. + +See `#830 `_ for more information. Suggested alternative: `pytest-tap `_. + +**metafunc.addcall** + +Issue: `#2876 `_. + +Deprecated in ``3.3``. + +**pytest_plugins in non-toplevel conftests** + +There is a deep conceptual confusion as ``conftest.py`` files themselves are activated/deactivated based on path, but the plugins they depend on aren't. + +Issue: `#2639 `_. + +Not yet officially deprecated. + +**passing a single string to pytest.main()** + +Pass a list of strings to ``pytest.main()`` instead. + +Deprecated in ``3.1``. + +**[pytest] section in setup.cfg** + +Use ``[tool:pytest]`` instead for compatibility with other tools. + +Deprecated in ``3.0``. From b0f558da44ed2a72fefcee172cba57ed688ff8db Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 18 Nov 2017 11:57:00 -0200 Subject: [PATCH 5/8] Add Future/Past Releases section --- doc/en/backwards-compatibility.rst | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/doc/en/backwards-compatibility.rst b/doc/en/backwards-compatibility.rst index 4daa33303..2500e85a3 100644 --- a/doc/en/backwards-compatibility.rst +++ b/doc/en/backwards-compatibility.rst @@ -19,8 +19,12 @@ This page lists deprecated features and when we plan to remove them. It is impor Following our deprecation policy, we should aim to keep features for *at least* two minor versions after it was considered deprecated. + +Future Releases +~~~~~~~~~~~~~~~ + 3.4 -~~~ +^^^ **Old style classes** @@ -29,7 +33,7 @@ Issue: `#2147 `_. Deprecated in ``3.2``. 4.0 -~~~ +^^^ **Yield tests** @@ -74,3 +78,21 @@ Deprecated in ``3.1``. Use ``[tool:pytest]`` instead for compatibility with other tools. Deprecated in ``3.0``. + +Past Releases +~~~~~~~~~~~~~ + +3.0 +^^^ + +* The following deprecated commandline options were removed: + + * ``--genscript``: no longer supported; + * ``--no-assert``: use ``--assert=plain`` instead; + * ``--nomagic``: use ``--assert=plain`` instead; + * ``--report``: use ``-r`` instead; + +* Removed all ``py.test-X*`` entry points. The versioned, suffixed entry points + were never documented and a leftover from a pre-virtualenv era. These entry + points also created broken entry points in wheels, so removing them also + removes a source of confusion for users. From c8d52b633b6a7423633042c0eec3c67483ac13a3 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 21 Nov 2017 22:49:46 -0200 Subject: [PATCH 6/8] Fix assertion rewrite to match module names correctly Fix #2939 --- _pytest/assertion/rewrite.py | 2 +- changelog/2939.bugfix | 1 + testing/test_assertion.py | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 changelog/2939.bugfix diff --git a/_pytest/assertion/rewrite.py b/_pytest/assertion/rewrite.py index d48b6648f..27026b0fe 100644 --- a/_pytest/assertion/rewrite.py +++ b/_pytest/assertion/rewrite.py @@ -168,7 +168,7 @@ class AssertionRewritingHook(object): return True for marked in self._must_rewrite: - if name.startswith(marked): + if name == marked or name.startswith(marked + '.'): state.trace("matched marked file %r (from %r)" % (name, marked)) return True diff --git a/changelog/2939.bugfix b/changelog/2939.bugfix new file mode 100644 index 000000000..8aeedad01 --- /dev/null +++ b/changelog/2939.bugfix @@ -0,0 +1 @@ +Fix issue in assertion rewriting which could lead it to rewrite modules which should not be rewritten. diff --git a/testing/test_assertion.py b/testing/test_assertion.py index 4cd050d8c..244b47516 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -129,6 +129,24 @@ class TestImportHookInstallation(object): result = testdir.runpytest_subprocess('--assert=rewrite') assert result.ret == 0 + def test_pytest_plugins_rewrite_module_names_correctly(self, testdir): + """Test that we match files correctly when they are marked for rewriting (#2939).""" + contents = { + 'conftest.py': """ + pytest_plugins = "ham" + """, + 'ham.py': "", + 'hamster.py': "", + 'test_foo.py': """ + def test_foo(pytestconfig): + assert pytestconfig.pluginmanager.rewrite_hook.find_module('ham') is not None + assert pytestconfig.pluginmanager.rewrite_hook.find_module('hamster') is None + """, + } + testdir.makepyfile(**contents) + result = testdir.runpytest_subprocess('--assert=rewrite') + assert result.ret == 0 + @pytest.mark.parametrize('mode', ['plain', 'rewrite']) @pytest.mark.parametrize('plugin_state', ['development', 'installed']) def test_installed_plugin_rewrite(self, testdir, mode, plugin_state): From 5e71ffab8721bf04105cd1b64d03880bd4a3683a Mon Sep 17 00:00:00 2001 From: Sviatoslav Abakumov Date: Wed, 22 Nov 2017 15:47:15 +0300 Subject: [PATCH 7/8] Handle marks without description --- _pytest/mark.py | 6 ++++-- changelog/2942.bugfix | 1 + testing/test_mark.py | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 changelog/2942.bugfix diff --git a/_pytest/mark.py b/_pytest/mark.py index 454722ca2..61b8177e5 100644 --- a/_pytest/mark.py +++ b/_pytest/mark.py @@ -119,7 +119,9 @@ def pytest_cmdline_main(config): config._do_configure() tw = _pytest.config.create_terminal_writer(config) for line in config.getini("markers"): - name, rest = line.split(":", 1) + parts = line.split(":", 1) + name = parts[0] + rest = parts[1] if len(parts) == 2 else '' tw.write("@pytest.mark.%s:" % name, bold=True) tw.line(rest) tw.line() @@ -272,7 +274,7 @@ class MarkGenerator: pass self._markers = values = set() for line in self._config.getini("markers"): - marker, _ = line.split(":", 1) + marker = line.split(":", 1)[0] marker = marker.rstrip() x = marker.split("(", 1)[0] values.add(x) diff --git a/changelog/2942.bugfix b/changelog/2942.bugfix new file mode 100644 index 000000000..aca02f6d0 --- /dev/null +++ b/changelog/2942.bugfix @@ -0,0 +1 @@ +Handle marks without description diff --git a/testing/test_mark.py b/testing/test_mark.py index 3ac42daee..bf50e1587 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -161,11 +161,13 @@ def test_markers_option(testdir): markers = a1: this is a webtest marker a1some: another marker + nodescription """) result = testdir.runpytest("--markers", ) result.stdout.fnmatch_lines([ "*a1*this is a webtest*", "*a1some*another marker", + "*nodescription*", ]) @@ -186,6 +188,21 @@ def test_ini_markers_whitespace(testdir): rec.assertoutcome(passed=1) +def test_marker_without_description(testdir): + testdir.makefile(".cfg", setup=""" + [tool:pytest] + markers=slow + """) + testdir.makeconftest(""" + import pytest + pytest.mark.xfail('FAIL') + """) + ftdir = testdir.mkdir("ft1_dummy") + testdir.tmpdir.join("conftest.py").move(ftdir.join("conftest.py")) + rec = testdir.runpytest_subprocess("--strict") + rec.assert_outcomes() + + def test_markers_option_with_plugin_in_current_dir(testdir): testdir.makeconftest('pytest_plugins = "flip_flop"') testdir.makepyfile(flip_flop="""\ From 378eb5d67b099128b498da5521737100bf18a6a0 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 22 Nov 2017 11:24:48 -0200 Subject: [PATCH 8/8] Minor formatting change in CHANGELOG --- changelog/2942.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/2942.bugfix b/changelog/2942.bugfix index aca02f6d0..3223719e2 100644 --- a/changelog/2942.bugfix +++ b/changelog/2942.bugfix @@ -1 +1 @@ -Handle marks without description +Handle marks without description in ``pytest.ini``.