You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/reference/changelog.rst
+8-1
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,18 @@ Changelog
4
4
5
5
0.23.0 (UNRELEASED)
6
6
===================
7
-
- Removes pytest-trio from the test dependencies `#620 <https://github.com/pytest-dev/pytest-asyncio/pull/620>`_
7
+
This release is backwards-compatible with v0.21.
8
+
Changes are non-breaking, unless you upgrade from v0.22.
9
+
10
+
- BREAKING: The *asyncio_event_loop* mark has been removed. Class-scoped and module-scoped event loops can be requested
11
+
via the *scope* keyword argument to the _asyncio_ mark.
8
12
- Introduces the *event_loop_policy* fixture which allows testing with non-default or multiple event loops `#662 <https://github.com/pytest-dev/pytest-asyncio/pull/662>`_
13
+
- Removes pytest-trio from the test dependencies `#620 <https://github.com/pytest-dev/pytest-asyncio/pull/620>`_
9
14
10
15
0.22.0 (2023-10-31)
11
16
===================
17
+
This release has been yanked from PyPI due to fundamental issues with the _asyncio_event_loop_ mark.
18
+
12
19
- Class-scoped and module-scoped event loops can be requested
13
20
via the _asyncio_event_loop_ mark. `#620 <https://github.com/pytest-dev/pytest-asyncio/pull/620>`_
14
21
- Deprecate redefinition of the `event_loop` fixture. `#587 <https://github.com/pytest-dev/pytest-asyncio/issues/531>`_
Copy file name to clipboardExpand all lines: docs/source/reference/fixtures/index.rst
+2-4
Original file line number
Diff line number
Diff line change
@@ -6,17 +6,15 @@ event_loop
6
6
==========
7
7
Creates a new asyncio event loop based on the current event loop policy. The new loop
8
8
is available as the return value of this fixture for synchronous functions, or via `asyncio.get_running_loop <https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop>`__ for asynchronous functions.
9
-
The event loop is closed when the fixture scope ends. The fixture scope defaults
10
-
to ``function`` scope.
9
+
The event loop is closed when the fixture scope ends.
10
+
The fixture scope defaults to ``function`` scope.
11
11
12
12
.. include:: event_loop_example.py
13
13
:code: python
14
14
15
15
Note that, when using the ``event_loop`` fixture, you need to interact with the event loop using methods like ``event_loop.run_until_complete``. If you want to *await* code inside your test function, you need to write a coroutine and use it as a test function. The `asyncio <#pytest-mark-asyncio>`__ marker
16
16
is used to mark coroutines that should be treated as test functions.
17
17
18
-
If your tests require an asyncio event loop with class or module scope, apply the `asyncio_event_loop mark <./markers.html/#pytest-mark-asyncio-event-loop>`__ to the respective class or module.
19
-
20
18
If you need to change the type of the event loop, prefer setting a custom event loop policy over redefining the ``event_loop`` fixture.
21
19
22
20
If the ``pytest.mark.asyncio`` decorator is applied to a test function, the ``event_loop``
The ``pytest.mark.asyncio`` marker can be omitted entirely in *auto* mode, where the *asyncio* marker is added automatically to *async* test functions.
45
19
46
-
The `asyncio_event_loop` mark supports an optional `policy` keyword argument to set the asyncio event loop policy.
20
+
By default, each test runs in it's own asyncio event loop.
21
+
Multiple tests can share the same event loop by providing a *scope* keyword argument to the *asyncio* mark.
22
+
The following code example provides a shared event loop for all tests in `TestClassScopedLoop`:
Requesting class scope for tests that are not part of a class will give a *UsageError.*
28
+
Similar to class-scoped event loops, a module-scoped loop is provided when setting the asyncio mark's scope to *module:*
51
29
52
-
The ``policy`` keyword argument may also take an iterable of event loop policies. This causes tests under by the `asyncio_event_loop` mark to be parametrized with different policies:
0 commit comments