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 445e59e commit fb81dfe
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/versionhistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ 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:
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 fb81dfe

Please sign in to comment.