Skip to content

Commit 5fce813

Browse files
authored
gh-102519: Avoid failing tests due to inaccessible volumes (GH-102706)
1 parent 0a539b5 commit 5fce813

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Lib/test/test_os.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,12 +2683,17 @@ def test_listvolumes(self):
26832683

26842684
def test_listmounts(self):
26852685
for volume in os.listvolumes():
2686-
mounts = os.listmounts(volume)
2687-
self.assertIsInstance(mounts, list)
2688-
self.assertSetEqual(
2689-
set(mounts),
2690-
self.known_mounts & set(mounts),
2691-
)
2686+
try:
2687+
mounts = os.listmounts(volume)
2688+
except OSError as ex:
2689+
if support.verbose:
2690+
print("Skipping", volume, "because of", ex)
2691+
else:
2692+
self.assertIsInstance(mounts, list)
2693+
self.assertSetEqual(
2694+
set(mounts),
2695+
self.known_mounts & set(mounts),
2696+
)
26922697

26932698

26942699
@unittest.skipUnless(hasattr(os, 'readlink'), 'needs os.readlink()')

0 commit comments

Comments
 (0)