Ticket #7235: 7235_tests.diff

File 7235_tests.diff, 1.3 KB (added by taylormarshall, 5 years ago)

regression tests for 7235

  • models.py

     
    88
    99from django.conf import settings
    1010from django.db import models, DEFAULT_DB_ALIAS
    11 from django.db.models.query import Q, ITER_CHUNK_SIZE
     11from django.db.models import Count
     12from django.db.models.query import Q, ITER_CHUNK_SIZE, EmptyQuerySet
    1213
    1314# Python 2.3 doesn't have sorted()
    1415try:
     
    969970...     break
    970971True
    971972
     973Bug #7235 -- an EmptyQuerySet should not raise exceptions if it is filtered.
     974>>> q = EmptyQuerySet()
     975>>> q.all()
     976[]
     977>>> q.filter(x=10)
     978[]
     979>>> q.exclude(y=3)
     980[]
     981>>> q.complex_filter({'pk': 1})
     982[]
     983>>> q.select_related('spam', 'eggs')
     984[]
     985>>> q.annotate(Count('eggs'))
     986[]
     987>>> q.order_by('-pub_date', 'headline')
     988[]
     989>>> q.distinct()
     990[]
     991>>> q.extra(select={'is_recent': "pub_date > '2006-01-01'"})
     992[]
     993>>> q.query.low_mark = 1
     994>>> q.extra(select={'is_recent': "pub_date > '2006-01-01'"})
     995Traceback (most recent call last):
     996...
     997AssertionError: Cannot change a query once a slice has been taken
     998>>> q.reverse()
     999[]
     1000>>> q.defer('spam', 'eggs')
     1001[]
     1002>>> q.only('spam', 'eggs')
     1003[]
     1004
    9721005Bug #7791 -- there were "issues" when ordering and distinct-ing on fields
    9731006related via ForeignKeys.
    9741007>>> len(Note.objects.order_by('extrainfo__info').distinct())
Back to Top