Skip to content

Commit 58c9de1

Browse files
Add test for frame status to conversion tests
If the frame is not complete, it might mean that no data was written to it and that all pixels still contain `0x00` as value from the buffer initialization. This makes the assertions further down in the test cases useless where it is asserted, that data was written to the expected buffers.
1 parent 71b804a commit 58c9de1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Tests/real_cam_tests/frame_test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@ def test_conversion_writes_to_user_supplied_buffer(self):
299299
target_format = PixelFormat.Bgr8
300300
self.cam.set_pixel_format(record_format)
301301
original_frame = self.cam.get_frame()
302+
self.assertEqual(original_frame.get_status(),
303+
FrameStatus.Complete,
304+
'Recorded frame was not complete. We cannot reliably work with a possibly '
305+
'empty frame because we want to check if pixel values are written '
306+
'correctly.')
302307
# Do conversion once without user supplied buffer. This creates a new VmbPy Frame with fresh
303308
# buffer. We can then reuse that buffer for future conversions
304309
np_buffer = original_frame.convert_pixel_format(target_format).as_numpy_ndarray()
@@ -317,6 +322,11 @@ def test_conversion_to_same_format_as_input(self):
317322
record_format = PixelFormat.Mono8
318323
self.cam.set_pixel_format(record_format)
319324
original_frame = self.cam.get_frame()
325+
self.assertEqual(original_frame.get_status(),
326+
FrameStatus.Complete,
327+
'Recorded frame was not complete. We cannot reliably work with a possibly '
328+
'empty frame because we want to check if pixel values are written '
329+
'correctly.')
320330
# Do conversion once without user supplied buffer. This creates a new VmbPy Frame with fresh
321331
# buffer. We can then reuse that buffer for future conversions
322332
np_buffer = original_frame.convert_pixel_format(original_frame.get_pixel_format()) \
@@ -342,6 +352,11 @@ def test_image_data_is_as_expected(self):
342352
except ValueError:
343353
self.skipTest(f'{str(self.cam)} does not support pixel format "{record_format}"')
344354
original_frame = self.cam.get_frame()
355+
self.assertEqual(original_frame.get_status(),
356+
FrameStatus.Complete,
357+
'Recorded frame was not complete. We cannot reliably work with a possibly '
358+
'empty frame because we want to check if pixel values are written '
359+
'correctly.')
345360
# Do conversion once without user supplied buffer. This creates a new VmbPy Frame with fresh
346361
# buffer. We can then reuse that buffer for future conversions
347362
np_buffer = original_frame.convert_pixel_format(target_format).as_numpy_ndarray()
@@ -364,6 +379,11 @@ def test_numpy_reports_shared_memory_for_user_buffer_and_new_ndarray(self):
364379
target_format = PixelFormat.Bgr8
365380
self.cam.set_pixel_format(record_format)
366381
original_frame = self.cam.get_frame()
382+
self.assertEqual(original_frame.get_status(),
383+
FrameStatus.Complete,
384+
'Recorded frame was not complete. We cannot reliably work with a possibly '
385+
'empty frame because we want to check if pixel values are written '
386+
'correctly.')
367387
# Do conversion once without user supplied buffer. This creates a new VmbPy Frame with fresh
368388
# buffer. We can then reuse that buffer for future conversions
369389
np_buffer = original_frame.convert_pixel_format(target_format).as_numpy_ndarray()

0 commit comments

Comments
 (0)