Merge pull request #2744 from nicoddemus/pluggy-master

Add test environment using pluggy from master branch
This commit is contained in:
Bruno Oliveira 2017-09-06 15:03:19 -03:00 committed by GitHub
commit b55a4f805f
10 changed files with 71 additions and 65 deletions

View File

@ -19,10 +19,12 @@ env:
- TOXENV=py27-xdist
- TOXENV=py27-trial
- TOXENV=py27-numpy
- TOXENV=py36-pexpect
- TOXENV=py36-xdist
- TOXENV=py36-trial
- TOXENV=py36-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=docs

View File

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

View File

@ -21,10 +21,12 @@ environment:
- TOXENV: "py27-xdist"
- TOXENV: "py27-trial"
- TOXENV: "py27-numpy"
- TOXENV: "py36-pexpect"
- TOXENV: "py36-xdist"
- TOXENV: "py36-trial"
- TOXENV: "py36-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: "py35-freeze"

View File

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

View File

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

View File

@ -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.force_result(rep)
""")
result = testdir.runpytest(p)
result.stdout.fnmatch_lines([

View File

@ -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 = []

View File

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

View File

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

48
tox.ini
View File

@ -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,14 +12,14 @@ envlist =
py36
py37
pypy
{py27,py35}-{pexpect,xdist,trial,numpy}
{py27,py35}-{pexpect,xdist,trial,numpy,pluggymaster}
py27-nobyte
doctesting
py35-freeze
docs
[testenv]
commands = pytest --lsof -rfsxX {posargs:testing}
commands = pytest --lsof -ra {posargs:testing}
passenv = USER USERNAME
deps =
hypothesis>=3.5.2
@ -28,7 +28,7 @@ deps =
requests
[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
@ -43,7 +43,7 @@ deps =
mock
nose
commands =
pytest -n3 -rfsxX --runpytest=subprocess {posargs:testing}
pytest -n3 -ra --runpytest=subprocess {posargs:testing}
[testenv:linting]
@ -66,26 +66,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 =
@ -95,7 +95,7 @@ distribute = true
setenv =
PYTHONDONTWRITEBYTECODE=1
commands =
pytest -n3 -rfsxX {posargs:testing}
pytest -n3 -ra {posargs:testing}
[testenv:py27-trial]
deps = twisted
@ -110,12 +110,30 @@ 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: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:py27-pluggymaster]passenv}
commands={[testenv:py27-pluggymaster]commands}
setenv=
_PYTEST_SETUP_SKIP_PLUGGY_DEP=1
deps =
{[testenv:py27-pluggymaster]deps}
git+https://github.com/pytest-dev/pluggy.git@master
[testenv:docs]
skipsdist = True
@ -138,7 +156,7 @@ changedir = doc/
deps =
PyYAML
commands =
pytest -rfsxX en
pytest -ra en
pytest --doctest-modules --pyargs _pytest
[testenv:regen]
@ -167,7 +185,7 @@ commands =
[testenv:jython]
changedir = testing
commands =
{envpython} {envbindir}/py.test-jython -rfsxX {posargs}
{envpython} {envbindir}/py.test-jython -ra {posargs}
[testenv:py35-freeze]
changedir = testing/freeze
@ -194,7 +212,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