99from typing import final
1010from typing import Generic
1111from typing import List
12+ from typing import Literal
1213from typing import Optional
1314from typing import Tuple
1415from typing import Type
3839 from exceptiongroup import BaseExceptionGroup
3940
4041if TYPE_CHECKING :
41- from typing_extensions import Literal
42-
4342 from _pytest .main import Session
4443 from _pytest .terminal import TerminalReporter
4544
@@ -184,7 +183,7 @@ def pytest_runtest_teardown(item: Item, nextitem: Optional[Item]) -> None:
184183
185184
186185def _update_current_test_var (
187- item : Item , when : Optional [" Literal[' setup', ' call', ' teardown']" ]
186+ item : Item , when : Optional [Literal [" setup" , " call" , " teardown" ] ]
188187) -> None :
189188 """Update :envvar:`PYTEST_CURRENT_TEST` to reflect the current item and stage.
190189
@@ -217,7 +216,7 @@ def pytest_report_teststatus(report: BaseReport) -> Optional[Tuple[str, str, str
217216
218217
219218def 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
221220) -> TestReport :
222221 call = call_runtest_hook (item , when , ** kwds )
223222 hook = item .ihook
@@ -245,7 +244,7 @@ def check_interactive_exception(call: "CallInfo[object]", report: BaseReport) ->
245244
246245
247246def call_runtest_hook (
248- item : Item , when : " Literal[' setup', ' call', ' teardown']" , ** kwds
247+ item : Item , when : Literal [" setup" , " call" , " teardown" ] , ** kwds
249248) -> "CallInfo[None]" :
250249 if when == "setup" :
251250 ihook : Callable [..., None ] = item .ihook .pytest_runtest_setup
@@ -281,7 +280,7 @@ class CallInfo(Generic[TResult]):
281280 #: The call duration, in seconds.
282281 duration : float
283282 #: The context of invocation: "collect", "setup", "call" or "teardown".
284- when : " Literal[' collect', ' setup', ' call', ' teardown']"
283+ when : Literal [" collect" , " setup" , " call" , " teardown" ]
285284
286285 def __init__ (
287286 self ,
@@ -290,7 +289,7 @@ def __init__(
290289 start : float ,
291290 stop : float ,
292291 duration : float ,
293- when : " Literal[' collect', ' setup', ' call', ' teardown']" ,
292+ when : Literal [" collect" , " setup" , " call" , " teardown" ] ,
294293 * ,
295294 _ispytest : bool = False ,
296295 ) -> None :
@@ -319,7 +318,7 @@ def result(self) -> TResult:
319318 def from_call (
320319 cls ,
321320 func : "Callable[[], TResult]" ,
322- when : " Literal[' collect', ' setup', ' call', ' teardown']" ,
321+ when : Literal [" collect" , " setup" , " call" , " teardown" ] ,
323322 reraise : Optional [
324323 Union [Type [BaseException ], Tuple [Type [BaseException ], ...]]
325324 ] = None ,
0 commit comments