-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
Turn examples into simple unit tests. #292
Comments
I think we should have another decorator, because we need way more than just one testcase per callable (for example, to test both database timezone and user-specified timezone in clock.py |
How about selecting the first example as default and extending the syntax of help to show more examples? Like:
|
I'm thinking of using nose instead of unittest, because a lot of these examples are io-bound and nose can run tests in multiple threads. It's an optional dependency, so not a big deal. |
This sounds like a great idea! We should also consider improving the help system by adding a search feature... for example
|
Actually, screw nose, pytest is much better. Everything just works, unlike the buggy mess that is nose. It's looking pretty great right now but I don't have time to work more on this today. |
We already have
@example('.calc 1 + 1')
. This syntax could be expanded to not only show the input, but also the output like:@example('.calc 1 + 1', '2')
. Then all that is left is to make@example
construct the needed mock objects to feed to the callable, and check if it replied or msg'd the output.This decorator would also generate the needed objects for unittest to find, so that you could simply put
to the bottom of the file and get some simple unit tests.
This would also complement issue #268, as the same examples could be used in that framework. But being able to simply run a file after modifications to check for dumb mistakes is very valuable. The dummy-triggers and bots could also be used in more complicated test cases.
I'm going to start working on this, but what do you guys think? Should the decorator be called something other than example? Is this too simplistic to be useful? Should I target something other that python's unittest module?
The text was updated successfully, but these errors were encountered: