def test_load_env_vile(self, mock_exists): file_data = "FAKE_ENV=fake_env\n" with mock.patch("rally.common.fileutils.open", mock.mock_open( read_data=file_data), create=True) as mock_file: fileutils.load_env_file("path_to_file") self.assertIn("FAKE_ENV", os.environ) mock_file.return_value.readlines.assert_called_once_with()
def get_global(global_key, do_raise=False): if global_key not in os.environ: fileutils.load_env_file(os.path.expanduser(PATH_GLOBALS)) value = os.environ.get(global_key) if not value and do_raise: raise exceptions.InvalidArgumentsException("%s env is missing" % global_key) return value