From 4fbbebe5cb5294edf50b8d7c85d86a9b1ea550bd Mon Sep 17 00:00:00 2001 From: Julia Dark <24235303+jp-dark@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:43:33 -0500 Subject: [PATCH] Close `Scene` classes in fixture before re-opening (#3475) --- .../python/tests/test_experiment_query_spatial.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apis/python/tests/test_experiment_query_spatial.py b/apis/python/tests/test_experiment_query_spatial.py index 14dc9cda3e..47b52c8b04 100644 --- a/apis/python/tests/test_experiment_query_spatial.py +++ b/apis/python/tests/test_experiment_query_spatial.py @@ -134,6 +134,7 @@ def add_scene( for key, shapes in images.items(): add_multiscale_image(scene, key, shapes) + scene.close() @pytest.fixture(scope="module") @@ -202,7 +203,14 @@ def soma_spatial_experiment(tmp_path_factory) -> soma.Experiment: scene_ids.flatten().tolist(), ) - return soma.Experiment.open(uri) + exp = soma.Experiment.open(uri) + + # Check coordinate spaces. + for index in range(4): + scene = exp.spatial[f"scene{index}"] + assert scene.coordinate_space is not None + + return exp def check_for_scene_data(sdata, has_scenes: List[bool]): @@ -271,6 +279,11 @@ def test_spatial_experiment_query_all(soma_spatial_experiment): # Read to SpatialData. sdata = query.to_spatialdata("data") + # Check the expected scenes are included. + scene_ids = set(str(val) for val in query.obs_scene_ids()) + expected_scene_ids = {"scene0", "scene1", "scene2", "scene3"} + assert scene_ids == expected_scene_ids + # Verify the correct number of assets. assert len(sdata.tables) == 1 assert len(sdata.points) == 8