#NEWLINE# def test_abstract_base_class_m2m_relation_inheritance( self ) : #NEWLINE# #INDENT# p1 = Person . objects . create ( name = 'Alice' ) #NEWLINE# p2 = Person . objects . create ( name = 'Bob' ) #NEWLINE# p3 = Person . objects . create ( name = 'Carol' ) #NEWLINE# p4 = Person . objects . create ( name = 'Dave' ) #NEWLINE# birthday = BirthdayParty . objects . create ( name = 'Birthday party for Alice' ) #NEWLINE# birthday . attendees = [ p1 , p3 ] #NEWLINE# bachelor = BachelorParty . objects . create ( name = 'Bachelor party for Bob' ) #NEWLINE# bachelor . attendees = [ p2 , p4 ] #NEWLINE# parties = list ( p1 . birthdayparty_set . all ( ) ) #NEWLINE# self . assertEqual ( parties , [ birthday ] ) #NEWLINE# parties = list ( p1 . bachelorparty_set . all ( ) ) #NEWLINE# self . assertEqual ( parties , [ ] ) #NEWLINE# parties = list ( p2 . bachelorparty_set . all ( ) ) #NEWLINE# self . assertEqual ( parties , [ bachelor ] ) #NEWLINE# self . assertFalse ( hasattr ( p2 , 'messybachelorparty_set' ) ) #NEWLINE# messy = MessyBachelorParty . objects . create ( name = 'Bachelor party for Dave' ) #NEWLINE# messy . attendees = [ p4 ] #NEWLINE# messy_parent = messy . bachelorparty_ptr #NEWLINE# parties = list ( p4 . bachelorparty_set . all ( ) ) #NEWLINE# self . assertEqual ( parties , [ bachelor , messy_parent ] )