-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Description
Hi and thanks for your great work devs!
When I try to integrate capsys or capfd fixtures with unittest.TestCase it throws 'CaptureFixture' object has no attribute '_outerr'
error.
Here is my test code:
import pytest
import unittest
class TestClass(unittest.TestCase):
@pytest.fixture(autouse=True)
def test_print(self, capfd):
print('x')
out, err = capfd.readouterr()
assert out == 'x'
It is essentially combined use of Support for unittest.TestCase / Integration of fixtures and Capturing of the stdout/stderr output.
Here is the full backtrace:
_____________ ERROR at setup of TestClass.test_print ______________
self = <_pytest.capture.CaptureFixture object at 0x7f8f6ccff6d8>
def readouterr(self):
try:
> return self._capture.readouterr()
E AttributeError: 'CaptureFixture' object has no attribute '_capture'
/usr/local/lib/python3.5/dist-packages/_pytest/capture.py:206: AttributeError
During handling of the above exception, another exception occurred:
self = <test_print.TestClass testMethod=test_print>, capfd = <_pytest.capture.CaptureFixture object at 0x7f8f6ccff6d8>
@pytest.fixture(autouse=True)
def test_print(self, capfd):
print('x')
> out, err = capfd.readouterr()
test_print.py:9:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_pytest.capture.CaptureFixture object at 0x7f8f6ccff6d8>
def readouterr(self):
try:
return self._capture.readouterr()
except AttributeError:
> return self._outerr
E AttributeError: 'CaptureFixture' object has no attribute '_outerr'
/usr/local/lib/python3.5/dist-packages/_pytest/capture.py:208: AttributeError
I tested in with newest pytset on Ubuntu 17.04:
This is pytest version 3.1.2, imported from /usr/local/lib/python3.5/dist-packages/pytest.py
This is pytest version 3.1.2, imported from /usr/local/lib/python2.7/dist-packages/pytest.pyc
Do I correctly combine built-in fixtures with unittest.TestCase? Are you planning to support this test case?
bra-fsn
Metadata
Metadata
Assignees
Labels
No labels