this somewhat related to my actuall code, Async context manager class used in pytest fixture returns async generator object instead of the expected context manager instance. Need help resolving this issue.
import asyncio
class MyAsyncContextManager:
async def __aenter__(self):
print("Entering async context")
return self
async def __aexit__(self, exc_type, exc, tb):
print("Exiting async context")
def add_numbers(self, a, b):
return a + b
@pytest.fixture
async def async_context_manager():
async with MyAsyncContextManager() as manager:
yield manager
@pytest.mark.asyncio
async def test_async_context_manager(async_context_manager):
assert isinstance(async_context_manager, MyAsyncContextManager)
async_context_manager.add_numbers(1, 2)```
this is my code
```assert isinstance(async_context_manager, MyAsyncContextManager)
assert False
+ where False = isinstance(<async_generator object async_context_manager at 0x723c132acec0>, MyAsyncContextManager)```
the error i am getting
New contributor
Kumar Gaurav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.