fixes to various tests, related to execnet automatic ID generation and other bits.

also lowering the version as "1.1.1post1" for now.  1.1.2 is still a bit off.

--HG--
branch : trunk
This commit is contained in:
holger krekel 2009-12-24 19:43:14 +01:00
parent 98863d1d01
commit f254b6f7c1
9 changed files with 28 additions and 26 deletions

View File

@ -9,7 +9,7 @@ dictionary or an import path.
(c) Holger Krekel and others, 2009 (c) Holger Krekel and others, 2009
""" """
version = "1.1.2" version = "1.1.1post1"
__version__ = version = version or "1.1.x" __version__ = version = version or "1.1.x"
import py.apipkg import py.apipkg

View File

@ -215,15 +215,16 @@ class DSession(Session):
for node, pending in self.node2pending.items(): for node, pending in self.node2pending.items():
room = min(self.MAXITEMSPERHOST - len(pending), room) room = min(self.MAXITEMSPERHOST - len(pending), room)
sending = tosend[:room] sending = tosend[:room]
for node, pending in self.node2pending.items(): if sending:
node.sendlist(sending) for node, pending in self.node2pending.items():
pending.extend(sending) node.sendlist(sending)
for item in sending: pending.extend(sending)
nodes = self.item2nodes.setdefault(item, []) for item in sending:
assert node not in nodes nodes = self.item2nodes.setdefault(item, [])
nodes.append(node) assert node not in nodes
self.config.hook.pytest_itemstart(item=item, node=node) nodes.append(node)
tosend[:] = tosend[room:] # update inplace self.config.hook.pytest_itemstart(item=item, node=node)
tosend[:] = tosend[room:] # update inplace
if tosend: if tosend:
# we have some left, give it to the main loop # we have some left, give it to the main loop
self.queueevent("pytest_rescheduleitems", items=tosend) self.queueevent("pytest_rescheduleitems", items=tosend)

View File

@ -42,7 +42,7 @@ class TXNode(object):
if eventcall == self.ENDMARK: if eventcall == self.ENDMARK:
err = self.channel._getremoteerror() err = self.channel._getremoteerror()
if not self._down: if not self._down:
if not err: if not err or isinstance(err, EOFError):
err = "Not properly terminated" err = "Not properly terminated"
self.notify("pytest_testnodedown", node=self, error=err) self.notify("pytest_testnodedown", node=self, error=err)
self._down = True self._down = True

View File

@ -16,9 +16,10 @@ def pytest_addoption(parser):
help="start pdb (the Python debugger) on errors.") help="start pdb (the Python debugger) on errors.")
def pytest_configure(config): def pytest_configure(__multicall__, config):
if config.option.usepdb: if config.option.usepdb:
if execnet: if execnet:
__multicall__.execute()
if config.getvalue("looponfail"): if config.getvalue("looponfail"):
raise config.Error("--pdb incompatible with --looponfail.") raise config.Error("--pdb incompatible with --looponfail.")
if config.option.dist != "no": if config.option.dist != "no":

View File

@ -28,7 +28,7 @@ def main():
name='py', name='py',
description='py.test and pylib: rapid testing and development utils.', description='py.test and pylib: rapid testing and development utils.',
long_description = long_description, long_description = long_description,
version= trunk or '1.1.2', version= trunk or '1.1.1post1',
url='http://pylib.org', url='http://pylib.org',
license='MIT license', license='MIT license',
platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],

View File

@ -36,8 +36,8 @@ class TestPDB:
assert i == 1 assert i == 1
""") """)
child = testdir.spawn_pytest("--pdb %s" % p1) child = testdir.spawn_pytest("--pdb %s" % p1)
#child.expect(".*def test_1.*") child.expect(".*def test_1")
child.expect(".*i = 0.*") child.expect(".*i = 0")
child.expect("(Pdb)") child.expect("(Pdb)")
child.sendeof() child.sendeof()
child.expect("1 failed") child.expect("1 failed")
@ -50,7 +50,7 @@ class TestPDB:
py.test.raises(Error, "testdir.parseconfigure('--pdb', '--looponfail')") py.test.raises(Error, "testdir.parseconfigure('--pdb', '--looponfail')")
result = testdir.runpytest("--pdb", "-n", "3") result = testdir.runpytest("--pdb", "-n", "3")
assert result.ret != 0 assert result.ret != 0
assert "incompatible" in result.stdout.str() assert "incompatible" in result.stderr.str()
result = testdir.runpytest("--pdb", "-d", "--tx", "popen") result = testdir.runpytest("--pdb", "-d", "--tx", "popen")
assert result.ret != 0 assert result.ret != 0
assert "incompatible" in result.stdout.str() assert "incompatible" in result.stderr.str()

