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