classification
Title: pyunit should allow __unittest in locals to trim stackframes
Type: feature request Stage: test needed
Components: Library (Lib) Versions: Python 3.2, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: purcell Nosy List: michael.foord, purcell, rbcollins (3)
Priority: normal Keywords:

Created on 2007-04-23 03:56 by rbcollins, last changed 2009-05-12 14:32 by ajaksu2.

Messages (2)
msg55078 - (view) Author: Robert Collins (rbcollins) Date: 2007-04-23 03:56
pyunit looks for __unittest = 1 in the globals of functions in an assertion stacktrace. This is used to trim the trace so that unittest implementation methods do  not show up.

It would be great if it looked in the locals of the frame as well, as this would allow subclasses of TestCase that add new assertFOO methods to have them filtered in the same manner.

e.g. (bad example :))
def assertComplexState(self, inputs):
    __unittest = 1
    self.assertEqual('42', inputs[0], 'the input %s is not the right answer' % inputs)

msg61493 - (view) Author: Steve Purcell (purcell) Date: 2008-01-22 10:16
This is a good idea, but slightly messy.

A better solution would be for unittest to provide a decorator that 
could be used to mark assertion functions.  Internally, that decorator 
may well work the way you describe.

Given a corresponding patch, someone with more time than myself may well 
be willing to commit it.
History
Date User Action Args
2009-05-12 14:32:41ajaksu2setnosy: + michael.foord

versions: + Python 2.7, Python 3.2, - Python 2.6
stage: test needed
2008-01-22 10:16:14purcellsetmessages: + msg61493
2007-04-23 03:56:38rbcollinscreate