Thanks to visit codestin.com
Credit goes to github.com

Skip to content

On python tests, suppressing the output of errors would lead to a better readability #410

@libavgIssueImporter

Description

@libavgIssueImporter

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions