@@ -81,20 +81,25 @@ class CapturedIO:
8181
8282
8383@pytest .fixture
84- def run_cli (monkeypatch , capsys , cap_lisp_io ):
84+ def run_cli (monkeypatch ):
8585 def _run_cli (args : Sequence [str ], input : Optional [str ] = None ):
8686 if input is not None :
8787 monkeypatch .setattr (
8888 "sys.stdin" , io .TextIOWrapper (io .BytesIO (input .encode ("utf-8" )))
8989 )
90- invoke_cli ([* args ])
91- python_io = capsys .readouterr ()
92- lisp_out , lisp_err = cap_lisp_io
90+ process = subprocess .run (
91+ ["basilisp" , * args ],
92+ stdin = io .StringIO (input ) if input is not None else None ,
93+ encoding = "utf-8" ,
94+ capture_output = True ,
95+ check = True ,
96+ )
97+
9398 return CapturedIO (
94- out = python_io . out ,
95- err = python_io . err ,
96- lisp_out = lisp_out . getvalue () ,
97- lisp_err = lisp_err . getvalue () ,
99+ out = process . stdout ,
100+ err = process . stderr ,
101+ lisp_out = process . stdout ,
102+ lisp_err = process . stderr ,
98103 )
99104
100105 return _run_cli
@@ -204,7 +209,7 @@ def test_valid_flag(self, run_cli, val):
204209
205210 @pytest .mark .parametrize ("val" , ["maybe" , "not-no" , "4" ])
206211 def test_invalid_flag (self , run_cli , val ):
207- with pytest .raises (SystemExit ):
212+ with pytest .raises (subprocess . CalledProcessError ):
208213 run_cli (["run" , "--warn-on-var-indirection" , val , "-c" , "(+ 1 2)" ])
209214
210215
@@ -355,7 +360,7 @@ def test_repl_include_extra_path(
355360
356361class TestRun :
357362 def test_run_ns_and_code_mutually_exclusive (self , run_cli ):
358- with pytest .raises (SystemExit ):
363+ with pytest .raises (subprocess . CalledProcessError ):
359364 run_cli (["run" , "-c" , "-n" ])
360365
361366 class TestRunCode :
@@ -550,7 +555,7 @@ def test_cannot_run_namespace_with_in_ns_arg(
550555 self , run_cli , namespace_name : str , namespace_file : pathlib .Path
551556 ):
552557 namespace_file .write_text ("(println (+ 1 2))" )
553- with pytest .raises (SystemExit ):
558+ with pytest .raises (subprocess . CalledProcessError ):
554559 run_cli (["run" , "--in-ns" , "otherpackage.core" , "-n" , namespace_name ])
555560
556561 def test_run_namespace (
0 commit comments