From 22ae7ff7af01fc3f23cb069725a64b569b6990dc Mon Sep 17 00:00:00 2001 From: Hugo Date: Sat, 11 Jul 2020 16:09:19 +0300 Subject: [PATCH] Upgrade Python syntax with pyupgrade --py3-plus --- src/xdist/dsession.py | 4 ++-- src/xdist/looponfail.py | 7 +++---- src/xdist/remote.py | 2 +- src/xdist/report.py | 1 - src/xdist/scheduler/each.py | 2 +- src/xdist/scheduler/load.py | 2 +- src/xdist/scheduler/loadfile.py | 2 +- src/xdist/scheduler/loadscope.py | 2 +- src/xdist/workermanage.py | 13 +++++-------- testing/test_dsession.py | 2 +- testing/test_slavemanage.py | 3 +-- 11 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/xdist/dsession.py b/src/xdist/dsession.py index 7a84c8b..8ea245c 100644 --- a/src/xdist/dsession.py +++ b/src/xdist/dsession.py @@ -17,7 +17,7 @@ class Interrupted(KeyboardInterrupt): """ signals an immediate interruption. """ -class DSession(object): +class DSession: """A pytest plugin which runs a distributed test session At the beginning of the test session this creates a NodeManager @@ -333,7 +333,7 @@ class DSession(object): self.config.hook.pytest_runtest_logreport(report=rep) -class TerminalDistReporter(object): +class TerminalDistReporter: def __init__(self, config): self.config = config self.tr = config.pluginmanager.getplugin("terminalreporter") diff --git a/src/xdist/looponfail.py b/src/xdist/looponfail.py index 7f01ad6..19b9313 100644 --- a/src/xdist/looponfail.py +++ b/src/xdist/looponfail.py @@ -6,7 +6,6 @@ processes) otherwise changes to source code can crash the controlling process which should best never happen. """ -from __future__ import print_function import py import pytest import sys @@ -55,7 +54,7 @@ def looponfail_main(config): print() -class RemoteControl(object): +class RemoteControl: def __init__(self, config): self.config = config self.failures = [] @@ -165,7 +164,7 @@ def init_worker_session(channel, args, option_dict): WorkerFailSession(config, channel).main() -class WorkerFailSession(object): +class WorkerFailSession: def __init__(self, config, channel): self.config = config self.channel = channel @@ -220,7 +219,7 @@ class WorkerFailSession(object): self.channel.send((trails, failreports, self.collection_failed)) -class StatRecorder(object): +class StatRecorder: def __init__(self, rootdirlist): self.rootdirlist = rootdirlist self.statcache = {} diff --git a/src/xdist/remote.py b/src/xdist/remote.py index 088ebeb..2df96fa 100644 --- a/src/xdist/remote.py +++ b/src/xdist/remote.py @@ -18,7 +18,7 @@ from execnet.gateway_base import dumps, DumpError from _pytest.config import _prepareconfig, Config -class WorkerInteractor(object): +class WorkerInteractor: def __init__(self, config, channel): self.config = config self.workerid = config.workerinput.get("workerid", "?") diff --git a/src/xdist/report.py b/src/xdist/report.py index 1a132d0..8843b40 100644 --- a/src/xdist/report.py +++ b/src/xdist/report.py @@ -1,4 +1,3 @@ -from __future__ import print_function from difflib import unified_diff diff --git a/src/xdist/scheduler/each.py b/src/xdist/scheduler/each.py index 486d8b0..b2a0442 100644 --- a/src/xdist/scheduler/each.py +++ b/src/xdist/scheduler/each.py @@ -4,7 +4,7 @@ from xdist.workermanage import parse_spec_config from xdist.report import report_collection_diff -class EachScheduling(object): +class EachScheduling: """Implement scheduling of test items on all nodes If a node gets added after the test run is started then it is diff --git a/src/xdist/scheduler/load.py b/src/xdist/scheduler/load.py index 4116984..e378d9a 100644 --- a/src/xdist/scheduler/load.py +++ b/src/xdist/scheduler/load.py @@ -7,7 +7,7 @@ from xdist.workermanage import parse_spec_config from xdist.report import report_collection_diff -class LoadScheduling(object): +class LoadScheduling: """Implement load scheduling across nodes. This distributes the tests collected across all nodes so each test diff --git a/src/xdist/scheduler/loadfile.py b/src/xdist/scheduler/loadfile.py index 52a28b1..867a94e 100644 --- a/src/xdist/scheduler/loadfile.py +++ b/src/xdist/scheduler/loadfile.py @@ -21,7 +21,7 @@ class LoadFileScheduling(LoadScopeScheduling): """ def __init__(self, config, log=None): - super(LoadFileScheduling, self).__init__(config, log) + super().__init__(config, log) if log is None: self.log = Producer("loadfilesched") else: diff --git a/src/xdist/scheduler/loadscope.py b/src/xdist/scheduler/loadscope.py index 6b50a48..31dbe26 100644 --- a/src/xdist/scheduler/loadscope.py +++ b/src/xdist/scheduler/loadscope.py @@ -6,7 +6,7 @@ from xdist.report import report_collection_diff from xdist.workermanage import parse_spec_config -class LoadScopeScheduling(object): +class LoadScopeScheduling: """Implement load scheduling across nodes, but grouping test by scope. This distributes the tests collected across all nodes so each test is run diff --git a/src/xdist/workermanage.py b/src/xdist/workermanage.py index 69b1fbd..ec7f3df 100644 --- a/src/xdist/workermanage.py +++ b/src/xdist/workermanage.py @@ -1,4 +1,3 @@ -from __future__ import print_function import fnmatch import os import re @@ -29,7 +28,7 @@ def parse_spec_config(config): return xspeclist -class NodeManager(object): +class NodeManager: EXIT_TIMEOUT = 10 DEFAULT_IGNORES = [".*", "*.pyc", "*.pyo", "*~"] @@ -167,7 +166,7 @@ class HostRSync(execnet.RSync): self._ignores = [ re.compile(fnmatch.translate(getattr(x, "strpath", x))) for x in ignores ] - super(HostRSync, self).__init__(sourcedir=sourcedir, **kwargs) + super().__init__(sourcedir=sourcedir, **kwargs) def filter(self, path): path = py.path.local(path) @@ -179,9 +178,7 @@ class HostRSync(execnet.RSync): def add_target_host(self, gateway, finished=None): remotepath = os.path.basename(self._sourcedir) - super(HostRSync, self).add_target( - gateway, remotepath, finishedcallback=finished, delete=True - ) + super().add_target(gateway, remotepath, finishedcallback=finished, delete=True) def _report_send_file(self, gateway, modified_rel_path): if self._verbose: @@ -211,7 +208,7 @@ def make_reltoroot(roots, args): return result -class WorkerController(object): +class WorkerController: ENDMARK = -1 class RemoteHook: @@ -292,7 +289,7 @@ class WorkerController(object): if not self._down: try: self.sendcommand("shutdown") - except (IOError, OSError): + except OSError: pass self._shutdown_sent = True diff --git a/testing/test_dsession.py b/testing/test_dsession.py index 8d0373e..b015c75 100644 --- a/testing/test_dsession.py +++ b/testing/test_dsession.py @@ -203,7 +203,7 @@ class TestLoadScheduling: different test ids are collected by workers. """ - class CollectHook(object): + class CollectHook: """ Dummy hook that stores collection reports. """ diff --git a/testing/test_slavemanage.py b/testing/test_slavemanage.py index 47d2cba..f8abcca 100644 --- a/testing/test_slavemanage.py +++ b/testing/test_slavemanage.py @@ -1,4 +1,3 @@ -from __future__ import print_function import py import pytest import textwrap @@ -35,7 +34,7 @@ def mysetup(tmpdir): @pytest.fixture def workercontroller(monkeypatch): - class MockController(object): + class MockController: def __init__(self, *args): pass