diff options
author | Simon Charette <charette.s@gmail.com> | 2018-08-05 22:15:10 -0400 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2018-10-02 10:53:04 -0400 |
commit | 9142bebff2657f2129a2028137f81d09db989968 (patch) | |
tree | 4d0ab0f5366d95f1d21e00ffdfe3fdfcf4eca787 /tests/constraints | |
parent | 0bf7b25f8f667d3710de91e91ae812efde05187c (diff) | |
download | django-9142bebff2657f2129a2028137f81d09db989968.tar.gz |
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.
Diffstat (limited to 'tests/constraints')
-rw-r--r-- | tests/constraints/models.py | 6 | ||||
-rw-r--r-- | tests/constraints/tests.py | 16 |
2 files changed, 11 insertions, 11 deletions
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), - "<CheckConstraint: constraint='{}' name='{}'>".format(constraint, name), + repr(constraint), + "<CheckConstraint: check='{}' name='{}'>".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): |