Problem
The storage singleton in utils/storage.py is a module-level global. Tests that create remediations, reports, or batch jobs (e.g., test_remediation.py, test_reports.py, test_platforms.py) add data to this shared instance that is never cleared between test runs.
This can cause:
- Order-dependent test failures
- Tests passing in isolation but failing when run together
- Unexpected data from earlier tests affecting later assertions
Suggested Fix
Add a pytest fixture that resets the storage before each test:
@pytest.fixture(autouse=True)
def reset_storage():
storage._reports.clear()
storage._jobs.clear()
storage._remediations.clear()
Or better yet, use FastAPI's dependency injection to provide storage per-request in tests.
Problem
The
storagesingleton inutils/storage.pyis a module-level global. Tests that create remediations, reports, or batch jobs (e.g.,test_remediation.py,test_reports.py,test_platforms.py) add data to this shared instance that is never cleared between test runs.This can cause:
Suggested Fix
Add a pytest fixture that resets the storage before each test:
Or better yet, use FastAPI's dependency injection to provide storage per-request in tests.