-
Notifications
You must be signed in to change notification settings - Fork 347
django_db_serialized_rollback
does not reset to previous db state
#1062
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
I might have misunderstood the application of the I was hoping I could restore the migration data after running my |
I came across this issue as well, that after adding a My investigation suggest this was not a The same author who summarised the issue in the above link also made a pull request here django/django#14147 but unfortunately it wasn't merged. If you're using |
Just running into the same problem and lost 2 days trying to understand what's going on. Didn't know about the serialized_rollback and thought it would solve my problem, but it runs the deserialization before the test run, while I was expecting it to run as a teardown of the test. |
Ce commit s'assure que tous les tests E2E de l'application soient OK qu'ils soient lancés individuellement ou dans leur ensemble. - Certains tests sont supprimés car les features n'existent plus - Correction id en double dans le HTML - Correcton des coordonnées manquantes dans le formulaire - Utilisation de `serialized_rollback=True` pour s'assurer que les données créés dans les migrations soient toujours présentent pour les autre tests - Ajout d'utilitaire pour créer des fiches détections plus facilement pytest-dev/pytest-django#1062 pytest-dev/pytest-django#970 pytest-dev/pytest-django#329
Ce commit s'assure que tous les tests E2E de l'application soient OK qu'ils soient lancés individuellement ou dans leur ensemble. - Certains tests sont supprimés car les features n'existent plus - Correction id en double dans le HTML - Correcton des coordonnées manquantes dans le formulaire - Utilisation de `serialized_rollback=True` pour s'assurer que les données créés dans les migrations soient toujours présentent pour les autre tests - Ajout d'utilitaire pour créer des fiches détections plus facilement pytest-dev/pytest-django#1062 pytest-dev/pytest-django#970 pytest-dev/pytest-django#329
I am running into the same issue as everyone above |
Problem description
Ever since I added the
live_server
to my tests, other tests started to fail, that did previously pass.Details
The fixture to setup my browser with live_server support:
Example of how I use that fixture:
The test that fails when (and after) using the live_server fixture:
Context infos:
I am using
--reuse-db
as part of mypytest.ini
file.Problem Analysis
I understand this happens due to improper reset (flush) of the test database after any test using the
live_server
fixture.I did some research and found this issue: #329
This lead me back to the docs of
pytest-django
where I payed closer attention and founddjango_db_serialized_rollback
: https://pytest-django.readthedocs.io/en/latest/helpers.html#std-fixture-django_db_serialized_rollbackAs I understand it, this would in theory restore the content of the test database after a test that uses my fixture.
However this does either not seem to be the case, or not work as expected.
The
user.get_absolute_url()
uses thedjango.contrib
Site model, for which I have a data migration.The content seems to get flushed in the tests using
live_server
and never get restored.Running only the broken test again after running my full test suit, still fails until I recreate the test database manually.
Solution ideas / requests
Workaround: Removing
--reuse-db
.Sadly this is the only reliable way I found so far to get my test to work again.
And even then I need to run
pytest
twice once excluding the tests usinglive_server
and then running them separately.Obviously this is considerably slowing down the (TDD) testing process.
At this point I don't really have any proper solution ideas.
I would be happy to clarify any misunderstandings I have,
and maybe even discuss potential solution ideas
(or at least better workarounds). 😊
If I can provide further context to clarify the issue and use case, I'll gladly provide it.
Looking forward to hearing some feedback. 😅
The text was updated successfully, but these errors were encountered: