Context
Identified during review of #558 (558-radionuclides-backfill branch).
Problem
The after_scenario cleanup for chemistry backfill data in environment.py (lines ~747–835) performs a long chain of FK-ordered deletes with no try/except. If any single delete fails (e.g., an unexpected FK dependency), the session.commit() never runs, all cleanup is lost, and orphan data causes cascading failures in subsequent test scenarios.
Fix
Wrap the cleanup block in try/except. On failure, log the scenario name and error with exc_info=True so developers can diagnose. Consider a fallback that deletes observations by nma_pk_chemistryresults IS NOT NULL as a safety net.
Files
tests/features/environment.py (after_scenario chemistry backfill cleanup block)
Context
Identified during review of #558 (
558-radionuclides-backfillbranch).Problem
The
after_scenariocleanup for chemistry backfill data inenvironment.py(lines ~747–835) performs a long chain of FK-ordered deletes with no try/except. If any single delete fails (e.g., an unexpected FK dependency), thesession.commit()never runs, all cleanup is lost, and orphan data causes cascading failures in subsequent test scenarios.Fix
Wrap the cleanup block in try/except. On failure, log the scenario name and error with
exc_info=Trueso developers can diagnose. Consider a fallback that deletes observations bynma_pk_chemistryresults IS NOT NULLas a safety net.Files
tests/features/environment.py(after_scenariochemistry backfill cleanup block)