Files
DeepTutor/tests/services/workspace/test_execution_environment.py
VAN b5443bf334 fix: force headless matplotlib backend in exec sandbox
The exec sandbox has no GUI session, so Figure.show() can block until the
tool timeout. schemdraw's Drawing defaults to show=True and calls show() on
context exit even after save(), which makes a successfully saved plot look
like a timed-out execution. Pin MPLBACKEND=Agg for model-authored programs.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-11 21:24:47 +08:00

19 lines
746 B
Python

from __future__ import annotations
from pathlib import Path
from deeptutor.services.workspace.execution import prepare_workspace_execution_env
def test_execution_environment_forces_headless_matplotlib(tmp_path: Path) -> None:
"""A GUI backend would block on show() in the display-less exec sandbox.
schemdraw's ``Drawing`` defaults to ``show=True``; its context manager
calls ``fig.show()`` on exit even after the figure was saved. Without a
non-interactive backend that call waits for a window server until the exec
timeout kills the process, so the saved plot never reaches the user.
"""
env = prepare_workspace_execution_env(tmp_path / "outputs" / "chat" / "s" / "turn")
assert env["MPLBACKEND"] == "Agg"