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: Fully qualified test name in failure output
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.11
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ethan.furman Nosy List: asvetlov, ethan.furman, michael.foord, palaviv, pitrou, r.david.murray, sam_ezeh
Priority: normal Keywords: easy, patch

Created on 2012-03-12 19:59 by michael.foord, last changed 2022-04-11 14:57 by admin. This issue is now closed.

File name Uploaded Description Edit
14265.patch palaviv, 2016-04-11 17:50 review
Pull Requests
URL Status Linked Edit
PR 32138 merged sam_ezeh, 2022-03-27 10:14
Messages (8)
msg155467 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2012-03-12 19:59
Somewhere in the failure message for tests Guido would like to see the fully qualified test name, suitable for copying and pasting into a test runner invocation for running just that test.
msg155468 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-03-12 20:02
+10 :)
msg155746 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-03-14 12:05
Which failure message are we talking about? regrtest? unittest?
msg155754 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-03-14 15:04
I'm pretty sure Michael is talking about unittest.  Doing the same for regrtest would be interesting but not as important.  (When I run individual tests from the Python test suite I generally use -m unittest to do it.)
msg263193 - (view) Author: Aviv Palivoda (palaviv) * Date: 2016-04-11 17:50
Included is a patch with the suggested change.
I changed the TestCase.__str__ method to:
    return "%s (%s.%s)" % (self._testMethodName, strclass(self.__class__), self._testMethodName)
instead of
    return "%s (%s)" % (self._testMethodName, strclass(self.__class__))

So now a failed test look like this:

ERROR: test_error_handling (Lib.test.test_logging.StreamHandlerTest.test_error_handling)
Traceback (most recent call last):
  File "/home/aviv/dev/cpython/Lib/test/", line 641, in test_error_handling
    self.assertIs(h.error_record, r)
AttributeError: 'TestStreamHandler' object has no attribute 'error_record'

msg416098 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2022-03-26 23:57
Hopefully somebody on the core-mentorship list can move this forward by converting to a PR and reviewing.

If @palaviv is still active the review itself will still be useful.
msg416116 - (view) Author: Sam Ezeh (sam_ezeh) * Date: 2022-03-27 10:19
The provided patch wasn't entirely compatible with the current upstream code. I used the patch file to apply the changes to `Lib/unittest/`, resolved the remaining conflicts with the patches to the test files and amended existing tests for the library.

I updated the documentation for unittest to reflect the changes in behaviour.
msg416265 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2022-03-29 15:02
New changeset 755be9b1505af591b9f2ee424a6525b6c2b65ce9 by Sam Ezeh in branch 'main':
bpo-14265: Adds fully qualified test name to unittest output (GH-32138)
Date User Action Args
2022-04-11 14:57:27adminsetgithub: 58473
2022-03-29 15:03:07asvetlovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-03-29 15:02:32asvetlovsetnosy: + asvetlov
messages: + msg416265
2022-03-27 10:19:58sam_ezehsetmessages: + msg416116
2022-03-27 10:14:17sam_ezehsetkeywords: + patch
pull_requests: + pull_request30218
2022-03-27 07:18:37sam_ezehsetnosy: + sam_ezeh
2022-03-26 23:57:02ethan.furmansetassignee: michael.foord -> ethan.furman
versions: + Python 3.11, - Python 3.6
keywords: + easy, - patch
nosy: + ethan.furman

messages: + msg416098
stage: patch review
2016-04-11 17:50:03palavivsetfiles: + 14265.patch
versions: + Python 3.6, - Python 3.3
nosy: + palaviv

messages: + msg263193

keywords: + patch
2012-03-14 15:04:15r.david.murraysetmessages: + msg155754
2012-03-14 12:05:33pitrousetnosy: + pitrou
messages: + msg155746
2012-03-12 20:02:17r.david.murraysetnosy: + r.david.murray
messages: + msg155468
2012-03-12 19:59:47michael.foordcreate