One function

OutputCapturer in cool-RR/PySnooper

The author described this change as Fix bug in OutputCapturer. It counts as a record because the check below fails on the code as it stood at 679a77e33 and passes on a602866ce, with nothing else changed between the two runs.

Fix saved2020-05-05
Sharing licenceMIT · LICENSE
Change size+0 1

What the code was meant to do, written into the code itself as a docstring

Context manager for catching all system output generated during suite. Example: with OutputCapturer() as output_capturer: print('woo!') assert output_capturer.output == 'woo! ' The boolean arguments `stdout` and `stderr` determine, respectively, whether the standard-output and the standard-error streams will be captured.

The change

3838 # Not doing exception swallowing anywhere here.
3939 self._stderr_temp_setter.__exit__(exc_type, exc_value, exc_traceback)
4040 self._stdout_temp_setter.__exit__(exc_type, exc_value, exc_traceback)
41- return self
4241
4342 output = property(lambda self: self.string_io.getvalue(),
4443 doc='''The string of output that was captured.''')

The check that tells the two apart

failpass·tests/test_mini_toolbox.py::test_output_capturer_doesnt_swallow_exceptions

Check file tests/test_mini_toolbox.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it679a77e3363348c9a79e7a311ec149863c8027ef
Broken version dated2020-04-21
Moduletests.mini_toolbox.__init__
Units changedOutputCapturer
Fingerprintd631568655f3764c
Checked2026-08-17 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.