How would you use ward with asyncio/trio/curio?
See original GitHub issuefrom ward import test, xfail
@xfail('but seriously.')
@test('async functions should fail')
async def _():
assert False
Naturally this should not pass, but indeed it does.
So I tried writing a decorator just to see if I could force the async to be sync.
import functools as ft
import asyncio
from ward import test, xfail
def async_test(fn):
@ft.wraps(fn)
def _async_wrapper(*args, **kwargs):
loop = asyncio.get_event_loop()
return loop.run_until_complete(fn(*args, **kwargs))
return _async_wrapper
@xfail('but seriously.')
@test('async functions should fail')
@async_test
async def _():
assert False
and it passed! … but I know for certain it’s not actually working. I can put literally anything in the anon function under @async_test
and ward will tell me it passes.
So my assumption is that ward currently will not support async testing… but maybe I’m not smart enough to figure it out. :~)
- SN
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
WTF is Ward?! - New PoE 3.15 Defense System - YouTube
Ward is a new defensive layer introduced in Path of Exile 3.15 Expedition, which prevents a flat amount of damage taken on any...
Read more >Runtime for writing reliable asynchronous applications with Rust
We need some time to stabilize our APIs and collect user feedback. ... within the Python ecosystem you've got asyncio, Trio, Curio, etc....
Read more >Vision Control: Step By Step Warding Guide for LoL - Mobalytics
This can be used to your advantage by deploying an alternative ward and wasting the enemies time clearing the ward and refusing them...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just as an update to this, after thinking about it I’ve got an update planned that’ll allow you to define your tests with
async def
and just use the standard@test
decorator:It still needs work, but hopefully this will land soon!
Interesting. I’m admittedly new to the world of async testing, so I’m not aware of what is/isn’t standard practice. It makes sense to me why there is a need for a synchronous runner, even if tests are async in isolation.