mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #23395 -- Limited line lengths to 119 characters.
This commit is contained in:
parent
84b0a8d2aa
commit
b1e33ceced
130 changed files with 5259 additions and 1501 deletions
|
@ -227,11 +227,25 @@ class Queries1Tests(BaseQuerysetTest):
|
|||
4
|
||||
)
|
||||
self.assertEqual(
|
||||
Item.objects.exclude(name='two').extra(select={'foo': '%s'}, select_params=(1,)).values('creator', 'name', 'foo').distinct().count(),
|
||||
(
|
||||
Item.objects
|
||||
.exclude(name='two')
|
||||
.extra(select={'foo': '%s'}, select_params=(1,))
|
||||
.values('creator', 'name', 'foo')
|
||||
.distinct()
|
||||
.count()
|
||||
),
|
||||
4
|
||||
)
|
||||
self.assertEqual(
|
||||
Item.objects.exclude(name='two').extra(select={'foo': '%s'}, select_params=(1,)).values('creator', 'name').distinct().count(),
|
||||
(
|
||||
Item.objects
|
||||
.exclude(name='two')
|
||||
.extra(select={'foo': '%s'}, select_params=(1,))
|
||||
.values('creator', 'name')
|
||||
.distinct()
|
||||
.count()
|
||||
),
|
||||
4
|
||||
)
|
||||
xx.delete()
|
||||
|
@ -355,7 +369,10 @@ class Queries1Tests(BaseQuerysetTest):
|
|||
# involve one "left outer" join (Author -> Item is 0-to-many).
|
||||
qs = Author.objects.filter(id=self.a1.id).filter(Q(extra__note=self.n1) | Q(item__note=self.n3))
|
||||
self.assertEqual(
|
||||
len([x for x in qs.query.alias_map.values() if x.join_type == LOUTER and qs.query.alias_refcount[x.table_alias]]),
|
||||
len([
|
||||
x for x in qs.query.alias_map.values()
|
||||
if x.join_type == LOUTER and qs.query.alias_refcount[x.table_alias]
|
||||
]),
|
||||
1
|
||||
)
|
||||
|
||||
|
@ -568,7 +585,13 @@ class Queries1Tests(BaseQuerysetTest):
|
|||
self.assertEqual(d, {'a': 'one', 'b': 'two'})
|
||||
|
||||
# Order by the number of tags attached to an item.
|
||||
l = Item.objects.extra(select={'count': 'select count(*) from queries_item_tags where queries_item_tags.item_id = queries_item.id'}).order_by('-count')
|
||||
l = (
|
||||
Item.objects
|
||||
.extra(select={
|
||||
'count': 'select count(*) from queries_item_tags where queries_item_tags.item_id = queries_item.id'
|
||||
})
|
||||
.order_by('-count')
|
||||
)
|
||||
self.assertEqual([o.count for o in l], [2, 2, 1, 0])
|
||||
|
||||
def test_ticket6154(self):
|
||||
|
@ -704,7 +727,9 @@ class Queries1Tests(BaseQuerysetTest):
|
|||
|
||||
def test_ticket7277(self):
|
||||
self.assertQuerysetEqual(
|
||||
self.n1.annotation_set.filter(Q(tag=self.t5) | Q(tag__children=self.t5) | Q(tag__children__children=self.t5)),
|
||||
self.n1.annotation_set.filter(
|
||||
Q(tag=self.t5) | Q(tag__children=self.t5) | Q(tag__children__children=self.t5)
|
||||
),
|
||||
['<Annotation: a1>']
|
||||
)
|
||||
|
||||
|
@ -1376,12 +1401,19 @@ class Queries4Tests(BaseQuerysetTest):
|
|||
self.assertEqual(str(q1.query), str(q2.query))
|
||||
|
||||
q1 = Item.objects.filter(Q(creator=self.a1) | Q(creator__report__name='r1')).order_by()
|
||||
q2 = Item.objects.filter(Q(creator=self.a1)).order_by() | Item.objects.filter(Q(creator__report__name='r1')).order_by()
|
||||
q2 = (
|
||||
Item.objects
|
||||
.filter(Q(creator=self.a1)).order_by() | Item.objects.filter(Q(creator__report__name='r1'))
|
||||
.order_by()
|
||||
)
|
||||
self.assertQuerysetEqual(q1, ["<Item: i1>"])
|
||||
self.assertEqual(str(q1.query), str(q2.query))
|
||||
|
||||
q1 = Item.objects.filter(Q(creator__report__name='e1') | Q(creator=self.a1)).order_by()
|
||||
q2 = Item.objects.filter(Q(creator__report__name='e1')).order_by() | Item.objects.filter(Q(creator=self.a1)).order_by()
|
||||
q2 = (
|
||||
Item.objects.filter(Q(creator__report__name='e1')).order_by()
|
||||
| Item.objects.filter(Q(creator=self.a1)).order_by()
|
||||
)
|
||||
self.assertQuerysetEqual(q1, ["<Item: i1>"])
|
||||
self.assertEqual(str(q1.query), str(q2.query))
|
||||
|
||||
|
@ -2621,7 +2653,10 @@ class DefaultValuesInsertTest(TestCase):
|
|||
try:
|
||||
DumbCategory.objects.create()
|
||||
except TypeError:
|
||||
self.fail("Creation of an instance of a model with only the PK field shouldn't error out after bulk insert refactoring (#17056)")
|
||||
self.fail(
|
||||
"Creation of an instance of a model with only the PK field "
|
||||
"shouldn't error out after bulk insert refactoring (#17056)"
|
||||
)
|
||||
|
||||
|
||||
class ExcludeTests(TestCase):
|
||||
|
@ -3524,7 +3559,10 @@ class RelatedLookupTypeTests(TestCase):
|
|||
# child objects
|
||||
self.assertQuerysetEqual(ObjectB.objects.filter(objecta__in=[self.coa]), [])
|
||||
self.assertQuerysetEqual(ObjectB.objects.filter(objecta__in=[self.poa, self.coa]).order_by('name'), out_b)
|
||||
self.assertQuerysetEqual(ObjectB.objects.filter(objecta__in=iter([self.poa, self.coa])).order_by('name'), out_b)
|
||||
self.assertQuerysetEqual(
|
||||
ObjectB.objects.filter(objecta__in=iter([self.poa, self.coa])).order_by('name'),
|
||||
out_b
|
||||
)
|
||||
|
||||
# parent objects
|
||||
self.assertQuerysetEqual(ObjectC.objects.exclude(childobjecta=self.oa), out_c)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue