-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functionality for selective mocking/wrapping of individual streams or stream combinations #4
Comments
For this, I would like to explore either
|
TeeStdin is only needed when both stdin and stdout are being programmatically managed. If only stdin is being mocked, and stdout should behave normally, the context manager should use the new lighter SimulateStdin which does not perform a tee. Also removes attrs dependency, which had few benefits anyhow, and complicates matters when building a deep class hierarchy. Related to bskinn#4
TeeStdin is only needed when both stdin and stdout are being programmatically managed. If only stdin is being mocked, and stdout should behave normally, the context manager should use the new lighter SimulateStdin which does not perform a tee. Also removes attrs dependency, which had few benefits anyhow, and complicates matters when building a deep class hierarchy. Related to bskinn#4
TeeStdin is only needed when both stdin and stdout are being programmatically managed. If only stdin is being mocked, and stdout should behave normally, the context manager should use the new lighter SimulateStdin which does not perform a tee. Also removes attrs dependency, which had few benefits anyhow, and complicates matters when building a deep class hierarchy. Related to bskinn#4
TeeStdin is only needed when both stdin and stdout are being programmatically managed. If only stdin is being mocked, and stdout should behave normally, the context manager should use the new lighter SimulateStdin which does not perform a tee. Also removes attrs dependency, which had few benefits anyhow, and complicates matters when building a deep class hierarchy. Related to bskinn#4
TeeStdin is only needed when both stdin and stdout are being programmatically managed. If only stdin is being mocked, and stdout should behave normally, the context manager should use the new lighter SimulateStdin which does not perform a tee. Also removes attrs dependency, which had few benefits anyhow, and complicates matters when building a deep class hierarchy. Related to bskinn#4
TeeStdin is only needed when both stdin and stdout are being programmatically managed. If only stdin is being mocked, and stdout should behave normally, the context manager should use the new lighter SimulateStdin which does not perform a tee. Also removes attrs dependency, which had few benefits anyhow, and complicates matters when building a deep class hierarchy. And removes TeeStdin.SEEK_END and TeeStdin.SEEK_SET. Related to bskinn#4
TeeStdin is only needed when both stdin and stdout are being programmatically managed. If only stdin is being mocked, and stdout should behave normally, the context manager should use the new lighter SimulateStdin which does not perform a tee. Also removes attrs dependency, which had few benefits anyhow, and complicates matters when building a deep class hierarchy. And removes TeeStdin.SEEK_END and TeeStdin.SEEK_SET. Related to bskinn#4
TeeStdin is only needed when both stdin and stdout are being programmatically managed. If only stdin is being mocked, and stdout should behave normally, the context manager should use the new lighter SimulateStdin which does not perform a tee. Also removes attrs dependency, which had few benefits anyhow, and complicates matters when building a deep class hierarchy. And removes TeeStdin.SEEK_END and TeeStdin.SEEK_SET. Related to bskinn#4
TeeStdin is only needed when both stdin and stdout are being programmatically managed. If only stdin is being mocked, and stdout should behave normally, the context manager should use the new lighter SimulateStdin which does not perform a tee. Also removes attrs dependency, which had few benefits anyhow, and complicates matters when building a deep class hierarchy. And removes TeeStdin.SEEK_END and TeeStdin.SEEK_SET. Related to bskinn#4
TeeStdin is only needed when both stdin and stdout are being programmatically managed. If only stdin is being mocked, and stdout should behave normally, the context manager should use the new lighter SimulateStdin which does not perform a tee. Also removes attrs dependency, which had few benefits anyhow, and complicates matters when building a deep class hierarchy. And removes TeeStdin.SEEK_END and TeeStdin.SEEK_SET. Related to bskinn#4
TeeStdin is only needed when both stdin and stdout are being programmatically managed. If only stdin is being mocked, and stdout should behave normally, the context manager should use the new lighter SimulateStdin which does not perform a tee. Also removes attrs dependency, which had few benefits anyhow, and complicates matters when building a deep class hierarchy. And removes TeeStdin.SEEK_END and TeeStdin.SEEK_SET. Related to bskinn#4
For this, would a user instantiate
Do you mean syntax like the the Separately, maybe it would make sense to have at least three redirection modes... tee-on-read, tee-on-write, and pipe? ('pipe' would pass anything written to the stream through to the target stream, without retaining an internal copy, as in bash's |
Yes, like the example you have, but I am envisioning also the following for creation of new streams. >>> with _current_stdio().tee(stdin="foo") as cm:
... assert cm.stdout.getvalue() == "foo\n"
>>> with _current_stdio().tee(stdout=False, stderr=True) as cm:
... print("foo")
... assert cm.stderr.getvalue() == "foo\n"
Yes, specifically creating constants for the three streams, so non-default behaviour is written in semi-literate code.
Sounds good. Thinking out loud ... >>> with _current_stdio().pipe(in=stdio_mgr.STDIN, out=stdio_mgr.STDERR) as cm:
... print("foo")
... assert cm.stderr.getvalue() == "foo\n" |
Only
stdout
, or onlystderr
; orstdout
andstdin
but notstderr
; etc.contextlib
in the standard library already exists for singly mockingstdout
andstderr
, but there's potential forstdio_mgr
to represent a more concise and customizeable means for mocking multiple streams. Thestdin
mock appears to be a novel capability, though?The text was updated successfully, but these errors were encountered: