def test_VerboseRegexField_validation_error_includes_value(self): message = "Unknown value: %(value)s" field = VerboseRegexField(regex="test", message=message) value = factory.make_name("value") error = self.assertRaises(ValidationError, field.clean, value) self.assertEqual([message % {"value": value}], error.messages)
def test_VerboseRegexField_accepts_valid_value(self): field = VerboseRegexField(regex="test", message="Unknown value") self.assertEqual("test", field.clean("test"))