Skip to content

Upgrading pytest-asyncio 0.21 to 0.23

Breaking0.21.2 → 0.23.8Breaking1Platform2Deprecated1New2Changed3Fixed13Other2

BreakingUpgrade verdict

1 breaking change and 2 platform requirement changes.

  • The old way of asking for a shared event loop is gone. Use the asyncio mark's scope option instead.
  • This version no longer runs on Python 3.7; upgrade to a newer Python.
  • This version officially supports Python 3.12.
  • Overriding the event_loop fixture is deprecated. If you need a loop shared by a class or module, mark it with asyncio_event_loop instead.
4 items need code or config changes

Python requirement changed in 0.22.0: >=3.7 → >=3.8.

Moves pytest 9.2.0 → 8.4.2. Your build may pick other versions.

Breaking1
Removes the asyncio_event_loop mark; request class, module, package, and session scoped event loops via the scope keyword argument to the asyncio mark.
asyncio_event_loopasyncioscope
Platform2
Removes support for Python 3.7.
Declares support for Python 3.12.
Deprecated1
Deprecates redefinition of the event_loop fixture; use the asyncio_event_loop mark for class- or module-scoped loops.
event_loopasyncio_event_loop

Generated by DepDelta from published Python source. Not mixed with prose notes.

  • added: export is_async_test
  • removed: function pytest_collection_modifyitems(session: Session, config: Config, items: List[Item]) -> None
  • removed: function pytest_pycollect_makeitem(collector: Union[pytest.Module, pytest.Class], name: str, obj: object) -> Union[pytest.Item, pytest.Collector, List[Union[pytest.Item, pytest.Collector]], None]
  • removed: variable SubRequest
  • changed: function pytest_fixture_setup(fixturedef: FixtureDef, request: SubRequest) -> Optional[object] → function pytest_fixture_setup(fixturedef: FixtureDef) -> Generator[None, Any, None]
  • changed: function pytest_pyfunc_call(pyfuncitem: pytest.Function) -> Optional[object] → function pytest_pyfunc_call(pyfuncitem: Function) -> Optional[object]
  • changed: function wrap_in_sync(pyfuncitem: pytest.Function, func: Callable[..., Awaitable[Any]], _loop: asyncio.AbstractEventLoop) → function wrap_in_sync(func: Callable[..., Awaitable[Any]])
  • added: class AsyncGenerator(PytestAsyncioFunction)
  • added: class AsyncHypothesisTest(PytestAsyncioFunction)
  • added: class AsyncStaticMethod(PytestAsyncioFunction)
  • added: class Coroutine(PytestAsyncioFunction)
  • added: class MultipleEventLoopsRequestedError(PytestAsyncioError)
  • added: class PytestAsyncioError(Exception)
  • added: class PytestAsyncioFunction(Function)
  • added: function event_loop_policy() -> AbstractEventLoopPolicy
  • added: function is_async_test(item: Item) -> bool
  • added: function pytest_collectstart(collector: pytest.Collector) -> None
  • added: function pytest_generate_tests(metafunc: Metafunc) -> None
  • added: function pytest_pycollect_makeitem_convert_async_functions_to_subclass(collector: Union[pytest.Module, pytest.Class], name: str, obj: object) -> Generator[None, Any, None]
  • added: function pytest_pycollect_makeitem_preprocess_async_fixtures(collector: Union[pytest.Module, pytest.Class], name: str, obj: object) -> Union[pytest.Item, pytest.Collector, List[Union[pytest.Item, pytest.Collector]], None]
  • added: method AsyncHypothesisTest.runtest() -> None
  • added: method AsyncStaticMethod.runtest() -> None
  • added: method Coroutine.runtest() -> None
  • added: static method PytestAsyncioFunction.item_subclass_for(item: Function, /) -> Union[Type[PytestAsyncioFunction], None]