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(
9797) -> st .SearchStrategy [str ]:
9898 def check_valid (string : str ) -> str :
9999 try :
100- assert isinstance (string , str )
100+ if not isinstance (string , str ):
101+ raise jsonschema .FormatError (f"{ string !r} is not a string" )
101102 checker .check (string , format = format_name )
102- except ( AssertionError , jsonschema .FormatError ) as err :
103+ except jsonschema .FormatError as err :
103104 raise InvalidArgument (
104105 f"Got string={ string !r} from strategy { strategy !r} , but this "
105106 f"is not a valid value for the { format_name !r} checker."
@@ -136,8 +137,6 @@ def __from_schema(
136137 format_checker = jsonschema .FormatChecker ()
137138 custom_formats = {
138139 name : _get_format_filter (name , format_checker , strategy )
139- if name in format_checker .checkers
140- else strategy
141140 for name , strategy in custom_formats .items ()
142141 }
143142 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):
432432 {5 : st .just ("name is not a string" )},
433433 {"full-date" : st .just ("2000-01-01" )}, # can't override a standard format
434434 {"card-test" : st .just ("not a valid card" )},
435+ {"card-test" : st .none ()}, # Not a string
435436 ],
436437)
437438@given (data = st .data ())
You can’t perform that action at this time.
0 commit comments