@@ -81,25 +81,21 @@ class CapturedIO:
8181
8282
8383@pytest .fixture
84- def run_cli (monkeypatch ):
84+ def run_cli (monkeypatch , capsys , cap_lisp_io ):
8585 def _run_cli (args : Sequence [str ], input : Optional [str ] = None ):
86+ monkeypatch .setattr ("basilisp.main._runtime_is_initialized" , False )
8687 if input is not None :
8788 monkeypatch .setattr (
8889 "sys.stdin" , io .TextIOWrapper (io .BytesIO (input .encode ("utf-8" )))
8990 )
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-
91+ invoke_cli ([* args ])
92+ python_io = capsys .readouterr ()
93+ lisp_out , lisp_err = cap_lisp_io
9894 return CapturedIO (
99- out = process . stdout ,
100- err = process . stderr ,
101- lisp_out = process . stdout ,
102- lisp_err = process . stderr ,
95+ out = python_io . out ,
96+ err = python_io . err ,
97+ lisp_out = lisp_out . getvalue () ,
98+ lisp_err = lisp_err . getvalue () ,
10399 )
104100
105101 return _run_cli
@@ -209,7 +205,7 @@ def test_valid_flag(self, run_cli, val):
209205
210206 @pytest .mark .parametrize ("val" , ["maybe" , "not-no" , "4" ])
211207 def test_invalid_flag (self , run_cli , val ):
212- with pytest .raises (subprocess . CalledProcessError ):
208+ with pytest .raises (SystemExit ):
213209 run_cli (["run" , "--warn-on-var-indirection" , val , "-c" , "(+ 1 2)" ])
214210
215211
@@ -360,7 +356,7 @@ def test_repl_include_extra_path(
360356
361357class TestRun :
362358 def test_run_ns_and_code_mutually_exclusive (self , run_cli ):
363- with pytest .raises (subprocess . CalledProcessError ):
359+ with pytest .raises (SystemExit ):
364360 run_cli (["run" , "-c" , "-n" ])
365361
366362 class TestRunCode :
@@ -555,7 +551,7 @@ def test_cannot_run_namespace_with_in_ns_arg(
555551 self , run_cli , namespace_name : str , namespace_file : pathlib .Path
556552 ):
557553 namespace_file .write_text ("(println (+ 1 2))" )
558- with pytest .raises (subprocess . CalledProcessError ):
554+ with pytest .raises (SystemExit ):
559555 run_cli (["run" , "--in-ns" , "otherpackage.core" , "-n" , namespace_name ])
560556
561557 def test_run_namespace (
0 commit comments