def test_get_save_file_path_unix(self): with guard_temp_dir() as temp_dir, \ guard_patch_module('os.path.expanduser', lambda p: temp_dir), \ guard_patch_module('sys.stderr', TestSaveFilePath.StreamMock()), \ guard_patch_module('sys.platform', 'darwin'): with guard_patch_module('os.environ', {}), \ guard_temp_subdir(temp_dir, '.cache'): self.assertEqual(os.path.join(temp_dir, '.cache', 'gtest-parallel'), gtest_parallel.get_save_file_path()) with guard_patch_module('os.environ', {'XDG_CACHE_HOME': temp_dir}): self.assertEqual(os.path.join(temp_dir, 'gtest-parallel'), gtest_parallel.get_save_file_path()) with guard_patch_module('os.environ', {'XDG_CACHE_HOME': os.path.realpath(__file__)}): self.assertEqual(os.path.join(temp_dir, '.gtest-parallel-times'), gtest_parallel.get_save_file_path())
def test_get_save_file_path_win32(self): with guard_temp_dir() as temp_dir, \ guard_patch_module('os.path.expanduser', lambda p: temp_dir), \ guard_patch_module('sys.stderr', TestSaveFilePath.StreamMock()), \ guard_patch_module('sys.platform', 'win32'): with guard_patch_module('os.environ', {}), \ guard_temp_subdir(temp_dir, 'AppData', 'Local'): self.assertEqual(os.path.join(temp_dir, 'AppData', 'Local', 'gtest-parallel'), gtest_parallel.get_save_file_path()) with guard_patch_module('os.environ', {'LOCALAPPDATA': temp_dir}): self.assertEqual(os.path.join(temp_dir, 'gtest-parallel'), gtest_parallel.get_save_file_path()) with guard_patch_module('os.environ', {'LOCALAPPDATA': os.path.realpath(__file__)}): self.assertEqual(os.path.join(temp_dir, '.gtest-parallel-times'), gtest_parallel.get_save_file_path())