pytest-dev / pytest-dev/pytest-django

Order of settings and transactional_db fixtures

Open
#870 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
367
PR merge metrics
No merged PRs in 30d

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the interaction between the autouse media fixture, the settings fixture, and transactional_db, focusing on the post_migrate handler and transactional_db teardown flush(). No file or test path is named in the issue. Done means modified settings no longer affect teardown database restoration while settings-dependent post_migrate behavior still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
databases, testing
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.