-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Supports class level setUp and Teardown #494
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
Conversation
Hi @steveli777 thanks for the contribution! As a general rule (not yet documented anywhere easy to find) the commits here should follow a pattern of |
python-stdlib/unittest/unittest.py
Outdated
set_up = getattr(o, "setUp", lambda: None) | ||
tear_down = getattr(o, "tearDown", lambda: None) | ||
|
||
if set_up_class: | ||
set_up_class() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the getattr
line above, if the function doesn't exist it defaults to lambda: None
. This is done so that you don't need the if set_up_class
here, you can just run set_up_class()
and if it doesn't exist it'll just run the no-op lambda function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion, fixed.
python-stdlib/unittest/unittest.py
Outdated
except SkipTest as e: | ||
print(" skipped:", e.args[0]) | ||
print(" SKIPPED:", e.args[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These output format changes should be done in a separate commit - but only if the new format matches cpython unittest? I'd prefer to add this commit after the #488 changeset which has had some other changes made to the output format already to more closely match cpython.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I reverted those text changes.
Add setUpClass and tearDownClass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean and simple, nice!
Hi @steveli777 as I've got a running unittest PR on the go, I've rebased your commit here on top of that one. It needed some manual intervention to deal with merge conflicts, but I think I got it right: 23866f3 Even with the merge changes the commit is still comitted in your name, I hope that's good for you! If you get a chance could you review / test this setUpClass functionality in the branch from #488 ? Otherwise do you have a simple test case I can run (or add as unit test) to cover this functionality? |
This feature was implemented in 2d61dbd |
To support class level setUp and Teardown for Unittest