Merge remote-tracking branch 'upstream/master' into features

This commit is contained in:
Bruno Oliveira 2017-12-05 22:30:35 -02:00
commit 655146e522
14 changed files with 125 additions and 16 deletions

View File

@ -3,7 +3,7 @@ Thanks for submitting a PR, your contribution is really appreciated!
Here's a quick checklist that should be present in PRs:
- [ ] Add a new news fragment into the changelog folder
* name it `$issue_id.$type` for example (588.bug)
* name it `$issue_id.$type` for example (588.bugfix)
* if you don't have an issue_id change it to the pr id after creating the pr
* ensure type is one of `removal`, `feature`, `bugfix`, `vendor`, `doc` or `trivial`
* Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

View File

@ -8,6 +8,48 @@
.. towncrier release notes start
Pytest 3.3.1 (2017-12-05)
=========================
Bug Fixes
---------
- Fix issue about ``-p no:<plugin>`` having no effect. (`#2920
<https://github.com/pytest-dev/pytest/issues/2920>`_)
- Fix regression with warnings that contained non-strings in their arguments in
Python 2. (`#2956 <https://github.com/pytest-dev/pytest/issues/2956>`_)
- Always escape null bytes when setting ``PYTEST_CURRENT_TEST``. (`#2957
<https://github.com/pytest-dev/pytest/issues/2957>`_)
- Fix ``ZeroDivisionError`` when using the ``testmon`` plugin when no tests
were actually collected. (`#2971
<https://github.com/pytest-dev/pytest/issues/2971>`_)
- Bring back ``TerminalReporter.writer`` as an alias to
``TerminalReporter._tw``. This alias was removed by accident in the ``3.3.0``
release. (`#2984 <https://github.com/pytest-dev/pytest/issues/2984>`_)
- The ``pytest-capturelog`` plugin is now also blacklisted, avoiding errors when
running pytest with it still installed. (`#3004
<https://github.com/pytest-dev/pytest/issues/3004>`_)
Improved Documentation
----------------------
- Fix broken link to plugin ``pytest-localserver``. (`#2963
<https://github.com/pytest-dev/pytest/issues/2963>`_)
Trivial/Internal Changes
------------------------
- Update github "bugs" link in ``CONTRIBUTING.rst`` (`#2949
<https://github.com/pytest-dev/pytest/issues/2949>`_)
Pytest 3.3.0 (2017-11-23)
=========================
@ -38,6 +80,14 @@ Deprecations and Removals
with the boolean ``Node._skipped_by_mark``. (`#2767
<https://github.com/pytest-dev/pytest/issues/2767>`_)
- The ``params`` list passed to ``pytest.fixture`` is now for
all effects considered immutable and frozen at the moment of the ``pytest.fixture``
call. Previously the list could be changed before the first invocation of the fixture
allowing for a form of dynamic parametrization (for example, updated from command-line options),
but this was an unwanted implementation detail which complicated the internals and prevented
some internal cleanup. See issue `#2959 <https://github.com/pytest-dev/pytest/issues/2959>`_
for details and a recommended workaround.
Features
--------

View File

@ -242,9 +242,10 @@ class PytestPluginManager(PluginManager):
return opts
def register(self, plugin, name=None):
if name == 'pytest_catchlog':
self._warn('pytest-catchlog plugin has been merged into the core, '
'please remove it from your requirements.')
if name in ['pytest_catchlog', 'pytest_capturelog']:
self._warn('{0} plugin has been merged into the core, '
'please remove it from your requirements.'.format(
name.replace('_', '-')))
return
ret = super(PytestPluginManager, self).register(plugin, name)
if ret:

View File

@ -553,7 +553,7 @@ class FixtureRequest(FuncargnamesCompatAttr):
if node is None and scope == "class":
# fallback to function item itself
node = self._pyfuncitem
assert node
assert node, 'Could not obtain a node for scope "{}" for function {!r}'.format(scope, self._pyfuncitem)
return node
def __repr__(self):

View File

