8000 bpo-32266: make test_pathlib pass when working path has junctions by native-api · Pull Request #4778 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-32266: make test_pathlib pass when working path has junctions #4778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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
8000
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
0