MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_failing_ffmpeg

Function test_failing_ffmpeg

lib/matplotlib/tests/test_animation.py:314–327  ·  view source on GitHub ↗

Test that we correctly raise a CalledProcessError when ffmpeg fails. To do so, mock ffmpeg using a simple executable shell script that succeeds when called with no arguments (so that it gets registered by `isAvailable`), but fails otherwise, and add it to the $PATH.

(tmp_path, monkeypatch, anim)

Source from the content-addressed store, hash-verified

312 reason='emscripten does not support subprocesses')
313@pytest.mark.skipif(shutil.which("/bin/sh") is None, reason="requires a POSIX OS")
314def test_failing_ffmpeg(tmp_path, monkeypatch, anim):
315 """
316 Test that we correctly raise a CalledProcessError when ffmpeg fails.
317
318 To do so, mock ffmpeg using a simple executable shell script that
319 succeeds when called with no arguments (so that it gets registered by
320 `isAvailable`), but fails otherwise, and add it to the $PATH.
321 """
322 monkeypatch.setenv("PATH", str(tmp_path), prepend=":")
323 exe_path = tmp_path / "ffmpeg"
324 exe_path.write_bytes(b"#!/bin/sh\n[[ $@ -eq 0 ]]\n")
325 os.chmod(exe_path, 0o755)
326 with pytest.raises(subprocess.CalledProcessError):
327 anim.save("test.mpeg")
328
329
330@pytest.mark.parametrize("cache_frame_data", [False, True])

Callers

nothing calls this directly

Calls 1

saveMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…