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.

Title: unittest subTest does not call addFailure
Type: behavior Stage: test needed
Components: Library (Lib) Versions: Python 3.7, Python 3.6, Python 3.5
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, kristall, martin.panter, pitrou
Priority: normal Keywords:

Created on 2017-01-04 12:57 by kristall, last changed 2022-04-11 14:58 by admin.

Messages (4)
msg284635 - (view) Author: (kristall) Date: 2017-01-04 12:57
unittests subTests do not call addFailure in the case of a failure.

Please see for detailed problemdescription.
msg284691 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-01-05 02:05
Thanks for the report. That's because TestResult.addSubTest() updates TestResult.errors and TestResult.failures itself instead of calling the addError() and addFailure() methods respectively:

    if issubclass(err[0], test.failureException):
        errors = self.failures
        errors = self.errors
    errors.append((subtest, self._exc_info_to_string(err, test)))

I don't know whether it was intentional or not so I'm adding Antoine to nosy list.

(I removed 3.4 from the versions field because it's in security-fix-only mode.)
msg286085 - (view) Author: (kristall) Date: 2017-01-23 13:37
Thanks for the quick 1st response. Since I put that part of my script on hold, I'd like to ask if it is possible to estimate when Antoine will have a look at this? Thanks in advance.
msg286117 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2017-01-23 21:12
It is not obvious what the effect of not calling addFailure() is, but perhaps this is related to Issue 25894? Failure and error statuses are not immediately reported from subtests.
Date User Action Args
2022-04-11 14:58:41adminsetgithub: 73338
2021-08-31 08:16:59serhiy.storchakalinkissue37719 superseder
2017-01-23 21:12:35martin.pantersetnosy: + martin.panter
messages: + msg286117
2017-01-23 13:37:06kristallsetmessages: + msg286085
2017-01-05 02:05:50berker.peksagsettype: behavior
components: + Library (Lib), - Tests
versions: + Python 3.6, Python 3.7, - Python 3.4
nosy: + berker.peksag, pitrou

messages: + msg284691
stage: test needed
2017-01-04 12:57:35kristallcreate