Skip to content
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

Merged
merged 2 commits into from
Feb 24, 2017
Merged

Make capsys more like stdio streams in python3. Resolves #1407. #2266

merged 2 commits into from
Feb 24, 2017

Conversation

asottile
Copy link
Member

Replay of #2265 against origin/features

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 92.772% when pulling 4b2ca16 on asottile:capture_v2 into 44ad369 on pytest-dev:features.

@asottile
Copy link
Member Author

See discussion in #2265

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).
Copy link
Member

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)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@nicoddemus
Copy link
Member

Thanks for following up @asottile!

Looking over at #1407, I noticed this comment from @RonnyPfannschmidt. @RonnyPfannschmidt you still think the same way?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 92.772% when pulling 8b598f0 on asottile:capture_v2 into 44ad369 on pytest-dev:features.

@asottile
Copy link
Member Author

Looks like travis-ci is only failing due to the nightly

@nicoddemus
Copy link
Member

Yes, and the same failures are happening on master for the nightly job. The AppVeyor failure seemed to be a fluke of the CI, I have triggered it again.

@RonnyPfannschmidt
Copy link
Member

@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

@nicoddemus
Copy link
Member

Thanks @RonnyPfannschmidt, merging it then.

Thanks @asottile again for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants