66
77from __future__ import annotations
88
9+ import shutil
910import subprocess
1011from pathlib import Path
1112
1819from docgen .config import Config
1920from docgen .validate import Validator , _sample_frames
2021
22+ _has_ffmpeg = shutil .which ("ffmpeg" ) is not None
23+ requires_ffmpeg = pytest .mark .skipif (not _has_ffmpeg , reason = "ffmpeg not installed" )
24+
2125
2226# ── Helpers: create synthetic test videos ─────────────────────────────
2327
@@ -252,6 +256,7 @@ def test_check_freeze_ratio_math(self, config):
252256 assert c .check_freeze_ratio (100.0 , 0.0 ) == pytest .approx (1.0 )
253257 assert c .check_freeze_ratio (0.0 , 50.0 ) == pytest .approx (0.0 )
254258
259+ @requires_ffmpeg
255260 def test_compose_rejects_short_video (self , config , cfg_dir ):
256261 """Compose in strict mode should raise when video is way shorter than audio."""
257262 audio = cfg_dir / "audio" / "01-test.mp3"
@@ -264,6 +269,7 @@ def test_compose_rejects_short_video(self, config, cfg_dir):
264269 with pytest .raises (ComposeError , match = "FREEZE GUARD" ):
265270 c ._compose_simple ("01" , video , strict = True )
266271
272+ @requires_ffmpeg
267273 def test_compose_allows_matching_durations (self , config , cfg_dir ):
268274 """Compose should succeed when video roughly matches audio."""
269275 audio = cfg_dir / "audio" / "01-test.mp3"
@@ -276,6 +282,7 @@ def test_compose_allows_matching_durations(self, config, cfg_dir):
276282 result = c ._compose_simple ("01" , video , strict = True )
277283 assert result is True
278284
285+ @requires_ffmpeg
279286 def test_compose_nonstrict_warns (self , config , cfg_dir , capsys ):
280287 """Non-strict mode prints a warning but doesn't raise."""
281288 audio = cfg_dir / "audio" / "01-test.mp3"
@@ -329,6 +336,7 @@ def test_half_black_fails_pre_push(self, config, cfg_dir):
329336 with pytest .raises (SystemExit ):
330337 v .run_pre_push ()
331338
339+ @requires_ffmpeg
332340 def test_static_video_does_not_fail_pre_push (self , config , cfg_dir ):
333341 """freeze_ratio is a soft check — static (non-black) video only warns."""
334342 vid = cfg_dir / "recordings" / "01-test.mp4"
0 commit comments