New issue 547: ``capsys``: ``AttributeError`` is raised and output is not captured when using the ``-s`` option https://bitbucket.org/hpk42/pytest/issue/547/capsys-attributeerror-is-raised-and-output
Ignacy Sokołowski: Test: ``` #!python def print_foo(): print('foo') def test_print_foo(capsys): print_foo() output, __ = capsys.readouterr() assert output == 'foo\n' ``` Output for ``py.test``: ``` test_capsys.py . ``` Output for ``py.test -s`` ``` test_capsys.py foo F ================================= FAILURES ================================== ______________________________ test_print_foo _______________________________ capsys = <_pytest.capture.CaptureFixture object at 0x7fdf0ed8d9b0> def test_print_foo(capsys): print_foo() > output, __ = capsys.readouterr() test_capsys.py:9: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <_pytest.capture.CaptureFixture object at 0x7fdf0ed8d9b0> def readouterr(self): try: return self._capture.readouterr() except AttributeError: > return self._outerr E AttributeError: 'CaptureFixture' object has no attribute '_outerr' ../env/lib/python3.4/site-packages/_pytest/capture.py:205: AttributeError ``` Looks like the ``CaptureFixture._start`` method, where the ``_capture`` attribute is set, is not called. This test fails on pytest 2.6 but passes on 2.5.2. On 2.5.2 the print output is captured even though the ``-s`` option was set. I think it's the expected behavior. _______________________________________________ pytest-commit mailing list pytest-commit@python.org https://mail.python.org/mailman/listinfo/pytest-commit