Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9c43a0933 | ||
|
|
d753e53ee4 | ||
|
|
81309e8d69 | ||
|
|
26d0fcabf6 | ||
|
|
486fa25bcb | ||
|
|
bc44fea8a8 | ||
|
|
6d544cef9a | ||
|
|
93780dcccc | ||
|
|
ca58e5e7ed | ||
|
|
d8a794bc84 | ||
|
|
ca032692a8 | ||
|
|
6fc02bb04a | ||
|
|
c5f65b39ec | ||
|
|
f00f9ecf58 | ||
|
|
48b7014530 | ||
|
|
1dec9dc246 | ||
|
|
f6ecaa9b7f | ||
|
|
1276df4cfa | ||
|
|
ccdb36a477 | ||
|
|
45ddc221ef | ||
|
|
c3dbd05bd1 | ||
|
|
b9423d894c | ||
|
|
242c009866 | ||
|
|
0ee219dc48 | ||
|
|
ad5e35213d | ||
|
|
76075f5de1 | ||
|
|
f8d51aab57 | ||
|
|
ac2bf10fe2 | ||
|
|
fa85371c73 | ||
|
|
d55fab3aa7 | ||
|
|
4632df37a6 | ||
|
|
ca94bda1b7 | ||
|
|
261d4189f0 | ||
|
|
f283dddf36 | ||
|
|
ab5f12f92e | ||
|
|
b28c3d98c5 | ||
|
|
b94dcfe4cd | ||
|
|
311554324a | ||
|
|
5bb35b0f26 | ||
|
|
47d271ad97 | ||
|
|
7fb7bd9d04 |
@@ -1,3 +1,41 @@
|
|||||||
|
pytest-xdist 1.27.0 (2019-02-15)
|
||||||
|
================================
|
||||||
|
|
||||||
|
Features
|
||||||
|
--------
|
||||||
|
|
||||||
|
- `#374 <https://github.com/pytest-dev/pytest-xdist/issues/374>`_: The new ``pytest_xdist_getremotemodule`` hook allows overriding the module run on remote nodes.
|
||||||
|
|
||||||
|
- `#415 <https://github.com/pytest-dev/pytest-xdist/issues/415>`_: Improve behavior of ``--numprocesses=auto`` to work well with ``--pdb`` option.
|
||||||
|
|
||||||
|
|
||||||
|
pytest-xdist 1.26.1 (2019-01-28)
|
||||||
|
================================
|
||||||
|
|
||||||
|
Bug Fixes
|
||||||
|
---------
|
||||||
|
|
||||||
|
- `#406 <https://github.com/pytest-dev/pytest-xdist/issues/406>`_: Do not implement deprecated ``pytest_logwarning`` hook in pytest versions where it is deprecated.
|
||||||
|
|
||||||
|
|
||||||
|
pytest-xdist 1.26.0 (2019-01-11)
|
||||||
|
================================
|
||||||
|
|
||||||
|
Features
|
||||||
|
--------
|
||||||
|
|
||||||
|
- `#376 <https://github.com/pytest-dev/pytest-xdist/issues/376>`_: The current directory is no longer added ``sys.path`` for local workers, only for remote connections.
|
||||||
|
|
||||||
|
This behavior is surprising because it makes xdist runs and non-xdist runs to potentially behave differently.
|
||||||
|
|
||||||
|
|
||||||
|
Bug Fixes
|
||||||
|
---------
|
||||||
|
|
||||||
|
- `#379 <https://github.com/pytest-dev/pytest-xdist/issues/379>`_: Warning attributes are checked to make sure they can be dumped prior to
|
||||||
|
serializing the warning for submission to the master node.
|
||||||
|
|
||||||
|
|
||||||
pytest-xdist 1.25.0 (2018-12-12)
|
pytest-xdist 1.25.0 (2018-12-12)
|
||||||
================================
|
================================
|
||||||
|
|
||||||
|
|||||||
@@ -223,6 +223,12 @@ defined:
|
|||||||
The information about the worker_id in a test is stored in the ``TestReport`` as
|
The information about the worker_id in a test is stored in the ``TestReport`` as
|
||||||
well, under the ``worker_id`` attribute.
|
well, under the ``worker_id`` attribute.
|
||||||
|
|
||||||
|
Acessing ``sys.argv`` from the master node in workers
|
||||||
|
-----------------------------------------------------
|
||||||
|
|
||||||
|
To access the ``sys.argv`` passed to the command-line of the master node, use
|
||||||
|
``request.config.workerinput["mainargv"]``.
|
||||||
|
|
||||||
|
|
||||||
Specifying test exec environments in an ini file
|
Specifying test exec environments in an ini file
|
||||||
------------------------------------------------
|
------------------------------------------------
|
||||||
|
|||||||
5
setup.py
5
setup.py
@@ -3,12 +3,15 @@ from setuptools import setup, find_packages
|
|||||||
install_requires = ["execnet>=1.1", "pytest>=3.6.0", "pytest-forked", "six"]
|
install_requires = ["execnet>=1.1", "pytest>=3.6.0", "pytest-forked", "six"]
|
||||||
|
|
||||||
|
|
||||||
|
with open("README.rst") as f:
|
||||||
|
long_description = f.read()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="pytest-xdist",
|
name="pytest-xdist",
|
||||||
use_scm_version={"write_to": "xdist/_version.py"},
|
use_scm_version={"write_to": "xdist/_version.py"},
|
||||||
description="pytest xdist plugin for distributed testing"
|
description="pytest xdist plugin for distributed testing"
|
||||||
" and loop-on-failing modes",
|
" and loop-on-failing modes",
|
||||||
long_description=open("README.rst").read(),
|
long_description=long_description,
|
||||||
license="MIT",
|
license="MIT",
|
||||||
author="holger krekel and contributors",
|
author="holger krekel and contributors",
|
||||||
author_email="pytest-dev@python.org,holger@merlinux.eu",
|
author_email="pytest-dev@python.org,holger@merlinux.eu",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
import py
|
import py
|
||||||
@@ -489,9 +490,8 @@ def test_session_hooks(testdir):
|
|||||||
name = "worker"
|
name = "worker"
|
||||||
else:
|
else:
|
||||||
name = "master"
|
name = "master"
|
||||||
f = open(name, "w")
|
with open(name, "w") as f:
|
||||||
f.write("xy")
|
f.write("xy")
|
||||||
f.close()
|
|
||||||
# let's fail on the worker
|
# let's fail on the worker
|
||||||
if name == "worker":
|
if name == "worker":
|
||||||
raise ValueError(42)
|
raise ValueError(42)
|
||||||
@@ -738,10 +738,12 @@ def test_sub_plugins_disabled(testdir, plugin):
|
|||||||
class TestWarnings:
|
class TestWarnings:
|
||||||
@pytest.mark.parametrize("n", ["-n0", "-n1"])
|
@pytest.mark.parametrize("n", ["-n0", "-n1"])
|
||||||
@pytest.mark.parametrize("warn_type", ["pytest", "builtin"])
|
@pytest.mark.parametrize("warn_type", ["pytest", "builtin"])
|
||||||
def test_warnings(self, testdir, n, warn_type):
|
def test_warnings(self, testdir, n, request, warn_type):
|
||||||
if warn_type == "builtin":
|
if warn_type == "builtin":
|
||||||
warn_code = """warnings.warn(UserWarning('this is a warning'))"""
|
warn_code = """warnings.warn(UserWarning('this is a warning'))"""
|
||||||
elif warn_type == "pytest":
|
elif warn_type == "pytest":
|
||||||
|
if not hasattr(request.config, "warn"):
|
||||||
|
pytest.skip("config.warn has been removed in pytest 4.1")
|
||||||
warn_code = """request.config.warn('', 'this is a warning',
|
warn_code = """request.config.warn('', 'this is a warning',
|
||||||
fslocation=py.path.local())"""
|
fslocation=py.path.local())"""
|
||||||
else:
|
else:
|
||||||
@@ -801,6 +803,39 @@ class TestWarnings:
|
|||||||
result = testdir.runpytest(n)
|
result = testdir.runpytest(n)
|
||||||
result.stdout.fnmatch_lines(["*UserWarning*foo.txt*", "*1 passed, 1 warnings*"])
|
result.stdout.fnmatch_lines(["*UserWarning*foo.txt*", "*1 passed, 1 warnings*"])
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("n", ["-n0", "-n1"])
|
||||||
|
def test_unserializable_warning_details(self, testdir, n):
|
||||||
|
"""Check that warnings with unserializable _WARNING_DETAILS are
|
||||||
|
handled correctly (#379).
|
||||||
|
"""
|
||||||
|
if sys.version_info[0] < 3:
|
||||||
|
# The issue is only present in Python 3 warnings
|
||||||
|
return
|
||||||
|
testdir.makepyfile(
|
||||||
|
"""
|
||||||
|
import warnings, pytest
|
||||||
|
import socket
|
||||||
|
import gc
|
||||||
|
def abuse_socket():
|
||||||
|
s = socket.socket()
|
||||||
|
del s
|
||||||
|
|
||||||
|
# Deliberately provoke a ResourceWarning for an unclosed socket.
|
||||||
|
# The socket itself will end up attached as a value in
|
||||||
|
# _WARNING_DETAIL. We need to test that it is not serialized
|
||||||
|
# (it can't be, so the test will fail if we try to).
|
||||||
|
@pytest.mark.filterwarnings('always')
|
||||||
|
def test_func(tmpdir):
|
||||||
|
abuse_socket()
|
||||||
|
gc.collect()
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
testdir.syspathinsert()
|
||||||
|
result = testdir.runpytest(n)
|
||||||
|
result.stdout.fnmatch_lines(
|
||||||
|
["*ResourceWarning*unclosed*", "*1 passed, 1 warnings*"]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestNodeFailure:
|
class TestNodeFailure:
|
||||||
def test_load_single(self, testdir):
|
def test_load_single(self, testdir):
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ def test_dist_options(testdir):
|
|||||||
|
|
||||||
def test_auto_detect_cpus(testdir, monkeypatch):
|
def test_auto_detect_cpus(testdir, monkeypatch):
|
||||||
import os
|
import os
|
||||||
|
from xdist.plugin import pytest_cmdline_main as check_options
|
||||||
|
|
||||||
if hasattr(os, "sched_getaffinity"):
|
if hasattr(os, "sched_getaffinity"):
|
||||||
monkeypatch.setattr(os, "sched_getaffinity", lambda _pid: set(range(99)))
|
monkeypatch.setattr(os, "sched_getaffinity", lambda _pid: set(range(99)))
|
||||||
@@ -52,6 +53,11 @@ def test_auto_detect_cpus(testdir, monkeypatch):
|
|||||||
config = testdir.parseconfigure("-nauto")
|
config = testdir.parseconfigure("-nauto")
|
||||||
assert config.getoption("numprocesses") == 99
|
assert config.getoption("numprocesses") == 99
|
||||||
|
|
||||||
|
config = testdir.parseconfigure("-nauto", "--pdb")
|
||||||
|
check_options(config)
|
||||||
|
assert config.getoption("usepdb")
|
||||||
|
assert config.getoption("numprocesses") == 0
|
||||||
|
|
||||||
monkeypatch.delattr(os, "sched_getaffinity", raising=False)
|
monkeypatch.delattr(os, "sched_getaffinity", raising=False)
|
||||||
monkeypatch.setenv("TRAVIS", "true")
|
monkeypatch.setenv("TRAVIS", "true")
|
||||||
config = testdir.parseconfigure("-nauto")
|
config = testdir.parseconfigure("-nauto")
|
||||||
|
|||||||
@@ -153,7 +153,6 @@ class TestReportSerialization:
|
|||||||
for i in range(len(a_entries)):
|
for i in range(len(a_entries)):
|
||||||
assert isinstance(rep_entries[i], ReprEntry)
|
assert isinstance(rep_entries[i], ReprEntry)
|
||||||
assert rep_entries[i].lines == a_entries[i].lines
|
assert rep_entries[i].lines == a_entries[i].lines
|
||||||
assert rep_entries[i].localssep == a_entries[i].localssep
|
|
||||||
assert rep_entries[i].reprfileloc.lineno == a_entries[i].reprfileloc.lineno
|
assert rep_entries[i].reprfileloc.lineno == a_entries[i].reprfileloc.lineno
|
||||||
assert (
|
assert (
|
||||||
rep_entries[i].reprfileloc.message == a_entries[i].reprfileloc.message
|
rep_entries[i].reprfileloc.message == a_entries[i].reprfileloc.message
|
||||||
@@ -458,6 +457,4 @@ def test_remote_usage_prog(testdir, request):
|
|||||||
|
|
||||||
result = testdir.runpytest_subprocess("-n1")
|
result = testdir.runpytest_subprocess("-n1")
|
||||||
assert result.ret == 1
|
assert result.ret == 1
|
||||||
result.stdout.fnmatch_lines(
|
result.stdout.fnmatch_lines(["*usage: *", "*error: my_usage_error"])
|
||||||
["usage: pytest.py *", "pytest.py: error: my_usage_error"]
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -30,6 +30,11 @@ def pytest_xdist_rsyncfinish(source, gateways):
|
|||||||
""" called after rsyncing a directory to remote gateways takes place. """
|
""" called after rsyncing a directory to remote gateways takes place. """
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.firstresult
|
||||||
|
def pytest_xdist_getremotemodule():
|
||||||
|
""" called when creating remote node"""
|
||||||
|
|
||||||
|
|
||||||
def pytest_configure_node(node):
|
def pytest_configure_node(node):
|
||||||
""" configure node information before it gets instantiated. """
|
""" configure node information before it gets instantiated. """
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,14 @@ def auto_detect_cpus():
|
|||||||
return n if n else 1
|
return n if n else 1
|
||||||
|
|
||||||
|
|
||||||
|
class AutoInt(int):
|
||||||
|
"""Mark value as auto-detected."""
|
||||||
|
|
||||||
|
|
||||||
def parse_numprocesses(s):
|
def parse_numprocesses(s):
|
||||||
if s == "auto":
|
if s == "auto":
|
||||||
return auto_detect_cpus()
|
return AutoInt(auto_detect_cpus())
|
||||||
else:
|
elif s is not None:
|
||||||
return int(s)
|
return int(s)
|
||||||
|
|
||||||
|
|
||||||
@@ -45,7 +49,7 @@ def pytest_addoption(parser):
|
|||||||
type=parse_numprocesses,
|
type=parse_numprocesses,
|
||||||
help="shortcut for '--dist=load --tx=NUM*popen', "
|
help="shortcut for '--dist=load --tx=NUM*popen', "
|
||||||
"you can use 'auto' here for auto detection CPUs number on "
|
"you can use 'auto' here for auto detection CPUs number on "
|
||||||
"host system",
|
"host system and it will be 0 when used with --pdb",
|
||||||
)
|
)
|
||||||
group.addoption(
|
group.addoption(
|
||||||
"--maxprocesses",
|
"--maxprocesses",
|
||||||
@@ -177,6 +181,10 @@ def pytest_configure(config):
|
|||||||
|
|
||||||
@pytest.mark.tryfirst
|
@pytest.mark.tryfirst
|
||||||
def pytest_cmdline_main(config):
|
def pytest_cmdline_main(config):
|
||||||
|
usepdb = config.getoption("usepdb") # a core option
|
||||||
|
if isinstance(config.option.numprocesses, AutoInt):
|
||||||
|
config.option.numprocesses = 0 if usepdb else int(config.option.numprocesses)
|
||||||
|
|
||||||
if config.option.numprocesses:
|
if config.option.numprocesses:
|
||||||
if config.option.dist == "no":
|
if config.option.dist == "no":
|
||||||
config.option.dist = "load"
|
config.option.dist = "load"
|
||||||
@@ -188,11 +196,10 @@ def pytest_cmdline_main(config):
|
|||||||
config.option.dist = "load"
|
config.option.dist = "load"
|
||||||
val = config.getvalue
|
val = config.getvalue
|
||||||
if not val("collectonly"):
|
if not val("collectonly"):
|
||||||
usepdb = config.getoption("usepdb") # a core option
|
|
||||||
if val("dist") != "no":
|
if val("dist") != "no":
|
||||||
if usepdb:
|
if usepdb:
|
||||||
raise pytest.UsageError(
|
raise pytest.UsageError(
|
||||||
"--pdb is incompatible with distributing tests; try using -n0."
|
"--pdb is incompatible with distributing tests; try using -n0 or -nauto."
|
||||||
) # noqa: E501
|
) # noqa: E501
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import py
|
||||||
import _pytest.hookspec
|
import _pytest.hookspec
|
||||||
import pytest
|
import pytest
|
||||||
from execnet.gateway_base import dumps, DumpError
|
from execnet.gateway_base import dumps, DumpError
|
||||||
@@ -115,8 +116,10 @@ class WorkerInteractor(object):
|
|||||||
data = serialize_report(report)
|
data = serialize_report(report)
|
||||||
self.sendevent("collectreport", data=data)
|
self.sendevent("collectreport", data=data)
|
||||||
|
|
||||||
# the pytest_logwarning hook was removed in pytest 4.1
|
# the pytest_logwarning hook was deprecated since pytest 4.0
|
||||||
if hasattr(_pytest.hookspec, "pytest_logwarning"):
|
if hasattr(
|
||||||
|
_pytest.hookspec, "pytest_logwarning"
|
||||||
|
) and not _pytest.hookspec.pytest_logwarning.pytest_spec.get("warn_on_impl"):
|
||||||
|
|
||||||
def pytest_logwarning(self, message, code, nodeid, fslocation):
|
def pytest_logwarning(self, message, code, nodeid, fslocation):
|
||||||
self.sendevent(
|
self.sendevent(
|
||||||
@@ -218,7 +221,15 @@ def serialize_warning_message(warning_message):
|
|||||||
for attr_name in warning_message._WARNING_DETAILS:
|
for attr_name in warning_message._WARNING_DETAILS:
|
||||||
if attr_name in ("message", "category"):
|
if attr_name in ("message", "category"):
|
||||||
continue
|
continue
|
||||||
result[attr_name] = getattr(warning_message, attr_name)
|
attr = getattr(warning_message, attr_name)
|
||||||
|
# Check if we can serialize the warning detail, marking `None` otherwise
|
||||||
|
# Note that we need to define the attr (even as `None`) to allow deserializing
|
||||||
|
try:
|
||||||
|
dumps(attr)
|
||||||
|
except DumpError:
|
||||||
|
result[attr_name] = repr(attr)
|
||||||
|
else:
|
||||||
|
result[attr_name] = attr
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@@ -252,16 +263,17 @@ def remote_initconfig(option_dict, args):
|
|||||||
|
|
||||||
if __name__ == "__channelexec__":
|
if __name__ == "__channelexec__":
|
||||||
channel = channel # noqa
|
channel = channel # noqa
|
||||||
workerinput, args, option_dict = channel.receive()
|
workerinput, args, option_dict, change_sys_path = channel.receive()
|
||||||
importpath = os.getcwd()
|
|
||||||
sys.path.insert(0, importpath) # XXX only for remote situations
|
if change_sys_path:
|
||||||
os.environ["PYTHONPATH"] = (
|
importpath = os.getcwd()
|
||||||
importpath + os.pathsep + os.environ.get("PYTHONPATH", "")
|
sys.path.insert(0, importpath)
|
||||||
)
|
os.environ["PYTHONPATH"] = (
|
||||||
|
importpath + os.pathsep + os.environ.get("PYTHONPATH", "")
|
||||||
|
)
|
||||||
|
|
||||||
os.environ["PYTEST_XDIST_WORKER"] = workerinput["workerid"]
|
os.environ["PYTEST_XDIST_WORKER"] = workerinput["workerid"]
|
||||||
os.environ["PYTEST_XDIST_WORKER_COUNT"] = str(workerinput["workercount"])
|
os.environ["PYTEST_XDIST_WORKER_COUNT"] = str(workerinput["workercount"])
|
||||||
# os.environ['PYTHONPATH'] = importpath
|
|
||||||
import py
|
|
||||||
|
|
||||||
config = remote_initconfig(option_dict, args)
|
config = remote_initconfig(option_dict, args)
|
||||||
config._parser.prog = os.path.basename(workerinput["mainargv"][0])
|
config._parser.prog = os.path.basename(workerinput["mainargv"][0])
|
||||||
|
|||||||
@@ -204,7 +204,13 @@ def make_reltoroot(roots, args):
|
|||||||
class WorkerController(object):
|
class WorkerController(object):
|
||||||
ENDMARK = -1
|
ENDMARK = -1
|
||||||
|
|
||||||
|
class RemoteHook:
|
||||||
|
@pytest.mark.trylast
|
||||||
|
def pytest_xdist_getremotemodule(self):
|
||||||
|
return xdist.remote
|
||||||
|
|
||||||
def __init__(self, nodemanager, gateway, config, putevent):
|
def __init__(self, nodemanager, gateway, config, putevent):
|
||||||
|
config.pluginmanager.register(self.RemoteHook())
|
||||||
self.nodemanager = nodemanager
|
self.nodemanager = nodemanager
|
||||||
self.putevent = putevent
|
self.putevent = putevent
|
||||||
self.gateway = gateway
|
self.gateway = gateway
|
||||||
@@ -244,8 +250,13 @@ class WorkerController(object):
|
|||||||
basetemp = self.config._tmpdirhandler.getbasetemp()
|
basetemp = self.config._tmpdirhandler.getbasetemp()
|
||||||
option_dict["basetemp"] = str(basetemp.join(name))
|
option_dict["basetemp"] = str(basetemp.join(name))
|
||||||
self.config.hook.pytest_configure_node(node=self)
|
self.config.hook.pytest_configure_node(node=self)
|
||||||
self.channel = self.gateway.remote_exec(xdist.remote)
|
|
||||||
self.channel.send((self.workerinput, args, option_dict))
|
remote_module = self.config.hook.pytest_xdist_getremotemodule()
|
||||||
|
self.channel = self.gateway.remote_exec(remote_module)
|
||||||
|
# change sys.path only for remote workers
|
||||||
|
change_sys_path = not self.gateway.spec.popen
|
||||||
|
self.channel.send((self.workerinput, args, option_dict, change_sys_path))
|
||||||
|
|
||||||
if self.putevent:
|
if self.putevent:
|
||||||
self.channel.setcallback(self.process_from_remote, endmarker=self.ENDMARK)
|
self.channel.setcallback(self.process_from_remote, endmarker=self.ENDMARK)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user