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

✅ Fix incorrect mocking in unit tests (issue #1780)#1781

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

Open
vicaya wants to merge2 commits intofastapi:master
base:master
Choose a base branch
Loading
fromvicaya:fix_backend_init_tests

Conversation

@vicaya
Copy link

@vicayavicaya commentedAug 20, 2025
edited
Loading

Fix issue#1780: the 2test_init_successful_connection tests were basically noops due to misuse of MagicMock.

The errors went undetected until python 3.12+ tightened up the MagicMock implementation.

@YuriiMotovYuriiMotov changed the titleFix broken unit tests #1780✅ Fix broken unit tests (issue #1780)Sep 3, 2025
Copy link
Member

@YuriiMotovYuriiMotov 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.

LGTM

I suggest removing several lines to simplify tests (I tested it locally - it doesn't break tests).

Currently if you replacesession.exec(select(1)) inthis line withpass,this assertion will not fail as it's expected.
This PR fixes mocking theSession and after applying it, that test will not only ensure that there was no exception ininit, but also thatselect(1) was actually called.

The same forhttps://github.com/fastapi/full-stack-fastapi-template/blob/master/backend/app/tests/scripts/test_test_pre_start.py

@vicaya, thank you!
Could you please take a look at my suggested changes? (done)

@YuriiMotovYuriiMotov changed the title✅ Fix broken unit tests (issue #1780)✅ Fix incorrect mocking in unit tests (issue #1780)Sep 3, 2025
@YuriiMotovYuriiMotov linked an issueSep 3, 2025 that may beclosed by this pull request
@tiangolo
Copy link
Member

It seems we now have some conflicts here 🤔 😔

@github-actions
Copy link
Contributor

This pull request has a merge conflict that needs to be resolved.

@github-actionsgithub-actionsbot added the conflictsAutomatically generated when a PR has a merge conflict labelSep 20, 2025
@github-actionsgithub-actionsbot removed the conflictsAutomatically generated when a PR has a merge conflict labelSep 20, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@YuriiMotovYuriiMotovYuriiMotov approved these changes

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Broken unit tests exposed by Python 3.12+

3 participants

@vicaya@tiangolo@YuriiMotov

[8]ページ先頭

©2009-2025 Movatter.jp