Skip to content

Commit

Permalink
Fixed a regression in the pytest plugin that broke parametrized async…
Browse files Browse the repository at this point in the history
… fixtures
  • Loading branch information
agronholm committed Oct 13, 2024
1 parent 4ecc963 commit f6ddfc8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
18 changes: 18 additions & 0 deletions docs/versionhistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ Version history

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

**UNRELEASED**

- Fixed regression caused by (`#807 <https://github.com/agronholm/anyio/pull/807>`_)
that prevented the use of parametrized async fixtures

**4.6.1**

This release contains all the changes from both v4.5.1 and v4.6.0, plus:

- Fixed TaskGroup and CancelScope producing cyclic references in tracebacks
when raising exceptions (`#806 <https://github.com/agronholm/anyio/pull/806>`_)
(PR by @graingert)

**4.6.0**

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

**UNRELEASED**

- Fixed regression caused by (`#807 <https://github.com/agronholm/anyio/pull/807>`_)
that prevented the use of parametrized async fixtures

**4.5.1**

As Python 3.8 support was dropped in v4.6.0, this interim release was created to bring a
Expand Down
2 changes: 1 addition & 1 deletion src/anyio/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def wrapper(
kwargs["anyio_backend"] = anyio_backend

if has_request_arg:
kwargs["request"] = anyio_backend
kwargs["request"] = request

with get_runner(backend_name, backend_options) as runner:
if isasyncgenfunction(local_func):
Expand Down
20 changes: 20 additions & 0 deletions tests/test_pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,3 +541,23 @@ def test_no_mark(fixt):

result = testdir.runpytest(*pytest_args)
result.assert_outcomes(passed=len(get_all_backends()) + 1)


def test_async_fixture_params(testdir: Pytester) -> None:
testdir.makepyfile(
"""
import inspect
import pytest
@pytest.fixture(params=[1, 2])
async def fixt(request):
return request.param
@pytest.mark.anyio
async def test_params(fixt):
assert fixt in (1, 2)
"""
)

result = testdir.runpytest(*pytest_args)
result.assert_outcomes(passed=len(get_all_backends()) * 2)

0 comments on commit f6ddfc8

Please sign in to comment.