Skip to content

Commit 2ce13b9

Browse files
committed
Fixed a regression in the pytest plugin that broke parametrized async fixtures
1 parent 4ecc963 commit 2ce13b9

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

docs/versionhistory.rst

+18
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@ Version history
33

44
This library adheres to `Semantic Versioning 2.0 <http://semver.org/>`_.
55

6+
**UNRELEASED**
7+
8+
- Fixed regression caused by (`#807 <https://github.com/agronholm/anyio/pull/807>`_)
9+
that prevented the use of parametrized async fixtures.
10+
11+
**4.6.1**
12+
13+
This release contains all the changes from both v4.5.1 and v4.6.0, plus:
14+
15+
- Fixed TaskGroup and CancelScope producing cyclic references in tracebacks
16+
when raising exceptions (`#806 <https://github.com/agronholm/anyio/pull/806>`_)
17+
(PR by @graingert)
18+
619
**4.6.0**
720

821
This release is the successor to v4.5.0 with Python 3.8 support dropped, and does not
@@ -22,6 +35,11 @@ contain the changes from v4.5.1.
2235
- Fixed inconsistent task uncancellation with asyncio cancel scopes belonging to a
2336
task group when said task group has child tasks running
2437

38+
**4.5.2**
39+
40+
- Fixed regression caused by (`#807 <https://github.com/agronholm/anyio/pull/807>`_)
41+
that prevented the use of parametrized async fixtures.
42+
2543
**4.5.1**
2644

2745
As Python 3.8 support was dropped in v4.6.0, this interim release was created to bring a

src/anyio/pytest_plugin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def wrapper(
9191
kwargs["anyio_backend"] = anyio_backend
9292

9393
if has_request_arg:
94-
kwargs["request"] = anyio_backend
94+
kwargs["request"] = request
9595

9696
with get_runner(backend_name, backend_options) as runner:
9797
if isasyncgenfunction(local_func):

tests/test_pytest_plugin.py

+20
Original file line numberDiff line numberDiff line change
@@ -541,3 +541,23 @@ def test_no_mark(fixt):
541541

542542
result = testdir.runpytest(*pytest_args)
543543
result.assert_outcomes(passed=len(get_all_backends()) + 1)
544+
545+
546+
def test_async_fixture_params(testdir: Pytester) -> None:
547+
testdir.makepyfile(
548+
"""
549+
import inspect
550+
import pytest
551+
552+
@pytest.fixture(params=[1, 2])
553+
async def fixt(request):
554+
return request.param
555+
556+
@pytest.mark.anyio
557+
async def test_params(fixt):
558+
assert fixt in (1, 2)
559+
"""
560+
)
561+
562+
result = testdir.runpytest(*pytest_args)
563+
result.assert_outcomes(passed=len(get_all_backends()) * 2)

0 commit comments

Comments
 (0)