Fix #9333. The symlink function is always available now, raising OSError
when the user doesn't hold the symbolic link privilege rather than hiding it.
diff --git a/Lib/test/support.py b/Lib/test/support.py
index 27efd37..142a87e 100644
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -43,7 +43,7 @@
"run_unittest", "run_doctest", "threading_setup", "threading_cleanup",
"reap_children", "cpython_only", "check_impl_detail", "get_attribute",
"swap_item", "swap_attr", "requires_IEEE_754",
- "TestHandler", "Matcher"]
+ "TestHandler", "Matcher", "can_symlink", "skip_unless_symlink"]
class Error(Exception):
@@ -1412,3 +1412,23 @@
else:
result = dv.find(v) >= 0
return result
+
+
+_can_symlink = None
+def can_symlink():
+ global _can_symlink
+ if _can_symlink is not None:
+ return _can_symlink
+ try:
+ os.symlink(TESTFN, TESTFN + "can_symlink")
+ can = True
+ except OSError:
+ can = False
+ _can_symlink = can
+ return can
+
+def skip_unless_symlink(test):
+ """Skip decorator for tests that require functional symlink"""
+ ok = can_symlink()
+ msg = "Requires functional symlink implementation"
+ return test if ok else unittest.skip(msg)(test)