Skip to content

Commit 8bd9c25

Browse files
committed
add test cases for method extract_frams_as_images
1 parent d6cceee commit 8bd9c25

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/test_utils.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,23 @@ def test_convert_timeframe(self):
105105
for times in zip((3.337, 6.674), vdh.convert_timeframe(self.mmif_obj, timeframe_ann, 's')):
106106
self.assertAlmostEqual(*times, places=0)
107107

108+
def test_extract_frams_as_images(self):
109+
frame_list = [5, 10, 15]
110+
target_images = vdh.extract_frames_as_images(self.video_doc, frame_list, as_PIL=False)
111+
self.assertEqual(3, len(target_images))
112+
# check if the extract_frames_as_images destroy the input frame list
113+
self.assertEqual(3, len(frame_list))
114+
# check return empty list if the frame list is empty
115+
empty_flist = []
116+
empty_target_images = vdh.extract_frames_as_images(self.video_doc, empty_flist, as_PIL=False)
117+
self.assertEqual([], empty_target_images)
118+
# check there is an error if there is a frame in the list that does not exist
119+
tot_fcount = self.video_doc.get_property('frameCount')
120+
frame_list.append(tot_fcount + 1)
121+
new_target_images = vdh.extract_frames_as_images(self.video_doc, frame_list, as_PIL=False)
122+
self.assertEqual(4, len(frame_list))
123+
self.assertEqual(3, len(new_target_images))
124+
108125

109126
class TestSequenceHelper(unittest.TestCase):
110127

0 commit comments

Comments
 (0)