-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
plugin: capturerelated to the capture builtin pluginrelated to the capture builtin plugintype: bugproblem that needs to be addressedproblem that needs to be addressed
Description
It seems that the replacement for sys.stdout
installed by the capsysbinary
does not work correctly. See the exception in the captured output in the example run below.
The setup is incredibly simple. The test file I'm using has the following content:
def test_capture(capsysbinary):
print('hello')
There is no pytest.ini or anything else I've locally configured that should influence pytest.
(venv) ~/Desktop/pytest-issue$ pip list
Package Version
-------------- -------
attrs 19.3.0
more-itertools 8.2.0
packaging 20.3
pip 19.2.3
pluggy 0.13.1
py 1.8.1
pyparsing 2.4.6
pytest 5.3.5
setuptools 41.2.0
six 1.14.0
wcwidth 0.1.8
WARNING: You are using pip version 19.2.3, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(venv) ~/Desktop/pytest-issue$ ls
test_capture.py venv
(venv) ~/Desktop/pytest-issue$ cat test_capture.py
def test_capture(capsysbinary):
print('hello')
(venv) ~/Desktop/pytest-issue$ pytest
============================= test session starts ==============================
platform darwin -- Python 3.8.2, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /Users/michi/Desktop/pytest-issue
collected 1 item
test_capture.py [100%]
=================================== FAILURES ===================================
_________________________________ test_capture _________________________________
self = <contextlib._GeneratorContextManager object at 0x105da09d0>, type = None
value = None, traceback = None
def __exit__(self, type, value, traceback):
if type is None:
try:
> next(self.gen)
E TypeError: write() argument must be str, not bytes
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/contextlib.py:120: TypeError
--------------------------- Captured stdout teardown ---------------------------
F
============================== 1 failed in 0.06s ===============================
I've also tried sys.stdout.write()
with the same result. Is this a bug or am I doing something incredibly stupid?
Metadata
Metadata
Assignees
Labels
plugin: capturerelated to the capture builtin pluginrelated to the capture builtin plugintype: bugproblem that needs to be addressedproblem that needs to be addressed