From e9a2ede950187b89a1dfa7c0f11f82fd3af1241a Mon Sep 17 00:00:00 2001 From: BO ZHANG Date: Tue, 23 Aug 2022 15:17:17 +0800 Subject: [PATCH] added unit test --- tests/test_flip_image.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/test_flip_image.py diff --git a/tests/test_flip_image.py b/tests/test_flip_image.py new file mode 100644 index 0000000..bfce6b7 --- /dev/null +++ b/tests/test_flip_image.py @@ -0,0 +1,21 @@ +import unittest + +import numpy as np + +from csst_proto.top_level_interface import flip_image, read_test_image + + +class FlipImageTestCase(unittest.TestCase): + def test_flip_image(self): + # flip test image + self.assertTrue( + np.all(flip_image(read_test_image()) == np.array([[4, 3], [2, 1]])) + ) + + # the code fails for 1D array + with self.assertRaises(AssertionError): + flip_image(np.array([1, 2, 3, 4])) + + +if __name__ == "__main__": + unittest.main() -- GitLab