From: Aarni Koskela Date: Mon, 11 Apr 2016 10:44:39 +0000 (+0300) Subject: Refactor out `configure_cli_command` X-Git-Tag: v2.4.0~30^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fbc1648;p=thirdparty%2Fbabel.git Refactor out `configure_cli_command` --- 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(( '_',