(self)
| 3320 | |
| 3321 | @needs_windows |
| 3322 | def test_absolute_windows(self): |
| 3323 | P = self.cls |
| 3324 | |
| 3325 | # Simple absolute paths. |
| 3326 | self.assertEqual(str(P('c:\\').absolute()), 'c:\\') |
| 3327 | self.assertEqual(str(P('c:\\a').absolute()), 'c:\\a') |
| 3328 | self.assertEqual(str(P('c:\\a\\b').absolute()), 'c:\\a\\b') |
| 3329 | |
| 3330 | # UNC absolute paths. |
| 3331 | share = '\\\\server\\share\\' |
| 3332 | self.assertEqual(str(P(share).absolute()), share) |
| 3333 | self.assertEqual(str(P(share + 'a').absolute()), share + 'a') |
| 3334 | self.assertEqual(str(P(share + 'a\\b').absolute()), share + 'a\\b') |
| 3335 | |
| 3336 | # UNC relative paths. |
| 3337 | with mock.patch("os.getcwd") as getcwd: |
| 3338 | getcwd.return_value = share |
| 3339 | |
| 3340 | self.assertEqual(str(P().absolute()), share) |
| 3341 | self.assertEqual(str(P('.').absolute()), share) |
| 3342 | self.assertEqual(str(P('a').absolute()), os.path.join(share, 'a')) |
| 3343 | self.assertEqual(str(P('a', 'b', 'c').absolute()), |
| 3344 | os.path.join(share, 'a', 'b', 'c')) |
| 3345 | |
| 3346 | drive = os.path.splitdrive(self.base)[0] |
| 3347 | with os_helper.change_cwd(self.base): |
| 3348 | # Relative path with root |
| 3349 | self.assertEqual(str(P('\\').absolute()), drive + '\\') |
| 3350 | self.assertEqual(str(P('\\foo').absolute()), drive + '\\foo') |
| 3351 | |
| 3352 | # Relative path on current drive |
| 3353 | self.assertEqual(str(P(drive).absolute()), self.base) |
| 3354 | self.assertEqual(str(P(drive + 'foo').absolute()), os.path.join(self.base, 'foo')) |
| 3355 | |
| 3356 | with os_helper.subst_drive(self.base) as other_drive: |
| 3357 | # Set the working directory on the substitute drive |
| 3358 | saved_cwd = os.getcwd() |
| 3359 | other_cwd = f'{other_drive}\\dirA' |
| 3360 | os.chdir(other_cwd) |
| 3361 | os.chdir(saved_cwd) |
| 3362 | |
| 3363 | # Relative path on another drive |
| 3364 | self.assertEqual(str(P(other_drive).absolute()), other_cwd) |
| 3365 | self.assertEqual(str(P(other_drive + 'foo').absolute()), other_cwd + '\\foo') |
| 3366 | |
| 3367 | @needs_windows |
| 3368 | def test_expanduser_windows(self): |
nothing calls this directly
no test coverage detected