Skip to content

Commit 4a1212e

Browse files
committed
More generic skipping mechanism.
1 parent 1eb34d9 commit 4a1212e

File tree

1 file changed

+57
-66
lines changed

1 file changed

+57
-66
lines changed

jsonschema/tests/test_jsonschema_test_suite.py

Lines changed: 57 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,10 @@
3030
DRAFT7 = SUITE.version(name="draft7")
3131

3232

33-
def skip_tests_containing_descriptions(**kwargs):
33+
def skip(message, **kwargs):
3434
def skipper(test):
35-
descriptions_and_reasons = kwargs.get(test.subject, {})
36-
return next(
37-
(
38-
reason
39-
for description, reason in descriptions_and_reasons.items()
40-
if description in test.description
41-
),
42-
None,
43-
)
35+
if all(value in getattr(test, attr) for attr, value in kwargs.items()):
36+
return message
4437
return skipper
4538

4639

@@ -57,15 +50,9 @@ def missing_format(test):
5750

5851
is_narrow_build = sys.maxunicode == 2 ** 16 - 1
5952
if is_narrow_build: # pragma: no cover
60-
narrow_unicode_build = skip_tests_containing_descriptions(
61-
maxLength={
62-
"supplementary Unicode":
63-
"Not running surrogate Unicode case, this Python is narrow.",
64-
},
65-
minLength={
66-
"supplementary Unicode":
67-
"Not running surrogate Unicode case, this Python is narrow.",
68-
},
53+
narrow_unicode_build = skip(
54+
message="Not running surrogate Unicode case, this Python is narrow.",
55+
description="supplementary Unicode",
6956
)
7057
else:
7158
def narrow_unicode_build(test): # pragma: no cover
@@ -87,12 +74,12 @@ def bug(issue=None):
8774
Validator=Draft3Validator,
8875
format_checker=draft3_format_checker,
8976
skip=lambda test: (
90-
narrow_unicode_build(test) or
91-
missing_format(draft3_format_checker)(test) or
92-
skip_tests_containing_descriptions(
93-
format={
94-
"case-insensitive T and Z": "Upstream bug in strict_rfc3339",
95-
},
77+
narrow_unicode_build(test)
78+
or missing_format(draft3_format_checker)(test)
79+
or skip(
80+
message="Upstream bug in strict_rfc3339",
81+
subject="format",
82+
description="case-insensitive T and Z",
9683
)(test)
9784
),
9885
)
@@ -106,19 +93,22 @@ def bug(issue=None):
10693
Validator=Draft4Validator,
10794
format_checker=draft4_format_checker,
10895
skip=lambda test: (
109-
narrow_unicode_build(test) or
110-
missing_format(draft4_format_checker)(test) or
111-
skip_tests_containing_descriptions(
112-
format={
113-
"case-insensitive T and Z": "Upstream bug in strict_rfc3339",
114-
},
115-
ref={
116-
"valid tree": bug(),
117-
},
118-
refRemote={
119-
"number is valid": bug(),
120-
"string is invalid": bug(),
121-
},
96+
narrow_unicode_build(test)
97+
or missing_format(draft4_format_checker)(test)
98+
or skip(
99+
message=bug(),
100+
subject="ref",
101+
case_description="Recursive references between schemas",
102+
)(test)
103+
or skip(
104+
message=bug(),
105+
subject="refRemote",
106+
case_description="base URI change - change folder",
107+
)(test)
108+
or skip(
109+
message="Upstream bug in strict_rfc3339",
110+
subject="format",
111+
description="case-insensitive T and Z",
122112
)(test)
123113
),
124114
)
@@ -132,19 +122,22 @@ def bug(issue=None):
132122
Validator=Draft6Validator,
133123
format_checker=draft6_format_checker,
134124
skip=lambda test: (
135-
narrow_unicode_build(test) or
136-
missing_format(draft6_format_checker)(test) or
137-
skip_tests_containing_descriptions(
138-
format={
139-
"case-insensitive T and Z": "Upstream bug in strict_rfc3339",
140-
},
141-
ref={
142-
"valid tree": bug(),
143-
},
144-
refRemote={
145-
"number is valid": bug(),
146-
"string is invalid": bug(),
147-
},
125+
narrow_unicode_build(test)
126+
or missing_format(draft6_format_checker)(test)
127+
or skip(
128+
message=bug(),
129+
subject="ref",
130+
case_description="Recursive references between schemas",
131+
)(test)
132+
or skip(
133+
message=bug(),
134+
subject="refRemote",
135+
case_description="base URI change - change folder",
136+
)(test)
137+
or skip(
138+
message="Upstream bug in strict_rfc3339",
139+
subject="format",
140+
description="case-insensitive T and Z",
148141
)(test)
149142
),
150143
)
@@ -160,22 +153,20 @@ def bug(issue=None):
160153
skip=lambda test: (
161154
narrow_unicode_build(test)
162155
or missing_format(draft7_format_checker)(test)
163-
or skip_tests_containing_descriptions(
164-
ref={
165-
"valid tree": bug(),
166-
},
167-
refRemote={
168-
"number is valid": bug(),
169-
"string is invalid": bug(),
170-
},
156+
or skip(
157+
message=bug(),
158+
subject="ref",
159+
case_description="Recursive references between schemas",
160+
)(test)
161+
or skip(
162+
message=bug(),
163+
subject="refRemote",
164+
case_description="base URI change - change folder",
171165
)(test)
172-
or skip_tests_containing_descriptions(
173-
**{
174-
"date-time": {
175-
"case-insensitive T and Z":
176-
"Upstream bug in strict_rfc3339",
177-
},
178-
}
166+
or skip(
167+
message="Upstream bug in strict_rfc3339",
168+
subject="date-time",
169+
description="case-insensitive T and Z",
179170
)(test)
180171
),
181172
)

0 commit comments

Comments
 (0)