Test loading a corrupted stats file created by outputting data in the wrong format.
(tmp_path: Path)
| 169 | |
| 170 | |
| 171 | def 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) |
nothing calls this directly
no test coverage detected