16
16
import os
17
17
import re
18
18
import subprocess
19
+ import sys
19
20
20
21
try :
21
22
from sys import pypy_version_info
@@ -73,12 +74,12 @@ def test_case(self):
73
74
return test_case
74
75
75
76
76
- def maybe_skip (skip , test , case ):
77
+ def maybe_skip (skip , test_case , case , test ):
77
78
if skip is not None :
78
- reason = skip (case )
79
+ reason = skip (case , test )
79
80
if reason is not None :
80
- test = unittest .skip (reason )(test )
81
- return test
81
+ test_case = unittest .skip (reason )(test_case )
82
+ return test_case
82
83
83
84
84
85
def load_json_cases (tests_glob , ignore_glob = "" , basedir = TESTS_DIR , skip = None ):
@@ -111,7 +112,7 @@ def add_test_methods(test_class):
111
112
valid = test ["valid" ],
112
113
name = name ,
113
114
)
114
- test_case = maybe_skip (skip , test_case , case )
115
+ test_case = maybe_skip (skip , test_case , case , test )
115
116
setattr (test_class , name , test_case )
116
117
117
118
return test_class
@@ -140,7 +141,7 @@ def test_it_can_validate_with_decimals(self):
140
141
141
142
142
143
def missing_format (checker ):
143
- def missing_format (case ):
144
+ def missing_format (case , test ):
144
145
format = case ["schema" ].get ("format" )
145
146
if format not in checker .checkers :
146
147
return "Format checker {0!r} not found." .format (format )
@@ -202,7 +203,20 @@ def test_it_validates_formats_of_any_type(self):
202
203
self .assertIs (cm .exception .cause , cause )
203
204
204
205
205
- @load_json_cases ("draft3/*.json" , ignore_glob = "draft3/refRemote.json" )
206
+ if sys .maxunicode == 2 ** 16 - 1 : # This is a narrow build.
207
+ def narrow_unicode_build (case , test ):
208
+ if "supplementary Unicode" in test ["description" ]:
209
+ return "Not running surrogate Unicode case, this Python is narrow."
210
+ else :
211
+ def narrow_unicode_build (case , test ): # This isn't, skip nothing.
212
+ return
213
+
214
+
215
+ @load_json_cases (
216
+ "draft3/*.json" ,
217
+ skip = narrow_unicode_build ,
218
+ ignore_glob = "draft3/refRemote.json" ,
219
+ )
206
220
@load_json_cases (
207
221
"draft3/optional/format.json" , skip = missing_format (draft3_format_checker )
208
222
)
@@ -228,7 +242,11 @@ def test_minItems_invalid_string(self):
228
242
validate ([1 ], {"minItems" : "1" }, cls = self .validator_class )
229
243
230
244
231
- @load_json_cases ("draft4/*.json" , ignore_glob = "draft4/refRemote.json" )
245
+ @load_json_cases (
246
+ "draft4/*.json" ,
247
+ skip = narrow_unicode_build ,
248
+ ignore_glob = "draft4/refRemote.json" ,
249
+ )
232
250
@load_json_cases (
233
251
"draft4/optional/format.json" , skip = missing_format (draft4_format_checker )
234
252
)
0 commit comments