Skip to content

Commit 8cb02cc

Browse files
refactored tests finally
1 parent 64bf5b2 commit 8cb02cc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

test_main.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,25 @@ class TestMainFunction(unittest.TestCase):
1212

1313
def test_missing_input_image(self):
1414
# Test with a missing input image
15+
print('Test1 on Nonexisting image')
1516
with self.assertRaises(FileNotFoundError):
1617
main.preprocess_image('/nonexistent/image.jpg')
1718

1819
def test_tensor_size(self):
1920
input_dir = "input_raw"
2021
resized_image_path = os.path.join(input_dir, "image.jpg")
2122
image, img_shape, img_type = main.preprocess_image(resized_image_path)
22-
print(img_shape, img_type)
23-
self.assertNotEqual(img_shape, (1,2,3), 'Equal Shape')
23+
print('Test2 on Tensor Size')
24+
print(len(img_shape))
25+
self.assertNotEqual(img_shape, torch.Size([1, 3, 3031, 5184]), 'Not equal Shape')
2426

2527
def test_image_type(self):
2628
input_dir = "input_raw"
2729
resized_image_path = os.path.join(input_dir, "image.jpg")
2830
image, img_shape, img_type = main.preprocess_image(resized_image_path)
29-
print(img_shape, img_type)
30-
self.assertNotEqual(img_type, int, 'Equal Image Type')
31+
print('Test3 on Image Type')
32+
print(img_type, str(img_type))
33+
self.assertEqual(img_type, "<class 'torch.Tensor'>", 'Equal Image Type')
3134

3235
if __name__ == '__main__':
3336
unittest.main()

0 commit comments

Comments
 (0)