@@ -15,22 +15,26 @@ def instructions(tmp_path):
1515 return folder
1616
1717
18- def test_selection_order_and_invalid_answers (tmp_path , monkeypatch , capsys ):
18+ def test_selection_order (tmp_path , monkeypatch ):
1919 folder = instructions (tmp_path )
20- assert [p .name for p in instruction_files (tmp_path )] == ["a.yaml" , "b.yml" ]
21- answers = iter (["bad" , "0" , "3" , "2" ])
22- monkeypatch .setattr ("builtins.input" , lambda prompt : next (answers ))
20+
21+ def choose (title , labels ):
22+ assert labels == ["a.yaml" , "b.yml" ]
23+ return 1
24+
25+ monkeypatch .setattr ("abench.discovery.choose" , choose )
2326 assert select_experiment (tmp_path , True ) == folder / "b.yml"
24- assert "Enter a number" in capsys .readouterr ().out
2527
2628
27- def test_single_file_still_prompts_and_accepts_enter (tmp_path , monkeypatch ):
29+ def test_single_file_still_prompts (tmp_path , monkeypatch ):
2830 folder = instructions (tmp_path )
2931 (folder / "b.yml" ).unlink ()
3032 prompts = []
31- monkeypatch .setattr ("builtins.input" , lambda prompt : prompts .append (prompt ) or "" )
33+ monkeypatch .setattr (
34+ "abench.discovery.choose" , lambda title , labels : prompts .append (labels ) or 0
35+ )
3236 assert select_experiment (tmp_path , True ) == folder / "a.yaml"
33- assert len ( prompts ) == 1
37+ assert prompts == [[ "a.yaml" ]]
3438 assert select_experiment (tmp_path , False ) == folder / "a.yaml"
3539
3640
@@ -46,17 +50,6 @@ def test_noninteractive_multiple_and_missing(tmp_path):
4650 instruction_files (tmp_path )
4751
4852
49- def test_selection_eof (tmp_path , monkeypatch ):
50- instructions (tmp_path )
51-
52- def ended (prompt ):
53- raise EOFError ()
54-
55- monkeypatch .setattr ("builtins.input" , ended )
56- with pytest .raises (ValueError , match = "nothing started" ):
57- select_experiment (tmp_path , True )
58-
59-
6053def test_directory_help_does_not_prompt_or_parse_suites (tmp_path , monkeypatch , capsys ):
6154 instructions (tmp_path )
6255
@@ -85,7 +78,11 @@ def test_choice_then_inputs_and_file_relative_paths(tmp_path, monkeypatch):
8578 households: ${households}
8679""" )
8780 prompts = []
88- answers = iter (["2" , "42" ])
81+ answers = iter (["42" ])
82+ monkeypatch .setattr (
83+ "abench.discovery.choose" ,
84+ lambda title , labels : prompts .append ("Choose experiment" ) or 1 ,
85+ )
8986
9087 def respond (prompt ):
9188 prompts .append (prompt )
0 commit comments