#NEWLINE# def test_simulate_healthcheck_on_service_dead_container_exits_immediately( capsys ) : #NEWLINE# #INDENT# with mock . patch ( 'time.sleep' , side_effect = AssertionError ( 'sleep should not have been called' ) ) : #NEWLINE# #INDENT# mock_client = mock . MagicMock ( spec_set = docker . Client ) #NEWLINE# mock_client . inspect_container . return_value = { #NEWLINE# #INDENT# 'State' : { #NEWLINE# #INDENT# 'Running' : False , #NEWLINE# 'ExitCode' : 127 , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# fake_service_manifest = MarathonServiceConfig ( service = 'fake_name' , cluster = 'fake_cluster' , instance = 'fake_instance' , config_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , branch_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# ret = simulate_healthcheck_on_service ( out , mock_client , mock . sentinel . container_id , 'http' , 'http://fake_host/status' , True ) #NEWLINE# assert ( ret == ( False , 'Aborted by the user' ) ) #NEWLINE# ( out , _ ) = capsys . readouterr ( ) #NEWLINE# assert ( out . count ( 'Container exited with code 127' ) == 1 )