Skip to content

Commit ad3e684

Browse files
committed
Add missing test helper.
1 parent 0d32864 commit ad3e684

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎Lib/test/support/os_helper.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,24 @@ def skip_unless_symlink(test):
198198
return test if ok else unittest.skip(msg)(test)
199199

200200

201+
_can_hardlink = None
202+
203+
204+
def can_hardlink():
205+
global _can_hardlink
206+
if _can_hardlink is None:
207+
# Android blocks hard links using SELinux
208+
# (https://stackoverflow.com/q/32365690).
209+
_can_hardlink = hasattr(os, "link") and not support.is_android
210+
return _can_hardlink
211+
212+
213+
def skip_unless_hardlink(test):
214+
ok = can_hardlink()
215+
msg = "requires hardlink support"
216+
return test if ok else unittest.skip(msg)(test)
217+
218+
201219
_can_xattr = None
202220

203221

0 commit comments

Comments
 (0)