classification
Title: Make unittest assertions staticmethods/classmethods
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, michael.foord, pakal, rbcollins, xtreak
Priority: normal Keywords:

Created on 2019-06-13 07:15 by pakal, last changed 2019-06-13 09:20 by pakal. This issue is now closed.

Messages (4)
msg345463 - (view) Author: Pascal Chambon (pakal) Date: 2019-06-13 07:15
Is there any reasons why assertXXX methods in TestCase are instance methods and not staticmethods/classmethods?

Since they (to my knowledge) don't need to access an instance dict, they could be turned into instance-less methods, and thus be usable from other testing frameworks (like pytest, for those who want to use all the power of fixtures and yet benefit from advanced assertions, like Django's TestCase's assertXXX).

Am I missing something here?
msg345475 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python triager) Date: 2019-06-13 08:43
See also issue19645 which seems to be a slightly related discussion
msg345479 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2019-06-13 09:02
I think this is strictly redundant with that other ticket and I'm going to close it. That said, they need access to self.failureException. https://docs.python.org/3/library/unittest.html#unittest.TestCase.failureException
msg345481 - (view) Author: Pascal Chambon (pakal) Date: 2019-06-13 09:20
Indeed I missed this ticket, thanks
History
Date User Action Args
2019-06-13 09:20:50pakalsetmessages: + msg345481
2019-06-13 09:02:03rbcollinssetstatus: open -> closed

messages: + msg345479
stage: resolved
2019-06-13 08:44:34xtreaksetnosy: + rbcollins, ezio.melotti, michael.foord

components: + Library (Lib), - Tests
versions: - Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8
2019-06-13 08:43:56xtreaksetnosy: + xtreak
messages: + msg345475
2019-06-13 07:15:04pakalcreate