diff --git a/tests/tracks/test_subtitle_convert.py b/tests/tracks/test_subtitle_convert.py index 1c231e61..15408dd7 100644 --- a/tests/tracks/test_subtitle_convert.py +++ b/tests/tracks/test_subtitle_convert.py @@ -16,6 +16,7 @@ import pathlib import re import struct +import pycaption import pytest from unshackle.core import binaries @@ -371,3 +372,40 @@ def test_segmented_fttml_parses_and_converts(tmp_path, monkeypatch): assert sub.codec == Codec.TimedTextMarkupLang out = sub.convert(Codec.SubRip, forced=True) assert cue_count(out) == 2 + + +def test_fttml_with_viewport_units_converts(tmp_path, monkeypatch): + """TTML2 ``vw``/``vh`` and ``rw``/``rh`` sizes, which pycaption rejects, still parse and convert. + + Only the size attributes pycaption parses are rewritten: a negative one becomes 0, while an ``rh`` + font size and the same units in cue text stay as they are. + """ + monkeypatch.setattr("unshackle.core.config.config.subtitle", {}, raising=False) + frag = ( + '' + '' + '