pytest-dev / pytest-dev/pytest-django

ContentTypes cache not cleared between tests

Open Beginner friendly
#1,156 3 comments 4 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

We've been testing our query counts, and found our tests weren't independent due to the caching of ContentTypes causing query counts to depend on test ordering.

There's a handy pytest-django fixture for clearing the Sites cache but not one for ContentTypes.

Is this something that would be accepted as an addition to this library? It would call ContentType.objects.clear_cache()

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 comparing the existing Sites-cache fixture in pytest_django/plugin.py with Django's ContentType.objects.clear_cache(). Run the relevant pytest-django test suite to understand fixture conventions. Done means the library provides a ContentTypes cache-clearing fixture and tests remain independent of ordering.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
testing-qa
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
85/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.