[py-svn] r57294 - in py/branch/event/py/test2: . dsession dsession/testing testing
hpk at codespeak.net
hpk at codespeak.net
Fri Aug 15 21:44:28 CEST 2008
Author: hpk
Date: Fri Aug 15 21:44:25 2008
New Revision: 57294
Modified:
py/branch/event/py/test2/config.py
py/branch/event/py/test2/defaultconftest.py
py/branch/event/py/test2/dsession/hostmanage.py
py/branch/event/py/test2/dsession/testing/test_hostmanage.py
py/branch/event/py/test2/testing/test_config.py
py/branch/event/py/test2/testing/test_session.py
Log:
implement --exec, works nicely with dsessions and looponfailing
Modified: py/branch/event/py/test2/config.py
==============================================================================
--- py/branch/event/py/test2/config.py (original)
+++ py/branch/event/py/test2/config.py Fri Aug 15 21:44:25 2008
@@ -177,11 +177,12 @@
def _getsessionname(self):
""" return default session name as determined from options. """
- name = 'Session'
- if self.option.looponfailing or self.option.executable:
+ if self.option.looponfailing:
name = 'LooponfailingSession'
- elif self.option.dist:
+ elif self.option.dist or self.option.executable:
name = 'DSession'
+ else:
+ name = 'Session'
return name
def _reparse(self, args):
Modified: py/branch/event/py/test2/defaultconftest.py
==============================================================================
--- py/branch/event/py/test2/defaultconftest.py (original)
+++ py/branch/event/py/test2/defaultconftest.py Fri Aug 15 21:44:25 2008
@@ -16,7 +16,7 @@
#dist_hosts: needs to be provided by user
#dist_rsync_roots: might be provided by user, if not present or None,
# whole pkgdir will be rsynced
-dist_remotepython = "python"
+# XXX deprecated dist_remotepython = None
dist_taskspernode = 15
dist_boxed = False
if hasattr(py.std.os, 'nice'):
Modified: py/branch/event/py/test2/dsession/hostmanage.py
==============================================================================
--- py/branch/event/py/test2/dsession/hostmanage.py (original)
+++ py/branch/event/py/test2/dsession/hostmanage.py Fri Aug 15 21:44:25 2008
@@ -7,7 +7,7 @@
""" Host location representation for distributed testing. """
_hostname2list = {}
- def __init__(self, spec, addrel=""):
+ def __init__(self, spec, addrel="", python=None):
parts = spec.split(':', 1)
self.hostname = parts.pop(0)
self.relpath = parts and parts.pop(0) or ""
@@ -23,6 +23,7 @@
assert not parts
assert self.inplacelocal or self.relpath
self.hostid = self._getuniqueid(self.hostname)
+ self.python = python
def __getstate__(self):
return (self.hostname, self.relpath, self.hostid)
@@ -36,7 +37,8 @@
l.append(hostid)
return hostid
- def initgateway(self, python="python"):
+ def initgateway(self):
+ python = self.python or "python"
if self.hostname == "localhost":
self.gw = py.execnet.PopenGateway(python=python)
else:
@@ -132,15 +134,14 @@
self.roots = roots
if hosts is None:
hosts = self.session.config.getvalue("dist_hosts")
- hosts = [Host(x, addrel) for x in hosts]
+ python = self.session.config.option.executable or "python"
+ hosts = [Host(x, addrel, python=python) for x in hosts]
self.hosts = hosts
def prepare_gateways(self):
- python = self.session.config.getvalue("dist_remotepython")
for host in self.hosts:
- host.initgateway(python=python)
+ host.initgateway()
self.session.bus.notify(event.HostGatewayReady(host, self.roots))
- host.gw.host = host
def init_rsync(self):
self.prepare_gateways()
Modified: py/branch/event/py/test2/dsession/testing/test_hostmanage.py
==============================================================================
--- py/branch/event/py/test2/dsession/testing/test_hostmanage.py (original)
+++ py/branch/event/py/test2/dsession/testing/test_hostmanage.py Fri Aug 15 21:44:25 2008
@@ -84,6 +84,19 @@
finally:
host.gw.exit()
+ def test_initgateway_python(self):
+ host = Host("localhost", python="python2.4")
+ l = []
+ def p(python):
+ l.append(python)
+ raise ValueError
+ py.magic.patch(py.execnet, 'PopenGateway', p)
+ try:
+ py.test2.raises(ValueError, host.initgateway)
+ finally:
+ py.magic.revert(py.execnet, 'PopenGateway')
+ assert l[0] == host.python
+
def test_initgateway_ssh_and_remotepath(self):
from py.__.conftest import option
if not option.sshtarget:
Modified: py/branch/event/py/test2/testing/test_config.py
==============================================================================
--- py/branch/event/py/test2/testing/test_config.py (original)
+++ py/branch/event/py/test2/testing/test_config.py Fri Aug 15 21:44:25 2008
@@ -206,11 +206,6 @@
assert s.find("TestrunStart") != -1
def test_implied_lsession(self):
- #optnames = 'startserver runbrowser apigen=x rest boxed'.split()
- #for x in optnames:
- # config = py.test2.config._reparse([self.tmpdir, '--%s' % x])
- # assert config._getsessionname() == 'LSession'
-
for x in 'startserver runbrowser rest'.split():
config = py.test2.config._reparse([self.tmpdir, '--dist', '--%s' % x])
assert config._getsessionname() == 'DSession'
@@ -219,8 +214,11 @@
config = py.test2.config._reparse([self.tmpdir, '--looponfailing'])
assert config._getsessionname() == 'LooponfailingSession'
config = py.test2.config._reparse([self.tmpdir, '--exec=x'])
- assert config._getsessionname() == 'LooponfailingSession'
+ assert config._getsessionname() == 'DSession'
config = py.test2.config._reparse([self.tmpdir, '--dist', '--exec=x'])
+ assert config._getsessionname() == 'DSession'
+ config = py.test2.config._reparse([self.tmpdir, '-f',
+ '--dist', '--exec=x'])
assert config._getsessionname() == 'LooponfailingSession'
def test_sessionname_lookup_custom(self):
@@ -486,3 +484,4 @@
assert newcol.fspath == topdir
assert newcol2.fspath.basename == dir1.basename
assert newcol2.fspath.relto(topdir)
+
Modified: py/branch/event/py/test2/testing/test_session.py
==============================================================================
--- py/branch/event/py/test2/testing/test_session.py (original)
+++ py/branch/event/py/test2/testing/test_session.py Fri Aug 15 21:44:25 2008
@@ -223,17 +223,3 @@
assert failed[1].colitem.name == "test_other"
assert failed[2].colitem.name == "test_two"
-from py.__.test2.looponfail.remote import LooponfailingSession
-
-class Test_TerminalRemoteSession:
- def test_exec_leads_to_DistSession(self):
- py.test.skip("XXX fix --exec")
- executable = py.std.sys.executable
- config = py.test2.config._reparse(['--exec=' + executable])
- print config
- assert config._getsessionname() == "LooponfailingSession"
-
- def test_looponfailing_leads_to_LooponfailingSession(self):
- config = py.test2.config._reparse(['--looponfailing'])
- sessionname = config._getsessionname()
- assert sessionname == "LooponfailingSession"
More information about the pytest-commit
mailing list