Check if symlink does not privileges on Windows for test_cmdline_python_package_symlink

os.symlink might fail on Windows because users require a special policy
to create symlinks (argh).

This is not a problem on AppVeyor because it is logged in as an admin,
but would be surprising for Windows users running pytest's test
suite on their computer.
This commit is contained in:
Bruno Oliveira 2017-12-13 20:06:49 -02:00
parent 476d4df1b7
commit 586ecea6f2
1 changed files with 7 additions and 0 deletions

View File

@ -653,6 +653,13 @@ class TestInvocationVariants(object):
test --pyargs option with packages with path containing symlink can
have conftest.py in their package (#2985)
"""
# dummy check that we can actually create symlinks: on Windows `os.symlink` is available,
# but normal users require special admin privileges to create symlinks.
if sys.platform == 'win32':
try:
os.symlink(str(testdir.tmpdir.ensure('tmpfile')), str(testdir.tmpdir.join('tmpfile2')))
except OSError as e:
pytest.skip(six.text_type(e.args[0]))
monkeypatch.delenv('PYTHONDONTWRITEBYTECODE', raising=False)
search_path = ["lib", os.path.join("local", "lib")]