Make capsys more like stdio streams in python3. Resolves #1407.#2266
Make capsys more like stdio streams in python3. Resolves #1407.#2266nicoddemus merged 2 commits intopytest-dev:featuresfrom asottile:capture_v2
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.
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)
|
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