File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,27 @@ def testdir(testdir: Testdir) -> Testdir:
165165 return testdir
166166
167167
168+ @pytest .fixture
169+ def symlink_or_skip ():
170+ """Return a function that creates a symlink or raises ``Skip``.
171+
172+ On Windows `os.symlink` is available, but normal users require special
173+ admin privileges to create symlinks.
174+ """
175+
176+ def wrap_os_symlink (src , dst , * args , ** kwargs ):
177+ if os .path .islink (dst ):
178+ return
179+
180+ try :
181+ os .symlink (src , dst , * args , ** kwargs )
182+ except OSError as e :
183+ pytest .skip ("os.symlink({!r}) failed: {!r}" .format ((src , dst ), e ))
184+ assert os .path .islink (dst )
185+
186+ return wrap_os_symlink
187+
188+
168189@pytest .fixture (scope = "session" )
169190def color_mapping ():
170191 """Returns a utility class which can replace keys in strings in the form "{NAME}"
You can’t perform that action at this time.
0 commit comments