MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_UNC_path

Method test_UNC_path

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

Source from the content-addressed store, hash-verified

1459 # Regression test for http://bugs.python.org/issue3677.
1460 @unittest.skipUnless(sys.platform == 'win32', 'Windows-specific')
1461 def test_UNC_path(self):
1462 with open(os.path.join(self.path, 'test_unc_path.py'), 'w') as f:
1463 f.write("testdata = 'test_unc_path'")
1464 importlib.invalidate_caches()
1465 # Create the UNC path, like \\myhost\c$\foo\bar.
1466 path = os.path.abspath(self.path)
1467 import socket
1468 hn = socket.gethostname()
1469 drive = path[0]
1470 unc = "\\\\%s\\%s$"%(hn, drive)
1471 unc += path[2:]
1472 try:
1473 os.listdir(unc)
1474 except OSError as e:
1475 if e.errno in (errno.EPERM, errno.EACCES, errno.ENOENT):
1476 # See issue #15338
1477 self.skipTest("cannot access administrative share %r" % (unc,))
1478 raise
1479 sys.path.insert(0, unc)
1480 try:
1481 mod = __import__("test_unc_path")
1482 except ImportError as e:
1483 self.fail("could not import 'test_unc_path' from %r: %r"
1484 % (unc, e))
1485 self.assertEqual(mod.testdata, 'test_unc_path')
1486 self.assertStartsWith(mod.__file__, unc)
1487 unload("test_unc_path")
1488
1489
1490class RelativeImportTests(unittest.TestCase):

Callers

nothing calls this directly

Calls 12

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

Tested by

no test coverage detected