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)
File details
Details for the file OutputCatcher-0.0.1.tar.gz
.
File metadata
- Download URL: OutputCatcher-0.0.1.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfe1e4ad58fde28cb778de479899af1c8d9dbbf3aecedfb3e9498026566dc7d3 |
|
MD5 | a6c8cad08f618ed0dc3be52d63fbd3d7 |
|
BLAKE2b-256 | 5af3ef09157afcc650d61d975d9de4584fb913a368d19064d3ce61d6adc6bdcf |