From 772658d6168f69e684d11d27d3b8390f071b8d3a Mon Sep 17 00:00:00 2001 From: hpk Date: Wed, 18 Mar 2009 13:05:18 +0100 Subject: [PATCH] [svn r63028] allow py.test --exec=python2.4 -n 3 to work and fix some bugs from doing so. --HG-- branch : trunk --- py/doc/execnet.txt | 2 +- py/execnet/gwmanage.py | 5 ++++- py/test/dsession/hostmanage.py | 6 +++++- py/test/dsession/masterslave.py | 5 +---- py/test/plugin/pytest_pytester.py | 2 +- py/test/plugin/pytest_terminal.py | 4 ++-- py/test/testing/acceptance_test.py | 4 ++-- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/py/doc/execnet.txt b/py/doc/execnet.txt index 76ab622b5..d24582568 100644 --- a/py/doc/execnet.txt +++ b/py/doc/execnet.txt @@ -140,7 +140,7 @@ To specify Gateways with a String:: >>> gwspec = py.execnet.GatewaySpec("popen") >>> gw = gwspec.makegateway() >>> ex = gw.remote_exec("import sys ; channel.send(sys.executable)").receive() - >>> assert ex == py.std.sys.executable + >>> assert ex == py.std.sys.executable, (ex, py.std.sys.executable) >>> current gateway types and specifications diff --git a/py/execnet/gwmanage.py b/py/execnet/gwmanage.py index 1e87c808d..e24c6610b 100644 --- a/py/execnet/gwmanage.py +++ b/py/execnet/gwmanage.py @@ -24,7 +24,7 @@ from py.__.execnet.channel import RemoteError NO_ENDMARKER_WANTED = object() class GatewaySpec(object): - python = "python" + python = None def __init__(self, spec, defaultjoinpath="pyexecnetcache"): if spec == "popen" or spec.startswith("popen:"): parts = spec.split(":", 2) @@ -35,6 +35,9 @@ class GatewaySpec(object): self.joinpath = parts.pop(0) else: self.joinpath = "" + if not self.python: + self.python = py.std.sys.executable + elif spec.startswith("socket:"): parts = spec[7:].split(":", 2) self.address = parts.pop(0) diff --git a/py/test/dsession/hostmanage.py b/py/test/dsession/hostmanage.py index 5de2e033d..badf9f1cf 100644 --- a/py/test/dsession/hostmanage.py +++ b/py/test/dsession/hostmanage.py @@ -6,7 +6,11 @@ from py.__.test import event def getconfiggwspecs(config): if config.option.numprocesses: - gwspecs = ['popen'] * config.option.numprocesses + if config.option.executable: + s = 'popen:%s' % config.option.executable + else: + s = 'popen' + gwspecs = [s] * config.option.numprocesses else: gwspecs = config.option.gateways if not gwspecs: diff --git a/py/test/dsession/masterslave.py b/py/test/dsession/masterslave.py index 46ba87291..d90d5e127 100644 --- a/py/test/dsession/masterslave.py +++ b/py/test/dsession/masterslave.py @@ -120,11 +120,8 @@ class SlaveNode(object): self.sendevent("itemtestreport", testrep) -def makehostup(host=None): - from py.__.execnet.gwmanage import GatewaySpec +def makehostup(host="INPROCESS"): import sys - if host is None: - host = GatewaySpec("localhost") platinfo = {} for name in 'platform', 'executable', 'version_info': platinfo["sys."+name] = getattr(sys, name) diff --git a/py/test/plugin/pytest_pytester.py b/py/test/plugin/pytest_pytester.py index 1e7af0fc4..1525c7f7f 100644 --- a/py/test/plugin/pytest_pytester.py +++ b/py/test/plugin/pytest_pytester.py @@ -232,7 +232,7 @@ class TmpTestdir: else: script = bindir.join(scriptname) assert script.check() - return self.run(script, *args) + return self.run(py.std.sys.executable, script, *args) def runpytest(self, *args): p = py.path.local.make_numbered_dir(prefix="runpytest-", diff --git a/py/test/plugin/pytest_terminal.py b/py/test/plugin/pytest_terminal.py index 03a587e50..448dafe9a 100644 --- a/py/test/plugin/pytest_terminal.py +++ b/py/test/plugin/pytest_terminal.py @@ -98,7 +98,7 @@ class TerminalReporter: def pyevent_hostup(self, event): d = event.platinfo.copy() - d['host'] = event.host.address + d['host'] = getattr(event.host, 'address', event.host) d['version'] = repr_pythonversion(d['sys.version_info']) self.write_line("HOSTUP: %(host)s %(sys.platform)s " "%(sys.executable)s - Python %(version)s" % @@ -325,7 +325,7 @@ class TestTerminal: rep = TerminalReporter(item.config, linecomp.stringio) rep.pyevent_hostup(makehostup()) linecomp.assert_contains_lines([ - "*localhost %s %s - Python %s" %(sys.platform, + "*inline %s %s - Python %s" %(sys.platform, sys.executable, repr_pythonversion(sys.version_info)) ]) diff --git a/py/test/testing/acceptance_test.py b/py/test/testing/acceptance_test.py index 9541cd1f2..0177e8be9 100644 --- a/py/test/testing/acceptance_test.py +++ b/py/test/testing/acceptance_test.py @@ -179,7 +179,7 @@ class TestPyTest: verinfo = ".".join(map(str, py.std.sys.version_info[:3])) extra = result.stdout.fnmatch_lines([ "*===== test session starts ====*", - "*localhost* %s %s - Python %s*" %( + "HOSTUP*INPROCESS* %s %s - Python %s*" %( py.std.sys.platform, py.std.sys.executable, verinfo), "*test_header_trailer_info.py .", "=* 1 passed in *.[0-9][0-9] seconds *=", @@ -379,7 +379,7 @@ class TestInteractive: return spawn def requirespexpect(self, version_needed): - import pexpect + pexpect = py.test.importorskip("pexpect") ver = tuple(map(int, pexpect.__version__.split("."))) if ver < version_needed: py.test.skip("pexpect version %s needed" %(".".join(map(str, version_needed))))