diff -r 7b9b4163406b tests/modeltests/basic/models.py
a
|
b
|
True
|
401 | 401 | |
402 | 402 | # The 'select' argument to extra() supports names with dashes in them, as long |
403 | 403 | # 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)] |
406 | 407 | |
407 | 408 | # If you use 'select' with extra() and names containing dashes on a query |
408 | 409 | # that's *not* a values() query, those extra 'select' values will silently be |
diff -r 7b9b4163406b tests/modeltests/or_lookups/models.py
a
|
b
|
__test__ = {'API_TESTS':"""
|
110 | 110 | >>> Article.objects.filter(Q(headline__startswith='Hello') | Q(headline__contains='bye')).count() |
111 | 111 | 3 |
112 | 112 | |
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)] |
115 | 116 | |
116 | 117 | >>> Article.objects.filter(Q(headline__startswith='Hello')).in_bulk([1,2]) |
117 | 118 | {1: <Article: Hello>} |
diff -r 7b9b4163406b tests/regressiontests/defaultfilters/tests.py
a
|
b
|
u'some <b>html</b> with alert("You smell
|
226 | 226 | >>> striptags(u'some <b>html</b> with <script>alert("You smell")</script> disallowed <img /> tags') |
227 | 227 | u'some html with alert("You smell") disallowed tags' |
228 | 228 | |
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')] |
233 | 234 | |
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')] |
238 | 240 | |
239 | 241 | >>> first([0,1,2]) |
240 | 242 | 0 |
diff -r 7b9b4163406b tests/regressiontests/queries/models.py
a
|
b
|
True
|
503 | 503 | |
504 | 504 | # Despite having some extra aliases in the query, we can still omit them in a |
505 | 505 | # 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)] |
508 | 509 | |
509 | 510 | Bugs #2874, #3002 |
510 | 511 | >>> qs = Item.objects.select_related().order_by('note__note', 'name') |