From b43b4295b415e781ddc203a2e883c8763c8956aa Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Wed, 16 Dec 2015 22:17:56 -0500 Subject: [PATCH] Fix tests if ~/.aws/shell/ doesn't exist. Fixes issues with test_keys.py and test_config.py. Creates the directory that will contain the awsshellrc config file if it doesn't yet exist. Once it exists, continues with copying the template config file to ~/.aws/shell/awsshellrc. --- awsshell/config.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/awsshell/config.py b/awsshell/config.py index a111196..5bdec5a 100644 --- a/awsshell/config.py +++ b/awsshell/config.py @@ -75,9 +75,17 @@ def _copy_template_to_config(self, template_path, :type overwrite: bool :param overwrite: (Optional) Determines whether to overwrite the existing config file, if it exists. + + :raises: :class:`OSError ` """ expanded_config_path = os.path.expanduser(config_path) if not overwrite and os.path.isfile(config_path): return else: + try: + config_path_dir_name = os.path.dirname(config_path) + os.makedirs(config_path_dir_name) + except OSError: + if not os.path.isdir(config_path_dir_name): + raise shutil.copyfile(template_path, config_path)