Skip to content

Commit 5473fc5

Browse files
author
guilherme.polo
committed
Use a single Tcl interpreter through all these tests, this may help some
failing buildbots. git-svn-id: http://svn.python.org/projects/python/trunk@69195 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 7e3e228 commit 5473fc5

File tree

4 files changed

+34
-16
lines changed

4 files changed

+34
-16
lines changed

Lib/lib-tk/test/test_ttk/support.py

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ def get_tk_root():
1515

1616
return root
1717

18+
def root_deiconify():
19+
root = get_tk_root()
20+
root.deiconify()
21+
22+
def root_withdraw():
23+
root = get_tk_root()
24+
root.withdraw()
25+
1826

1927
def simulate_mouse_click(widget, x, y):
2028
"""Generate proper events to click at the x, y position (tries to act

Lib/lib-tk/test/test_ttk/test_extensions.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010

1111
class LabeledScaleTest(unittest.TestCase):
1212

13+
def setUp(self):
14+
support.root_deiconify()
15+
16+
def tearDown(self):
17+
support.root_withdraw()
18+
19+
1320
def test_widget_destroy(self):
1421
# automatically created variable
1522
x = ttk.LabeledScale()
@@ -175,12 +182,12 @@ def test_resize(self):
175182
class OptionMenuTest(unittest.TestCase):
176183

177184
def setUp(self):
178-
self.root = support.get_tk_root()
179-
self.textvar = Tkinter.StringVar(self.root)
185+
support.root_deiconify()
186+
self.textvar = Tkinter.StringVar()
180187

181188
def tearDown(self):
182189
del self.textvar
183-
self.root.destroy()
190+
support.root_withdraw()
184191

185192

186193
def test_widget_destroy(self):

Lib/lib-tk/test/test_ttk/test_style.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,7 @@
1010
class StyleTest(unittest.TestCase):
1111

1212
def setUp(self):
13-
self.root = support.get_tk_root()
14-
self.style = ttk.Style(self.root)
15-
16-
def tearDown(self):
17-
# As tests have shown, these tests are likely to deliver
18-
# <<ThemeChanged>> events after the root is destroyed, so
19-
# lets let them happen now.
20-
self.root.update_idletasks()
21-
self.root.destroy()
13+
self.style = ttk.Style()
2214

2315

2416
def test_configure(self):

Lib/lib-tk/test/test_ttk/test_widgets.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ class WidgetTest(unittest.TestCase):
1212
"""Tests methods available in every ttk widget."""
1313

1414
def setUp(self):
15+
support.root_deiconify()
1516
self.widget = ttk.Button()
1617
self.widget.pack()
1718
self.widget.wait_visibility()
1819

1920
def tearDown(self):
2021
self.widget.destroy()
22+
support.root_withdraw()
2123

2224

2325
def test_identify(self):
@@ -107,10 +109,12 @@ def cb_test():
107109
class ComboboxTest(unittest.TestCase):
108110

109111
def setUp(self):
112+
support.root_deiconify()
110113
self.combo = ttk.Combobox()
111114

112115
def tearDown(self):
113116
self.combo.destroy()
117+
support.root_withdraw()
114118

115119
def _show_drop_down_listbox(self):
116120
width = self.combo.winfo_width()
@@ -195,10 +199,12 @@ def check_get_current(getval, currval):
195199
class EntryTest(unittest.TestCase):
196200

197201
def setUp(self):
202+
support.root_deiconify()
198203
self.entry = ttk.Entry()
199204

200205
def tearDown(self):
201206
self.entry.destroy()
207+
support.root_withdraw()
202208

203209

204210
def test_bbox(self):
@@ -297,10 +303,12 @@ def validate(content):
297303
class PanedwindowTest(unittest.TestCase):
298304

299305
def setUp(self):
306+
support.root_deiconify()
300307
self.paned = ttk.Panedwindow()
301308

302309
def tearDown(self):
303310
self.paned.destroy()
311+
support.root_withdraw()
304312

305313

306314
def test_add(self):
@@ -445,12 +453,14 @@ def cb_test():
445453
class ScaleTest(unittest.TestCase):
446454

447455
def setUp(self):
456+
support.root_deiconify()
448457
self.scale = ttk.Scale()
449458
self.scale.pack()
450459
self.scale.update()
451460

452461
def tearDown(self):
453462
self.scale.destroy()
463+
support.root_withdraw()
454464

455465

456466
def test_custom_event(self):
@@ -519,6 +529,7 @@ def test_set(self):
519529
class NotebookTest(unittest.TestCase):
520530

521531
def setUp(self):
532+
support.root_deiconify()
522533
self.nb = ttk.Notebook()
523534
self.child1 = ttk.Label()
524535
self.child2 = ttk.Label()
@@ -529,6 +540,7 @@ def tearDown(self):
529540
self.child1.destroy()
530541
self.child2.destroy()
531542
self.nb.destroy()
543+
support.root_withdraw()
532544

533545

534546
def test_tab_identifiers(self):
@@ -708,13 +720,12 @@ def test_traversal(self):
708720
class TreeviewTest(unittest.TestCase):
709721

710722
def setUp(self):
711-
self.root = support.get_tk_root()
712-
self.tv = ttk.Treeview(self.root)
723+
support.root_deiconify()
724+
self.tv = ttk.Treeview()
713725

714726
def tearDown(self):
715727
self.tv.destroy()
716-
self.root.update_idletasks()
717-
self.root.destroy()
728+
support.root_withdraw()
718729

719730

720731
def test_bbox(self):

0 commit comments

Comments
 (0)