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

Function test_load_hardcoded_file

tests/test_stats_manager.py:108–134  ·  view source on GitHub ↗

Test loading a stats file with some hard-coded data generated by this test case.

(tmp_path: Path)

Source from the content-addressed store, hash-verified

106
107
108def test_load_hardcoded_file(tmp_path: Path):
109 """Test loading a stats file with some hard-coded data generated by this test case."""
110
111 path = tmp_path.joinpath("stats.csv")
112 stats_manager = StatsManager()
113 with open(path, "w") as stats_file:
114 stats_writer = csv.writer(stats_file, lineterminator="\n")
115
116 some_metric_key = "some_metric"
117 some_metric_value = 1.2
118 some_frame_key = 100
119 base_timecode = FrameTimecode(0, 29.97)
120 some_frame_timecode = base_timecode + some_frame_key
121
122 # Write out a valid file.
123 stats_writer.writerow([COLUMN_NAME_FRAME_NUMBER, COLUMN_NAME_TIMECODE, some_metric_key])
124 stats_writer.writerow(
125 [some_frame_key + 1, some_frame_timecode.get_timecode(), str(some_metric_value)]
126 )
127
128 stats_manager.load_from_csv(path)
129
130 # Check that we decoded the correct values.
131 assert stats_manager.metrics_exist(some_frame_key, [some_metric_key])
132 assert stats_manager.get_metrics(some_frame_key, [some_metric_key])[0] == pytest.approx(
133 some_metric_value
134 )
135
136
137def test_save_load_from_video(test_video_file, tmp_path: Path):

Callers

nothing calls this directly

Calls 6

load_from_csvMethod · 0.95
metrics_existMethod · 0.95
get_metricsMethod · 0.95
StatsManagerClass · 0.90
FrameTimecodeClass · 0.90
get_timecodeMethod · 0.80

Tested by

no test coverage detected