class SprintfStdout(contextlib.AbstractContextManager):
"""
A context manager that captures outputs to stdout to a buffer
- without printing them. e.g.::
+ without printing them.
- with SprintfStdout() as buf:
- print("test")
- print("1, 2, 3")
- print(buf())
-
- This yields::
-
- 'test\\n1, 2, 3\\n'
+ >>> with SprintfStdout() as buf:
+ ... print("test")
+ ... print("1, 2, 3")
+ ...
+ >>> print(buf(), end='')
+ test
+ 1, 2, 3
"""