File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change 18
18
import json
19
19
import numbers
20
20
import operator
21
+ import pprint
21
22
import re
22
23
import socket
23
24
import sys
@@ -108,7 +109,31 @@ def __str__(self):
108
109
return unicode (self ).encode ("utf-8" )
109
110
110
111
def __unicode__ (self ):
111
- return self .message
112
+ schema_path = ""
113
+ if len (self .schema_path ) > 1 :
114
+ schema_path = (
115
+ "[%s]" % "][" .join (
116
+ map (repr , list (self .schema_path )[:- 1 ])
117
+ )
118
+ )
119
+ path = ""
120
+ if self .path :
121
+ path = "[%s]" % "][" .join (map (repr , self .path ))
122
+ pschema = pprint .pformat (self .schema , width = 72 )
123
+ pinstance = pprint .pformat (self .instance , width = 72 )
124
+ return textwrap .dedent ("""\
125
+ %s: %s
126
+ Failed validating '%s' in schema%s:
127
+ %s
128
+ On instance%s:
129
+ %s
130
+ """ ) % (
131
+ self .__class__ .__name__ , self .message ,
132
+ self .validator , schema_path ,
133
+ textwrap .indent (pschema , " " * 8 ),
134
+ path ,
135
+ textwrap .indent (pinstance , " " * 8 )
136
+ )
112
137
113
138
if PY3 :
114
139
__str__ = __unicode__
You can’t perform that action at this time.
0 commit comments