@@ -6,21 +6,22 @@ from _typeshed import SupportsFlush, SupportsWrite
6
6
from collections .abc import Callable , Iterable
7
7
from typing import Any , Generic , Protocol , TypeVar
8
8
from typing_extensions import Never , TypeAlias
9
+ from warnings import _ActionKind
9
10
10
- _ResultClassType : TypeAlias = Callable [[_TextTestStream , bool , int ], TextTestResult ]
11
+ _ResultClassType : TypeAlias = Callable [[_TextTestStream , bool , int ], TextTestResult [ Any ] ]
11
12
12
13
class _SupportsWriteAndFlush (SupportsWrite [str ], SupportsFlush , Protocol ): ...
13
14
14
15
# All methods used by unittest.runner.TextTestResult's stream
15
16
class _TextTestStream (_SupportsWriteAndFlush , Protocol ):
16
- def writeln (self , arg : str | None = None , / ) -> str : ...
17
+ def writeln (self , arg : str | None = None , / ) -> None : ...
17
18
18
19
# _WritelnDecorator should have all the same attrs as its stream param.
19
20
# But that's not feasible to do Generically
20
21
# We can expand the attributes if requested
21
22
class _WritelnDecorator :
22
- def __init__ (self , stream : _TextTestStream ) -> None : ...
23
- def writeln (self , arg : str | None = None ) -> str : ...
23
+ def __init__ (self , stream : _SupportsWriteAndFlush ) -> None : ...
24
+ def writeln (self , arg : str | None = None ) -> None : ...
24
25
def __getattr__ (self , attr : str ) -> Any : ... # Any attribute from the stream type passed to __init__
25
26
# These attributes are prevented by __getattr__
26
27
stream : Never
@@ -39,10 +40,8 @@ class TextTestResult(unittest.result.TestResult, Generic[_StreamT]):
39
40
showAll : bool # undocumented
40
41
stream : _StreamT # undocumented
41
42
if sys .version_info >= (3 , 12 ):
42
- durations : unittest .result ._DurationsType | None
43
- def __init__ (
44
- self , stream : _StreamT , descriptions : bool , verbosity : int , * , durations : unittest .result ._DurationsType | None = None
45
- ) -> None : ...
43
+ durations : int | None
44
+ def __init__ (self , stream : _StreamT , descriptions : bool , verbosity : int , * , durations : int | None = None ) -> None : ...
46
45
else :
47
46
def __init__ (self , stream : _StreamT , descriptions : bool , verbosity : int ) -> None : ...
48
47
@@ -56,11 +55,11 @@ class TextTestRunner:
56
55
verbosity : int
57
56
failfast : bool
58
57
buffer : bool
59
- warnings : str | None
58
+ warnings : _ActionKind | None
60
59
tb_locals : bool
61
60
62
61
if sys .version_info >= (3 , 12 ):
63
- durations : unittest . result . _DurationsType | None
62
+ durations : int | None
64
63
def __init__ (
65
64
self ,
66
65
stream : _SupportsWriteAndFlush | None = None ,
@@ -69,10 +68,10 @@ class TextTestRunner:
69
68
failfast : bool = False ,
70
69
buffer : bool = False ,
71
70
resultclass : _ResultClassType | None = None ,
72
- warnings : str | None = None ,
71
+ warnings : _ActionKind | None = None ,
73
72
* ,
74
73
tb_locals : bool = False ,
75
- durations : unittest . result . _DurationsType | None = None ,
74
+ durations : int | None = None ,
76
75
) -> None : ...
77
76
else :
78
77
def __init__ (
0 commit comments