Update test_posix.py from 3.14.3 and adjust android cfg (#7320)

* Update `test_posix.py` from 3.14.3

* patch

* Align availability

* Fix test_fchmod_file
This commit is contained in:
Shahar Naveh authored and GitHub committed 2026-03-03 09:09:47 +09:00
1 parent 0e2bd75df6
commit 2b099100bd
2 files changed
+16 -14

No files matched your search

+13 -1
View File
@@ -668,6 +668,19 @@ class PosixTester(unittest.TestCase):
finally:
fp.close()
@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.skipUnless(hasattr(posix, 'stat'),
'test needs posix.stat()')
@unittest.skipUnless(os.stat in os.supports_follow_symlinks,
'test needs follow_symlinks support in os.stat()')
def test_stat_fd_zero_follow_symlinks(self):
with self.assertRaisesRegex(ValueError,
'cannot use fd and follow_symlinks together'):
posix.stat(0, follow_symlinks=False)
with self.assertRaisesRegex(ValueError,
'cannot use fd and follow_symlinks together'):
posix.stat(1, follow_symlinks=False)
def test_stat(self):
self.assertTrue(posix.stat(os_helper.TESTFN))
self.assertTrue(posix.stat(os.fsencode(os_helper.TESTFN)))
@@ -1017,7 +1030,6 @@ class PosixTester(unittest.TestCase):
target = self.tempdir()
self.check_chmod(posix.chmod, target)
@unittest.skipIf(sys.platform in ("darwin", "linux"), "TODO: RUSTPYTHON; crash")
@os_helper.skip_unless_working_chmod
def test_fchmod_file(self):
with open(os_helper.TESTFN, 'wb+') as f:
+3 -13
View File
@@ -1035,7 +1035,7 @@ pub mod module {
fn _fchmod(fd: BorrowedFd<'_>, mode: u32, vm: &VirtualMachine) -> PyResult<()> {
nix::sys::stat::fchmod(
fd,
nix::sys::stat::Mode::from_bits(mode as libc::mode_t).unwrap(),
nix::sys::stat::Mode::from_bits_truncate(mode as libc::mode_t),
)
.map_err(|err| err.into_pyexception(vm))
}
@@ -1404,12 +1404,7 @@ pub mod module {
}
// cfg from nix
#[cfg(any(
target_os = "android",
target_os = "freebsd",
target_os = "linux",
target_os = "openbsd"
))]
#[cfg(any(target_os = "freebsd", target_os = "linux", target_os = "openbsd"))]
#[pyfunction]
fn setresgid(rgid: Gid, egid: Gid, sgid: Gid, vm: &VirtualMachine) -> PyResult<()> {
unistd::setresgid(rgid, egid, sgid).map_err(|err| err.into_pyexception(vm))
@@ -1423,12 +1418,7 @@ pub mod module {
}
// cfg from nix
#[cfg(any(
target_os = "android",
target_os = "freebsd",
target_os = "linux",
target_os = "openbsd"
))]
#[cfg(any(target_os = "freebsd", target_os = "linux", target_os = "openbsd"))]
#[pyfunction]
fn initgroups(user_name: PyUtf8StrRef, gid: Gid, vm: &VirtualMachine) -> PyResult<()> {
let user = user_name.to_cstring(vm)?;