]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-114435: Allow test_stat_inaccessible_file() to have matching ino/dev (GH-114571)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 23 Feb 2024 12:35:42 +0000 (13:35 +0100)
committerGitHub <noreply@github.com>
Fri, 23 Feb 2024 12:35:42 +0000 (12:35 +0000)
This may occur if Windows allows reading stat information from a file even if the current user does not have access.
(cherry picked from commit d91ddff5de61447844f1dac575d2e670c8d7e26b)

Co-authored-by: Steve Dower <steve.dower@python.org>
Lib/test/test_os.py

index 67281c7c3562fb2f898da57a2497b2eb6db0849e..ad6a607f2fafde8e5f2e4afa8e66e5568b9823ec 100644 (file)
@@ -3121,10 +3121,9 @@ class Win32NtTests(unittest.TestCase):
         if support.verbose:
             print(" without access:", stat2)
 
-        # We cannot get st_dev/st_ino, so ensure those are 0 or else our test
-        # is not set up correctly
-        self.assertEqual(0, stat2.st_dev)
-        self.assertEqual(0, stat2.st_ino)
+        # We may not get st_dev/st_ino, so ensure those are 0 or match
+        self.assertIn(stat2.st_dev, (0, stat1.st_dev))
+        self.assertIn(stat2.st_ino, (0, stat1.st_ino))
 
         # st_mode and st_size should match (for a normal file, at least)
         self.assertEqual(stat1.st_mode, stat2.st_mode)