Issue 36612: Unittest document is not clear on SetUpClass calls (original) (raw)

Issue36612

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:13 admin set github: 80793
2019-06-01 15:21:51 cheryl.sabella set nosy: + lisroach, cheryl.sabella, xtreakmessages: +
2019-04-12 12:35:33 SilentGhost set nosy: + SilentGhostmessages: + versions: + Python 3.7, Python 3.8, - Python 3.9
2019-04-12 12:23:16 vrpolakatcisco set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest12725>
2019-04-12 12:09:53 vrpolakatcisco create