From ecab884f5608af771cc09ef513263da8548285a3 Mon Sep 17 00:00:00 2001 From: Tal Einat Date: Sun, 1 Nov 2020 13:01:06 +0200 Subject: [PATCH] fix failing tests on Azure Devops --- Lib/idlelib/idle_test/test_sidebar.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Lib/idlelib/idle_test/test_sidebar.py b/Lib/idlelib/idle_test/test_sidebar.py index 478849c49fb..a2129b4686a 100644 --- a/Lib/idlelib/idle_test/test_sidebar.py +++ b/Lib/idlelib/idle_test/test_sidebar.py @@ -405,7 +405,17 @@ class ShellSidebarTest(unittest.TestCase): def setUpClass(cls): requires('gui') + try: + orig_use_subprocess = idlelib.pyshell.use_subprocess + except AttributeError: + orig_use_subprocess = None idlelib.pyshell.use_subprocess = False + def cleanup_use_subprocess(): + if orig_use_subprocess is not None: + idlelib.pyshell.use_subprocess = orig_use_subprocess + else: + del idlelib.pyshell.use_subprocess + cls.addClassCleanup(cleanup_use_subprocess) cls.root = root = tk.Tk() root.withdraw() @@ -497,7 +507,7 @@ class ShellSidebarTest(unittest.TestCase): for line_index, line in enumerate(input.split('\n')): if line_index > 0: text.event_generate('<>') - text.insert('insert', line) + text.insert('insert', line, 'stdin') def run_test_coroutine(self, coroutine): root = self.root @@ -514,8 +524,8 @@ class ShellSidebarTest(unittest.TestCase): exception = exc root.quit() else: - root.after_idle(after_callback) - root.after(0, after_callback) + root.after(1, root.after_idle, after_callback) + root.after(0, root.after_idle, after_callback) root.mainloop() if exception: