Skip to content

Commit 378c463

Browse files
committed
Add tests covering HFR timecodes
Change names of tests where name didn't match what was actually tested
1 parent e78464a commit 378c463

1 file changed

Lines changed: 74 additions & 15 deletions

File tree

tests/test_timecode.py

Lines changed: 74 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,22 @@
4949
[["30000/1001", "00:00:00;00"], {}],
5050
[["60000/1000", "00:00:00:00"], {}],
5151
[["60000/1001", "00:00:00;00"], {}],
52+
[["72000/1000", "00:00:00:00"], {}],
53+
[["96000/1000", "00:00:00:00"], {}],
54+
[["100000/1000", "00:00:00:00"], {}],
55+
[["120000/1000", "00:00:00:00"], {}],
56+
[["120000/1001", "00:00:00;00"], {}],
5257
[[(24000, 1000), "00:00:00:00"], {}],
5358
[[(24000, 1001), "00:00:00;00"], {}],
5459
[[(30000, 1000), "00:00:00:00"], {}],
5560
[[(30000, 1001), "00:00:00;00"], {}],
5661
[[(60000, 1000), "00:00:00:00"], {}],
5762
[[(60000, 1001), "00:00:00;00"], {}],
63+
[[(72000, 1000), "00:00:00:00"], {}],
64+
[[(96000, 1000), "00:00:00:00"], {}],
65+
[[(100000, 1000), "00:00:00:00"], {}],
66+
[[(120000, 1000), "00:00:00:00"], {}],
67+
[[(120000, 1001), "00:00:00;00"], {}],
5868
[[12], {"frames": 12000}],
5969
[[24], {"frames": 12000}],
6070
[[23.976, "00:00:00:00"], {}],
@@ -109,6 +119,9 @@ def test_2398_vs_23976():
109119
[["100", "00:00:09:00"], {}, "00:00:09:00", True],
110120
[["120", "00:00:09:00"], {}, "00:00:09:00", True],
111121
[["119.88", "00:00:20;00"], {}, "00:00:20;00", True],
122+
[["119.88", "00:00:20;00"], {}, "00:00:20:00", False],
123+
[["119.88", "01:30:45;100"], {}, "01:30:45;100", True],
124+
[["119.88", "00:09:00:00"], {"force_non_drop_frame": True}, "00:09:00:00", True],
112125
[["ms", "00:00:00.900"], {}, "00:00:00.900", True],
113126
[["ms", "00:00:00.900"], {}, "00:00:00:900", False],
114127
[["24"], {"frames": 49}, "00:00:02:00", True],
@@ -195,6 +208,11 @@ def test_start_seconds_argument_is_zero():
195208
[["59.94", "03:36:09;23"], {}, 3, 36, 9, 23, None],
196209
[["60", "03:36:09:23"], {}, 3, 36, 9, 23, None],
197210
[["59.94", "03:36:09;23"], {}, 3, 36, 9, 23, None],
211+
[["72", "03:36:09:23"], {}, 3, 36, 9, 23, None],
212+
[["96", "03:36:09:23"], {}, 3, 36, 9, 23, None],
213+
[["100", "03:36:09:23"], {}, 3, 36, 9, 23, None],
214+
[["120", "03:36:09:23"], {}, 3, 36, 9, 23, None],
215+
[["119.88", "03:36:09;23"], {}, 3, 36, 9, 23, None],
198216
[["23.98", "03:36:09:23"], {}, 3, 36, 9, 23, None],
199217
[["24", "03:36:09:23"], {}, 3, 36, 9, 23, None],
200218
[["ms", "03:36:09.230"], {}, 3, 36, 9, 230, None],
@@ -229,10 +247,19 @@ def test_timecode_properties_test(args, kwargs, hrs, mins, secs, frs, str_repr):
229247
[["59.94", "13:36:59;59"], {}, None, None, "13:37:00;04"],
230248
[["59.94", "13:39:59;59"], {}, None, None, "13:40:00;00"],
231249
[["29.97", "13:39:59;29"], {}, None, None, "13:40:00;00"],
250+
[["119.88", "00:00:00;00"], {}, 1, None, None],
251+
[["119.88", "00:00:00;119"], {}, 120, None, None],
252+
[["119.88", "00:00:01;00"], {}, 121, None, None],
253+
[["119.88", "00:01:00;00"], {}, 7193, "00:00:59;112", None],
254+
[["119.88", "23:59:59;119"], {}, 10357632, None, None],
255+
[["119.88", "01:00:00;00"], {"force_non_drop_frame": True}, None, "01:00:00:00", None],
256+
[["119.88", "01:00:00:00"], {"force_non_drop_frame": True}, None, "01:00:00:00", None],
257+
[["119.88", "13:36:59;119"], {}, None, None, "13:37:00;08"],
258+
[["119.88", "13:39:59;119"], {}, None, None, "13:40:00;00"],
232259
]
233260
)
234-
def test_tc_to_frame_test_in_2997(args, kwargs, frames, str_repr, tc_next):
235-
"""timecode to frame conversion is ok in 2997."""
261+
def test_ntsc_drop_frame_conversion(args, kwargs, frames, str_repr, tc_next):
262+
"""Test timecode to frame conversion for NTSC drop frame rates (29.97, 59.94, 119.88)."""
236263
tc = Timecode(*args, **kwargs)
237264
if frames is not None:
238265
assert frames == tc._frames
@@ -242,25 +269,22 @@ def test_tc_to_frame_test_in_2997(args, kwargs, frames, str_repr, tc_next):
242269
assert tc_next == tc.next().__str__()
243270

