mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Refs #29641 -- Extracted reusable CheckConstraint logic into a base class.
This commit is contained in:
committed by
Tim Graham
parent
9142bebff2
commit
24dc7d8940
@@ -1,9 +1,18 @@
|
||||
from django.db import IntegrityError, models
|
||||
from django.test import TestCase, skipUnlessDBFeature
|
||||
from django.db.models.constraints import BaseConstraint
|
||||
from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
|
||||
|
||||
from .models import Product
|
||||
|
||||
|
||||
class BaseConstraintTests(SimpleTestCase):
|
||||
def test_constraint_sql(self):
|
||||
c = BaseConstraint('name')
|
||||
msg = 'This method must be implemented by a subclass.'
|
||||
with self.assertRaisesMessage(NotImplementedError, msg):
|
||||
c.constraint_sql(None, None)
|
||||
|
||||
|
||||
class CheckConstraintTests(TestCase):
|
||||
def test_repr(self):
|
||||
check = models.Q(price__gt=models.F('discounted_price'))
|
||||
|
||||
Reference in New Issue
Block a user