harborapi
harborapi copied to clipboard
Ensure `T` and `None` are tested for fields with type `Optional[T]`
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.
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 use st.from_type()