From 6843253435afe2cab217f785d9b0aa5f4c88b423 Mon Sep 17 00:00:00 2001 From: Malia Gehan Date: Fri, 29 Mar 2024 10:50:25 -0500 Subject: [PATCH] tests refactor tests slightly. --- tests/test_napari_classes.py | 7 +------ tests/test_napari_label_classes.py | 7 +------ tests/test_napari_open.py | 27 ++++++--------------------- 3 files changed, 8 insertions(+), 33 deletions(-) diff --git a/tests/test_napari_classes.py b/tests/test_napari_classes.py index 094a82d..01f66b8 100644 --- a/tests/test_napari_classes.py +++ b/tests/test_napari_classes.py @@ -2,7 +2,7 @@ from plantcv.annotate import napari_classes -def test_napari_classes(make_napari_viewer, qtbot): +def test_napari_classes(make_napari_viewer): """Test for PlantCV.Annotate""" # Read in test data viewer = make_napari_viewer() @@ -15,9 +15,4 @@ def test_napari_classes(make_napari_viewer, qtbot): face_color="red", size=30) keys = napari_classes(viewer) - def check_keys(): - assert keys != [] - - qtbot.waitUntil(check_keys, timeout=60_000) - assert keys == ['total', 'test'] diff --git a/tests/test_napari_label_classes.py b/tests/test_napari_label_classes.py index 49f7409..50d866d 100644 --- a/tests/test_napari_label_classes.py +++ b/tests/test_napari_label_classes.py @@ -3,7 +3,7 @@ from plantcv.plantcv import readimage -def test_napari_label_classes_gray(make_napari_viewer, qtbot, test_data): +def test_napari_label_classes_gray(make_napari_viewer, test_data): """Test for PlantCV.Annotate""" # Read in test data img, _, _ = readimage(test_data.kmeans_seed_gray_img) @@ -13,9 +13,4 @@ def test_napari_label_classes_gray(make_napari_viewer, qtbot, test_data): viewer.add_points(np.array(coor), symbol="o", name='background', face_color="red", size=1) - def check_open(): - assert np.shape(viewer.layers['background'].data) != (0, 2) - - qtbot.waitUntil(check_open, timeout=60_000) - assert len(viewer.layers['background'].data) == 1 diff --git a/tests/test_napari_open.py b/tests/test_napari_open.py index a066f53..9c4f5cf 100644 --- a/tests/test_napari_open.py +++ b/tests/test_napari_open.py @@ -3,56 +3,41 @@ from plantcv.plantcv import readimage -def test_napari_open_rgb(make_napari_viewer, qtbot, test_data): +def test_napari_open_rgb(viewer_widget, test_data): """Test for PlantCV.Annotate""" # Read in test data img, _, _ = readimage(test_data.small_rgb_img) - viewer = make_napari_viewer() + viewer = viewer_widget viewer = napari_open(img, viewer) coor = [(25, 25), (50, 50)] viewer.add_points(np.array(coor), symbol="o", name="total", face_color="red", size=1) - def check_open(): - assert np.shape(viewer.layers['total'].data) != (0, 2) - - qtbot.waitUntil(check_open, timeout=60_000) - assert len(viewer.layers['total'].data) == 2 -def test_napari_open_gray(make_napari_viewer,qtbot, test_data): +def test_napari_open_gray(viewer_widget, test_data): """Test for PlantCV.Annotate""" # Read in test data img, _, _ = readimage(test_data.kmeans_seed_gray_img) - viewer = make_napari_viewer() + viewer = viewer_widget viewer = napari_open(img, viewer) coor = [(25, 25), (50, 50)] viewer.add_points(np.array(coor), symbol="o", name="total", face_color="red", size=1) - def check_open(): - assert np.shape(viewer.layers['total'].data) != (0, 2) - - qtbot.waitUntil(check_open, timeout=60_000) - assert len(viewer.layers['total'].data) == 2 -def test_napari_open_envi(make_napari_viewer,qtbot, test_data): +def test_napari_open_envi(viewer_widget, test_data): """Test for PlantCV.Annotate""" # Read in test data img = readimage(test_data.envi_sample_data, mode='envi') img = img.array_data - viewer = make_napari_viewer() + viewer = viewer_widget viewer = napari_open(img, viewer) coor = [(25, 25), (50, 50)] viewer.add_points(np.array(coor), symbol="o", name="total", face_color="red", size=1) - def check_open(): - assert np.shape(viewer.layers['total'].data) != (0, 2) - - qtbot.waitUntil(check_open, timeout=60_000) - assert len(viewer.layers['total'].data) == 2