9
9
from typing import final
10
10
from typing import Generic
11
11
from typing import List
12
+ from typing import Literal
12
13
from typing import Optional
13
14
from typing import Tuple
14
15
from typing import Type
38
39
from exceptiongroup import BaseExceptionGroup
39
40
40
41
if TYPE_CHECKING :
41
- from typing_extensions import Literal
42
-
43
42
from _pytest .main import Session
44
43
from _pytest .terminal import TerminalReporter
45
44
@@ -184,7 +183,7 @@ def pytest_runtest_teardown(item: Item, nextitem: Optional[Item]) -> None:
184
183
185
184
186
185
def _update_current_test_var (
187
- item : Item , when : Optional [" Literal[' setup', ' call', ' teardown']" ]
186
+ item : Item , when : Optional [Literal [" setup" , " call" , " teardown" ] ]
188
187
) -> None :
189
188
"""Update :envvar:`PYTEST_CURRENT_TEST` to reflect the current item and stage.
190
189
@@ -217,7 +216,7 @@ def pytest_report_teststatus(report: BaseReport) -> Optional[Tuple[str, str, str
217
216
218
217
219
218
def call_and_report (
220
- item : Item , when : " Literal[' setup', ' call', ' teardown']" , log : bool = True , ** kwds
219
+ item : Item , when : Literal [" setup" , " call" , " teardown" ] , log : bool = True , ** kwds
221
220
) -> TestReport :
222
221
call = call_runtest_hook (item , when , ** kwds )
223
222
hook = item .ihook
@@ -245,7 +244,7 @@ def check_interactive_exception(call: "CallInfo[object]", report: BaseReport) ->
245
244
246
245
247
246
def call_runtest_hook (
248
- item : Item , when : " Literal[' setup', ' call', ' teardown']" , ** kwds
247
+ item : Item , when : Literal [" setup" , " call" , " teardown" ] , ** kwds
249
248
) -> "CallInfo[None]" :
250
249
if when == "setup" :
251
250
ihook : Callable [..., None ] = item .ihook .pytest_runtest_setup
@@ -281,7 +280,7 @@ class CallInfo(Generic[TResult]):
281
280
#: The call duration, in seconds.
282
281
duration : float
283
282
#: The context of invocation: "collect", "setup", "call" or "teardown".
284
- when : " Literal[' collect', ' setup', ' call', ' teardown']"
283
+ when : Literal [" collect" , " setup" , " call" , " teardown" ]
285
284
286
285
def __init__ (
287
286
self ,
@@ -290,7 +289,7 @@ def __init__(
290
289
start : float ,
291
290
stop : float ,
292
291
duration : float ,
293
- when : " Literal[' collect', ' setup', ' call', ' teardown']" ,
292
+ when : Literal [" collect" , " setup" , " call" , " teardown" ] ,
294
293
* ,
295
294
_ispytest : bool = False ,
296
295
) -> None :
@@ -319,7 +318,7 @@ def result(self) -> TResult:
319
318
def from_call (
320
319
cls ,
321
320
func : "Callable[[], TResult]" ,
322
- when : " Literal[' collect', ' setup', ' call', ' teardown']" ,
321
+ when : Literal [" collect" , " setup" , " call" , " teardown" ] ,
323
322
reraise : Optional [
324
323
Union [Type [BaseException ], Tuple [Type [BaseException ], ...]]
325
324
] = None ,
0 commit comments