Use ruff instead of black, flake8, autoflake, pyupgrade
Config adapted from pytest.
This commit is contained in:
@@ -266,8 +266,8 @@ class TestDistribution:
|
||||
"-pfoobarplugin",
|
||||
"--foobar=123",
|
||||
"--dist=load",
|
||||
"--rsyncdir=%(subdir)s" % locals(),
|
||||
"--tx=popen//chdir=%(dest)s" % locals(),
|
||||
f"--rsyncdir={subdir}",
|
||||
f"--tx=popen//chdir={dest}",
|
||||
p,
|
||||
)
|
||||
assert result.ret == 0
|
||||
@@ -657,9 +657,7 @@ def test_crashing_item(pytester, when) -> None:
|
||||
|
||||
def test_ok():
|
||||
pass
|
||||
""".format(
|
||||
**code
|
||||
)
|
||||
""".format(**code)
|
||||
)
|
||||
passes = 2 if when == "teardown" else 1
|
||||
result = pytester.runpytest("-n2", p)
|
||||
@@ -1513,9 +1511,7 @@ class TestLocking:
|
||||
|
||||
FILE_LOCK = filelock.FileLock("test.lock")
|
||||
|
||||
""" + (
|
||||
(_test_content * 4) % ("A", "B", "C", "D")
|
||||
)
|
||||
""" + ((_test_content * 4) % ("A", "B", "C", "D"))
|
||||
|
||||
@pytest.mark.parametrize("scope", ["each", "load", "loadscope", "loadfile", "no"])
|
||||
def test_single_file(self, pytester, scope) -> None:
|
||||
|
||||
@@ -165,7 +165,7 @@ class TestLoadScheduling:
|
||||
|
||||
for i in range(7, 16):
|
||||
sched.mark_test_complete(node1, i - 3)
|
||||
assert node1.sent == [0, 1] + list(range(4, i))
|
||||
assert node1.sent == [0, 1, *range(4, i)]
|
||||
assert node2.sent == [2, 3]
|
||||
assert sched.pending == list(range(i, 16))
|
||||
|
||||
@@ -187,7 +187,7 @@ class TestLoadScheduling:
|
||||
|
||||
for complete_index, first_pending in enumerate(range(5, 16)):
|
||||
sched.mark_test_complete(node1, node1.sent[complete_index])
|
||||
assert node1.sent == [0, 1] + list(range(4, first_pending))
|
||||
assert node1.sent == [0, 1, *range(4, first_pending)]
|
||||
assert node2.sent == [2, 3]
|
||||
assert sched.pending == list(range(first_pending, 16))
|
||||
|
||||
@@ -251,9 +251,7 @@ class TestLoadScheduling:
|
||||
"""
|
||||
|
||||
class CollectHook:
|
||||
"""
|
||||
Dummy hook that stores collection reports.
|
||||
"""
|
||||
"""Dummy hook that stores collection reports."""
|
||||
|
||||
def __init__(self):
|
||||
self.reports = []
|
||||
@@ -295,7 +293,7 @@ class TestWorkStealingScheduling:
|
||||
sched.schedule()
|
||||
assert not sched.pending
|
||||
assert not sched.tests_finished
|
||||
assert node1.sent == list(range(0, 8))
|
||||
assert node1.sent == list(range(8))
|
||||
assert node2.sent == list(range(8, 16))
|
||||
for i in range(8):
|
||||
sched.mark_test_complete(node1, node1.sent[i])
|
||||
@@ -315,7 +313,7 @@ class TestWorkStealingScheduling:
|
||||
sched.add_node_collection(node2, collection)
|
||||
assert sched.collection_is_completed
|
||||
sched.schedule()
|
||||
assert node1.sent == list(range(0, 8))
|
||||
assert node1.sent == list(range(8))
|
||||
assert node2.sent == list(range(8, 16))
|
||||
for i in range(8):
|
||||
sched.mark_test_complete(node1, node1.sent[i])
|
||||
|
||||
@@ -13,7 +13,7 @@ from xdist.workermanage import NodeManager
|
||||
def monkeypatch_3_cpus(monkeypatch: pytest.MonkeyPatch):
|
||||
"""Make pytest-xdist believe the system has 3 CPUs."""
|
||||
# block import
|
||||
monkeypatch.setitem(sys.modules, "psutil", None) # type: ignore
|
||||
monkeypatch.setitem(sys.modules, "psutil", None)
|
||||
monkeypatch.delattr(os, "sched_getaffinity", raising=False)
|
||||
monkeypatch.setattr(os, "cpu_count", lambda: 3)
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ WAIT_TIMEOUT = 10.0
|
||||
def check_marshallable(d):
|
||||
try:
|
||||
marshal.dumps(d)
|
||||
except ValueError:
|
||||
except ValueError as e:
|
||||
pprint.pprint(d)
|
||||
raise ValueError("not marshallable")
|
||||
raise ValueError("not marshallable") from e
|
||||
|
||||
|
||||
class EventCall:
|
||||
@@ -164,7 +164,7 @@ class TestWorkerInteractor:
|
||||
worker.sendcommand("runtests_all")
|
||||
worker.sendcommand("shutdown")
|
||||
for func in "::test_func", "::test_func2":
|
||||
for i in range(3): # setup/call/teardown
|
||||
for _ in range(3): # setup/call/teardown
|
||||
ev = worker.popevent("testreport")
|
||||
assert ev.name == "testreport"
|
||||
rep = unserialize_report(ev.kwargs["data"])
|
||||
@@ -329,12 +329,10 @@ def test_remote_mainargv(pytester: pytest.Pytester) -> None:
|
||||
outer_argv = sys.argv
|
||||
|
||||
pytester.makepyfile(
|
||||
"""
|
||||
f"""
|
||||
def test_mainargv(request):
|
||||
assert request.config.workerinput["mainargv"] == {!r}
|
||||
""".format(
|
||||
outer_argv
|
||||
)
|
||||
assert request.config.workerinput["mainargv"] == {outer_argv!r}
|
||||
"""
|
||||
)
|
||||
result = pytester.runpytest("-n1")
|
||||
assert result.ret == 0
|
||||
|
||||
Reference in New Issue
Block a user