30
30
Collector ,
31
31
Config ,
32
32
FixtureRequest ,
33
+ Function ,
33
34
Item ,
34
35
Metafunc ,
35
36
Parser ,
@@ -347,11 +348,11 @@ async def setup():
347
348
fixturedef .func = _async_fixture_wrapper
348
349
349
350
350
- class PytestAsyncioFunction (pytest . Function ):
351
+ class PytestAsyncioFunction (Function ):
351
352
"""Base class for all test functions managed by pytest-asyncio."""
352
353
353
354
@classmethod
354
- def substitute (cls , item : pytest . Function , / ) -> pytest . Function :
355
+ def substitute (cls , item : Function , / ) -> Function :
355
356
"""
356
357
Returns a PytestAsyncioFunction if there is an implementation that can handle
357
358
the specified function item.
@@ -365,10 +366,10 @@ def substitute(cls, item: pytest.Function, /) -> pytest.Function:
365
366
return item
366
367
367
368
@classmethod
368
- def _from_function (cls , function : pytest . Function , / ) -> pytest . Function :
369
+ def _from_function (cls , function : Function , / ) -> Function :
369
370
"""
370
371
Instantiates this specific PytestAsyncioFunction type from the specified
371
- pytest. Function item.
372
+ Function item.
372
373
"""
373
374
return cls .from_parent (
374
375
function .parent ,
@@ -381,7 +382,7 @@ def _from_function(cls, function: pytest.Function, /) -> pytest.Function:
381
382
)
382
383
383
384
@staticmethod
384
- def _can_substitute (item : pytest . Function ) -> bool :
385
+ def _can_substitute (item : Function ) -> bool :
385
386
"""Returns whether the specified function can be replaced by this class"""
386
387
raise NotImplementedError ()
387
388
@@ -390,7 +391,7 @@ class AsyncFunction(PytestAsyncioFunction):
390
391
"""Pytest item that is a coroutine or an asynchronous generator"""
391
392
392
393
@staticmethod
393
- def _can_substitute (item : pytest . Function ) -> bool :
394
+ def _can_substitute (item : Function ) -> bool :
394
395
func = item .obj
395
396
return _is_coroutine_or_asyncgen (func )
396
397
@@ -409,7 +410,7 @@ class AsyncStaticMethod(PytestAsyncioFunction):
409
410
"""
410
411
411
412
@staticmethod
412
- def _can_substitute (item : pytest . Function ) -> bool :
413
+ def _can_substitute (item : Function ) -> bool :
413
414
func = item .obj
414
415
return isinstance (func , staticmethod ) and _is_coroutine_or_asyncgen (
415
416
func .__func__
@@ -430,7 +431,7 @@ class AsyncHypothesisTest(PytestAsyncioFunction):
430
431
"""
431
432
432
433
@staticmethod
433
- def _can_substitute (item : pytest . Function ) -> bool :
434
+ def _can_substitute (item : Function ) -> bool :
434
435
func = item .obj
435
436
return getattr (
436
437
func , "is_hypothesis_test" , False
@@ -486,7 +487,7 @@ def pytest_pycollect_makeitem_convert_async_functions_to_subclass(
486
487
updated_node_collection = []
487
488
for node in node_iterator :
488
489
updated_item = node
489
- if isinstance (node , pytest . Function ):
490
+ if isinstance (node , Function ):
490
491
updated_item = PytestAsyncioFunction .substitute (node )
491
492
updated_node_collection .append (updated_item )
492
493
@@ -716,7 +717,7 @@ def _provide_clean_event_loop() -> None:
716
717
717
718
718
719
@pytest .hookimpl (tryfirst = True , hookwrapper = True )
719
- def pytest_pyfunc_call (pyfuncitem : pytest . Function ) -> Optional [object ]:
720
+ def pytest_pyfunc_call (pyfuncitem : Function ) -> Optional [object ]:
720
721
"""
721
722
Pytest hook called before a test case is run.
722
723
0 commit comments