Code

Ticket #7366: no-dicts-on-doctest-output.patch

File no-dicts-on-doctest-output.patch, 4.2 KB (added by leosoto, 6 years ago)
  • tests/modeltests/basic/models.py

    diff -r 7b9b4163406b tests/modeltests/basic/models.py
    a b True 
    401401 
    402402# The 'select' argument to extra() supports names with dashes in them, as long 
    403403# as you use values(). 
    404 >>> Article.objects.filter(pub_date__year=2008).extra(select={'dashed-value': '1'}).values('headline', 'dashed-value') 
    405 [{'headline': u'Article 11', 'dashed-value': 1}, {'headline': u'Article 12', 'dashed-value': 1}] 
     404>>> dicts = Article.objects.filter(pub_date__year=2008).extra(select={'dashed-value': '1'}).values('headline', 'dashed-value') 
     405>>> [(d['headline'], d['dashed-value']) for d in dicts] 
     406[(u'Article 11', 1), (u'Article 12', 1)] 
    406407 
    407408# If you use 'select' with extra() and names containing dashes on a query 
    408409# that's *not* a values() query, those extra 'select' values will silently be 
  • tests/modeltests/or_lookups/models.py

    diff -r 7b9b4163406b tests/modeltests/or_lookups/models.py
    a b __test__ = {'API_TESTS':""" 
    110110>>> Article.objects.filter(Q(headline__startswith='Hello') | Q(headline__contains='bye')).count() 
    1111113 
    112112 
    113 >>> list(Article.objects.filter(Q(headline__startswith='Hello'), Q(headline__contains='bye')).values()) 
    114 [{'headline': u'Hello and goodbye', 'pub_date': datetime.datetime(2005, 11, 29, 0, 0), 'id': 3}] 
     113>>> dict_list = list(Article.objects.filter(Q(headline__startswith='Hello'), Q(headline__contains='bye')).values()) 
     114>>> [(d['headline'], d['pub_date'], d['id']) for d in dict_list] 
     115[(u'Hello and goodbye', datetime.datetime(2005, 11, 29, 0, 0), 3)] 
    115116 
    116117>>> Article.objects.filter(Q(headline__startswith='Hello')).in_bulk([1,2]) 
    117118{1: <Article: Hello>} 
  • tests/regressiontests/defaultfilters/tests.py

    diff -r 7b9b4163406b tests/regressiontests/defaultfilters/tests.py
    a b u'some <b>html</b> with alert("You smell 
    226226>>> striptags(u'some <b>html</b> with <script>alert("You smell")</script> disallowed <img /> tags') 
    227227u'some html with alert("You smell") disallowed  tags' 
    228228 
    229 >>> dictsort([{'age': 23, 'name': 'Barbara-Ann'}, 
    230 ...           {'age': 63, 'name': 'Ra Ra Rasputin'}, 
    231 ...           {'name': 'Jonny B Goode', 'age': 18}], 'age') 
    232 [{'age': 18, 'name': 'Jonny B Goode'}, {'age': 23, 'name': 'Barbara-Ann'}, {'age': 63, 'name': 'Ra Ra Rasputin'}] 
     229>>> sorted_dicts = dictsort([{'age': 23, 'name': 'Barbara-Ann'}, 
     230...                          {'age': 63, 'name': 'Ra Ra Rasputin'}, 
     231...                          {'name': 'Jonny B Goode', 'age': 18}], 'age') 
     232>>> [(dict['age'], dict['name']) for dict in sorted_dicts] 
     233[(18, 'Jonny B Goode'), (23, 'Barbara-Ann'), (63, 'Ra Ra Rasputin')] 
    233234 
    234 >>> dictsortreversed([{'age': 23, 'name': 'Barbara-Ann'}, 
    235 ...           {'age': 63, 'name': 'Ra Ra Rasputin'}, 
    236 ...           {'name': 'Jonny B Goode', 'age': 18}], 'age') 
    237 [{'age': 63, 'name': 'Ra Ra Rasputin'}, {'age': 23, 'name': 'Barbara-Ann'}, {'age': 18, 'name': 'Jonny B Goode'}] 
     235>>> sorted_dicts = dictsortreversed([{'age': 23, 'name': 'Barbara-Ann'}, 
     236...                                  {'age': 63, 'name': 'Ra Ra Rasputin'}, 
     237...                                  {'name': 'Jonny B Goode', 'age': 18}], 'age') 
     238>>> [(dict['age'], dict['name']) for dict in sorted_dicts] 
     239[(63, 'Ra Ra Rasputin'), (23, 'Barbara-Ann'), (18, 'Jonny B Goode')] 
    238240 
    239241>>> first([0,1,2]) 
    2402420 
  • tests/regressiontests/queries/models.py

    diff -r 7b9b4163406b tests/regressiontests/queries/models.py
    a b True 
    503503 
    504504# Despite having some extra aliases in the query, we can still omit them in a 
    505505# values() query. 
    506 >>> qs.values('id', 'rank').order_by('id') 
    507 [{'id': 1, 'rank': 2}, {'id': 2, 'rank': 1}, {'id': 3, 'rank': 3}] 
     506>>> dicts = qs.values('id', 'rank').order_by('id') 
     507>>> [(d['id'], d['rank']) for d in dicts] 
     508[(1, 2), (2, 1), (3, 3)] 
    508509 
    509510Bugs #2874, #3002 
    510511>>> qs = Item.objects.select_related().order_by('note__note', 'name')