11from textwrap import dedent
22import os
3+ import shlex
34import subprocess
45
56import pytest
1314JULIA = os .environ .get ("JULIA_EXE" )
1415
1516
16- @pytest .mark .parametrize ("cli_args " , [
17- [ "-h" ] ,
18- [ "-i" , " --help"] ,
19- [ "--julia" , " false" , " -h"] ,
20- [ "--julia" , " false" , "-i" , " --help"] ,
17+ @pytest .mark .parametrize ("args " , [
18+ "-h" ,
19+ "-i --help" ,
20+ "--julia false -h" ,
21+ "--julia false -i --help" ,
2122])
22- def test_help_option (cli_args , capsys ):
23+ def test_help_option (args , capsys ):
2324 with pytest .raises (SystemExit ) as exc_info :
24- parse_pyjl_args (cli_args )
25+ parse_pyjl_args (shlex . split ( args ) )
2526 assert exc_info .value .code == 0
2627
2728 captured = capsys .readouterr ()
2829 assert "usage:" in captured .out
2930
3031
3132quick_pass_cli_args = [
32- [ "-h" ] ,
33- [ "-i" , " --help"] ,
34- [ "-V" ] ,
35- [ "--version" , "-c" , " 1/0"] ,
33+ "-h" ,
34+ "-i --help" ,
35+ "-V" ,
36+ "--version -c 1/0" ,
3637]
3738
3839
39- @pytest .mark .parametrize ("cli_args " , quick_pass_cli_args )
40- def test_cli_quick_pass (cli_args ):
40+ @pytest .mark .parametrize ("args " , quick_pass_cli_args )
41+ def test_cli_quick_pass (args ):
4142 subprocess .check_output (
42- ["python-jl" ] + cli_args ,
43+ ["python-jl" ] + shlex . split ( args ) ,
4344 )
4445
4546
4647@pytest .mark .skipif (
4748 not which ("false" ),
4849 reason = "false command not found" )
49- @pytest .mark .parametrize ("cli_args " , quick_pass_cli_args )
50- def test_cli_quick_pass_no_julia (cli_args ):
50+ @pytest .mark .parametrize ("args " , quick_pass_cli_args )
51+ def test_cli_quick_pass_no_julia (args ):
5152 subprocess .check_output (
52- ["python-jl" , "--julia" , "false" ] + cli_args ,
53+ ["python-jl" , "--julia" , "false" ] + shlex . split ( args ) ,
5354 )
5455
5556
@@ -60,17 +61,17 @@ def test_cli_quick_pass_no_julia(cli_args):
6061 not PYJULIA_TEST_REBUILD ,
6162 reason = "PYJULIA_TEST_REBUILD=yes is not set" )
6263def test_cli_import ():
63- cli_args = ["-c" , dedent ("""
64+ args = ["-c" , dedent ("""
6465 from julia import Base
6566 Base.banner()
6667 from julia import Main
6768 Main.x = 1
6869 assert Main.x == 1
6970 """ )]
7071 if JULIA :
71- cli_args = ["--julia" , JULIA ] + cli_args
72+ args = ["--julia" , JULIA ] + args
7273 output = subprocess .check_output (
73- ["python-jl" ] + cli_args ,
74+ ["python-jl" ] + args ,
7475 universal_newlines = True )
7576 assert "julialang.org" in output
7677
0 commit comments