summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tcl.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_tcl.py')
-rw-r--r--Lib/test/test_tcl.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
index e8ba58f..d86246c 100644
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -1,13 +1,14 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import unittest
+import sys
import os
-from test import test_support
+from test import support
# Skip this test if the _tkinter module wasn't built.
-_tkinter = test_support.import_module('_tkinter')
+_tkinter = support.import_module('_tkinter')
-from Tkinter import Tcl
+from tkinter import Tcl
from _tkinter import TclError
@@ -119,7 +120,7 @@ class TclTest(unittest.TestCase):
filename = "doesnotexists"
try:
os.remove(filename)
- except Exception,e:
+ except Exception as e:
pass
self.assertRaises(TclError,tcl.evalfile,filename)
@@ -127,34 +128,33 @@ class TclTest(unittest.TestCase):
tcl = self.interp
self.assertRaises(TclError,tcl.eval,'package require DNE')
+ @unittest.skipUnless(sys.platform == 'win32', 'Requires Windows')
def testLoadWithUNC(self):
- import sys
- if sys.platform != 'win32':
- return
-
# Build a UNC path from the regular path.
# Something like
# \\%COMPUTERNAME%\c$\python27\python.exe
fullname = os.path.abspath(sys.executable)
if fullname[1] != ':':
- return
+ raise unittest.SkipTest('Absolute path should have drive part')
unc_name = r'\\%s\%s$\%s' % (os.environ['COMPUTERNAME'],
fullname[0],
fullname[3:])
+ if not os.path.exists(unc_name):
+ raise unittest.SkipTest('Cannot connect to UNC Path')
- with test_support.EnvironmentVarGuard() as env:
+ with support.EnvironmentVarGuard() as env:
env.unset("TCL_LIBRARY")
- f = os.popen('%s -c "import Tkinter; print Tkinter"' % (unc_name,))
+ f = os.popen('%s -c "import tkinter; print(tkinter)"' % (unc_name,))
- self.assertTrue('Tkinter.py' in f.read())
+ self.assertIn('tkinter', f.read())
# exit code must be zero
self.assertEqual(f.close(), None)
def test_main():
- test_support.run_unittest(TclTest, TkinterTest)
+ support.run_unittest(TclTest, TkinterTest)
if __name__ == "__main__":
test_main()