@@ -411,11 +411,14 @@ def test_process_input_formula_copy_failure(mock_exists, tmp_path, operating_sys
411411
412412@patch ('actions.release_homebrew.main._run_subprocess' )
413413def test_brew_upgrade_update_failure (mock_run ):
414- # Set up the mock to fail on brew update but not continue to brew upgrade
414+ # Set up the mock to fail on brew update
415415 def side_effect (args_list , * args , ** kwargs ):
416- if 'update' in args_list :
416+ # Check if 'update' is in the args_list (which is a list)
417+ if args_list and 'update' in args_list :
418+ main .ERROR = True
417419 return False
418- return True # Return True for any other commands
420+ # Should not reach here for upgrade since update failed
421+ return True
419422
420423 mock_run .side_effect = side_effect
421424
@@ -425,10 +428,10 @@ def side_effect(args_list, *args, **kwargs):
425428 # Assert that brew_upgrade returns False when update fails
426429 assert not result
427430
428- # Verify that brew update was called
429- update_call_made = any ('update' in str (call ) for call in mock_run .call_args_list )
430- assert update_call_made
431+ # Verify that only one call was made (the update call)
432+ assert mock_run .call_count == 1
431433
432- # Verify that brew upgrade was NOT called (execution should stop after update fails)
433- upgrade_call_made = any ('upgrade' in str (call ) for call in mock_run .call_args_list )
434- assert not upgrade_call_made
434+ # Verify that the call was for brew update
435+ call_args = mock_run .call_args_list [0 ][1 ]['args_list' ]
436+ assert 'update' in call_args
437+ assert 'upgrade' not in call_args
0 commit comments