#NEWLINE# def test_reverse_descriptors( self ) : #NEWLINE# #INDENT# self . assertRaises ( AttributeError , ( lambda : self . bob . group_set . add ( self . rock ) ) ) #NEWLINE# self . assertRaises ( AttributeError , ( lambda : self . bob . group_set . create ( name = 'funk' ) ) ) #NEWLINE# self . assertRaises ( AttributeError , ( lambda : self . jim . group_set . remove ( self . rock ) ) ) #NEWLINE# m1 = Membership . objects . create ( person = self . jim , group = self . rock ) #NEWLINE# m2 = Membership . objects . create ( person = self . jim , group = self . roll ) #NEWLINE# backup = list ( self . jim . group_set . all ( ) ) #NEWLINE# self . assertEqual ( [ g . name for g in backup ] , [ 'Rock' , 'Roll' ] ) #NEWLINE# self . jim . group_set . clear ( ) #NEWLINE# self . assertQuerysetEqual ( self . jim . group_set . all ( ) , [ ] ) #NEWLINE# self . assertRaises ( AttributeError , setattr , self . jim , 'group_set' , backup ) #NEWLINE# m1 . save ( ) #NEWLINE# m2 . save ( ) #NEWLINE# self . assertQuerysetEqual ( self . jim . group_set . all ( ) , [ 'Rock' , 'Roll' ] , attrgetter ( 'name' ) )