Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

✅ Useinline-snapshot to support different Pydantic versions in the test suite#12534

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

15r10nk
Copy link
Contributor

@15r10nk15r10nk commentedOct 24, 2024
edited
Loading

This pull-request contains an example how inline-snapshot can be used with different snapshots for different pydantic versions.

The following code can be used to create different snapshots for each pydantic version (pytest has to be run with both pydantic version).

assertsome_value==snapshot_pydantic(v1=snapshot(),v2=snapshot())

both snapshots will be created (see example in the pull-request).

@tiangolo
I would be interested if this approach looks useful to you, or if you prefer the current IsDict(...)|IsDict(...) pattern for some reason.

The next version of inline-snapshot will support things likesnapshot_pydantic() inside of snapshots. which will make the following code work:

assertresponse.json()==snapshot(        {"openapi":"3.1.0","info": {"title":"FastAPI","version":"0.1.0"},"paths": {"/items/": {"get": {"summary":"Read Items","operationId":"read_items_items__get","parameters": [                            {"name":"session_id","in":"cookie","required":True,"schema": {"type":"string","title":"Session Id"},                            },                            {"name":"fatebook_tracker","in":"cookie","required":False,"schema":snapshot_pydantic(v1=snapshot(),v2=snapshot()),                            },

Thank you for using inline-snapshot 😃.

tiangolo and svlandeg reacted with heart emoji
@15r10nk15r10nkforce-pushed theinline-snapshot-for-pydantic branch fromae68755 to8d1875bCompareOctober 24, 2024 20:03
@svlandegsvlandeg added the featureNew feature or request labelOct 25, 2024
@15r10nk15r10nkforce-pushed theinline-snapshot-for-pydantic branch from8d1875b to9708ef1CompareDecember 9, 2024 16:45
@15r10nk15r10nkforce-pushed theinline-snapshot-for-pydantic branch 4 times, most recently fromca3c891 to0bdd732CompareDecember 10, 2024 07:50
@15r10nk
Copy link
ContributorAuthor

inline-snapshot 0.15 is out.

I changed the order of the v1,v2 arguments to match the order which is currently used in the tests.

I changed not all the existing tests to use the new function. Let me know if you think this is needed.

@tiangolo
Copy link
Member

This is great! 🚀

I would love to have this in all the tests, but that's a giant task, you don't have to do it. 😅

Having this first one as a template is already great. 🚀

@tiangolotiangolo removed the featureNew feature or request labelDec 10, 2024
@15r10nk15r10nkforce-pushed theinline-snapshot-for-pydantic branch 2 times, most recently fromb430987 to2a7e93bCompareDecember 17, 2024 19:13
@15r10nk15r10nk marked this pull request as ready for reviewDecember 17, 2024 19:17
@15r10nk15r10nkforce-pushed theinline-snapshot-for-pydantic branch from2a7e93b tod8b34afCompareDecember 21, 2024 12:34
@svlandegsvlandeg self-assigned thisFeb 18, 2025
@svlandegsvlandeg changed the titletest: special snapshot function to support different snapshots for different pydantic versions✅ Useinline-snapshot to support different Pydantic versions in the test suiteMar 28, 2025
@svlandegsvlandeg changed the title✅ Useinline-snapshot to support different Pydantic versions in the test suite✅ Usesnapshot_pydantic to support different Pydantic versions in the test suiteMar 28, 2025
@svlandegsvlandeg changed the title✅ Usesnapshot_pydantic to support different Pydantic versions in the test suite✅ Useinline-snapshot to support different Pydantic versions in the test suiteMar 28, 2025
Copy link
Member

@svlandegsvlandeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This looks great, just left a few small suggestions & questions.

15r10nkand others added2 commitsMarch 28, 2025 20:28
@15r10nk
Copy link
ContributorAuthor

@svlandeg, thank you for the review. I added the missing comment.

Copy link
Member

@svlandegsvlandeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This PR looks good to merge to me, but I'll run it internally by Tiangolo for a final review. Thanks again@15r10nk!

@svlandegsvlandeg removed their assignmentApr 17, 2025
Copy link
Member

@tiangolotiangolo left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is awesome, thank you! 🚀

I need to copy this over to SQLModel too. 😎

And thank you@svlandeg! 🙌

@tiangolotiangolo merged commitea42ebd intofastapi:masterApr 28, 2025
28 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tiangolotiangolotiangolo approved these changes

@svlandegsvlandegsvlandeg approved these changes

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@15r10nk@tiangolo@svlandeg

[8]ページ先頭

©2009-2025 Movatter.jp