From: Pavol Babinčák‏ Date: Wed, 13 Dec 2023 20:23:13 +0000 (+0100) Subject: bpo-40648: Test modes that file can get with chmod() on Windows (GH-20130) X-Git-Tag: v3.13.0a3~395 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5c05e015c178975f24b77e5a8975a22d694e019;p=thirdparty%2FPython%2Fcpython.git bpo-40648: Test modes that file can get with chmod() on Windows (GH-20130) Order of tests matter second part makes testing file writable and possible to remove again. --- diff --git a/Lib/test/test_stat.py b/Lib/test/test_stat.py index 0eced2fcf983..a0d0f61e5a19 100644 --- a/Lib/test/test_stat.py +++ b/Lib/test/test_stat.py @@ -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 index 000000000000..8fbe42d263fe --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2020-05-16-18-00-21.bpo-40648.p2uPqy.rst @@ -0,0 +1 @@ +Test modes that file can get with chmod() on Windows.