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

Method test_getlongpathname

Lib/test/test_winapi.py:99–113  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

97
98class WinAPITests(unittest.TestCase):
99 def test_getlongpathname(self):
100 testfn = pathlib.Path(os.getenv("ProgramFiles")).parents[-1] / "PROGRA~1"
101 if not os.path.isdir(testfn):
102 raise unittest.SkipTest("require x:\\PROGRA~1 to test")
103
104 # pathlib.Path will be rejected - only str is accepted
105 with self.assertRaises(TypeError):
106 _winapi.GetLongPathName(testfn)
107
108 actual = _winapi.GetLongPathName(os.fsdecode(testfn))
109
110 # Can't assume that PROGRA~1 expands to any particular variation, so
111 # ensure it matches any one of them.
112 candidates = set(testfn.parent.glob("Progra*"))
113 self.assertIn(pathlib.Path(actual), candidates)
114
115 def test_getshortpathname(self):
116 testfn = pathlib.Path(os.getenv("ProgramFiles"))

Callers

nothing calls this directly

Calls 5

setFunction · 0.85
assertInMethod · 0.80
isdirMethod · 0.45
assertRaisesMethod · 0.45
globMethod · 0.45

Tested by

no test coverage detected