mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Refs #35234 -- Removed CheckConstraint.check per deprecation timeline.
This commit is contained in:
parent
4968f0012e
commit
85750bd2f8
4 changed files with 3 additions and 56 deletions
|
@ -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"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue