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 expectedFailure could take a message argument like skip does
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: adam-collard, barry, benjamin.peterson, ezio.melotti, michael.foord, r.david.murray, rbcollins, santoso.wijaya, serhiy.storchaka
Priority: low Keywords: easy

Created on 2011-08-02 11:41 by r.david.murray, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
new-unittest adam-collard, 2013-07-06 11:05 patch for allowing expectedFailure to take a message review
Messages (9)
msg141560 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-08-02 11:41
I think that it would be good for expectedFailure to take a message argument like skip does.  My thought is that it would be printed both when it is triggered (the test fails as expected) so that one case from the verbose output why the test is expected to fail, and when the test passes unexpectedly.  My specific use case is OS bugs, where we could mark a test as an expected failure instead of a skip, and then we would see the unexpected pass when the OS fixes the bug, but in the meantime the verbose output would show the 'skip' reason.

Hmm.  I suppose this means I want expectedFailureIf, too...
msg141578 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-08-02 18:51
Too late I'm afraid as expectedFailure not expectedFailure() is the decorator.
msg141588 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2011-08-03 00:20
Well, expectedFailure could dispatch on the type of the argument, with different behaviour for strings and anything else (presumed to be a function / method). That would be inconsistent with the api for skipping though. (I'm not wild on the message argument to the skip decorators - I keep forgetting it.)
msg145119 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2011-10-07 18:15
It would be nice if expectedFailure took a bug number and printed a url to the tracker.
msg145147 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2011-10-07 21:51
Well, it would be nice for the Python test suite, maybe not so useful for external users of the api. Something for regrtest rather than unittest I think.
msg147588 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-11-14 12:43
Maybe we could add an expected_issue(id) decorator to test.support.
msg192410 - (view) Author: Adam Collard (adam-collard) * Date: 2013-07-06 11:05
I've got a patch for this, but I'm a bit worried about the impact on the documented API. I've tried to do the best I could to minimize it through use of keyword-arguments but I'm a bit unsure about the change (and the docs too!)

I hope this is useful to someone!
msg192834 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-07-10 20:32
Thanks, Adam.  I'm afraid it may be a while before Michael (or anyone else) gets a chance to review it and think about the issue some more.
msg408696 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-12-16 12:15
Such change would break a lot of existing interfaces.

* addUnexpectedSuccess() has a single parameter. The change will add the second parameter and will break subclasses of TestResult.
* addExpectedFailure() has two parameter. The change will add the third parameter and will break subclasses of TestResult.
* unexpectedSuccesses is a list of tests. The change will make it a list of 2-tuples and will break users of TestResult.
* expectedFailures is a list of 2-tuples. The change will make it a list of 3-tuples and will break users of TestResult.

It is too destructive change. I think we can live without a message argument for expectedFailure().
History
Date User Action Args
2022-04-11 14:57:20adminsetgithub: 56890
2021-12-16 12:15:32serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg408696
2021-06-22 16:24:42iritkatrielsetversions: + Python 3.11, - Python 3.3
2015-01-02 20:17:20rbcollinssetnosy: + rbcollins
2013-07-10 20:32:55r.david.murraysetmessages: + msg192834
2013-07-06 11:05:16adam-collardsetfiles: + new-unittest

messages: + msg192410
2013-01-31 10:52:11adam-collardsetnosy: + adam-collard
2011-11-14 12:43:38ezio.melottisetnosy: + ezio.melotti
messages: + msg147588
2011-10-07 21:51:54michael.foordsetmessages: + msg145147
2011-10-07 18:15:33barrysetnosy: + barry
messages: + msg145119
2011-08-03 00:20:29michael.foordsetmessages: + msg141588
2011-08-02 18:51:49benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg141578
2011-08-02 16:56:19santoso.wijayasetnosy: + santoso.wijaya
2011-08-02 11:41:56r.david.murraycreate