[New-bugs-announce] [issue36612] Unittest document is not clear on SetUpClass calls

Vratko Polak report at bugs.python.org
Fri Apr 12 08:09:53 EDT 2019


New submission from Vratko Polak <vrpolak at cisco.com>:

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

----------
assignee: docs at python
components: Documentation
messages: 340028
nosy: docs at python, vrpolakatcisco
priority: normal
severity: normal
status: open
title: Unittest document is not clear on SetUpClass calls
type: enhancement
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36612>
_______________________________________


More information about the New-bugs-announce mailing list