From 1c712fe6a015c6a0d7ad5f14f102d8c902bafd52 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Tue, 7 Dec 2010 12:00:22 +0100 Subject: [PATCH] fix and shorten collection reporting and fix a test wrt internal pytest api --- setup.py | 2 +- testing/test_remote.py | 2 +- xdist/__init__.py | 2 +- xdist/dsession.py | 26 +++++++++++++++++--------- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/setup.py b/setup.py index c25c1e7..5bb4052 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( name="pytest-xdist", - version='1.5', + version='1.6', description='py.test xdist plugin for distributed testing and loop-on-failing modes', long_description=open('README.txt').read(), license='GPLv2 or later', diff --git a/testing/test_remote.py b/testing/test_remote.py index e3dfacc..870f0af 100644 --- a/testing/test_remote.py +++ b/testing/test_remote.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") == None class TestReportSerialization: def test_itemreport_outcomes(self, testdir): diff --git a/xdist/__init__.py b/xdist/__init__.py index 53b03de..49e36d6 100644 --- a/xdist/__init__.py +++ b/xdist/__init__.py @@ -1,2 +1,2 @@ # -__version__ = '1.5' +__version__ = '1.6' diff --git a/xdist/dsession.py b/xdist/dsession.py index 2971bfe..c2c73b5 100644 --- a/xdist/dsession.py +++ b/xdist/dsession.py @@ -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__)) @@ -327,13 +328,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 +354,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 +365,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 +374,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: