Hi, we use a common library for system level testing, unfortunately it is tightly coupled to unittest.testcase - we use pytest but obviously this presents some issue(s), primarily lack of full fixture capabilities and parametrization.
Is there any known work around to make this work? I am having a look at the makeitem hook, but I am unsure of how to actually solve it with that.
removing unittest.testcase from the inheritance would require us to fork the library (which we really don't want to do and replacing it out is not viable either as its such a massive piece at the core of our code). Can we hack something somehow to achieve this?
Thanks!
Hi @symonk,
For parametrization you are out of luck, there's no easy workaround for that.
For fixtures though you can use an autouse fixture to inject other fixtures you need:
class T(unittest.TestCase);
@pytest.fixture(autouse=True)
def _inject_fixtures(self, tmpdir, capsys):
self.tmpdir = tmpdir
self.capsys = capsys
def test_foo(self):
self.tmpdir.ensure(dir=1)
...
@symonk I鈥檇 take a look at https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_usefixtures.py , which lets you use pytest fixtures with SeleniumBase, which also inherits from unittest.TestCase .
Most helpful comment
Hi @symonk,
For parametrization you are out of luck, there's no easy workaround for that.
For fixtures though you can use an
autousefixture to inject other fixtures you need: