#NEWLINE# def test_related_object( self ) : #NEWLINE# #INDENT# public_school = School . objects . create ( is_public = True ) #NEWLINE# public_student = Student . objects . create ( school = public_school ) #NEWLINE# private_school = School . objects . create ( is_public = False ) #NEWLINE# private_student = Student . objects . create ( school = private_school ) #NEWLINE# self . assertQuerysetEqual ( School . objects . all ( ) , [ '<School: School object>' ] ) #NEWLINE# self . assertEqual ( public_student . school , public_school ) #NEWLINE# self . assertEqual ( private_student . school , private_school ) #NEWLINE# School . objects . use_for_related_fields = True #NEWLINE# try : #NEWLINE# #INDENT# private_student = Student . objects . get ( pk = private_student . pk ) #NEWLINE# with self . assertRaises ( School . DoesNotExist ) : #NEWLINE# #INDENT# private_student . school #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# School . objects . use_for_related_fields = False