(self)
| 97 | |
| 98 | class 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")) |
nothing calls this directly
no test coverage detected