Skip to content

Global storage singleton leaks state between tests #17

@jtdub

Description

@jtdub

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions