fixes for new internal pytest tmpdir handling
This commit is contained in:
@@ -72,10 +72,10 @@ class TestDistribution:
|
||||
|
||||
def test_basetemp_in_subprocesses(self, testdir):
|
||||
p1 = testdir.makepyfile("""
|
||||
def test_send(pytestconfig):
|
||||
bt = pytestconfig.getbasetemp()
|
||||
assert bt.basename.startswith("popen-")
|
||||
""")
|
||||
def test_send(tmpdir):
|
||||
import py
|
||||
assert tmpdir.relto(py.path.local(%r)), tmpdir
|
||||
""" % str(testdir.tmpdir))
|
||||
result = testdir.runpytest(p1, "-n1")
|
||||
assert result.ret == 0
|
||||
result.stdout.fnmatch_lines([
|
||||
|
||||
@@ -34,7 +34,7 @@ class SlaveSetup:
|
||||
self.testdir.chdir()
|
||||
#import os ; os.environ['EXECNET_DEBUG'] = "2"
|
||||
self.gateway = execnet.makegateway()
|
||||
self.config = config = self.testdir.parseconfig()
|
||||
self.config = config = self.testdir.parseconfigure()
|
||||
putevent = self.use_callback and self.events.put or None
|
||||
self.slp = SlaveController(None, self.gateway, config, putevent)
|
||||
self.request.addfinalizer(self.slp.ensure_teardown)
|
||||
|
||||
@@ -17,11 +17,9 @@ def pytest_funcarg__hook(request):
|
||||
|
||||
class pytest_funcarg__mysetup:
|
||||
def __init__(self, request):
|
||||
basetemp = request.config.mktemp(
|
||||
"mysetup-%s" % request.function.__name__,
|
||||
numbered=True)
|
||||
self.source = basetemp.mkdir("source")
|
||||
self.dest = basetemp.mkdir("dest")
|
||||
temp = request.getfuncargvalue("tmpdir")
|
||||
self.source = temp.mkdir("source")
|
||||
self.dest = temp.mkdir("dest")
|
||||
request.getfuncargvalue("_pytest")
|
||||
|
||||
class TestGatewayManagerPopen:
|
||||
@@ -220,7 +218,7 @@ class TestNodeManager:
|
||||
specs = ["popen"] * 2
|
||||
source.join("conftest.py").write("rsyncdirs = ['a']")
|
||||
source.ensure('a', dir=1)
|
||||
config = testdir.reparseconfig([source, '--debug'])
|
||||
config = testdir.parseconfigure(source, '--debug')
|
||||
assert config.option.debug
|
||||
nodemanager = NodeManager(config, specs)
|
||||
reprec = testdir.getreportrecorder(config).hookrecorder
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import py
|
||||
import pytest, py
|
||||
import sys
|
||||
from xdist.slavemanage import NodeManager
|
||||
queue = py.builtin._tryimport('queue', 'Queue')
|
||||
@@ -171,8 +171,8 @@ class DSession:
|
||||
if self.terminal and self.config.option.verbose >= 0:
|
||||
self.terminal.write_line(line)
|
||||
|
||||
def pytest_sessionstart(self, session, __multicall__):
|
||||
#print "remaining multicall methods", __multicall__.methods
|
||||
@pytest.mark.trylast
|
||||
def pytest_sessionstart(self, session):
|
||||
if self.config.option.verbose > 0:
|
||||
self.report_line("instantiating gateways (use -v for details): %s" %
|
||||
",".join(self.config.option.tx))
|
||||
@@ -181,11 +181,13 @@ class DSession:
|
||||
|
||||
def pytest_sessionfinish(self, session):
|
||||
""" teardown any resources after a test run. """
|
||||
self.nodemanager.teardown_nodes()
|
||||
nm = getattr(self, 'nodemanager', None) # if not fully initialized
|
||||
if nm is not None:
|
||||
nm.teardown_nodes()
|
||||
|
||||
def pytest_collection(self, __multicall__):
|
||||
def pytest_collection(self):
|
||||
# prohibit collection of test items in master process
|
||||
__multicall__.methods[:] = []
|
||||
return True
|
||||
|
||||
def pytest_runtestloop(self):
|
||||
numnodes = len(self.nodemanager.gwmanager.specs)
|
||||
@@ -326,7 +328,7 @@ class TerminalDistReporter:
|
||||
gateway.id, rinfo.platform, version, rinfo.cwd))
|
||||
|
||||
def pytest_testnodeready(self, node):
|
||||
if self.config.option.verbose >= 0:
|
||||
if self.config.option.verbose > 0:
|
||||
d = node.slaveinfo
|
||||
infoline = "[%s] Python %s" %(
|
||||
d['id'],
|
||||
|
||||
@@ -14,9 +14,7 @@ class NodeManager(object):
|
||||
self.specs = self.gwmanager.specs
|
||||
self.roots = self._getrsyncdirs()
|
||||
self._nodesready = py.std.threading.Event()
|
||||
|
||||
def trace(self, msg):
|
||||
self.config.hook.pytest_trace(category="nodemanage", msg=msg)
|
||||
self.trace = self.config.trace.get("nodemanager")
|
||||
|
||||
def config_getignores(self):
|
||||
return self.config.getini("rsyncignore")
|
||||
@@ -89,9 +87,9 @@ class NodeManager(object):
|
||||
config = self.config
|
||||
candidates = [py._pydir,pytestpath,pytestdir]
|
||||
candidates += config.option.rsyncdir
|
||||
conftestroots = config.getini("rsyncdirs")
|
||||
if conftestroots:
|
||||
candidates.extend(conftestroots)
|
||||
rsyncroots = config.getini("rsyncdirs")
|
||||
if rsyncroots:
|
||||
candidates.extend(rsyncroots)
|
||||
roots = []
|
||||
for root in candidates:
|
||||
root = py.path.local(root).realpath()
|
||||
@@ -101,7 +99,6 @@ class NodeManager(object):
|
||||
roots.append(root)
|
||||
return roots
|
||||
|
||||
|
||||
class GatewayManager:
|
||||
"""
|
||||
instantiating, managing and rsyncing to test hosts
|
||||
@@ -239,7 +236,8 @@ class SlaveController(object):
|
||||
option_dict = vars(self.config.option)
|
||||
if spec.popen:
|
||||
name = "popen-%s" % self.gateway.id
|
||||
option_dict['basetemp'] = str(self.config.getbasetemp().join(name))
|
||||
basetemp = self.config._tmpdirhandler.getbasetemp()
|
||||
option_dict['basetemp'] = str(basetemp.join(name))
|
||||
self.config.hook.pytest_configure_node(node=self)
|
||||
self.channel = self.gateway.remote_exec(xdist.remote)
|
||||
self.channel.send((self.slaveinput, args, option_dict))
|
||||
|
||||
Reference in New Issue
Block a user