From a602866ce10d0f45f56d20fc70107faff75965e2 Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Tue, 5 May 2020 13:55:10 +0300 Subject: [PATCH] Fix bug in OutputCapturer --- tests/mini_toolbox/__init__.py | 1 - tests/test_mini_toolbox.py | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/test_mini_toolbox.py diff --git a/tests/mini_toolbox/__init__.py b/tests/mini_toolbox/__init__.py index 97d6f57..3184e37 100644 --- a/tests/mini_toolbox/__init__.py +++ b/tests/mini_toolbox/__init__.py @@ -213,7 +213,6 @@ class OutputCapturer(object): # Not doing exception swallowing anywhere here. self._stderr_temp_setter.__exit__(exc_type, exc_value, exc_traceback) self._stdout_temp_setter.__exit__(exc_type, exc_value, exc_traceback) - return self output = property(lambda self: self.string_io.getvalue(), doc='''The string of output that was captured.''') diff --git a/tests/test_mini_toolbox.py b/tests/test_mini_toolbox.py new file mode 100644 index 0000000..7074e07 --- /dev/null +++ b/tests/test_mini_toolbox.py @@ -0,0 +1,12 @@ +# Copyright 2019 Ram Rachum and collaborators. +# This program is distributed under the MIT license. + +import pytest + +from . import mini_toolbox + + +def test_output_capturer_doesnt_swallow_exceptions(): + with pytest.raises(ZeroDivisionError): + with mini_toolbox.OutputCapturer(): + 1 / 0