mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
bpo-34195: Fix case-sensitive comparison in test_nt_helpers (GH-8448)
* Fix case-sensitive comparison test_nt_helpers assumed that two versions of a Windows path could be compared case-sensitively. This is not the case, and the difference can be triggered (apparently) by running the test on a path somewhere below a Junction.
This commit is contained in:
parent
ee98e7bbde
commit
ff64add8d4
1 changed files with 11 additions and 5 deletions
|
@ -422,16 +422,22 @@ class TestNtpath(unittest.TestCase):
|
||||||
self.assertTrue(ntpath.ismount(b"\\\\localhost\\c$"))
|
self.assertTrue(ntpath.ismount(b"\\\\localhost\\c$"))
|
||||||
self.assertTrue(ntpath.ismount(b"\\\\localhost\\c$\\"))
|
self.assertTrue(ntpath.ismount(b"\\\\localhost\\c$\\"))
|
||||||
|
|
||||||
|
def assertEqualCI(self, s1, s2):
|
||||||
|
"""Assert that two strings are equal ignoring case differences."""
|
||||||
|
self.assertEqual(s1.lower(), s2.lower())
|
||||||
|
|
||||||
@unittest.skipUnless(nt, "OS helpers require 'nt' module")
|
@unittest.skipUnless(nt, "OS helpers require 'nt' module")
|
||||||
def test_nt_helpers(self):
|
def test_nt_helpers(self):
|
||||||
# Trivial validation that the helpers do not break, and support both
|
# Trivial validation that the helpers do not break, and support both
|
||||||
# unicode and bytes (UTF-8) paths
|
# unicode and bytes (UTF-8) paths
|
||||||
|
|
||||||
drive, path = ntpath.splitdrive(sys.executable)
|
executable = nt._getfinalpathname(sys.executable)
|
||||||
drive = drive.rstrip(ntpath.sep) + ntpath.sep
|
|
||||||
self.assertEqual(drive, nt._getvolumepathname(sys.executable))
|
for path in executable, os.fsencode(executable):
|
||||||
self.assertEqual(drive.encode(),
|
volume_path = nt._getvolumepathname(path)
|
||||||
nt._getvolumepathname(sys.executable.encode()))
|
path_drive = ntpath.splitdrive(path)[0]
|
||||||
|
volume_path_drive = ntpath.splitdrive(volume_path)[0]
|
||||||
|
self.assertEqualCI(path_drive, volume_path_drive)
|
||||||
|
|
||||||
cap, free = nt._getdiskusage(sys.exec_prefix)
|
cap, free = nt._getdiskusage(sys.exec_prefix)
|
||||||
self.assertGreater(cap, 0)
|
self.assertGreater(cap, 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue