Simulate running pex command for integration testing. This is different from run_simple_pex in that it calls the pex command rather than running a generated pex. This is useful for testing end to end runs with specific command line arguments or env options.
(
args, # type: Iterable[str]
env=None, # type: Optional[Dict[str, str]]
python=None, # type: Optional[Union[str, UvPython]]
quiet=None, # type: Optional[bool]
cwd=None, # type: Optional[str]
pex_module="pex", # type: str
use_pex_whl_venv=True, # type: bool
)
| 569 | |
| 570 | |
| 571 | def run_pex_command( |
| 572 | args, # type: Iterable[str] |
| 573 | env=None, # type: Optional[Dict[str, str]] |
| 574 | python=None, # type: Optional[Union[str, UvPython]] |
| 575 | quiet=None, # type: Optional[bool] |
| 576 | cwd=None, # type: Optional[str] |
| 577 | pex_module="pex", # type: str |
| 578 | use_pex_whl_venv=True, # type: bool |
| 579 | ): |
| 580 | # type: (...) -> IntegResults |
| 581 | """Simulate running pex command for integration testing. |
| 582 | |
| 583 | This is different from run_simple_pex in that it calls the pex command rather than running a |
| 584 | generated pex. This is useful for testing end to end runs with specific command line arguments |
| 585 | or env options. |
| 586 | """ |
| 587 | if isinstance(python, UvPython): |
| 588 | python = ensure_uv_python(python) |
| 589 | cmd = create_pex_command( |
| 590 | args, python=python, quiet=quiet, pex_module=pex_module, use_pex_whl_venv=use_pex_whl_venv |
| 591 | ) |
| 592 | process = Executor.open_process( |
| 593 | cmd=cmd, env=env, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE |
| 594 | ) |
| 595 | output, error = process.communicate() |
| 596 | return IntegResults( |
| 597 | tuple(cmd), output.decode("utf-8"), error.decode("utf-8"), process.returncode |
| 598 | ) |
| 599 | |
| 600 | |
| 601 | def run_simple_pex( |