Test calling a python coroutine (async def) from a regular function
问题 Let's say I have some asyncio coroutine which fetches some data and returns it. Like this: async def fetch_data(*args): result = await some_io() return result Basically this coroutine is called from the chain of coroutines, and initial coroutine is runned by creating a task. But what if for test purposes I want to run only one coroutine this way just when running some file: if __name__ == '__main__': result = await fetch_data(*args) print(result) And obviously I can't do this since I'm trying