From 8b8d6e13a6c033543692f3a1a102de2fbd20b0b0 Mon Sep 17 00:00:00 2001 From: alessandrofelder Date: Mon, 29 Apr 2024 16:20:21 +0100 Subject: [PATCH] distinguish datatypes in test assertions --- .../test_unit/test_regions/test_region_analysis.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/tests/test_unit/test_regions/test_region_analysis.py b/tests/tests/test_unit/test_regions/test_region_analysis.py index 58bb6bf..3c4bf86 100644 --- a/tests/tests/test_unit/test_regions/test_region_analysis.py +++ b/tests/tests/test_unit/test_regions/test_region_analysis.py @@ -99,7 +99,10 @@ def test_summarise_brain_regions_all_not_empty( df = pd.read_csv(filename) assert df.shape == (3, 11) for key, value in previous_world_space_values.items(): - assert np.isclose(df[key].iloc[0],value) + if isinstance(value, (int, float)): + assert np.isclose(df[key].iloc[0], value) + else: + assert df[key].iloc[0] == value def test_summarise_brain_regions_some_empty( @@ -124,8 +127,10 @@ def test_summarise_brain_regions_some_empty( df = pd.read_csv(filename) assert df.shape == (1, 11) for key, value in previous_world_space_values.items(): - assert np.isclose(df[key].iloc[0], value) - + if isinstance(value, (int, float)): + assert np.isclose(df[key].iloc[0], value) + else: + assert df[key].iloc[0] == value def test_summarise_brain_regions_all_empty( labels_layer, empty_labels_layer, tmp_path