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

Add tests #7

Open
samuelcolvin opened this issue Aug 22, 2022 · 3 comments
Open

Add tests #7

samuelcolvin opened this issue Aug 22, 2022 · 3 comments

Comments

@samuelcolvin
Copy link

Hi, this question is quite selfish, I'd like to use this repo among others for smoke testing new pydantic releases, see pydantic/pydantic#4359. According to this this repo has the most pydantic imports, hence why I came here.

It would be great if we could add tests to this repo, I guess either (or both of):

  • add tests for a few specific examples
  • automate the build of models for all types (perhaps using hypothesis?) and compare to stored JSON schemas - this wouldn't immediately catch bugs, but it would catch changes, e.g. in new pydantic releases

WDYT?

@crbaker89
Copy link
Member

Hi @samuelcolvin. Great to hear from you, i have been using pydantic in so many projects 👍

In this repo there is already one test script that creates the extended BaseModel classes for all all schema.org examples located at (https://schema.org/version/latest/schemaorg-all-examples.txt). This script effectively checks if the examples provided by schema.org can be loaded into the Pydantic models. The script can be found here: https://github.com/lexiq-legal/pydantic_schemaorg/blob/main/src/test_classes.py.

All the models in this repo are already automatically build according to the Schema.org model definitions. Please do note that these Schema.org models use mostly primitive types and will not cover all of Pydantic's field types.

TL;DR: With a modifications on the existing code I can produce the tests you describe. Maybe you can provide me with a list of Pydantic features/mechanisms you would like to test first? I would be happy to contribute to Pydantic.

Cheers

@samuelcolvin
Copy link
Author

Thanks so much would be great if you could test against pydantic v1.10.0b1, more information at pydantic/pydantic#4419.

Ice now tested that release against quite a lot of libraries, so I doubt there will be a problem, but still busy to check.

Also as per the linked discussion, I'd like to build up a list of libraries I can easily test future pydantic releases against to avoid breaking changes.

@westurner
Copy link

westurner commented Feb 24, 2023

Might I suggest @pytest.mark.parametrize (and pytest-cov) or better?

/cc @danbri @RichardWallis @rvguha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants