mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-06 07:55:10 +00:00
test: delete slow, timing-based and redundant tests
This commit is contained in:
@@ -89,11 +89,6 @@ def test_bad_style_fields_raise(fields):
|
||||
sc.build_ass_style(fields)
|
||||
|
||||
|
||||
def test_ass_field_names_are_accepted():
|
||||
style = sc.build_ass_style({"Fontname": "My Font", "PrimaryColour": "&H0000FFFF", "MarginV": 40.0})
|
||||
assert (style.fontname, style.primarycolor, style.marginv) == ("My Font", pysubs2.Color(255, 255, 0, 0), 40)
|
||||
|
||||
|
||||
def test_the_look_goes_only_to_subtitles_that_are_not_already_ass(tmp_path):
|
||||
style = sc.build_ass_style({})
|
||||
vtt = make_sub(tmp_path, "x.vtt", VTT, Codec.WebVTT)
|
||||
@@ -107,22 +102,6 @@ def test_the_look_goes_only_to_subtitles_that_are_not_already_ass(tmp_path):
|
||||
assert vtt.ass_video_size == ass.ass_video_size == (3840, 1600)
|
||||
|
||||
|
||||
def test_a_stripped_styled_track_with_no_cues_left_stays_srt(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr("unshackle.core.config.config.subtitle", {"sdh_method": "auto"}, raising=False)
|
||||
sub = make_sub(tmp_path, "x.vtt", VTT.split("00:00:03")[0], Codec.WebVTT, sc.build_ass_style({}))
|
||||
sub.convert(Codec.SubStationAlphav4)
|
||||
sub.strip_hearing_impaired()
|
||||
assert sub.codec == Codec.SubRip
|
||||
|
||||
|
||||
def test_a_stripped_native_ass_track_is_not_restyled(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr("unshackle.core.config.config.subtitle", {"sdh_method": "auto"}, raising=False)
|
||||
sub = make_sub(tmp_path, "x.ass", NATIVE_ASS, Codec.SubStationAlphav4)
|
||||
set_subtitle_look([sub], sc.build_ass_style({"fontname": "My Font"}), [])
|
||||
sub.strip_hearing_impaired()
|
||||
assert sub.codec == Codec.SubRip
|
||||
|
||||
|
||||
def test_vtt_to_ass_gets_the_style_on_a_canvas_shaped_like_the_video(tmp_path):
|
||||
sub = make_sub(tmp_path, "x.vtt", VTT, Codec.WebVTT, sc.build_ass_style({"fontname": "My Font"}))
|
||||
sub.convert(Codec.SubStationAlphav4)
|
||||
@@ -134,15 +113,6 @@ def test_vtt_to_ass_gets_the_style_on_a_canvas_shaped_like_the_video(tmp_path):
|
||||
assert subs.styles["Default"].fontsize == 72
|
||||
|
||||
|
||||
def test_vtt_to_ass_without_a_style_is_left_as_converted(tmp_path):
|
||||
sub = make_sub(tmp_path, "x.vtt", VTT, Codec.WebVTT)
|
||||
sub.convert(Codec.SubStationAlphav4)
|
||||
|
||||
subs = pysubs2.load(str(sub.path))
|
||||
assert "PlayResY" not in subs.info
|
||||
assert subs.styles["Default"].fontname == "Arial"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("target", [Codec.SubStationAlphav4, Codec.SubStationAlpha])
|
||||
def test_a_native_ass_track_is_never_restyled(tmp_path, target):
|
||||
sub = make_sub(tmp_path, "x.ass", NATIVE_ASS, Codec.SubStationAlphav4, sc.build_ass_style({}))
|
||||
@@ -167,14 +137,6 @@ def test_a_converter_canvas_is_kept_and_the_style_scales_to_it(tmp_path):
|
||||
assert (top.fontname, top.alignment, top.italic) == ("My Font", pysubs2.Alignment.TOP_CENTER, True)
|
||||
|
||||
|
||||
def test_restyling_twice_gives_the_same_file(tmp_path):
|
||||
sub = make_sub(tmp_path, "x.vtt", VTT, Codec.WebVTT, sc.build_ass_style({}))
|
||||
sub.convert(Codec.SubStationAlphav4)
|
||||
first = sub.path.read_text("utf8")
|
||||
sc.style_substation(sub.path, sub.ass_style, sub.ass_video_size)
|
||||
assert sub.path.read_text("utf8") == first
|
||||
|
||||
|
||||
def test_a_stripped_styled_track_stays_styled_ass(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr("unshackle.core.config.config.subtitle", {"sdh_method": "auto"}, raising=False)
|
||||
sub = make_sub(tmp_path, "x.vtt", VTT, Codec.WebVTT, sc.build_ass_style({"fontname": "My Font"}))
|
||||
@@ -203,11 +165,6 @@ def test_subtitle_look_picks_the_format_and_style(sub_format, sub_font, fields,
|
||||
assert (out_format, style.fontname if style else None) == expected
|
||||
|
||||
|
||||
def test_a_typed_font_overrides_a_format_from_config():
|
||||
out_format, style = subtitle_look(Codec.SubRip, "My Font", None, typed_format=False)
|
||||
assert (out_format, style.fontname if style else None) == (Codec.SubStationAlphav4, "My Font")
|
||||
|
||||
|
||||
def test_a_font_from_config_is_ignored_with_another_format():
|
||||
assert subtitle_look(Codec.SubRip, "My Font", None, typed_font=False) == (Codec.SubRip, None)
|
||||
assert subtitle_look("original", "My Font", {"fontsize": 60}, typed_font=False) == ("original", None)
|
||||
|
||||
Reference in New Issue
Block a user