Skip to content

Commit 2eadcc3

Browse files
committed
Skip the new unicode tests on narrow builds which don't know about surrogates.
1 parent 161f307 commit 2eadcc3

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

jsonschema/tests/test_jsonschema_test_suite.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import os
1717
import re
1818
import subprocess
19+
import sys
1920

2021
try:
2122
from sys import pypy_version_info
@@ -73,12 +74,12 @@ def test_case(self):
7374
return test_case
7475

7576

76-
def maybe_skip(skip, test, case):
77+
def maybe_skip(skip, test_case, case, test):
7778
if skip is not None:
78-
reason = skip(case)
79+
reason = skip(case, test)
7980
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
8283

8384

8485
def load_json_cases(tests_glob, ignore_glob="", basedir=TESTS_DIR, skip=None):
@@ -111,7 +112,7 @@ def add_test_methods(test_class):
111112
valid=test["valid"],
112113
name=name,
113114
)
114-
test_case = maybe_skip(skip, test_case, case)
115+
test_case = maybe_skip(skip, test_case, case, test)
115116
setattr(test_class, name, test_case)
116117

117118
return test_class
@@ -140,7 +141,7 @@ def test_it_can_validate_with_decimals(self):
140141

141142

142143
def missing_format(checker):
143-
def missing_format(case):
144+
def missing_format(case, test):
144145
format = case["schema"].get("format")
145146
if format not in checker.checkers:
146147
return "Format checker {0!r} not found.".format(format)
@@ -202,7 +203,20 @@ def test_it_validates_formats_of_any_type(self):
202203
self.assertIs(cm.exception.cause, cause)
203204

204205

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+
)
206220
@load_json_cases(
207221
"draft3/optional/format.json", skip=missing_format(draft3_format_checker)
208222
)
@@ -228,7 +242,11 @@ def test_minItems_invalid_string(self):
228242
validate([1], {"minItems" : "1"}, cls=self.validator_class)
229243

230244

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+
)
232250
@load_json_cases(
233251
"draft4/optional/format.json", skip=missing_format(draft4_format_checker)
234252
)

0 commit comments

Comments
 (0)