]> granicus.if.org Git - python/commitdiff
Issue #17883: Tweak test_tcl testLoadWithUNC to skip the test in the
authorZachary Ware <zachary.ware@gmail.com>
Mon, 4 Nov 2013 04:51:25 +0000 (22:51 -0600)
committerZachary Ware <zachary.ware@gmail.com>
Mon, 4 Nov 2013 04:51:25 +0000 (22:51 -0600)
event of a permission error on Windows and to properly report other
skip conditions.

Lib/test/test_tcl.py
Misc/NEWS

index 50e1ac40acf9a1ec8b6d78761b9df80a62e55348..0ccede1a7e875c417ac2dd6f431303855c0cdab8 100644 (file)
@@ -138,18 +138,15 @@ class TclTest(unittest.TestCase):
         tcl = self.interp
         self.assertRaises(TclError,tcl.eval,'package require DNE')
 
+    @unittest.skipUnless(sys.platform == 'win32', "only applies to 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
+            self.skipTest('unusable path: %r' % fullname)
         unc_name = r'\\%s\%s$\%s' % (os.environ['COMPUTERNAME'],
                                     fullname[0],
                                     fullname[3:])
@@ -158,7 +155,14 @@ class TclTest(unittest.TestCase):
             env.unset("TCL_LIBRARY")
             cmd = '%s -c "import Tkinter; print Tkinter"' % (unc_name,)
 
-            p = Popen(cmd, stdout=PIPE, stderr=PIPE)
+            try:
+                p = Popen(cmd, stdout=PIPE, stderr=PIPE)
+            except WindowsError as e:
+                if e.winerror == 5:
+                    self.skipTest('Not permitted to start the child process')
+                else:
+                    raise
+
             out_data, err_data = p.communicate()
 
             msg = '\n\n'.join(['"Tkinter.py" not in output',
index 22be7c46f27ca3022bc66350383dc96213d853cc..9de6aafbb5c1359c97e6402cd6c7087bc0c593ef 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -23,6 +23,10 @@ Library
 Tests
 -----
 
+- Issue #17883: Tweak test_tcl testLoadWithUNC to skip the test in the
+  event of a permission error on Windows and to properly report other
+  skip conditions.
+
 - Issue #17883: Backported _is_gui_available() in test.test_support to
   avoid hanging Windows buildbots on test_ttk_guionly.