Answers for "django pytest how to load data"

0

django pytest how to load data

@pytest.fixture(autouse=True)
def setup(self, db):
    call_command('loaddata', './apps/accounts/fixtures/accounts.json')
    call_command('loaddata', './apps/activation/fixtures/activation.json')
    call_command('loaddata', './apps/questionnaire/fixtures/questionnaire.json')
Posted by: Guest on February-26-2022
0

django pytest how to load data

from pytest_django.fixtures import _django_db_fixture_helper

@pytest.fixture(autoscope='module')
def setup_db(request, django_db_setup, django_db_blocker):
    _django_db_fixture_helper(request,·django_db_blocker)
    call_command('loaddata', 'path/to/fixture.json')
Posted by: Guest on February-26-2022

Python Answers by Framework

Browse Popular Code Answers by Language