This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Unittest document is not clear on SetUpClass calls
Type: enhancement Stage: patch review
Components: Documentation Versions: Python 3.8, Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: SilentGhost, cheryl.sabella, docs@python, lisroach, vrpolakatcisco, xtreak
Priority: normal Keywords: patch

Created on 2019-04-12 12:09 by vrpolakatcisco, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 12798 open vrpolakatcisco, 2019-04-12 12:23
Messages (3)
msg340028 - (view) Author: Vratko Polak (vrpolakatcisco) * Date: 2019-04-12 12:09
One particular paragraph from unittest.rst is not clear enough:

"If you want the setUpClass and tearDownClass on base classes called then you must call up to them yourself. The implementations in TestCase are empty."

It has sparkled a debate here [0].

Example:
A class SuperTestCase, which inherits from unittest.TestCase, defines some non-trivial setUpClass class method. Then a class SubTestCase, which inherits from SuperTestCase, wants to have SuperTestCase.setUpClass executed as its setUpClass.
Does SubTestCase need to override setUpClass just to call SuperTestCase.setUpClass (as the paragraphs might suggest), or can it rely in inheritance to have it executed without overriding?

I will create GitHub PR soon.

[0] https://gerrit.fd.io/r/#/c/18579/1/test/test_sparse_vec.py@14
msg340032 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2019-04-12 12:35
Normal inheritance rules apply to TestCase and its subclasses, as can be demonstrated by a trivial example.
msg344177 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2019-06-01 15:21
@xtreak or @lisroach, any thoughts?  Thanks!
History
Date User Action Args
2022-04-11 14:59:13adminsetgithub: 80793
2019-06-01 15:21:51cheryl.sabellasetnosy: + lisroach, cheryl.sabella, xtreak
messages: + msg344177
2019-04-12 12:35:33SilentGhostsetnosy: + SilentGhost

messages: + msg340032
versions: + Python 3.7, Python 3.8, - Python 3.9
2019-04-12 12:23:16vrpolakatciscosetkeywords: + patch
stage: patch review
pull_requests: + pull_request12725
2019-04-12 12:09:53vrpolakatciscocreate