Skip to content
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

Order of settings and transactional_db fixtures #870

Open
bdauvergne opened this issue Sep 24, 2020 · 2 comments · May be fixed by #871
Open

Order of settings and transactional_db fixtures #870

bdauvergne opened this issue Sep 24, 2020 · 2 comments · May be fixed by #871

Comments

@bdauvergne
Copy link

I use both in my tests and I created a media fixture (creating a temporary media directory and using the settings fixture) with autouse=True, due to alphabetic order it made the settings fixture run before the transactional_db fixture, but my post_migrate handler creating basic models depend upon the settings, in a test testing modification of those settings the teardown of transactional_db calling the flush() run with the modified settings instead of the default settings, modifying the default state of the database.

I think that a way of forcing run of setting before transactional_db must be found, as the post_migrate handler can depend upon the settings.

@bdauvergne bdauvergne changed the title Order of setting and transactional_db Order of settings and transactional_db fixtures Sep 24, 2020
bdauvergne added a commit to bdauvergne/pytest-django that referenced this issue Sep 24, 2020
bdauvergne added a commit to bdauvergne/pytest-django that referenced this issue Sep 24, 2020
bdauvergne added a commit to bdauvergne/pytest-django that referenced this issue Sep 24, 2020
@bluetech
Copy link
Member

I tried to follow what you are saying but the paragraph is a bit long and hard to understand. Can you rephrase it such that a simpleton like me can understand? 😄 The deputy likes dots!

@bdauvergne
Copy link
Author

Simplification would be all pytest-django Django fixtures can depend upon the settings in a way or another but the ordering between the settings fixtures and other fixtures is mainly random. It would be useful that this order is fixed and documented. You can ignore my particular solution in the pull request, it just illustrates the problem. Note that it is a fundamental problem with the way pytest fixtures works, I think that without explicit dependencies between fixtures their ordering depend on their name or point of definition, I don't remember exactly. There is no way to indicate such fixture must run around another without depending on it.

bdauvergne added a commit to bdauvergne/pytest-django that referenced this issue Oct 23, 2021
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

Successfully merging a pull request may close this issue.

2 participants