forked from pool/python-pytest-asyncio
Compare commits
11 Commits
Author | SHA256 | Date | |
---|---|---|---|
34f36267e9 | |||
f87ab29d24 | |||
1c51c1b08f | |||
3c40e37133 | |||
d937cf86bd | |||
0d097c0969 | |||
b1fd431cd1 | |||
36d0c84cb6 | |||
7afde0eff5 | |||
24efb77e1a | |||
b1d5daabf2 |
@@ -1,86 +0,0 @@
|
|||||||
From b646cc18a222c8043433c38a42c07245fe9735ce Mon Sep 17 00:00:00 2001
|
|
||||||
From: Michael Seifert <m.seifert@digitalernachschub.de>
|
|
||||||
Date: Sun, 19 May 2024 14:00:57 +0200
|
|
||||||
Subject: [PATCH] [fix] Fixed a bug that causes markers to be duplicated for
|
|
||||||
async test functions.
|
|
||||||
|
|
||||||
Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
|
|
||||||
---
|
|
||||||
docs/source/reference/changelog.rst | 9 ++++++++
|
|
||||||
pytest_asyncio/plugin.py | 3 ++-
|
|
||||||
tests/markers/test_function_scope.py | 31 ++++++++++++++++++++++++++++
|
|
||||||
3 files changed, 42 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/docs/source/reference/changelog.rst b/docs/source/reference/changelog.rst
|
|
||||||
index a55fb9a8..5f0de0a1 100644
|
|
||||||
--- a/docs/source/reference/changelog.rst
|
|
||||||
+++ b/docs/source/reference/changelog.rst
|
|
||||||
@@ -2,6 +2,15 @@
|
|
||||||
Changelog
|
|
||||||
=========
|
|
||||||
|
|
||||||
+0.23.8 (UNRELEASED)
|
|
||||||
+===================
|
|
||||||
+- Fixes a bug that caused duplicate markers in async tests `#813 <https://github.com/pytest-dev/pytest-asyncio/issues/813>`_
|
|
||||||
+
|
|
||||||
+Known issues
|
|
||||||
+------------
|
|
||||||
+As of v0.23, pytest-asyncio attaches an asyncio event loop to each item of the test suite (i.e. session, packages, modules, classes, functions) and allows tests to be run in those loops when marked accordingly. Pytest-asyncio currently assumes that async fixture scope is correlated with the new event loop scope. This prevents fixtures from being evaluated independently from the event loop scope and breaks some existing test suites (see `#706`_). For example, a test suite may require all fixtures and tests to run in the same event loop, but have async fixtures that are set up and torn down for each module. If you're affected by this issue, please continue using the v0.21 release, until it is resolved.
|
|
||||||
+
|
|
||||||
+
|
|
||||||
0.23.7 (2024-05-19)
|
|
||||||
===================
|
|
||||||
- Silence deprecation warnings about unclosed event loops that occurred with certain CPython patch releases `#817 <https://github.com/pytest-dev/pytest-asyncio/pull/817>`_
|
|
||||||
diff --git a/pytest_asyncio/plugin.py b/pytest_asyncio/plugin.py
|
|
||||||
index cd4c4ede..d3d1fcf7 100644
|
|
||||||
--- a/pytest_asyncio/plugin.py
|
|
||||||
+++ b/pytest_asyncio/plugin.py
|
|
||||||
@@ -405,7 +405,8 @@ def _from_function(cls, function: Function, /) -> Function:
|
|
||||||
keywords=function.keywords,
|
|
||||||
originalname=function.originalname,
|
|
||||||
)
|
|
||||||
- subclass_instance.own_markers.extend(function.own_markers)
|
|
||||||
+ subclass_instance.own_markers = function.own_markers
|
|
||||||
+ assert subclass_instance.own_markers == function.own_markers
|
|
||||||
subclassed_function_signature = inspect.signature(subclass_instance.obj)
|
|
||||||
if "event_loop" in subclassed_function_signature.parameters:
|
|
||||||
subclass_instance.warn(
|
|
||||||
diff --git a/tests/markers/test_function_scope.py b/tests/markers/test_function_scope.py
|
|
||||||
index 2057a128..eded4552 100644
|
|
||||||
--- a/tests/markers/test_function_scope.py
|
|
||||||
+++ b/tests/markers/test_function_scope.py
|
|
||||||
@@ -197,3 +197,34 @@ async def test_anything():
|
|
||||||
)
|
|
||||||
result = pytester.runpytest_subprocess("--asyncio-mode=strict")
|
|
||||||
result.assert_outcomes(warnings=0, passed=1)
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+def test_asyncio_mark_does_not_duplicate_other_marks_in_auto_mode(
|
|
||||||
+ pytester: Pytester,
|
|
||||||
+):
|
|
||||||
+ pytester.makeconftest(
|
|
||||||
+ dedent(
|
|
||||||
+ """\
|
|
||||||
+ def pytest_configure(config):
|
|
||||||
+ config.addinivalue_line(
|
|
||||||
+ "markers", "dummy_marker: mark used for testing purposes"
|
|
||||||
+ )
|
|
||||||
+ """
|
|
||||||
+ )
|
|
||||||
+ )
|
|
||||||
+ pytester.makepyfile(
|
|
||||||
+ dedent(
|
|
||||||
+ """\
|
|
||||||
+ import pytest
|
|
||||||
+
|
|
||||||
+ @pytest.mark.dummy_marker
|
|
||||||
+ async def test_markers_not_duplicated(request):
|
|
||||||
+ markers = []
|
|
||||||
+ for node, marker in request.node.iter_markers_with_node():
|
|
||||||
+ markers.append(marker)
|
|
||||||
+ assert len(markers) == 2
|
|
||||||
+ """
|
|
||||||
+ )
|
|
||||||
+ )
|
|
||||||
+ result = pytester.runpytest_subprocess("--asyncio-mode=auto")
|
|
||||||
+ result.assert_outcomes(warnings=0, passed=1)
|
|
BIN
pytest-asyncio-0.23.7.tar.gz
(Stored with Git LFS)
BIN
pytest-asyncio-0.23.7.tar.gz
(Stored with Git LFS)
Binary file not shown.
3
pytest-asyncio-1.0.0.tar.gz
Normal file
3
pytest-asyncio-1.0.0.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:fd0235c0c60badfb2f845942d19c54ce0280d1cea073ec1ec36037321c900fd8
|
||||||
|
size 45557
|
78
pytest84.patch
Normal file
78
pytest84.patch
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
From 8c6612fda96f78a1df2f0d271426b7b6e3c10737 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Yao Zi <ziyao@disroot.org>
|
||||||
|
Date: Tue, 10 Jun 2025 16:17:11 +0000
|
||||||
|
Subject: [PATCH] test: Adapt unmarked async tests in strict mode for pytest
|
||||||
|
8.4.0
|
||||||
|
|
||||||
|
Async tests fail instead of skipping and warning with Pytest 8.4.0 if
|
||||||
|
no suitable async plugin is installed[1]. Adjust expectation of these
|
||||||
|
tests to pass the testsuite with Pytest 8.4.0.
|
||||||
|
|
||||||
|
Link: https://docs.pytest.org/en/stable/changelog.html#pytest-8-4-0-2025-06-02 # [1]
|
||||||
|
Signed-off-by: Yao Zi <ziyao@disroot.org>
|
||||||
|
---
|
||||||
|
tests/modes/test_strict_mode.py | 23 ++++++++++++++++++-----
|
||||||
|
1 file changed, 18 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/tests/modes/test_strict_mode.py b/tests/modes/test_strict_mode.py
|
||||||
|
index 52cbb251..44f54b7d 100644
|
||||||
|
--- a/tests/modes/test_strict_mode.py
|
||||||
|
+++ b/tests/modes/test_strict_mode.py
|
||||||
|
@@ -2,7 +2,7 @@
|
||||||
|
|
||||||
|
from textwrap import dedent
|
||||||
|
|
||||||
|
-from pytest import Pytester
|
||||||
|
+from pytest import Pytester, version_tuple as pytest_version
|
||||||
|
|
||||||
|
|
||||||
|
def test_strict_mode_cmdline(pytester: Pytester):
|
||||||
|
@@ -95,7 +95,10 @@ async def test_anything():
|
||||||
|
)
|
||||||
|
)
|
||||||
|
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
|
||||||
|
- result.assert_outcomes(skipped=1, warnings=1)
|
||||||
|
+ if pytest_version >= (8, 4, 0):
|
||||||
|
+ result.assert_outcomes(failed=1, skipped=0, warnings=0)
|
||||||
|
+ else:
|
||||||
|
+ result.assert_outcomes(skipped=1, warnings=1)
|
||||||
|
result.stdout.fnmatch_lines(["*async def functions are not natively supported*"])
|
||||||
|
|
||||||
|
|
||||||
|
@@ -117,7 +120,11 @@ async def test_anything(any_fixture):
|
||||||
|
)
|
||||||
|
)
|
||||||
|
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
|
||||||
|
- result.assert_outcomes(skipped=1, warnings=2)
|
||||||
|
+
|
||||||
|
+ if pytest_version >= (8, 4, 0):
|
||||||
|
+ result.assert_outcomes(failed=1, skipped=0, warnings=2)
|
||||||
|
+ else:
|
||||||
|
+ result.assert_outcomes(skipped=1, warnings=2)
|
||||||
|
result.stdout.fnmatch_lines(
|
||||||
|
[
|
||||||
|
"*async def functions are not natively supported*",
|
||||||
|
@@ -149,7 +156,10 @@ async def test_anything(any_fixture):
|
||||||
|
)
|
||||||
|
)
|
||||||
|
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
|
||||||
|
- result.assert_outcomes(passed=1, failed=0, skipped=0, warnings=1)
|
||||||
|
+ if pytest_version >= (8, 4, 0):
|
||||||
|
+ result.assert_outcomes(passed=1, failed=0, skipped=0, warnings=2)
|
||||||
|
+ else:
|
||||||
|
+ result.assert_outcomes(passed=1, failed=0, skipped=0, warnings=1)
|
||||||
|
result.stdout.fnmatch_lines(
|
||||||
|
[
|
||||||
|
"*warnings summary*",
|
||||||
|
@@ -193,7 +203,10 @@ async def test_anything(any_fixture):
|
||||||
|
)
|
||||||
|
)
|
||||||
|
result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W default")
|
||||||
|
- result.assert_outcomes(passed=1, warnings=1)
|
||||||
|
+ if pytest_version >= (8, 4, 0):
|
||||||
|
+ result.assert_outcomes(passed=1, warnings=2)
|
||||||
|
+ else:
|
||||||
|
+ result.assert_outcomes(passed=1, warnings=1)
|
||||||
|
result.stdout.fnmatch_lines(
|
||||||
|
[
|
||||||
|
"*warnings summary*",
|
@@ -1,3 +1,107 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Jun 20 12:27:13 UTC 2025 - Markéta Machová <mmachova@suse.com>
|
||||||
|
|
||||||
|
- Add upstream pytest84.patch for compatibility with pytest 8.4.0
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue May 27 11:12:52 UTC 2025 - Johannes Kastl <opensuse_buildservice@ojkastl.de>
|
||||||
|
|
||||||
|
- update to 1.0.0:
|
||||||
|
https://github.com/pytest-dev/pytest-asyncio/releases/tag/v1.0.0
|
||||||
|
* Removed
|
||||||
|
- The deprecated event_loop fixture.
|
||||||
|
(#1106)
|
||||||
|
* Added
|
||||||
|
- Prelimiary support for Python 3.14
|
||||||
|
(#1025)
|
||||||
|
* Changed
|
||||||
|
+ Scoped event loops (e.g. module-scoped loops) are created
|
||||||
|
once rather than per scope (e.g. per module). This reduces
|
||||||
|
the number of fixtures and speeds up collection time,
|
||||||
|
especially for large test suites.
|
||||||
|
(#1107)
|
||||||
|
* The loop_scope argument to pytest.mark.asyncio no longer
|
||||||
|
forces that a pytest Collector exists at the level of the
|
||||||
|
specified scope. For example, a test function marked with
|
||||||
|
pytest.mark.asyncio(loop_scope="class") no longer requires a
|
||||||
|
class surrounding the test. This is consistent with the
|
||||||
|
behavior of the scope argument to pytest_asyncio.fixture.
|
||||||
|
(#1112)
|
||||||
|
* Fixed
|
||||||
|
* An error caused when using pytest's
|
||||||
|
[--setup-plan]{.title-ref} option.
|
||||||
|
(#630)
|
||||||
|
* Unsuppressed import errors with pytest option
|
||||||
|
--doctest-ignore-import-errors
|
||||||
|
(#797)
|
||||||
|
* A "fixture not found" error in connection with package-scoped
|
||||||
|
loops
|
||||||
|
(#1052)
|
||||||
|
* Notes for Downstream Packagers
|
||||||
|
* Removed a test that had an ordering dependency on other
|
||||||
|
tests.
|
||||||
|
(#1114)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Apr 28 14:19:40 UTC 2025 - Dirk Müller <dmueller@suse.com>
|
||||||
|
|
||||||
|
- update to 0.26.0:
|
||||||
|
* Adds configuration option that sets default event loop scope
|
||||||
|
for all tests #793
|
||||||
|
* Improved type annotations for pytest_asyncio.fixture #1045
|
||||||
|
* Added typing-extensions as additional dependency for Python
|
||||||
|
<3.10 #1045
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Mar 5 12:37:11 UTC 2025 - Johannes Kastl <opensuse_buildservice@ojkastl.de>
|
||||||
|
|
||||||
|
- update to 0.25.3:
|
||||||
|
* Avoid errors in cleanup of async generators when event loop is
|
||||||
|
already closed #1040
|
||||||
|
- update to 0.25.2:
|
||||||
|
* Call loop.shutdown_asyncgens() before closing the event loop to
|
||||||
|
ensure async generators are closed in the same manner as
|
||||||
|
asyncio.run does #1034
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Jan 3 09:12:39 UTC 2025 - Johannes Kastl <opensuse_buildservice@ojkastl.de>
|
||||||
|
|
||||||
|
- update to 0.25.1:
|
||||||
|
* Fixes an issue that caused a broken event loop when a
|
||||||
|
function-scoped test was executed in between two tests with
|
||||||
|
wider loop scope #950
|
||||||
|
* Improves test collection speed in auto mode #1020
|
||||||
|
* Corrects the warning that is emitted upon redefining the
|
||||||
|
event_loop fixture
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Jan 3 09:10:08 UTC 2025 - Johannes Kastl <opensuse_buildservice@ojkastl.de>
|
||||||
|
|
||||||
|
- Update to 0.25.0:
|
||||||
|
* Deprecated: Added warning when asyncio test requests async
|
||||||
|
@pytest.fixture in strict mode. This will become an error in a
|
||||||
|
future version of flake8-asyncio. #979
|
||||||
|
* Updates the error message about pytest.mark.asyncio's scope
|
||||||
|
keyword argument to say loop_scope instead. #1004
|
||||||
|
* Verbose log displays correct parameter name:
|
||||||
|
asyncio_default_fixture_loop_scope #990
|
||||||
|
* Propagates contextvars set in async fixtures to other fixtures
|
||||||
|
and tests on Python 3.11 and above. #1008
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Oct 8 15:42:52 UTC 2024 - Markéta Machová <mmachova@suse.com>
|
||||||
|
|
||||||
|
- Update to 0.24.0
|
||||||
|
* BREAKING: Updated minimum supported pytest version to v8.2.0
|
||||||
|
* Adds an optional loop_scope keyword argument to pytest.mark.asyncio.
|
||||||
|
* Deprecates the optional scope keyword argument to pytest.mark.asyncio
|
||||||
|
for API consistency with pytest_asyncio.fixture.
|
||||||
|
* Fixes a bug that caused module-scoped async fixtures to fail when
|
||||||
|
reused in other modules
|
||||||
|
* Fixes a bug that caused duplicate markers in async tests
|
||||||
|
* Declare support for Python 3.13
|
||||||
|
- Drop merged duplicated-markers.patch
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Jul 9 13:43:10 UTC 2024 - Markéta Machová <mmachova@suse.com>
|
Tue Jul 9 13:43:10 UTC 2024 - Markéta Machová <mmachova@suse.com>
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package python-pytest-asyncio
|
# spec file for package python-pytest-asyncio
|
||||||
#
|
#
|
||||||
# Copyright (c) 2024 SUSE LLC
|
# Copyright (c) 2025 SUSE LLC
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
@@ -26,14 +26,14 @@
|
|||||||
%endif
|
%endif
|
||||||
%{?sle15_python_module_pythons}
|
%{?sle15_python_module_pythons}
|
||||||
Name: python-pytest-asyncio%{psuffix}
|
Name: python-pytest-asyncio%{psuffix}
|
||||||
Version: 0.23.7
|
Version: 1.0.0
|
||||||
Release: 0
|
Release: 0
|
||||||
Summary: Pytest support for asyncio
|
Summary: Pytest support for asyncio
|
||||||
License: Apache-2.0
|
License: Apache-2.0
|
||||||
URL: https://github.com/pytest-dev/pytest-asyncio
|
URL: https://github.com/pytest-dev/pytest-asyncio
|
||||||
Source: https://github.com/pytest-dev/pytest-asyncio/archive/v%{version}.tar.gz#/pytest-asyncio-%{version}.tar.gz
|
Source: https://github.com/pytest-dev/pytest-asyncio/archive/v%{version}.tar.gz#/pytest-asyncio-%{version}.tar.gz
|
||||||
# PATCH-FIX-UPSTREAM https://github.com/pytest-dev/pytest-asyncio/pull/838 Fix duplication of markers in async tests
|
# PATCH-FIX-UPSTREAM https://github.com/pytest-dev/pytest-asyncio/commit/8c6612fda96f78a1df2f0d271426b7b6e3c10737 test: Adapt unmarked async tests in strict mode for pytest 8.4.0
|
||||||
Patch: duplicated-markers.patch
|
Patch0: pytest84.patch
|
||||||
BuildRequires: %{python_module base >= 3.8}
|
BuildRequires: %{python_module base >= 3.8}
|
||||||
BuildRequires: %{python_module pip}
|
BuildRequires: %{python_module pip}
|
||||||
BuildRequires: %{python_module setuptools_scm}
|
BuildRequires: %{python_module setuptools_scm}
|
||||||
@@ -41,14 +41,10 @@ BuildRequires: %{python_module setuptools}
|
|||||||
BuildRequires: %{python_module wheel}
|
BuildRequires: %{python_module wheel}
|
||||||
BuildRequires: fdupes
|
BuildRequires: fdupes
|
||||||
BuildRequires: python-rpm-macros
|
BuildRequires: python-rpm-macros
|
||||||
Requires: (python-pytest >= 7.0.0 with python-pytest < 9)
|
Requires: (python-pytest >= 8.2.0 with python-pytest < 9)
|
||||||
%if 0%{?python_version_nodots} < 38
|
|
||||||
Requires: python-typing-extensions >= 3.7.2
|
|
||||||
%endif
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
%if %{with test}
|
%if %{with test}
|
||||||
BuildRequires: %{python_module hypothesis >= 5.7.1}
|
BuildRequires: %{python_module hypothesis >= 5.7.1}
|
||||||
BuildRequires: %{python_module pytest >= 7.0.0 with %python-pytest < 9}
|
|
||||||
BuildRequires: %{python_module pytest-asyncio = %{version}}
|
BuildRequires: %{python_module pytest-asyncio = %{version}}
|
||||||
%endif
|
%endif
|
||||||
%python_subpackages
|
%python_subpackages
|
||||||
|
Reference in New Issue
Block a user