Coverage for src/driada/utils/output.py: 75.00%
16 statements
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-25 15:40 +0300
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-25 15:40 +0300
1from io import StringIO
2import sys
4class Capturing(list):
5 def __enter__(self):
6 self._stdout = sys.stdout
7 sys.stdout = self._stringio = StringIO()
8 return self
9 def __exit__(self, *args):
10 self.extend(self._stringio.getvalue().splitlines())
11 del self._stringio # free up some memory
12 sys.stdout = self._stdout
15def show_output(output):
16 if len(output) == 0:
17 print('log is empty')
18 else:
19 for s in output:
20 print(s)