unit tests of cred field types

This commit is contained in:
AlanCoding
2018-04-04 08:43:30 -04:00
parent ee8416140a
commit 996a5b20b0
3 changed files with 186 additions and 139 deletions

View File

@@ -396,10 +396,16 @@ class JSONSchemaField(JSONBField):
expected_type = error.validator_value
if expected_type == 'object':
expected_type = 'dict'
error.message = _(
'{type} provided in relative path {path}, expected {expected_type}'
).format(path=list(error.path), type=type(error.instance).__name__,
expected_type=expected_type)
if error.path:
error.message = _(
'{type} provided in relative path {path}, expected {expected_type}'
).format(path=list(error.path), type=type(error.instance).__name__,
expected_type=expected_type)
else:
error.message = _(
'{type} provided, expected {expected_type}'
).format(path=list(error.path), type=type(error.instance).__name__,
expected_type=expected_type)
errors.append(error)
if errors: