capsys = <_pytest.capture.CaptureFixture object at 0x7f02a1e2f7f0>
def test_can_output_to_stdout(capsys): print("hello") > capture = capsys.readouterror() E AttributeError: 'CaptureFixture' object has no attribute 'readouterror'
test_aaa.py:5: AttributeError
我使用的代码类似于:
import pytest
def test_can_output_to_stdout(capsys): print("hello") capture = capsys.readouterror() assert "hello" in capture.out
我这样调用测试:
py.test --capture=sys --capture=fd test_aaa.py
版本是:
py测试:
py.test --version This is pytest version 4.6.5, imported from /usr/local/lib/python3.4/site-packages/pytest.p
我是一名优秀的程序员,十分优秀!