<s> from __future__ import absolute_import <EOL> from django . test import TestCase <EOL> from django . core . exceptions import FieldError <EOL> from . models import Poll , Choice , OuterA , Inner , OuterB <EOL> class NullQueriesTests ( TestCase ) : <EOL> def test_none_as_null ( self ) : <EOL> """<STR_LIT>""" <EOL> p1 = Poll ( question = '<STR_LIT>' ) <EOL> p1 . save ( ) <EOL> c1 = Choice ( poll = p1 , choice = '<STR_LIT>' ) <EOL> c1 . save ( ) <EOL> c2 = Choice ( poll = p1 , choice = '<STR_LIT>' ) <EOL> c2 . save ( ) <EOL> self . assertQuerysetEqual ( Choice . objects . filter ( choice__exact = None ) , [ ] ) <EOL> self . assertQuerysetEqual ( <EOL> Choice . objects . exclude ( choice = None ) . order_by ( '<STR_LIT:id>' ) , <EOL> [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> ) <EOL> self . assertRaises ( FieldError , Choice . objects . filter , foo__exact = None ) <EOL> self . assertRaises ( ValueError , Choice . objects . filter , id__gt = None ) <EOL> self . assertRaises ( ValueError , Choice . objects . filter , foo__gt = None ) <EOL> p2 = Poll ( question = "<STR_LIT>" ) <EOL> self . assertEqual ( repr ( p2 . choice_set . all ( ) ) , '<STR_LIT>' ) <EOL> def test_reverse_relations ( self ) : <EOL> """<STR_LIT>""" <EOL> obj = OuterA . objects . create ( ) <EOL> self . assertQuerysetEqual ( <EOL> OuterA . objects . filter ( inner__third = None ) , <EOL> [ '<STR_LIT>' ] <EOL> ) <EOL> self . assertQuerysetEqual ( <EOL> OuterA . objects . filter ( inner__third__data = None ) , <EOL> [ '<STR_LIT>' ] <EOL> ) <EOL> inner_obj = Inner . objects . create ( first = obj ) <EOL> self . assertQuerysetEqual ( <EOL> Inner . objects . filter ( first__inner__third = None ) , <EOL> [ '<STR_LIT>' ] <EOL> ) <EOL> objB = OuterB . objects . create ( data = "<STR_LIT>" ) <EOL> self . assertQuerysetEqual ( <EOL> OuterB . objects . filter ( inner__isnull = False ) , <EOL> [ ] <EOL> ) <EOL> Inner . objects . create ( first = obj ) <EOL> self . assertQuerysetEqual ( <EOL> OuterB . objects . exclude ( inner__isnull = False ) , <EOL> [ '<STR_LIT>' ] <EOL> ) </s>
