[py-svn] pytest-xdist commit ba07fdbea9d9: adapt to new pytest changes, use new addini/getini methods for rsyncdirs / rsyncignore options

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Nov 1 00:26:48 CET 2010


# HG changeset patch -- Bitbucket.org
# Project pytest-xdist
# URL http://bitbucket.org/hpk42/pytest-xdist/overview
# User holger krekel <holger at merlinux.eu>
# Date 1288567663 -3600
# Node ID ba07fdbea9d953cf4f55db67e2e242527948019f
# Parent  407d2815cad2f31af54070ddbc9367c8cba31ee6
adapt to new pytest changes, use new addini/getini methods for rsyncdirs / rsyncignore options

--- a/xdist/plugin.py
+++ b/xdist/plugin.py
@@ -126,17 +126,18 @@ put options values in a ``conftest.py`` 
 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
 # -------------------------------------------------------------------------

--- a/xdist/dsession.py
+++ b/xdist/dsession.py
@@ -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'],

--- a/testing/test_slavemanage.py
+++ b/testing/test_slavemanage.py
@@ -173,8 +173,9 @@ class TestNodeManager:
         source.ensure("dir1", "somefile", dir=1)
         dir2.ensure("hello")
         source.ensure("bogusdir", "file")
-        source.join("conftest.py").write(py.code.Source("""
-            rsyncdirs = ['dir1/dir2']
+        source.join("tox.ini").write(py.std.textwrap.dedent("""
+            [pytest]
+            rsyncdirs=dir1/dir2
         """))
         config = testdir.reparseconfig([source])
         nodemanager = NodeManager(config, ["popen//chdir=%s" % dest])
@@ -189,9 +190,10 @@ class TestNodeManager:
         dir5 = source.ensure("dir5", "dir6", "bogus")
         dirf = source.ensure("dir5", "file")
         dir2.ensure("hello")
-        source.join("conftest.py").write(py.code.Source("""
-            rsyncdirs = ['dir1', 'dir5']
-            rsyncignore = ['dir1/dir2', 'dir5/dir6']
+        source.join("tox.ini").write(py.std.textwrap.dedent("""
+            [pytest]
+            rsyncdirs = dir1 dir5
+            rsyncignore = dir1/dir2 dir5/dir6
         """))
         config = testdir.reparseconfig([source])
         nodemanager = NodeManager(config, ["popen//chdir=%s" % dest])

--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,7 +1,9 @@
 1.5a1
 -------------------------
 
-
+- adapt to pytest-2.0 changes, rsyncdirs and rsyncignore can now
+  only be specified in [pytest] sections of ini files, see "py.test -h"
+  for details.
 - major internal refactoring to match the py-1.4 event refactoring
   - perform test collection always at slave side instead of at the master
   - make python2/python3 bridging work, remove usage of pickling

--- a/xdist/slavemanage.py
+++ b/xdist/slavemanage.py
@@ -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

--- a/xdist/looponfail.py
+++ b/xdist/looponfail.py
@@ -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

--- a/xdist/remote.py
+++ b/xdist/remote.py
@@ -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),



More information about the pytest-commit mailing list