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