@@ -166,30 +166,21 @@ def test_run_operation_edit_is_global_no_project_select(monkeypatch, tmp_path):
166166 assert captured ["cwd" ] == before , "edit は chdir しない"
167167
168168
169- @pytest .mark .parametrize ("reset" , [True , False ])
170- def test_run_operation_init_collects_reset (monkeypatch , tmp_path , reset ):
171- """init は confirm の結果を --reset として渡す (plan 2.3: reset 既定 False)。"""
169+ def test_run_operation_init_runs_without_confirm (monkeypatch , tmp_path ):
170+ """init は確認プロンプトなしで reset=False (CLI 既定) のまま即実行する。
171+
172+ セットアップ済みの環境では cmd_env_init が案内を出して安全に終了する。
173+ やり直しは CLI (`env init --reset`) を使う想定。
174+ """
172175 captured = _capture_dispatch (monkeypatch )
173- monkeypatch .setattr (menu , "confirm" , lambda * a , ** k : reset )
176+ monkeypatch .setattr (menu , "confirm" ,
177+ lambda * a , ** k : pytest .fail ("init で確認を求めない" ))
174178 assert actions_env ._run_operation (tmp_path , "init" ) == 0
175- assert captured ["attrs" ] == {"subcommand" : "init" , "reset" : reset }
176-
177-
178- @pytest .mark .parametrize ("confirm_ret" , ["BACK" , None ])
179- def test_run_operation_init_cancel (monkeypatch , tmp_path , confirm_ret ):
180- """init の confirm で Esc は再表示 (_ARG_CANCEL)、Ctrl-C は全体中止 (None)。"""
181- from devbase .commands import env as env_mod
182- called = []
183- monkeypatch .setattr (env_mod , "cmd_env" , lambda root , args : called .append (1 ) or 0 )
184- ret = menu .MENU_BACK if confirm_ret == "BACK" else None
185- monkeypatch .setattr (menu , "confirm" , lambda * a , ** k : ret )
186- expected = actions_env ._ARG_CANCEL if confirm_ret == "BACK" else None
187- assert actions_env ._run_operation (tmp_path , "init" ) is expected
188- assert called == []
179+ assert captured ["attrs" ] == {"subcommand" : "init" , "reset" : False }
189180
190181
191182# ---------------------------------------------------------------------------
192- # _run_operation: list (表示範囲 + reveal/keys)
183+ # _run_operation: list (表示範囲のみ収集。 reveal/keys は CLI 既定の False )
193184# ---------------------------------------------------------------------------
194185
195186def test_run_operation_list_global_scope_no_chdir (monkeypatch , tmp_path ):
@@ -198,15 +189,15 @@ def test_run_operation_list_global_scope_no_chdir(monkeypatch, tmp_path):
198189 monkeypatch .setattr (menu , "select" , lambda * a , ** k : "global" )
199190 monkeypatch .setattr (actions_env , "_select_project" ,
200191 lambda root : pytest .fail ("global でプロジェクト選択してはいけない" ))
201- confirms = iter ([ True , False ]) # reveal=True, keys_only=False
202- monkeypatch . setattr ( menu , "confirm" , lambda * a , ** k : next ( confirms ))
192+ monkeypatch . setattr ( menu , "confirm" ,
193+ lambda * a , ** k : pytest . fail ( "list で確認を求めない" ))
203194
204195 before = os .getcwd ()
205196 assert actions_env ._run_operation (tmp_path , "list" ) == 0
206197 assert captured ["attrs" ] == {
207198 "subcommand" : "list" ,
208199 "global_only" : True , "project_only" : False ,
209- "reveal" : True , "keys_only" : False ,
200+ "reveal" : False , "keys_only" : False ,
210201 }
211202 assert captured ["cwd" ] == before , "global スコープは chdir しない"
212203
@@ -223,16 +214,14 @@ def test_run_operation_list_both_scope_chdirs_and_restores(monkeypatch, tmp_path
223214 target .mkdir (parents = True )
224215 monkeypatch .setattr (menu , "select" , lambda * a , ** k : "both" )
225216 monkeypatch .setattr (actions_env , "_select_project" , lambda root : "carmo" )
226- confirms = iter ([True , False ]) # reveal=True, keys_only=False
227- monkeypatch .setattr (menu , "confirm" , lambda * a , ** k : next (confirms ))
228217 monkeypatch .setenv ("PWD" , str (tmp_path ))
229218
230219 before = os .getcwd ()
231220 assert actions_env ._run_operation (tmp_path , "list" ) == 0
232221 assert captured ["attrs" ] == {
233222 "subcommand" : "list" ,
234223 "global_only" : False , "project_only" : False ,
235- "reveal" : True , "keys_only" : False ,
224+ "reveal" : False , "keys_only" : False ,
236225 }
237226 # ハンドラ実行中は projects/carmo に居る (グローバル + プロジェクト両方が出る)
238227 assert captured ["cwd" ] == str (target )
@@ -253,16 +242,14 @@ def test_run_operation_list_project_chdirs_and_restores(monkeypatch, tmp_path):
253242 target .mkdir (parents = True )
254243 monkeypatch .setattr (menu , "select" , lambda * a , ** k : "project" )
255244 monkeypatch .setattr (actions_env , "_select_project" , lambda root : "carmo" )
256- confirms = iter ([False , True ]) # reveal=False, keys_only=True
257- monkeypatch .setattr (menu , "confirm" , lambda * a , ** k : next (confirms ))
258245 monkeypatch .setenv ("PWD" , str (tmp_path ))
259246
260247 before = os .getcwd ()
261248 assert actions_env ._run_operation (tmp_path , "list" ) == 0
262249 assert captured ["attrs" ] == {
263250 "subcommand" : "list" ,
264251 "global_only" : False , "project_only" : True ,
265- "reveal" : False , "keys_only" : True ,
252+ "reveal" : False , "keys_only" : False ,
266253 }
267254 # ハンドラ実行中は projects/carmo に居る (CWD と PWD の両方を切り替える)
268255 assert captured ["cwd" ] == str (target )
@@ -273,15 +260,13 @@ def test_run_operation_list_project_chdirs_and_restores(monkeypatch, tmp_path):
273260
274261
275262def test_run_operation_list_project_select_cancel (monkeypatch , tmp_path ):
276- """list のプロジェクト選択を中止したら表示オプション収集にも進まない 。"""
263+ """list のプロジェクト選択を中止したら実行しない 。"""
277264 from devbase .commands import env as env_mod
278265 called = []
279266 monkeypatch .setattr (env_mod , "cmd_env" , lambda root , args : called .append (1 ) or 0 )
280267 monkeypatch .setattr (menu , "select" , lambda * a , ** k : "project" )
281268 monkeypatch .setattr (actions_env , "_select_project" ,
282269 lambda root : actions_env ._ARG_CANCEL )
283- monkeypatch .setattr (menu , "confirm" ,
284- lambda * a , ** k : pytest .fail ("選択中止後に確認を求めない" ))
285270 assert actions_env ._run_operation (tmp_path , "list" ) is actions_env ._ARG_CANCEL
286271 assert called == []
287272
@@ -299,20 +284,6 @@ def test_run_operation_list_scope_cancel(monkeypatch, tmp_path, scope_ret):
299284 assert called == []
300285
301286
302- @pytest .mark .parametrize ("confirm_ret" , ["BACK" , None ])
303- def test_run_operation_list_confirm_cancel (monkeypatch , tmp_path , confirm_ret ):
304- """reveal の confirm で Esc は再表示 (_ARG_CANCEL)、Ctrl-C は全体中止 (None)。"""
305- from devbase .commands import env as env_mod
306- called = []
307- monkeypatch .setattr (env_mod , "cmd_env" , lambda root , args : called .append (1 ) or 0 )
308- monkeypatch .setattr (menu , "select" , lambda * a , ** k : "global" )
309- ret = menu .MENU_BACK if confirm_ret == "BACK" else None
310- monkeypatch .setattr (menu , "confirm" , lambda * a , ** k : ret )
311- expected = actions_env ._ARG_CANCEL if confirm_ret == "BACK" else None
312- assert actions_env ._run_operation (tmp_path , "list" ) is expected
313- assert called == []
314-
315-
316287# ---------------------------------------------------------------------------
317288# _run_operation: get / delete
318289# ---------------------------------------------------------------------------
0 commit comments