Skip to content

Honor serialized rollback fixture alongside django_db marker - #1322

Open
AryanRG wants to merge 1 commit into
pytest-dev:mainfrom
AryanRG:fix/serialized-rollback-marker-fixture
Open

AryanRG wants to merge 1 commit into
pytest-dev:mainfrom
AryanRG:fix/serialized-rollback-marker-fixture

Conversation

@AryanRG

@AryanRG AryanRG commented Oct 17, 2026

Copy link
Copy Markdown

Summary

When a transactional test has both @pytest.mark.django_db and the declared django_db_serialized_rollback fixture, database setup currently uses only the marker's serialized_rollback value. With the default marker value, migrated data is not serialized for restoration even though the fixture enables serialized rollback at execution time. A later transactional test can therefore lose rows inserted by a data migration.

This change makes collection-time database serialization consider either the marker or the declared rollback fixture, matching the existing execution-time behavior. It adds a regression using a real data migration and two successive transactional tests, plus controls for marker and fixture combinations. Dynamic fixture lookup is not changed.

Validation

  • Before the fix: four new regression cases failed and two controls passed on both Django 5.2.18 and 6.1.2.
  • After the fix: all six cases passed on both versions.
  • Django 5.2 adjacent database/fixture suites: 136 passed, 2 skipped.
  • Django 6.1 full suite: 246 passed, 2 skipped.
  • Ruff lint/format and git diff --check: passed.

Tests were run with SQLite on macOS. PostgreSQL, MySQL, other platforms, and the full hosted matrix remain unverified locally.

AI assistance was used to prepare the implementation and regression tests.

This branch has not been deployed

No deployments
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.

1 participant