From 58f7291a994d6e78b46298e68f96fdb95e4cd7b9 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 22 Nov 2017 20:00:39 -0200 Subject: [PATCH] Fix E741 and E722 flake errors --- testing/conftest.py | 8 ++++---- testing/test_looponfail.py | 6 +++--- testing/test_slavemanage.py | 26 +++++++++++++------------- xdist/slavemanage.py | 8 ++++---- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/testing/conftest.py b/testing/conftest.py index c10007f..0029b21 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -20,13 +20,13 @@ pytest_plugins = "pytester" @pytest.fixture(autouse=True) def _divert_atexit(request, monkeypatch): import atexit - l = [] + finalizers = [] def finish(): - while l: - l.pop()() + while finalizers: + finalizers.pop()() - monkeypatch.setattr(atexit, "register", l.append) + monkeypatch.setattr(atexit, "register", finalizers.append) request.addfinalizer(finish) diff --git a/testing/test_looponfail.py b/testing/test_looponfail.py index e6d2bb9..4114802 100644 --- a/testing/test_looponfail.py +++ b/testing/test_looponfail.py @@ -83,10 +83,10 @@ class TestStatRecorder: tmp = tmpdir sd = StatRecorder([tmp]) - l = [True, False] - monkeypatch.setattr(StatRecorder, 'check', lambda self: l.pop()) + ret_values = [True, False] + monkeypatch.setattr(StatRecorder, 'check', lambda self: ret_values.pop()) sd.waitonchange(checkinterval=0.2) - assert not l + assert not ret_values class TestRemoteControl: diff --git a/testing/test_slavemanage.py b/testing/test_slavemanage.py index ac79449..8058271 100644 --- a/testing/test_slavemanage.py +++ b/testing/test_slavemanage.py @@ -50,10 +50,10 @@ class TestNodeManagerPopen: assert gm.specs[0].chdir is None def test_default_chdir(self, config): - l = ["ssh=noco", "socket=xyz"] - for spec in NodeManager(config, l).specs: + specs = ["ssh=noco", "socket=xyz"] + for spec in NodeManager(config, specs).specs: assert spec.chdir == "pyexecnetcache" - for spec in NodeManager(config, l, defaultchdir="abc").specs: + for spec in NodeManager(config, specs, defaultchdir="abc").specs: assert spec.chdir == "abc" def test_popen_makegateway_events(self, config, hookrecorder, @@ -89,10 +89,10 @@ class TestNodeManagerPopen: pass gw.remote_exec = pseudoexec - l = [] + notifications = [] for gw in hm.group: - hm.rsync(gw, source, notify=lambda *args: l.append(args)) - assert not l + hm.rsync(gw, source, notify=lambda *args: notifications.append(args)) + assert not notifications hm.teardown_nodes() assert not len(hm.group) assert "sys.path.insert" in gw.remote_exec.args[0] @@ -102,11 +102,11 @@ class TestNodeManagerPopen: hm = NodeManager(config, ["popen//chdir=%s" % dest] * 1) hm.setup_nodes(None) source.ensure("dir1", "dir2", "hello") - l = [] + notifications = [] for gw in hm.group: - hm.rsync(gw, source, notify=lambda *args: l.append(args)) - assert len(l) == 1 - assert l[0] == ("rsyncrootready", hm.group['gw0'].spec, source) + hm.rsync(gw, source, notify=lambda *args: notifications.append(args)) + assert len(notifications) == 1 + assert notifications[0] == ("rsyncrootready", hm.group['gw0'].spec, source) hm.teardown_nodes() dest = dest.join(source.basename) assert dest.join("dir1").check() @@ -137,9 +137,9 @@ class TestHRSync: source.ensure(".somedotfile", "moreentries") source.ensure("somedir", "editfile~") syncer = HostRSync(source, ignores=NodeManager.DEFAULT_IGNORES) - l = list(source.visit(rec=syncer.filter, fil=syncer.filter)) - assert len(l) == 3 - basenames = [x.basename for x in l] + files = list(source.visit(rec=syncer.filter, fil=syncer.filter)) + assert len(files) == 3 + basenames = [x.basename for x in files] assert 'dir' in basenames assert 'file.txt' in basenames assert 'somedir' in basenames diff --git a/xdist/slavemanage.py b/xdist/slavemanage.py index 7fc0b2c..3501548 100644 --- a/xdist/slavemanage.py +++ b/xdist/slavemanage.py @@ -186,7 +186,7 @@ class HostRSync(execnet.RSync): def make_reltoroot(roots, args): # XXX introduce/use public API for splitting py.test args splitcode = "::" - l = [] + result = [] for arg in args: parts = arg.split(splitcode) fspath = py.path.local(parts[0]) @@ -197,8 +197,8 @@ def make_reltoroot(roots, args): break else: raise ValueError("arg %s not relative to an rsync root" % (arg,)) - l.append(splitcode.join(parts)) - return l + result.append(splitcode.join(parts)) + return result class SlaveController(object): @@ -326,7 +326,7 @@ class SlaveController(object): except KeyboardInterrupt: # should not land in receiver-thread raise - except: + except: # noqa excinfo = py.code.ExceptionInfo() py.builtin.print_("!" * 20, excinfo) self.config.notify_exception(excinfo)