Skip to content
This repository was archived by the owner on Jul 10, 2026. It is now read-only.

Commit a14537f

Browse files
authored
Merge pull request #3340 from latent-to/fix/thewhaleking/pytest-asyncio-1.0
Should fix the change to pytest-asyncio 1.3
2 parents b5a555e + a49ef55 commit a14537f

2 files changed

Lines changed: 1 addition & 22 deletions

File tree

tests/e2e_tests/conftest.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import asyncio
2-
import contextlib
31
import os
42
import re
53
import shlex
@@ -328,23 +326,3 @@ def log_test_start_and_end(request):
328326
logging.console.info(f"🏁[green]Testing[/green] [yellow]{test_name}[/yellow]")
329327
yield
330328
logging.console.success(f"✅ [green]Finished[/green] [yellow]{test_name}[/yellow]")
331-
332-
333-
@pytest_asyncio.fixture(scope="session")
334-
def event_loop():
335-
"""Create an instance of the default event loop for each test case and close all alive tasks at the end."""
336-
loop = asyncio.get_event_loop()
337-
yield loop
338-
339-
# 1) cance all alive tasks
340-
pending = [t for t in asyncio.all_tasks(loop) if not t.done()]
341-
for t in pending:
342-
t.cancel()
343-
with contextlib.suppress(Exception):
344-
loop.run_until_complete(asyncio.gather(*pending, return_exceptions=True))
345-
346-
# 2) cleanup async generators
347-
with contextlib.suppress(Exception):
348-
loop.run_until_complete(loop.shutdown_asyncgens())
349-
350-
loop.close()

tests/pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[pytest]
22
filterwarnings = ignore::DeprecationWarning:pkg_resources.*:
33
asyncio_default_fixture_loop_scope = session
4+
asyncio_default_test_loop_scope = session
45
addopts = -s

0 commit comments

Comments
 (0)