Fake callback used for testing. Tracks the frame numbers the callback was invoked with.
| 84 | # TODO: This would be more readable if the callbacks were defined within the test case, e.g. |
| 85 | # split up the callback function and callback lambda test cases. |
| 86 | class FakeCallback: |
| 87 | """Fake callback used for testing. Tracks the frame numbers the callback was invoked with.""" |
| 88 | |
| 89 | def __init__(self): |
| 90 | self.scene_list: list[int] = [] |
| 91 | |
| 92 | def get_callback_lambda(self): |
| 93 | """For testing using a lambda..""" |
| 94 | return lambda image, frame_num: self._callback(image, frame_num) |
| 95 | |
| 96 | def get_callback_func(self): |
| 97 | """For testing using a callback function.""" |
| 98 | |
| 99 | def callback(image, frame_num): |
| 100 | nonlocal self |
| 101 | self._callback(image, frame_num) |
| 102 | |
| 103 | return callback |
| 104 | |
| 105 | def _callback(self, image, frame_num): |
| 106 | self.scene_list.append(frame_num) |
| 107 | |
| 108 | |
| 109 | def test_detect_scenes_callback(test_video_file): |
no outgoing calls