Fix test_render_all_run_gallery_invokes_subprocess clobbering LaTeX's own subprocess.run
CI / Format (ruff format) (push) Successful in 28s
CI / Lint (ruff check) (push) Successful in 29s
CI / Sync project version with tag (push) Has been skipped
CI / Lint (ruff check) (pull_request) Successful in 37s
CI / Type check (ty) (push) Successful in 40s
CI / Format (ruff format) (pull_request) Successful in 32s
CI / Sync project version with tag (pull_request) Has been skipped
CI / Type check (ty) (pull_request) Successful in 32s
CI / Tests (pull_request) Successful in 3m20s
CI / Tests (push) Successful in 3m32s
CI / Format (ruff format) (push) Successful in 28s
CI / Lint (ruff check) (push) Successful in 29s
CI / Sync project version with tag (push) Has been skipped
CI / Lint (ruff check) (pull_request) Successful in 37s
CI / Type check (ty) (push) Successful in 40s
CI / Format (ruff format) (pull_request) Successful in 32s
CI / Sync project version with tag (pull_request) Has been skipped
CI / Type check (ty) (pull_request) Successful in 32s
CI / Tests (pull_request) Successful in 3m20s
CI / Tests (push) Successful in 3m32s
render_mod.subprocess is the stdlib subprocess module itself, not a copy — patching .run unconditionally also intercepted the real subprocess.run calls matplotlib's texmanager makes to compile LaTeX during savefig, so those returned the test's fake return value instead of a real CompletedProcess and crashed with AttributeError: 'NoneType' object has no attribute 'stdout' on any environment where render_all runs before the gallery call (i.e. everywhere but this dev machine's warm state that happened to mask it). Only intercept the "gallery generate" call now; everything else passes through to the real subprocess.run. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+14
-3
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user