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

Skip to content

Commit 2a998fa

Browse files
committed
Merged revisions 73495 via svnmerge from
svn+ssh://pythondev/python/trunk ........ r73495 | guilherme.polo | 2009-06-21 14:22:50 -0300 (Sun, 21 Jun 2009) | 4 lines Issue #5450: Moved tests involving loading tk from Lib/test/test_tcl to Lib/lib-tk/test/test_tkinter/test_loadtk in order to follow the behaviour of test_ttkguionly. ........
1 parent 10706e2 commit 2a998fa

3 files changed

Lines changed: 50 additions & 31 deletions

File tree

Lib/test/test_tcl.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -127,37 +127,6 @@ def testPackageRequireException(self):
127127
tcl = self.interp
128128
self.assertRaises(TclError,tcl.eval,'package require DNE')
129129

130-
def testLoadTk(self):
131-
import os
132-
if 'DISPLAY' not in os.environ:
133-
# skipping test of clean upgradeability
134-
return
135-
tcl = Tcl()
136-
self.assertRaises(TclError,tcl.winfo_geometry)
137-
tcl.loadtk()
138-
self.assertEqual('1x1+0+0', tcl.winfo_geometry())
139-
tcl.destroy()
140-
141-
def testLoadTkFailure(self):
142-
import os
143-
old_display = None
144-
import sys
145-
if sys.platform.startswith(('win', 'darwin', 'cygwin')):
146-
return # no failure possible on windows?
147-
with support.EnvironmentVarGuard() as env:
148-
if 'DISPLAY' in os.environ:
149-
del env['DISPLAY']
150-
# on some platforms, deleting environment variables
151-
# doesn't actually carry through to the process level
152-
# because they don't support unsetenv
153-
# If that's the case, abort.
154-
display = os.popen('echo $DISPLAY').read().strip()
155-
if display:
156-
return
157-
158-
tcl = Tcl()
159-
self.assertRaises(TclError, tcl.winfo_geometry)
160-
self.assertRaises(TclError, tcl.loadtk)
161130

162131
def test_main():
163132
support.run_unittest(TclTest, TkinterTest)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import os
2+
import sys
3+
import unittest
4+
import test.support as test_support
5+
from tkinter import Tcl, TclError
6+
7+
test_support.requires('gui')
8+
9+
class TkLoadTest(unittest.TestCase):
10+
11+
@unittest.skipIf('DISPLAY' not in os.environ, 'No $DISPLAY set.')
12+
def testLoadTk(self):
13+
tcl = Tcl()
14+
self.assertRaises(TclError,tcl.winfo_geometry)
15+
tcl.loadtk()
16+
self.assertEqual('1x1+0+0', tcl.winfo_geometry())
17+
tcl.destroy()
18+
19+
def testLoadTkFailure(self):
20+
old_display = None
21+
if sys.platform.startswith(('win', 'darwin', 'cygwin')):
22+
# no failure possible on windows?
23+
24+
# XXX Maybe on tk older than 8.4.13 it would be possible,
25+
# see tkinter.h.
26+
return
27+
with test_support.EnvironmentVarGuard() as env:
28+
if 'DISPLAY' in os.environ:
29+
del env['DISPLAY']
30+
# on some platforms, deleting environment variables
31+
# doesn't actually carry through to the process level
32+
# because they don't support unsetenv
33+
# If that's the case, abort.
34+
display = os.popen('echo $DISPLAY').read().strip()
35+
if display:
36+
return
37+
38+
tcl = Tcl()
39+
self.assertRaises(TclError, tcl.winfo_geometry)
40+
self.assertRaises(TclError, tcl.loadtk)
41+
42+
tests_gui = (TkLoadTest, )
43+
44+
if __name__ == "__main__":
45+
test_support.run_unittest(*tests_gui)

Misc/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,11 @@ Extension Modules
13371337
Tests
13381338
-----
13391339

1340+
- Issue #5450: Moved tests involving loading tk from Lib/test/test_tcl to
1341+
Lib/tkinter/test/test_tkinter/test_loadtk. With this, these tests demonstrate
1342+
the same behaviour as test_ttkguionly (and now also test_tk) which is to
1343+
skip the tests if DISPLAY is defined but can't be used.
1344+
13401345
- regrtest no longer treats ImportError as equivalent to SkipTest. Imports
13411346
that should cause a test to be skipped are now done using import_module
13421347
from test support, which does the conversion.

0 commit comments

Comments
 (0)