As of now, Hypothesis does not seem to guarantee that it actually tests the type for Pydantic model fields with type Optional[T] with default value None. It seems to test with None only.
This will require a somewhat large change to both the existing unit tests and the testing regime in general. Any new tests following this change will be required to use hypothesis-jsonschema. We could potentially also make use of st.register_type_strategy() to register the type strategy after inferring the strategy from the schema, so that other tests can simply use st.from_type()
As of now, Hypothesis does not seem to guarantee that it actually tests the type for Pydantic model fields with type
Optional[T]
with default valueNone
. It seems to test withNone
only.Using the solution outlined in this issue, we can use hypothesis-jsonschema to generate the required values.
This will require a somewhat large change to both the existing unit tests and the testing regime in general. Any new tests following this change will be required to use hypothesis-jsonschema. We could potentially also make use of
st.register_type_strategy()
to register the type strategy after inferring the strategy from the schema, so that other tests can simply usest.from_type()