This release is a pre-release and may not be stable for production use.
Python context manager for mocking/wrapping stdin/stdout/stderr
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45cf1c5ff5b912d7ca516419c71797f47ec7b1bf83d9ea53bba41c17c7855d4d
|
|
| MD5 |
606147327144e6cad9ed4ca7ebff79cf
|
|
| BLAKE2b-256 |
04cb4970e115d29a46e21578193c50d5b69fa6a7dac04fea5ca931bffe0dc869
|
File details
Details for the file stdio_mgr-1.0rc1-py3-none-any.whl.
File metadata
- Download URL: stdio_mgr-1.0rc1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53905e5d41dad9a2ca75304d0fc2de7a63c941243b75901107f46ca053b4d64a
|
|
| MD5 |
08f3bc37b58692f7c1150119ab578de1
|
|
| BLAKE2b-256 |
1aaf8d2bb815d9993747a8946d2977fba86b1a1542c1012181a0d7eea4166a87
|