Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Python context manager for mocking/wrapping stdin/stdout/stderr

https://travis-ci.org/bskinn/stdio-mgr.svg?branch=dev https://codecov.io/gh/bskinn/stdio-mgr/branch/dev/graph/badge.svg https://img.shields.io/pypi/v/stdio_mgr.svg https://img.shields.io/pypi/pyversions/stdio-mgr.svg https://img.shields.io/github/license/mashape/apistatus.svg

README draft in progress.

Have a command-line Python application? Want to test […continued]

[more about mocking stdio]

In addition to mocking stdio for testing, stdio_mgr can also be used to wrap functions that directly interact with stdio. Example:

>>> def embellish(func):
...     def func_wrapper(s):
...         from stdio_mgr import stdio_mgr
...
...         with stdio_mgr() as (i, o, e):
...             func(s)
...             content = o.getvalue()
...         newcontent = '*** ' + content.replace('\n', ' ***\n*** ')
...         newcontent = newcontent[:-5]
...         print(newcontent)
...     return func_wrapper

>>> @embellish
... def testfunc(s):
...     print(s)

>>> testfunc("""\
... Foo bar baz quux.
... Lorem ipsum dolor sit amet....""")
*** Foo bar baz quux. ***
*** Lorem ipsum dolor sit amet.... ***

Download files

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

Source Distribution

stdio-mgr-1.0rc1.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stdio_mgr-1.0rc1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file stdio-mgr-1.0rc1.tar.gz.

File metadata

  • Download URL: stdio-mgr-1.0rc1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for stdio-mgr-1.0rc1.tar.gz
Algorithm Hash digest
SHA256 45cf1c5ff5b912d7ca516419c71797f47ec7b1bf83d9ea53bba41c17c7855d4d
MD5 606147327144e6cad9ed4ca7ebff79cf
BLAKE2b-256 04cb4970e115d29a46e21578193c50d5b69fa6a7dac04fea5ca931bffe0dc869

See more details on using hashes here.

File details

Details for the file stdio_mgr-1.0rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for stdio_mgr-1.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 53905e5d41dad9a2ca75304d0fc2de7a63c941243b75901107f46ca053b4d64a
MD5 08f3bc37b58692f7c1150119ab578de1
BLAKE2b-256 1aaf8d2bb815d9993747a8946d2977fba86b1a1542c1012181a0d7eea4166a87

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.1.1

2 files

1.0.1

2 files

1.0

2 files

This release

1.0rc1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page