MCPcopy
hub / github.com/joowani/binarytree / CaptureOutput

Class CaptureOutput

tests/utils.py:15–27  ·  view source on GitHub ↗

Context manager to catch stdout.

Source from the content-addressed store, hash-verified

13
14
15class CaptureOutput(List[str]):
16 """Context manager to catch stdout."""
17
18 def __enter__(self) -> "CaptureOutput":
19 self._original_stdout = sys.stdout
20 self._temp_stdout = StringIO()
21 sys.stdout = self._temp_stdout
22 return self
23
24 def __exit__(self, *args: Any) -> None:
25 lines = self._temp_stdout.getvalue().splitlines()
26 self.extend(line.rstrip() for line in lines)
27 sys.stdout = self._original_stdout
28
29
30def pprint_default(values: NodeValueList) -> List[str]:

Callers 3

pprint_defaultFunction · 0.85
pprint_with_indexFunction · 0.85
builtin_printFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected