Filter Jupyter terminal wrapper output
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
|
||||
from src.jupyter_runtime import (
|
||||
clean_terminal_output,
|
||||
extract_terminal_command_output,
|
||||
)
|
||||
|
||||
|
||||
class TestJupyterRuntimeOutputFiltering(unittest.TestCase):
|
||||
def test_extract_terminal_command_output_drops_wrapper_echo(self) -> None:
|
||||
start_marker = '__ZK_AGENT_START_test__'
|
||||
raw = (
|
||||
'root@host:/workspace# mkdir -p /workspace && cd /workspace && '
|
||||
'printf "\\n__ZK_AGENT_START_test__\\n"; '
|
||||
'( setsid bash -lc \'export A=1; echo real-output\' ) &\r\n'
|
||||
f'{start_marker}\r\n'
|
||||
'real-output\r\n'
|
||||
)
|
||||
|
||||
output = extract_terminal_command_output(
|
||||
clean_terminal_output(raw),
|
||||
start_marker=start_marker,
|
||||
)
|
||||
|
||||
self.assertEqual(output, 'real-output')
|
||||
|
||||
def test_extract_terminal_command_output_uses_last_marker(self) -> None:
|
||||
start_marker = '__ZK_AGENT_START_test__'
|
||||
output = extract_terminal_command_output(
|
||||
f'echo text containing {start_marker}\n{start_marker}\nactual',
|
||||
start_marker=start_marker,
|
||||
)
|
||||
|
||||
self.assertEqual(output, 'actual')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user