@ -145,6 +145,8 @@ class TerminalReporter:
if file is None:
file = sys.stdout
self._tw = _pytest.config.create_terminal_writer(config, file)
# self.writer will be deprecated in pytest-3.4
self.writer = self._tw
self._screen_width = self._tw.fullwidth
self.currentfspath = None
self.reportchars = getreportopt(config)
@ -313,8 +315,11 @@ class TerminalReporter:
_PROGRESS_LENGTH = len(' [100%]')
def _get_progress_information_message(self):
progress = self._progress_items_reported * 100 // self._session.testscollected
return ' [{:3d}%]'.format(progress)
collected = self._session.testscollected
if collected:
progress = self._progress_items_reported * 100 // collected
return ' [{:3d}%]'.format(progress)
return ' [100%]'
def _write_progress_information_filling_space(self):
if not self._show_progress_info:

View File

@ -1 +0,0 @@
Fix issue about ``-p no:<plugin>`` having no effect.

View File

@ -1 +0,0 @@
Update github "bugs" link in CONTRIBUTING.rst

View File

@ -1 +0,0 @@
Fix regression with warnings that contained non-strings in their arguments in Python 2.

View File

@ -1 +0,0 @@
Always escape null bytes when setting ``PYTEST_CURRENT_TEST``.

View File

@ -1 +0,0 @@
Fix broken link to plugin pytest-localserver.

View File

@ -6,6 +6,7 @@ Release announcements
:maxdepth: 2
release-3.3.1
release-3.3.0
release-3.2.5
release-3.2.4

View File

@ -0,0 +1,25 @@
pytest-3.3.1
=======================================
pytest 3.3.1 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
* Daniel Hahler
* Eugene Prikazchikov
* Florian Bruhin
* Roland Puntaier
* Ronny Pfannschmidt
* Sebastian Rahlf
* Tom Viner
Happy testing,
The pytest Development Team

View File

@ -101,14 +101,28 @@ def test_metafunc_addcall_deprecated(testdir):
])
def test_pytest_catchlog_deprecated(testdir):
def test_terminal_reporter_writer_attr(pytestconfig):
"""Check that TerminalReporter._tw is also available as 'writer' (#2984)
This attribute is planned to be deprecated in 3.4.
"""
try:
import xdist # noqa
pytest.skip('xdist workers disable the terminal reporter plugin')
except ImportError:
pass
terminal_reporter = pytestconfig.pluginmanager.get_plugin('terminalreporter')
assert terminal_reporter.writer is terminal_reporter._tw
@pytest.mark.parametrize('plugin', ['catchlog', 'capturelog'])
def test_pytest_catchlog_deprecated(testdir, plugin):
testdir.makepyfile("""
def test_func(pytestconfig):
pytestconfig.pluginmanager.register(None, 'pytest_catchlog')
""")
pytestconfig.pluginmanager.register(None, 'pytest_{0}')
""".format(plugin))
res = testdir.runpytest()
assert res.ret == 0
res.stdout.fnmatch_lines([
"*pytest-catchlog plugin has been merged into the core*",
"*pytest-*log plugin has been merged into the core*",
"*1 passed, 1 warnings*",
])

View File

@ -988,6 +988,24 @@ class TestProgress:
""",
)
def test_zero_tests_collected(self, testdir):
"""Some plugins (testmon for example) might issue pytest_runtest_logreport without any tests being
actually collected (#2971)."""
testdir.makeconftest("""
def pytest_collection_modifyitems(items, config):
from _pytest.runner import CollectReport
for node_id in ('nodeid1', 'nodeid2'):
rep = CollectReport(node_id, 'passed', None, None)
rep.when = 'passed'
rep.duration = 0.1
config.hook.pytest_runtest_logreport(report=rep)
""")
output = testdir.runpytest()
assert 'ZeroDivisionError' not in output.stdout.str()
output.stdout.fnmatch_lines([
'=* 2 passed in *=',
])
def test_normal(self, many_tests_file, testdir):
output = testdir.runpytest()
output.stdout.re_match_lines([