gh-102519: Avoid failing tests due to inaccessible volumes (GH-102706)

This commit is contained in:
Steve Dower 2023-03-15 00:07:30 +00:00 committed by GitHub
parent 0a539b5db3
commit 5fce813d8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 6 deletions

View File

@ -2683,12 +2683,17 @@ class Win32ListdriveTests(unittest.TestCase):
def test_listmounts(self):
for volume in os.listvolumes():
mounts = os.listmounts(volume)
self.assertIsInstance(mounts, list)
self.assertSetEqual(
set(mounts),
self.known_mounts & set(mounts),
)
try:
mounts = os.listmounts(volume)
except OSError as ex:
if support.verbose:
print("Skipping", volume, "because of", ex)
else:
self.assertIsInstance(mounts, list)
self.assertSetEqual(
set(mounts),
self.known_mounts & set(mounts),
)
@unittest.skipUnless(hasattr(os, 'readlink'), 'needs os.readlink()')