Skip to content

Streamline test suite with shared, session-scoped pytest fixtures #403

Description

@animmosmith

Raised by @emlynjdavies on #394. pyopia/tests/conftest.py (added in #394) uses @pytest.fixture(scope='session') to share expensive real setup (network download of the example model/image, a real end-to-end process run) across multiple tests instead of repeating it per test.

This differs from the existing pattern in test_pipeline.py and test_classify.py, where each test function independently opens its own tempfile.TemporaryDirectory() and downloads its own copy of example data via pyopia.exampledata, even when another test elsewhere needs the same thing. Concretely, test_classify.py::test_match_to_database and #394's silcam_example_files fixture each separately download the same classifier model.

Proposed: promote the shared download/setup fixtures to a top-level conftest.py, and replace manual tempfile.TemporaryDirectory() usage with pytest's built-in tmp_path/tmp_path_factory fixtures across test_pipeline.py and test_classify.py. Should reduce redundant downloads and pipeline runs, and cut test-suite runtime.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions