diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2b9e03af..373516ee 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -118,7 +118,7 @@ jobs: uses: codecov/codecov-action@v3 with: files: coverage.xml - fail_ci_if_error: true + fail_ci_if_error: false deploy: name: Deploy diff --git a/docs/source/reference/changelog.rst b/docs/source/reference/changelog.rst index f68a63c2..170ba29a 100644 --- a/docs/source/reference/changelog.rst +++ b/docs/source/reference/changelog.rst @@ -2,12 +2,16 @@ Changelog ========= -0.22.0 (UNRELEASED) +0.21.2 (2024-04-29) +=================== +- Fix compatibility with pytest 8.2. Backport of `#800 `_ to pytest-asyncio v0.21 for users who are unable to upgrade to a more recent version (see `#706 `_) + +0.21.1 (2023-07-12) =================== - Output a proper error message when an invalid ``asyncio_mode`` is selected. - Extend warning message about unclosed event loops with additional possible cause. `#531 `_ -- Previously, some tests reported "skipped" or "xfailed" as a result. Now all tests report a "success" results. +- Previously, some tests reported "skipped" or "xfailed" as a result. Now all tests report a "success" result. 0.21.0 (2023-03-19) =================== diff --git a/pytest_asyncio/__init__.py b/pytest_asyncio/__init__.py index 1bc2811d..0f94a517 100644 --- a/pytest_asyncio/__init__.py +++ b/pytest_asyncio/__init__.py @@ -1,4 +1,5 @@ """The main point for importing pytest-asyncio items.""" + from ._version import version as __version__ # noqa from .plugin import fixture diff --git a/pytest_asyncio/plugin.py b/pytest_asyncio/plugin.py index 12669791..919f66e5 100644 --- a/pytest_asyncio/plugin.py +++ b/pytest_asyncio/plugin.py @@ -1,4 +1,5 @@ """pytest-asyncio implementation.""" + import asyncio import contextlib import enum @@ -102,8 +103,7 @@ def fixture( None, ] = ..., name: Optional[str] = ..., -) -> FixtureFunction: - ... +) -> FixtureFunction: ... @overload @@ -119,8 +119,7 @@ def fixture( None, ] = ..., name: Optional[str] = None, -) -> FixtureFunctionMarker: - ... +) -> FixtureFunctionMarker: ... def fixture( @@ -240,7 +239,7 @@ def _add_kwargs( func: Callable[..., Any], kwargs: Dict[str, Any], event_loop: asyncio.AbstractEventLoop, - request: SubRequest, + request: FixtureRequest, ) -> Dict[str, Any]: sig = inspect.signature(func) ret = kwargs.copy() @@ -277,9 +276,8 @@ def _wrap_asyncgen_fixture(fixturedef: FixtureDef) -> None: def _asyncgen_fixture_wrapper( event_loop: asyncio.AbstractEventLoop, request: SubRequest, **kwargs: Any ): - func = _perhaps_rebind_fixture_func( - fixture, request.instance, fixturedef.unittest - ) + unittest = False if pytest.version_tuple >= (8, 2) else fixturedef.unittest + func = _perhaps_rebind_fixture_func(fixture, request.instance, unittest) gen_obj = func(**_add_kwargs(func, kwargs, event_loop, request)) async def setup(): @@ -315,9 +313,8 @@ def _wrap_async_fixture(fixturedef: FixtureDef) -> None: def _async_fixture_wrapper( event_loop: asyncio.AbstractEventLoop, request: SubRequest, **kwargs: Any ): - func = _perhaps_rebind_fixture_func( - fixture, request.instance, fixturedef.unittest - ) + unittest = False if pytest.version_tuple >= (8, 2) else fixturedef.unittest + func = _perhaps_rebind_fixture_func(fixture, request.instance, unittest) async def setup(): res = await func(**_add_kwargs(func, kwargs, event_loop, request)) diff --git a/tests/async_fixtures/test_async_fixtures_scope.py b/tests/async_fixtures/test_async_fixtures_scope.py index 079a981a..a25934a8 100644 --- a/tests/async_fixtures/test_async_fixtures_scope.py +++ b/tests/async_fixtures/test_async_fixtures_scope.py @@ -2,6 +2,7 @@ We support module-scoped async fixtures, but only if the event loop is module-scoped too. """ + import asyncio import pytest diff --git a/tests/hypothesis/test_base.py b/tests/hypothesis/test_base.py index aef20d79..53570102 100644 --- a/tests/hypothesis/test_base.py +++ b/tests/hypothesis/test_base.py @@ -1,6 +1,7 @@ """Tests for the Hypothesis integration, which wraps async functions in a sync shim for Hypothesis. """ + from textwrap import dedent import pytest diff --git a/tests/hypothesis/test_inherited_test.py b/tests/hypothesis/test_inherited_test.py deleted file mode 100644 index a7762264..00000000 --- a/tests/hypothesis/test_inherited_test.py +++ /dev/null @@ -1,20 +0,0 @@ -import hypothesis.strategies as st -import pytest -from hypothesis import given - - -class BaseClass: - @pytest.mark.asyncio - @given(value=st.integers()) - async def test_hypothesis(self, value: int) -> None: - pass - - -class TestOne(BaseClass): - """During the first execution the Hypothesis test - is wrapped in a synchronous function.""" - - -class TestTwo(BaseClass): - """Execute the test a second time to ensure that - the test receives a fresh event loop.""" diff --git a/tests/loop_fixture_scope/test_loop_fixture_scope.py b/tests/loop_fixture_scope/test_loop_fixture_scope.py index 679ab48f..eb4be8c9 100644 --- a/tests/loop_fixture_scope/test_loop_fixture_scope.py +++ b/tests/loop_fixture_scope/test_loop_fixture_scope.py @@ -1,4 +1,5 @@ """Unit tests for overriding the event loop with a larger scoped one.""" + import asyncio import pytest diff --git a/tests/markers/test_class_marker.py b/tests/markers/test_class_marker.py index d46c3af7..220e8d07 100644 --- a/tests/markers/test_class_marker.py +++ b/tests/markers/test_class_marker.py @@ -1,4 +1,5 @@ """Test if pytestmark works when defined on a class.""" + import asyncio import pytest diff --git a/tests/markers/test_module_marker.py b/tests/markers/test_module_marker.py index 2f69dbc9..20952ceb 100644 --- a/tests/markers/test_module_marker.py +++ b/tests/markers/test_module_marker.py @@ -1,4 +1,5 @@ """Test if pytestmark works when defined in a module.""" + import asyncio import pytest diff --git a/tests/multiloop/test_alternative_loops.py b/tests/multiloop/test_alternative_loops.py index 5f66c967..8baac3ac 100644 --- a/tests/multiloop/test_alternative_loops.py +++ b/tests/multiloop/test_alternative_loops.py @@ -1,4 +1,5 @@ """Unit tests for overriding the event loop.""" + import asyncio import pytest diff --git a/tests/test_flaky_integration.py b/tests/test_flaky_integration.py index 54c9d2ea..183daf81 100644 --- a/tests/test_flaky_integration.py +++ b/tests/test_flaky_integration.py @@ -1,5 +1,6 @@ """Tests for the Flaky integration, which retries failed tests. """ + from textwrap import dedent diff --git a/tests/test_simple.py b/tests/test_simple.py index 5e6a0d20..571c0eda 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -1,4 +1,5 @@ """Quick'n'dirty unit tests for provided fixtures and markers.""" + import asyncio from textwrap import dedent diff --git a/tests/test_subprocess.py b/tests/test_subprocess.py index 79c5109d..c813df7d 100644 --- a/tests/test_subprocess.py +++ b/tests/test_subprocess.py @@ -1,4 +1,5 @@ """Tests for using subprocesses in tests.""" + import asyncio.subprocess import sys