]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Refactor out `configure_cli_command`
authorAarni Koskela <akx@iki.fi>
Mon, 11 Apr 2016 10:44:39 +0000 (13:44 +0300)
committerAarni Koskela <akx@iki.fi>
Tue, 12 Apr 2016 06:20:26 +0000 (09:20 +0300)
tests/messages/test_frontend.py

index 4c3c4a5a1ab4f7d36128665079210afe88e4296d..e0c9a8eb3b1048b98ff907bf9f13b15c72add5d1 100644 (file)
@@ -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((
         '_',