]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-40648: Test modes that file can get with chmod() on Windows (GH-20130)
authorPavol Babinčák‏ <scroolik@gmail.com>
Wed, 13 Dec 2023 20:23:13 +0000 (21:23 +0100)
committerGitHub <noreply@github.com>
Wed, 13 Dec 2023 20:23:13 +0000 (22:23 +0200)
Order of tests matter second part makes testing file writable and
possible to remove again.

Lib/test/test_stat.py
Misc/NEWS.d/next/Tests/2020-05-16-18-00-21.bpo-40648.p2uPqy.rst [new file with mode: 0644]

index 0eced2fcf98376e416c4f0966250846898702228..a0d0f61e5a192c1319604da414b94cccc856eb9b 100644 (file)
@@ -148,12 +148,19 @@ class TestFilemode:
             self.assertEqual(modestr, '-r--r--r--')
             self.assertEqual(self.statmod.S_IMODE(st_mode), 0o444)
         else:
+            os.chmod(TESTFN, 0o500)
+            st_mode, modestr = self.get_mode()
+            self.assertEqual(modestr[:3], '-r-')
+            self.assertS_IS("REG", st_mode)
+            self.assertEqual(self.statmod.S_IMODE(st_mode), 0o444)
+
             os.chmod(TESTFN, 0o700)
             st_mode, modestr = self.get_mode()
             self.assertEqual(modestr[:3], '-rw')
             self.assertS_IS("REG", st_mode)
             self.assertEqual(self.statmod.S_IFMT(st_mode),
                              self.statmod.S_IFREG)
+            self.assertEqual(self.statmod.S_IMODE(st_mode), 0o666)
 
     @os_helper.skip_unless_working_chmod
     def test_directory(self):
diff --git a/Misc/NEWS.d/next/Tests/2020-05-16-18-00-21.bpo-40648.p2uPqy.rst b/Misc/NEWS.d/next/Tests/2020-05-16-18-00-21.bpo-40648.p2uPqy.rst
new file mode 100644 (file)
index 0000000..8fbe42d
--- /dev/null
@@ -0,0 +1 @@
+Test modes that file can get with chmod() on Windows.