#NEWLINE# def test_proxy_model_signals( self ) : #NEWLINE# #INDENT# '\n        Test save signals for proxy models\n        ' #NEWLINE# output = [ ] #NEWLINE# def make_handler( model , event ) : #NEWLINE# #INDENT# def _handler( * args , **kwargs ) : #NEWLINE# #INDENT# output . append ( ( '%s %s save' % ( model , event ) ) ) #NEWLINE# #UNINDENT# return _handler #NEWLINE# #UNINDENT# h1 = make_handler ( 'MyPerson' , 'pre' ) #NEWLINE# h2 = make_handler ( 'MyPerson' , 'post' ) #NEWLINE# h3 = make_handler ( 'Person' , 'pre' ) #NEWLINE# h4 = make_handler ( 'Person' , 'post' ) #NEWLINE# signals . pre_save . connect ( h1 , sender = MyPerson ) #NEWLINE# signals . post_save . connect ( h2 , sender = MyPerson ) #NEWLINE# signals . pre_save . connect ( h3 , sender = Person ) #NEWLINE# signals . post_save . connect ( h4 , sender = Person ) #NEWLINE# dino = MyPerson . objects . create ( name = 'dino' ) #NEWLINE# self . assertEqual ( output , [ 'MyPerson pre save' , 'MyPerson post save' ] ) #NEWLINE# output = [ ] #NEWLINE# h5 = make_handler ( 'MyPersonProxy' , 'pre' ) #NEWLINE# h6 = make_handler ( 'MyPersonProxy' , 'post' ) #NEWLINE# signals . pre_save . connect ( h5 , sender = MyPersonProxy ) #NEWLINE# signals . post_save . connect ( h6 , sender = MyPersonProxy ) #NEWLINE# dino = MyPersonProxy . objects . create ( name = 'pebbles' ) #NEWLINE# self . assertEqual ( output , [ 'MyPersonProxy pre save' , 'MyPersonProxy post save' ] ) #NEWLINE# signals . pre_save . disconnect ( h1 , sender = MyPerson ) #NEWLINE# signals . post_save . disconnect ( make_handler , sender = MyPerson ) #NEWLINE# signals . pre_save . disconnect ( h3 , sender = Person ) #NEWLINE# signals . post_save . disconnect ( h4 , sender = Person ) #NEWLINE# signals . pre_save . disconnect ( h5 , sender = MyPersonProxy ) #NEWLINE# signals . post_save . disconnect ( h6 , sender = MyPersonProxy )