#NEWLINE# def test_inherited_collections( self ) : #NEWLINE# #INDENT# "Ensure that subclassed documents don't override parents'\n        collections\n        " #NEWLINE# class Drink ( Document ) : #NEWLINE# #INDENT# name = StringField ( ) #NEWLINE# meta = { #NEWLINE# #INDENT# 'allow_inheritance' : True , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# class Drinker ( Document ) : #NEWLINE# #INDENT# drink = GenericReferenceField ( ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# warnings . simplefilter ( 'error' ) #NEWLINE# class AcloholicDrink ( Drink ) : #NEWLINE# #INDENT# meta = { #NEWLINE# #INDENT# 'collection' : 'booze' , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# except SyntaxWarning : #NEWLINE# #INDENT# warnings . simplefilter ( 'ignore' ) #NEWLINE# class AlcoholicDrink ( Drink ) : #NEWLINE# #INDENT# meta = { #NEWLINE# #INDENT# 'collection' : 'booze' , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise AssertionError ( 'SyntaxWarning should be triggered' ) #NEWLINE# #UNINDENT# warnings . resetwarnings ( ) #NEWLINE# Drink . drop_collection ( ) #NEWLINE# AlcoholicDrink . drop_collection ( ) #NEWLINE# Drinker . drop_collection ( ) #NEWLINE# red_bull = Drink ( name = 'Red Bull' ) #NEWLINE# red_bull . save ( ) #NEWLINE# programmer = Drinker ( drink = red_bull ) #NEWLINE# programmer . save ( ) #NEWLINE# beer = AlcoholicDrink ( name = 'Beer' ) #NEWLINE# beer . save ( ) #NEWLINE# real_person = Drinker ( drink = beer ) #NEWLINE# real_person . save ( ) #NEWLINE# self . assertEqual ( Drinker . objects [ 0 ] . drink . name , red_bull . name ) #NEWLINE# self . assertEqual ( Drinker . objects [ 1 ] . drink . name , beer . name )