MCPcopy Index your code
hub / github.com/Breakthrough/PySceneDetect / FakeCallback

Class FakeCallback

tests/test_scene_manager.py:86–106  ·  view source on GitHub ↗

Fake callback used for testing. Tracks the frame numbers the callback was invoked with.

Source from the content-addressed store, hash-verified

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.
86class 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
109def test_detect_scenes_callback(test_video_file):

Calls

no outgoing calls

Tested by 2