pytest-dev / pytest-dev/pytest-django

Reset values of settings fixture does not work on mutable types?

Open
#601 17 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi,

together with @jnns we stumbled upon this issue:

we have a dictionary in our settings_test.py where one key is just holding a boolean value.

In one test we modify that boolean value and on the next test the default value set on settings_test.py is not there, but rather the value set on the previous test.

On regular, plain values, i.e. MY_SETTING = 3 the value is reset perfectly from test to test, but seems that it does not handle mutable types like dictionaries, could it be?

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 behavior described in settings_test.py: mutate a dictionary-backed setting in one test and check its value in the next. Trace the fixture reset behavior for mutable settings, then confirm that the default value is restored between tests without changing the existing reset behavior for plain values.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.