diff --git a/moulinette/interfaces/cli.py b/moulinette/interfaces/cli.py index b6846b0a..2b009065 100644 --- a/moulinette/interfaces/cli.py +++ b/moulinette/interfaces/cli.py @@ -288,7 +288,9 @@ class ActionsMapParser(BaseActionsMapParser): """ - def __init__(self, parent=None, parser=None, subparser_kwargs=None, top_parser=None): + def __init__( + self, parent=None, parser=None, subparser_kwargs=None, top_parser=None + ): super(ActionsMapParser, self).__init__(parent) @@ -334,7 +336,11 @@ class ActionsMapParser(BaseActionsMapParser): parser = self._subparsers.add_parser( name, description=category_help, help=category_help, **kwargs ) - return self.__class__(parent=self, parser=parser, subparser_kwargs={"title": "subcommands", "required": True}) + return self.__class__( + parent=self, + parser=parser, + subparser_kwargs={"title": "subcommands", "required": True}, + ) def add_subcategory_parser(self, name, subcategory_help=None, **kwargs): """Add a parser for a subcategory @@ -353,7 +359,11 @@ class ActionsMapParser(BaseActionsMapParser): help=subcategory_help, **kwargs, ) - return self.__class__(parent=self, parser=parser, subparser_kwargs={"title": "actions", "required": True}) + return self.__class__( + parent=self, + parser=parser, + subparser_kwargs={"title": "actions", "required": True}, + ) def add_action_parser( self, diff --git a/test/actionsmap/moulitest.yml b/test/actionsmap/moulitest.yml index 9802037d..4bb760b9 100644 --- a/test/actionsmap/moulitest.yml +++ b/test/actionsmap/moulitest.yml @@ -7,21 +7,6 @@ _global: authentication: api: dummy cli: dummy - arguments: - -v: - full: --version - help: Display Yoloswag versions - action: callback - callback: - method: test.src.testauth.yoloswag_version - return: true - -w: - full: --wersion - help: Not existing function - action: callback - callback: - method: test.src.testauth.not_existing_function - return: true ############################# # Test Actions # diff --git a/test/src/testauth.py b/test/src/testauth.py index ffd5583d..cbcb3c5b 100644 --- a/test/src/testauth.py +++ b/test/src/testauth.py @@ -44,7 +44,3 @@ def testauth_with_extra_str_only(only_a_str): def testauth_with_type_int(only_an_int): return only_an_int - - -def yoloswag_version(*args, **kwargs): - return "666" diff --git a/test/test_auth.py b/test/test_auth.py index b5537bb7..1f557329 100644 --- a/test/test_auth.py +++ b/test/test_auth.py @@ -255,25 +255,6 @@ class TestAuthCLI: assert "invalid_password" in str(exception) - def test_request_with_callback(self, moulinette_cli, capsys, mocker): - mocker.patch("os.isatty", return_value=True) - mocker.patch("prompt_toolkit.prompt", return_value="dummy") - moulinette_cli.run(["--version"], output_as="plain") - message = capsys.readouterr() - - assert "666" in message.out - - moulinette_cli.run(["-v"], output_as="plain") - message = capsys.readouterr() - - assert "666" in message.out - - with pytest.raises(MoulinetteError): - moulinette_cli.run(["--wersion"], output_as="plain") - message = capsys.readouterr() - - assert "cannot get value from callback method" in message.err - def test_request_with_arg(self, moulinette_cli, capsys, mocker): mocker.patch("os.isatty", return_value=True) mocker.patch("prompt_toolkit.prompt", return_value="dummy")