244271

245-
def test_setting_frame_rate_to_2997_forces_drop_frame():
246-
"""Setting the frame rate to 29.97 forces the dropframe to True."""
247-
tc = Timecode("29.97")
248-
assert tc.drop_frame
249-
250-
251-
def test_setting_frame_rate_to_5994_forces_drop_frame():
252-
"""Setting the frame rate to 59.94 forces the dropframe to True."""
253-
tc = Timecode("59.94")
272+
@pytest.mark.parametrize(
273+
"framerate", ["29.97", "59.94", "119.88"]
274+
)
275+
def test_setting_ntsc_frame_rate_forces_drop_frame(framerate):
276+
"""Setting NTSC frame rates forces the dropframe to True."""
277+
tc = Timecode(framerate)
254278
assert tc.drop_frame
255279

256280

257-
def test_setting_frame_rate_to_ms_forces_drop_frame():
281+
def test_setting_framerate_to_ms_enables_ms_frame():
258282
"""Setting the frame rate to ms forces the ms_frame to True."""
259283
tc = Timecode("ms")
260284
assert tc.ms_frame
261285

262286

263-
def test_setting_frame_rate_to_1000_forces_drop_frame():
287+
def test_setting_framerate_to_1000_enables_ms_frame():
264288
"""Setting the frame rate to 1000 forces the ms_frame to True."""
265289
tc = Timecode("1000")
266290
assert tc.ms_frame
@@ -281,6 +305,11 @@ def test_framerate_argument_is_frames():
281305
[["59.94", "03:36:09;23"], {}, "03:36:09;23", 60, "03:36:10;23", 777444],
282306
[["60", "03:36:09:23"], {}, "03:36:09:23", 60, "03:36:10:23", 778224],
283307
[["59.94", "03:36:09:23"], {}, "03:36:09;23", 60, "03:36:10:23", 777444],
308+
[["72", "03:36:09:23"], {}, "03:36:09:23", 120, "03:36:10:71", 933912],
309+
[["96", "03:36:09:23"], {}, "03:36:09:23", 120, "03:36:10:47", 1245168],
310+
[["100", "03:36:09:23"], {}, "03:36:09:23", 120, "03:36:10:43", 1297044],
311+
[["120", "03:36:09:23"], {}, "03:36:09:23", 120, "03:36:10:23", 1556424],
312+
[["119.88", "03:36:09;23"], {}, "03:36:09;23", 120, "03:36:10;23", 1554864],
284313
[["23.98", "03:36:09:23"], {}, "03:36:09:23", 60, "03:36:12:11", 311340],
285314
[["24", "03:36:09:23"], {}, "03:36:09:23", 60, "03:36:12:11", 311340],
286315
[["ms", "03:36:09.230"], {}, "03:36:09.230", 60, "03:36:09.290", 12969291],
@@ -309,6 +338,11 @@ def test_iteration(args, kwargs, str_repr, next_range, last_tc_str_repr, frames)
309338
[["59.94", "03:36:09;23"], {}, ["59.94", "00:00:29;23"], {}, 1764, 1764, "03:36:38;47", "03:36:38;47", 779148, 779148],
310339
[["60", "03:36:09:23"], {}, ["60", "00:00:29:23"], {}, 1764, 1764, "03:36:38:47", "03:36:38:47", 779928, 779928],
311340
[["59.94", "03:36:09;23"], {}, ["59.94", "00:00:29;23"], {}, 1764, 1764, "03:36:38;47", "03:36:38;47", 779148, 779148],
341+
[["72", "03:36:09:23"], {}, ["72", "00:00:29:23"], {}, 2112, 2112, "03:36:38:47", "03:36:38:47", 935904, 935904],
342+
[["96", "03:36:09:23"], {}, ["96", "00:00:29:23"], {}, 2808, 2808, "03:36:38:47", "03:36:38:47", 1247856, 1247856],
343+
[["100", "03:36:09:23"], {}, ["100", "00:00:29:23"], {}, 2924, 2924, "03:36:38:47", "03:36:38:47", 1299848, 1299848],
344+
[["120", "03:36:09:23"], {}, ["120", "00:00:29:23"], {}, 3504, 3504, "03:36:38:47", "03:36:38:47", 1559808, 1559808],
345+
[["119.88", "03:36:09;23"],{}, ["119.88", "00:00:29;23"],{}, 3504, 3504, "03:36:38;47", "03:36:38;47", 1558248, 1558248],
312346
[["23.98", "03:36:09:23"], {}, ["23.98", "00:00:29:23"], {}, 720, 720, "03:36:39:23", "03:36:39:23", 312000, 312000],
313347
[["ms", "03:36:09.230"], {}, ["ms", "01:06:09.230"], {}, 3969231, 720, "04:42:18.461", "03:36:09.950", 16938462, 12969951],
314348
[["ms", "03:36:09.230"], {}, ["ms", "01:06:09.230"], {}, 3969231, 720, "04:42:18.461", "03:36:09.950", 16938462, 12969951],
@@ -337,6 +371,11 @@ def test_op_overloads_add(args1, kwargs1, args2, kwargs2, custom_offset1, custom
337371
[["59.94", "03:36:09;23"], {}, ["59.94", "00:00:29;23"], {}, 1764, 1764, "03:35:39;55", "03:35:39;55", 775620, 775620],
338372
[["60", "03:36:09:23"], {}, ["60", "00:00:29:23"], {}, 1764, 1764, "03:35:39:59", "03:35:39:59", 776400, 776400],
339373
[["59.94", "03:36:09;23"], {}, ["59.94", "00:00:29;23"], {}, 1764, 1764, "03:35:39;55", "03:35:39;55", 775620, 775620],
374+
[["72", "03:36:09:23"], {}, ["72", "00:00:29:23"], {}, 2112, 2112, "03:35:39:71", "03:35:39:71", 931680, 931680],
375+
[["96", "03:36:09:23"], {}, ["96", "00:00:29:23"], {}, 2808, 2808, "03:35:39:95", "03:35:39:95", 1242240, 1242240],
376+
[["100", "03:36:09:23"], {}, ["100", "00:00:29:23"], {}, 2924, 2924, "03:35:39:99", "03:35:39:99", 1294000, 1294000],
377+
[["120", "03:36:09:23"], {}, ["120", "00:00:29:23"], {}, 3504, 3504, "03:35:39:119", "03:35:39:119", 1552800, 1552800],
378+
[["119.88", "03:36:09;23"], {}, ["119.88", "00:00:29;23"], {}, 3504, 3504, "03:35:39;111", "03:35:39;111", 1551240, 1551240],
340379
[["23.98", "03:36:09:23"], {}, ["23.98", "00:00:29:23"], {}, 720, 720, "03:35:39:23", "03:35:39:23", 310560, 310560],
341380
[["23.98", "03:36:09:23"], {}, ["23.98", "00:00:29:23"], {}, 720, 720, "03:35:39:23", "03:35:39:23", 310560, 310560],
342381
[["ms", "03:36:09.230"], {}, ["ms", "01:06:09.230"], {}, 3969231, 3969231, "02:29:59.999", "02:29:59.999", 9000000, 9000000],
@@ -364,6 +403,11 @@ def test_op_overloads_subtract(args1, kwargs1, args2, kwargs2, custom_offset1, c
364403
[["59.94", "03:36:09;23"], {}, ["59.94", "00:00:29;23"], {}, 1764, 1764, "18:59:27;35", "18:59:27;35", 1371305376, 1371305376],
365404
[["60", "03:36:09:23"], {}, ["60", "00:00:29:23"], {}, 1764, 1764, "19:00:21:35", "19:00:21:35", 1372681296, 1372681296],
366405
[["59.94", "03:36:09;23"], {}, ["59.94", "00:00:29;23"], {}, 1764, 1764, "18:59:27;35", "18:59:27;35", 1371305376, 1371305376],
406+
[["72", "03:36:09:23"], {}, ["72", "00:00:29:23"], {}, 2112, 2112, "00:40:31:71", "00:40:31:71", 1972168704, 1972168704],
407+
[["96", "03:36:09:23"], {}, ["96", "00:00:29:23"], {}, 2808, 2808, "12:00:53:95", "12:00:53:95", 3496094784, 3496094784],
408+
[["100", "03:36:09:23"], {}, ["100", "00:00:29:23"], {}, 2924, 2924, "21:54:17:75", "21:54:17:75", 3792205776, 3792205776],
409+
[["120", "03:36:09:23"], {}, ["120", "00:00:29:23"], {}, 3504, 3504, "23:21:16:95", "23:21:16:95", 5453289216, 5453289216],
410+
[["119.88", "03:36:09;23"], {}, ["119.88", "00:00:29;23"], {}, 3504, 3504, "23:19:28;95", "23:19:28;95", 5447822976, 5447822976],
367411
[["ms", "03:36:09.230"], {}, ["ms", "01:06:09.230"], {}, 3969231, 3969231, "17:22:11.360", "17:22:11.360", 51477873731361, 51477873731361],
368412
[["24"], {"frames": 12000}, ["24"], {"frames": 485}, 485, 485, "19:21:39:23", "19:21:39:23", 5820000, 5820000],
369413
[["24"], {"frames": 12000}, ["24"], {"frames": 485}, 485, 485, "19:21:39:23", "19:21:39:23", 5820000, 5820000],
@@ -428,7 +472,7 @@ def test_add_with_two_different_frame_rates():
428472
[["24", "00:00:01:00"], {}, lambda x, y: x / y, 32.4],
429473
]
430474
)
431-
def test_add_with_non_suitable_class_instance(args, kwargs, func, tc2):
475+
def test_arithmetic_with_unsupported_type_raises_error(args, kwargs, func, tc2):
432476
"""TimecodeError is raised if the other class is not suitable for the operation."""
433477
tc1 = Timecode(*args, **kwargs)
434478
with pytest.raises(TimecodeError) as cm:
@@ -464,6 +508,11 @@ def test_div_method_working_properly_2():
464508
[["50", "00:01:00:00"], 3001, 3000],
465509
[["59.94", "00:01:00;00"], 3597, 3596],
466510
[["60", "00:01:00:00"], 3601, 3600],
511+
[["72", "00:01:00:00"], 4321, 4320],
512+
[["96", "00:01:00:00"], 5761, 5760],
513+
[["100", "00:01:00:00"], 6001, 6000],
514+
[["120", "00:01:00:00"], 7201, 7200],
515+
[["119.88", "00:01:00;00"], 7193, 7192],
467516
]
468517
)
469518
def test_frame_number_attribute_value_is_correctly_calculated(args, frames, frame_number):
@@ -596,6 +645,16 @@ def test_framerate_can_be_changed():
596645
[["60000/1000", "00:00:00:00"], {}, "60", 60],
597646
[["60000/1001", "00:00:00;00"], {}, "59.94", 60],
598647
[[(60000, 1001), "00:00:00;00"], {}, "59.94", 60],
648+
[["72000/1000", "00:00:00:00"], {}, "72", 72],
649+
[[(72000, 1000), "00:00:00:00"], {}, "72", 72],
650+
[["96000/1000", "00:00:00:00"], {}, "96", 96],
651+
[[(96000, 1000), "00:00:00:00"], {}, "96", 96],
652+
[["100000/1000", "00:00:00:00"], {}, "100", 100],
653+
[[(100000, 1000), "00:00:00:00"], {}, "100", 100],
654+
[["120000/1000", "00:00:00:00"], {}, "120", 120],
655+
[["120000/1001", "00:00:00;00"], {}, "119.88", 120],
656+
[[(120000, 1000), "00:00:00:00"], {}, "120", 120],
657+
[[(120000, 1001), "00:00:00;00"], {}, "119.88", 120],
599658
]
600659
)
601660
def test_rational_framerate_conversion(args, kwargs, frame_rate, int_framerate):
@@ -779,7 +838,7 @@ def test_le_overload():
779838
assert tc5 > tc4
780839

781840

782-
def test_gt_overload_b():
841+
def test_lt_overload():
783842
tc1 = Timecode(24, "00:00:00:00")
784843
tc2 = Timecode(24, "00:00:00:00")
785844
tc3 = Timecode(24, "00:00:00:01")

0 commit comments

Comments
 (0)