[Python-checkins] cpython (2.7): Issue #17883: Tweak test_tcl testLoadWithUNC to skip the test in the

zach.ware python-checkins at python.org
Mon Nov 4 05:52:47 CET 2013


http://hg.python.org/cpython/rev/72c3ca3ed22a
changeset:   86909:72c3ca3ed22a
branch:      2.7
user:        Zachary Ware <zachary.ware at gmail.com>
date:        Sun Nov 03 22:51:25 2013 -0600
summary:
  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.

files:
  Lib/test/test_tcl.py |  16 ++++++++++------
  Misc/NEWS            |   4 ++++
  2 files changed, 14 insertions(+), 6 deletions(-)


diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -138,18 +138,15 @@
         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 @@
             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',
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -23,6 +23,10 @@
 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.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list