Merge remote-tracking branch 'upstream/master' into release-3.3.0

This commit is contained in:
Bruno Oliveira 2017-11-23 20:20:40 +00:00
commit f50ace7c0a
11 changed files with 160 additions and 4 deletions

View File

@ -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
<https://github.com/pytest-dev/pytest/issues/2926>`_)
Pytest 3.2.4 (2017-11-13)
=========================
@ -28,6 +39,8 @@ Bug Fixes
failed example in the docstring is < 9. (`#2882
<https://github.com/pytest-dev/pytest/issues/2882>`_)
- Match fixture paths against actual path segments in order to avoid matching folders which share a prefix.
(`#2836 <https://github.com/pytest-dev/pytest/issues/2836>`_)
Improved Documentation
----------------------

View File

@ -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

View File

@ -141,7 +141,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()
@ -298,7 +300,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)

View File

@ -1 +0,0 @@
Match fixture paths against actual path segments in order to avoid matching folders which share a prefix.

1
changelog/2939.bugfix Normal file
View File

@ -0,0 +1 @@
Fix issue in assertion rewriting which could lead it to rewrite modules which should not be rewritten.

1
changelog/2942.bugfix Normal file
View File

@ -0,0 +1 @@
Handle marks without description in ``pytest.ini``.

View File

@ -6,6 +6,7 @@ Release announcements
:maxdepth: 2
release-3.2.5
release-3.2.4
release-3.2.3
release-3.2.2

View File

@ -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

View File

@ -10,3 +10,89 @@ 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.
Future Releases
~~~~~~~~~~~~~~~
3.4
^^^
**Old style classes**
Issue: `#2147 <https://github.com/pytest-dev/pytest/issues/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 <https://github.com/pytest-dev/pytest/issues/830>`_ for more information. Suggested alternative: `pytest-tap <https://pypi.python.org/pypi/pytest-tap>`_.
**metafunc.addcall**
Issue: `#2876 <https://github.com/pytest-dev/pytest/issues/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 <https://github.com/pytest-dev/pytest/issues/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``.
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.

View File

@ -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):

View File

@ -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="""\