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

Function test_load_corrupt_stats

tests/test_stats_manager.py:171–198  ·  view source on GitHub ↗

Test loading a corrupted stats file created by outputting data in the wrong format.

(tmp_path: Path)

Source from the content-addressed store, hash-verified

169
170
171def test_load_corrupt_stats(tmp_path: Path):
172 """Test loading a corrupted stats file created by outputting data in the wrong format."""
173
174 stats_manager = StatsManager()
175
176 path = tmp_path.joinpath("stats.csv")
177 with open(path, "w") as stats_file:
178 stats_writer = csv.writer(stats_file, lineterminator="\n")
179
180 some_metric_key = "some_metric"
181 some_metric_value = str(1.2)
182 some_frame_key = 100
183 base_timecode = FrameTimecode(0, 29.97)
184 some_frame_timecode = base_timecode + some_frame_key
185
186 # Write out some invalid files.
187
188 # File #0: Wrong Header Names [StatsFileCorrupt]
189 # Swapped timecode & frame number.
190 stats_writer.writerow([COLUMN_NAME_TIMECODE, COLUMN_NAME_FRAME_NUMBER, some_metric_key])
191 stats_writer.writerow(
192 [some_frame_key, some_frame_timecode.get_timecode(), some_metric_value]
193 )
194
195 stats_file.close()
196
197 with pytest.raises(StatsFileCorrupt):
198 stats_manager.load_from_csv(path)

Callers

nothing calls this directly

Calls 5

load_from_csvMethod · 0.95
StatsManagerClass · 0.90
FrameTimecodeClass · 0.90
get_timecodeMethod · 0.80
closeMethod · 0.80

Tested by

no test coverage detected