From 9142bebff2657f2129a2028137f81d09db989968 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Sun, 5 Aug 2018 22:15:10 -0400 Subject: Refs #11964 -- Changed CheckConstraint() signature to use keyword-only arguments. Also renamed the `constraint` argument to `check` to better represent which part of the constraint the provided `Q` object represents. --- tests/constraints/models.py | 6 +++--- tests/constraints/tests.py | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'tests/constraints') diff --git a/tests/constraints/models.py b/tests/constraints/models.py index de49fa2765..08fbe9e1df 100644 --- a/tests/constraints/models.py +++ b/tests/constraints/models.py @@ -9,7 +9,7 @@ class Product(models.Model): class Meta: constraints = [ models.CheckConstraint( - models.Q(price__gt=models.F('discounted_price')), - 'price_gt_discounted_price' - ) + check=models.Q(price__gt=models.F('discounted_price')), + name='price_gt_discounted_price', + ), ] diff --git a/tests/constraints/tests.py b/tests/constraints/tests.py index 908f0aaf38..6bff8ce042 100644 --- a/tests/constraints/tests.py +++ b/tests/constraints/tests.py @@ -6,22 +6,22 @@ from .models import Product class CheckConstraintTests(TestCase): def test_repr(self): - constraint = models.Q(price__gt=models.F('discounted_price')) + check = models.Q(price__gt=models.F('discounted_price')) name = 'price_gt_discounted_price' - check = models.CheckConstraint(constraint, name) + constraint = models.CheckConstraint(check=check, name=name) self.assertEqual( - repr(check), - "".format(constraint, name), + repr(constraint), + "".format(check, name), ) def test_deconstruction(self): - constraint = models.Q(price__gt=models.F('discounted_price')) + check = models.Q(price__gt=models.F('discounted_price')) name = 'price_gt_discounted_price' - check = models.CheckConstraint(constraint, name) - path, args, kwargs = check.deconstruct() + constraint = models.CheckConstraint(check=check, name=name) + path, args, kwargs = constraint.deconstruct() self.assertEqual(path, 'django.db.models.CheckConstraint') self.assertEqual(args, ()) - self.assertEqual(kwargs, {'constraint': constraint, 'name': name}) + self.assertEqual(kwargs, {'check': check, 'name': name}) @skipUnlessDBFeature('supports_table_check_constraints') def test_database_constraint(self): -- cgit v1.2.1