Closed
Description
I am in the middle of writing a pytest plugin and noticed that pytest_pyfunc_call
is not called on tests that have unittest.TestCase
subclassed. This method is called correctly when the test class subclasses object
or just plain function tests.
I have created a simple example to explain the bug.
conftest.py
@pytest.hookimpl(hookwrapper=True)
def pytest_pyfunc_call(pyfuncitem):
outcome = yield
try:
outcome.get_result() # will raise if outcome was exception
print('success')
except Exception:
print('Failed')
import unittest
class TestStupid(unittest.TestCase):
def test_a(self):
assert 1 == 1
def test_b(self):
assert 2 == 2
def test_error(self):
assert 2 != 2
I am using pytest==3.6.1 on Python 3.6. Tried it on a Mac and Ubuntu Trusty.
I can get around the issue by using pytest_runtest_setup
and pytest_runtest_teardown
but unable to get the result of the test this way.