[New-bugs-announce] [issue18765] unittest needs a way to launch pdb.post_mortem or other debug hooks

Gregory P. Smith report at bugs.python.org
Sat Aug 17 01:45:52 CEST 2013


New submission from Gregory P. Smith:

A few times now I've seen people write something that overrides and re-implements the unittest.TestCase run() method, copying most of the implementation but adding one feature:

The ability for pdb.post_mortem() to be called after every phase of execution iff an exception/error was caught (setUp(), the testMethod() call itself and tearDown()).

I really hate seeing people have to copy the run method implementation and modify it.

We could support this either by adding another debugHook() method to the TestCase API.  Proposal: it gets called within the except: clause surrounding each phase of test execution.

Turning on support for automatic pdb.post_mortem(), typically controlled via a flag or other environment configurable as it isn't desirable during automation:

  def debugHook(self):
    if SOMETHING_SAYS_TO_ENABLE_THIS:
      pdb.post_mortem()

no more copy and pasting the run() method.

----------
components: Library (Lib)
messages: 195444
nosy: gregory.p.smith, michael.foord
priority: normal
severity: normal
stage: needs patch
status: open
title: unittest needs a way to launch pdb.post_mortem or other debug hooks
type: enhancement
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18765>
_______________________________________


More information about the New-bugs-announce mailing list