Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Captured IO accepts bytes even tough it should not #4861
On Python3, when output capturing is enabled, bytes are accepted where normaly only text would we accepted.
I am on Ubuntu 18.04 and using it's Python 3.6 packages with pytest 4.3.0.
# coding: utf-8 import sys as _sys def test_output(): _sys.stdout.write(b"foo")
I've extended the test a bit:
def test_output(): assert type(b"foo") == bytes print(_sys.stdout) print(_sys.stdout.write) print(id(_sys.stdout.write)) _sys.stdout.write(b"foo")
With output capturing:
Looks like pytest's
cpython itself appears to check it here: https://github.com/python/cpython/blob/ef17fdbc1c274dc84c2f611c40449ab84824607e/Modules/_io/clinic/textio.c.h#L253-L256
added a commit
Mar 1, 2019
referenced this issue
Mar 1, 2019
Yes, sorry, the tests should both fail on Python 3, should have mentioned that.
As for handling the type, yes that should probably be changed to mimc Python 3 behaviour, but as usual it also still needs to mimic Python 2, which is to accept both...which you have already done in your commit...that just popped up while writing this.