]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41514: Fix buggy IDLE test (GH-21808)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 10 Aug 2020 14:01:14 +0000 (07:01 -0700)
committerGitHub <noreply@github.com>
Mon, 10 Aug 2020 14:01:14 +0000 (07:01 -0700)
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.
(cherry picked from commit 416f0b71ba84fe83ee2ba4399b8a28712702980b)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Lib/idlelib/idle_test/test_run.py

index 469c13d756d5e8b8d671ce9ad390f61e49238b9a..37c0d4525e56cd99566e4cbf4fe499a39b7b080b 100644 (file)
@@ -326,11 +326,11 @@ class RecursionLimitTest(unittest.TestCase):
 
 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 @@ class HandleErrorTest(unittest.TestCase):
             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)