Skip to content

Commit 9b747c1

Browse files
gh-156707: Remove the junction created in test_realpath_volume_guid_path()
The junction pointed to a volume without a mount point. It was left for the temporary directory cleanup, which descended into it and tried to remove files on that volume. os.rmdir() removes the junction itself, not the directory it points to.
1 parent d7f9c64 commit 9b747c1

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎Lib/test/test_ntpath.py‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,11 +1585,15 @@ def test_realpath_volume_guid_path(self):
15851585
except (OSError, subprocess.CalledProcessError):
15861586
raise unittest.SkipTest('creating the test junction failed')
15871587

1588-
for path in 'testjunc', 'testjunc/spam', 'testjunc/spam/eggs':
1589-
with self.subTest(path=path):
1590-
realpath = ntpath.realpath(path)
1591-
self.assertStartsWith(realpath, '\\\\?\\Volume{')
1592-
self.assertTrue(ntpath.isabs(realpath), realpath)
1588+
try:
1589+
for path in 'testjunc', 'testjunc/spam', 'testjunc/spam/eggs':
1590+
with self.subTest(path=path):
1591+
realpath = ntpath.realpath(path)
1592+
self.assertStartsWith(realpath, '\\\\?\\Volume{')
1593+
self.assertTrue(ntpath.isabs(realpath), realpath)
1594+
finally:
1595+
# Remove the junction, not the volume it points to.
1596+
os_helper.rmdir('testjunc')
15931597

15941598
def test_isfile_invalid_paths(self):
15951599
isfile = ntpath.isfile

0 commit comments

Comments
 (0)