summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2020-11-30 08:42:56 (GMT)
committerGitHub <noreply@github.com>2020-11-30 08:42:56 (GMT)
commita5b0c17e0d04931e639c4aa7a908a69cd0b529b3 (patch)
tree4c2484ca10a154af6599fc0f6c61858b1c9c16e0
parentd82e08d185d52086f4d921c08b853c76c80bebbe (diff)
downloadcpython-a5b0c17e0d04931e639c4aa7a908a69cd0b529b3.zip
cpython-a5b0c17e0d04931e639c4aa7a908a69cd0b529b3.tar.gz
cpython-a5b0c17e0d04931e639c4aa7a908a69cd0b529b3.tar.bz2
bpo-42142: Try to fix timeouts in ttk tests (GH-23474)
Instead of using wait_visibility() which waits event <VisibilityNotify> in dead loop use update() which should proceed all queued events. (cherry picked from commit 6cc2c419f6cf5ed336609ba01055e77d7c553e6d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
-rw-r--r--Lib/tkinter/test/test_ttk/test_extensions.py6
-rw-r--r--Lib/tkinter/test/test_ttk/test_widgets.py20
2 files changed, 7 insertions, 19 deletions
diff --git a/Lib/tkinter/test/test_ttk/test_extensions.py b/Lib/tkinter/test/test_ttk/test_extensions.py
index a45f882..6937ba1 100644
--- a/Lib/tkinter/test/test_ttk/test_extensions.py
+++ b/Lib/tkinter/test/test_ttk/test_extensions.py
@@ -114,7 +114,6 @@ class LabeledScaleTest(AbstractTkTest, unittest.TestCase):
def test_horizontal_range(self):
lscale = ttk.LabeledScale(self.root, from_=0, to=10)
lscale.pack()
- lscale.wait_visibility()
lscale.update()
linfo_1 = lscale.label.place_info()
@@ -144,7 +143,6 @@ class LabeledScaleTest(AbstractTkTest, unittest.TestCase):
def test_variable_change(self):
x = ttk.LabeledScale(self.root)
x.pack()
- x.wait_visibility()
x.update()
curr_xcoord = x.scale.coords()[0]
@@ -187,7 +185,6 @@ class LabeledScaleTest(AbstractTkTest, unittest.TestCase):
def test_resize(self):
x = ttk.LabeledScale(self.root)
x.pack(expand=True, fill='both')
- x.wait_visibility()
x.update()
width, height = x.master.winfo_width(), x.master.winfo_height()
@@ -268,7 +265,6 @@ class OptionMenuTest(AbstractTkTest, unittest.TestCase):
# check that variable is updated correctly
optmenu.pack()
- optmenu.wait_visibility()
optmenu['menu'].invoke(0)
self.assertEqual(optmenu._variable.get(), items[0])
@@ -299,9 +295,7 @@ class OptionMenuTest(AbstractTkTest, unittest.TestCase):
textvar2 = tkinter.StringVar(self.root)
optmenu2 = ttk.OptionMenu(self.root, textvar2, default, *items)
optmenu.pack()
- optmenu.wait_visibility()
optmenu2.pack()
- optmenu2.wait_visibility()
optmenu['menu'].invoke(1)
optmenu2['menu'].invoke(2)
optmenu_stringvar_name = optmenu['menu'].entrycget(0, 'variable')
diff --git a/Lib/tkinter/test/test_ttk/test_widgets.py b/Lib/tkinter/test/test_ttk/test_widgets.py
index e20ec39..157ef0e 100644
--- a/Lib/tkinter/test/test_ttk/test_widgets.py
+++ b/Lib/tkinter/test/test_ttk/test_widgets.py
@@ -60,11 +60,10 @@ class WidgetTest(AbstractTkTest, unittest.TestCase):
super().setUp()
self.widget = ttk.Button(self.root, width=0, text="Text")
self.widget.pack()
- self.widget.wait_visibility()
def test_identify(self):
- self.widget.update_idletasks()
+ self.widget.update()
self.assertEqual(self.widget.identify(
int(self.widget.winfo_width() / 2),
int(self.widget.winfo_height() / 2)
@@ -326,8 +325,7 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
def test_identify(self):
self.entry.pack()
- self.entry.wait_visibility()
- self.entry.update_idletasks()
+ self.entry.update()
# bpo-27313: macOS Cocoa widget differs from X, allow either
if sys.platform == 'darwin':
@@ -450,7 +448,7 @@ class ComboboxTest(EntryTest, unittest.TestCase):
self.combo.bind('<<ComboboxSelected>>',
lambda evt: success.append(True))
self.combo.pack()
- self.combo.wait_visibility()
+ self.combo.update()
height = self.combo.winfo_height()
self._show_drop_down_listbox()
@@ -466,7 +464,7 @@ class ComboboxTest(EntryTest, unittest.TestCase):
self.combo['postcommand'] = lambda: success.append(True)
self.combo.pack()
- self.combo.wait_visibility()
+ self.combo.update()
self._show_drop_down_listbox()
self.assertTrue(success)
@@ -666,7 +664,6 @@ class PanedWindowTest(AbstractWidgetTest, unittest.TestCase):
self.assertRaises(tkinter.TclError, self.paned.sashpos, 1)
self.paned.pack(expand=True, fill='both')
- self.paned.wait_visibility()
curr_pos = self.paned.sashpos(0)
self.paned.sashpos(0, 1000)
@@ -934,7 +931,7 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
self.nb.add(self.child1, text='a')
self.nb.pack()
- self.nb.wait_visibility()
+ self.nb.update()
if sys.platform == 'darwin':
tb_idx = "@20,5"
else:
@@ -1042,7 +1039,7 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
def test_select(self):
self.nb.pack()
- self.nb.wait_visibility()
+ self.nb.update()
success = []
tab_changed = []
@@ -1085,7 +1082,7 @@ class NotebookTest(AbstractWidgetTest, unittest.TestCase):
def test_traversal(self):
self.nb.pack()
- self.nb.wait_visibility()
+ self.nb.update()
self.nb.select(0)
@@ -1347,7 +1344,6 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
def test_bbox(self):
self.tv.pack()
self.assertEqual(self.tv.bbox(''), '')
- self.tv.wait_visibility()
self.tv.update()
item_id = self.tv.insert('', 'end')
@@ -1544,7 +1540,6 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
success = [] # no success for now
self.tv.pack()
- self.tv.wait_visibility()
self.tv.heading('#0', command=lambda: success.append(True))
self.tv.column('#0', width=100)
self.tv.update()
@@ -1792,7 +1787,6 @@ class TreeviewTest(AbstractWidgetTest, unittest.TestCase):
lambda evt: events.append(2))
self.tv.pack()
- self.tv.wait_visibility()
self.tv.update()
pos_y = set()