Issue #15338: skip test_UNC_path when the current user doesn't have enough permissions to access the path.

This commit is contained in:
Antoine Pitrou 2012-07-13 20:59:19 +02:00
commit c27ace688c

View file

@ -464,19 +464,22 @@ class PathsTests(unittest.TestCase):
drive = path[0] drive = path[0]
unc = "\\\\%s\\%s$"%(hn, drive) unc = "\\\\%s\\%s$"%(hn, drive)
unc += path[2:] unc += path[2:]
sys.path.insert(0, unc)
try: try:
os.listdir(unc) os.listdir(unc)
try: except OSError as e:
mod = __import__("test_unc_path") if e.errno in (errno.EPERM, errno.EACCES):
except ImportError as e: # See issue #15338
self.fail("could not import 'test_unc_path' from %r: %r" self.skipTest("cannot access administrative share %r" % (unc,))
% (unc, e)) raise
self.assertEqual(mod.testdata, 'test_unc_path') sys.path.insert(0, unc)
self.assertTrue(mod.__file__.startswith(unc), mod.__file__) try:
unload("test_unc_path") mod = __import__("test_unc_path")
finally: except ImportError as e:
sys.path.remove(unc) self.fail("could not import 'test_unc_path' from %r: %r"
% (unc, e))
self.assertEqual(mod.testdata, 'test_unc_path')
self.assertTrue(mod.__file__.startswith(unc), mod.__file__)
unload("test_unc_path")
class RelativeImportTests(unittest.TestCase): class RelativeImportTests(unittest.TestCase):