summaryrefslogtreecommitdiff
path: root/tests/annotations/tests.py
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2020-06-06 14:34:38 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-07-15 10:58:38 +0200
commit156a2138db20abc89933121e4ff2ee2ce56a173a (patch)
tree294047367a3c1d87d69b0cacac3504ffc892faa3 /tests/annotations/tests.py
parent1e38f1191de21b6e96736f58df57dfb851a28c1f (diff)
Refs #30446 -- Removed unnecessary Value(..., output_field) in docs and tests.
Diffstat (limited to 'tests/annotations/tests.py')
-rw-r--r--tests/annotations/tests.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py
index aa3682b86b..5401cd9b21 100644
--- a/tests/annotations/tests.py
+++ b/tests/annotations/tests.py
@@ -5,9 +5,9 @@ from unittest import skipIf
from django.core.exceptions import FieldDoesNotExist, FieldError
from django.db import connection
from django.db.models import (
- BooleanField, Case, CharField, Count, DateTimeField, Exists,
- ExpressionWrapper, F, FloatField, Func, IntegerField, Max,
- NullBooleanField, OuterRef, Q, Subquery, Sum, Value, When,
+ BooleanField, Case, Count, DateTimeField, Exists, ExpressionWrapper, F,
+ FloatField, Func, IntegerField, Max, NullBooleanField, OuterRef, Q,
+ Subquery, Sum, Value, When,
)
from django.db.models.expressions import RawSQL
from django.db.models.functions import Length, Lower
@@ -115,8 +115,7 @@ class NonAggregateAnnotationTestCase(TestCase):
s3.books.add(cls.b3, cls.b4, cls.b6)
def test_basic_annotation(self):
- books = Book.objects.annotate(
- is_book=Value(1, output_field=IntegerField()))
+ books = Book.objects.annotate(is_book=Value(1))
for book in books:
self.assertEqual(book.is_book, 1)
@@ -163,9 +162,7 @@ class NonAggregateAnnotationTestCase(TestCase):
self.assertTrue(all(not book.selected for book in books))
def test_annotate_with_aggregation(self):
- books = Book.objects.annotate(
- is_book=Value(1, output_field=IntegerField()),
- rating_count=Count('rating'))
+ books = Book.objects.annotate(is_book=Value(1), rating_count=Count('rating'))
for book in books:
self.assertEqual(book.is_book, 1)
self.assertEqual(book.rating_count, 1)
@@ -231,9 +228,7 @@ class NonAggregateAnnotationTestCase(TestCase):
self.assertCountEqual(lengths, [3, 7, 8])
def test_filter_annotation(self):
- books = Book.objects.annotate(
- is_book=Value(1, output_field=IntegerField())
- ).filter(is_book=1)
+ books = Book.objects.annotate(is_book=Value(1)).filter(is_book=1)
for book in books:
self.assertEqual(book.is_book, 1)
@@ -469,7 +464,7 @@ class NonAggregateAnnotationTestCase(TestCase):
qs = Employee.objects.extra(
select={'random_value': '42'}
).select_related('store').annotate(
- annotated_value=Value(17, output_field=IntegerField())
+ annotated_value=Value(17),
)
rows = [
@@ -493,7 +488,7 @@ class NonAggregateAnnotationTestCase(TestCase):
qs = Employee.objects.extra(
select={'random_value': '42'}
).select_related('store').annotate(
- annotated_value=Value(17, output_field=IntegerField())
+ annotated_value=Value(17),
)
rows = [
@@ -554,7 +549,7 @@ class NonAggregateAnnotationTestCase(TestCase):
function='COALESCE',
)
).annotate(
- tagline_lower=Lower(F('tagline'), output_field=CharField())
+ tagline_lower=Lower(F('tagline')),
).order_by('name')
# LOWER function supported by:
@@ -661,7 +656,6 @@ class NonAggregateAnnotationTestCase(TestCase):
max_pages=Case(
When(book_contact_set__isnull=True, then=Value(0)),
default=Max(F('book__pages')),
- output_field=IntegerField(),
),
).values('name', 'max_pages')
self.assertCountEqual(qs, [