Refs #35234 -- Removed CheckConstraint.check per deprecation timeline.

This commit is contained in:
Sarah Boyce 2024-12-13 09:30:29 +01:00
parent 4968f0012e
commit 85750bd2f8
4 changed files with 3 additions and 56 deletions

View file

@ -7,8 +7,6 @@ from django.db.models.constraints import BaseConstraint, UniqueConstraint
from django.db.models.functions import Abs, Lower, Sqrt, Upper
from django.db.transaction import atomic
from django.test import SimpleTestCase, TestCase, skipIfDBFeature, skipUnlessDBFeature
from django.test.utils import ignore_warnings
from django.utils.deprecation import RemovedInDjango60Warning
from .models import (
ChildModel,
@ -399,23 +397,6 @@ class CheckConstraintTests(TestCase):
constraint.validate(model, invalid_product, exclude={"price"})
constraint.validate(model, invalid_product, exclude={"rebate"})
def test_check_deprecation(self):
msg = "CheckConstraint.check is deprecated in favor of `.condition`."
condition = models.Q(foo="bar")
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
constraint = models.CheckConstraint(name="constraint", check=condition)
self.assertEqual(ctx.filename, __file__)
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
self.assertIs(constraint.check, condition)
self.assertEqual(ctx.filename, __file__)
other_condition = models.Q(something="else")
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
constraint.check = other_condition
self.assertEqual(ctx.filename, __file__)
with self.assertWarnsMessage(RemovedInDjango60Warning, msg) as ctx:
self.assertIs(constraint.check, other_condition)
self.assertEqual(ctx.filename, __file__)
def test_database_default(self):
models.CheckConstraint(
condition=models.Q(field_with_db_default="field_with_db_default"),