Skip to content

django_db_setup data only available before first tearDown #788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
frruit opened this issue Dec 4, 2019 · 2 comments
Open

django_db_setup data only available before first tearDown #788

frruit opened this issue Dec 4, 2019 · 2 comments

Comments

@frruit
Copy link

frruit commented Dec 4, 2019

Hi,
Inside the conftest.py I have following configuration

@pytest.fixture(scope='session')
def django_db_setup(django_db_setup, django_db_blocker):
    with django_db_blocker.unblock():
        call_command('loaddata', 'tests/test_data/test_data1.json', database='default')
        call_command('loaddata', 'tests/test_data/test_data2.json', database='ipr')

As you can see i use two different DB's

However, test first test case has access to the populated data and is successful but all test cases after that have no data. After debugging I have figured out that the tearDown methods flushs the db and no loaddata occures anymore.

HELP, I need somebody :-)

@blueyed
Copy link
Contributor

blueyed commented Dec 4, 2019

This is with transactional_db then I assume?
It's a known issue, and there should be some discussion / more insight with others here probably already.
Search for "serialized rollback" also maybe, which is meant to help with that IIRC.

@bluetech
Copy link
Member

This will be fixed with #970, though you'd need to enable serialized rollbacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants