flush()
self._output_file.flush()
self._output_file.seek(0)
text = self._output_file.read().decode()
if self.captured_out_filter is not None:
text = self.captured_out_filter(text)
self.captured_out = text
After Change
self._output_file.flush()
self._output_file.seek(0)
text = self._output_file.read()
if isinstance(text, bytes):
text = text.decode()
if self.captured_out_filter is not None:
text = self.captured_out_filter(text)
self.captured_out = text