View File

@ -49,8 +49,8 @@ class TestDistribution:
) )
result = testdir.runpytest(p1, '-d', '--tx=popen', '--tx=popen') result = testdir.runpytest(p1, '-d', '--tx=popen', '--tx=popen')
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
"*0*popen*Python*",
"*1*popen*Python*", "*1*popen*Python*",
"*2*popen*Python*",
"*2 failed, 1 passed, 1 skipped*", "*2 failed, 1 passed, 1 skipped*",
]) ])
assert result.ret == 1 assert result.ret == 1
@ -73,9 +73,9 @@ class TestDistribution:
""") """)
result = testdir.runpytest(p1, '-d') result = testdir.runpytest(p1, '-d')
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
"*0*popen*Python*",
"*1*popen*Python*", "*1*popen*Python*",
"*2*popen*Python*", "*2*popen*Python*",
"*3*popen*Python*",
"*2 failed, 1 passed, 1 skipped*", "*2 failed, 1 passed, 1 skipped*",
]) ])
assert result.ret == 1 assert result.ret == 1
@ -122,7 +122,7 @@ class TestDistribution:
"--tx=popen//chdir=%(dest)s" % locals(), p) "--tx=popen//chdir=%(dest)s" % locals(), p)
assert result.ret == 0 assert result.ret == 0
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
"*1* *popen*platform*", "*0* *popen*platform*",
#"RSyncStart: [G1]", #"RSyncStart: [G1]",
#"RSyncFinished: [G1]", #"RSyncFinished: [G1]",
"*1 passed*" "*1 passed*"

View File

@ -37,10 +37,10 @@ class TestGatewayManagerPopen:
hm.makegateways() hm.makegateways()
call = hookrecorder.popcall("pytest_gwmanage_newgateway") call = hookrecorder.popcall("pytest_gwmanage_newgateway")
assert call.gateway.spec == execnet.XSpec("popen") assert call.gateway.spec == execnet.XSpec("popen")
assert call.gateway.id == "1" assert call.gateway.id == "gw0"
assert call.platinfo.executable == call.gateway._rinfo().executable assert call.platinfo.executable == call.gateway._rinfo().executable
call = hookrecorder.popcall("pytest_gwmanage_newgateway") call = hookrecorder.popcall("pytest_gwmanage_newgateway")
assert call.gateway.id == "2" assert call.gateway.id == "gw1"
assert len(hm.group) == 2 assert len(hm.group) == 2
hm.exit() hm.exit()
assert not len(hm.group) assert not len(hm.group)
@ -66,7 +66,7 @@ class TestGatewayManagerPopen:
l = [] l = []
hm.rsync(source, notify=lambda *args: l.append(args)) hm.rsync(source, notify=lambda *args: l.append(args))
assert len(l) == 1 assert len(l) == 1
assert l[0] == ("rsyncrootready", hm.group['1'].spec, source) assert l[0] == ("rsyncrootready", hm.group['gw0'].spec, source)
hm.exit() hm.exit()
dest = dest.join(source.basename) dest = dest.join(source.basename)
assert dest.join("dir1").check() assert dest.join("dir1").check()

View File

@ -79,7 +79,7 @@ class TestMasterSlaveConnection:
node.send(123) # invalid item node.send(123) # invalid item
kwargs = mysetup.geteventargs("pytest_testnodedown") kwargs = mysetup.geteventargs("pytest_testnodedown")
assert kwargs['node'] is node assert kwargs['node'] is node
assert str(kwargs['error']).find("AttributeError") != -1 assert "Not properly terminated" in str(kwargs['error'])
def test_crash_killed(self, testdir, mysetup): def test_crash_killed(self, testdir, mysetup):
if not hasattr(py.std.os, 'kill'): if not hasattr(py.std.os, 'kill'):
@ -87,13 +87,13 @@ class TestMasterSlaveConnection:
item = testdir.getitem(""" item = testdir.getitem("""
def test_func(): def test_func():
import os import os
os.kill(os.getpid(), 15) os.kill(os.getpid(), 9)
""") """)
node = mysetup.makenode(item.config) node = mysetup.makenode(item.config)
node.send(item) node.send(item)
kwargs = mysetup.geteventargs("pytest_testnodedown") kwargs = mysetup.geteventargs("pytest_testnodedown")
assert kwargs['node'] is node assert kwargs['node'] is node
assert str(kwargs['error']).find("Not properly terminated") != -1 assert "Not properly terminated" in str(kwargs['error'])
def test_node_down(self, mysetup): def test_node_down(self, mysetup):
node = mysetup.makenode() node = mysetup.makenode()