pytest-asyncio 0.25.2__tar.gz → 0.25.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/PKG-INFO +2 -2
  2. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/changelog.rst +6 -1
  3. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/pytest_asyncio/_version.py +2 -2
  4. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/pytest_asyncio/plugin.py +8 -4
  5. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/pytest_asyncio.egg-info/PKG-INFO +2 -2
  6. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/test_event_loop_fixture.py +58 -0
  7. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/.readthedocs.yaml +0 -0
  8. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/LICENSE +0 -0
  9. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/MANIFEST.in +0 -0
  10. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/Makefile +0 -0
  11. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/README.rst +0 -0
  12. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/SECURITY.rst +0 -0
  13. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/dependencies/default/constraints.txt +0 -0
  14. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/dependencies/default/requirements.txt +0 -0
  15. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/dependencies/docs/constraints.txt +0 -0
  16. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/dependencies/docs/requirements.txt +0 -0
  17. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/dependencies/pytest-min/constraints.txt +0 -0
  18. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/dependencies/pytest-min/requirements.txt +0 -0
  19. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/concepts.rst +0 -0
  20. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/concepts_function_scope_example.py +0 -0
  21. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/concepts_module_scope_example.py +0 -0
  22. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/conf.py +0 -0
  23. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/change_default_fixture_loop.rst +0 -0
  24. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/change_fixture_loop.rst +0 -0
  25. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/change_fixture_loop_example.py +0 -0
  26. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/class_scoped_loop_example.py +0 -0
  27. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/index.rst +0 -0
  28. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/migrate_from_0_21.rst +0 -0
  29. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/migrate_from_0_23.rst +0 -0
  30. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/module_scoped_loop_example.py +0 -0
  31. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/multiple_loops.rst +0 -0
  32. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/multiple_loops_example.py +0 -0
  33. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/package_scoped_loop_example.py +0 -0
  34. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/run_class_tests_in_same_loop.rst +0 -0
  35. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/run_module_tests_in_same_loop.rst +0 -0
  36. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/run_package_tests_in_same_loop.rst +0 -0
  37. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/run_session_tests_in_same_loop.rst +0 -0
  38. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/session_scoped_loop_example.py +0 -0
  39. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/test_item_is_async.rst +0 -0
  40. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/test_item_is_async_example.py +0 -0
  41. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/test_session_scoped_loop_example.py +0 -0
  42. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/how-to-guides/uvloop.rst +0 -0
  43. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/index.rst +0 -0
  44. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/configuration.rst +0 -0
  45. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/decorators/index.rst +0 -0
  46. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/decorators/pytest_asyncio_fixture_example.py +0 -0
  47. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/fixtures/event_loop_example.py +0 -0
  48. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/fixtures/event_loop_policy_example.py +0 -0
  49. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/fixtures/event_loop_policy_parametrized_example.py +0 -0
  50. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/fixtures/index.rst +0 -0
  51. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/functions.rst +0 -0
  52. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/index.rst +0 -0
  53. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/markers/class_scoped_loop_custom_policies_strict_mode_example.py +0 -0
  54. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/markers/class_scoped_loop_strict_mode_example.py +0 -0
  55. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/markers/class_scoped_loop_with_fixture_strict_mode_example.py +0 -0
  56. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/markers/function_scoped_loop_pytestmark_strict_mode_example.py +0 -0
  57. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/markers/function_scoped_loop_strict_mode_example.py +0 -0
  58. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/markers/index.rst +0 -0
  59. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/reference/markers/module_scoped_loop_strict_mode_example.py +0 -0
  60. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/docs/support.rst +0 -0
  61. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/pyproject.toml +0 -0
  62. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/pytest_asyncio/__init__.py +0 -0
  63. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/pytest_asyncio/py.typed +0 -0
  64. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/pytest_asyncio.egg-info/SOURCES.txt +0 -0
  65. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/pytest_asyncio.egg-info/dependency_links.txt +0 -0
  66. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/pytest_asyncio.egg-info/entry_points.txt +0 -0
  67. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/pytest_asyncio.egg-info/requires.txt +0 -0
  68. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/pytest_asyncio.egg-info/top_level.txt +0 -0
  69. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/setup.cfg +0 -0
  70. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/__init__.py +0 -0
  71. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/async_fixtures/__init__.py +0 -0
  72. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/async_fixtures/test_async_fixtures.py +0 -0
  73. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/async_fixtures/test_async_fixtures_contextvars.py +0 -0
  74. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/async_fixtures/test_async_fixtures_scope.py +0 -0
  75. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/async_fixtures/test_async_fixtures_with_finalizer.py +0 -0
  76. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/async_fixtures/test_async_gen_fixtures.py +0 -0
  77. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/async_fixtures/test_nested.py +0 -0
  78. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/async_fixtures/test_parametrized_loop.py +0 -0
  79. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/async_fixtures/test_shared_module_fixture.py +0 -0
  80. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/conftest.py +0 -0
  81. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/hypothesis/__init__.py +0 -0
  82. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/hypothesis/test_base.py +0 -0
  83. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/loop_fixture_scope/__init__.py +0 -0
  84. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/loop_fixture_scope/conftest.py +0 -0
  85. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/loop_fixture_scope/test_loop_fixture_scope.py +0 -0
  86. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/markers/__init__.py +0 -0
  87. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/markers/test_class_scope.py +0 -0
  88. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/markers/test_function_scope.py +0 -0
  89. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/markers/test_invalid_arguments.py +0 -0
  90. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/markers/test_mixed_scope.py +0 -0
  91. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/markers/test_module_scope.py +0 -0
  92. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/markers/test_package_scope.py +0 -0
  93. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/markers/test_session_scope.py +0 -0
  94. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/modes/__init__.py +0 -0
  95. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/modes/test_auto_mode.py +0 -0
  96. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/modes/test_strict_mode.py +0 -0
  97. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/test_asyncio_fixture.py +0 -0
  98. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/test_asyncio_mark.py +0 -0
  99. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/test_dependent_fixtures.py +0 -0
  100. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/test_doctest.py +0 -0
  101. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/test_event_loop_fixture_finalizer.py +0 -0
  102. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/test_event_loop_fixture_override_deprecation.py +0 -0
  103. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/test_explicit_event_loop_fixture_request.py +0 -0
  104. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/test_fixture_loop_scopes.py +0 -0
  105. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/test_import.py +0 -0
  106. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/test_is_async_test.py +0 -0
  107. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/test_multiloop.py +0 -0
  108. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/test_port_factories.py +0 -0
  109. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/test_simple.py +0 -0
  110. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/test_skips.py +0 -0
  111. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tests/test_subprocess.py +0 -0
  112. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tools/get-version.py +0 -0
  113. {pytest_asyncio-0.25.2 → pytest_asyncio-0.25.3}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: pytest-asyncio
