darrenburns / ward

Ward is a modern test framework for Python with a focus on productivity and readability.
https://ward.readthedocs.io
MIT License
1.21k stars 53 forks source link

[Feature request] Support Curio, trio or other async libraries #356

Open logileifs opened 1 year ago

logileifs commented 1 year ago

Would you be willing to add support for Curio and/or Trio? I would submit a PR myself but I see in https://github.com/darrenburns/ward/blob/master/ward/testing.py#L200 that asyncio.run(coro) is hardcoded and I'm not sure how you would go about to make that configurable. If you could check on the user supplied config before calling asyncio.run(coro) you could do something like:

if self.is_async_test:
    coro = self.fn(**resolved_args)
    if config.asynclib == 'curio':
        import curio
        curio.run(coro)
    elif config.asynclib == 'trio':
        import trio
        trio.run(coro)
    else:
        asyncio.run(coro)
else:
    self.fn(**resolved_args)
logileifs commented 1 year ago

I took a stab at it myself: https://github.com/darrenburns/ward/pull/357