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
In unittest.TestCase docs for setUp() and tearDown() don't mention AssertionError #62766
Comments
http://docs.python.org/3/library/unittest.html#unittest.TestCase.setUp http://docs.python.org/3/library/unittest.html#unittest.TestCase.tearDown utest.py #!/usr/bin/env python3 import unittest
class Test(unittest.TestCase):
def setUp(self):
raise AssertionError
def tearDown(self):
raise AssertionError
def test_nothing(self):
pass [guest@localhost py]$ python3 -m unittest -v utest ====================================================================== Traceback (most recent call last):
File "./utest.py", line 8, in setUp
raise AssertionError
AssertionError Ran 1 test in 0.000s FAILED (failures=1) also raising unittest.SkipTest works properly |
I re-ran with setUp 'raise' changed to 'pass' to see the effect of raise AssertionError or unittest.SkipTest in tearDown and indeed the test fails or skips even then. I suggest adding ', other than AssertionError or SkipTest,' just after 'method'. The same is true of test_xxx methods. A slight anomaly is that AssertionError in test_nothing and SkipTest in tearDown results in "FAILED (failures=1, skipped=1)", which is not really a skip. For setUpClass and setUpModule, AssertionErrors *are* errors, not failures, while SkipTest works everywhere. |
I did some further testing and it seems that you are right, testcase.SkipTest() never causes an error in setUp or tearDown but "raise AssertionError" does (even in setUp or tearDown). I went ahead and made relevant documentation changes, let me know what you think. |
Looks like this issue has been resolved. Can we close it? |
Resolved in what way? The doc seems unchanged. |
Sorry. I meant, merged. |
I have built 3.4.0a4 and run - same thing |
Yep, those docs are just wrong. I'm trying to think of a concise rewording. |
In proposed patches fix Skiptest -> :exc:`SkipTest` |
Hi, |
Hi, |
Patch looks good to me. |
New changeset fdadc152b964 by Terry Jan Reedy in branch '2.7': New changeset 9ab66a7f654a by Terry Jan Reedy in branch '3.4': New changeset 72b1715e18c1 by Terry Jan Reedy in branch '2.7': New changeset a37440dec1b6 by Terry Jan Reedy in branch '3.4': |
Nitika, congrats on first patch. One minor problem: spaces at end of lines. It it my fault for not checking, but try to avoid them anyway. |
@terry J.Reedy |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: