From 3dc0da9339e4952cb276b32f451fa8cdc23d38be Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 30 Aug 2017 20:23:55 -0300 Subject: [PATCH] Remove __multicall__ warning and usages in testing pluggy>=0.5 already warns about those --- _pytest/config.py | 11 ----------- testing/python/collect.py | 8 +++++--- testing/test_collection.py | 8 +++++--- testing/test_pluginmanager.py | 17 ----------------- testing/test_runner.py | 12 +++++++----- testing/test_unittest.py | 6 ++++-- 6 files changed, 21 insertions(+), 41 deletions(-) diff --git a/_pytest/config.py b/_pytest/config.py index fd295fc73..795056449 100644 --- a/_pytest/config.py +++ b/_pytest/config.py @@ -241,17 +241,6 @@ class PytestPluginManager(PluginManager): "historic": hasattr(method, "historic")} return opts - def _verify_hook(self, hook, hookmethod): - super(PytestPluginManager, self)._verify_hook(hook, hookmethod) - if "__multicall__" in hookmethod.argnames: - fslineno = _pytest._code.getfslineno(hookmethod.function) - warning = dict(code="I1", - fslocation=fslineno, - nodeid=None, - message="%r hook uses deprecated __multicall__ " - "argument" % (hook.name)) - self._warn(warning) - def register(self, plugin, name=None): ret = super(PytestPluginManager, self).register(plugin, name) if ret: diff --git a/testing/python/collect.py b/testing/python/collect.py index bd7013b44..d67437392 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -809,10 +809,12 @@ class TestConftestCustomization(object): def test_customized_pymakemodule_issue205_subdir(self, testdir): b = testdir.mkdir("a").mkdir("b") b.join("conftest.py").write(_pytest._code.Source(""" - def pytest_pycollect_makemodule(__multicall__): - mod = __multicall__.execute() + import pytest + @pytest.hookimpl(hookwrapper=True) + def pytest_pycollect_makemodule(): + outcome = yield + mod = outcome.get_result() mod.obj.hello = "world" - return mod """)) b.join("test_module.py").write(_pytest._code.Source(""" def test_hello(): diff --git a/testing/test_collection.py b/testing/test_collection.py index 5d1654410..1fc1a5d89 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -276,10 +276,12 @@ class TestPrunetraceback(object): """) testdir.makeconftest(""" import pytest - def pytest_make_collect_report(__multicall__): - rep = __multicall__.execute() + @pytest.hookimpl(hookwrapper=True) + def pytest_make_collect_report(): + outcome = yield + rep = outcome.get_result() rep.headerlines += ["header1"] - return rep + outcome.set_result(rep) """) result = testdir.runpytest(p) result.stdout.fnmatch_lines([ diff --git a/testing/test_pluginmanager.py b/testing/test_pluginmanager.py index be7980c26..2838f83c5 100644 --- a/testing/test_pluginmanager.py +++ b/testing/test_pluginmanager.py @@ -155,23 +155,6 @@ class TestPytestPluginInteractions(object): ihook_b = session.gethookproxy(testdir.tmpdir.join('tests')) assert ihook_a is not ihook_b - def test_warn_on_deprecated_multicall(self, pytestpm): - warnings = [] - - class get_warnings(object): - def pytest_logwarning(self, message): - warnings.append(message) - - class Plugin(object): - def pytest_configure(self, __multicall__): - pass - - pytestpm.register(get_warnings()) - before = list(warnings) - pytestpm.register(Plugin()) - assert len(warnings) == len(before) + 1 - assert "deprecated" in warnings[-1] - def test_warn_on_deprecated_addhooks(self, pytestpm): warnings = [] diff --git a/testing/test_runner.py b/testing/test_runner.py index 1ab449ba3..1b39a989f 100644 --- a/testing/test_runner.py +++ b/testing/test_runner.py @@ -637,12 +637,14 @@ def test_pytest_cmdline_main(testdir): def test_unicode_in_longrepr(testdir): testdir.makeconftest(""" - import py - def pytest_runtest_makereport(__multicall__): - rep = __multicall__.execute() + # -*- coding: utf-8 -*- + import pytest + @pytest.hookimpl(hookwrapper=True) + def pytest_runtest_makereport(): + outcome = yield + rep = outcome.get_result() if rep.when == "call": - rep.longrepr = py.builtin._totext("\\xc3\\xa4", "utf8") - return rep + rep.longrepr = u'รค' """) testdir.makepyfile(""" def test_out(): diff --git a/testing/test_unittest.py b/testing/test_unittest.py index 84f432a54..8051deda4 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -770,8 +770,10 @@ def test_no_teardown_if_setupclass_failed(testdir): def test_issue333_result_clearing(testdir): testdir.makeconftest(""" - def pytest_runtest_call(__multicall__, item): - __multicall__.execute() + import pytest + @pytest.hookimpl(hookwrapper=True) + def pytest_runtest_call(item): + yield assert 0 """) testdir.makepyfile("""