2121from _pytest .capture import CaptureFixture
2222from _pytest .capture import FDCapture
2323from _pytest .capture import SysCapture
24+ from _pytest .config import Config
25+ from _pytest .config import hookimpl
26+ from _pytest .config import Parser
27+ from _pytest .fixtures import fixture
2428from _pytest .fixtures import SubRequest
2529from _pytest .logging import catching_logs
2630from _pytest .logging import LogCaptureHandler
31+ from _pytest .nodes import Item
2732from _pytest .reports import TestReport
2833from _pytest .runner import CallInfo
2934from _pytest .runner import check_interactive_exception
3035from _pytest .unittest import TestCaseFunction
31- import pytest
36+ from _pytest . warning_types import PytestDeprecationWarning
3237
3338
3439if TYPE_CHECKING :
3540 from types import TracebackType
3641 from typing import Literal
3742
3843
39- def pytest_addoption (parser : pytest . Parser ) -> None :
44+ def pytest_addoption (parser : Parser ) -> None :
4045 group = parser .getgroup ("subtests" )
4146 group .addoption (
4247 "--no-subtests-shortletter" ,
@@ -174,7 +179,7 @@ def _addSubTest(
174179 self ._originaladdSkip (testcase , reason ) # type: ignore[attr-defined]
175180
176181
177- def pytest_configure (config : pytest . Config ) -> None :
182+ def pytest_configure (config : Config ) -> None :
178183 TestCaseFunction .addSubTest = _addSubTest # type: ignore[attr-defined]
179184 TestCaseFunction .failfast = False # type: ignore[attr-defined]
180185 # This condition is to prevent `TestCaseFunction._originaladdSkip` being assigned again in a subprocess from a
@@ -217,7 +222,7 @@ def pytest_unconfigure() -> None:
217222 del TestCaseFunction ._originaladdSkip
218223
219224
220- @pytest . fixture
225+ @fixture
221226def subtests (request : SubRequest ) -> Generator [SubTests , None , None ]:
222227 """Provides subtests functionality."""
223228 capmam = request .node .config .pluginmanager .get_plugin ("capturemanager" )
@@ -235,7 +240,7 @@ class SubTests:
235240 request : SubRequest = attr .ib ()
236241
237242 @property
238- def item (self ) -> pytest . Item :
243+ def item (self ) -> Item :
239244 return self .request .node
240245
241246 def test (
@@ -414,7 +419,7 @@ def ignore_pytest_private_warning() -> Generator[None, None, None]:
414419 warnings .filterwarnings (
415420 "ignore" ,
416421 "A private pytest class or function was used." ,
417- category = pytest . PytestDeprecationWarning ,
422+ category = PytestDeprecationWarning ,
418423 )
419424 yield
420425
@@ -424,7 +429,7 @@ class Captured:
424429 out = attr .ib (default = "" , type = str )
425430 err = attr .ib (default = "" , type = str )
426431
427- def update_report (self , report : pytest . TestReport ) -> None :
432+ def update_report (self , report : TestReport ) -> None :
428433 if self .out :
429434 report .sections .append (("Captured stdout call" , self .out ))
430435 if self .err :
@@ -435,16 +440,16 @@ class CapturedLogs:
435440 def __init__ (self , handler : LogCaptureHandler ) -> None :
436441 self ._handler = handler
437442
438- def update_report (self , report : pytest . TestReport ) -> None :
443+ def update_report (self , report : TestReport ) -> None :
439444 report .sections .append (("Captured log call" , self ._handler .stream .getvalue ()))
440445
441446
442447class NullCapturedLogs :
443- def update_report (self , report : pytest . TestReport ) -> None :
448+ def update_report (self , report : TestReport ) -> None :
444449 pass
445450
446451
447- def pytest_report_to_serializable (report : pytest . TestReport ) -> dict [str , Any ] | None :
452+ def pytest_report_to_serializable (report : TestReport ) -> dict [str , Any ] | None :
448453 if isinstance (report , SubTestReport ):
449454 return report ._to_json ()
450455 return None
@@ -456,10 +461,10 @@ def pytest_report_from_serializable(data: dict[str, Any]) -> SubTestReport | Non
456461 return None
457462
458463
459- @pytest . hookimpl (tryfirst = True )
464+ @hookimpl (tryfirst = True )
460465def pytest_report_teststatus (
461- report : pytest . TestReport ,
462- config : pytest . Config ,
466+ report : TestReport ,
467+ config : Config ,
463468) -> tuple [str , str , str | Mapping [str , bool ]] | None :
464469 if report .when != "call" or not isinstance (report , SubTestReport ):
465470 return None
0 commit comments