Refs #30581 -- Moved CheckConstraint tests for conditional expressions to migrations.test_operations.

This allows avoiding warning in tests about using RawSQL in
CheckConstraints.
This commit is contained in:
Mariusz Felisiak 2022-05-05 06:44:34 +02:00 committed by GitHub
parent c5cc750b56
commit 27b07a3246
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 27 deletions

View file

@ -103,18 +103,6 @@ class CheckConstraintTests(TestCase):
with self.assertRaises(IntegrityError):
Product.objects.create(price=10, discounted_price=7, unit="l")
@skipUnlessDBFeature("supports_table_check_constraints")
def test_database_constraint_expression(self):
Product.objects.create(price=999, discounted_price=5)
with self.assertRaises(IntegrityError):
Product.objects.create(price=1000, discounted_price=5)
@skipUnlessDBFeature("supports_table_check_constraints")
def test_database_constraint_expressionwrapper(self):
Product.objects.create(price=499, discounted_price=5)
with self.assertRaises(IntegrityError):
Product.objects.create(price=500, discounted_price=5)
@skipUnlessDBFeature(
"supports_table_check_constraints", "can_introspect_check_constraints"
)
@ -122,8 +110,6 @@ class CheckConstraintTests(TestCase):
constraints = get_constraints(Product._meta.db_table)
for expected_name in (
"price_gt_discounted_price",
"constraints_price_lt_1000_raw",
"constraints_price_neq_500_wrap",
"constraints_product_price_gt_0",
):
with self.subTest(expected_name):