diff --git a/docs/ref/models/conditional-expressions.txt b/docs/ref/models/conditional-expressions.txt index a1e2430ec1..546733dd8d 100644 --- a/docs/ref/models/conditional-expressions.txt +++ b/docs/ref/models/conditional-expressions.txt @@ -100,7 +100,7 @@ An example:: >>> >>> from datetime import date, timedelta - >>> from django.db.models import Case, CharField, Value, When + >>> from django.db.models import Case, Value, When >>> Client.objects.create( ... name='Jane Doe', ... account_type=Client.REGULAR, @@ -119,7 +119,6 @@ An example:: ... When(account_type=Client.GOLD, then=Value('5%')), ... When(account_type=Client.PLATINUM, then=Value('10%')), ... default=Value('0%'), - ... output_field=CharField(), ... ), ... ).values_list('name', 'discount') @@ -141,7 +140,6 @@ the ``Client`` has been with us, we could do so using lookups:: ... When(registered_on__lte=a_year_ago, then=Value('10%')), ... When(registered_on__lte=a_month_ago, then=Value('5%')), ... default=Value('0%'), - ... output_field=CharField(), ... ) ... ).values_list('name', 'discount') diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index da78b8d9a9..c738cbb27e 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -841,7 +841,7 @@ class AggregateTestCase(TestCase): Book.objects.aggregate(fail=F('price')) def test_nonfield_annotation(self): - book = Book.objects.annotate(val=Max(Value(2, output_field=IntegerField()))).first() + book = Book.objects.annotate(val=Max(Value(2))).first() self.assertEqual(book.val, 2) book = Book.objects.annotate(val=Max(Value(2), output_field=IntegerField())).first() self.assertEqual(book.val, 2) diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py index b298a1f132..7604335257 100644 --- a/tests/aggregation_regress/tests.py +++ b/tests/aggregation_regress/tests.py @@ -374,7 +374,7 @@ class AggregationTests(TestCase): # Conditional aggregation of a grouped queryset. self.assertEqual( Book.objects.annotate(c=Count('authors')).values('pk').aggregate(test=Sum( - Case(When(c__gt=1, then=1), output_field=IntegerField()) + Case(When(c__gt=1, then=1)) ))['test'], 3 ) @@ -382,7 +382,7 @@ class AggregationTests(TestCase): def test_sliced_conditional_aggregate(self): self.assertEqual( Author.objects.all()[:5].aggregate(test=Sum(Case( - When(age__lte=35, then=1), output_field=IntegerField() + When(age__lte=35, then=1) )))['test'], 3 ) 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, [ diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index c89bb1d69e..2f392a51e6 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -729,7 +729,7 @@ class BasicExpressionsTests(TestCase): self.assertEqual(qs.get().ceo_company, 'Test GmbH') def test_pickle_expression(self): - expr = Value(1, output_field=IntegerField()) + expr = Value(1) expr.convert_value # populate cached property self.assertEqual(pickle.loads(pickle.dumps(expr)), expr) @@ -1545,7 +1545,7 @@ class FTimeDeltaTests(TestCase): def test_time_subtraction(self): Time.objects.create(time=datetime.time(12, 30, 15, 2345)) queryset = Time.objects.annotate( - difference=F('time') - Value(datetime.time(11, 15, 0), output_field=TimeField()), + difference=F('time') - Value(datetime.time(11, 15, 0)), ) self.assertEqual( queryset.get().difference, @@ -1631,7 +1631,7 @@ class FTimeDeltaTests(TestCase): def test_date_minus_duration(self): more_than_4_days = Experiment.objects.filter( - assigned__lt=F('completed') - Value(datetime.timedelta(days=4), output_field=DurationField()) + assigned__lt=F('completed') - Value(datetime.timedelta(days=4)) ) self.assertQuerysetEqual(more_than_4_days, ['e3', 'e4', 'e5'], lambda e: e.name) diff --git a/tests/expressions_case/tests.py b/tests/expressions_case/tests.py index 3778e32f1b..2a101eeee1 100644 --- a/tests/expressions_case/tests.py +++ b/tests/expressions_case/tests.py @@ -6,9 +6,9 @@ from uuid import UUID from django.core.exceptions import FieldError from django.db.models import ( - BinaryField, BooleanField, Case, CharField, Count, DecimalField, - DurationField, F, GenericIPAddressField, IntegerField, Max, Min, Q, Sum, - TextField, TimeField, UUIDField, Value, When, + BinaryField, BooleanField, Case, Count, DecimalField, F, + GenericIPAddressField, IntegerField, Max, Min, Q, Sum, TextField, Value, + When, ) from django.test import SimpleTestCase, TestCase @@ -68,7 +68,6 @@ class CaseExpressionTests(TestCase): When(integer=1, then=Value('one')), When(integer=2, then=Value('two')), default=Value('other'), - output_field=CharField(), )).order_by('pk'), [(1, 'one'), (2, 'two'), (3, 'other'), (2, 'two'), (3, 'other'), (3, 'other'), (4, 'other')], transform=attrgetter('integer', 'test') @@ -79,7 +78,6 @@ class CaseExpressionTests(TestCase): CaseTestModel.objects.annotate(test=Case( When(integer=1, then=1), When(integer=2, then=2), - output_field=IntegerField(), )).order_by('pk'), [(1, 1), (2, 2), (3, None), (2, 2), (3, None), (3, None), (4, None)], transform=attrgetter('integer', 'test') @@ -101,7 +99,6 @@ class CaseExpressionTests(TestCase): CaseTestModel.objects.annotate(f_test=Case( When(integer2=F('integer'), then=Value('equal')), When(integer2=F('integer') + 1, then=Value('+1')), - output_field=CharField(), )).order_by('pk'), [(1, 'equal'), (2, '+1'), (3, '+1'), (2, 'equal'), (3, '+1'), (3, 'equal'), (4, '+1')], transform=attrgetter('integer', 'f_test') @@ -135,7 +132,6 @@ class CaseExpressionTests(TestCase): When(integer2=F('o2o_rel__integer'), then=Value('equal')), When(integer2=F('o2o_rel__integer') + 1, then=Value('+1')), default=Value('other'), - output_field=CharField(), )).order_by('pk'), [(1, 'equal'), (2, '+1'), (3, '+1'), (2, 'equal'), (3, '+1'), (3, 'equal'), (4, 'other')], transform=attrgetter('integer', 'join_test') @@ -148,7 +144,6 @@ class CaseExpressionTests(TestCase): When(o2o_rel__integer=2, then=Value('two')), When(o2o_rel__integer=3, then=Value('three')), default=Value('other'), - output_field=CharField(), )).order_by('pk'), [(1, 'one'), (2, 'two'), (3, 'three'), (2, 'two'), (3, 'three'), (3, 'three'), (4, 'one')], transform=attrgetter('integer', 'join_test') @@ -178,7 +173,6 @@ class CaseExpressionTests(TestCase): f_test=Case( When(integer2=F('integer'), then=Value('equal')), When(integer2=F('f_plus_1'), then=Value('+1')), - output_field=CharField(), ), ).order_by('pk'), [(1, 'equal'), (2, '+1'), (3, '+1'), (2, 'equal'), (3, '+1'), (3, 'equal'), (4, '+1')], @@ -195,7 +189,6 @@ class CaseExpressionTests(TestCase): When(f_minus_2=0, then=Value('zero')), When(f_minus_2=1, then=Value('one')), default=Value('other'), - output_field=CharField(), ), ).order_by('pk'), [(1, 'negative one'), (2, 'zero'), (3, 'one'), (2, 'zero'), (3, 'one'), (3, 'one'), (4, 'other')], @@ -226,7 +219,6 @@ class CaseExpressionTests(TestCase): test=Case( When(integer2=F('min'), then=Value('min')), When(integer2=F('max'), then=Value('max')), - output_field=CharField(), ), ).order_by('pk'), [(1, 1, 'min'), (2, 3, 'max'), (3, 4, 'max'), (2, 2, 'min'), (3, 4, 'max'), (3, 3, 'min'), (4, 5, 'min')], @@ -242,7 +234,6 @@ class CaseExpressionTests(TestCase): When(max=3, then=Value('max = 3')), When(max=4, then=Value('max = 4')), default=Value(''), - output_field=CharField(), ), ).order_by('pk'), [(1, 1, ''), (2, 3, 'max = 3'), (3, 4, 'max = 4'), (2, 3, 'max = 3'), @@ -256,7 +247,6 @@ class CaseExpressionTests(TestCase): When(integer=1, then=Value('one')), When(integer=2, then=Value('two')), default=Value('other'), - output_field=CharField(), )).exclude(test='other').order_by('pk'), [(1, 'one'), (2, 'two'), (2, 'two')], transform=attrgetter('integer', 'test') @@ -269,7 +259,6 @@ class CaseExpressionTests(TestCase): When(integer=2, then=Value('two')), When(integer=3, then=Value('three')), default=Value('other'), - output_field=CharField(), )).order_by('test').values_list('integer', flat=True)), [1, 4, 3, 3, 3, 2, 2] ) @@ -278,7 +267,7 @@ class CaseExpressionTests(TestCase): objects = CaseTestModel.objects.annotate( selected=Case( When(pk__in=[], then=Value('selected')), - default=Value('not selected'), output_field=CharField() + default=Value('not selected'), ) ) self.assertEqual(len(objects), CaseTestModel.objects.count()) @@ -291,7 +280,6 @@ class CaseExpressionTests(TestCase): When(integer=1, then=2), When(integer=2, then=1), default=3, - output_field=IntegerField(), ) + 1, ).order_by('pk'), [(1, 3), (2, 2), (3, 4), (2, 2), (3, 4), (3, 4), (4, 4)], @@ -305,7 +293,6 @@ class CaseExpressionTests(TestCase): test=Case( When(integer=F('integer2'), then='pk'), When(integer=4, then='pk'), - output_field=IntegerField(), ), ).values('test')).order_by('pk'), [(1, 1), (2, 2), (3, 3), (4, 5)], @@ -327,7 +314,6 @@ class CaseExpressionTests(TestCase): SOME_CASE = Case( When(pk=0, then=Value('0')), default=Value('1'), - output_field=CharField(), ) self.assertQuerysetEqual( CaseTestModel.objects.annotate(somecase=SOME_CASE).order_by('pk'), @@ -340,19 +326,15 @@ class CaseExpressionTests(TestCase): CaseTestModel.objects.aggregate( one=Sum(Case( When(integer=1, then=1), - output_field=IntegerField(), )), two=Sum(Case( When(integer=2, then=1), - output_field=IntegerField(), )), three=Sum(Case( When(integer=3, then=1), - output_field=IntegerField(), )), four=Sum(Case( When(integer=4, then=1), - output_field=IntegerField(), )), ), {'one': 1, 'two': 2, 'three': 3, 'four': 1} @@ -373,11 +355,9 @@ class CaseExpressionTests(TestCase): CaseTestModel.objects.aggregate( equal=Sum(Case( When(integer2=F('integer'), then=1), - output_field=IntegerField(), )), plus_one=Sum(Case( When(integer2=F('integer') + 1, then=1), - output_field=IntegerField(), )), ), {'equal': 3, 'plus_one': 4} @@ -389,7 +369,6 @@ class CaseExpressionTests(TestCase): When(integer=2, then=3), When(integer=3, then=4), default=1, - output_field=IntegerField(), )).order_by('pk'), [(1, 1), (2, 3), (3, 4), (3, 4)], transform=attrgetter('integer', 'integer2') @@ -400,7 +379,6 @@ class CaseExpressionTests(TestCase): CaseTestModel.objects.filter(integer2=Case( When(integer=2, then=3), When(integer=3, then=4), - output_field=IntegerField(), )).order_by('pk'), [(2, 3), (3, 4), (3, 4)], transform=attrgetter('integer', 'integer2') @@ -422,7 +400,6 @@ class CaseExpressionTests(TestCase): CaseTestModel.objects.filter(string=Case( When(integer2=F('integer'), then=Value('2')), When(integer2=F('integer') + 1, then=Value('3')), - output_field=CharField(), )).order_by('pk'), [(3, 4, '3'), (2, 2, '2'), (3, 4, '3')], transform=attrgetter('integer', 'integer2', 'string') @@ -444,7 +421,6 @@ class CaseExpressionTests(TestCase): CaseTestModel.objects.filter(integer=Case( When(integer2=F('o2o_rel__integer') + 1, then=2), When(integer2=F('o2o_rel__integer'), then=3), - output_field=IntegerField(), )).order_by('pk'), [(2, 3), (3, 3)], transform=attrgetter('integer', 'integer2') @@ -456,7 +432,6 @@ class CaseExpressionTests(TestCase): When(o2o_rel__integer=1, then=1), When(o2o_rel__integer=2, then=3), When(o2o_rel__integer=3, then=4), - output_field=IntegerField(), )).order_by('pk'), [(1, 1), (2, 3), (3, 4), (3, 4)], transform=attrgetter('integer', 'integer2') @@ -485,7 +460,6 @@ class CaseExpressionTests(TestCase): integer=Case( When(integer2=F('integer'), then=2), When(integer2=F('f_plus_1'), then=3), - output_field=IntegerField(), ), ).order_by('pk'), [(3, 4), (2, 2), (3, 4)], @@ -501,7 +475,6 @@ class CaseExpressionTests(TestCase): When(f_plus_1=3, then=3), When(f_plus_1=4, then=4), default=1, - output_field=IntegerField(), ), ).order_by('pk'), [(1, 1), (2, 3), (3, 4), (3, 4)], @@ -612,7 +585,6 @@ class CaseExpressionTests(TestCase): integer=Case( When(integer2=F('o2o_rel__integer') + 1, then=2), When(integer2=F('o2o_rel__integer'), then=3), - output_field=IntegerField(), ), ) @@ -624,7 +596,6 @@ class CaseExpressionTests(TestCase): When(o2o_rel__integer=2, then=Value('two')), When(o2o_rel__integer=3, then=Value('three')), default=Value('other'), - output_field=CharField(), ), ) @@ -644,9 +615,9 @@ class CaseExpressionTests(TestCase): def test_update_binary(self): CaseTestModel.objects.update( binary=Case( - When(integer=1, then=Value(b'one', output_field=BinaryField())), - When(integer=2, then=Value(b'two', output_field=BinaryField())), - default=Value(b'', output_field=BinaryField()), + When(integer=1, then=b'one'), + When(integer=2, then=b'two'), + default=b'', ), ) self.assertQuerysetEqual( @@ -725,10 +696,8 @@ class CaseExpressionTests(TestCase): def test_update_duration(self): CaseTestModel.objects.update( duration=Case( - # fails on sqlite if output_field is not set explicitly on all - # Values containing timedeltas - When(integer=1, then=Value(timedelta(1), output_field=DurationField())), - When(integer=2, then=Value(timedelta(2), output_field=DurationField())), + When(integer=1, then=timedelta(1)), + When(integer=2, then=timedelta(2)), ), ) self.assertQuerysetEqual( @@ -808,7 +777,6 @@ class CaseExpressionTests(TestCase): def test_update_generic_ip_address(self): CaseTestModel.objects.update( generic_ip_address=Case( - # fails on postgresql if output_field is not set explicitly When(integer=1, then=Value('1.1.1.1')), When(integer=2, then=Value('2.2.2.2')), output_field=GenericIPAddressField(), @@ -915,8 +883,8 @@ class CaseExpressionTests(TestCase): def test_update_string(self): CaseTestModel.objects.filter(string__in=['1', '2']).update( string=Case( - When(integer=1, then=Value('1', output_field=CharField())), - When(integer=2, then=Value('2', output_field=CharField())), + When(integer=1, then=Value('1')), + When(integer=2, then=Value('2')), ), ) self.assertQuerysetEqual( @@ -942,10 +910,8 @@ class CaseExpressionTests(TestCase): def test_update_time(self): CaseTestModel.objects.update( time=Case( - # fails on sqlite if output_field is not set explicitly on all - # Values containing times - When(integer=1, then=Value(time(1), output_field=TimeField())), - When(integer=2, then=Value(time(2), output_field=TimeField())), + When(integer=1, then=time(1)), + When(integer=2, then=time(2)), ), ) self.assertQuerysetEqual( @@ -974,16 +940,8 @@ class CaseExpressionTests(TestCase): def test_update_uuid(self): CaseTestModel.objects.update( uuid=Case( - # fails on sqlite if output_field is not set explicitly on all - # Values containing UUIDs - When(integer=1, then=Value( - UUID('11111111111111111111111111111111'), - output_field=UUIDField(), - )), - When(integer=2, then=Value( - UUID('22222222222222222222222222222222'), - output_field=UUIDField(), - )), + When(integer=1, then=UUID('11111111111111111111111111111111')), + When(integer=2, then=UUID('22222222222222222222222222222222')), ), ) self.assertQuerysetEqual( @@ -1022,7 +980,6 @@ class CaseExpressionTests(TestCase): When(integer__lt=2, then=Value('less than 2')), When(integer__gt=2, then=Value('greater than 2')), default=Value('equal to 2'), - output_field=CharField(), ), ).order_by('pk'), [ @@ -1038,7 +995,6 @@ class CaseExpressionTests(TestCase): test=Case( When(integer=2, integer2=3, then=Value('when')), default=Value('default'), - output_field=CharField(), ), ).order_by('pk'), [ @@ -1054,7 +1010,6 @@ class CaseExpressionTests(TestCase): test=Case( When(Q(integer=2) | Q(integer2=3), then=Value('when')), default=Value('default'), - output_field=CharField(), ), ).order_by('pk'), [ @@ -1070,7 +1025,6 @@ class CaseExpressionTests(TestCase): When(integer=1, then=2), When(integer=2, then=1), default=3, - output_field=IntegerField(), )).order_by('test', 'pk'), [(2, 1), (2, 1), (1, 2)], transform=attrgetter('integer', 'test') @@ -1082,7 +1036,6 @@ class CaseExpressionTests(TestCase): When(integer=1, then=2), When(integer=2, then=1), default=3, - output_field=IntegerField(), )).order_by(F('test').asc(), 'pk'), [(2, 1), (2, 1), (1, 2)], transform=attrgetter('integer', 'test') @@ -1101,7 +1054,6 @@ class CaseExpressionTests(TestCase): foo=Case( When(fk_rel__pk=1, then=2), default=3, - output_field=IntegerField() ), ), [(o, 3)], @@ -1113,7 +1065,6 @@ class CaseExpressionTests(TestCase): foo=Case( When(fk_rel__isnull=True, then=2), default=3, - output_field=IntegerField() ), ), [(o, 2)], @@ -1133,12 +1084,10 @@ class CaseExpressionTests(TestCase): foo=Case( When(fk_rel__pk=1, then=2), default=3, - output_field=IntegerField() ), bar=Case( When(fk_rel__pk=1, then=4), default=5, - output_field=IntegerField() ), ), [(o, 3, 5)], @@ -1150,12 +1099,10 @@ class CaseExpressionTests(TestCase): foo=Case( When(fk_rel__isnull=True, then=2), default=3, - output_field=IntegerField() ), bar=Case( When(fk_rel__isnull=True, then=4), default=5, - output_field=IntegerField() ), ), [(o, 2, 4)], @@ -1167,7 +1114,6 @@ class CaseExpressionTests(TestCase): qs = CaseTestModel.objects.values_list('id', 'integer').annotate( cnt=Sum( Case(When(~Q(fk_rel__integer=1), then=1), default=2), - output_field=IntegerField() ), ).order_by('integer') # The first o has 2 as its fk_rel__integer=1, thus it hits the @@ -1189,12 +1135,10 @@ class CaseExpressionTests(TestCase): qs = CaseTestModel.objects.values_list('id', 'integer').annotate( cnt=Sum( Case(When(~Q(fk_rel__integer=1), then=1), default=2), - output_field=IntegerField() ), ).annotate( cnt2=Sum( Case(When(~Q(fk_rel__integer=1), then=1), default=2), - output_field=IntegerField() ), ).order_by('integer') self.assertEqual(str(qs.query).count(' JOIN '), 1) @@ -1231,7 +1175,6 @@ class CaseDocumentationExamples(TestCase): When(account_type=Client.GOLD, then=Value('5%')), When(account_type=Client.PLATINUM, then=Value('10%')), default=Value('0%'), - output_field=CharField(), ), ).order_by('pk'), [('Jane Doe', '0%'), ('James Smith', '5%'), ('Jack Black', '10%')], @@ -1247,7 +1190,6 @@ class CaseDocumentationExamples(TestCase): When(registered_on__lte=a_year_ago, then=Value('10%')), When(registered_on__lte=a_month_ago, then=Value('5%')), default=Value('0%'), - output_field=CharField(), ), ).order_by('pk'), [('Jane Doe', '5%'), ('James Smith', '0%'), ('Jack Black', '10%')], @@ -1299,15 +1241,12 @@ class CaseDocumentationExamples(TestCase): Client.objects.aggregate( regular=Sum(Case( When(account_type=Client.REGULAR, then=1), - output_field=IntegerField(), )), gold=Sum(Case( When(account_type=Client.GOLD, then=1), - output_field=IntegerField(), )), platinum=Sum(Case( When(account_type=Client.PLATINUM, then=1), - output_field=IntegerField(), )), ), {'regular': 2, 'gold': 1, 'platinum': 3} @@ -1360,9 +1299,9 @@ class CaseWhenTests(SimpleTestCase): with self.assertRaisesMessage(TypeError, msg): When(condition=object()) with self.assertRaisesMessage(TypeError, msg): - When(condition=Value(1, output_field=IntegerField())) + When(condition=Value(1)) with self.assertRaisesMessage(TypeError, msg): - When(Value(1, output_field=IntegerField()), string='1') + When(Value(1), string='1') with self.assertRaisesMessage(TypeError, msg): When() diff --git a/tests/postgres_tests/test_ranges.py b/tests/postgres_tests/test_ranges.py index 7257d66505..14dc75c998 100644 --- a/tests/postgres_tests/test_ranges.py +++ b/tests/postgres_tests/test_ranges.py @@ -170,7 +170,7 @@ class TestRangeContainsLookup(PostgreSQLTestCase): self.aware_timestamps[1], (self.timestamps[1], self.timestamps[2]), (self.aware_timestamps[1], self.aware_timestamps[2]), - Value(self.dates[0], output_field=DateTimeField()), + Value(self.dates[0]), Func(F('dates'), function='lower', output_field=DateTimeField()), F('timestamps_inner'), )