Skip to content

Conversation

@amureki
Copy link
Member

@amureki amureki commented Jan 18, 2026

Describe the change
Finally figured (hopefully) out where flaky ContentType tests are coming from.
pytest-dev/pytest-django#1156

Adding a fixture to clear the cache between the tests.

PR Checklist

  • Change is covered with tests
  • CHANGELOG.md is updated if needed

Summary by CodeRabbit

  • Tests
    • Improved test stability by fixing cache-related issues that could cause intermittent test failures, particularly on PostgreSQL systems.

✏️ Tip: You can customize this high-level summary in your review settings.

@amureki amureki self-assigned this Jan 18, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 18, 2026

📝 Walkthrough

Walkthrough

A test fixture was added to clear the ContentType cache between test executions, preventing stale cache entries from rolled-back transactions and avoiding foreign key violations on PostgreSQL.

Changes

Cohort / File(s) Summary
Test fixture for cache management
tests/test_filling_fields.py
Added clear_content_type_cache autouse fixture within TestFillingGenericForeignKeyField class that clears ContentType cache between tests to prevent FK violations from transaction rollbacks

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A cache that lingers? Not on our watch!
With fixtures so clever, we clear every blotch,
Transactions may rollback, but we've got the cure,
ContentType chaos? We'll keep tests pure! 🧹✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix flaky CT tests' directly addresses the main purpose of the changeset - fixing flaky ContentType (CT) tests by adding a cache-clearing fixture.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@amureki amureki merged commit a318fa0 into main Jan 18, 2026
45 checks passed
@amureki amureki deleted the flaky-ct-tests branch January 18, 2026 22:14
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.

2 participants