summaryrefslogtreecommitdiff
path: root/tests/queries
diff options
context:
space:
mode:
authorDražen Odobašić <dodobas@candela-it.com>2015-09-11 19:33:12 -0400
committerTim Graham <timograham@gmail.com>2015-09-12 11:40:50 -0400
commitb1e33ceceda1e75ff68c7deed8f6659683a195d3 (patch)
treee4e446f69194f2dc3c9c7ee3ecf48290ea8d4d31 /tests/queries
parent84b0a8d2aad042fb573df5055b6153770d0929ac (diff)
Fixed #23395 -- Limited line lengths to 119 characters.
Diffstat (limited to 'tests/queries')
-rw-r--r--tests/queries/tests.py56
1 files changed, 47 insertions, 9 deletions
diff --git a/tests/queries/tests.py b/tests/queries/tests.py
index 23c9891079..05d9ca24a6 100644
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -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)