Run pyupgrade --py37-plus
This commit is contained in:
@@ -169,7 +169,7 @@ class DSession:
|
|||||||
"""
|
"""
|
||||||
self.config.hook.pytest_testnodedown(node=node, error=None)
|
self.config.hook.pytest_testnodedown(node=node, error=None)
|
||||||
if node.workeroutput["exitstatus"] == 2: # keyboard-interrupt
|
if node.workeroutput["exitstatus"] == 2: # keyboard-interrupt
|
||||||
self.shouldstop = "{} received keyboard-interrupt".format(node)
|
self.shouldstop = f"{node} received keyboard-interrupt"
|
||||||
self.worker_errordown(node, "keyboard-interrupt")
|
self.worker_errordown(node, "keyboard-interrupt")
|
||||||
return
|
return
|
||||||
if node in self.sched.nodes:
|
if node in self.sched.nodes:
|
||||||
@@ -230,7 +230,7 @@ class DSession:
|
|||||||
@pytest.hookimpl
|
@pytest.hookimpl
|
||||||
def pytest_terminal_summary(self, terminalreporter):
|
def pytest_terminal_summary(self, terminalreporter):
|
||||||
if self.config.option.verbose >= 0 and self._summary_report:
|
if self.config.option.verbose >= 0 and self._summary_report:
|
||||||
terminalreporter.write_sep("=", "xdist: {}".format(self._summary_report))
|
terminalreporter.write_sep("=", f"xdist: {self._summary_report}")
|
||||||
|
|
||||||
def worker_collectionfinish(self, node, ids):
|
def worker_collectionfinish(self, node, ids):
|
||||||
"""worker has finished test collection.
|
"""worker has finished test collection.
|
||||||
@@ -345,7 +345,7 @@ class DSession:
|
|||||||
# XXX count no of failures and retry N times
|
# XXX count no of failures and retry N times
|
||||||
runner = self.config.pluginmanager.getplugin("runner")
|
runner = self.config.pluginmanager.getplugin("runner")
|
||||||
fspath = nodeid.split("::")[0]
|
fspath = nodeid.split("::")[0]
|
||||||
msg = "worker {!r} crashed while running {!r}".format(worker.gateway.id, nodeid)
|
msg = f"worker {worker.gateway.id!r} crashed while running {nodeid!r}"
|
||||||
rep = runner.TestReport(
|
rep = runner.TestReport(
|
||||||
nodeid, (fspath, None, fspath), (), "failed", msg, "???"
|
nodeid, (fspath, None, fspath), (), "failed", msg, "???"
|
||||||
)
|
)
|
||||||
@@ -381,9 +381,7 @@ class TerminalDistReporter:
|
|||||||
|
|
||||||
def getstatus(self):
|
def getstatus(self):
|
||||||
if self.config.option.verbose >= 0:
|
if self.config.option.verbose >= 0:
|
||||||
parts = [
|
parts = [f"{spec.id} {self._status[spec.id]}" for spec in self._specs]
|
||||||
"{} {}".format(spec.id, self._status[spec.id]) for spec in self._specs
|
|
||||||
]
|
|
||||||
return " / ".join(parts)
|
return " / ".join(parts)
|
||||||
else:
|
else:
|
||||||
return "bringing up nodes..."
|
return "bringing up nodes..."
|
||||||
@@ -431,7 +429,7 @@ class TerminalDistReporter:
|
|||||||
def pytest_testnodedown(self, node, error):
|
def pytest_testnodedown(self, node, error):
|
||||||
if not error:
|
if not error:
|
||||||
return
|
return
|
||||||
self.write_line("[{}] node down: {}".format(node.gateway.id, error))
|
self.write_line(f"[{node.gateway.id}] node down: {error}")
|
||||||
|
|
||||||
|
|
||||||
def get_default_max_worker_restart(config):
|
def get_default_max_worker_restart(config):
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ def repr_pytest_looponfailinfo(failreports, rootdirs):
|
|||||||
tr.line(report, red=True)
|
tr.line(report, red=True)
|
||||||
tr.sep("#", "waiting for changes", bold=True)
|
tr.sep("#", "waiting for changes", bold=True)
|
||||||
for rootdir in rootdirs:
|
for rootdir in rootdirs:
|
||||||
tr.line("### Watching: {}".format(rootdir), bold=True)
|
tr.line(f"### Watching: {rootdir}", bold=True)
|
||||||
|
|
||||||
|
|
||||||
def init_worker_session(channel, args, option_dict):
|
def init_worker_session(channel, args, option_dict):
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class WorkerInteractor:
|
|||||||
if len(mark.args) > 0
|
if len(mark.args) > 0
|
||||||
else mark.kwargs.get("name", "default")
|
else mark.kwargs.get("name", "default")
|
||||||
)
|
)
|
||||||
item._nodeid = "{}@{}".format(item.nodeid, gname)
|
item._nodeid = f"{item.nodeid}@{gname}"
|
||||||
|
|
||||||
@pytest.hookimpl
|
@pytest.hookimpl
|
||||||
def pytest_collection_finish(self, session):
|
def pytest_collection_finish(self, session):
|
||||||
|
|||||||
@@ -361,12 +361,12 @@ class LoadScopeScheduling:
|
|||||||
extra_nodes = len(self.nodes) - len(self.workqueue)
|
extra_nodes = len(self.nodes) - len(self.workqueue)
|
||||||
|
|
||||||
if extra_nodes > 0:
|
if extra_nodes > 0:
|
||||||
self.log("Shutting down {} nodes".format(extra_nodes))
|
self.log(f"Shutting down {extra_nodes} nodes")
|
||||||
|
|
||||||
for _ in range(extra_nodes):
|
for _ in range(extra_nodes):
|
||||||
unused_node, assigned = self.assigned_work.popitem(last=True)
|
unused_node, assigned = self.assigned_work.popitem(last=True)
|
||||||
|
|
||||||
self.log("Shutting down unused node {}".format(unused_node))
|
self.log(f"Shutting down unused node {unused_node}")
|
||||||
unused_node.shutdown()
|
unused_node.shutdown()
|
||||||
|
|
||||||
# Assign initial workload
|
# Assign initial workload
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class NodeManager:
|
|||||||
for root in candidates:
|
for root in candidates:
|
||||||
root = Path(root).resolve()
|
root = Path(root).resolve()
|
||||||
if not root.exists():
|
if not root.exists():
|
||||||
raise pytest.UsageError("rsyncdir doesn't exist: {!r}".format(root))
|
raise pytest.UsageError(f"rsyncdir doesn't exist: {root!r}")
|
||||||
if root not in roots:
|
if root not in roots:
|
||||||
roots.append(root)
|
roots.append(root)
|
||||||
return roots
|
return roots
|
||||||
@@ -192,7 +192,7 @@ class HostRSync(execnet.RSync):
|
|||||||
if self._verbose > 0:
|
if self._verbose > 0:
|
||||||
path = os.path.basename(self._sourcedir) + "/" + modified_rel_path
|
path = os.path.basename(self._sourcedir) + "/" + modified_rel_path
|
||||||
remotepath = gateway.spec.chdir
|
remotepath = gateway.spec.chdir
|
||||||
print("{}:{} <= {}".format(gateway.spec, remotepath, path))
|
print(f"{gateway.spec}:{remotepath} <= {path}")
|
||||||
|
|
||||||
|
|
||||||
def make_reltoroot(roots: Sequence[Path], args: List[str]) -> List[str]:
|
def make_reltoroot(roots: Sequence[Path], args: List[str]) -> List[str]:
|
||||||
@@ -219,7 +219,7 @@ def make_reltoroot(roots: Sequence[Path], args: List[str]) -> List[str]:
|
|||||||
parts[0] = root.name + "/" + str(x)
|
parts[0] = root.name + "/" + str(x)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise ValueError("arg {} not relative to an rsync root".format(arg))
|
raise ValueError(f"arg {arg} not relative to an rsync root")
|
||||||
result.append(splitcode.join(parts))
|
result.append(splitcode.join(parts))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ class WorkerController:
|
|||||||
self.log = Producer(f"workerctl-{gateway.id}", enabled=config.option.debug)
|
self.log = Producer(f"workerctl-{gateway.id}", enabled=config.option.debug)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<{} {}>".format(self.__class__.__name__, self.gateway.id)
|
return f"<{self.__class__.__name__} {self.gateway.id}>"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def shutting_down(self):
|
def shutting_down(self):
|
||||||
@@ -310,11 +310,11 @@ class WorkerController:
|
|||||||
|
|
||||||
def sendcommand(self, name, **kwargs):
|
def sendcommand(self, name, **kwargs):
|
||||||
"""send a named parametrized command to the other side."""
|
"""send a named parametrized command to the other side."""
|
||||||
self.log("sending command {}(**{})".format(name, kwargs))
|
self.log(f"sending command {name}(**{kwargs})")
|
||||||
self.channel.send((name, kwargs))
|
self.channel.send((name, kwargs))
|
||||||
|
|
||||||
def notify_inproc(self, eventname, **kwargs):
|
def notify_inproc(self, eventname, **kwargs):
|
||||||
self.log("queuing {}(**{})".format(eventname, kwargs))
|
self.log(f"queuing {eventname}(**{kwargs})")
|
||||||
self.putevent((eventname, kwargs))
|
self.putevent((eventname, kwargs))
|
||||||
|
|
||||||
def process_from_remote(self, eventcall): # noqa too complex
|
def process_from_remote(self, eventcall): # noqa too complex
|
||||||
@@ -336,7 +336,7 @@ class WorkerController:
|
|||||||
return
|
return
|
||||||
eventname, kwargs = eventcall
|
eventname, kwargs = eventcall
|
||||||
if eventname in ("collectionstart",):
|
if eventname in ("collectionstart",):
|
||||||
self.log("ignoring {}({})".format(eventname, kwargs))
|
self.log(f"ignoring {eventname}({kwargs})")
|
||||||
elif eventname == "workerready":
|
elif eventname == "workerready":
|
||||||
self.notify_inproc(eventname, node=self, **kwargs)
|
self.notify_inproc(eventname, node=self, **kwargs)
|
||||||
elif eventname == "internal_error":
|
elif eventname == "internal_error":
|
||||||
@@ -389,7 +389,7 @@ class WorkerController:
|
|||||||
location=kwargs["location"],
|
location=kwargs["location"],
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise ValueError("unknown event: {}".format(eventname))
|
raise ValueError(f"unknown event: {eventname}")
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
# should not land in receiver-thread
|
# should not land in receiver-thread
|
||||||
raise
|
raise
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class EventCall:
|
|||||||
self.name, self.kwargs = eventcall
|
self.name, self.kwargs = eventcall
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "<EventCall {}(**{})>".format(self.name, self.kwargs)
|
return f"<EventCall {self.name}(**{self.kwargs})>"
|
||||||
|
|
||||||
|
|
||||||
class WorkerSetup:
|
class WorkerSetup:
|
||||||
@@ -60,7 +60,7 @@ class WorkerSetup:
|
|||||||
ev = EventCall(data)
|
ev = EventCall(data)
|
||||||
if name is None or ev.name == name:
|
if name is None or ev.name == name:
|
||||||
return ev
|
return ev
|
||||||
print("skipping {}".format(ev))
|
print(f"skipping {ev}")
|
||||||
|
|
||||||
def sendcommand(self, name, **kwargs):
|
def sendcommand(self, name, **kwargs):
|
||||||
self.slp.sendcommand(name, **kwargs)
|
self.slp.sendcommand(name, **kwargs)
|
||||||
|
|||||||
Reference in New Issue
Block a user