-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Make capsys more like stdio streams in python3. Resolves #1407. #2266
Conversation
See discussion in #2265 |
testing/test_capture.py
Outdated
def test_write_bytes_to_buffer(self): | ||
f = capture.CaptureIO() | ||
# In python3, stdout / stderr are text io wrappers (exposing a buffer | ||
# property of the underlying bytestream). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather at this point to be explicit about the expected behavior in Python 3:
@pytest.mark.skipif(sys.version_info[0] == 2, 'python 3 only behavior')
def test_write_bytes_to_buffer(self):
"""In python3, stdout / stderr are text io wrappers (exposing a buffer
property of the underlying bytestream). See issue #1407
"""
f = capture.CaptureIO()
f.buffer.write(b'foo\r\n')
assert f.getvalue() == 'foo\n'
(I also added a \r\n
there to ensure we are not messing with how newlines are treated)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Thanks for following up @asottile! Looking over at #1407, I noticed this comment from @RonnyPfannschmidt. @RonnyPfannschmidt you still think the same way? |
Looks like travis-ci is only failing due to the nightly |
Yes, and the same failures are happening on |
@nicoddemus i still think the capture objects should be simple/simplified, but since we have no way to properly do any cases, this pr adds value in any case |
Thanks @RonnyPfannschmidt, merging it then. Thanks @asottile again for the contribution! |
Replay of #2265 against origin/features