def test_model_local_path_field_validator(self):
"""Test model 'local_path' field `RegexValidator`"""
instance = self.model()
field = instance._meta.get_field('local_path')
validator = field.validators[0]
assert isinstance(validator, RegexValidator)
assert validator.regex.pattern == '[a-zA-Z0-9/._-]+'
assert (
validator.message ==
"Allowed characters: a-z, A-Z, 0-9, slash (/), dot (.), "
"underscore (_) and hyphen (-)."
)
评论列表
文章目录