Skip to content

Chemistry backfill test cleanup should handle errors gracefully #566

@kbighorse

Description

@kbighorse

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions