@@ -37,7 +37,9 @@ def pytest_unconfigure(config):
37
37
# https://github.com/AdamGleave/pytest-shard/blob/64610a08dac6b0511b6d51cf895d0e1040d162ad/pytest_shard/pytest_shard.py
38
38
39
39
40
- def get_group (items : Iterable [nodes .Node ], group_count : int , group_id : int ) -> Sequence [nodes .Node ]:
40
+ def get_group (
41
+ items : Iterable [nodes .Node ], group_count : int , group_id : int
42
+ ) -> Sequence [nodes .Node ]:
41
43
"""Get the items from the passed in group based on group count."""
42
44
if not (0 <= group_id < group_count ):
43
45
raise ValueError ("Invalid test-group argument" )
@@ -53,29 +55,34 @@ def get_group_id(node: nodes.Node) -> int:
53
55
54
56
55
57
def pytest_addoption (parser ):
56
- group = parser .getgroup ('split your tests into evenly sized groups and run them' )
57
- group .addoption ('--test-group-count' , dest = 'test-group-count' , type = int ,
58
- help = 'The number of groups to split the tests into' )
59
- group .addoption ('--test-group' , dest = 'test-group' , type = int ,
60
- help = 'The group of tests that should be executed' )
58
+ group = parser .getgroup ("split your tests into evenly sized groups and run them" )
59
+ group .addoption (
60
+ "--test-group-count" ,
61
+ dest = "test-group-count" ,
62
+ type = int ,
63
+ help = "The number of groups to split the tests into" ,
64
+ )
65
+ group .addoption (
66
+ "--test-group" ,
67
+ dest = "test-group" ,
68
+ type = int ,
69
+ help = "The group of tests that should be executed" ,
70
+ )
61
71
62
72
63
73
def pytest_collection_modifyitems (session , config , items : List [nodes .Node ]):
64
- group_count = config .getoption (' test-group-count' )
65
- group_id = config .getoption (' test-group' )
74
+ group_count = config .getoption (" test-group-count" )
75
+ group_id = config .getoption (" test-group" )
66
76
67
77
if not group_count or not group_id :
68
78
return
69
79
70
80
items [:] = get_group (items , group_count , group_id )
71
81
72
- terminal_reporter = config .pluginmanager .get_plugin (' terminalreporter' )
82
+ terminal_reporter = config .pluginmanager .get_plugin (" terminalreporter" )
73
83
terminal_writer = create_terminal_writer (config )
74
84
message = terminal_writer .markup (
75
- 'Running test group #{0} ({1} tests)\n ' .format (
76
- group_id ,
77
- len (items )
78
- ),
79
- yellow = True
85
+ "Running test group #{0} ({1} tests)\n " .format (group_id , len (items )),
86
+ yellow = True ,
80
87
)
81
88
terminal_reporter .write (message )
0 commit comments