diff options
Diffstat (limited to 'Lib/test/support/os_helper.py')
-rw-r--r-- | Lib/test/support/os_helper.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/support/os_helper.py b/Lib/test/support/os_helper.py index 22787e3..ffa5fc5 100644 --- a/Lib/test/support/os_helper.py +++ b/Lib/test/support/os_helper.py @@ -198,6 +198,23 @@ def skip_unless_symlink(test): return test if ok else unittest.skip(msg)(test) +_can_hardlink = None + +def can_hardlink(): + global _can_hardlink + if _can_hardlink is None: + # Android blocks hard links using SELinux + # (https://stackoverflow.com/q/32365690). + _can_hardlink = hasattr(os, "link") and not support.is_android + return _can_hardlink + + +def skip_unless_hardlink(test): + ok = can_hardlink() + msg = "requires hardlink support" + return test if ok else unittest.skip(msg)(test) + + _can_xattr = None |