Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1f27bf87e | ||
|
|
c19f5e4bfd | ||
|
|
8a923ea2f4 | ||
|
|
e8ae2f9090 | ||
|
|
f946ab1835 | ||
|
|
1c2563d864 | ||
|
|
b04616419e | ||
|
|
722006f7f6 | ||
|
|
d9c5f18478 | ||
|
|
bd30e96ab0 | ||
|
|
eb09e22b62 | ||
|
|
319e247de5 | ||
|
|
1c712fe6a0 | ||
|
|
a6a4158b78 |
3
.hgtags
3
.hgtags
@@ -5,3 +5,6 @@ e6c4ce20db4bf65086ff55807a3c306cad7ca393 1.3
|
||||
e6c4ce20db4bf65086ff55807a3c306cad7ca393 1.3
|
||||
eaf8b1cb7c312883598677231be5bbeea3b5c127 1.3
|
||||
a423748bf17ee778a37853225210257699cad9c1 1.4
|
||||
cd44a941c833c098e4899fe3d42a96703754d0d5 1.5
|
||||
4815040bdad8f182a5487f57a9da385483836e75 1.6
|
||||
20875fed94e7f3dff50bdf762df91153b15ceca6 1.7
|
||||
|
||||
16
CHANGELOG
16
CHANGELOG
@@ -1,3 +1,19 @@
|
||||
1.7
|
||||
-------------------------
|
||||
|
||||
- fix incompatibilities with pytest-2.2.0 (allow multiple
|
||||
pytest_runtest_logreport reports for a test item)
|
||||
|
||||
1.6
|
||||
-------------------------
|
||||
|
||||
- terser collection reporting
|
||||
|
||||
- fix issue34 - distributed testing with -p plugin now works correctly
|
||||
|
||||
- fix race condition in looponfail mode where a concurrent file removal
|
||||
could cause a crash
|
||||
|
||||
1.5
|
||||
-------------------------
|
||||
|
||||
|
||||
4
setup.py
4
setup.py
@@ -2,7 +2,7 @@ from setuptools import setup
|
||||
|
||||
setup(
|
||||
name="pytest-xdist",
|
||||
version='1.5',
|
||||
version='1.7.dev1',
|
||||
description='py.test xdist plugin for distributed testing and loop-on-failing modes',
|
||||
long_description=open('README.txt').read(),
|
||||
license='GPLv2 or later',
|
||||
@@ -13,7 +13,7 @@ setup(
|
||||
packages = ['xdist'],
|
||||
entry_points = {'pytest11': ['xdist = xdist.plugin'],},
|
||||
zip_safe=False,
|
||||
install_requires = ['execnet>=1.0.8', 'pytest>1.9.9'],
|
||||
install_requires = ['execnet>=1.0.8', 'pytest>=2.2.0'],
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Intended Audience :: Developers',
|
||||
|
||||
@@ -407,5 +407,18 @@ def test_skipping(testdir):
|
||||
"*1 skipped*"
|
||||
])
|
||||
|
||||
|
||||
|
||||
def test_issue34_pluginloading_in_subprocess(testdir):
|
||||
testdir.tmpdir.join("plugin123.py").write(py.code.Source("""
|
||||
def pytest_namespace():
|
||||
return {'sample_variable': 'testing'}
|
||||
"""))
|
||||
testdir.makepyfile("""
|
||||
import pytest
|
||||
def test_hello():
|
||||
assert pytest.sample_variable == "testing"
|
||||
""")
|
||||
result = testdir.runpytest("-n1", "-p", "plugin123")
|
||||
assert result.ret == 0
|
||||
result.stdout.fnmatch_lines([
|
||||
"*1 passed*",
|
||||
])
|
||||
|
||||
@@ -16,13 +16,13 @@ def test_functional_boxed(testdir):
|
||||
class TestOptionEffects:
|
||||
def test_boxed_option_default(self, testdir):
|
||||
tmpdir = testdir.tmpdir.ensure("subdir", dir=1)
|
||||
config = testdir.reparseconfig()
|
||||
config = testdir.parseconfig()
|
||||
assert not config.option.boxed
|
||||
py.test.importorskip("execnet")
|
||||
config = testdir.reparseconfig(['-d', tmpdir])
|
||||
config = testdir.parseconfig('-d', tmpdir)
|
||||
assert not config.option.boxed
|
||||
|
||||
def test_is_not_boxed_by_default(self, testdir):
|
||||
config = testdir.reparseconfig([testdir.tmpdir])
|
||||
config = testdir.parseconfig(testdir.tmpdir)
|
||||
assert not config.option.boxed
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from xdist.dsession import DSession, LoadScheduling, EachScheduling
|
||||
from _pytest import session as outcome
|
||||
from _pytest import main as outcome
|
||||
import py
|
||||
import execnet
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ class TestStatRecorder:
|
||||
changed = sd.check()
|
||||
assert changed
|
||||
|
||||
tmp.ensure("new.py")
|
||||
p = tmp.ensure("new.py")
|
||||
changed = sd.check()
|
||||
assert changed
|
||||
|
||||
tmp.join("new.py").remove()
|
||||
p.remove()
|
||||
changed = sd.check()
|
||||
assert changed
|
||||
|
||||
@@ -36,6 +36,24 @@ class TestStatRecorder:
|
||||
changed = sd.check()
|
||||
assert changed
|
||||
|
||||
def test_filechange_deletion_race(self, tmpdir, monkeypatch):
|
||||
tmp = tmpdir
|
||||
sd = StatRecorder([tmp])
|
||||
changed = sd.check()
|
||||
assert not changed
|
||||
|
||||
p = tmp.ensure("new.py")
|
||||
changed = sd.check()
|
||||
assert changed
|
||||
|
||||
p.remove()
|
||||
# make check()'s visit() call return our just removed
|
||||
# path as if we were in a race condition
|
||||
monkeypatch.setattr(tmp, 'visit', lambda *args: [p])
|
||||
|
||||
changed = sd.check()
|
||||
assert changed
|
||||
|
||||
def test_pycremoval(self, tmpdir):
|
||||
tmp = tmpdir
|
||||
hello = tmp.ensure("hello.py")
|
||||
|
||||
@@ -62,7 +62,7 @@ def test_remoteinitconfig(testdir):
|
||||
config1 = testdir.parseconfig()
|
||||
config2 = remote_initconfig(config1.option.__dict__, config1.args)
|
||||
assert config2.option.__dict__ == config1.option.__dict__
|
||||
py.test.raises(KeyError, 'config2.pluginmanager.getplugin("terminal")')
|
||||
assert config2.pluginmanager.getplugin("terminal") in (-1, None)
|
||||
|
||||
class TestReportSerialization:
|
||||
def test_itemreport_outcomes(self, testdir):
|
||||
@@ -80,7 +80,7 @@ class TestReportSerialization:
|
||||
py.test.xfail("hello")
|
||||
""")
|
||||
reports = reprec.getreports("pytest_runtest_logreport")
|
||||
assert len(reports) == 6
|
||||
assert len(reports) == 17 # with setup/teardown "passed" reports
|
||||
for rep in reports:
|
||||
d = serialize_report(rep)
|
||||
check_marshallable(d)
|
||||
@@ -138,6 +138,7 @@ class TestSlaveInteractor:
|
||||
ids = ev.kwargs['ids']
|
||||
assert len(ids) == 1
|
||||
slave.sendcommand("runtests", ids=ids)
|
||||
ev = slave.popevent("testreport") # setup
|
||||
ev = slave.popevent("testreport")
|
||||
assert ev.name == "testreport"
|
||||
rep = unserialize_report(ev.name, ev.kwargs['data'])
|
||||
@@ -194,16 +195,13 @@ class TestSlaveInteractor:
|
||||
ids = ev.kwargs['ids']
|
||||
assert len(ids) == 2
|
||||
slave.sendcommand("runtests_all", )
|
||||
ev = slave.popevent("testreport")
|
||||
assert ev.name == "testreport"
|
||||
rep = unserialize_report(ev.name, ev.kwargs['data'])
|
||||
assert rep.nodeid.endswith("::test_func")
|
||||
ev = slave.popevent("testreport")
|
||||
assert ev.name == "testreport"
|
||||
rep = unserialize_report(ev.name, ev.kwargs['data'])
|
||||
assert rep.nodeid.endswith("::test_func2")
|
||||
assert rep.passed
|
||||
slave.sendcommand("shutdown")
|
||||
slave.sendcommand("shutdown", )
|
||||
for func in "::test_func", "::test_func2":
|
||||
for i in range(3): # setup/call/teardown
|
||||
ev = slave.popevent("testreport")
|
||||
assert ev.name == "testreport"
|
||||
rep = unserialize_report(ev.name, ev.kwargs['data'])
|
||||
assert rep.nodeid.endswith(func)
|
||||
ev = slave.popevent("slavefinished")
|
||||
assert 'slaveoutput' in ev.kwargs
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ class TestNodeManager:
|
||||
@py.test.mark.xfail
|
||||
def test_rsync_roots_no_roots(self, testdir, mysetup):
|
||||
mysetup.source.ensure("dir1", "file1").write("hello")
|
||||
config = testdir.reparseconfig([source])
|
||||
config = testdir.parseconfig(source)
|
||||
nodemanager = NodeManager(config, ["popen//chdir=%s" % mysetup.dest])
|
||||
#assert nodemanager.config.topdir == source == config.topdir
|
||||
nodemanager.makegateways()
|
||||
@@ -179,7 +179,7 @@ class TestNodeManager:
|
||||
[pytest]
|
||||
rsyncdirs=dir1/dir2
|
||||
"""))
|
||||
config = testdir.reparseconfig([source])
|
||||
config = testdir.parseconfig(source)
|
||||
nodemanager = NodeManager(config, ["popen//chdir=%s" % dest])
|
||||
nodemanager.makegateways()
|
||||
nodemanager.rsync_roots()
|
||||
@@ -198,7 +198,7 @@ class TestNodeManager:
|
||||
rsyncdirs = dir1 dir5
|
||||
rsyncignore = dir1/dir2 dir5/dir6
|
||||
"""))
|
||||
config = testdir.reparseconfig([source])
|
||||
config = testdir.parseconfig(source)
|
||||
nodemanager = NodeManager(config, ["popen//chdir=%s" % dest])
|
||||
nodemanager.makegateways()
|
||||
nodemanager.rsync_roots()
|
||||
@@ -212,7 +212,7 @@ class TestNodeManager:
|
||||
specs = ["popen"] * 3
|
||||
source.join("conftest.py").write("rsyncdirs = ['a']")
|
||||
source.ensure('a', dir=1)
|
||||
config = testdir.reparseconfig([source])
|
||||
config = testdir.parseconfig(source)
|
||||
nodemanager = NodeManager(config, specs)
|
||||
nodemanager.makegateways()
|
||||
nodemanager.rsync_roots()
|
||||
|
||||
12
tox.ini
12
tox.ini
@@ -1,18 +1,22 @@
|
||||
[tox]
|
||||
envlist=py26,py31,py27,py25,py24
|
||||
indexserver=
|
||||
default = http://pypi.testrun.org
|
||||
testrun = http://pypi.testrun.org
|
||||
pypi = http://pypi.python.org/simple
|
||||
|
||||
[testenv]
|
||||
|
||||
changedir=testing
|
||||
deps=pytest
|
||||
deps=:testrun:pytest>=2.2.0.dev2
|
||||
commands= py.test --junitxml={envlogdir}/junit-{envname}.xml []
|
||||
|
||||
[testenv:py31]
|
||||
deps=:pypi:pytest # XXX needed because ClueRelease/pip broken
|
||||
[testenv:py32]
|
||||
deps=:pypi:pytest # XXX needed because ClueRelease/pip broken
|
||||
|
||||
[testenv:py26]
|
||||
deps=
|
||||
pytest
|
||||
:testrun:pytest
|
||||
:pypi:pexpect
|
||||
|
||||
[pytest]
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#
|
||||
__version__ = '1.5'
|
||||
__version__ = '1.7.dev1'
|
||||
|
||||
@@ -267,6 +267,7 @@ class DSession:
|
||||
|
||||
if self.sched.collection_is_completed:
|
||||
if self.terminal:
|
||||
self.trdist.ensure_show_status()
|
||||
self.terminal.write_line("")
|
||||
self.terminal.write_line("scheduling tests via %s" %(
|
||||
self.sched.__class__.__name__))
|
||||
@@ -278,8 +279,9 @@ class DSession:
|
||||
nodeid=nodeid, location=location)
|
||||
|
||||
def slave_testreport(self, node, rep):
|
||||
if rep.when in ("setup", "call"):
|
||||
self.sched.remove_item(node, rep.nodeid)
|
||||
if not (rep.passed and rep.when != "call"):
|
||||
if rep.when in ("setup", "call"):
|
||||
self.sched.remove_item(node, rep.nodeid)
|
||||
#self.report_line("testreport %s: %s" %(rep.id, rep.status))
|
||||
rep.node = node
|
||||
self.config.hook.pytest_runtest_logreport(report=rep)
|
||||
@@ -327,13 +329,19 @@ class TerminalDistReporter:
|
||||
def write_line(self, msg):
|
||||
self.tr.write_line(msg)
|
||||
|
||||
def ensure_show_status(self):
|
||||
if not self.tr.hasmarkup:
|
||||
self.write_line(self.getstatus())
|
||||
|
||||
def setstatus(self, spec, status, show=True):
|
||||
self._status[spec.id] = status
|
||||
if show:
|
||||
parts = ["%s %s" %(spec.id, self._status[spec.id])
|
||||
for spec in self._specs]
|
||||
line = " / ".join(parts)
|
||||
self.rewrite(line)
|
||||
if show and self.tr.hasmarkup:
|
||||
self.rewrite(self.getstatus())
|
||||
|
||||
def getstatus(self):
|
||||
parts = ["%s %s" %(spec.id, self._status[spec.id])
|
||||
for spec in self._specs]
|
||||
return " / ".join(parts)
|
||||
|
||||
def rewrite(self, line, newline=False):
|
||||
pline = line + " " * max(self._lastlen-len(line), 0)
|
||||
@@ -347,8 +355,9 @@ class TerminalDistReporter:
|
||||
def pytest_xdist_setupnodes(self, specs):
|
||||
self._specs = specs
|
||||
for spec in specs:
|
||||
self.setstatus(spec, "initializing", show=False)
|
||||
self.setstatus(spec, "initializing", show=True)
|
||||
self.setstatus(spec, "I", show=False)
|
||||
self.setstatus(spec, "I", show=True)
|
||||
self.ensure_show_status()
|
||||
|
||||
def pytest_xdist_newgateway(self, gateway):
|
||||
if self.config.option.verbose > 0:
|
||||
@@ -357,7 +366,7 @@ class TerminalDistReporter:
|
||||
self.rewrite("[%s] %s Python %s cwd: %s" % (
|
||||
gateway.id, rinfo.platform, version, rinfo.cwd),
|
||||
newline=True)
|
||||
self.setstatus(gateway.spec, "collecting")
|
||||
self.setstatus(gateway.spec, "C")
|
||||
|
||||
def pytest_testnodeready(self, node):
|
||||
if self.config.option.verbose > 0:
|
||||
@@ -366,7 +375,7 @@ class TerminalDistReporter:
|
||||
d['id'],
|
||||
d['version'].replace('\n', ' -- '),)
|
||||
self.rewrite(infoline, newline=True)
|
||||
self.setstatus(node.gateway.spec, "ready")
|
||||
self.setstatus(node.gateway.spec, "ok")
|
||||
|
||||
def pytest_testnodedown(self, node, error):
|
||||
if not error:
|
||||
|
||||
@@ -120,9 +120,7 @@ def init_slave_session(channel, args, option_dict):
|
||||
|
||||
#fullwidth, hasmarkup = channel.receive()
|
||||
from _pytest.config import Config
|
||||
config = Config()
|
||||
config.option.__dict__.update(option_dict)
|
||||
config._preparse(list(args))
|
||||
config = Config.fromdictargs(option_dict, list(args))
|
||||
config.args = args
|
||||
from xdist.looponfail import SlaveFailSession
|
||||
SlaveFailSession(config, channel).main()
|
||||
@@ -203,14 +201,11 @@ class StatRecorder:
|
||||
newstat = {}
|
||||
for rootdir in self.rootdirlist:
|
||||
for path in rootdir.visit(self.fil, self.rec):
|
||||
oldstat = statcache.get(path, None)
|
||||
if oldstat is not None:
|
||||
del statcache[path]
|
||||
oldstat = statcache.pop(path, None)
|
||||
try:
|
||||
newstat[path] = curstat = path.stat()
|
||||
except py.error.ENOENT:
|
||||
if oldstat:
|
||||
del statcache[path]
|
||||
changed = True
|
||||
else:
|
||||
if oldstat:
|
||||
|
||||
@@ -109,10 +109,8 @@ def getinfodict():
|
||||
|
||||
def remote_initconfig(option_dict, args):
|
||||
from _pytest.config import Config
|
||||
config = Config()
|
||||
config.pluginmanager.unregister(name="terminal")
|
||||
config._preparse(args, addopts=False)
|
||||
config.option.__dict__.update(option_dict)
|
||||
option_dict['plugins'].append("no:terminal")
|
||||
config = Config.fromdictargs(option_dict, args)
|
||||
config.option.looponfail = False
|
||||
config.option.usepdb = False
|
||||
config.option.dist = "no"
|
||||
|
||||
Reference in New Issue
Block a user