import os import pytest from install_mpsd_software_environment import os_chdir, build_toolchains def test_os_chdir(): # create a temporary directory for testing temp_dir = "/tmp/test_os_chdir" os.mkdir(temp_dir) # initial current working directory initial_cwd = os.getcwd() # change to the temporary directory using os_chdir with os_chdir(temp_dir): assert os.getcwd() == os.path.abspath(temp_dir) # current working directory should be back to initial directory assert os.getcwd() == initial_cwd # clean up the temporary directory os.rmdir(temp_dir)