3
- Version: 0.25.2
3
+ Version: 0.25.3
4
4
  Summary: Pytest support for asyncio
5
5
  Author-email: "Tin Tvrtković <tinchester@gmail.com>" <tinchester@gmail.com>
6
6
  License: Apache 2.0
@@ -2,11 +2,17 @@
2
2
  Changelog
3
3
  =========
4
4
 
5
+ 0.25.3 (2025-01-28)
6
+ ===================
7
+ - Avoid errors in cleanup of async generators when event loop is already closed `#1040 <https://github.com/pytest-dev/pytest-asyncio/issues/1040>`_
8
+
9
+
5
10
  0.25.2 (2025-01-08)
6
11
  ===================
7
12
 
8
13
  - Call ``loop.shutdown_asyncgens()`` before closing the event loop to ensure async generators are closed in the same manner as ``asyncio.run`` does `#1034 <https://github.com/pytest-dev/pytest-asyncio/pull/1034>`_
9
14
 
15
+
10
16
  0.25.1 (2025-01-02)
11
17
  ===================
12
18
  - 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 <https://github.com/pytest-dev/pytest-asyncio/issues/950>`_
@@ -22,7 +28,6 @@ Changelog
22
28
  - Propagates `contextvars` set in async fixtures to other fixtures and tests on Python 3.11 and above. `#1008 <https://github.com/pytest-dev/pytest-asyncio/pull/1008>`_
