#NEWLINE# def call( self , cmdobj , args , msg = None , cmdset = None , noansi = True , caller = None , receiver = None ) : #NEWLINE# #INDENT# '\n        Test a command by assigning all the needed\n        properties to cmdobj and  running\n            cmdobj.at_pre_cmd()\n            cmdobj.parse()\n            cmdobj.func()\n            cmdobj.at_post_cmd()\n        The msgreturn value is compared to eventual\n        output sent to caller.msg in the game\n        ' #NEWLINE# caller = ( caller if caller else self . char1 ) #NEWLINE# receiver = ( receiver if receiver else caller ) #NEWLINE# cmdobj . caller = caller #NEWLINE# cmdobj . cmdstring = cmdobj . key #NEWLINE# cmdobj . args = args #NEWLINE# cmdobj . cmdset = cmdset #NEWLINE# cmdobj . session = SESSIONS . session_from_sessid ( 1 ) #NEWLINE# cmdobj . player = self . player #NEWLINE# cmdobj . raw_string = ( ( cmdobj . key + ' ' ) + args ) #NEWLINE# cmdobj . obj = ( caller if caller else self . char1 ) #NEWLINE# old_msg = receiver . msg #NEWLINE# try : #NEWLINE# #INDENT# receiver . msg = Mock ( ) #NEWLINE# cmdobj . at_pre_cmd ( ) #NEWLINE# cmdobj . parse ( ) #NEWLINE# cmdobj . func ( ) #NEWLINE# cmdobj . at_post_cmd ( ) #NEWLINE# stored_msg = [ args [ 0 ] for ( name , args , kwargs ) in receiver . msg . mock_calls ] #NEWLINE# returned_msg = '||' . join ( ( _RE . sub ( '' , mess ) for mess in stored_msg ) ) #NEWLINE# returned_msg = ansi . parse_ansi ( returned_msg , strip_ansi = noansi ) . strip ( ) #NEWLINE# if ( msg is not None ) : #NEWLINE# #INDENT# if ( ( ( msg == '' ) and returned_msg ) or ( not returned_msg . startswith ( msg . strip ( ) ) ) ) : #NEWLINE# #INDENT# sep1 = ( ( ( ( '\n' + ( '=' * 30 ) ) + 'Wanted message' ) + ( '=' * 34 ) ) + '\n' ) #NEWLINE# sep2 = ( ( ( ( '\n' + ( '=' * 30 ) ) + 'Returned message' ) + ( '=' * 32 ) ) + '\n' ) #NEWLINE# sep3 = ( '\n' + ( '=' * 78 ) ) #NEWLINE# retval = ( ( ( ( sep1 + msg . strip ( ) ) + sep2 ) + returned_msg ) + sep3 ) #NEWLINE# raise AssertionError ( cmdobj ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# receiver . msg = old_msg