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

capsys: AttributeError is raised and output is not captured when using the '-s' option #547

Closed
pytestbot opened this issue Jul 26, 2014 · 1 comment
Labels
type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Ignacy Sokołowski (BitBucket: ignacy.sokolowski, GitHub: ignacy.sokolowski)


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.


@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


fix issue547 2.6 regression: capsys/capfd now work again when output capturing ("-s") is disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

1 participant