File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
src/hypothesis_jsonschema Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -97,9 +97,10 @@ def _get_format_filter(
97
97
) -> st .SearchStrategy [str ]:
98
98
def check_valid (string : str ) -> str :
99
99
try :
100
- assert isinstance (string , str )
100
+ if not isinstance (string , str ):
101
+ raise jsonschema .FormatError (f"{ string !r} is not a string" )
101
102
checker .check (string , format = format_name )
102
- except ( AssertionError , jsonschema .FormatError ) as err :
103
+ except jsonschema .FormatError as err :
103
104
raise InvalidArgument (
104
105
f"Got string={ string !r} from strategy { strategy !r} , but this "
105
106
f"is not a valid value for the { format_name !r} checker."
@@ -136,8 +137,6 @@ def __from_schema(
136
137
format_checker = jsonschema .FormatChecker ()
137
138
custom_formats = {
138
139
name : _get_format_filter (name , format_checker , strategy )
139
- if name in format_checker .checkers
140
- else strategy
141
140
for name , strategy in custom_formats .items ()
142
141
}
143
142
custom_formats [_FORMATS_TOKEN ] = None # type: ignore
Original file line number Diff line number Diff line change @@ -432,6 +432,7 @@ def validate_card_format(string):
432
432
{5 : st .just ("name is not a string" )},
433
433
{"full-date" : st .just ("2000-01-01" )}, # can't override a standard format
434
434
{"card-test" : st .just ("not a valid card" )},
435
+ {"card-test" : st .none ()}, # Not a string
435
436
],
436
437
)
437
438
@given (data = st .data ())
You can’t perform that action at this time.
0 commit comments