@@ -62,14 +62,18 @@ def __init__(
62
62
def __repr__ (self ):
63
63
return "<%s: %r>" % (self .__class__ .__name__ , self .message )
64
64
65
- def __unicode__ (self ):
65
+ def formatted_message (self , pretty = False ):
66
66
essential_for_verbose = (
67
67
self .validator , self .validator_value , self .instance , self .schema ,
68
68
)
69
69
if any (m is _unset for m in essential_for_verbose ):
70
70
return self .message
71
71
72
- pschema = json .dumps (self .schema , separators = (',\n ' , ': ' ), sort_keys = True )
72
+ if (pretty is True ):
73
+ pschema = json .dumps (self .schema , separators = (',\n ' , ': ' ), sort_keys = True )
74
+ else :
75
+ pschema = pprint .pformat (self .schema , width = 72 )
76
+
73
77
pinstance = pprint .pformat (self .instance , width = 72 )
74
78
return self .message + textwrap .dedent ("""
75
79
@@ -89,6 +93,9 @@ def __unicode__(self):
89
93
_utils .indent (pinstance ),
90
94
)
91
95
96
+ def __unicode__ (self ):
97
+ return self .formatted_message (pretty = False )
98
+
92
99
if PY3 :
93
100
__str__ = __unicode__
94
101
else :
@@ -201,7 +208,7 @@ def __init__(self, type, instance, schema):
201
208
self .schema = schema
202
209
203
210
def __unicode__ (self ):
204
- pschema = json . dumps (self .schema , separators = ( ', \n ' , ': ' ), sort_keys = True )
211
+ pschema = pprint . pformat (self .schema , width = 72 )
205
212
pinstance = pprint .pformat (self .instance , width = 72 )
206
213
return textwrap .dedent ("""
207
214
Unknown type %r for validator with schema:
0 commit comments