Patch at import point instead of subprocess.run

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
J. Nick Koston
2026-03-06 22:38:44 -10:00
co-authored by Claude Opus 4.6
parent 9f72d5e428
commit 696c0f021c
+1 -3
View File
@@ -557,10 +557,8 @@ def test_run_external_process_line_callbacks() -> None:
return "PROCESS CALLBACK\n"
return None
with patch("subprocess.run") as mock_run:
mock_run.return_value = MagicMock(returncode=0)
with patch("esphome.util.subprocess.run") as mock_run:
# Capture the RedirectText objects passed to subprocess.run
def run_side_effect(*args: Any, **kwargs: Any) -> MagicMock:
# Simulate subprocess writing to the stdout RedirectText
stdout = kwargs.get("stdout")