1010WIDE_TERMINAL_ENV = {"COLUMNS" : "240" , "LINES" : "60" }
1111
1212
13- def _extract_project_names (output : str ) -> set [str ]:
14- """Extract project names from rich table output."""
15- names : set [str ] = set ()
16- separator = "│" if "│" in output else "|"
17-
18- for line in output .splitlines ():
19- if separator not in line :
20- continue
21-
22- columns = [column .strip () for column in line .split (separator )]
23- if len (columns ) < 3 :
24- continue
25-
26- name = columns [1 ]
27- if not name or name == "Name" :
28- continue
29-
30- names .add (name )
31-
32- return names
33-
34-
3513def test_project_list (app , app_config , test_project , config_manager ):
3614 """Test 'bm project list' command shows projects."""
3715 runner = CliRunner ()
@@ -160,19 +138,16 @@ def test_remove_main_project(app, app_config, config_manager):
160138 new_default_path = Path (new_default_dir )
161139
162140 # Ensure main exists
163- # Force local routing to keep this regression test independent from cloud auth/mode state.
164- result = runner .invoke (cli_app , ["project" , "list" , "--local" ], env = WIDE_TERMINAL_ENV )
165- assert result .exit_code == 0
166- listed_projects = _extract_project_names (result .stdout )
167- if "main" not in listed_projects :
141+ # Trigger: this test must work on Windows runners where output may contain "runneradmin".
142+ # Why: substring checks against command output can mistake path text for project names.
143+ # Outcome: use config state for setup decisions, then validate behavior via CLI invocation.
144+ if "main" not in config_manager .config .projects :
168145 result = runner .invoke (cli_app , ["project" , "add" , "main" , str (main_path ), "--local" ])
169146 print (result .stdout )
170147 assert result .exit_code == 0
171148
172149 # Confirm main is present
173- result = runner .invoke (cli_app , ["project" , "list" , "--local" ], env = WIDE_TERMINAL_ENV )
174- assert result .exit_code == 0
175- assert "main" in _extract_project_names (result .stdout )
150+ assert "main" in config_manager .config .projects
176151
177152 # Add a second project
178153 result = runner .invoke (
@@ -194,6 +169,6 @@ def test_remove_main_project(app, app_config, config_manager):
194169 # Confirm only new_default exists and main does not
195170 result = runner .invoke (cli_app , ["project" , "list" , "--local" ], env = WIDE_TERMINAL_ENV )
196171 assert result .exit_code == 0
197- listed_projects = _extract_project_names ( result . stdout )
198- assert "main" not in listed_projects
199- assert "new_default" in listed_projects
172+ config_after_list = config_manager . load_config ( )
173+ assert "main" not in config_after_list . projects
174+ assert "new_default" in config_after_list . projects
0 commit comments