You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got tests which rely on a database with initial data (which is possible as explained here). I want to check that the initial data are present as expected and that my custom setup/teardown functions work well. Whether I use db (TestCase) or transactional_db (TransactionTestCase) should not matter in my test suite.
Thus, I wanted to use indirect parametrization as suggested here, in order not to write twice the same tests (DRY)...
@pytest.mark.parametrize("db_access", ["db", "transactional_db"], indirect=True)classTestInitialData:
@pytest.fixture(autouse=True)defdb_access(self, request):
returnrequest.getfixturevalue(request.param)
deftest_example(self):
pass# many other tests
No error is raised in this example, but it turns out (though that was hard to notice) that it doesn't work as expected: all tests use django.test.TestCase and are run twice without transaction support.
Admittedly, that's an edge case, but after having carefully read the documentation of pytest, pytest-django and django itself, I think it can be considered a bug.
I would say that the issue stems from the implementation of pytest_django.fixtures._django_db_helper which don't take into account indirect parametrization. Am I missing something?
The text was updated successfully, but these errors were encountered:
I've got tests which rely on a database with initial data (which is possible as explained here). I want to check that the initial data are present as expected and that my custom setup/teardown functions work well. Whether I use
db
(TestCase
) ortransactional_db
(TransactionTestCase
) should not matter in my test suite.Thus, I wanted to use indirect parametrization as suggested here, in order not to write twice the same tests (DRY)...
No error is raised in this example, but it turns out (though that was hard to notice) that it doesn't work as expected: all tests use
django.test.TestCase
and are run twice without transaction support.Admittedly, that's an edge case, but after having carefully read the documentation of
pytest
,pytest-django
anddjango
itself, I think it can be considered a bug.I would say that the issue stems from the implementation of
pytest_django.fixtures._django_db_helper
which don't take into account indirect parametrization. Am I missing something?The text was updated successfully, but these errors were encountered: