From 5df12550f45289c0464837fabff1dc3ba7bdc7bf Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Mon, 10 Aug 2020 09:21:23 -0400 Subject: [PATCH] bpo-41514: Fix buggy IDLE test test_run method test_fatal_error failed when run twice, as with python -m test -m test_fatal_error test_idle test_idle because func.called was not reinitialized to 0. This bug caused a failure on a refleak buildbot. --- Lib/idlelib/idle_test/test_run.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Lib/idlelib/idle_test/test_run.py b/Lib/idlelib/idle_test/test_run.py index 469c13d756d5e8..37c0d4525e56cd 100644 --- a/Lib/idlelib/idle_test/test_run.py +++ b/Lib/idlelib/idle_test/test_run.py @@ -326,11 +326,11 @@ def func(): "docstring" class HandleErrorTest(unittest.TestCase): # Method of MyRPCServer - func = Func() - @mock.patch('idlelib.run.thread.interrupt_main', new=func) - def test_error(self): + def test_fatal_error(self): eq = self.assertEqual - with captured_output('__stderr__') as err: + with captured_output('__stderr__') as err,\ + mock.patch('idlelib.run.thread.interrupt_main', + new_callable=Func) as func: try: raise EOFError except EOFError: @@ -349,7 +349,7 @@ def test_error(self): self.assertIn('abc', msg) self.assertIn('123', msg) self.assertIn('IndexError', msg) - eq(self.func.called, 2) + eq(func.called, 2) if __name__ == '__main__': unittest.main(verbosity=2)