Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9de29af

Browse files
committed
Merged revisions 69060-69063 via svnmerge from
svn+ssh://pythondev/python/trunk ........ r69060 | guilherme.polo | 2009-01-28 17:23:28 -0200 (Wed, 28 Jan 2009) | 2 lines Added support for collecting tests only from specific packages. ........ r69061 | guilherme.polo | 2009-01-28 17:28:04 -0200 (Wed, 28 Jan 2009) | 4 lines * Renaming test_tk_* to test_ttk_* since that is what they are testing. * Added ttk tests to the expected skips mapping just like where test_tcl was expected to be skipped too. ........ r69062 | guilherme.polo | 2009-01-28 18:02:01 -0200 (Wed, 28 Jan 2009) | 1 line Make sure the root windows gets destroyed ........ r69063 | guilherme.polo | 2009-01-28 18:03:26 -0200 (Wed, 28 Jan 2009) | 2 lines Issue #5083: New 'gui' resource for regrtest. ........
1 parent a7d2797 commit 9de29af

6 files changed

Lines changed: 49 additions & 9 deletions

File tree

Lib/test/regrtest.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@
123123
124124
urlfetch - It is okay to download files required on testing.
125125
126+
gui - Run tests that require a running GUI.
127+
126128
To enable all resources except one, use '-uall,-<resource>'. For
127129
example, to run all the tests except for the bsddb tests, give the
128130
option '-uall,-bsddb'.
@@ -176,7 +178,7 @@
176178
from test import support
177179

178180
RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb',
179-
'decimal', 'compiler', 'subprocess', 'urlfetch')
181+
'decimal', 'compiler', 'subprocess', 'urlfetch', 'gui')
180182

181183

182184
def usage(msg):
@@ -1073,6 +1075,8 @@ def printlist(x, width=70, indent=4):
10731075
test_pty
10741076
test_socketserver
10751077
test_tcl
1078+
test_ttk_guionly
1079+
test_ttk_textonly
10761080
test_timeout
10771081
test_urllibnet
10781082
test_multiprocessing
@@ -1088,6 +1092,8 @@ def printlist(x, width=70, indent=4):
10881092
test_kqueue
10891093
test_ossaudiodev
10901094
test_tcl
1095+
test_ttk_guionly
1096+
test_ttk_textonly
10911097
test_zipimport
10921098
test_zlib
10931099
""",
@@ -1103,6 +1109,8 @@ def printlist(x, width=70, indent=4):
11031109
test_ossaudiodev
11041110
test_pep277
11051111
test_tcl
1112+
test_ttk_guionly
1113+
test_ttk_textonly
11061114
test_multiprocessing
11071115
""",
11081116
'netbsd3':
@@ -1117,6 +1125,8 @@ def printlist(x, width=70, indent=4):
11171125
test_ossaudiodev
11181126
test_pep277
11191127
test_tcl
1128+
test_ttk_guionly
1129+
test_ttk_textonly
11201130
test_multiprocessing
11211131
""",
11221132
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
from test import support
1+
import os
2+
import sys
3+
from tkinter import ttk
24
from tkinter.test import runtktests
5+
from _tkinter import TclError
6+
from test import support
7+
8+
try:
9+
ttk.Button()
10+
except TclError as msg:
11+
# assuming ttk is not available
12+
raise support.TestSkipped("ttk not available: %s" % msg)
313

414
def test_main(enable_gui=False):
515
if enable_gui:
@@ -8,7 +18,8 @@ def test_main(enable_gui=False):
818
elif 'gui' not in support.use_resources:
919
support.use_resources.append('gui')
1020

11-
support.run_unittest(*runtktests.get_tests(text=False))
21+
support.run_unittest(
22+
*runtktests.get_tests(text=False, packages=['test_ttk']))
1223

1324
if __name__ == '__main__':
1425
test_main(enable_gui=True)
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
import os
2+
import sys
13
from test import support
24
from tkinter.test import runtktests
35

46
def test_main():
5-
support.run_unittest(*runtktests.get_tests(gui=False))
7+
support.run_unittest(
8+
*runtktests.get_tests(gui=False, packages=['test_ttk']))
69

710
if __name__ == '__main__':
811
test_main()

Lib/tkinter/test/runtktests.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ def is_package(path):
1919
return True
2020
return False
2121

22-
def get_tests_modules(basepath=this_dir_path, gui=True):
22+
def get_tests_modules(basepath=this_dir_path, gui=True, packages=None):
2323
"""This will import and yield modules whose names start with test_
24-
and are inside packages found in the path starting at basepath."""
24+
and are inside packages found in the path starting at basepath.
25+
26+
If packages is specified it should contain package names that
27+
want their tests collected.
28+
"""
2529
py_ext = '.py'
2630

2731
for dirpath, dirnames, filenames in os.walk(basepath):
@@ -31,6 +35,9 @@ def get_tests_modules(basepath=this_dir_path, gui=True):
3135

3236
if is_package(dirpath) and filenames:
3337
pkg_name = dirpath[len(basepath) + len(os.sep):].replace('/', '.')
38+
if packages and pkg_name not in packages:
39+
continue
40+
3441
filenames = filter(
3542
lambda x: x.startswith('test_') and x.endswith(py_ext),
3643
filenames)
@@ -48,7 +55,7 @@ def get_tests_modules(basepath=this_dir_path, gui=True):
4855
if gui:
4956
raise
5057

51-
def get_tests(text=True, gui=True):
58+
def get_tests(text=True, gui=True, packages=None):
5259
"""Yield all the tests in the modules found by get_tests_modules.
5360
5461
If nogui is True, only tests that do not require a GUI will be
@@ -58,7 +65,7 @@ def get_tests(text=True, gui=True):
5865
attrs.append('tests_nogui')
5966
if gui:
6067
attrs.append('tests_gui')
61-
for module in get_tests_modules(gui=gui):
68+
for module in get_tests_modules(gui=gui, packages=packages):
6269
for attr in attrs:
6370
for test in getattr(module, attr, ()):
6471
yield test

Lib/tkinter/test/test_ttk/test_widgets.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,13 @@ def test_traversal(self):
708708
class TreeviewTest(unittest.TestCase):
709709

710710
def setUp(self):
711-
self.tv = ttk.Treeview()
711+
self.root = support.get_tk_root()
712+
self.tv = ttk.Treeview(self.root)
712713

713714
def tearDown(self):
714715
self.tv.destroy()
716+
self.root.update_idletasks()
717+
self.root.destroy()
715718

716719

717720
def test_bbox(self):

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,12 @@ Extension Modules
423423
buffer.
424424

425425

426+
Tests
427+
-----
428+
429+
- Issue #5083: New 'gui' resource for regrtest.
430+
431+
426432
Docs
427433
----
428434

0 commit comments

Comments
 (0)