mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
bpo-38087: Fix case sensitivity in test_pathlib and test_ntpath (GH-15850)
This commit is contained in:
parent
cd8221152d
commit
97d7906e30
3 changed files with 123 additions and 105 deletions
|
@ -1361,10 +1361,13 @@ class _BasePathTest(object):
|
|||
func(*args, **kwargs)
|
||||
self.assertEqual(cm.exception.errno, errno.ENOENT)
|
||||
|
||||
def assertEqualNormCase(self, path_a, path_b):
|
||||
self.assertEqual(os.path.normcase(path_a), os.path.normcase(path_b))
|
||||
|
||||
def _test_cwd(self, p):
|
||||
q = self.cls(os.getcwd())
|
||||
self.assertEqual(p, q)
|
||||
self.assertEqual(str(p), str(q))
|
||||
self.assertEqualNormCase(str(p), str(q))
|
||||
self.assertIs(type(p), type(q))
|
||||
self.assertTrue(p.is_absolute())
|
||||
|
||||
|
@ -1375,7 +1378,7 @@ class _BasePathTest(object):
|
|||
def _test_home(self, p):
|
||||
q = self.cls(os.path.expanduser('~'))
|
||||
self.assertEqual(p, q)
|
||||
self.assertEqual(str(p), str(q))
|
||||
self.assertEqualNormCase(str(p), str(q))
|
||||
self.assertIs(type(p), type(q))
|
||||
self.assertTrue(p.is_absolute())
|
||||
|
||||
|
@ -1583,14 +1586,14 @@ class _BasePathTest(object):
|
|||
p.resolve(strict=True)
|
||||
self.assertEqual(cm.exception.errno, errno.ENOENT)
|
||||
# Non-strict
|
||||
self.assertEqual(str(p.resolve(strict=False)),
|
||||
os.path.join(BASE, 'foo'))
|
||||
self.assertEqualNormCase(str(p.resolve(strict=False)),
|
||||
os.path.join(BASE, 'foo'))
|
||||
p = P(BASE, 'foo', 'in', 'spam')
|
||||
self.assertEqual(str(p.resolve(strict=False)),
|
||||
os.path.join(BASE, 'foo', 'in', 'spam'))
|
||||
self.assertEqualNormCase(str(p.resolve(strict=False)),
|
||||
os.path.join(BASE, 'foo', 'in', 'spam'))
|
||||
p = P(BASE, '..', 'foo', 'in', 'spam')
|
||||
self.assertEqual(str(p.resolve(strict=False)),
|
||||
os.path.abspath(os.path.join('foo', 'in', 'spam')))
|
||||
self.assertEqualNormCase(str(p.resolve(strict=False)),
|
||||
os.path.abspath(os.path.join('foo', 'in', 'spam')))
|
||||
# These are all relative symlinks.
|
||||
p = P(BASE, 'dirB', 'fileB')
|
||||
self._check_resolve_relative(p, p)
|
||||
|
@ -2137,16 +2140,16 @@ class _BasePathTest(object):
|
|||
# Resolve absolute paths.
|
||||
p = (P / 'link0').resolve()
|
||||
self.assertEqual(p, P)
|
||||
self.assertEqual(str(p), BASE)
|
||||
self.assertEqualNormCase(str(p), BASE)
|
||||
p = (P / 'link1').resolve()
|
||||
self.assertEqual(p, P)
|
||||
self.assertEqual(str(p), BASE)
|
||||
self.assertEqualNormCase(str(p), BASE)
|
||||
p = (P / 'link2').resolve()
|
||||
self.assertEqual(p, P)
|
||||
self.assertEqual(str(p), BASE)
|
||||
self.assertEqualNormCase(str(p), BASE)
|
||||
p = (P / 'link3').resolve()
|
||||
self.assertEqual(p, P)
|
||||
self.assertEqual(str(p), BASE)
|
||||
self.assertEqualNormCase(str(p), BASE)
|
||||
|
||||
# Resolve relative paths.
|
||||
old_path = os.getcwd()
|
||||
|
@ -2154,16 +2157,16 @@ class _BasePathTest(object):
|
|||
try:
|
||||
p = self.cls('link0').resolve()
|
||||
self.assertEqual(p, P)
|
||||
self.assertEqual(str(p), BASE)
|
||||
self.assertEqualNormCase(str(p), BASE)
|
||||
p = self.cls('link1').resolve()
|
||||
self.assertEqual(p, P)
|
||||
self.assertEqual(str(p), BASE)
|
||||
self.assertEqualNormCase(str(p), BASE)
|
||||
p = self.cls('link2').resolve()
|
||||
self.assertEqual(p, P)
|
||||
self.assertEqual(str(p), BASE)
|
||||
self.assertEqualNormCase(str(p), BASE)
|
||||
p = self.cls('link3').resolve()
|
||||
self.assertEqual(p, P)
|
||||
self.assertEqual(str(p), BASE)
|
||||
self.assertEqualNormCase(str(p), BASE)
|
||||
finally:
|
||||
os.chdir(old_path)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue