Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure T and None are tested for fields with type Optional[T] #13

Open
pederhan opened this issue Dec 19, 2022 · 0 comments
Open

Ensure T and None are tested for fields with type Optional[T] #13

pederhan opened this issue Dec 19, 2022 · 0 comments
Labels
bug Something isn't working enhancement New feature or request tests Unit and integration testing

Comments

@pederhan
Copy link
Member

pederhan commented Dec 19, 2022

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()

@pederhan pederhan added bug Something isn't working enhancement New feature or request tests Unit and integration testing labels Dec 19, 2022
@pederhan pederhan added this to Harbor Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request tests Unit and integration testing
Projects
None yet
Development

No branches or pull requests

1 participant