From 05ab96feaf85a0979e70e13a24c3fe07defae03c Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 4 Jul 2015 15:40:55 -0300 Subject: [PATCH] update collected tests from slaves into main pytest session object Upstream changes in https://github.com/pytest-dev/pytest/pull/817 make pytest-dist always return EXIT_NOTESTSCOLLECTED because the master node doesn't collect any tests. This patch updates the pytest session about the collected items on the slaves. --- xdist/dsession.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xdist/dsession.py b/xdist/dsession.py index 1370a8c..40c3596 100644 --- a/xdist/dsession.py +++ b/xdist/dsession.py @@ -455,6 +455,7 @@ class DSession: self.countfailures = 0 self.maxfail = config.getvalue("maxfail") self.queue = queue.Queue() + self._session = None self._failed_collection_errors = {} self._active_nodes = set() try: @@ -488,12 +489,14 @@ class DSession: self.nodemanager = NodeManager(self.config) nodes = self.nodemanager.setup_nodes(putevent=self.queue.put) self._active_nodes.update(nodes) + self._session = session def pytest_sessionfinish(self, session): """Shutdown all nodes.""" nm = getattr(self, 'nodemanager', None) # if not fully initialized if nm is not None: nm.teardown_nodes() + self._session = None def pytest_collection(self): # prohibit collection of test items in master process @@ -595,6 +598,9 @@ class DSession: """ if self.shuttingdown: return + # tell session which items were effectively collected otherwise + # the master node will exit with EXIT_NOTESTSCOLLECTED + self._session._testscollected = len(ids) self.sched.addnode_collection(node, ids) if self.terminal: self.trdist.setstatus(node.gateway.spec, "[%d]" % (len(ids)))