Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/anyio/abc/_testing.py: 94%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

17 statements  

1from __future__ import annotations 

2 

3import types 

4from abc import ABCMeta, abstractmethod 

5from collections.abc import AsyncGenerator, Callable, Coroutine, Iterable 

6from typing import Any, TypeVar 

7 

8_T = TypeVar("_T") 

9 

10 

11class TestRunner(metaclass=ABCMeta): 

12 """ 

13 Encapsulates a running event loop. Every call made through this object will use the 

14 same event loop. 

15 """ 

16 

17 def __enter__(self) -> TestRunner: 

18 return self 

19 

20 @abstractmethod 

21 def __exit__( 

22 self, 

23 exc_type: type[BaseException] | None, 

24 exc_val: BaseException | None, 

25 exc_tb: types.TracebackType | None, 

26 ) -> bool | None: ... 

27 

28 @abstractmethod 

29 def run_asyncgen_fixture( 

30 self, 

31 fixture_func: Callable[..., AsyncGenerator[_T, Any]], 

32 kwargs: dict[str, Any], 

33 ) -> Iterable[_T]: 

34 """ 

35 Run an async generator fixture. 

36 

37 :param fixture_func: the fixture function 

38 :param kwargs: keyword arguments to call the fixture function with 

39 :return: an iterator yielding the value yielded from the async generator 

40 """ 

41 

42 @abstractmethod 

43 def run_fixture( 

44 self, 

45 fixture_func: Callable[..., Coroutine[Any, Any, _T]], 

46 kwargs: dict[str, Any], 

47 ) -> _T: 

48 """ 

49 Run an async fixture. 

50 

51 :param fixture_func: the fixture function 

52 :param kwargs: keyword arguments to call the fixture function with 

53 :return: the return value of the fixture function 

54 """ 

55 

56 @abstractmethod 

57 def run_test( 

58 self, test_func: Callable[..., Coroutine[Any, Any, Any]], kwargs: dict[str, Any] 

59 ) -> None: 

60 """ 

61 Run an async test function. 

62 

63 :param test_func: the test function 

64 :param kwargs: keyword arguments to call the test function with 

65 """