#NEWLINE# def test_float_validates_object( self ) : #NEWLINE# #INDENT# instance = FloatModel ( size = 2.5 ) #NEWLINE# instance . size = instance #NEWLINE# with transaction . atomic ( ) : #NEWLINE# #INDENT# with self . assertRaises ( TypeError ) : #NEWLINE# #INDENT# instance . save ( ) #NEWLINE# #UNINDENT# #UNINDENT# instance . size = 2.5 #NEWLINE# instance . save ( ) #NEWLINE# self . assertTrue ( instance . id ) #NEWLINE# instance . size = instance #NEWLINE# msg = 'Tried to update field model_fields.FloatModel.size with a model instance, <FloatModel: FloatModel object>. Use a value compatible with FloatField.' #NEWLINE# with transaction . atomic ( ) : #NEWLINE# #INDENT# with self . assertRaisesMessage ( TypeError , msg ) : #NEWLINE# #INDENT# instance . save ( ) #NEWLINE# #UNINDENT# #UNINDENT# obj = FloatModel . objects . get ( pk = instance . id ) #NEWLINE# obj . size = obj #NEWLINE# with self . assertRaises ( TypeError ) : #NEWLINE# #INDENT# obj . save ( )