1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
import py
from py.__.test.testing.setupdata import setup_module
class TestRemote:
def test_exec(self):
o = tmpdir.ensure('remote', dir=1)
tfile = o.join('test_exec.py')
tfile.write(py.code.Source("""
def test_1():
assert 1 == 0
"""))
print py.std.sys.executable
config = py.test.config._reparse(
['--exec=' + py.std.sys.executable,
o])
cls = config._getsessionclass()
out = [] # out = py.std.Queue.Queue()
session = cls(config, out.append)
session.main()
for s in out:
if s.find('1 failed') != -1:
break
else:
py.test.fail("did not see test_1 failure")
def test_looponfailing(self):
o = tmpdir.ensure('looponfailing', dir=1)
tfile = o.join('test_looponfailing.py')
tfile.write(py.code.Source("""
def test_1():
assert 1 == 0
"""))
print py.std.sys.executable
config = py.test.config._reparse(['--looponfailing', str(o)])
cls = config._getsessionclass()
out = py.std.Queue.Queue()
session = cls(config, out.put)
pool = py._thread.WorkerPool()
reply = pool.dispatch(session.main)
while 1:
s = out.get(timeout=5.0)
if s.find('1 failed') != -1:
break
print s
else:
py.test.fail("did not see test_1 failure")
# XXX we would like to have a cleaner way to finish
try:
reply.get(timeout=5.0)
except IOError, e:
assert str(e).lower().find('timeout') != -1
|