Skip to content

Commit e2756cb

Browse files
authored
Test suite: add pytest-asyncio to enable async tests (#42)
Add pytest-asyncio to make sure async test methods are not skipped.
1 parent d63aed2 commit e2756cb

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

test/test_async.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
# NOTE: Testing keys https://opencagedata.com/api#testingkeys
88

9+
@pytest.mark.asyncio
910
async def test_success():
1011
async with OpenCageGeocode('6d0e711d72d74daeb2b0bfd2a5cdfdba') as geocoder:
1112
results = await geocoder.geocode_async("EC1M 5RF")
@@ -15,13 +16,15 @@ async def test_success():
1516
for result in results
1617
)
1718

19+
@pytest.mark.asyncio
1820
async def test_failure():
1921
async with OpenCageGeocode('6c79ee8e1ca44ad58ad1fc493ba9542f') as geocoder:
2022
with pytest.raises(ForbiddenError) as excinfo:
2123
await geocoder.geocode_async("Atlantis")
2224

2325
assert str(excinfo.value) == 'Your API key has been blocked or suspended.'
2426

27+
@pytest.mark.asyncio
2528
async def test_without_async_session():
2629
geocoder = OpenCageGeocode('4372eff77b8343cebfc843eb4da4ddc4')
2730

@@ -30,6 +33,7 @@ async def test_without_async_session():
3033

3134
assert str(excinfo.value) == 'Async methods must be used inside an async context.'
3235

36+
@pytest.mark.asyncio
3337
async def test_using_non_async_method():
3438
async with OpenCageGeocode('6d0e711d72d74daeb2b0bfd2a5cdfdba') as geocoder:
3539
with pytest.raises(AioHttpError) as excinfo:

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ deps =
66
httpretty
77
pytest
88
pytest-aiohttp
9+
pytest-asyncio
910
commands = pytest test
1011

1112
[testenv:lint]

0 commit comments

Comments
 (0)