keyval: skip symlink test if on Windows with insufficient permissions

Creating symlinks on Windows is, by default, a privileged operation.
From the `os.symlink()` documentation:

> On newer versions of Windows 10, unprivileged accounts can create
> symlinks if Developer Mode is enabled. When Developer Mode is not
> available/enabled, the SeCreateSymbolicLinkPrivilege privilege is
> required, or the process must be run as an administrator.

While it is important to test that our keyval storage is consistent even
with pathological symlinks, we shouldn't break the test suite if we're
unable to run this test because the user/developer hasn't enabled
developer mode.

Fixes: #460
This commit is contained in:
Jonas Malaco 2022-05-30 11:44:33 -03:00
parent 9140b9f906
commit 25b64aa763
1 changed files with 7 additions and 1 deletions

View File

@ -113,7 +113,13 @@ def test_fs_backend_load_store_loads_from_fallback_dir_that_is_symlink(tmpdir):
run_dir = tmpdir.mkdir('run_dir')
fb_dir = os.path.join(run_dir, 'symlink')
os.symlink(run_dir, fb_dir, target_is_directory=True)
try:
os.symlink(run_dir, fb_dir, target_is_directory=True)
except OSError as _:
if sys.platform == 'win32':
pytest.skip('unable to create Windows symlink with current permissions')
else:
raise
# don't store any initial value so that the fallback location is checked