Skip to main content

Catches/silences stdout/stderr output.

Project description

A context manager that catches/suppresses output from sys.stderr and sys.stdout.

Usage

from outputcatcher import StdErrCatcher, StdOutCatcher

# Catching stdout
with StdOutCatcher(safe=False, maxlength=0) as fakeout:
    print('This is a test. you shouldn\'t see it right away.')
print('Captured stdout: {}'.format(fakeout.output))

# Catching stderr
with StdErrCatcher(safe=False, maxlength=0) as fakeerr:
    print('Testing stderr output.', file=sys.stderr)
print('Captured stderr: {}'.format(fakeerr.output))

API

StdOutCatcher(safe=False, maxlength=0)

Arguments

  • safe: If truthy, output is “encoded” using repr(). Default: False

  • maxlength: If non-zero, trim each write() call to maxlength. Default: 0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

OutputCatcher-0.0.1.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file OutputCatcher-0.0.1.tar.gz.

File metadata

File hashes

Hashes for OutputCatcher-0.0.1.tar.gz
Algorithm Hash digest
SHA256 cfe1e4ad58fde28cb778de479899af1c8d9dbbf3aecedfb3e9498026566dc7d3
MD5 a6c8cad08f618ed0dc3be52d63fbd3d7
BLAKE2b-256 5af3ef09157afcc650d61d975d9de4584fb913a368d19064d3ce61d6adc6bdcf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page