From 5fce813d8e547d6508daa386b67f230105c3a174 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 15 Mar 2023 00:07:30 +0000 Subject: gh-102519: Avoid failing tests due to inaccessible volumes (GH-102706) --- Lib/test/test_os.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 253e2a2..42357fe 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -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()') -- cgit v0.12