<s> from django . test import TestCase <EOL> from regressiontests . null_fk . models import * <EOL> class NullFkTests ( TestCase ) : <EOL> def test_null_fk ( self ) : <EOL> d = SystemDetails . objects . create ( details = '<STR_LIT>' ) <EOL> s = SystemInfo . objects . create ( system_name = '<STR_LIT>' , system_details = d ) <EOL> f = Forum . objects . create ( system_info = s , forum_name = '<STR_LIT>' ) <EOL> p = Post . objects . create ( forum = f , title = '<STR_LIT>' ) <EOL> c1 = Comment . objects . create ( post = p , comment_text = '<STR_LIT>' ) <EOL> c2 = Comment . objects . create ( comment_text = '<STR_LIT>' ) <EOL> c = Comment . objects . select_related ( ) . get ( id = <NUM_LIT:1> ) <EOL> self . assertEquals ( c . post , p ) <EOL> self . assertEquals ( Comment . objects . select_related ( ) . get ( id = <NUM_LIT:2> ) . post , None ) <EOL> self . assertQuerysetEqual ( <EOL> Comment . objects . select_related ( '<STR_LIT>' ) . all ( ) , <EOL> [ <EOL> ( <NUM_LIT:1> , u'<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( <NUM_LIT:2> , u'<STR_LIT>' , '<STR_LIT:None>' ) <EOL> ] , <EOL> transform = lambda c : ( c . id , c . comment_text , repr ( c . post ) ) <EOL> ) <EOL> self . assertTrue ( Comment . objects . select_related ( '<STR_LIT>' ) . filter ( post__isnull = True ) [ <NUM_LIT:0> ] . post is None ) <EOL> self . assertQuerysetEqual ( <EOL> Comment . objects . select_related ( '<STR_LIT>' ) , <EOL> [ <EOL> ( <NUM_LIT:1> , u'<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( <NUM_LIT:2> , u'<STR_LIT>' , '<STR_LIT:None>' ) <EOL> ] , <EOL> transform = lambda c : ( c . id , c . comment_text , repr ( c . post ) ) <EOL> ) </s>
