Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Order of setting and transactional_db[/-][+]Order of settings and transactional_db fixtures[/+]Force ordering of settings and transactional_db fixtures pytest-dev#870
Force ordering of settings and transactional_db fixtures pytest-dev#870
Force ordering of settings and transactional_db fixtures pytest-dev#870
bluetech commentedon Apr 10, 2021
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 commentedon Apr 11, 2021
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.
Force ordering of settings and transactional_db fixtures pytest-dev#870