summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2018-08-05 22:12:27 -0400
committerTim Graham <timograham@gmail.com>2018-10-02 13:11:18 -0400
commit24dc7d89402d533474193fda9b1b999d00e9fb4f (patch)
tree08f74efcedb4a07bfbd48aa9cc67b72ad1f70c65 /tests
parent9142bebff2657f2129a2028137f81d09db989968 (diff)
Refs #29641 -- Extracted reusable CheckConstraint logic into a base class.
Diffstat (limited to 'tests')
-rw-r--r--tests/constraints/tests.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/constraints/tests.py b/tests/constraints/tests.py
index 6bff8ce042..28a5c4ba34 100644
--- a/tests/constraints/tests.py
+++ b/tests/constraints/tests.py
@@ -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'))