Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions Lib/test/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,23 @@ def test_different_flavours_unordered(self):
#

# Make sure any symbolic links in the base test path are resolved
BASE = os.path.realpath(TESTFN)
def _realpath(existing_path, virtual_relpath = None):
"""Expand junctions as well in NT which os.path.realpath doesn't do."""
if os.name == 'nt':
p = os.path._getfinalpathname(existing_path)
assert p.startswith('\\\\?\\')
p = p[4:]
else:
p = os.path.realpath(existing_path)

if virtual_relpath is not None:
p = os.path.join(p, virtual_relpath)

return p

BASE = _realpath('.', TESTFN)


join = lambda *x: os.path.join(BASE, *x)
rel_join = lambda *x: os.path.join(TESTFN, *x)

Expand Down Expand Up @@ -1494,7 +1510,7 @@ def test_resolve_common(self):
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')))
_realpath('.',(os.path.join('foo', 'in', 'spam'))))
# These are all relative symlinks
p = P(BASE, 'dirB', 'fileB')
self._check_resolve_relative(p, p)
Expand All @@ -1519,7 +1535,7 @@ def test_resolve_common(self):
# resolves to 'dirB/..' first before resolving to parent of dirB.
self._check_resolve_relative(p, P(BASE, 'foo', 'in', 'spam'), False)
# Now create absolute symlinks
d = tempfile.mkdtemp(suffix='-dirD')
d = _realpath(tempfile.mkdtemp(suffix='-dirD'))
self.addCleanup(support.rmtree, d)
os.symlink(os.path.join(d), join('dirA', 'linkX'))
os.symlink(join('dirB'), os.path.join(d, 'linkY'))
Expand Down