From f985507761b42405182bc00778d5b1ea7e8ab5d6 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 13 Jun 2021 19:09:24 +0200 Subject: [PATCH] Fix f-strings and linter --- moulinette/authentication.py | 6 +++--- test/src/authenticators/yoloswag.py | 1 + test/test_actionsmap.py | 17 ----------------- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/moulinette/authentication.py b/moulinette/authentication.py index 2f54de14..3c93340b 100644 --- a/moulinette/authentication.py +++ b/moulinette/authentication.py @@ -79,7 +79,7 @@ class BaseAuthenticator(object): except MoulinetteError: raise except Exception as e: - logger.exception("authentication {self.name} failed because '{e}'") + logger.exception(f"authentication {self.name} failed because '{e}'") raise MoulinetteAuthenticationError("unable_authenticate") else: is_authenticated = True @@ -93,7 +93,7 @@ class BaseAuthenticator(object): import traceback traceback.print_exc() - logger.exception("unable to store session because %s", e) + logger.exception(f"unable to store session because {e}") else: logger.debug("session has been stored") @@ -108,7 +108,7 @@ class BaseAuthenticator(object): except MoulinetteError: raise except Exception as e: - logger.exception("authentication {self.name} failed because '{e}'") + logger.exception(f"authentication {self.name} failed because '{e}'") raise MoulinetteAuthenticationError("unable_authenticate") else: is_authenticated = True diff --git a/test/src/authenticators/yoloswag.py b/test/src/authenticators/yoloswag.py index 3fe0ea98..335fe9bc 100644 --- a/test/src/authenticators/yoloswag.py +++ b/test/src/authenticators/yoloswag.py @@ -8,6 +8,7 @@ logger = logging.getLogger("moulinette.authenticator.yoloswag") # Dummy authenticator implementation + class Authenticator(BaseAuthenticator): """Dummy authenticator used for tests""" diff --git a/test/test_actionsmap.py b/test/test_actionsmap.py index f7040c0a..6768f066 100644 --- a/test/test_actionsmap.py +++ b/test/test_actionsmap.py @@ -156,27 +156,10 @@ def test_required_paremeter_missing_value(iface, caplog): def test_actions_map_unknown_authenticator(monkeypatch, tmp_path): - # from moulinette.interfaces.cli import ActionsMapParser - # import argparse - # - # parser = argparse.ArgumentParser(add_help=False) - # parser.add_argument( - # "--debug", - # action="store_true", - # default=False, - # help="Log and print debug messages", - # ) - # - #monkeypatch.setenv("MOULINETTE_DATA_DIR", str(tmp_path)) - #actionsmap_dir = tmp_path / "actionsmap" - #actionsmap_dir.mkdir() from moulinette.interfaces.api import ActionsMapParser amap = ActionsMap(ActionsMapParser()) - #from moulinette.interfaces import BaseActionsMapParser - #amap = ActionsMap(BaseActionsMapParser()) - with pytest.raises(MoulinetteError) as exception: amap.get_authenticator("unknown") assert "No module named" in str(exception)