def raise_check(func, **kwds): try: with capture('stdout') as out: check(func, **kwds) except Exception: e = sys.exc_info()[1] raise AssertionError(str(e)) else: assert 'Traceback' not in out.getvalue() finally: out.close()