=== added file 'Lib/lib-tk/test/test_tkinter/test_tcl.py' --- Lib/lib-tk/test/test_tkinter/test_tcl.py 1970-01-01 00:00:00 +0000 +++ Lib/lib-tk/test/test_tkinter/test_tcl.py 2009-03-12 21:17:35 +0000 @@ -0,0 +1,71 @@ +#!/usr/bin/env python + +import unittest +import os +import sys +import _tkinter +from test import test_support +from Tkinter import Tcl +from _tkinter import TclError + +# These tests were originally in test_tcl in the main test directory, but it +# seems to be more appropriate for them to be here. The move was prompted by +# the case of testLoadTK, which could fail instead of being skipped like the +# other TK tests in certain circumstances (eg: DISPLAY is set but the display +# isn't responding). + +test_support.requires('gui') + + +class TkinterTest(unittest.TestCase): + + def testFlattenLen(self): + # flatten() + self.assertRaises(TypeError, _tkinter._flatten, True) + + +class TclTest(unittest.TestCase): + + def setUp(self): + self.interp = Tcl() + + def testLoadTk(self): + if 'DISPLAY' not in os.environ: + # skipping test of clean upgradeability + return + tcl = Tcl() + self.assertRaises(TclError,tcl.winfo_geometry) + tcl.loadtk() + self.assertEqual('1x1+0+0', tcl.winfo_geometry()) + tcl.destroy() + + def testLoadTkFailure(self): + old_display = None + if sys.platform.startswith(('win', 'darwin', 'cygwin')): + return # no failure possible on windows? + if 'DISPLAY' in os.environ: + old_display = os.environ['DISPLAY'] + del os.environ['DISPLAY'] + # on some platforms, deleting environment variables + # doesn't actually carry through to the process level + # because they don't support unsetenv + # If that's the case, abort. + display = os.popen('echo $DISPLAY').read().strip() + if display: + return + try: + tcl = Tcl() + self.assertRaises(TclError, tcl.winfo_geometry) + self.assertRaises(TclError, tcl.loadtk) + finally: + if old_display is not None: + os.environ['DISPLAY'] = old_display + + +tests_gui = (TkinterTest, TclTest) + +def test_main(): + test_support.run_unittest(*tests_gui) + +if __name__ == "__main__": + test_main() === modified file 'Lib/test/test_tcl.py' --- Lib/test/test_tcl.py 2009-02-07 02:20:29 +0000 +++ Lib/test/test_tcl.py 2009-03-12 14:20:23 +0000 @@ -2,19 +2,11 @@ import unittest import os -import _tkinter from test import test_support from Tkinter import Tcl from _tkinter import TclError -class TkinterTest(unittest.TestCase): - - def testFlattenLen(self): - # flatten() - self.assertRaises(TypeError, _tkinter._flatten, True) - - class TclTest(unittest.TestCase): def setUp(self): @@ -124,43 +116,9 @@ tcl = self.interp self.assertRaises(TclError,tcl.eval,'package require DNE') - def testLoadTk(self): - import os - if 'DISPLAY' not in os.environ: - # skipping test of clean upgradeability - return - tcl = Tcl() - self.assertRaises(TclError,tcl.winfo_geometry) - tcl.loadtk() - self.assertEqual('1x1+0+0', tcl.winfo_geometry()) - tcl.destroy() - - def testLoadTkFailure(self): - import os - old_display = None - import sys - if sys.platform.startswith(('win', 'darwin', 'cygwin')): - return # no failure possible on windows? - if 'DISPLAY' in os.environ: - old_display = os.environ['DISPLAY'] - del os.environ['DISPLAY'] - # on some platforms, deleting environment variables - # doesn't actually carry through to the process level - # because they don't support unsetenv - # If that's the case, abort. - display = os.popen('echo $DISPLAY').read().strip() - if display: - return - try: - tcl = Tcl() - self.assertRaises(TclError, tcl.winfo_geometry) - self.assertRaises(TclError, tcl.loadtk) - finally: - if old_display is not None: - os.environ['DISPLAY'] = old_display def test_main(): - test_support.run_unittest(TclTest, TkinterTest) + test_support.run_unittest(TclTest) if __name__ == "__main__": test_main()