Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/awscli_login/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,11 @@ def wrapper(args: Namespace, session: Session):
sig = None
fargs = (extra_args_handler(args), ) if extra_args_handler else ()

if hasattr(args, "verbose"):
configConsoleLogger(args.verbose)

try:
if not skip_args:
# verbosity can only be set at command line
configConsoleLogger(args.verbose)
del args.verbose

filename, load = config_vcr(args)
Expand Down
31 changes: 31 additions & 0 deletions src/tests/test_error_handler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import unittest

from argparse import Namespace
from unittest.mock import patch

from awscli_login.config import error_handler

from .login import MockBotocoreClient

BOTO_ERR = "ERROR:awscli_login.config:'MockBotocoreClient' " \
"object has no attribute 'profile'"


class ErrorHandler(unittest.TestCase):

@patch("awscli_login.config.Profile")
def _test_error_handler(self, args, mesg, patch):
@error_handler()
def func(profile, session):
raise Exception(mesg)

func(args, MockBotocoreClient())

def test_error_handler_logging_level_warn(self):
mesg = "First and only exception."
with self.assertLogs() as cm:
self._test_error_handler(Namespace(), mesg)

self.assertEqual(cm.output, [
f"ERROR:awscli_login.config:{mesg}",
])