Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/anyio/abc/_testing.py: 89%
18 statements
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-25 06:38 +0000
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-25 06:38 +0000
1from __future__ import annotations
3import types
4from abc import ABCMeta, abstractmethod
5from collections.abc import AsyncGenerator, Callable, Coroutine, Iterable
6from typing import Any, TypeVar
8_T = TypeVar("_T")
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 """
17 def __enter__(self) -> TestRunner:
18 return self
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 ...
29 @abstractmethod
30 def run_asyncgen_fixture(
31 self,
32 fixture_func: Callable[..., AsyncGenerator[_T, Any]],
33 kwargs: dict[str, Any],
34 ) -> Iterable[_T]:
35 """
36 Run an async generator fixture.
38 :param fixture_func: the fixture function
39 :param kwargs: keyword arguments to call the fixture function with
40 :return: an iterator yielding the value yielded from the async generator
41 """
43 @abstractmethod
44 def run_fixture(
45 self,
46 fixture_func: Callable[..., Coroutine[Any, Any, _T]],
47 kwargs: dict[str, Any],
48 ) -> _T:
49 """
50 Run an async fixture.
52 :param fixture_func: the fixture function
53 :param kwargs: keyword arguments to call the fixture function with
54 :return: the return value of the fixture function
55 """
57 @abstractmethod
58 def run_test(
59 self, test_func: Callable[..., Coroutine[Any, Any, Any]], kwargs: dict[str, Any]
60 ) -> None:
61 """
62 Run an async test function.
64 :param test_func: the test function
65 :param kwargs: keyword arguments to call the test function with
66 """