Metadata-Version: 2.1
Name: iomux
Version: 0.2.0
Summary: IO buffer multiplexer
Keywords: io multiplexer mux bytesio stringio process capture
Home-page: https://github.com/FFY00/python-iomux
Author: Filipe Laíns <lains@riseup.net>
Author-Email: Filipe Laíns <lains@riseup.net>
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Project-URL: Homepage, https://github.com/FFY00/python-iomux
Project-URL: Repository, https://github.com/FFY00/python-iomux
Requires-Python: >=3.7
Provides-Extra: test
Provides-Extra: docs
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: furo>=2021.04.11b34; extra == "docs"
Requires-Dist: sphinx~=3.0; extra == "docs"
Description-Content-Type: text/markdown

# iomux

[![checks](https://github.com/FFY00/python-iomux/actions/workflows/checks.yml/badge.svg)](https://github.com/FFY00/python-iomux/actions/workflows/checks.yml)
[![tests](https://github.com/FFY00/python-iomux/actions/workflows/tests.yml/badge.svg)](https://github.com/FFY00/python-iomux/actions/workflows/tests.yml)
[![codecov](https://codecov.io/gh/FFY00/python-iomux/branch/main/graph/badge.svg?token=b8Sp012QO7)](https://codecov.io/gh/FFY00/python-iomux)

IO buffer multiplexer.


```python
import sys

from contextlib import redirect_stdout, redirect_stderr

import iomux


capture = iomux.StringMux()

with redirect_stdout(capture.out), redirect_stderr(capture.err):
    print('aaa')
    print('bbb', file=sys.stderr)
    print('aaa')
    print('bbb', file=sys.stderr)

assert capture.getvalue() == 'aaa\nbbb\naaa\nbbb\n'
assert capture.getvalue('out') == 'aaa\naaa\n'
assert capture.getvalue('err') == 'bbb\nbbb\n'
assert list(capture.values()) == [
    ('out', 'aaa\n'),
    ('err', 'bbb\n'),
    ('out', 'aaa\n'),
    ('err', 'bbb\n'),
]
```
