Skip to content

Commit

Permalink
[internal] Add experimenatl_resolve to python_tests (#12773)
Browse files Browse the repository at this point in the history
As explained in #12734, this allows you to set the resolve when running a specific test target.

The resolve will not yet be consumed when running Pylint and MyPy on the `python_tests` code, which is blocked by implementing #12714.

[ci skip-rust]
[ci skip-build-wheels]
  • Loading branch information
Eric-Arellano authored Sep 8, 2021
1 parent 824b8d7 commit 3576b75
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/python/pants/backend/python/goals/pytest_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ async def setup_pytest_for_target(
requirements_pex_get = Get(
Pex,
PexFromTargetsRequest,
PexFromTargetsRequest.for_requirements([request.field_set.address], internal_only=True),
PexFromTargetsRequest.for_requirements(
[request.field_set.address],
internal_only=True,
resolve_and_lockfile=request.field_set.resolve.resolve_and_lockfile(python_setup),
),
)
pytest_pex_get = Get(
Pex,
Expand Down
2 changes: 2 additions & 0 deletions src/python/pants/backend/python/subsystems/pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from pants.backend.python.subsystems.python_tool_base import PythonToolBase
from pants.backend.python.target_types import (
ConsoleScript,
PythonResolveField,
PythonTestsExtraEnvVars,
PythonTestsSources,
PythonTestsTimeout,
Expand Down Expand Up @@ -49,6 +50,7 @@ class PythonTestFieldSet(TestFieldSet):
timeout: PythonTestsTimeout
runtime_package_dependencies: RuntimePackageDependenciesField
extra_env_vars: PythonTestsExtraEnvVars
resolve: PythonResolveField

@classmethod
def opt_out(cls, tgt: Target) -> bool:
Expand Down
1 change: 1 addition & 0 deletions src/python/pants/backend/python/target_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ class PythonTests(Target):
core_fields = (
*COMMON_TARGET_FIELDS,
InterpreterConstraintsField,
PythonResolveField,
PythonTestsSources,
PythonTestsDependencies,
PythonTestsTimeout,
Expand Down

0 comments on commit 3576b75

Please sign in to comment.