|
@@ -9,9 +9,10 @@ from django.db.models import Max
|
|
|
from django.db.models.expressions import Exists, OuterRef
|
|
|
from django.db.models.functions import Substr
|
|
|
from django.test import TestCase, skipUnlessDBFeature
|
|
|
+from django.utils.deprecation import RemovedInDjango40Warning
|
|
|
|
|
|
from .models import (
|
|
|
- Article, Author, Game, IsNullWithNoneAsRHS, Player, Season, Tag,
|
|
|
+ Article, Author, Freebie, Game, IsNullWithNoneAsRHS, Player, Season, Tag,
|
|
|
)
|
|
|
|
|
|
|
|
@@ -969,3 +970,24 @@ class LookupTests(TestCase):
|
|
|
).values('max_id')
|
|
|
authors = Author.objects.filter(id=authors_max_ids[:1])
|
|
|
self.assertEqual(authors.get(), newest_author)
|
|
|
+
|
|
|
+ def test_isnull_non_boolean_value(self):
|
|
|
+ # These tests will catch ValueError in Django 4.0 when using
|
|
|
+ # non-boolean values for an isnull lookup becomes forbidden.
|
|
|
+ # msg = (
|
|
|
+ # 'The QuerySet value for an isnull lookup must be True or False.'
|
|
|
+ # )
|
|
|
+ msg = (
|
|
|
+ 'Using a non-boolean value for an isnull lookup is deprecated, '
|
|
|
+ 'use True or False instead.'
|
|
|
+ )
|
|
|
+ tests = [
|
|
|
+ Author.objects.filter(alias__isnull=1),
|
|
|
+ Article.objects.filter(author__isnull=1),
|
|
|
+ Season.objects.filter(games__isnull=1),
|
|
|
+ Freebie.objects.filter(stock__isnull=1),
|
|
|
+ ]
|
|
|
+ for qs in tests:
|
|
|
+ with self.subTest(qs=qs):
|
|
|
+ with self.assertWarnsMessage(RemovedInDjango40Warning, msg):
|
|
|
+ qs.exists()
|