-
-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
I have been experimenting with using httpx as an async http client and have built an api client around this. I have been attempting to run test cases using twisted trial unittests. However running this fails as get an error with sniffio failing to detect that it is within an asyncio event loop.
Here is an example of showing what causes the error.
from twisted.trial import unittest
from foo import APIClientAsync
import asyncio
from twisted.internet import asyncioreactor
asyncioreactor.install(asyncio.get_event_loop())
class TestAPIClient(unittest.TestCase):
def setUp(self):
self.client = APIClientAsync()
async def test_client(self):
result = await self.client.request()
This will give the following error:
sniffio/_impl.py", line 93, in current_async_library raise AsyncLibraryNotFoundError( sniffio._impl.AsyncLibraryNotFoundError: unknown async library, or not in async context
Is this a known error, or is there any known workaround for this? Or should I switch to a different testing framework to enable asyncio detection?
Metadata
Metadata
Assignees
Labels
No labels