fix and unify remote skip test/collect reports

This commit is contained in:
holger krekel
2010-11-13 20:53:35 +01:00
parent d81ffaa980
commit 47d3e99083
6 changed files with 27 additions and 20 deletions

View File

@@ -10,7 +10,7 @@ from setuptools import setup
setup( setup(
name="pytest-xdist", name="pytest-xdist",
version='1.5a7', version='1.5a8',
description='py.test xdist plugin for distributed testing and loop-on-failing modes', description='py.test xdist plugin for distributed testing and loop-on-failing modes',
long_description=__doc__, long_description=__doc__,
license='GPLv2 or later', license='GPLv2 or later',

View File

@@ -144,7 +144,7 @@ class TestDistribution:
subdir.ensure("__init__.py") subdir.ensure("__init__.py")
p = subdir.join("test_one.py") p = subdir.join("test_one.py")
p.write("def test_5():\n assert not __file__.startswith(%r)" % str(p)) p.write("def test_5():\n assert not __file__.startswith(%r)" % str(p))
result = testdir.runpytest("-v", "-d", result = testdir.runpytest("-v", "-d",
"--rsyncdir=%(subdir)s" % locals(), "--rsyncdir=%(subdir)s" % locals(),
"--tx=popen//chdir=%(dest)s" % locals(), p) "--tx=popen//chdir=%(dest)s" % locals(), p)
assert result.ret == 0 assert result.ret == 0
@@ -394,3 +394,18 @@ def test_crashing_item(testdir):
def test_skipping(testdir):
p = testdir.makepyfile("""
import pytest
def test_crash():
pytest.skip("hello")
""")
result = testdir.runpytest("-n1", '-rs', p)
assert result.ret == 0
result.stdout.fnmatch_lines([
"*hello*",
"*1 skipped*"
])

View File

@@ -88,8 +88,8 @@ class TestReportSerialization:
assert newrep.passed == rep.passed assert newrep.passed == rep.passed
assert newrep.failed == rep.failed assert newrep.failed == rep.failed
assert newrep.skipped == rep.skipped assert newrep.skipped == rep.skipped
if newrep.skipped: if newrep.skipped and 'xfail' not in newrep.keywords:
assert len(newrep.reprcrash) == 3 assert len(newrep.longrepr) == 3
assert newrep.outcome == rep.outcome assert newrep.outcome == rep.outcome
assert newrep.when == rep.when assert newrep.when == rep.when
assert newrep.keywords == rep.keywords assert newrep.keywords == rep.keywords

View File

@@ -1,2 +1,2 @@
# #
__version__ = '1.5a7' __version__ = '1.5a8'

View File

@@ -274,12 +274,12 @@ class DSession:
if rep.when in ("setup", "call"): if rep.when in ("setup", "call"):
self.sched.remove_item(node, rep.nodeid) self.sched.remove_item(node, rep.nodeid)
#self.report_line("testreport %s: %s" %(rep.id, rep.status)) #self.report_line("testreport %s: %s" %(rep.id, rep.status))
enrich_report_with_platform_data(rep, node) rep.node = node
self.config.hook.pytest_runtest_logreport(report=rep) self.config.hook.pytest_runtest_logreport(report=rep)
self._handlefailures(rep) self._handlefailures(rep)
def slave_teardownreport(self, node, rep): def slave_teardownreport(self, node, rep):
enrich_report_with_platform_data(rep, node) rep.node = node
self.config.hook.pytest__teardown_final_logerror(report=rep) self.config.hook.pytest__teardown_final_logerror(report=rep)
def slave_collectreport(self, node, rep): def slave_collectreport(self, node, rep):
@@ -307,7 +307,7 @@ class DSession:
msg = "Slave %r crashed while running %r" %(slave.gateway.id, nodeid) msg = "Slave %r crashed while running %r" %(slave.gateway.id, nodeid)
rep = runner.TestReport(nodeid, (fspath, None, fspath), (), rep = runner.TestReport(nodeid, (fspath, None, fspath), (),
"failed", msg, "???") "failed", msg, "???")
enrich_report_with_platform_data(rep, slave) rep.node = slave
self.config.hook.pytest_runtest_logreport(report=rep) self.config.hook.pytest_runtest_logreport(report=rep)
class TerminalDistReporter: class TerminalDistReporter:
@@ -346,14 +346,3 @@ class TerminalDistReporter:
# targets = ", ".join(["[%s]" % gw.id for gw in gateways]) # targets = ", ".join(["[%s]" % gw.id for gw in gateways])
# self.write_line("rsyncfinish: %s -> %s" %(source, targets)) # self.write_line("rsyncfinish: %s -> %s" %(source, targets))
def enrich_report_with_platform_data(rep, node):
rep.node = node
if hasattr(rep, 'node') and rep.longrepr:
d = node.slaveinfo
ver = "%s.%s.%s" % d['version_info'][:3]
infoline = "[%s] %s -- Python %s %s" % (
d['id'], d['sysplatform'], ver, d['executable'])
# XXX more structured longrepr?
rep.longrepr = infoline + "\n\n" + str(rep.longrepr)

View File

@@ -85,7 +85,10 @@ class SlaveInteractor:
def serialize_report(rep): def serialize_report(rep):
import py import py
d = rep.__dict__.copy() d = rep.__dict__.copy()
d['longrepr'] = rep.longrepr and str(rep.longrepr) or None if hasattr(rep.longrepr, 'toterminal'):
d['longrepr'] = str(rep.longrepr)
else:
d['longrepr'] = rep.longrepr
for name in d: for name in d:
if isinstance(d[name], py.path.local): if isinstance(d[name], py.path.local):
d[name] = str(d[name]) d[name] = str(d[name])