Skip to content

Add test environment using pluggy from master branch #2744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions _pytest/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,6 @@ def parse_hookspec_opts(self, module_or_class, name):
"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:
Expand Down
10 changes: 6 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
8 changes: 5 additions & 3 deletions testing/python/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,10 +809,12 @@ def pytest_pycollect_makemodule(path, parent):
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():
Expand Down
8 changes: 5 additions & 3 deletions testing/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,12 @@ def test_collect_report_postprocessing(self, testdir):
""")
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([
Expand Down
17 changes: 0 additions & 17 deletions testing/test_pluginmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,23 +155,6 @@ def test_hook_proxy(self, testdir):
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 = []

Expand Down
12 changes: 7 additions & 5 deletions testing/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,14 @@ def test_hello():

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():
Expand Down
6 changes: 4 additions & 2 deletions testing/test_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,10 @@ def test_notTornDown():

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("""
Expand Down
48 changes: 33 additions & 15 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -43,7 +43,7 @@ deps =
mock
nose
commands =
pytest -n3 -rfsxX --runpytest=subprocess {posargs:testing}
pytest -n3 -ra --runpytest=subprocess {posargs:testing}


[testenv:linting]
Expand All @@ -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 =
Expand All @@ -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
Expand All @@ -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 =
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicoddemus heh I was actually thinking to derive setenv and deps just because they're common to these two envs.

Not a big deal though :)

{[testenv:py27-pluggymaster]deps}
git+https://github.com/pytest-dev/pluggy.git@master

[testenv:docs]
skipsdist = True
Expand All @@ -138,7 +156,7 @@ changedir = doc/
deps =
PyYAML
commands =
pytest -rfsxX en
pytest -ra en
pytest --doctest-modules --pyargs _pytest

[testenv:regen]
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down