Skip to content

Commit 9952a40

Browse files
committed
Let ruff fix things
1 parent 611def1 commit 9952a40

File tree

5 files changed

+13
-17
lines changed

5 files changed

+13
-17
lines changed

src/pytest_split/plugin.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def pytest_addoption(parser: "Parser") -> None:
7676
)
7777

7878

79-
@pytest.mark.tryfirst
79+
@pytest.mark.tryfirst()
8080
def pytest_cmdline_main(config: "Config") -> "Optional[Union[int, ExitCode]]":
8181
"""
8282
Validate options.
@@ -135,9 +135,7 @@ def __init__(self, config: "Config") -> None:
135135
# from saving durations in a list-of-lists to a dict format
136136
# Remove this when bumping to v1
137137
if isinstance(self.cached_durations, list):
138-
self.cached_durations = {
139-
test_name: duration for test_name, duration in self.cached_durations
140-
}
138+
self.cached_durations = dict(self.cached_durations)
141139

142140

143141
class PytestSplitPlugin(Base):
@@ -182,7 +180,6 @@ def pytest_collection_modifyitems(
182180
f"[pytest-split] Running group {group_idx}/{splits} (estimated duration: {group.duration:.2f}s)\n"
183181
)
184182
)
185-
return None
186183

187184

188185
class PytestSplitCachePlugin(Base):

tests/test_algorithms.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
if TYPE_CHECKING:
88
from typing import List, Set
9+
910
from _pytest.nodes import Item
1011

1112
from pytest_split.algorithms import Algorithms
@@ -17,7 +18,7 @@ class TestAlgorithms:
1718
@pytest.mark.parametrize("algo_name", Algorithms.names())
1819
def test__split_test(self, algo_name):
1920
durations = {"a": 1, "b": 1, "c": 1}
20-
items = [item(x) for x in durations.keys()]
21+
items = [item(x) for x in durations]
2122
algo = Algorithms[algo_name].value
2223
first, second, third = algo(splits=3, items=items, durations=durations)
2324

@@ -70,7 +71,7 @@ def test__split_test_handles_large_duration_at_end(self):
7071
assert second.selected == [item(x) for x in ["a", "b", "c"]]
7172

7273
@pytest.mark.parametrize(
73-
"algo_name, expected",
74+
("algo_name", "expected"),
7475
[
7576
("duration_based_chunks", [[item("a"), item("b")], [item("c"), item("d")]]),
7677
("least_duration", [[item("a"), item("c")], [item("b"), item("d")]]),
@@ -94,7 +95,7 @@ def test__split_tests_calculates_avg_test_duration_only_on_present_tests(
9495
assert second.selected == expected_second
9596

9697
@pytest.mark.parametrize(
97-
"algo_name, expected",
98+
("algo_name", "expected"),
9899
[
99100
(
100101
"duration_based_chunks",

tests/test_cli.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
from unittest.mock import patch
66

77
import pytest
8-
98
from pytest_split import cli
109

1110

12-
@pytest.fixture
11+
@pytest.fixture()
1312
def durations_file(tmpdir):
1413
durations_path = str(tmpdir.join(".durations"))
1514
durations = {f"test_{i}": float(i) for i in range(1, 11)}

tests/test_ipynb.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from collections import namedtuple
22

33
import pytest
4-
54
from pytest_split.algorithms import Algorithms
65
from pytest_split.ipynb_compatibility import ensure_ipynb_compatibility
76

@@ -28,7 +27,7 @@ def test_ensure_ipynb_compatibility(self, algo_name):
2827
"temp/nbs/test_4.ipynb::Cell 1": 1,
2928
"temp/nbs/test_4.ipynb::Cell 2": 3,
3029
}
31-
items = [item(x) for x in durations.keys()]
30+
items = [item(x) for x in durations]
3231
algo = Algorithms[algo_name].value
3332
groups = algo(splits=3, items=items, durations=durations)
3433

tests/test_plugin.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010
EXAMPLE_SUITE_TEST_COUNT = 10
1111

1212

13-
@pytest.fixture
13+
@pytest.fixture()
1414
def example_suite(testdir):
1515
testdir.makepyfile(
1616
"".join(
1717
f"def test_{num}(): pass\n"
1818
for num in range(1, EXAMPLE_SUITE_TEST_COUNT + 1)
1919
)
2020
)
21-
yield testdir
21+
return testdir
2222

2323

24-
@pytest.fixture
24+
@pytest.fixture()
2525
def durations_path(tmpdir):
2626
return str(tmpdir.join(".durations"))
2727

@@ -74,7 +74,7 @@ def test_it_doesnt_remove_old_durations(self, example_suite, durations_path):
7474
durations = json.load(f)
7575

7676
for item in old_durations:
77-
assert item in durations.keys()
77+
assert item in durations
7878
assert len(durations) == EXAMPLE_SUITE_TEST_COUNT + len(old_durations)
7979

8080
def test_it_removes_old_when_cli_flag_used(self, example_suite, durations_path):
@@ -171,7 +171,7 @@ class TestSplitToSuites:
171171
enumerated_params = [(i, *param) for i, param in enumerate(all_params)]
172172

173173
@pytest.mark.parametrize(
174-
"test_idx, splits, group, algo, expected, legacy_flag", enumerated_params
174+
("test_idx", "splits", "group", "algo", "expected", "legacy_flag"), enumerated_params
175175
)
176176
def test_it_splits( # noqa: PLR0913
177177
self,

0 commit comments

Comments
 (0)