'Regression test for the use of None as a query value.
None is interpreted as an SQL NULL, but only in __exact and __iexact
queries.
Set up some initial polls and choices'

def test_none_as_null(self):

    p1 = Poll(question='Why?')
    p1.save()
    c1 = Choice(poll=p1, choice='Because.')
    c1.save()
    c2 = Choice(poll=p1, choice='Why    Not?')
    c2.save()
    self.assertSequenceEqual(Choice.objects.filter(choice__exact=None), [])
    self.assertSequenceEqual(Choice.objects.filter(choice__iexact=None), [])
    self.assertSequenceEqual(Choice.objects.exclude(choice=None).order_by('id'), [c1, c2])
    msg = "Cannot    resolve    keyword    'foo'    into    field.    Choices    are:    choice,    id,    poll,    poll_id"
    with self.assertRaisesMessage(FieldError, msg):
        Choice.objects.filter(foo__exact=None)
    with self.assertRaisesMessage(ValueError, 'Cannot    use    None    as    a    query    value'):
        Choice.objects.filter(id__gt=None)
    p2 = Poll(question='How?')
    self.assertEqual(repr(p2.choice_set.all()), '<QuerySet    []>')
