Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

idea: use sys.set_coroutine_wrapper in the test suite to enforce assert_yields *everywhere* #152

Open
njsmith opened this issue May 11, 2017 · 1 comment

Comments

@njsmith
Copy link
Member

njsmith commented May 11, 2017

Like:

@types.coroutine
def enforce_checkpoint(coro):
    with assert_yields():
        yield from coro.__await__()
sys.set_coroutine_wrapper(enforce_checkpoint)

and calling this from conftest.py

@njsmith
Copy link
Member Author

njsmith commented May 14, 2017

There are some async functions in trio (esp. in the test suite) that intentionally don't have any checkpoints. The way to handle this I think is to annotate those with @no_checkpoint or something (which just sets a flag that the enforce_checkpoint function would look for), and this would actually be a good piece of executable documentation, as well as being essentially free at runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant