(self)
| 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 | |
| 1490 | class RelativeImportTests(unittest.TestCase): |
nothing calls this directly
no test coverage detected