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() as fakeout:
    print('This is a test. you shouldn\'t see it right away.')
print('Captured stdout: {}'.format(fakeout.output))

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

API

StdOutCatcher(escaped=False, max_length=0)

Arguments

  • escaped: If truthy, output is “encoded” using repr(), but without quotes. Default: False

  • max_length: If non-zero, final output will not exceed max_length. Once max_length is reached, further write() calls will not write to the original stream. 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.4.tar.gz (4.4 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for OutputCatcher-0.0.4.tar.gz
Algorithm Hash digest
SHA256 eb5e2fabc4c6fc34a4f267c7f945095cc885dc25451b2b1bdf409a46b6bd14ff
MD5 35c4077722cbec3a5014cfc68349ded1
BLAKE2b-256 7b338d79be8934fa3f02b95a7d33c1df4a6ca94ad9251a2bba476c2d2511c427

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