conftest.py
This file
Path
tests/conftest.py
31 lines · 794 bytes · Python
Last changed by
Merge remote-tracking branch 'origin/8.0.x'David Lordbefore adoptionc3687bf
History of this fileTake it
1import os2import shutil3import tempfile45import pytest67from click.testing import CliRunner8910@pytest.fixture(scope="function")11def runner(request):12 return CliRunner()131415def check_symlink_impl():16 """This function checks if using symlinks is allowed17 on the host machine"""18 tempdir = tempfile.mkdtemp(prefix="click-")19 test_pth = os.path.join(tempdir, "check_sym_impl")20 sym_pth = os.path.join(tempdir, "link")21 open(test_pth, "w").close()22 rv = True23 try:24 os.symlink(test_pth, sym_pth)25 except (NotImplementedError, OSError):26 # Creating symlinks on Windows require elevated access.27 # OSError is thrown if the function is called without it.28 rv = False29 finally:30 shutil.rmtree(tempdir, ignore_errors=True)31 return rv