Ticket #33902: ticket-33902-regression.diff

File ticket-33902-regression.diff, 981 bytes (added by Mariusz Felisiak, 2 years ago)

Regression test.

  • tests/constraints/tests.py

    diff --git a/tests/constraints/tests.py b/tests/constraints/tests.py
    index 4032b418b4..d4054dfd77 100644
    a b class UniqueConstraintTests(TestCase):  
    685685            exclude={"color"},
    686686        )
    687687
     688    def test_validate_expression_str(self):
     689        constraint = models.UniqueConstraint("name", name="name_uniq")
     690        msg = "Constraint “name_uniq” is violated."
     691        with self.assertRaisesMessage(ValidationError, msg):
     692            constraint.validate(
     693                UniqueConstraintProduct,
     694                UniqueConstraintProduct(name=self.p1.name),
     695            )
     696        constraint.validate(
     697            UniqueConstraintProduct,
     698            UniqueConstraintProduct(name=self.p1.name),
     699            exclude={"name"},
     700        )
     701
    688702    def test_name(self):
    689703        constraints = get_constraints(UniqueConstraintProduct._meta.db_table)
    690704        expected_name = "name_color_uniq"
Back to Top