Verify that PyBridge captures poutput but not raw print from within a command.
()
| 125 | |
| 126 | |
| 127 | def test_py_bridge_capture_isolation() -> None: |
| 128 | """Verify that PyBridge captures poutput but not raw print from within a command.""" |
| 129 | import cmd2 |
| 130 | from cmd2.py_bridge import PyBridge |
| 131 | |
| 132 | class App(cmd2.Cmd): |
| 133 | def do_test_capture(self, _): |
| 134 | print("process_stdout") |
| 135 | self.poutput("app_stdout") |
| 136 | |
| 137 | app = App() |
| 138 | bridge = PyBridge(app) |
| 139 | result = bridge("test_capture") |
| 140 | |
| 141 | # Verify isolation: only the application stream should be in the result |
| 142 | assert result.stdout == "app_stdout\n" |
| 143 | assert "process_stdout" not in result.stdout |
| 144 | |
| 145 | |
| 146 | def test_run_pyscript_stop(base_app, request) -> None: |