MCPcopy Index your code
hub / github.com/python/cpython / test_UNC_path

Method test_UNC_path

Lib/test/test_import/__init__.py:1508–1534  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1506 # Regression test for http://bugs.python.org/issue3677.
1507 @unittest.skipUnless(sys.platform == 'win32', 'Windows-specific')
1508 def test_UNC_path(self):
1509 with open(os.path.join(self.path, 'test_unc_path.py'), 'w') as f:
1510 f.write("testdata = 'test_unc_path'")
1511 importlib.invalidate_caches()
1512 # Create the UNC path, like \\myhost\c$\foo\bar.
1513 path = os.path.abspath(self.path)
1514 import socket
1515 hn = socket.gethostname()
1516 drive = path[0]
1517 unc = "\\\\%s\\%s$"%(hn, drive)
1518 unc += path[2:]
1519 try:
1520 os.listdir(unc)
1521 except OSError as e:
1522 if e.errno in (errno.EPERM, errno.EACCES, errno.ENOENT):
1523 # See issue #15338
1524 self.skipTest("cannot access administrative share %r" % (unc,))
1525 raise
1526 sys.path.insert(0, unc)
1527 try:
1528 mod = __import__("test_unc_path")
1529 except ImportError as e:
1530 self.fail("could not import 'test_unc_path' from %r: %r"
1531 % (unc, e))
1532 self.assertEqual(mod.testdata, 'test_unc_path')
1533 self.assertStartsWith(mod.__file__, unc)
1534 unload("test_unc_path")
1535
1536
1537class RelativeImportTests(unittest.TestCase):

Callers

nothing calls this directly

Calls 13

unloadFunction · 0.90
__import__Function · 0.85
listdirMethod · 0.80
skipTestMethod · 0.80
assertStartsWithMethod · 0.80
openFunction · 0.50
joinMethod · 0.45
writeMethod · 0.45
invalidate_cachesMethod · 0.45
abspathMethod · 0.45
insertMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected