-
Notifications
You must be signed in to change notification settings - Fork 347
django_db_setup runs inside transactional_db transaction #595
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
Comments
Hitting this as well. It appears that fixture data loaded in We're loading fixture data in
Tests that run prior to the
... but once we run a transaction test case, subsequent tests are missing the fixture data.
If whatever subset of tests we run (using e.g. |
IIRC "serialized_rollback" is required for this, which I've started a while ago in #353 - maybe you want to pick it up? |
@yourcelf |
Also relevant: #214 |
Thanks for the suggestions @blueyed. I tried adding this definition to
Is that what you meant by loading data in an overwritten This didn't have any change in the availability of fixture data after running a test with |
Try just that: import pytest
from django.core.management import call_command
@pytest.fixture(scope='function')
def transactional_db(transactiona_db, request, django_db_setup, django_db_blocker):
with django_db_blocker.unblock():
call_command('loaddata', 'myfixture.json') |
No change... with only the |
That is expected. Too bad it does not work. |
I think I have a similar problem. I have two separate test functions, and both with The first function test all database constraints of the FooBarModel. The second function test if the automatic records are created as expected. (I use a fixture to create instances of the other models, and by consequence will some records in FooBarModel table) after the first test function is executed, the database no longer has the data included by the data migration (apparently this data was removed) and because of this, the second function fails to verify that the data included in the migration exists in the database. I expected An update: I use MySQL |
Hi @luzfcb I'm experiencing exactly the same issues. Do you have any suggestions as to how to fix it? |
Same here! |
Hello, currently encountering this problem - is there a workaround that anyone is aware of please? Thank you |
This probably can be solved by adding support to serialized_rollback On pull-request #721 I have tried to put together some of the solutions, but the approach is not yet 100% functional. It would be nice to have new eyes on that pull-request. |
I'm experiencing exactly the same issues. |
We have also observed this issue. Are there workarounds know to avoid this issue? Some solutions perhaps? |
I reproduced this issue and can confirm that it is fixed in #970, using |
If the first db test that gets run happens to have
transactional_db
(ordjango_db(transaction=True)
) then all subsequent db tests will fail.This appears to be because the db setup (migrations etc.) are all rolled-back and will not run again because
django_db_setup
is session-scoped.The text was updated successfully, but these errors were encountered: