Skip to content

Order of settings and transactional_db fixtures #870

Open
@bdauvergne

Description

@bdauvergne

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.

Activity

changed the title [-]Order of setting and transactional_db[/-] [+]Order of settings and transactional_db fixtures[/+] on Sep 24, 2020
bluetech

bluetech commented on Apr 10, 2021

@bluetech
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

bdauvergne commented on Apr 11, 2021

@bdauvergne
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @bdauvergne@bluetech

      Issue actions

        Order of settings and transactional_db fixtures · Issue #870 · pytest-dev/pytest-django