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

feat(WIP): allow pytest deps to come from target resolve#22835

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

Draft
lecardozo wants to merge2 commits intopantsbuild:main
base:main
Choose a base branch
Loading
fromlecardozo:feat/pytest-deps-from-target-resolve

Conversation

@lecardozo
Copy link

@lecardozolecardozo commentedOct 29, 2025
edited
Loading

Context

Currently, the pytest runner creates an environment composed by a mix of thepython_test dependencies and the pytest dependencies that are needed for the test to properly run. In cases which a third-party dependency is contained both the python_test dependency as well as pytest with potentially different versions (since they come from independent resolves), this can lead to inconsistencies between production and testing environment, which is undesirable.

Related issues and threads

Potential solution (work in progress)

One way to avoid that is to make sure pytest dependencies come from the same resolve as the one used by the python_test target. In cases where the monorepo has a single resolve, this can already be solved with thepytest.install_from_resolve setting. However, in cases where the monorepo contains more than one resolve, there's currently no way to solve that.

This PR introducespytest.install_from_target_resolve: BoolOption setting that, when set true, ignores the pytest resolve configuration and expects test dependencies to come from the target resolve. This ensures all dependencies are aligned across different execution environments.

Potential problems

  • Since we are ignoring pytest dependencies, we need to make sure they are included on the list of dependencies before building the venv, otherwise this won't work. this should be addressed on903daaa

@lecardozolecardozoforce-pushed thefeat/pytest-deps-from-target-resolve branch from5035b26 to903daaaCompareOctober 29, 2025 15:58
Comment on lines +299 to +312
pytest_req_strings=pytest.requirementsifpytest.requirementselsepytest.default_requirements
pytest_requirements=PexRequirements(
pytest_req_strings,
from_superset=Resolve(target_resolve,use_entire_lockfile=False),
description_of_origin="pytest requirements from target resolve",
)
pytest_pex_get=create_pex(
PexRequest(
output_filename="pytest_from_target_resolve.pex",
internal_only=True,
requirements=pytest_requirements,
interpreter_constraints=interpreter_constraints,
)
)
Copy link
Author

Choose a reason for hiding this comment

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

author's note: maybe this logic would be better close toPythonToolBase.pex_requirements


Kept it here initially because it feels like this behavior is only desirable for pytest specifically not all python tools due to it's nature as both a library and a tool

Copy link
Contributor

Choose a reason for hiding this comment

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

We can always move it later, and for now this keeps the blast radius more contained.

Copy link
Contributor

@benjywbenjyw 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 good, thanks for the contribution!

How have you tested it? It would be good to add some testing inpytest_runner_test.py.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@benjywbenjywbenjyw left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@lecardozo@benjyw

[8]ページ先頭

©2009-2025 Movatter.jp