On Tue, 2009-01-20 at 09:20 -0500, James Laska wrote:
> Greetings folks,
> 
> I'm finishing up some work for Chris Lumens to add unittests into
> pykickstart.  I'm trying to reduce the expected noise of some tests and
> would like to capture or suppress any warnings displayed.  
> 
> Chris directed me to
> http://docs.python.org/library/warnings.html#temporarily-suppressing-warnings,
>  which most likely works.  But I'm looking for something a bit more backwards 
> compatible (that doesn't use the new with: syntax).

The with syntax isn't the biggest backwards compatibility issue there.
But that's a topic for another day.

> Any suggestions or experiences to share?

Here's a little chunk of code I used for doctests:

def _test():
  sw = warnings.showwarning
  def showwarning(msg, cat, fname, lno, file=None):
    sw(msg, cat, fname.split('/')[-1], 0, sys.stdout)
  warnings.showwarning = showwarning
  warnings.simplefilter('always')
  import doctest
  doctest.testmod()

-- 
Ignacio Vazquez-Abrams <[email protected]>

PLEASE don't CC me; I'm already subscribed

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Fedora-python-devel-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/fedora-python-devel-list

Reply via email to