diff options
author | pxinwr <peixing.xin@windriver.com> | 2020-12-09 07:18:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-09 00:18:37 +0100 |
commit | eb7594f85741ef809b1ee337ee3431df20e6f8bb (patch) | |
tree | f1af9e51e8fc745dde09943b4df2c710bec9253d /Lib/test | |
parent | fe6e5e7cfd68eeaa69fd1511f354a1b4d8d90990 (diff) | |
download | cpython-git-eb7594f85741ef809b1ee337ee3431df20e6f8bb.tar.gz |
bpo-41443: Add more attribute checking in test_posix (GH-21688)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_posix.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index d4d348cdc0..185b293b07 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -1094,7 +1094,8 @@ class PosixTester(unittest.TestCase): finally: posix.close(f) - @unittest.skipUnless(os.chown in os.supports_dir_fd, "test needs dir_fd support in os.chown()") + @unittest.skipUnless(hasattr(os, 'chown') and (os.chown in os.supports_dir_fd), + "test needs dir_fd support in os.chown()") def test_chown_dir_fd(self): os_helper.unlink(os_helper.TESTFN) os_helper.create_empty_file(os_helper.TESTFN) @@ -1189,7 +1190,9 @@ class PosixTester(unittest.TestCase): posix.close(f) os_helper.rmtree(os_helper.TESTFN + 'dir') - @unittest.skipUnless((os.mknod in os.supports_dir_fd) and hasattr(stat, 'S_IFIFO'), + @unittest.skipUnless(hasattr(os, 'mknod') + and (os.mknod in os.supports_dir_fd) + and hasattr(stat, 'S_IFIFO'), "test requires both stat.S_IFIFO and dir_fd support for os.mknod()") def test_mknod_dir_fd(self): # Test using mknodat() to create a FIFO (the only use specified @@ -1222,7 +1225,8 @@ class PosixTester(unittest.TestCase): posix.close(a) posix.close(b) - @unittest.skipUnless(os.readlink in os.supports_dir_fd, "test needs dir_fd support in os.readlink()") + @unittest.skipUnless(hasattr(os, 'readlink') and (os.readlink in os.supports_dir_fd), + "test needs dir_fd support in os.readlink()") def test_readlink_dir_fd(self): os.symlink(os_helper.TESTFN, os_helper.TESTFN + 'link') f = posix.open(posix.getcwd(), posix.O_RDONLY) |