`FrameTimecode` arithmetic should accept a bare :class:`Timecode` operand by treating it as an absolute time in seconds.
()
| 444 | |
| 445 | |
| 446 | def test_arithmetic_with_bare_timecode(): |
| 447 | """`FrameTimecode` arithmetic should accept a bare :class:`Timecode` operand by treating |
| 448 | it as an absolute time in seconds.""" |
| 449 | fps = 30.0 |
| 450 | base = FrameTimecode(timecode=10, fps=fps) # 10 frames @ 30fps == ~0.333s |
| 451 | # 1/30s expressed in a 1/1000 time base is pts=33 (rounded). |
| 452 | one_frame_at_30 = Timecode(pts=33, time_base=Fraction(1, 1000)) |
| 453 | |
| 454 | plus = base + one_frame_at_30 |
| 455 | assert plus.frame_num == 11 |
| 456 | |
| 457 | minus = base - one_frame_at_30 |
| 458 | assert minus.frame_num == 9 |
| 459 | |
| 460 | # Reverse direction: a Timecode-backed FrameTimecode plus a bare Timecode. |
| 461 | pts_base = FrameTimecode(timecode=Timecode(pts=1, time_base=Fraction(1, 1000)), fps=fps) |
| 462 | pts_plus = pts_base + Timecode(pts=2, time_base=Fraction(1, 1000)) |
| 463 | assert pts_plus.seconds == pytest.approx(0.003) |
| 464 | |
| 465 | |
| 466 | def test_comparisons_with_bare_timecode(): |
nothing calls this directly
no test coverage detected