Skip to content

Clear ContentType cache between tests - #1312

Open
avenet wants to merge 1 commit into
pytest-dev:mainfrom
avenet:issue-1156-clear-contenttypes-cache
Open

Clear ContentType cache between tests#1312
avenet wants to merge 1 commit into
pytest-dev:mainfrom
avenet:issue-1156-clear-contenttypes-cache

Conversation

@avenet

@avenet avenet commented Aug 29, 2026

Copy link
Copy Markdown

Closes #1156.

Clear Django's ContentType cache before each test when django.contrib.contenttypes is installed. This prevents cache state from affecting query-count assertions based on test order.

Tests:

  • .env/bin/python -m pytest tests/test_environment.py -k "clear_site_cache or clear_contenttypes_cache"
  • .env/bin/ruff check pytest_django/plugin.py tests/test_environment.py

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ContentTypes cache not cleared between tests

1 participant