From 11ec6aeafb6f07047c043055f4beb33d83f1d4ba Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 1 Sep 2017 18:33:30 -0300 Subject: [PATCH 1/6] Add test environment using pluggy from master branch Fix #2737 --- .travis.yml | 2 ++ appveyor.yml | 2 ++ setup.py | 6 +++++- tox.ini | 7 +++++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6d8d58328..387ff7160 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,10 +18,12 @@ env: - TOXENV=py27-xdist - TOXENV=py27-trial - TOXENV=py27-numpy + - TOXENV=py27-pluggymaster - TOXENV=py35-pexpect - TOXENV=py35-xdist - TOXENV=py35-trial - TOXENV=py35-numpy + - TOXENV=py35-pluggymaster - TOXENV=py27-nobyte - TOXENV=doctesting - TOXENV=freeze diff --git a/appveyor.yml b/appveyor.yml index abf033b4c..337d89aec 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -21,10 +21,12 @@ environment: - TOXENV: "py27-xdist" - TOXENV: "py27-trial" - TOXENV: "py27-numpy" + - TOXENV: "py27-pluggymaster" - TOXENV: "py35-pexpect" - TOXENV: "py35-xdist" - TOXENV: "py35-trial" - TOXENV: "py35-numpy" + - TOXENV: "py35-pluggymaster" - TOXENV: "py27-nobyte" - TOXENV: "doctesting" - TOXENV: "freeze" diff --git a/setup.py b/setup.py index 7b781ed69..4d74e6bca 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,11 @@ def has_environment_marker_support(): def main(): - install_requires = ['py>=1.4.33', 'six>=1.10.0','setuptools', 'pluggy>=0.4.0,<0.5'] + install_requires = ['py>=1.4.33', 'six>=1.10.0', 'setuptools'] + # if _PYTEST_SETUP_SKIP_PLUGGY_DEP is set, skip installing pluggy; + # used by tox.ini to test with pluggy master + if '_PYTEST_SETUP_SKIP_PLUGGY_DEP' not in os.environ: + install_requires.append('pluggy>=0.4.0,<0.5') extras_require = {} if has_environment_marker_support(): extras_require[':python_version=="2.6"'] = ['argparse', 'ordereddict'] diff --git a/tox.ini b/tox.ini index 907b7891b..c72bd7c0a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] minversion = 2.0 distshare = {homedir}/.tox/distshare -# make sure to update environment list on appveyor.yml +# make sure to update environment list in travis.yml and appveyor.yml envlist = linting py26 @@ -12,7 +12,7 @@ envlist = py36 py37 pypy - {py27,py35}-{pexpect,xdist,trial,numpy} + {py27,py35}-{pexpect,xdist,trial,numpy,pluggymaster} py27-nobyte doctesting freeze @@ -21,11 +21,14 @@ envlist = [testenv] commands = pytest --lsof -rfsxX {posargs:testing} passenv = USER USERNAME +setenv= + pluggymaster: _PYTEST_SETUP_SKIP_PLUGGY_DEP=1 deps = hypothesis>=3.5.2 nose mock requests + pluggymaster: git+https://github.com/pytest-dev/pluggy.git@master [testenv:py26] commands = pytest --lsof -rfsxX {posargs:testing} From 3dc0da9339e4952cb276b32f451fa8cdc23d38be Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 30 Aug 2017 20:23:55 -0300 Subject: [PATCH 2/6] 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(""" From c42d966a4088d9ef26eac70040fe68029b71877c Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 1 Sep 2017 18:55:21 -0300 Subject: [PATCH 3/6] Change all pytest report options to the more concise '-ra' in tox.ini --- tox.ini | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tox.ini b/tox.ini index c72bd7c0a..89383e6fb 100644 --- a/tox.ini +++ b/tox.ini @@ -19,7 +19,7 @@ envlist = docs [testenv] -commands = pytest --lsof -rfsxX {posargs:testing} +commands = pytest --lsof -ra {posargs:testing} passenv = USER USERNAME setenv= pluggymaster: _PYTEST_SETUP_SKIP_PLUGGY_DEP=1 @@ -31,7 +31,7 @@ deps = pluggymaster: git+https://github.com/pytest-dev/pluggy.git@master [testenv:py26] -commands = pytest --lsof -rfsxX {posargs:testing} +commands = pytest --lsof -ra {posargs:testing} # pinning mock to last supported version for python 2.6 deps = hypothesis<3.0 @@ -46,7 +46,7 @@ deps = mock nose commands = - pytest -n3 -rfsxX --runpytest=subprocess {posargs:testing} + pytest -n3 -ra --runpytest=subprocess {posargs:testing} [testenv:linting] @@ -69,26 +69,26 @@ deps = nose hypothesis>=3.5.2 commands = - pytest -n1 -rfsxX {posargs:testing} + pytest -n1 -ra {posargs:testing} [testenv:py35-xdist] deps = {[testenv:py27-xdist]deps} commands = - pytest -n3 -rfsxX {posargs:testing} + pytest -n3 -ra {posargs:testing} [testenv:py27-pexpect] changedir = testing platform = linux|darwin deps = pexpect commands = - pytest -rfsxX test_pdb.py test_terminal.py test_unittest.py + pytest -ra test_pdb.py test_terminal.py test_unittest.py [testenv:py35-pexpect] changedir = testing platform = linux|darwin deps = {[testenv:py27-pexpect]deps} commands = - pytest -rfsxX test_pdb.py test_terminal.py test_unittest.py + pytest -ra test_pdb.py test_terminal.py test_unittest.py [testenv:py27-nobyte] deps = @@ -98,7 +98,7 @@ distribute = true setenv = PYTHONDONTWRITEBYTECODE=1 commands = - pytest -n3 -rfsxX {posargs:testing} + pytest -n3 -ra {posargs:testing} [testenv:py27-trial] deps = twisted @@ -113,12 +113,12 @@ commands = [testenv:py27-numpy] deps=numpy commands= - pytest -rfsxX {posargs:testing/python/approx.py} + pytest -ra {posargs:testing/python/approx.py} [testenv:py35-numpy] deps=numpy commands= - pytest -rfsxX {posargs:testing/python/approx.py} + pytest -ra {posargs:testing/python/approx.py} [testenv:docs] skipsdist = True @@ -141,7 +141,7 @@ changedir = doc/ deps = PyYAML commands = - pytest -rfsxX en + pytest -ra en pytest --doctest-modules --pyargs _pytest [testenv:regen] @@ -170,7 +170,7 @@ commands = [testenv:jython] changedir = testing commands = - {envpython} {envbindir}/py.test-jython -rfsxX {posargs} + {envpython} {envbindir}/py.test-jython -ra {posargs} [testenv:freeze] changedir = testing/freeze @@ -197,7 +197,7 @@ commands = minversion = 2.0 plugins = pytester #--pyargs --doctest-modules --ignore=.tox -addopts = -rxsX -p pytester --ignore=testing/cx_freeze +addopts = -ra -p pytester --ignore=testing/cx_freeze rsyncdirs = tox.ini pytest.py _pytest testing python_files = test_*.py *_test.py testing/*/*.py python_classes = Test Acceptance From 9bbf14d0f6d68a175a440daffad97c63c51fde37 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 1 Sep 2017 20:40:14 -0300 Subject: [PATCH 4/6] Create explicit 'pluggymaster' env definitions For some reason, the previous approach brakes 'coveralls' because pip still tries to install the 'pluggy' master requirement (git+https://...) --- tox.ini | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 89383e6fb..59a151895 100644 --- a/tox.ini +++ b/tox.ini @@ -21,14 +21,11 @@ envlist = [testenv] commands = pytest --lsof -ra {posargs:testing} passenv = USER USERNAME -setenv= - pluggymaster: _PYTEST_SETUP_SKIP_PLUGGY_DEP=1 deps = hypothesis>=3.5.2 nose mock requests - pluggymaster: git+https://github.com/pytest-dev/pluggy.git@master [testenv:py26] commands = pytest --lsof -ra {posargs:testing} @@ -120,6 +117,24 @@ deps=numpy commands= pytest -ra {posargs:testing/python/approx.py} +[testenv:py27-pluggymaster] +passenv={[testenv]passenv} +commands={[testenv]commands} +setenv= + _PYTEST_SETUP_SKIP_PLUGGY_DEP=1 +deps = + {[testenv]deps} + git+https://github.com/pytest-dev/pluggy.git@master + +[testenv:py35-pluggymaster] +passenv={[testenv]passenv} +commands={[testenv]commands} +setenv= + _PYTEST_SETUP_SKIP_PLUGGY_DEP=1 +deps = + {[testenv]deps} + git+https://github.com/pytest-dev/pluggy.git@master + [testenv:docs] skipsdist = True usedevelop = True From d9992558fc0d1eac599ccf54b077ea37e1e06ac0 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 5 Sep 2017 19:04:58 -0300 Subject: [PATCH 5/6] Refactor tox.ini so pluggymaster envs share definitions --- tox.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 59a151895..fa5565048 100644 --- a/tox.ini +++ b/tox.ini @@ -127,12 +127,12 @@ deps = git+https://github.com/pytest-dev/pluggy.git@master [testenv:py35-pluggymaster] -passenv={[testenv]passenv} -commands={[testenv]commands} +passenv={[testenv:py27-pluggymaster]passenv} +commands={[testenv:py27-pluggymaster]commands} setenv= _PYTEST_SETUP_SKIP_PLUGGY_DEP=1 deps = - {[testenv]deps} + {[testenv:py27-pluggymaster]deps} git+https://github.com/pytest-dev/pluggy.git@master [testenv:docs] From 7d59b2e350cbff1454355bc5225fc0f93bbba3a7 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 5 Sep 2017 19:08:20 -0300 Subject: [PATCH 6/6] Fix call to outcome.force_result Even though the test is not running at the moment (xfail), at least we avoid future confusion --- testing/test_collection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/test_collection.py b/testing/test_collection.py index 1fc1a5d89..a4ed9f22c 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -281,7 +281,7 @@ class TestPrunetraceback(object): outcome = yield rep = outcome.get_result() rep.headerlines += ["header1"] - outcome.set_result(rep) + outcome.force_result(rep) """) result = testdir.runpytest(p) result.stdout.fnmatch_lines([