Set tempdir for Windows in tests/conftest.py

This commit is contained in:
twangboy 2021-05-21 15:48:16 -06:00 committed by Gareth J. Greenaway
parent 065f9c6486
commit c364ff55cb

View file

@ -117,6 +117,20 @@ log = logging.getLogger("salt.testsuite")
# ----- PyTest Tempdir Plugin Hooks --------------------------------------------------------------------------------->
def pytest_tempdir_temproot():
# Taken from https://github.com/saltstack/salt/blob/v2019.2.0/tests/support/paths.py
# Avoid ${TMPDIR} and gettempdir() on MacOS as they yield a base path too long
# for unix sockets: ``error: AF_UNIX path too long``
# Gentoo Portage prefers ebuild tests are rooted in ${TMPDIR}
if saltfactories.utils.platform.is_windows():
tempdir = "c:/temp"
elif saltfactories.utils.platform.is_darwin():
tempdir = "/tmp"
else:
tempdir = os.environ.get("TMPDIR") or tempfile.gettempdir()
return os.path.abspath(os.path.realpath(tempdir))
def pytest_tempdir_basename():
"""
Return the temporary directory basename for the salt test suite.