#NEWLINE# def _check_mutation( self , obj , attr , mutator , expected_event_old , expected_event_new ) : #NEWLINE# #INDENT# result = dict ( calls = [ ] ) #NEWLINE# def record_trigger( attr , old , new_ ) : #NEWLINE# #INDENT# result [ 'calls' ] . append ( ( attr , old , new_ ) ) #NEWLINE# #UNINDENT# obj . on_change ( attr , record_trigger ) #NEWLINE# try : #NEWLINE# #INDENT# actual_old = getattr ( obj , attr ) #NEWLINE# self . assertEqual ( expected_event_old , actual_old ) #NEWLINE# mutator ( actual_old ) #NEWLINE# self . assertEqual ( expected_event_new , getattr ( obj , attr ) ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# obj . remove_on_change ( attr , record_trigger ) #NEWLINE# #UNINDENT# self . assertEqual ( 1 , len ( result [ 'calls' ] ) ) #NEWLINE# call = result [ 'calls' ] [ 0 ] #NEWLINE# self . assertEqual ( attr , call [ 0 ] ) #NEWLINE# self . assertEqual ( expected_event_old , call [ 1 ] ) #NEWLINE# self . assertEqual ( expected_event_new , call [ 2 ] )