Skip to content

Commit 3a350f0

Browse files
committed
refactor: seperate tests
1 parent a111b40 commit 3a350f0

File tree

9 files changed

+25
-3
lines changed

9 files changed

+25
-3
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ jobs:
4444
TWINE_USERNAME: __token__
4545
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} #
4646
run: |
47-
uv run twine upload --verbose --repository testpypi dist/*
47+
uv run twine upload --verbose --repository pypi dist/*
File renamed without changes.
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
import asyncio
2+
import os
3+
import tempfile
24
from typing import cast
35

46
import pytest
7+
import pytest_asyncio
58

69
from uringloop.loop import IouringProactorEventLoop, IouringProactorEventLoopPolicy
710

811

9-
@pytest.fixture(scope="session", autouse=True)
10-
def event_loop_policy():
12+
@pytest_asyncio.fixture(scope="package", autouse=True)
13+
async def event_loop_policy():
1114
asyncio.set_event_loop_policy(IouringProactorEventLoopPolicy())
1215

16+
# TODO: remove pytest_asyncio warning
1317
@pytest.fixture
1418
def event_loop():
1519
loop = asyncio.get_event_loop()
1620
yield cast(IouringProactorEventLoop, loop)
1721
loop.close()
22+
23+
@pytest.fixture
24+
def unix_socket_path():
25+
with tempfile.TemporaryDirectory() as f:
26+
yield os.path.join(f, "test.sock")
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/e2e/conftest.py renamed to tests/e2e/proactor/conftest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@ async def _run_proactor_task():
9191
await asyncio.sleep(0.1)
9292

9393
task = loop.create_task(_run_proactor_task())
94+
95+
def stop_all_coro_if_raise_exception(task: asyncio.Task[None]):
96+
if task.exception(): # If task failed
97+
# Cancel all other tasks
98+
for t in asyncio.all_tasks(loop):
99+
if t != task and not t.done():
100+
t.cancel()
101+
102+
loop.run_until_complete(loop.shutdown_asyncgens())
103+
104+
# Add failure callback
105+
task.add_done_callback(stop_all_coro_if_raise_exception)
106+
94107
yield proactor
95108

96109
# Cleanup
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)