From 1790391e880aa335a0ba47cc072b442a4854db5d Mon Sep 17 00:00:00 2001 From: Han Wang Date: Thu, 18 Apr 2024 13:57:48 +0100 Subject: [PATCH] Fixed four test issues within test code. Signed-off-by: Han Wang --- tests/test_auto3dseg.py | 1 - tests/test_compose.py | 6 +++--- tests/test_pad_collation.py | 2 +- tests/test_to_numpy.py | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/test_auto3dseg.py b/tests/test_auto3dseg.py index e2097679e2..6be33bf6ca 100644 --- a/tests/test_auto3dseg.py +++ b/tests/test_auto3dseg.py @@ -367,7 +367,6 @@ def test_filename_case_analyzer(self): for batch_data in self.dataset: d = transform(batch_data[0]) assert DataStatsKeys.BY_CASE_IMAGE_PATH in d - assert DataStatsKeys.BY_CASE_IMAGE_PATH in d def test_filename_case_analyzer_image_only(self): analyzer_image = FilenameStats("image", DataStatsKeys.BY_CASE_IMAGE_PATH) diff --git a/tests/test_compose.py b/tests/test_compose.py index 309767833b..3c53ac4a22 100644 --- a/tests/test_compose.py +++ b/tests/test_compose.py @@ -716,15 +716,15 @@ def test_compose_execute_equivalence_with_flags(self, flags, data, pipeline): for k in actual.keys(): self.assertEqual(expected[k], actual[k]) else: - self.assertTrue(expected, actual) + self.assertEqual(expected, actual) p = deepcopy(pipeline) actual = execute_compose(execute_compose(data, p, start=0, end=cutoff, **flags), p, start=cutoff, **flags) if isinstance(actual, dict): for k in actual.keys(): - self.assertTrue(expected[k], actual[k]) + self.assertEqual(expected[k], actual[k]) else: - self.assertTrue(expected, actual) + self.assertEqual(expected, actual) class TestComposeCallableInput(unittest.TestCase): diff --git a/tests/test_pad_collation.py b/tests/test_pad_collation.py index ee6e001438..17f49611df 100644 --- a/tests/test_pad_collation.py +++ b/tests/test_pad_collation.py @@ -117,7 +117,7 @@ def test_pad_collation(self, t_type, collate_method, transform): batch_inverse = BatchInverseTransform(dataset.transform, loader) for data in loader: output = batch_inverse(data) - self.assertTrue(output[0]["image"].shape, (1, 10, 9)) + self.assertEqual(output[0]["image"].shape, (1, 10, 9)) if __name__ == "__main__": diff --git a/tests/test_to_numpy.py b/tests/test_to_numpy.py index 8f7cf34865..f92b7c0075 100644 --- a/tests/test_to_numpy.py +++ b/tests/test_to_numpy.py @@ -71,7 +71,7 @@ def test_list_tuple(self): assert_allclose(result, np.asarray(test_data), type_test=False) test_data = ((1, 2), (3, 4)) result = ToNumpy(wrap_sequence=False)(test_data) - self.assertTrue(type(result), tuple) + self.assertIsInstance(result, tuple) assert_allclose(result, ((np.asarray(1), np.asarray(2)), (np.asarray(3), np.asarray(4)))) def test_single_value(self):