KEMBAR78
✅ Simplify tests for response_model by dynamicy · Pull Request #14062 · fastapi/fastapi · GitHub
Skip to content

Conversation

@dynamicy
Copy link
Contributor

@dynamicy dynamicy marked this pull request as ready for review September 10, 2025 15:59
@dynamicy dynamicy force-pushed the tests-tutorial-tasks branch 3 times, most recently from 31b613b to 4aeae73 Compare September 11, 2025 05:36
@svlandeg
Copy link
Member

Hi! Could you look into the failing tests for Python 3.8?

@svlandeg svlandeg marked this pull request as draft September 11, 2025 17:44
@svlandeg svlandeg changed the title Simplify tests for parametrize response model tutorial ✅ Simplify response model tests by using pytest.mark.parametrize Sep 12, 2025
@dynamicy dynamicy force-pushed the tests-tutorial-tasks branch from 4aeae73 to c257eac Compare September 12, 2025 09:45
@dynamicy dynamicy marked this pull request as ready for review September 12, 2025 09:49
@dynamicy
Copy link
Contributor Author

Hi @svlandeg,
I’ve fixed the issues causing the Python 3.8 test failures — everything should be working now.
Please let me know if you spot anything else!

@github-actions github-actions bot removed the waiting label Sep 12, 2025
@svlandeg svlandeg self-assigned this Sep 12, 2025
@svlandeg svlandeg changed the title ✅ Simplify response model tests by using pytest.mark.parametrize ✅ Simplify tests for response_model Sep 12, 2025
Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

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

Thanks for looking into this, @dynamicy!

I'm not quite sure I understand why you're rewriting
client = TestClient(app)

to a get_client function that yields several TestClientobjects, even when there's only one. In fact, I don't think we need to change the test files that don't have variants of them (which is the focus of #13150)

Have a look at https://github.com/fastapi/fastapi/pull/13197/files for instance. The get_client method becomes something like this:

@pytest.fixture(
    name="client",
    params=[
        "tutorial001",
        pytest.param("tutorial001_py310", marks=needs_py310),
    ],
)
def get_client(request: pytest.FixtureRequest):
    mod = importlib.import_module(f"docs_src.schema_extra_example.{request.param}")

    client = TestClient(mod.app)
    return client

I suggest to keep to this style for consistency across the code base. Then most of the edits of this PR can be removed, and we can focus on the files that actually have code variants for Python 3.10 and clean those up.

@svlandeg svlandeg removed their assignment Sep 12, 2025
@svlandeg svlandeg marked this pull request as draft September 12, 2025 10:26
@dynamicy dynamicy force-pushed the tests-tutorial-tasks branch 5 times, most recently from a25d3d3 to a5bd18c Compare September 12, 2025 18:18
@dynamicy dynamicy marked this pull request as ready for review September 12, 2025 18:23
@dynamicy
Copy link
Contributor Author

Thanks for the feedback, @svlandeg! Thanks for pointing me to the right direction!

@dynamicy dynamicy requested a review from svlandeg September 12, 2025 18:24
@github-actions github-actions bot removed the waiting label Sep 12, 2025
@svlandeg svlandeg self-assigned this Sep 13, 2025
Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

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

This now looks good to me, thanks @dynamicy !

@svlandeg svlandeg removed their assignment Sep 13, 2025
@dynamicy dynamicy force-pushed the tests-tutorial-tasks branch from a5bd18c to 8ca56ee Compare September 16, 2025 17:57
@svlandeg svlandeg self-assigned this Sep 16, 2025
@svlandeg
Copy link
Member

svlandeg commented Sep 16, 2025

@dynamicy: this was already approved and ready to merge, but now I see that a change has been force-pushed. I generally dislike force pushes because it doesn't allow a reviewer to track the history. What have you changed on this PR since my approval?

Just to clarify: there's really no need to obliterate the history of a PR. We squash right before merging anyway.

@dynamicy
Copy link
Contributor Author

Thanks for the heads-up! GitHub showed a notice that the branch was out of date with the base, so I used the Rebase and update option in the UI. That resulted in a force-push of the rebased commits.
There are no functional changes since the approval—only the base was updated (rebased). Sorry for the noise and any inconvenience.
I’m happy to avoid rebasing/force-pushing here going forward and leave base updates to maintainers (we’ll squash on merge anyway). Please let me know if you’d like me to do anything else to make the review easier.

Copy link
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

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

Ok cool, thanks for the explanation! Had another look and confirmed all is still good to merge here 😎

@svlandeg svlandeg removed their assignment Sep 17, 2025
Copy link
Member

@tiangolo tiangolo left a comment

Choose a reason for hiding this comment

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

Nice, thanks! 🚀

And thanks @svlandeg for the review and help! ☕

@tiangolo tiangolo merged commit 11d424c into fastapi:master Sep 20, 2025
29 checks passed
@dynamicy dynamicy mentioned this pull request Sep 20, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants