From a011765b44febfb11bae122d2ed7db763621ac8f Mon Sep 17 00:00:00 2001 From: Jacob Evan Shreve Date: Wed, 8 Feb 2023 01:50:16 -0500 Subject: [PATCH] Isolate the attack tests with setUp and tearDown methods --- IPython/core/tests/test_interactiveshell.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py index 3fb9fdf5b5d..641dcef3cf4 100644 --- a/IPython/core/tests/test_interactiveshell.py +++ b/IPython/core/tests/test_interactiveshell.py @@ -1112,11 +1112,17 @@ def foo(*args, **kwargs): ip.Completer.custom_matchers.pop() -class TestShowTracebacksAttack(unittest.TestCase): +class TestShowTracebackAttack(unittest.TestCase): """Test that the interactive shell is resilient against the client attack of manipulating the showtracebacks method. These attacks shouldn't result in an unhandled exception in the kernel.""" + def setUp(self): + self.orig_showtraceback = interactiveshell.InteractiveShell.showtraceback + + def tearDown(self): + interactiveshell.InteractiveShell.showtraceback = self.orig_showtraceback + def test_set_show_tracebacks_none(self): """Test the case of the client setting showtracebacks to None"""