adapt to new pytest changes, use new addini/getini methods for rsyncdirs / rsyncignore options

This commit is contained in:
holger krekel
2010-11-01 00:27:43 +01:00
parent f1a77e80e8
commit 4cd76363f6
7 changed files with 38 additions and 28 deletions

View File

@@ -168,12 +168,12 @@ class DSession:
self.terminal = None
def report_line(self, line):
if self.terminal:
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
if not self.config.getvalue("verbose"):
if self.config.option.verbose > 0:
self.report_line("instantiating gateways (use -v for details): %s" %
",".join(self.config.option.tx))
self.nodemanager = NodeManager(self.config)
@@ -183,11 +183,11 @@ class DSession:
""" teardown any resources after a test run. """
self.nodemanager.teardown_nodes()
def pytest_perform_collection(self, __multicall__):
def pytest_collection(self, __multicall__):
# prohibit collection of test items in master process
__multicall__.methods[:] = []
def pytest_runtest_mainloop(self):
def pytest_runtestloop(self):
numnodes = len(self.nodemanager.gwmanager.specs)
dist = self.config.getvalue("dist")
if dist == "load":
@@ -316,13 +316,13 @@ class TerminalDistReporter:
def pytest_gwmanage_newgateway(self, gateway):
rinfo = gateway._rinfo()
if self.config.getvalue("verbose"):
if self.config.option.verbose >= 0:
version = "%s.%s.%s" %rinfo.version_info[:3]
self.write_line("[%s] %s Python %s cwd: %s" % (
gateway.id, rinfo.platform, version, rinfo.cwd))
def pytest_testnodeready(self, node):
if self.config.getvalue("verbose"):
if self.config.option.verbose >= 0:
d = node.slaveinfo
infoline = "[%s] Python %s" %(
d['id'],

View File

@@ -145,7 +145,7 @@ class SlaveFailSession:
if self.config.option.debug:
print(" ".join(map(str, args)))
def pytest_perform_collection(self, session):
def pytest_collection(self, session):
self.session = session
self.collection = session.collection
self.topdir, self.trails = self.current_command

View File

@@ -126,17 +126,18 @@ put options values in a ``conftest.py`` file like this::
Any commandline ``--tx`` specifictions will add to the list of
available execution environments.
Specifying "rsync" dirs in a conftest.py
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Specifying "rsync" dirs in a setup.cfg|tox.ini
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
In your ``mypkg/conftest.py`` you may specify directories to synchronise
or to exclude::
In a ``tox.ini`` or ``setup.cfg`` file in your root project directory
you may specify directories to include or to exclude in synchronisation::
rsyncdirs = ['.', '../plugins']
rsyncignore = ['_cache']
[pytest]
rsyncdirs = . mypkg helperpkg
rsyncignore = .hg
These directory specifications are relative to the directory
where the ``conftest.py`` is found.
where the configuration file was found.
"""
@@ -173,6 +174,11 @@ def pytest_addoption(parser):
group.addoption('--rsyncdir', action="append", default=[], metavar="dir1",
help="add directory for rsyncing to remote tx nodes.")
parser.addini('rsyncdirs', 'list of (relative) paths to be rsynced for'
' remote distributed testing.', type="pathlist")
parser.addini('rsyncignore', 'list of (relative) paths to be ignored '
'for rsyncing.', type="pathlist")
# -------------------------------------------------------------------------
# distributed testing hooks
# -------------------------------------------------------------------------

View File

@@ -42,10 +42,10 @@ class SlaveInteractor:
self.sendevent("slavefinished", slaveoutput=self.config.slaveoutput)
return res
def pytest_perform_collection(self, session):
def pytest_collection(self, session):
self.sendevent("collectionstart")
def pytest_runtest_mainloop(self, session):
def pytest_runtestloop(self, session):
self.log("entering main loop")
while 1:
name, kwargs = self.channel.receive()
@@ -62,7 +62,7 @@ class SlaveInteractor:
break
return True
def pytest_log_finishcollection(self, collection):
def pytest_collection_finish(self, collection):
ids = [collection.getid(item) for item in collection.items]
self.sendevent("collectionfinish",
topdir=str(collection.topdir),

View File

@@ -1,4 +1,4 @@
import py
import py, pytest
import sys, os
import execnet
import xdist.remote
@@ -18,7 +18,7 @@ class NodeManager(object):
self.config.hook.pytest_trace(category="nodemanage", msg=msg)
def config_getignores(self):
return self.config.getconftest_pathlist("rsyncignore")
return self.config.getini("rsyncignore")
def rsync_roots(self):
""" make sure that all remote gateways
@@ -78,7 +78,7 @@ class NodeManager(object):
else:
xspeclist.extend([xspec[i+1:]] * num)
if not xspeclist:
raise config.Error(
raise pytest.UsageError(
"MISSING test execution (tx) nodes: please specify --tx")
return [execnet.XSpec(x) for x in xspeclist]
@@ -86,14 +86,14 @@ class NodeManager(object):
config = self.config
candidates = [py._pydir]
candidates += config.option.rsyncdir
conftestroots = config.getconftest_pathlist("rsyncdirs")
conftestroots = config.getini("rsyncdirs")
if conftestroots:
candidates.extend(conftestroots)
roots = []
for root in candidates:
root = py.path.local(root).realpath()
if not root.check():
raise config.Error("rsyncdir doesn't exist: %r" %(root,))
raise pytest.UsageError("rsyncdir doesn't exist: %r" %(root,))
if root not in roots:
roots.append(root)
return roots