Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd9c542

Browse files
committed
using os.listdrives() to find non exist drive
1 parent c283d4a commit cd9c542

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/test/test_ntpath.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,9 @@ def test_realpath_basic(self):
376376

377377
# gh-88013: call ntpath.realpath with binary drive name may raise a
378378
# TypeError. The drive should not exist to reproduce the bug.
379-
self.assertEqual(ntpath.realpath(b"n:/"), b"n:\\")
379+
drives = {f"{chr(x)}:\\" for x in range(65, 91)} - set(os.listdrives())
380+
d = drives.pop().encode()
381+
self.assertEqual(ntpath.realpath(d), d)
380382

381383
@os_helper.skip_unless_symlink
382384
@unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')

0 commit comments

Comments
 (0)