python / cpython

The Python programming language
https://www.python.org
Other
63.49k stars 30.41k forks source link

Add public TestCase method/property to get result of current test #77107

Open a78eea09-d630-4b7e-83e2-508679a01de9 opened 6 years ago

a78eea09-d630-4b7e-83e2-508679a01de9 commented 6 years ago
BPO 32926
Nosy @rbtcollins, @ezio-melotti, @voidspace

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = None created_at = labels = ['type-feature', 'library', '3.9'] title = 'Add public TestCase method/property to get result of current test' updated_at = user = 'https://bugs.python.org/VictorEngmark' ``` bugs.python.org fields: ```python activity = actor = 'jdemeyer' assignee = 'none' closed = False closed_date = None closer = None components = ['Library (Lib)'] creation = creator = 'Victor Engmark' dependencies = [] files = [] hgrepos = [] issue_num = 32926 keywords = ['patch'] message_count = 1.0 messages = ['312671'] nosy_count = 4.0 nosy_names = ['rbcollins', 'ezio.melotti', 'michael.foord', 'Victor Engmark'] pr_nums = [] priority = 'normal' resolution = None stage = 'patch review' status = 'open' superseder = None type = 'enhancement' url = 'https://bugs.python.org/issue32926' versions = ['Python 3.9'] ```

a78eea09-d630-4b7e-83e2-508679a01de9 commented 6 years ago

The community has come up with multiple hacks [1] to be able to inspect the current test result in tearDown (to collect more expensive diagnostics only when the test fails). It would be great to have a documented and simple way to check whether the test currently in play was successful. To be clear, TestCase.wasSuccessful() is not useful in this case, since it only reports whether all tests run so far were successful.

[1] https://stackoverflow.com/q/4414234/96588