#234 Fix flake 8 and fix comments
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import py
|
||||
import pytest
|
||||
from xdist.workermanage import workerController, unserialize_report
|
||||
from xdist.workermanage import WorkerController, unserialize_report
|
||||
from xdist.remote import serialize_report
|
||||
import execnet
|
||||
import marshal
|
||||
@@ -26,7 +26,7 @@ class EventCall:
|
||||
return "<EventCall %s(**%s)>" % (self.name, self.kwargs)
|
||||
|
||||
|
||||
class workerSetup:
|
||||
class WorkerSetup:
|
||||
use_callback = False
|
||||
|
||||
def __init__(self, request, testdir):
|
||||
@@ -44,7 +44,7 @@ class workerSetup:
|
||||
class DummyMananger:
|
||||
specs = [0, 1]
|
||||
|
||||
self.slp = workerController(DummyMananger, self.gateway, config,
|
||||
self.slp = WorkerController(DummyMananger, self.gateway, config,
|
||||
putevent)
|
||||
self.request.addfinalizer(self.slp.ensure_teardown)
|
||||
self.slp.setup()
|
||||
@@ -66,7 +66,7 @@ class workerSetup:
|
||||
|
||||
@pytest.fixture
|
||||
def worker(request, testdir):
|
||||
return workerSetup(request, testdir)
|
||||
return WorkerSetup(request, testdir)
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason='#59')
|
||||
@@ -243,7 +243,7 @@ class TestReportSerialization:
|
||||
assert newrep.longrepr == str(rep.longrepr)
|
||||
|
||||
|
||||
class TestworkerInteractor:
|
||||
class TestWorkerInteractor:
|
||||
def test_basic_collect_and_runtests(self, worker):
|
||||
worker.testdir.makepyfile("""
|
||||
def test_func():
|
||||
|
||||
@@ -40,7 +40,7 @@ def workercontroller(monkeypatch):
|
||||
def setup(self):
|
||||
pass
|
||||
|
||||
monkeypatch.setattr(workermanage, 'workerController', MockController)
|
||||
monkeypatch.setattr(workermanage, 'WorkerController', MockController)
|
||||
return MockController
|
||||
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ class DSession:
|
||||
self._active_nodes.remove(node)
|
||||
|
||||
def worker_errordown(self, node, error):
|
||||
"""Emitted by the workerController when a node dies."""
|
||||
"""Emitted by the WorkerController when a node dies."""
|
||||
self.config.hook.pytest_testnodedown(node=node, error=error)
|
||||
try:
|
||||
crashitem = self.sched.remove_node(node)
|
||||
|
||||
@@ -153,11 +153,11 @@ def init_worker_session(channel, args, option_dict):
|
||||
from _pytest.config import Config
|
||||
config = Config.fromdictargs(option_dict, list(args))
|
||||
config.args = args
|
||||
from xdist.looponfail import workerFailSession
|
||||
workerFailSession(config, channel).main()
|
||||
from xdist.looponfail import WorkerFailSession
|
||||
WorkerFailSession(config, channel).main()
|
||||
|
||||
|
||||
class workerFailSession:
|
||||
class WorkerFailSession:
|
||||
def __init__(self, config, channel):
|
||||
self.config = config
|
||||
self.channel = channel
|
||||
|
||||
@@ -30,7 +30,8 @@ def pytest_addoption(parser):
|
||||
dest="maxworkerrestart",
|
||||
help="maximum number of workers that can be restarted "
|
||||
"when crashed (set to zero to disable this feature)\n"
|
||||
"'--max-slave-restart' option is deprecated and will be removed in a future release")
|
||||
"'--max-slave-restart' option is deprecated and will be removed in "
|
||||
"a future release")
|
||||
group.addoption(
|
||||
'--dist', metavar="distmode",
|
||||
action="store", choices=['each', 'load', 'loadscope', 'loadfile', 'no'],
|
||||
|
||||
@@ -14,7 +14,7 @@ import _pytest.hookspec
|
||||
import pytest
|
||||
|
||||
|
||||
class workerInteractor:
|
||||
class WorkerInteractor:
|
||||
def __init__(self, config, channel):
|
||||
self.config = config
|
||||
self.workerid = config.workerinput.get('workerid', "?")
|
||||
@@ -198,5 +198,8 @@ if __name__ == '__channelexec__':
|
||||
config = remote_initconfig(option_dict, args)
|
||||
config.workerinput = workerinput
|
||||
config.workeroutput = {}
|
||||
interactor = workerInteractor(config, channel)
|
||||
# TODO: deprecated name, backward compatibility only. Remove it in future
|
||||
config.slaveinput = config.workerinput
|
||||
config.slaveoutput = config.workeroutput
|
||||
interactor = WorkerInteractor(config, channel)
|
||||
config.hook.pytest_cmdline_main(config=config)
|
||||
|
||||
@@ -68,7 +68,7 @@ class NodeManager(object):
|
||||
gw = self.group.makegateway(spec)
|
||||
self.config.hook.pytest_xdist_newgateway(gateway=gw)
|
||||
self.rsync_roots(gw)
|
||||
node = workerController(self, gw, self.config, putevent)
|
||||
node = WorkerController(self, gw, self.config, putevent)
|
||||
gw.node = node # keep the node alive
|
||||
node.setup()
|
||||
self.trace("started node %r" % node)
|
||||
@@ -201,7 +201,7 @@ def make_reltoroot(roots, args):
|
||||
return result
|
||||
|
||||
|
||||
class workerController(object):
|
||||
class WorkerController(object):
|
||||
ENDMARK = -1
|
||||
|
||||
def __init__(self, nodemanager, gateway, config, putevent):
|
||||
@@ -211,6 +211,8 @@ class workerController(object):
|
||||
self.config = config
|
||||
self.workerinput = {'workerid': gateway.id,
|
||||
'workercount': len(nodemanager.specs)}
|
||||
# TODO: deprecated name, backward compatibility only. Remove it in future
|
||||
self.slaveinput = self.workerinput
|
||||
self._down = False
|
||||
self._shutdown_sent = False
|
||||
self.log = py.log.Producer("workerctl-%s" % gateway.id)
|
||||
|
||||
Reference in New Issue
Block a user