23
29
 
24
30
 
25
-
26
31
  0.24.0 (2024-08-22)
27
32
  ===================
28
33
  - BREAKING: Updated minimum supported pytest version to v8.2.0
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.25.2'
16
- __version_tuple__ = version_tuple = (0, 25, 2)
15
+ __version__ = version = '0.25.3'
16
+ __version_tuple__ = version_tuple = (0, 25, 3)
@@ -1164,10 +1164,14 @@ def _provide_event_loop() -> Iterator[asyncio.AbstractEventLoop]:
1164
1164
  try:
1165
1165
  yield loop
1166
1166
  finally:
1167
- try:
1168
- loop.run_until_complete(loop.shutdown_asyncgens())
1169
- finally:
1170
- loop.close()
1167
+ # cleanup the event loop if it hasn't been cleaned up already
1168
+ if not loop.is_closed():
1169
+ try:
1170
+ loop.run_until_complete(loop.shutdown_asyncgens())
1171
+ except Exception as e:
1172
+ warnings.warn(f"Error cleaning up asyncio loop: {e}", RuntimeWarning)
1173
+ finally:
1174
+ loop.close()
1171
1175
 
1172
1176
 
1173
1177
  @pytest.fixture(scope="session")
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: pytest-asyncio
3
- Version: 0.25.2
3
+ Version: 0.25.3
4
4
  Summary: Pytest support for asyncio
5
5
  Author-email: "Tin Tvrtković <tinchester@gmail.com>" <tinchester@gmail.com>
6
6
  License: Apache 2.0
@@ -80,3 +80,61 @@ def test_event_loop_fixture_handles_unclosed_async_gen(
80
80
  )
81
81
  result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W", "default")
82
82
  result.assert_outcomes(passed=1, warnings=0)
83
+
84
+
85
+ def test_event_loop_already_closed(
86
+ pytester: Pytester,
87
+ ):
88
+ pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
89
+ pytester.makepyfile(
90
+ dedent(
91
+ """\
92
+ import asyncio
93
+ import pytest
94
+ import pytest_asyncio
95
+ pytest_plugins = 'pytest_asyncio'
96
+
97
+ @pytest_asyncio.fixture
98
+ async def _event_loop():
99
+ return asyncio.get_running_loop()
100
+
101
+ @pytest.fixture
102
+ def cleanup_after(_event_loop):
103
+ yield
104
+ # fixture has its own cleanup code
105
+ _event_loop.close()
106
+
107
+ @pytest.mark.asyncio
108
+ async def test_something(cleanup_after):
109
+ await asyncio.sleep(0.01)
110
+ """
111
+ )
112
+ )
113
+ result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W", "default")
114
+ result.assert_outcomes(passed=1, warnings=0)
115
+
116
+
117
+ def test_event_loop_fixture_asyncgen_error(
118
+ pytester: Pytester,
119
+ ):
120
+ pytester.makeini("[pytest]\nasyncio_default_fixture_loop_scope = function")
121
+ pytester.makepyfile(
122
+ dedent(
123
+ """\
124
+ import asyncio
125
+ import pytest
126
+
127
+ pytest_plugins = 'pytest_asyncio'
128
+
129
+ @pytest.mark.asyncio
130
+ async def test_something():
131
+ # mock shutdown_asyncgen failure
132
+ loop = asyncio.get_running_loop()
133
+ async def fail():
134
+ raise RuntimeError("mock error cleaning up...")
135
+ loop.shutdown_asyncgens = fail
136
+ """
137
+ )
138
+ )
139
+ result = pytester.runpytest_subprocess("--asyncio-mode=strict", "-W", "default")
140
+ result.assert_outcomes(passed=1, warnings=1)
File without changes
File without changes