mirror of
https://github.com/apache/superset.git
synced 2026-07-15 11:15:44 +00:00
The version-history integration tests follow the codebase's dominant pattern: a trailing ``# Cleanup`` block at the end of each test that restores the fixture entity's mutated scalar fields (``description``, ``slice_name``, ``dashboard_title``). The pattern is brittle — when any intermediate assertion fails, the cleanup is never reached and the fixture stays polluted with the test's last edit, cascading state into later tests in the same suite run. This bit hard in CI's full-suite Postgres ordering: a failure in ``test_restore_applies_scalar_field`` left ``description="restore-test v2"`` on the birth_names dataset, polluting downstream tests including the RLS virtual-dataset cascade. The same shape is latent in the chart and dashboard files. Convert every mutating test in the three version-history files to wrap the mutation block in ``try:`` and the restoration in ``finally:``, with a ``db.session.rollback()`` at the top of the finally to clear any half-flushed state left by a 422 response. Re-query the entity by id inside the finally so the restore writes against a live object rather than a stale handle the failing path may have expired or detached. Pure hygiene improvement — doesn't fix the underlying Postgres failure chain (still triggered by ``model_tests.py``'s interaction with later tests in the full-suite ordering), but prevents this set of tests from amplifying any future cascade. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>