summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ntpath.py
diff options
context:
space:
mode:
authorTim Golden <mail@timgolden.me.uk>2018-07-25 13:36:54 (GMT)
committerGitHub <noreply@github.com>2018-07-25 13:36:54 (GMT)
commitff64add8d4be2e37c552ba702f629b0b6639cd33 (patch)
treeaded94c791e7737e08c872df6df31f21c030f206 /Lib/test/test_ntpath.py
parentee98e7bbde45fcf24d769353e29337d5ccdbaac5 (diff)
downloadcpython-ff64add8d4be2e37c552ba702f629b0b6639cd33.zip
cpython-ff64add8d4be2e37c552ba702f629b0b6639cd33.tar.gz
cpython-ff64add8d4be2e37c552ba702f629b0b6639cd33.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_ntpath.py')
-rw-r--r--Lib/test/test_ntpath.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py
index 2d48be8..1e85ad5 100644
--- a/Lib/test/test_ntpath.py
+++ b/Lib/test/test_ntpath.py
@@ -422,16 +422,22 @@ class TestNtpath(unittest.TestCase):
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")
def test_nt_helpers(self):
# Trivial validation that the helpers do not break, and support both
# unicode and bytes (UTF-8) paths
- drive, path = ntpath.splitdrive(sys.executable)
- drive = drive.rstrip(ntpath.sep) + ntpath.sep
- self.assertEqual(drive, nt._getvolumepathname(sys.executable))
- self.assertEqual(drive.encode(),
- nt._getvolumepathname(sys.executable.encode()))
+ executable = nt._getfinalpathname(sys.executable)
+
+ for path in executable, os.fsencode(executable):
+ volume_path = nt._getvolumepathname(path)
+ 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)
self.assertGreater(cap, 0)