[Python-checkins] bpo-41514: Fix buggy IDLE test (GH-21808)

Miss Islington (bot) webhook-mailer at python.org
Mon Aug 10 10:01:24 EDT 2020


https://github.com/python/cpython/commit/860bc0ea70c365825bfd9b7de7685cf6842ca3c7
commit: 860bc0ea70c365825bfd9b7de7685cf6842ca3c7
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-08-10T07:01:14-07:00
summary:

bpo-41514: Fix buggy IDLE test (GH-21808)


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 at udel.edu>

files:
M Lib/idlelib/idle_test/test_run.py

diff --git a/Lib/idlelib/idle_test/test_run.py b/Lib/idlelib/idle_test/test_run.py
index 469c13d756d5e..37c0d4525e56c 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)



More information about the Python-checkins mailing list