@@ -76,20 +76,27 @@ def test_add_and_remove_parents_both_shown_and_force_parents_listing(self, runne
7676 # get_parents was never explicitly requested but is implied by add/remove:
7777 assert 'No parent found!' in result .output
7878
79- def test_add_parent_failure_aborts_the_rest_of_the_loop (self , runner , monkeypatch ):
80- # BUG-like current behavior (documented, not fixed): the try/except in
81- # student.py wraps the WHOLE for-loop, not each iteration. So a single
82- # failing add_parent() call aborts processing of any parents after it
83- # in the same --add-parents list.
79+ def test_add_parent_failure_does_not_abort_the_rest_of_the_loop (self , runner , monkeypatch ):
80+ # Each parent is now tried independently: a failing add_parent() call
81+ # is reported but does not stop the remaining parents in the same
82+ # --add-parents list from being processed.
8483 monkeypatch .setattr (student , 'LMNStudent' , FakeStudent )
8584
8685 result = runner .invoke (student .app , ['--add-parents' , 'good1,bad,good2' , 'johndoe' ])
8786
8887 assert result .exit_code == 0
8988 assert 'cannot add bad' in result .output
90- # "Parents ... added!" success message is never printed since the
91- # exception happened inside the try, before reaching typer.secho(...).
92- assert 'added!' not in result .output
89+ # Only the parents that actually succeeded are listed.
90+ assert 'Parents good1,good2 added!' in result .output
91+
92+ def test_remove_parent_failure_does_not_abort_the_rest_of_the_loop (self , runner , monkeypatch ):
93+ monkeypatch .setattr (student , 'LMNStudent' , FakeStudent )
94+
95+ result = runner .invoke (student .app , ['--remove-parents' , 'good1,bad,good2' , 'johndoe' ])
96+
97+ assert result .exit_code == 0
98+ assert 'cannot remove bad' in result .output
99+ assert 'Parents good1,good2 removed!' in result .output
93100
94101 def test_get_parents_shows_table (self , runner , monkeypatch ):
95102 class FakeStudentWithParents (FakeStudent ):
0 commit comments