diff --git a/tests/test_render.py b/tests/test_render.py index f5691c1..f1ec9d5 100644 --- a/tests/test_render.py +++ b/tests/test_render.py @@ -98,10 +98,21 @@ def test_render_router_diagnostics_and_edge_cases(tmp_path: Path): def test_render_all_run_gallery_invokes_subprocess(tmp_path: Path, monkeypatch): + # render_mod.subprocess *is* the stdlib subprocess module, so a blanket + # patch of .run would also swallow the real subprocess.run calls + # matplotlib's texmanager makes to compile LaTeX during savefig — only + # intercept the "gallery generate" call itself and pass everything else + # (LaTeX included) through to the real subprocess.run. calls = [] - monkeypatch.setattr( - render_mod.subprocess, "run", lambda *a, **k: calls.append((a, k)) - ) + real_run = render_mod.subprocess.run + + def fake_run(*a, **k): + if a and a[0] and a[0][0] == "gallery": + calls.append((a, k)) + return None + return real_run(*a, **k) + + monkeypatch.setattr(render_mod.subprocess, "run", fake_run) reduced = [ Reduced( "s",