From fbc1648756e025558e1e9a7987e92f13af097f80 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Mon, 11 Apr 2016 13:44:39 +0300 Subject: [PATCH] Refactor out `configure_cli_command` --- tests/messages/test_frontend.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/messages/test_frontend.py b/tests/messages/test_frontend.py index 4c3c4a5a..e0c9a8eb 100644 --- a/tests/messages/test_frontend.py +++ b/tests/messages/test_frontend.py @@ -1232,6 +1232,19 @@ def test_parse_keywords(): } +def configure_cli_command(cmdline): + """ + Helper to configure a command class, but not run it just yet. + + :param cmdline: The command line (sans the executable name) + :return: Command instance + """ + args = shlex.split(cmdline) + cli = CommandLineInterface() + cmdinst = cli._configure_command(cmdname=args[0], argv=args[1:]) + return cmdinst + + @pytest.mark.parametrize("split", (False, True)) def test_extract_keyword_args_384(split): # This is a regression test for https://github.com/python-babel/babel/issues/384 @@ -1254,11 +1267,9 @@ def test_extract_keyword_args_384(split): # (Both of those invocation styles should be equivalent, so there is no parametrization from here on out) - cmdline = "extract -F babel-django.cfg --add-comments Translators: -o django232.pot %s ." % kwarg_text - - args = shlex.split(cmdline) - cli = CommandLineInterface() - cmdinst = cli._configure_command(cmdname=args[0], argv=args[1:]) + cmdinst = configure_cli_command( + "extract -F babel-django.cfg --add-comments Translators: -o django232.pot %s ." % kwarg_text + ) assert isinstance(cmdinst, extract_messages) assert set(cmdinst.keywords.keys()) == set(( '_', -- 2.47.2