def test_subtitle_add_offset(subtitle): sub = subtitle + SubtitleTime(0, 0, 1, 0) assert sub.start_time == SubtitleTime(0, 0, 2, 600) assert sub.end_time == SubtitleTime(0, 0, 5, 200)
def test_subtitle_from_block(subtitle_block): sub = Subtitle.from_block(subtitle_block) assert sub.index == "1" assert sub.start_time == SubtitleTime(0, 0, 1, 600) assert sub.end_time == SubtitleTime(0, 0, 4, 200)
def test_subtitle_time_equality(): assert SubtitleTime(1, 2, 3, 400) == SubtitleTime(1, 2, 3, 400) assert SubtitleTime(1, 2, 3, 400) != SubtitleTime(0, 4, 0, 100)
def test_subtitle_file_add_offset(subtitle_file): subfile = SubtitlesFile.from_file(subtitle_file) subfile += SubtitleTime(0, 0, 1, 0) assert subfile.subtitles[0].start_time == SubtitleTime(0, 0, 2, 600) assert subfile.subtitles[0].end_time == SubtitleTime(0, 0, 5, 200)
def test_subtitle_time_str(): assert str(SubtitleTime(1, 2, 3, 400)) == "01:02:03,400"
def test_subtitle_time_from_str_no_match(): with pytest.raises(ValueError): SubtitleTime.from_str("nope")
def test_subtitle_time_from_str_rewind(): assert SubtitleTime.from_str("01:02:03,400", rewind=True) == SubtitleTime( -1, -2, -3, -400)
def test_subtitle_time_from_str(): assert SubtitleTime.from_str("01:02:03,400") == SubtitleTime(1, 2, 3, 400)
def test_add_negative_offset_to_subtitle_time(base_time, offset, expected): assert SubtitleTime(*base_time) + SubtitleTime(*offset) == SubtitleTime( *expected)