[py-svn] r33162 - in py/dist/py: . test/rsession test/rsession/testing
fijal at codespeak.net
fijal at codespeak.net
Wed Oct 11 14:07:59 CEST 2006
Author: fijal
Date: Wed Oct 11 14:07:54 2006
New Revision: 33162
Modified:
py/dist/py/__init__.py
py/dist/py/test/rsession/hostmanage.py
py/dist/py/test/rsession/master.py
py/dist/py/test/rsession/rsession.py
py/dist/py/test/rsession/slave.py
py/dist/py/test/rsession/testing/test_rsession.py
py/dist/py/test/rsession/testing/test_slave.py
Log:
Added some shortucts, added option traversal (altough only explicit ones by now), fixed some tests, added new tests for we_are_remote.
Modified: py/dist/py/__init__.py
==============================================================================
--- py/dist/py/__init__.py (original)
+++ py/dist/py/__init__.py Wed Oct 11 14:07:54 2006
@@ -28,6 +28,7 @@
'test.fail' : ('./test/item.py', 'fail'),
'test.exit' : ('./test/session.py', 'exit'),
'test.compat.TestCase' : ('./test/compat.py', 'TestCase'),
+ 'test.remote' : ('./test/rsession/rsession.py', 'remote_options'),
# configuration/initialization related test api
'test.Config' : ('./test/config.py', 'Config'),
Modified: py/dist/py/test/rsession/hostmanage.py
==============================================================================
--- py/dist/py/test/rsession/hostmanage.py (original)
+++ py/dist/py/test/rsession/hostmanage.py Wed Oct 11 14:07:54 2006
@@ -29,7 +29,7 @@
def init_hosts(reporter, sshhosts, relpath, pkgdir, rsync_roots=None, \
- remote_python=None):
+ remote_python=None, remote_options={}):
assert pkgdir.join("__init__.py").check(), (
"%s probably wrong" %(pkgdir,))
assert relpath, relpath
@@ -70,7 +70,8 @@
# hosts ready
for host, gw, remoterootpath in hosts:
- ch = setup_slave(gw, os.path.join(remoterootpath, pkgdir.basename))
+ ch = setup_slave(gw, os.path.join(remoterootpath, pkgdir.basename),
+ remote_options)
nodes.append(MasterNode(ch, reporter))
return nodes
Modified: py/dist/py/test/rsession/master.py
==============================================================================
--- py/dist/py/test/rsession/master.py (original)
+++ py/dist/py/test/rsession/master.py Wed Oct 11 14:07:54 2006
@@ -43,11 +43,12 @@
break
waiter()
-def setup_slave(gateway, pkgpath):
+def setup_slave(gateway, pkgpath, options={}):
from py.__.test.rsession import slave
import os
ch = gateway.remote_exec(str(py.code.Source(slave.setup, "setup()")))
#if hasattr(gateway, 'sshaddress'):
# assert not os.path.isabs(pkgpath)
ch.send(str(pkgpath))
+ ch.send(options)
return ch
Modified: py/dist/py/test/rsession/rsession.py
==============================================================================
--- py/dist/py/test/rsession/rsession.py (original)
+++ py/dist/py/test/rsession/rsession.py Wed Oct 11 14:07:54 2006
@@ -17,7 +17,14 @@
from py.__.test.terminal.out import getout
-we_are_remote = False
+class RemoteOptions(object):
+ def __init__(self, d):
+ self.d = d
+
+ def __getattr__(self, attr):
+ return self.d[attr]
+
+remote_options = RemoteOptions({'we_are_remote':False})
class Reporter(object):
def __init__(self, config, hosts):
Modified: py/dist/py/test/rsession/slave.py
==============================================================================
--- py/dist/py/test/rsession/slave.py (original)
+++ py/dist/py/test/rsession/slave.py Wed Oct 11 14:07:54 2006
@@ -58,16 +58,23 @@
def setup_screen():
# We cannot easily just assume that we do have full communication
# channels, so we have to provide a new ones.
- pass
+ import thread
+ import os, sys
+ # the idea is simple: we create another process in which we perform
+ # read/write operations on both channels
+
def setup():
import os, sys
pkgdir = channel.receive() # path is ready
+ options = channel.receive() # options stuff, should be dictionary
basedir = os.path.dirname(pkgdir)
pkgname = os.path.basename(pkgdir)
sys.path.insert(0, basedir)
import py
- py.test.we_are_remote = True
+ from py.__.test.rsession.rsession import RemoteOptions
+ options['we_are_remote'] = True
+ py.test.remote = RemoteOptions(options)
# XXX the following assumes that py lib is there, a bit
# much of an assumtion
mod = __import__(pkgname)
Modified: py/dist/py/test/rsession/testing/test_rsession.py
==============================================================================
--- py/dist/py/test/rsession/testing/test_rsession.py (original)
+++ py/dist/py/test/rsession/testing/test_rsession.py Wed Oct 11 14:07:54 2006
@@ -7,7 +7,8 @@
from py.__.test.rsession.rsession import RSession
from py.__.test.rsession.hostmanage import init_hosts, teardown_hosts
from py.__.test.rsession.testing.test_slave import funcfail_spec,\
- funcpass_spec, funcskip_spec, funcprint_spec, funcprintfail_spec
+ funcpass_spec, funcskip_spec, funcprint_spec, funcprintfail_spec, \
+ funcoptioncustom_spec, funcoption_spec
def setup_module(mod):
mod.pkgdir = py.path.local(py.__file__).dirpath()
@@ -30,7 +31,7 @@
def test_getpkdir_no_inits():
tmp = py.test.ensuretemp("getpkdir1")
fn = tmp.ensure("hello.py")
- py.test.raises(AssertionError, "RSession.getpkgdir(fn)")
+ assert RSession.getpkgdir(fn) == fn
def test_make_colitems():
one = pkgdir.join("initpkg.py")
@@ -112,6 +113,7 @@
tmpdir = py.path.local(py.__file__).dirpath().dirpath()
tmpdir.ensure("sub", "conftest.py").write(py.code.Source("""
disthosts = %r
+ distrsync_roots = ["sub", "py"]
""" % self.hosts[:1]))
tmpdir.ensure("sub", "__init__.py")
tmpdir.ensure("sub", "test_one.py").write(py.code.Source("""
@@ -126,7 +128,7 @@
"""))
args = [str(tmpdir.join("sub"))]
config, args = py.test.Config.parse(args)
- rsession = RSession(config)
+ rsession = RSession(config)
allevents = []
rsession.main(args, reporter=allevents.append)
testevents = [x for x in allevents
@@ -156,7 +158,8 @@
setup_events = []
teardown_events = []
- nodes = init_hosts(setup_events.append, hosts, 'pytesttest', pkgdir)
+ nodes = init_hosts(setup_events.append, hosts, 'pytesttest', pkgdir,
+ rsync_roots=["py"])
teardown_hosts(teardown_events.append,
[node.channel for node in nodes], nodes)
@@ -179,7 +182,8 @@
hosts = self.hosts
allevents = []
- nodes = init_hosts(allevents.append, hosts, 'pytesttest', pkgdir)
+ nodes = init_hosts(allevents.append, hosts, 'pytesttest', pkgdir,
+ rsync_roots=["py"])
from py.__.test.rsession.testing.test_executor \
import ItemTestPassing, ItemTestFailing, ItemTestSkipping
@@ -211,3 +215,30 @@
# one of passed for each node has non-empty stdout
passed_stdout = [i for i in passed if i.outcome.stdout == 'samfing\n']
assert len(passed_stdout) == len(nodes), passed
+
+ def test_config_pass(self):
+ """ Tests options object passing master -> server
+ """
+ allevents = []
+ hosts = self.hosts
+ nodes = init_hosts(allevents.append, hosts, 'pytesttest', pkgdir,
+ rsync_roots=["py"], remote_options={'custom':'custom'})
+
+ rootcol = py.test.collect.Directory(pkgdir.dirpath())
+ itempass = rootcol.getitembynames(funcoption_spec)
+ itempassaswell = rootcol.getitembynames(funcoptioncustom_spec)
+
+ for node in nodes:
+ node.send(itempass)
+ node.send(itempassaswell)
+
+ teardown_hosts(allevents.append, [node.channel for node in nodes], nodes)
+ events = [i for i in allevents
+ if isinstance(i, report.ReceivedItemOutcome)]
+ passed = [i for i in events
+ if i.outcome.passed]
+ skipped = [i for i in events
+ if i.outcome.skipped]
+ assert len(passed) == 2 * len(nodes)
+ assert len(skipped) == 0
+ assert len(events) == len(passed)
Modified: py/dist/py/test/rsession/testing/test_slave.py
==============================================================================
--- py/dist/py/test/rsession/testing/test_slave.py (original)
+++ py/dist/py/test/rsession/testing/test_slave.py Wed Oct 11 14:07:54 2006
@@ -29,11 +29,20 @@
print "samfing elz"
asddsa
-funcpass_spec = "py/test/rsession/testing/test_slave.py/funcpass".split("/")
-funcfail_spec = "py/test/rsession/testing/test_slave.py/funcfail".split("/")
-funcskip_spec = "py/test/rsession/testing/test_slave.py/funcskip".split("/")
-funcprint_spec = "py/test/rsession/testing/test_slave.py/funcprint".split("/")
-funcprintfail_spec = "py/test/rsession/testing/test_slave.py/funcprintfail".split("/")
+def funcoption():
+ assert py.test.remote.we_are_remote
+
+def funcoptioncustom():
+ assert py.test.remote.custom == "custom"
+
+BASE = "py/test/rsession/testing/test_slave.py/"
+funcpass_spec = (BASE + "funcpass").split("/")
+funcfail_spec = (BASE + "funcfail").split("/")
+funcskip_spec = (BASE + "funcskip").split("/")
+funcprint_spec = (BASE + "funcprint").split("/")
+funcprintfail_spec = (BASE + "funcprintfail").split("/")
+funcoption_spec = (BASE + "funcoption").split("/")
+funcoptioncustom_spec = (BASE + "funcoptioncustom").split("/")
# ----------------------------------------------------------------------
More information about the pytest-commit
mailing list