MCPcopy Create free account
hub / github.com/NVIDIA/SkillSpector / _FakePopen

Class _FakePopen

tests/unit/test_agent_cli.py:80–108  ·  view source on GitHub ↗

Stand-in for ``subprocess.Popen`` that ``run_agent_cli``'s bounded reader (`_run_bounded`) can drive: stdin/stdout/stderr streams plus wait/kill.

Source from the content-addressed store, hash-verified

78
79
80class _FakePopen:
81 """Stand-in for ``subprocess.Popen`` that ``run_agent_cli``'s bounded reader
82 (`_run_bounded`) can drive: stdin/stdout/stderr streams plus wait/kill."""
83
84 def __init__(
85 self,
86 stdout: bytes = b"",
87 returncode: int = 0,
88 stderr: bytes = b"",
89 wait_exc: BaseException | None = None,
90 ) -> None:
91 self.stdin = MagicMock()
92 self.stdout = io.BytesIO(stdout)
93 self.stderr = io.BytesIO(stderr)
94 self.returncode = returncode
95 self.kill = MagicMock()
96 self._returncode = returncode
97 self._wait_exc = wait_exc
98 self.wait = MagicMock(side_effect=self._wait)
99
100 def _wait(self, timeout: float | None = None) -> int:
101 if self._wait_exc is not None:
102 raise self._wait_exc
103 return self._returncode
104
105 @property
106 def stdin_bytes(self) -> bytes:
107 """All bytes written to stdin by the bounded reader."""
108 return b"".join(c.args[0] for c in self.stdin.write.call_args_list if c.args)
109
110
111def _make_ok_process(

Callers 1

_make_ok_processFunction · 0.85

Calls

no outgoing calls

Tested by 1

_make_ok_processFunction · 0.68