def db_session(request, django_db_setup, django_db_blocker): if 'django_db_reset_sequences' in request.funcargnames: request.getfixturevalue('django_db_reset_sequences') if 'transactional_db' in request.funcargnames or 'live_server' in request.funcargnames: request.getfixturevalue('transactional_db') else: _django_db_fixture_helper(request, django_db_blocker, transactional=False)
def class_scoped_db(request, django_db_blocker): """A class-scoped DB fixture The normal pytest-django `db` fixture is function-scoped, meaning that it gets torn down and set up again for every test case in a class. This reproduces the core bits of that with class scope, allowing a class with multiple tests in which the same DB transaction is used for all tests in the class. """ _django_db_fixture_helper(request=request, django_db_blocker=django_db_blocker)
def enable_db_access_for_all_tests(request, django_db_setup, django_db_blocker): from pytest_django.fixtures import _django_db_fixture_helper django_db_blocker.unblock() _django_db_fixture_helper(request, django_db_blocker, transactional=True)