Current pytest framework isn't fully compatible with unittest.TestCase, we should consider migrate to pytest framework:
The following pytest features do not work, and probably never will due to different design philosophies:
Fixtures (except for autouse fixtures, see below);
Parametrization;
Custom hooks;
For example pytest.mark.parametrize doesn't work:
from unittest import TestCase
import pytest
class TestPytest(TestCase):
@pytest.mark.parametrize("foo", ["hello", "world"])
def test_demo(self, foo):
assert isinstance(foo, str)
Gives:
def _callTestMethod(self, method):
> if method() is not None:
E TypeError: TestPytest.test_demo() missing 1 required positional argument: 'foo'
While the following works just fine:
- class TestPytest(TestCase):
+ class TestPytest:
Current
pytestframework isn't fully compatible withunittest.TestCase, we should consider migrate topytestframework:For example
pytest.mark.parametrizedoesn't work:parametrizein unittest.TestCase pytest-dev/pytest#5382Gives:
While the following works just fine: