Skip to content

Commit eb7594f

Browse files
authored
bpo-41443: Add more attribute checking in test_posix (GH-21688)
1 parent fe6e5e7 commit eb7594f

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Lib/test/test_posix.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,8 @@ def test_chmod_dir_fd(self):
10941094
finally:
10951095
posix.close(f)
10961096

1097-
@unittest.skipUnless(os.chown in os.supports_dir_fd, "test needs dir_fd support in os.chown()")
1097+
@unittest.skipUnless(hasattr(os, 'chown') and (os.chown in os.supports_dir_fd),
1098+
"test needs dir_fd support in os.chown()")
10981099
def test_chown_dir_fd(self):
10991100
os_helper.unlink(os_helper.TESTFN)
11001101
os_helper.create_empty_file(os_helper.TESTFN)
@@ -1189,7 +1190,9 @@ def test_mkdir_dir_fd(self):
11891190
posix.close(f)
11901191
os_helper.rmtree(os_helper.TESTFN + 'dir')
11911192

1192-
@unittest.skipUnless((os.mknod in os.supports_dir_fd) and hasattr(stat, 'S_IFIFO'),
1193+
@unittest.skipUnless(hasattr(os, 'mknod')
1194+
and (os.mknod in os.supports_dir_fd)
1195+
and hasattr(stat, 'S_IFIFO'),
11931196
"test requires both stat.S_IFIFO and dir_fd support for os.mknod()")
11941197
def test_mknod_dir_fd(self):
11951198
# Test using mknodat() to create a FIFO (the only use specified
@@ -1222,7 +1225,8 @@ def test_open_dir_fd(self):
12221225
posix.close(a)
12231226
posix.close(b)
12241227

1225-
@unittest.skipUnless(os.readlink in os.supports_dir_fd, "test needs dir_fd support in os.readlink()")
1228+
@unittest.skipUnless(hasattr(os, 'readlink') and (os.readlink in os.supports_dir_fd),
1229+
"test needs dir_fd support in os.readlink()")
12261230
def test_readlink_dir_fd(self):
12271231
os.symlink(os_helper.TESTFN, os_helper.TESTFN + 'link')
12281232
f = posix.open(posix.getcwd(), posix.O_RDONLY)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add more attribute checking in test_posix.py

0 commit comments

Comments
 (0)