diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index bf9fc199f..690426d68 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -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." diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2c3f5ff9c..eabd28be1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,48 @@ .. towncrier release notes start +Pytest 3.3.1 (2017-12-05) +========================= + +Bug Fixes +--------- + +- Fix issue about ``-p no:`` having no effect. (`#2920 + `_) + +- Fix regression with warnings that contained non-strings in their arguments in + Python 2. (`#2956 `_) + +- Always escape null bytes when setting ``PYTEST_CURRENT_TEST``. (`#2957 + `_) + +- Fix ``ZeroDivisionError`` when using the ``testmon`` plugin when no tests + were actually collected. (`#2971 + `_) + +- Bring back ``TerminalReporter.writer`` as an alias to + ``TerminalReporter._tw``. This alias was removed by accident in the ``3.3.0`` + release. (`#2984 `_) + +- The ``pytest-capturelog`` plugin is now also blacklisted, avoiding errors when + running pytest with it still installed. (`#3004 + `_) + + +Improved Documentation +---------------------- + +- Fix broken link to plugin ``pytest-localserver``. (`#2963 + `_) + + +Trivial/Internal Changes +------------------------ + +- Update github "bugs" link in ``CONTRIBUTING.rst`` (`#2949 + `_) + + Pytest 3.3.0 (2017-11-23) ========================= @@ -38,6 +80,14 @@ Deprecations and Removals with the boolean ``Node._skipped_by_mark``. (`#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 `_ + for details and a recommended workaround. + Features -------- diff --git a/_pytest/config.py b/_pytest/config.py index 499c8079d..ce7468f72 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -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: diff --git a/_pytest/fixtures.py b/_pytest/fixtures.py index 19b977224..e09ffaddb 100644 --- a/_pytest/fixtures.py +++ b/_pytest/fixtures.py @@ -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): diff --git a/_pytest/terminal.py b/_pytest/terminal.py index 8538ee6aa..1aba5e845 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -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: diff --git a/changelog/2920.bugfix b/changelog/2920.bugfix deleted file mode 100644 index 9c5217278..000000000 --- a/changelog/2920.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix issue about ``-p no:`` having no effect. diff --git a/changelog/2949.trivial b/changelog/2949.trivial deleted file mode 100644 index 39789e72b..000000000 --- a/changelog/2949.trivial +++ /dev/null @@ -1 +0,0 @@ -Update github "bugs" link in CONTRIBUTING.rst diff --git a/changelog/2956.bugfix b/changelog/2956.bugfix deleted file mode 100644 index 13717657b..000000000 --- a/changelog/2956.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix regression with warnings that contained non-strings in their arguments in Python 2. diff --git a/changelog/2957.bugfix b/changelog/2957.bugfix deleted file mode 100644 index 589665b69..000000000 --- a/changelog/2957.bugfix +++ /dev/null @@ -1 +0,0 @@ -Always escape null bytes when setting ``PYTEST_CURRENT_TEST``. diff --git a/changelog/2963.doc b/changelog/2963.doc deleted file mode 100644 index c9a1d661b..000000000 --- a/changelog/2963.doc +++ /dev/null @@ -1 +0,0 @@ -Fix broken link to plugin pytest-localserver. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index 1a5f3760b..b6255bc6d 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-3.3.1 release-3.3.0 release-3.2.5 release-3.2.4 diff --git a/doc/en/announce/release-3.3.1.rst b/doc/en/announce/release-3.3.1.rst new file mode 100644 index 000000000..074c3d5ac --- /dev/null +++ b/doc/en/announce/release-3.3.1.rst @@ -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 diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index f3c40cb3d..420070d91 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -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*", ]) diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 98a8ca121..97c2f71fb 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -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([