1
1
from __future__ import annotations
2
+
3
+ from enum import auto
4
+ from enum import Enum
5
+ from queue import Empty
6
+ from queue import Queue
2
7
import sys
3
- from enum import Enum , auto
4
8
from typing import Sequence
5
9
6
10
import pytest
7
11
8
12
from xdist .remote import Producer
13
+ from xdist .scheduler import EachScheduling
14
+ from xdist .scheduler import LoadFileScheduling
15
+ from xdist .scheduler import LoadGroupScheduling
16
+ from xdist .scheduler import LoadScheduling
17
+ from xdist .scheduler import LoadScopeScheduling
18
+ from xdist .scheduler import WorkStealingScheduling
9
19
from xdist .workermanage import NodeManager
10
- from xdist .scheduler import (
11
- EachScheduling ,
12
- LoadScheduling ,
13
- LoadScopeScheduling ,
14
- LoadFileScheduling ,
15
- LoadGroupScheduling ,
16
- WorkStealingScheduling ,
17
- )
18
-
19
-
20
- from queue import Empty , Queue
21
20
22
21
23
22
class Interrupted (KeyboardInterrupt ):
24
23
"""signals an immediate interruption."""
25
24
26
25
27
26
class DSession :
28
- """A pytest plugin which runs a distributed test session
27
+ """A pytest plugin which runs a distributed test session.
29
28
30
29
At the beginning of the test session this creates a NodeManager
31
30
instance which creates and starts all nodes. Nodes then emit
@@ -61,7 +60,7 @@ def __init__(self, config):
61
60
62
61
@property
63
62
def session_finished (self ):
64
- """Return True if the distributed session has finished
63
+ """Return True if the distributed session has finished.
65
64
66
65
This means all nodes have executed all test items. This is
67
66
used by pytest_runtestloop to break out of its loop.
@@ -231,9 +230,7 @@ def worker_errordown(self, node, error):
231
230
)
232
231
if maximum_reached :
233
232
if self ._max_worker_restart == 0 :
234
- msg = "worker {} crashed and worker restarting disabled" .format (
235
- node .gateway .id
236
- )
233
+ msg = f"worker { node .gateway .id } crashed and worker restarting disabled"
237
234
else :
238
235
msg = "maximum crashed workers reached: %d" % self ._max_worker_restart
239
236
self ._summary_report = msg
@@ -251,7 +248,7 @@ def pytest_terminal_summary(self, terminalreporter):
251
248
terminalreporter .write_sep ("=" , f"xdist: { self ._summary_report } " )
252
249
253
250
def worker_collectionfinish (self , node , ids ):
254
- """worker has finished test collection.
251
+ """Worker has finished test collection.
255
252
256
253
This adds the collection for this node to the scheduler. If
257
254
the scheduler indicates collection is finished (i.e. all
@@ -464,7 +461,7 @@ def pytest_xdist_newgateway(self, gateway) -> None:
464
461
rinfo = gateway ._rinfo ()
465
462
different_interpreter = rinfo .executable != sys .executable
466
463
if different_interpreter :
467
- version = "%s.%s.%s" % rinfo .version_info [:3 ]
464
+ version = "{}.{}.{}" . format ( * rinfo .version_info [:3 ])
468
465
self .rewrite (
469
466
f"[{ gateway .id } ] { rinfo .platform } Python { version } cwd: { rinfo .cwd } " ,
470
467
newline = True ,
@@ -491,7 +488,7 @@ def pytest_testnodedown(self, node, error) -> None:
491
488
492
489
493
490
def get_default_max_worker_restart (config ):
494
- """gets the default value of --max-worker-restart option if it is not provided.
491
+ """Gets the default value of --max-worker-restart option if it is not provided.
495
492
496
493
Use a reasonable default to avoid workers from restarting endlessly due to crashing collections (#226).
497
494
"""
@@ -505,7 +502,7 @@ def get_default_max_worker_restart(config):
505
502
506
503
507
504
def get_workers_status_line (
508
- status_and_items : Sequence [tuple [WorkerStatus , int ]]
505
+ status_and_items : Sequence [tuple [WorkerStatus , int ]],
509
506
) -> str :
510
507
"""
511
508
Return the line to display during worker setup/collection based on the
0 commit comments