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.2.tar.gz (3.2 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for OutputCatcher-0.0.2.tar.gz
Algorithm Hash digest
SHA256 9a45338c92ce69b4b2829721c783fe98054bae99c3eb01a650ef2f7ea0d9a4ca
MD5 b7e440d9de8b062d0516ad1ed2768aa7
BLAKE2b-256 d4636bd4eb92002843484c11078302012a8cf3bb9a8cdb703d9396ecde7c5f1e

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