Skip to content

Commit 31a2ca2

Browse files
committed
I think this also will help.
1 parent 164ff42 commit 31a2ca2

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

jsonschema/tests/_suite.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,9 @@ def optional_tests_of(self, name):
113113

114114
def to_unittest_testcase(self, *suites, **kwargs):
115115
name = kwargs.pop("name", "Test" + self.name.title())
116-
skip = kwargs.pop("skip", lambda test: None)
116+
kwargs.setdefault("skip", lambda test: None)
117117
methods = {
118-
test.method_name: _maybe_skip(skip(test))(
119-
test.to_unittest_method(**kwargs),
120-
)
118+
test.method_name: test.to_unittest_method(**kwargs)
121119
for suite in suites
122120
for tests in suite
123121
for test in tests
@@ -180,7 +178,7 @@ def method_name(self):
180178
name = name.encode("utf-8")
181179
return name
182180

183-
def to_unittest_method(self, **kwargs):
181+
def to_unittest_method(self, skip, **kwargs):
184182
if self.valid:
185183
def fn(this):
186184
self.validate(**kwargs)
@@ -190,7 +188,8 @@ def fn(this):
190188
self.validate(**kwargs)
191189

192190
fn.__name__ = self.method_name
193-
return fn
191+
reason = skip(self)
192+
return unittest.skipIf(reason is not None, reason)(fn)
194193

195194
def validate(self, Validator=None, **kwargs):
196195
resolver = jsonschema.RefResolver.from_schema(
@@ -209,7 +208,3 @@ def validate_ignoring_errors(self, **kwargs):
209208
self.validate(**kwargs)
210209
except jsonschema.ValidationError:
211210
pass
212-
213-
214-
def _maybe_skip(reason):
215-
return unittest.skipIf(reason is not None, reason)

0 commit comments

Comments
 (0)