#NEWLINE# def test_iter_instances( self ) : #NEWLINE# #INDENT# with mock . patch ( 'psutil.process_iter' , ** PATCH_OPTS ) as mock_process_iter : #NEWLINE# #INDENT# mock_process_iter . return_value = [ fake_process ( name = 'a_test' , pid = 3 , status = psutil . STATUS_IDLE ) , fake_process ( name = 'b_test' , pid = 4 , status = psutil . STATUS_IDLE ) ] #NEWLINE# items = [ self for item in self . pg . iter_instances ( ) ] #NEWLINE# self . assertEqual ( len ( items ) , 2 ) #NEWLINE# for item in items : #NEWLINE# #INDENT# self . assertIsInstance ( item , ProcessManager ) #NEWLINE# self . assertTrue ( ( '_test' in item . name ) )