this ticket is transfered from former bug tracking system
Possible implementation (borrowed from AppTest.py)
class SuppressOutput(object):
class Blackhole(object):
def write(self, *args):
pass
def __init__(self):
self.__savedStreams = [sys.stdout, sys.stderr]
def __enter__(self):
sys.stdout = self.Blackhole()
sys.stderr = self.Blackhole()
def __exit__(self, *args):
sys.stdout, sys.stderr = self.__savedStreams
And test with:
with SuppressOutput():
self.assertRaises(RuntimeError, noisyMethod)
author: oxullo
created: 2013/03/15 15:13:32 +0100
assigned to: uzadow
priority: High
project: libavg