Skip to content

Commit b5db91a

Browse files
committed
Test async functions using asyncio
Our tests use trio and trio uses outcome. Let’s avoid having a test dependency use the code under test. Fixes #12
1 parent f916e3d commit b5db91a

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

test-requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
pytest
22
pytest-cov
3-
trio; python_version >= '3.5'
4-
pytest-trio; python_version >= '3.5'
3+
pytest-asyncio; python_version >= '3.5'

tests/test_async.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1+
import asyncio
12
import sys
23

34
import pytest
4-
import trio
55
from async_generator import async_generator, yield_
66

77
import outcome
88
from outcome import Error, Value, AlreadyUsedError
99

10-
pytestmark = pytest.mark.trio
10+
pytestmark = pytest.mark.asyncio
1111

1212

1313
async def test_acapture():
1414
async def add(x, y):
15-
await trio.hazmat.checkpoint()
15+
await asyncio.sleep(0)
1616
return x + y
1717

1818
v = await outcome.acapture(add, 3, y=4)
1919
assert v == Value(7)
2020

2121
async def raise_ValueError(x):
22-
await trio.hazmat.checkpoint()
22+
await asyncio.sleep(0)
2323
raise ValueError(x)
2424

2525
e = await outcome.acapture(raise_ValueError, 9)

0 commit comments

Comments
 (0)