remove trailing whitespace from sources
This commit is contained in:
@@ -13,7 +13,7 @@ class TestDistribution:
|
||||
pass
|
||||
def test_skip():
|
||||
py.test.skip("hello")
|
||||
""",
|
||||
""",
|
||||
)
|
||||
result = testdir.runpytest(p1, "-v", '-d', '--tx=popen', '--tx=popen')
|
||||
result.stdout.fnmatch_lines([
|
||||
@@ -34,7 +34,7 @@ class TestDistribution:
|
||||
pass
|
||||
def test_skip():
|
||||
py.test.skip("hello")
|
||||
""",
|
||||
""",
|
||||
)
|
||||
testdir.makeconftest("""
|
||||
option_tx = 'popen popen popen'.split()
|
||||
@@ -52,7 +52,7 @@ class TestDistribution:
|
||||
def test_dist_tests_with_crash(self, testdir):
|
||||
if not hasattr(py.std.os, 'kill'):
|
||||
py.test.skip("no os.kill")
|
||||
|
||||
|
||||
p1 = testdir.makepyfile("""
|
||||
import py
|
||||
def test_fail0():
|
||||
@@ -87,7 +87,7 @@ class TestDistribution:
|
||||
subdir.ensure("__init__.py")
|
||||
p = subdir.join("test_one.py")
|
||||
p.write("def test_5(): assert not __file__.startswith(%r)" % str(p))
|
||||
result = testdir.runpytest("-v", "-d", "--rsyncdir=%(subdir)s" % locals(),
|
||||
result = testdir.runpytest("-v", "-d", "--rsyncdir=%(subdir)s" % locals(),
|
||||
"--tx=popen//chdir=%(dest)s" % locals(), p)
|
||||
assert result.ret == 0
|
||||
result.stdout.fnmatch_lines([
|
||||
@@ -143,7 +143,7 @@ class TestDistribution:
|
||||
def pytest_terminal_summary(terminalreporter):
|
||||
if not hasattr(terminalreporter.config, 'slaveinput'):
|
||||
calc_result = terminalreporter.config.calc_result
|
||||
terminalreporter._tw.sep('-',
|
||||
terminalreporter._tw.sep('-',
|
||||
'calculated result is %s' % calc_result)
|
||||
""")
|
||||
p1 = testdir.makepyfile("def test_func(): pass")
|
||||
@@ -171,12 +171,12 @@ class TestDistribution:
|
||||
args = ["-n1"]
|
||||
result = testdir.runpytest(*args)
|
||||
s = result.stdout.str()
|
||||
assert result.ret
|
||||
assert result.ret
|
||||
assert 'SIGINT' in s
|
||||
assert 's2call' in s
|
||||
|
||||
def test_keyboard_interrupt_dist(self, testdir):
|
||||
# xxx could be refined to check for return code
|
||||
# xxx could be refined to check for return code
|
||||
p = testdir.makepyfile("""
|
||||
def test_sleep():
|
||||
import time
|
||||
@@ -188,7 +188,7 @@ class TestDistribution:
|
||||
child.expect(".*KeyboardInterrupt.*")
|
||||
#child.expect(".*seconds.*")
|
||||
child.close()
|
||||
#assert ret == 2
|
||||
#assert ret == 2
|
||||
|
||||
class TestTerminalReporting:
|
||||
def test_pass_skip_fail(self, testdir):
|
||||
@@ -203,9 +203,9 @@ class TestTerminalReporting:
|
||||
""")
|
||||
result = testdir.runpytest("-n1", "-v")
|
||||
expected = [
|
||||
"*PASS*test_pass_skip_fail.py:2: *test_ok*",
|
||||
"*SKIP*test_pass_skip_fail.py:4: *test_skip*",
|
||||
"*FAIL*test_pass_skip_fail.py:6: *test_func*",
|
||||
"*PASS*test_pass_skip_fail.py:2: *test_ok*",
|
||||
"*SKIP*test_pass_skip_fail.py:4: *test_skip*",
|
||||
"*FAIL*test_pass_skip_fail.py:6: *test_func*",
|
||||
]
|
||||
for line in expected:
|
||||
result.stdout.fnmatch_lines([line])
|
||||
@@ -222,7 +222,7 @@ class TestTerminalReporting:
|
||||
""")
|
||||
result = testdir.runpytest("-n1", "-v")
|
||||
result.stdout.fnmatch_lines([
|
||||
"*FAIL*test_fail_platinfo.py:1: *test_func*",
|
||||
"*FAIL*test_fail_platinfo.py:1: *test_func*",
|
||||
"*popen*Python*",
|
||||
" def test_func():",
|
||||
"> assert 0",
|
||||
|
||||
@@ -2,11 +2,11 @@ import py
|
||||
import execnet
|
||||
|
||||
pytest_plugins = "pytester"
|
||||
|
||||
|
||||
#rsyncdirs = ['.', '../xdist', py.path.local(execnet.__file__).dirpath()]
|
||||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption('--gx',
|
||||
parser.addoption('--gx',
|
||||
action="append", dest="gspecs", default=None,
|
||||
help=("add a global test environment, XSpec-syntax. "))
|
||||
|
||||
@@ -16,9 +16,9 @@ def getgspecs(config):
|
||||
return [execnet.XSpec(spec)
|
||||
for spec in config.getvalueorskip("gspecs")]
|
||||
|
||||
# configuration information for tests
|
||||
# configuration information for tests
|
||||
def getgspecs(config):
|
||||
return [execnet.XSpec(spec)
|
||||
return [execnet.XSpec(spec)
|
||||
for spec in config.getvalueorskip("gspecs")]
|
||||
|
||||
def getspecssh(config):
|
||||
|
||||
@@ -8,9 +8,9 @@ def test_dist_conftest_options(testdir, recwarn):
|
||||
import py
|
||||
from py.builtin import print_
|
||||
print_("importing conftest", __file__)
|
||||
Option = py.test.config.Option
|
||||
option = py.test.config.addoptions("someopt",
|
||||
Option('--someopt', action="store_true",
|
||||
Option = py.test.config.Option
|
||||
option = py.test.config.addoptions("someopt",
|
||||
Option('--someopt', action="store_true",
|
||||
dest="someopt", default=False))
|
||||
dist_rsync_roots = ['../dir']
|
||||
print_("added options", option)
|
||||
@@ -20,13 +20,13 @@ def test_dist_conftest_options(testdir, recwarn):
|
||||
import py
|
||||
from %s import conftest
|
||||
from py.builtin import print_
|
||||
def test_1():
|
||||
def test_1():
|
||||
print_("config from test_1", py.test.config)
|
||||
print_("conftest from test_1", conftest.__file__)
|
||||
print_("test_1: py.test.config.option.someopt", py.test.config.option.someopt)
|
||||
print_("test_1: conftest", conftest)
|
||||
print_("test_1: conftest.option.someopt", conftest.option.someopt)
|
||||
assert conftest.option.someopt
|
||||
assert conftest.option.someopt
|
||||
""" % p1.dirpath().purebasename ))
|
||||
result = testdir.runpytest('-d', '--tx=popen', p1, '--someopt')
|
||||
assert result.ret == 0
|
||||
@@ -34,5 +34,5 @@ def test_dist_conftest_options(testdir, recwarn):
|
||||
"*Deprecation*pytest_addoptions*",
|
||||
])
|
||||
result.stdout.fnmatch_lines([
|
||||
"*1 passed*",
|
||||
"*1 passed*",
|
||||
])
|
||||
|
||||
@@ -7,10 +7,10 @@ XSpec = execnet.XSpec
|
||||
|
||||
def run(item, node, excinfo=None):
|
||||
runner = item.config.pluginmanager.getplugin("runner")
|
||||
rep = runner.ItemTestReport(item=item,
|
||||
rep = runner.ItemTestReport(item=item,
|
||||
excinfo=excinfo, when="call")
|
||||
rep.node = node
|
||||
return rep
|
||||
return rep
|
||||
|
||||
class MockNode:
|
||||
def __init__(self):
|
||||
@@ -43,7 +43,7 @@ class TestDSession:
|
||||
assert pending == [item]
|
||||
assert item not in session.item2nodes
|
||||
l = session.removenode(node)
|
||||
assert not l
|
||||
assert not l
|
||||
|
||||
def test_senditems_each_and_receive_with_two_nodes(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
@@ -60,7 +60,7 @@ class TestDSession:
|
||||
session.removeitem(item, node1)
|
||||
assert session.item2nodes[item] == [node2]
|
||||
session.removeitem(item, node2)
|
||||
assert not session.node2pending[node1]
|
||||
assert not session.node2pending[node1]
|
||||
assert not session.item2nodes
|
||||
|
||||
def test_senditems_load_and_receive_one_node(self, testdir):
|
||||
@@ -69,11 +69,11 @@ class TestDSession:
|
||||
rep = run(item, node)
|
||||
session = DSession(item.config)
|
||||
session.addnode(node)
|
||||
session.senditems_load([item])
|
||||
session.senditems_load([item])
|
||||
assert session.node2pending[node] == [item]
|
||||
assert session.item2nodes[item] == [node]
|
||||
session.removeitem(item, node)
|
||||
assert not session.node2pending[node]
|
||||
assert not session.node2pending[node]
|
||||
assert not session.item2nodes
|
||||
|
||||
def test_triggertesting_collect(self, testdir):
|
||||
@@ -110,7 +110,7 @@ class TestDSession:
|
||||
assert name == "pytest_rescheduleitems"
|
||||
assert kwargs['items'] == [item]
|
||||
|
||||
|
||||
|
||||
def test_keyboardinterrupt(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
session = DSession(item.config)
|
||||
@@ -142,8 +142,8 @@ class TestDSession:
|
||||
session.queueevent("pytest_rescheduleitems", items=[item])
|
||||
session.loop_once(loopstate)
|
||||
# now we want to not directly trigger work again to avoid busy-wait
|
||||
assert loopstate.dowork == False
|
||||
|
||||
assert loopstate.dowork == False
|
||||
|
||||
session.queueevent(None)
|
||||
session.loop_once(loopstate)
|
||||
session.queueevent(None)
|
||||
@@ -153,8 +153,8 @@ class TestDSession:
|
||||
session.loop_once(loopstate)
|
||||
session.queueevent("pytest_runtest_logreport", report=run(item, node))
|
||||
session.loop_once(loopstate)
|
||||
assert loopstate.shuttingdown
|
||||
assert not loopstate.testsfailed
|
||||
assert loopstate.shuttingdown
|
||||
assert not loopstate.testsfailed
|
||||
|
||||
def test_no_node_remaining_for_tests(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
@@ -162,7 +162,7 @@ class TestDSession:
|
||||
session = DSession(item.config)
|
||||
node = MockNode()
|
||||
session.addnode(node)
|
||||
|
||||
|
||||
# setup a HostDown event
|
||||
session.queueevent("pytest_testnodedown", node=node, error=None)
|
||||
|
||||
@@ -174,12 +174,12 @@ class TestDSession:
|
||||
|
||||
def test_removeitem_from_failing_teardown(self, testdir):
|
||||
# teardown reports only come in when they signal a failure
|
||||
# internal session-management should basically ignore them
|
||||
# XXX probably it'S best to invent a new error hook for
|
||||
# internal session-management should basically ignore them
|
||||
# XXX probably it'S best to invent a new error hook for
|
||||
# teardown/setup related failures
|
||||
modcol = testdir.getmodulecol("""
|
||||
def test_one():
|
||||
pass
|
||||
def test_one():
|
||||
pass
|
||||
def teardown_function(function):
|
||||
assert 0
|
||||
""")
|
||||
@@ -190,8 +190,8 @@ class TestDSession:
|
||||
node1, node2 = MockNode(), MockNode()
|
||||
session.addnode(node1)
|
||||
session.addnode(node2)
|
||||
|
||||
# have one test pending for a node that goes down
|
||||
|
||||
# have one test pending for a node that goes down
|
||||
session.senditems_each([item1])
|
||||
nodes = session.item2nodes[item1]
|
||||
class rep:
|
||||
@@ -233,14 +233,14 @@ class TestDSession:
|
||||
session.loop_once(loopstate)
|
||||
|
||||
assert node.sent == [item]
|
||||
ev = run(item, node, excinfo=excinfo)
|
||||
ev = run(item, node, excinfo=excinfo)
|
||||
session.queueevent("pytest_runtest_logreport", report=ev)
|
||||
session.loop_once(loopstate)
|
||||
assert loopstate.shuttingdown
|
||||
assert loopstate.shuttingdown
|
||||
session.queueevent("pytest_testnodedown", node=node, error=None)
|
||||
session.loop_once(loopstate)
|
||||
dumpqueue(session.queue)
|
||||
return session, loopstate.exitstatus
|
||||
return session, loopstate.exitstatus
|
||||
|
||||
def test_exit_completed_tests_ok(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
@@ -254,9 +254,9 @@ class TestDSession:
|
||||
|
||||
def test_exit_on_first_failing(self, testdir):
|
||||
modcol = testdir.getmodulecol("""
|
||||
def test_fail():
|
||||
def test_fail():
|
||||
assert 0
|
||||
def test_pass():
|
||||
def test_pass():
|
||||
pass
|
||||
""")
|
||||
modcol.config.option.maxfail = 1
|
||||
@@ -268,10 +268,10 @@ class TestDSession:
|
||||
# trigger testing - this sends tests to the node
|
||||
session.triggertesting(items)
|
||||
|
||||
# run tests ourselves and produce reports
|
||||
# run tests ourselves and produce reports
|
||||
ev1 = run(items[0], node, "fail")
|
||||
ev2 = run(items[1], node, None)
|
||||
session.queueevent("pytest_runtest_logreport", report=ev1)
|
||||
session.queueevent("pytest_runtest_logreport", report=ev1)
|
||||
session.queueevent("pytest_runtest_logreport", report=ev2)
|
||||
# now call the loop
|
||||
loopstate = session._initloopstate(items)
|
||||
@@ -281,11 +281,11 @@ class TestDSession:
|
||||
|
||||
def test_maxfail(self, testdir):
|
||||
modcol = testdir.getmodulecol("""
|
||||
def test_fail1():
|
||||
def test_fail1():
|
||||
assert 0
|
||||
def test_fail2():
|
||||
def test_fail2():
|
||||
assert 0
|
||||
def test_pass():
|
||||
def test_pass():
|
||||
pass
|
||||
""")
|
||||
modcol.config.option.maxfail = 2
|
||||
@@ -297,7 +297,7 @@ class TestDSession:
|
||||
# trigger testing - this sends tests to the node
|
||||
session.triggertesting(items)
|
||||
|
||||
# run tests ourselves and produce reports
|
||||
# run tests ourselves and produce reports
|
||||
ev1 = run(items[0], node, "fail")
|
||||
ev2 = run(items[1], node, "fail")
|
||||
session.queueevent("pytest_runtest_logreport", report=ev1) # a failing one
|
||||
@@ -329,23 +329,23 @@ class TestDSession:
|
||||
|
||||
def test_filteritems(self, testdir):
|
||||
modcol = testdir.getmodulecol("""
|
||||
def test_fail():
|
||||
def test_fail():
|
||||
assert 0
|
||||
def test_pass():
|
||||
def test_pass():
|
||||
pass
|
||||
""")
|
||||
session = DSession(modcol.config)
|
||||
|
||||
modcol.config.option.keyword = "nothing"
|
||||
dsel = session.filteritems([modcol])
|
||||
assert dsel == [modcol]
|
||||
assert dsel == [modcol]
|
||||
items = modcol.collect()
|
||||
hookrecorder = testdir.getreportrecorder(session).hookrecorder
|
||||
remaining = session.filteritems(items)
|
||||
assert remaining == []
|
||||
|
||||
|
||||
event = hookrecorder.getcalls("pytest_deselected")[-1]
|
||||
assert event.items == items
|
||||
assert event.items == items
|
||||
|
||||
modcol.config.option.keyword = "test_fail"
|
||||
remaining = session.filteritems(items)
|
||||
@@ -366,16 +366,16 @@ class TestDSession:
|
||||
session.loop_once(loopstate)
|
||||
assert node._shutdown is True
|
||||
assert loopstate.exitstatus is None, "loop did not wait for testnodedown"
|
||||
assert loopstate.shuttingdown
|
||||
assert loopstate.shuttingdown
|
||||
session.queueevent("pytest_testnodedown", node=node, error=None)
|
||||
session.loop_once(loopstate)
|
||||
assert loopstate.exitstatus == 0
|
||||
|
||||
def test_nopending_but_collection_remains(self, testdir):
|
||||
modcol = testdir.getmodulecol("""
|
||||
def test_fail():
|
||||
def test_fail():
|
||||
assert 0
|
||||
def test_pass():
|
||||
def test_pass():
|
||||
pass
|
||||
""")
|
||||
session = DSession(modcol.config)
|
||||
@@ -385,24 +385,24 @@ class TestDSession:
|
||||
colreport = modcol.config.hook.pytest_make_collect_report(collector=modcol)
|
||||
item1, item2 = colreport.result
|
||||
session.senditems_load([item1])
|
||||
# node2pending will become empty when the loop sees the report
|
||||
# node2pending will become empty when the loop sees the report
|
||||
rep = run(item1, node)
|
||||
session.queueevent("pytest_runtest_logreport", report=run(item1, node))
|
||||
session.queueevent("pytest_runtest_logreport", report=run(item1, node))
|
||||
|
||||
# but we have a collection pending
|
||||
session.queueevent("pytest_collectreport", report=colreport)
|
||||
session.queueevent("pytest_collectreport", report=colreport)
|
||||
|
||||
loopstate = session._initloopstate([])
|
||||
session.loop_once(loopstate)
|
||||
assert loopstate.exitstatus is None, "loop did not care for collection report"
|
||||
assert not loopstate.colitems
|
||||
assert not loopstate.colitems
|
||||
session.loop_once(loopstate)
|
||||
assert loopstate.colitems == colreport.result
|
||||
assert loopstate.exitstatus is None, "loop did not care for colitems"
|
||||
|
||||
def test_dist_some_tests(self, testdir):
|
||||
p1 = testdir.makepyfile(test_one="""
|
||||
def test_1():
|
||||
def test_1():
|
||||
pass
|
||||
def test_x():
|
||||
import py
|
||||
@@ -420,7 +420,7 @@ class TestDSession:
|
||||
assert rep.skipped
|
||||
rep = hookrecorder.popcall("pytest_runtest_logreport").report
|
||||
assert rep.failed
|
||||
# see that the node is really down
|
||||
# see that the node is really down
|
||||
node = hookrecorder.popcall("pytest_testnodedown").node
|
||||
assert node.gateway.spec.popen
|
||||
#XXX eq.geteventargs("pytest_sessionfinish")
|
||||
@@ -442,7 +442,7 @@ class TestDSession:
|
||||
# executable = "hello"
|
||||
# platform = "xyz"
|
||||
# cwd = "qwe"
|
||||
|
||||
|
||||
#dsession.pytest_gwmanage_newgateway(gw1, rinfo)
|
||||
#linecomp.assert_contains_lines([
|
||||
# "*X1*popen*xyz*2.5*"
|
||||
@@ -461,9 +461,9 @@ def test_collected_function_causes_remote_skip(testdir):
|
||||
path.remove()
|
||||
else:
|
||||
py.test.skip("remote skip")
|
||||
def test_func():
|
||||
def test_func():
|
||||
pass
|
||||
def test_func2():
|
||||
def test_func2():
|
||||
pass
|
||||
""" % str(sub.ensure("somefile"))))
|
||||
result = testdir.runpytest('-v', '--dist=each', '--tx=popen')
|
||||
@@ -473,14 +473,14 @@ def test_collected_function_causes_remote_skip(testdir):
|
||||
|
||||
def test_teardownfails_one_function(testdir):
|
||||
p = testdir.makepyfile("""
|
||||
def test_func():
|
||||
def test_func():
|
||||
pass
|
||||
def teardown_function(function):
|
||||
assert 0
|
||||
""")
|
||||
result = testdir.runpytest(p, '--dist=each', '--tx=popen')
|
||||
result.stdout.fnmatch_lines([
|
||||
"*def teardown_function(function):*",
|
||||
"*def teardown_function(function):*",
|
||||
"*1 passed*1 error*"
|
||||
])
|
||||
|
||||
@@ -493,7 +493,7 @@ def test_terminate_on_hangingnode(testdir):
|
||||
time.sleep(3)
|
||||
""")
|
||||
result = testdir.runpytest(p, '--dist=each', '--tx=popen//id=my')
|
||||
assert result.duration < 2.0
|
||||
assert result.duration < 2.0
|
||||
result.stdout.fnmatch_lines([
|
||||
"*killed*my*",
|
||||
])
|
||||
@@ -510,9 +510,9 @@ def test_session_hooks(testdir):
|
||||
f.write("xy")
|
||||
f.close()
|
||||
# let's fail on the slave
|
||||
if session.nodeid:
|
||||
if session.nodeid:
|
||||
raise ValueError(42)
|
||||
""")
|
||||
""")
|
||||
p = testdir.makepyfile("""
|
||||
import sys
|
||||
def test_hello():
|
||||
@@ -523,7 +523,7 @@ def test_session_hooks(testdir):
|
||||
"*ValueError*",
|
||||
"*1 passed*",
|
||||
])
|
||||
assert result.ret
|
||||
assert result.ret
|
||||
d = result.parseoutcomes()
|
||||
assert d['passed'] == 1
|
||||
assert testdir.tmpdir.join("my1").check()
|
||||
@@ -534,7 +534,7 @@ def test_funcarg_teardown_failure(testdir):
|
||||
def pytest_funcarg__myarg(request):
|
||||
def teardown(val):
|
||||
raise ValueError(val)
|
||||
return request.cached_setup(setup=lambda: 42, teardown=teardown,
|
||||
return request.cached_setup(setup=lambda: 42, teardown=teardown,
|
||||
scope="module")
|
||||
def test_hello(myarg):
|
||||
pass
|
||||
@@ -562,4 +562,4 @@ def test_crashing_item(testdir):
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class TestGatewayManagerPopen:
|
||||
assert spec.chdir == "pyexecnetcache"
|
||||
for spec in GatewayManager(l, hook, defaultchdir="abc").specs:
|
||||
assert spec.chdir == "abc"
|
||||
|
||||
|
||||
def test_popen_makegateway_events(self, hook, hookrecorder, _pytest):
|
||||
hm = GatewayManager(["popen"] * 2, hook)
|
||||
hm.makegateways()
|
||||
@@ -34,10 +34,10 @@ class TestGatewayManagerPopen:
|
||||
assert call.gateway.id == "gw0"
|
||||
assert call.platinfo.executable == call.gateway._rinfo().executable
|
||||
call = hookrecorder.popcall("pytest_gwmanage_newgateway")
|
||||
assert call.gateway.id == "gw1"
|
||||
assert call.gateway.id == "gw1"
|
||||
assert len(hm.group) == 2
|
||||
hm.exit()
|
||||
assert not len(hm.group)
|
||||
assert not len(hm.group)
|
||||
|
||||
def test_popens_rsync(self, hook, mysetup):
|
||||
source = mysetup.source
|
||||
@@ -56,11 +56,11 @@ class TestGatewayManagerPopen:
|
||||
hm.rsync(source, notify=lambda *args: l.append(args))
|
||||
assert not l
|
||||
hm.exit()
|
||||
assert not len(hm.group)
|
||||
assert "sys.path.insert" in gw.remote_exec.args[0]
|
||||
assert not len(hm.group)
|
||||
assert "sys.path.insert" in gw.remote_exec.args[0]
|
||||
|
||||
def test_rsync_popen_with_path(self, hook, mysetup):
|
||||
source, dest = mysetup.source, mysetup.dest
|
||||
source, dest = mysetup.source, mysetup.dest
|
||||
hm = GatewayManager(["popen//chdir=%s" %dest] * 1, hook)
|
||||
hm.makegateways()
|
||||
source.ensure("dir1", "dir2", "hello")
|
||||
@@ -75,16 +75,16 @@ class TestGatewayManagerPopen:
|
||||
assert dest.join("dir1", "dir2", 'hello').check()
|
||||
|
||||
def test_rsync_same_popen_twice(self, hook, mysetup, hookrecorder):
|
||||
source, dest = mysetup.source, mysetup.dest
|
||||
source, dest = mysetup.source, mysetup.dest
|
||||
hm = GatewayManager(["popen//chdir=%s" %dest] * 2, hook)
|
||||
hm.makegateways()
|
||||
source.ensure("dir1", "dir2", "hello")
|
||||
hm.rsync(source)
|
||||
call = hookrecorder.popcall("pytest_gwmanage_rsyncstart")
|
||||
assert call.source == source
|
||||
call = hookrecorder.popcall("pytest_gwmanage_rsyncstart")
|
||||
assert call.source == source
|
||||
assert len(call.gateways) == 1
|
||||
assert call.gateways[0] in hm.group
|
||||
call = hookrecorder.popcall("pytest_gwmanage_rsyncfinish")
|
||||
call = hookrecorder.popcall("pytest_gwmanage_rsyncfinish")
|
||||
|
||||
class pytest_funcarg__mysetup:
|
||||
def __init__(self, request):
|
||||
|
||||
@@ -7,7 +7,7 @@ Queue = py.builtin._tryimport('queue', 'Queue').Queue
|
||||
|
||||
from xdist.mypickle import ImmutablePickler, PickleChannel
|
||||
from xdist.mypickle import UnpickleError, makekey
|
||||
# first let's test some basic functionality
|
||||
# first let's test some basic functionality
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
if 'picklemod' in metafunc.funcargnames:
|
||||
@@ -52,17 +52,17 @@ def test_underlying_basic_pickling_mechanisms(picklemod):
|
||||
|
||||
pickler2.dump(d_other)
|
||||
f2.seek(0)
|
||||
|
||||
unpickler1.memo = dict([(makekey(x), y)
|
||||
|
||||
unpickler1.memo = dict([(makekey(x), y)
|
||||
for x, y in pickler1.memo.values()])
|
||||
d_back = unpickler1.load()
|
||||
assert d is d_back
|
||||
|
||||
|
||||
class A:
|
||||
class A:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def test_pickle_and_back_IS_same(obj, proto):
|
||||
p1 = ImmutablePickler(uneven=False, protocol=proto)
|
||||
p2 = ImmutablePickler(uneven=True, protocol=proto)
|
||||
@@ -70,7 +70,7 @@ def test_pickle_and_back_IS_same(obj, proto):
|
||||
d2 = p2.loads(s1)
|
||||
s2 = p2.dumps(d2)
|
||||
obj_back = p1.loads(s2)
|
||||
assert obj is obj_back
|
||||
assert obj is obj_back
|
||||
|
||||
def test_pickling_twice_before_unpickling():
|
||||
p1 = ImmutablePickler(uneven=False)
|
||||
@@ -78,7 +78,7 @@ def test_pickling_twice_before_unpickling():
|
||||
|
||||
a1 = A()
|
||||
a2 = A()
|
||||
a3 = A()
|
||||
a3 = A()
|
||||
a3.a1 = a1
|
||||
a2.a1 = a1
|
||||
s1 = p1.dumps(a1)
|
||||
@@ -102,7 +102,7 @@ def test_pickling_concurrently():
|
||||
a1.hasattr = 42
|
||||
a2 = A()
|
||||
|
||||
s1 = p1.dumps(a1)
|
||||
s1 = p1.dumps(a1)
|
||||
s2 = p2.dumps(a2)
|
||||
other_a1 = p2.loads(s1)
|
||||
other_a2 = p1.loads(s2)
|
||||
@@ -123,7 +123,7 @@ class TestPickleChannelFunctional:
|
||||
"import py ; py.path.local(%r).pyimport()" %(__file__)
|
||||
)
|
||||
cls.gw.remote_init_threads(5)
|
||||
# we need the remote test code to import
|
||||
# we need the remote test code to import
|
||||
# the same test module here
|
||||
|
||||
def test_popen_send_instance(self):
|
||||
@@ -143,7 +143,7 @@ class TestPickleChannelFunctional:
|
||||
assert a_received.hello == 10
|
||||
channel.send(a_received)
|
||||
remote_a2_is_a1 = channel.receive()
|
||||
assert remote_a2_is_a1
|
||||
assert remote_a2_is_a1
|
||||
|
||||
def test_send_concurrent(self):
|
||||
channel = self.gw.remote_exec("""
|
||||
@@ -152,7 +152,7 @@ class TestPickleChannelFunctional:
|
||||
from testing.test_mypickle import A
|
||||
l = [A() for i in range(10)]
|
||||
channel.send(l)
|
||||
other_l = channel.receive()
|
||||
other_l = channel.receive()
|
||||
channel.send((l, other_l))
|
||||
channel.send(channel.receive())
|
||||
channel.receive()
|
||||
@@ -164,17 +164,17 @@ class TestPickleChannelFunctional:
|
||||
channel.send(other_l)
|
||||
ret = channel.receive()
|
||||
assert ret[0] is other_l
|
||||
assert ret[1] is l
|
||||
assert ret[1] is l
|
||||
back = channel.receive()
|
||||
assert other_l is other_l
|
||||
assert other_l is other_l
|
||||
channel.send(None)
|
||||
|
||||
#s1 = p1.dumps(a1)
|
||||
#s1 = p1.dumps(a1)
|
||||
#s2 = p2.dumps(a2)
|
||||
#other_a1 = p2.loads(s1)
|
||||
#other_a2 = p1.loads(s2)
|
||||
#a1_back = p1.loads(p2.dumps(other_a1))
|
||||
|
||||
|
||||
def test_popen_with_callback(self):
|
||||
channel = self.gw.remote_exec("""
|
||||
from xdist.mypickle import PickleChannel
|
||||
@@ -194,7 +194,7 @@ class TestPickleChannelFunctional:
|
||||
assert a_received.hello == 10
|
||||
channel.send(a_received)
|
||||
#remote_a2_is_a1 = queue.get(timeout=TESTTIMEOUT)
|
||||
#assert remote_a2_is_a1
|
||||
#assert remote_a2_is_a1
|
||||
|
||||
def test_popen_with_callback_with_endmarker(self):
|
||||
channel = self.gw.remote_exec("""
|
||||
@@ -210,13 +210,13 @@ class TestPickleChannelFunctional:
|
||||
channel = PickleChannel(channel)
|
||||
queue = Queue()
|
||||
channel.setcallback(queue.put, endmarker=-1)
|
||||
|
||||
|
||||
a_received = queue.get(timeout=TESTTIMEOUT)
|
||||
assert isinstance(a_received, A)
|
||||
assert a_received.hello == 10
|
||||
channel.send(a_received)
|
||||
remote_a2_is_a1 = queue.get(timeout=TESTTIMEOUT)
|
||||
assert remote_a2_is_a1
|
||||
assert remote_a2_is_a1
|
||||
endmarker = queue.get(timeout=TESTTIMEOUT)
|
||||
assert endmarker == -1
|
||||
|
||||
@@ -235,7 +235,7 @@ class TestPickleChannelFunctional:
|
||||
channel._ipickle._unpicklememo.clear()
|
||||
channel.setcallback(queue.put, endmarker=-1)
|
||||
next = queue.get(timeout=TESTTIMEOUT)
|
||||
assert next == -1
|
||||
assert next == -1
|
||||
error = channel._getremoteerror()
|
||||
assert isinstance(error, UnpickleError)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from xdist.nodemanage import NodeManager
|
||||
class pytest_funcarg__mysetup:
|
||||
def __init__(self, request):
|
||||
basetemp = request.config.mktemp(
|
||||
"mysetup-%s" % request.function.__name__,
|
||||
"mysetup-%s" % request.function.__name__,
|
||||
numbered=True)
|
||||
self.source = basetemp.mkdir("source")
|
||||
self.dest = basetemp.mkdir("dest")
|
||||
@@ -26,7 +26,7 @@ class TestNodeManager:
|
||||
assert p.join("dir1", "file1").check()
|
||||
|
||||
def test_popen_rsync_subdir(self, testdir, mysetup):
|
||||
source, dest = mysetup.source, mysetup.dest
|
||||
source, dest = mysetup.source, mysetup.dest
|
||||
dir1 = mysetup.source.mkdir("dir1")
|
||||
dir2 = dir1.mkdir("dir2")
|
||||
dir2.ensure("hello")
|
||||
@@ -35,10 +35,10 @@ class TestNodeManager:
|
||||
nodemanager = NodeManager(testdir.parseconfig(
|
||||
"--tx", "popen//chdir=%s" % dest,
|
||||
"--rsyncdir", rsyncroot,
|
||||
source,
|
||||
source,
|
||||
))
|
||||
assert nodemanager.config.topdir == source
|
||||
nodemanager.rsync_roots()
|
||||
nodemanager.rsync_roots()
|
||||
if rsyncroot == source:
|
||||
dest = dest.join("source")
|
||||
assert dest.join("dir1").check()
|
||||
@@ -105,7 +105,7 @@ class TestNodeManager:
|
||||
nodemanager.setup_nodes(putevent=[].append)
|
||||
for spec in nodemanager.gwmanager.specs:
|
||||
l = reprec.getcalls("pytest_trace")
|
||||
assert l
|
||||
assert l
|
||||
nodemanager.teardown_nodes()
|
||||
|
||||
def test_ssh_setup_nodes(self, specssh, testdir):
|
||||
@@ -113,8 +113,8 @@ class TestNodeManager:
|
||||
def test_one():
|
||||
pass
|
||||
""")
|
||||
reprec = testdir.inline_run("-d", "--rsyncdir=%s" % testdir.tmpdir,
|
||||
reprec = testdir.inline_run("-d", "--rsyncdir=%s" % testdir.tmpdir,
|
||||
"--tx", specssh, testdir.tmpdir)
|
||||
rep, = reprec.getreports("pytest_runtest_logreport")
|
||||
assert rep.passed
|
||||
assert rep.passed
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import py
|
||||
import pickle
|
||||
|
||||
def setglobals(request):
|
||||
oldconfig = py.test.config
|
||||
oldconfig = py.test.config
|
||||
print("setting py.test.config to None")
|
||||
py.test.config = None
|
||||
def resetglobals():
|
||||
@@ -73,10 +73,10 @@ def test_config__setstate__wired_correctly_in_childprocess(testdir):
|
||||
from xdist.mypickle import PickleChannel
|
||||
channel = PickleChannel(channel)
|
||||
config = channel.receive()
|
||||
assert py.test.config == config
|
||||
assert py.test.config == config
|
||||
""")
|
||||
channel = PickleChannel(channel)
|
||||
config = testdir.parseconfig()
|
||||
channel.send(config)
|
||||
channel.waitclose() # this will potentially raise
|
||||
channel.waitclose() # this will potentially raise
|
||||
gw.exit()
|
||||
|
||||
@@ -27,14 +27,14 @@ class TestDistOptions:
|
||||
xspecs = nodemanager._getxspecs()
|
||||
assert len(xspecs) == 2
|
||||
print(xspecs)
|
||||
assert xspecs[0].popen
|
||||
assert xspecs[0].popen
|
||||
assert xspecs[1].ssh == "xyz"
|
||||
|
||||
def test_xspecs_multiplied(self, testdir):
|
||||
config = testdir.parseconfigure("--tx=3*popen",)
|
||||
xspecs = NodeManager(config)._getxspecs()
|
||||
assert len(xspecs) == 3
|
||||
assert xspecs[1].popen
|
||||
assert xspecs[1].popen
|
||||
|
||||
def test_getrsyncdirs(self, testdir):
|
||||
config = testdir.parseconfigure('--rsyncdir=' + str(testdir.tmpdir))
|
||||
@@ -48,14 +48,14 @@ class TestDistOptions:
|
||||
for bn in 'x y z'.split():
|
||||
p.mkdir(bn)
|
||||
testdir.makeconftest("""
|
||||
rsyncdirs= 'x',
|
||||
rsyncdirs= 'x',
|
||||
""")
|
||||
config = testdir.parseconfigure(
|
||||
testdir.tmpdir, '--rsyncdir=y', '--rsyncdir=z')
|
||||
nm = NodeManager(config, specs=[execnet.XSpec("popen")])
|
||||
roots = nm._getrsyncdirs()
|
||||
assert len(roots) == 3 + 2 # pylib + xdist
|
||||
assert py.path.local('y') in roots
|
||||
assert py.path.local('z') in roots
|
||||
assert testdir.tmpdir.join('x') in roots
|
||||
assert py.path.local('y') in roots
|
||||
assert py.path.local('z') in roots
|
||||
assert testdir.tmpdir.join('x') in roots
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import py
|
||||
py.test.importorskip("execnet")
|
||||
from xdist.remote import LooponfailingSession, LoopState, RemoteControl
|
||||
from xdist.remote import LooponfailingSession, LoopState, RemoteControl
|
||||
|
||||
class TestRemoteControl:
|
||||
def test_nofailures(self, testdir):
|
||||
@@ -15,7 +15,7 @@ class TestRemoteControl:
|
||||
control = RemoteControl(item.config)
|
||||
control.setup()
|
||||
failures = control.runsession()
|
||||
assert failures
|
||||
assert failures
|
||||
control.setup()
|
||||
item.fspath.write("def test_func(): assert 1\n")
|
||||
pyc = item.fspath.new(ext=".pyc")
|
||||
@@ -26,13 +26,13 @@ class TestRemoteControl:
|
||||
|
||||
def test_failure_change(self, testdir):
|
||||
modcol = testdir.getitem("""
|
||||
def test_func():
|
||||
def test_func():
|
||||
assert 0
|
||||
""")
|
||||
control = RemoteControl(modcol.config)
|
||||
control.setup()
|
||||
failures = control.runsession()
|
||||
assert failures
|
||||
assert failures
|
||||
control.setup()
|
||||
modcol.fspath.write(py.code.Source("""
|
||||
def test_func():
|
||||
@@ -63,7 +63,7 @@ class TestLooponFailing:
|
||||
loopstate = LoopState()
|
||||
session.loop_once(loopstate)
|
||||
assert len(loopstate.colitems) == 1
|
||||
|
||||
|
||||
modcol.fspath.write(py.code.Source("""
|
||||
def test_one():
|
||||
x = 15
|
||||
@@ -73,7 +73,7 @@ class TestLooponFailing:
|
||||
"""))
|
||||
assert session.statrecorder.check()
|
||||
session.loop_once(loopstate)
|
||||
assert not loopstate.colitems
|
||||
assert not loopstate.colitems
|
||||
|
||||
def test_looponfail_from_one_to_two_tests(self, testdir):
|
||||
modcol = testdir.getmodulecol("""
|
||||
@@ -114,7 +114,7 @@ class TestLooponFailing:
|
||||
|
||||
modcol.fspath.write(py.code.Source("""
|
||||
def test_xxx(): # renamed test
|
||||
assert 0
|
||||
assert 0
|
||||
def test_two():
|
||||
assert 1 # pass now
|
||||
"""))
|
||||
|
||||
@@ -23,7 +23,7 @@ class EventQueue:
|
||||
py.builtin.print_("seen events", events)
|
||||
raise IOError("did not see %r events" % (eventname))
|
||||
else:
|
||||
name, args, kwargs = eventcall
|
||||
name, args, kwargs = eventcall
|
||||
assert isinstance(name, str)
|
||||
if name == eventname:
|
||||
if args:
|
||||
@@ -55,7 +55,7 @@ class MySetup:
|
||||
self.nodemanager = None
|
||||
self.node = TXNode(self.nodemanager, self.gateway, self.config, putevent=self.queue.put)
|
||||
assert not self.node.channel.isclosed()
|
||||
return self.node
|
||||
return self.node
|
||||
|
||||
def xfinalize(self):
|
||||
if hasattr(self, 'node'):
|
||||
@@ -78,9 +78,9 @@ def test_node_hash_equality(mysetup):
|
||||
class TestMasterSlaveConnection:
|
||||
def test_crash_invalid_item(self, mysetup):
|
||||
node = mysetup.makenode()
|
||||
node.send(123) # invalid item
|
||||
node.send(123) # invalid item
|
||||
kwargs = mysetup.geteventargs("pytest_testnodedown")
|
||||
assert kwargs['node'] is node
|
||||
assert kwargs['node'] is node
|
||||
#assert isinstance(kwargs['error'], execnet.RemoteError)
|
||||
|
||||
def test_crash_killed(self, testdir, mysetup):
|
||||
@@ -92,19 +92,19 @@ class TestMasterSlaveConnection:
|
||||
os.kill(os.getpid(), 9)
|
||||
""")
|
||||
node = mysetup.makenode(item.config)
|
||||
node.send(item)
|
||||
node.send(item)
|
||||
kwargs = mysetup.geteventargs("pytest_testnodedown")
|
||||
assert kwargs['node'] is node
|
||||
assert kwargs['node'] is node
|
||||
assert "Not properly terminated" in str(kwargs['error'])
|
||||
|
||||
def test_node_down(self, mysetup):
|
||||
node = mysetup.makenode()
|
||||
node.shutdown()
|
||||
kwargs = mysetup.geteventargs("pytest_testnodedown")
|
||||
assert kwargs['node'] is node
|
||||
assert kwargs['node'] is node
|
||||
assert not kwargs['error']
|
||||
node.callback(node.ENDMARK)
|
||||
excinfo = py.test.raises(IOError,
|
||||
excinfo = py.test.raises(IOError,
|
||||
"mysetup.geteventargs('testnodedown', timeout=0.01)")
|
||||
|
||||
def test_send_on_closed_channel(self, testdir, mysetup):
|
||||
@@ -120,14 +120,14 @@ class TestMasterSlaveConnection:
|
||||
node = mysetup.makenode(item.config)
|
||||
node.send(item)
|
||||
kwargs = mysetup.geteventargs("pytest_runtest_logreport")
|
||||
rep = kwargs['report']
|
||||
assert rep.passed
|
||||
rep = kwargs['report']
|
||||
assert rep.passed
|
||||
py.builtin.print_(rep)
|
||||
assert rep.item == item
|
||||
|
||||
def test_send_some(self, testdir, mysetup):
|
||||
items = testdir.getitems("""
|
||||
def test_pass():
|
||||
def test_pass():
|
||||
pass
|
||||
def test_fail():
|
||||
assert 0
|
||||
@@ -141,12 +141,12 @@ class TestMasterSlaveConnection:
|
||||
for outcome in "passed failed skipped".split():
|
||||
kwargs = mysetup.geteventargs("pytest_runtest_logreport")
|
||||
report = kwargs['report']
|
||||
assert getattr(report, outcome)
|
||||
assert getattr(report, outcome)
|
||||
|
||||
node.sendlist(items)
|
||||
for outcome in "passed failed skipped".split():
|
||||
rep = mysetup.geteventargs("pytest_runtest_logreport")['report']
|
||||
assert getattr(rep, outcome)
|
||||
assert getattr(rep, outcome)
|
||||
|
||||
def test_send_one_with_env(self, testdir, mysetup, monkeypatch):
|
||||
if execnet.XSpec("popen").env is None:
|
||||
|
||||
@@ -15,7 +15,7 @@ def test_filechange(tmpdir):
|
||||
tmp.ensure("new.py")
|
||||
changed = sd.check()
|
||||
assert changed
|
||||
|
||||
|
||||
tmp.join("new.py").remove()
|
||||
changed = sd.check()
|
||||
assert changed
|
||||
@@ -44,12 +44,12 @@ def test_pycremoval(tmpdir):
|
||||
pycfile = hello + "c"
|
||||
pycfile.ensure()
|
||||
changed = sd.check()
|
||||
assert not changed
|
||||
assert not changed
|
||||
|
||||
hello.write("world")
|
||||
changed = sd.check()
|
||||
assert not pycfile.check()
|
||||
|
||||
|
||||
|
||||
def test_waitonchange(tmpdir, monkeypatch):
|
||||
tmp = tmpdir
|
||||
|
||||
Reference in New Issue
Block a user