-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Test helpers to add to project #93
Comments
How does this compare to the AsyncMock added to the stdlib in 3.8? Is it essentially just a backport for earlier versions?
So that would just be I do think #53 would be a good and fairly straightforward thing to implement, that would be strictly better for your use cases, right?
Huh, interesting. I agree that making these context managers might make more sense, similar to pytest's |
Whoops, I didn't realize that 3.8 has an AsyncMock. This isn't really a backport because I didn't put in the effort to completely replicate the API.
It's |
There are a few helpers I've written I copy into each new Trio project. Would any of these be good batteries to include in this project?
AsyncMock
class for mocking coroutines. I forget that the built-inMock
cannot be awaited at least once on every new project. Here's an example implementation.fail_after()
decorator that limits the time (relative to Trio's clock) that each test can run. With concurrency, I find that its easy to write code (and/or tests) that deadlock, and if you ctrl+c a pytest run you lose a lot of valuable info. Or if you run a deadlocked test on a CI platform like Travis, you'll time out the entire build. Here's an example implementation. I realize that this would step on Add test timeout support #53's toes.fail_after()
, I've also written min/max execution time decorators. See examples here. The goal for these isn't necessarily preventing runaway tests, but rather to make assertions regarding timing. For example if you've written something that's supposed to load balance connections, you can use these assertions to ensure that it doesn't dispatch them too quickly or too slowly.I'm happy to contribute ideas or source code. The 3 decorators mentioned above might also work better as context managers.
The text was updated successfully, but these errors were encountered: