diff options
| author | Brian Curtin <brian.curtin@gmail.com> | 2010-12-28 14:31:47 +0000 |
|---|---|---|
| committer | Brian Curtin <brian.curtin@gmail.com> | 2010-12-28 14:31:47 +0000 |
| commit | 3b4499c5c7718a2aca8558b857dfe02cc4a80cd9 (patch) | |
| tree | e952e750f0913c99ca1d4b021736476baab55408 /Lib/test/support.py | |
| parent | baab9d0bf6d1627aa292a7639878ae9ba46fc2ca (diff) | |
| download | cpython-git-3b4499c5c7718a2aca8558b857dfe02cc4a80cd9.tar.gz | |
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.
Diffstat (limited to 'Lib/test/support.py')
| -rw-r--r-- | Lib/test/support.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py index 27efd37afc..142a87ea4e 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -43,7 +43,7 @@ __all__ = [ "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 @@ class Matcher(object): 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) |
