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 errors can't show locals
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, rbcollins
Priority: normal Keywords:

Created on 2014-11-25 02:06 by rbcollins, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg231629 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2014-11-25 02:06
From - any code that is data dependent can be hard to diagnose from a backtrace alone. Many unittest and server environments address this by doing custom tracebacks that include locals.

To address this in unittest, we need to add a similar capacity to traceback, and then use it from unittest (as we can't just depend on a module from PyPI in the stdlib). This issue is for the unittest part of it. For the traceback dependency see .
msg231735 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2014-11-26 23:56
Note that IIRC py.test (a 3rd party module) will show you additional information in the traceback. SO it is definitely possible.
msg231737 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2014-11-27 00:03
Sorry, I missed the part where you said "we can't depend on PyPI".

There already is something in the stdlib that may be close enough to what you're looking for -- checkout  The following might even work:

import cgitb

That code is very old and primarily meant for CGI scripts (that shows how old it is!) but it still works.
msg238179 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2015-03-16 03:19
Fixed (patch referenced 22936)
Date User Action Args
2022-04-11 14:58:10adminsetgithub: 67126
2015-03-16 03:19:32rbcollinssetstatus: open -> closed
resolution: fixed
messages: + msg238179
2014-11-27 00:03:13gvanrossumsetmessages: + msg231737
2014-11-26 23:56:11gvanrossumsetnosy: + gvanrossum
messages: + msg231735
2014-11-25 02:06:22rbcollinscreate