diff --git a/testing/__init__.py b/testing/__init__.py index 27b66f7f2..962bd61eb 100644 --- a/testing/__init__.py +++ b/testing/__init__.py @@ -10,7 +10,6 @@ import platform import random import re -import subprocess import sys from collections import Counter from contextlib import contextmanager @@ -34,6 +33,10 @@ from pex.util import named_temporary_file from pex.venv.virtualenv import InstallationChoice, Virtualenv +# Explicitly re-export subprocess to enable a transparent substitution in tests that supports +# executing PEX files directly on Windows. +from testing import subprocess as subprocess + try: from unittest import mock except ImportError: diff --git a/testing/subprocess.py b/testing/subprocess.py new file mode 100644 index 000000000..94656be2b --- /dev/null +++ b/testing/subprocess.py @@ -0,0 +1,78 @@ +# Copyright 2025 Pex project contributors. +# Licensed under the Apache License, Version 2.0 (see LICENSE). + +from __future__ import absolute_import + +import os +import subprocess +import sys + +from pex.executables import is_python_script +from pex.os import WINDOWS +from pex.pex_info import PexInfo +from pex.typing import TYPE_CHECKING, cast +from pex.venv.virtualenv import InvalidVirtualenvError, Virtualenv + +if TYPE_CHECKING: + from typing import Any, List, Optional, Sequence + + +PIPE = subprocess.PIPE +STDOUT = subprocess.STDOUT +CalledProcessError = subprocess.CalledProcessError + + +def _maybe_load_pex_info(path): + # type: (str) -> Optional[PexInfo] + try: + return PexInfo.from_pex(path) + except (KeyError, IOError, OSError): + return None + + +def _safe_args(args): + # type: (Sequence[str]) -> List[str] + if WINDOWS: + argv0 = args[0] + pex_info = _maybe_load_pex_info(argv0) + if pex_info and is_python_script(argv0, check_executable=False): + try: + return [Virtualenv(os.path.dirname(argv0)).interpreter.binary] + list(args) + except InvalidVirtualenvError: + pass + if pex_info or argv0.endswith(".py"): + return [sys.executable] + list(args) + return args if isinstance(args, list) else list(args) + + +def call( + args, # type: Sequence[str] + **kwargs # type: Any +): + # type: (...) -> int + return subprocess.call(args=_safe_args(args), **kwargs) + + +def check_call( + args, # type: Sequence[str] + **kwargs # type: Any +): + # type: (...) -> None + subprocess.check_call(args=_safe_args(args), **kwargs) + + +def check_output( + args, # type: Sequence[str] + **kwargs # type: Any +): + # type: (...) -> bytes + return cast(bytes, subprocess.check_output(args=_safe_args(args), **kwargs)) + + +class Popen(subprocess.Popen): + def __init__( + self, + args, # type: Sequence[str] + **kwargs # type: Any + ): + super(Popen, self).__init__(_safe_args(args), **kwargs) # type: ignore[call-arg] diff --git a/tests/build_system/test_pep_518.py b/tests/build_system/test_pep_518.py index 677b1bc6e..94aedad60 100644 --- a/tests/build_system/test_pep_518.py +++ b/tests/build_system/test_pep_518.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess from textwrap import dedent from pex.build_system import pep_518 @@ -15,6 +14,7 @@ from pex.typing import TYPE_CHECKING from pex.variables import ENV from pex.venv.virtualenv import Virtualenv +from testing import subprocess from testing.build_system import hatchling_only_supports_37_and_greater if TYPE_CHECKING: diff --git a/tests/integration/build_system/test_pep_518.py b/tests/integration/build_system/test_pep_518.py index fadf61f89..0bbe893f1 100644 --- a/tests/integration/build_system/test_pep_518.py +++ b/tests/integration/build_system/test_pep_518.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess from pex.build_system.pep_518 import BuildSystem, load_build_system from pex.pip.version import PipVersion @@ -10,7 +9,7 @@ from pex.resolve.resolver_configuration import PipConfiguration, ReposConfiguration from pex.targets import LocalInterpreter from pex.typing import TYPE_CHECKING -from testing import make_env, run_pex_command +from testing import make_env, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/cli/commands/test_cache_prune.py b/tests/integration/cli/commands/test_cache_prune.py index 393ffc14e..40e729f65 100644 --- a/tests/integration/cli/commands/test_cache_prune.py +++ b/tests/integration/cli/commands/test_cache_prune.py @@ -5,7 +5,6 @@ import os.path import shutil -import subprocess import time from datetime import datetime, timedelta from textwrap import dedent @@ -33,7 +32,7 @@ from pex.pip.version import PipVersion, PipVersionValue from pex.typing import TYPE_CHECKING from pex.variables import ENV -from testing import run_pex_command +from testing import run_pex_command, subprocess from testing.cli import run_pex3 from testing.pytest.tmp import Tempdir diff --git a/tests/integration/cli/commands/test_issue_1413.py b/tests/integration/cli/commands/test_issue_1413.py index 3f7d44ddf..386888c05 100644 --- a/tests/integration/cli/commands/test_issue_1413.py +++ b/tests/integration/cli/commands/test_issue_1413.py @@ -3,7 +3,6 @@ import os import shutil -import subprocess import pytest @@ -15,7 +14,7 @@ from pex.resolve.path_mappings import PathMapping, PathMappings from pex.resolve.resolved_requirement import ArtifactURL, Pin from pex.typing import TYPE_CHECKING -from testing import make_env, run_pex_command +from testing import make_env, run_pex_command, subprocess from testing.cli import run_pex3 from testing.pytest.tmp import Tempdir, TempdirFactory diff --git a/tests/integration/cli/commands/test_issue_1667.py b/tests/integration/cli/commands/test_issue_1667.py index ecc5a9439..cd4626be9 100644 --- a/tests/integration/cli/commands/test_issue_1667.py +++ b/tests/integration/cli/commands/test_issue_1667.py @@ -2,14 +2,13 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess import sys import pytest from pex.interpreter import PythonInterpreter from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/cli/commands/test_issue_1688.py b/tests/integration/cli/commands/test_issue_1688.py index f143631c5..d21c3d98a 100644 --- a/tests/integration/cli/commands/test_issue_1688.py +++ b/tests/integration/cli/commands/test_issue_1688.py @@ -2,13 +2,12 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess from pex.interpreter import PythonInterpreter from pex.pex_info import PexInfo from pex.resolve.lockfile import json_codec from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/cli/commands/test_issue_1734.py b/tests/integration/cli/commands/test_issue_1734.py index 011914f67..360b8af15 100644 --- a/tests/integration/cli/commands/test_issue_1734.py +++ b/tests/integration/cli/commands/test_issue_1734.py @@ -3,12 +3,11 @@ import os import re -import subprocess from pex.interpreter import PythonInterpreter from pex.interpreter_constraints import InterpreterConstraint from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/cli/commands/test_issue_2050.py b/tests/integration/cli/commands/test_issue_2050.py index 8727e931c..a8f5c38cd 100644 --- a/tests/integration/cli/commands/test_issue_2050.py +++ b/tests/integration/cli/commands/test_issue_2050.py @@ -3,7 +3,6 @@ import json import os import re -import subprocess import sys import tempfile from textwrap import dedent @@ -23,7 +22,15 @@ from pex.targets import LocalInterpreter from pex.third_party.packaging.specifiers import SpecifierSet from pex.typing import TYPE_CHECKING -from testing import IS_LINUX, PY310, PY_VER, ensure_python_interpreter, make_env, run_pex_command +from testing import ( + IS_LINUX, + PY310, + PY_VER, + ensure_python_interpreter, + make_env, + run_pex_command, + subprocess, +) from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/cli/commands/test_issue_2057.py b/tests/integration/cli/commands/test_issue_2057.py index 880348126..939ccb523 100644 --- a/tests/integration/cli/commands/test_issue_2057.py +++ b/tests/integration/cli/commands/test_issue_2057.py @@ -3,7 +3,6 @@ import os.path import shutil -import subprocess import tempfile from textwrap import dedent @@ -12,7 +11,7 @@ from pex.resolve.lockfile import json_codec from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/cli/commands/test_local_project_lock.py b/tests/integration/cli/commands/test_local_project_lock.py index 64adca10d..1d31d8c25 100644 --- a/tests/integration/cli/commands/test_local_project_lock.py +++ b/tests/integration/cli/commands/test_local_project_lock.py @@ -4,7 +4,6 @@ import os import re import shutil -import subprocess import pytest @@ -12,7 +11,7 @@ from pex.interpreter import PythonInterpreter from pex.typing import TYPE_CHECKING from pex.venv.virtualenv import InstallationChoice, Virtualenv -from testing import PY27, ensure_python_interpreter, run_pex_command +from testing import PY27, ensure_python_interpreter, run_pex_command, subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/cli/commands/test_lock.py b/tests/integration/cli/commands/test_lock.py index 7fa63dab2..92ab712c6 100644 --- a/tests/integration/cli/commands/test_lock.py +++ b/tests/integration/cli/commands/test_lock.py @@ -5,7 +5,6 @@ import os import re import shutil -import subprocess import sys from textwrap import dedent @@ -43,6 +42,7 @@ ensure_python_interpreter, make_env, run_pex_command, + subprocess, ) from testing.build_system import hatchling_only_supports_37_and_greater from testing.cli import run_pex3 diff --git a/tests/integration/cli/commands/test_lock_foreign_platform_sdist.py b/tests/integration/cli/commands/test_lock_foreign_platform_sdist.py index 3177d926a..fb3b49f73 100644 --- a/tests/integration/cli/commands/test_lock_foreign_platform_sdist.py +++ b/tests/integration/cli/commands/test_lock_foreign_platform_sdist.py @@ -4,7 +4,6 @@ from __future__ import absolute_import import os.path -import subprocess from textwrap import dedent import pytest @@ -15,7 +14,7 @@ from pex.resolve.configured_resolver import ConfiguredResolver from pex.result import try_ from pex.typing import TYPE_CHECKING -from testing import PY_VER, data, run_pex_command +from testing import PY_VER, data, run_pex_command, subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/cli/commands/test_lock_reproducibility_hash_seed.py b/tests/integration/cli/commands/test_lock_reproducibility_hash_seed.py index f18f60217..2c78cd854 100644 --- a/tests/integration/cli/commands/test_lock_reproducibility_hash_seed.py +++ b/tests/integration/cli/commands/test_lock_reproducibility_hash_seed.py @@ -5,7 +5,6 @@ import filecmp import os.path -import subprocess from textwrap import dedent import pytest @@ -13,6 +12,7 @@ from pex.common import safe_open from pex.typing import TYPE_CHECKING +from testing import subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/cli/commands/test_lock_sync.py b/tests/integration/cli/commands/test_lock_sync.py index d61c9cd13..734100629 100644 --- a/tests/integration/cli/commands/test_lock_sync.py +++ b/tests/integration/cli/commands/test_lock_sync.py @@ -7,7 +7,6 @@ import os.path import re import shutil -import subprocess import sys from textwrap import dedent @@ -46,6 +45,7 @@ ensure_python_interpreter, make_env, re_exact, + subprocess, ) from testing.cli import run_pex3 from testing.find_links import FindLinksRepo diff --git a/tests/integration/cli/commands/test_lock_update.py b/tests/integration/cli/commands/test_lock_update.py index 1f98b6063..63817423e 100644 --- a/tests/integration/cli/commands/test_lock_update.py +++ b/tests/integration/cli/commands/test_lock_update.py @@ -5,7 +5,6 @@ import os import re import shutil -import subprocess import pytest @@ -17,7 +16,7 @@ from pex.resolve.lockfile.model import Lockfile from pex.resolve.resolved_requirement import ArtifactURL from pex.typing import TYPE_CHECKING -from testing import make_env, run_pex_command +from testing import make_env, run_pex_command, subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/cli/commands/test_vcs_lock.py b/tests/integration/cli/commands/test_vcs_lock.py index 12f192107..8d3bf1519 100644 --- a/tests/integration/cli/commands/test_vcs_lock.py +++ b/tests/integration/cli/commands/test_vcs_lock.py @@ -4,7 +4,6 @@ import filecmp import os.path import shutil -import subprocess import sys import tempfile from textwrap import dedent @@ -17,7 +16,7 @@ from pex.resolve.locked_resolve import VCSArtifact from pex.resolve.lockfile import json_codec from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/cli/commands/test_venv_create.py b/tests/integration/cli/commands/test_venv_create.py index 4d7e76e27..5bef9664b 100644 --- a/tests/integration/cli/commands/test_venv_create.py +++ b/tests/integration/cli/commands/test_venv_create.py @@ -6,7 +6,6 @@ import glob import os.path import shutil -import subprocess import sys from textwrap import dedent @@ -25,7 +24,15 @@ from pex.resolve import abbreviated_platforms from pex.typing import TYPE_CHECKING from pex.venv.virtualenv import Virtualenv -from testing import IS_MAC, PY39, PY310, ensure_python_interpreter, make_env, run_pex_command +from testing import ( + IS_MAC, + PY39, + PY310, + ensure_python_interpreter, + make_env, + run_pex_command, + subprocess, +) from testing.cli import run_pex3 from testing.pytest.tmp import Tempdir, TempdirFactory diff --git a/tests/integration/cli/commands/test_venv_inspect.py b/tests/integration/cli/commands/test_venv_inspect.py index e42155320..f1fffed4f 100644 --- a/tests/integration/cli/commands/test_venv_inspect.py +++ b/tests/integration/cli/commands/test_venv_inspect.py @@ -3,7 +3,6 @@ import json import os.path -import subprocess import sys import pytest @@ -21,6 +20,7 @@ ensure_python_venv, make_env, run_pex_command, + subprocess, ) from testing.cli import run_pex3 diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index c6d6e8b50..05f68eb03 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -5,7 +5,6 @@ import glob import os -import subprocess import pytest @@ -14,7 +13,7 @@ from pex.interpreter import PythonInterpreter from pex.typing import TYPE_CHECKING from pex.venv.virtualenv import Virtualenv -from testing import PY310, data, ensure_python_interpreter, make_env, run_pex_command +from testing import PY310, data, ensure_python_interpreter, make_env, run_pex_command, subprocess from testing.mitmproxy import Proxy if TYPE_CHECKING: diff --git a/tests/integration/resolve/test_dependency_groups.py b/tests/integration/resolve/test_dependency_groups.py index 1503c0653..bab5bfdda 100644 --- a/tests/integration/resolve/test_dependency_groups.py +++ b/tests/integration/resolve/test_dependency_groups.py @@ -4,7 +4,6 @@ from __future__ import absolute_import import os.path -import subprocess from textwrap import dedent import colors # vendor:skip @@ -13,7 +12,7 @@ from pex.pep_440 import Version from pex.pep_503 import ProjectName from pex.pex import PEX -from testing import run_pex_command +from testing import run_pex_command, subprocess from testing.pytest.tmp import Tempdir diff --git a/tests/integration/resolve/test_issue_1907.py b/tests/integration/resolve/test_issue_1907.py index 0353c8ad9..d469d563d 100644 --- a/tests/integration/resolve/test_issue_1907.py +++ b/tests/integration/resolve/test_issue_1907.py @@ -6,7 +6,6 @@ import glob import os.path import re -import subprocess import sys from textwrap import dedent @@ -19,7 +18,7 @@ from pex.pex import PEX from pex.pip.version import PipVersion from pex.typing import TYPE_CHECKING -from testing import IS_PYPY, PY_VER, data, run_pex_command +from testing import IS_PYPY, PY_VER, data, run_pex_command, subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/resolve/test_issue_1918.py b/tests/integration/resolve/test_issue_1918.py index ac1ee1c8c..85c3388e8 100644 --- a/tests/integration/resolve/test_issue_1918.py +++ b/tests/integration/resolve/test_issue_1918.py @@ -3,7 +3,6 @@ import itertools import os.path -import subprocess import pytest @@ -17,7 +16,7 @@ from pex.resolve.resolver_configuration import ResolverVersion from pex.sorted_tuple import SortedTuple from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/resolve/test_issue_2412.py b/tests/integration/resolve/test_issue_2412.py index f0c0c86f6..8d7a198b2 100644 --- a/tests/integration/resolve/test_issue_2412.py +++ b/tests/integration/resolve/test_issue_2412.py @@ -7,7 +7,6 @@ import os.path import re import shutil -import subprocess from textwrap import dedent from colors import color # vendor:skip @@ -15,7 +14,7 @@ from pex.common import safe_open, touch from pex.targets import LocalInterpreter from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/resolve/test_issue_2532.py b/tests/integration/resolve/test_issue_2532.py index 01b4a6ce6..852aeee93 100644 --- a/tests/integration/resolve/test_issue_2532.py +++ b/tests/integration/resolve/test_issue_2532.py @@ -4,11 +4,10 @@ from __future__ import absolute_import import os -import subprocess from textwrap import dedent from pex.typing import TYPE_CHECKING -from testing import WheelBuilder +from testing import WheelBuilder, subprocess from testing.docker import skip_unless_docker if TYPE_CHECKING: diff --git a/tests/integration/scie/test_discussion_2516.py b/tests/integration/scie/test_discussion_2516.py index 23b783d81..9f8835eed 100644 --- a/tests/integration/scie/test_discussion_2516.py +++ b/tests/integration/scie/test_discussion_2516.py @@ -5,13 +5,12 @@ import glob import os.path -import subprocess from textwrap import dedent from pex.common import safe_open from pex.sysconfig import SysPlatform from pex.typing import TYPE_CHECKING -from testing import make_env, run_pex_command +from testing import make_env, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/scie/test_pex_scie.py b/tests/integration/scie/test_pex_scie.py index 2be9d5b8b..681b23d4f 100644 --- a/tests/integration/scie/test_pex_scie.py +++ b/tests/integration/scie/test_pex_scie.py @@ -8,7 +8,6 @@ import os.path import re import shutil -import subprocess import sys from textwrap import dedent from typing import Optional @@ -27,7 +26,7 @@ from pex.targets import LocalInterpreter from pex.typing import TYPE_CHECKING from pex.version import __version__ -from testing import IS_PYPY, PY_VER, make_env, run_pex_command +from testing import IS_PYPY, PY_VER, make_env, run_pex_command, subprocess from testing.scie import skip_if_no_provider if TYPE_CHECKING: diff --git a/tests/integration/test_excludes.py b/tests/integration/test_excludes.py index 2a1f8dc30..2357971ae 100644 --- a/tests/integration/test_excludes.py +++ b/tests/integration/test_excludes.py @@ -8,7 +8,6 @@ import os.path import re import shutil -import subprocess from os.path import commonprefix from textwrap import dedent from typing import Iterator @@ -28,7 +27,7 @@ from pex.sorted_tuple import SortedTuple from pex.typing import TYPE_CHECKING from pex.venv.virtualenv import InstallationChoice, Virtualenv -from testing import PY_VER, IntegResults, data, make_env, run_pex_command +from testing import PY_VER, IntegResults, data, make_env, run_pex_command, subprocess from testing.cli import run_pex3 from testing.lock import extract_lock_option_args, index_lock_artifacts from testing.pytest.tmp import Tempdir, TempdirFactory diff --git a/tests/integration/test_executuon_mode_venv.py b/tests/integration/test_executuon_mode_venv.py index 808add001..62c075af8 100644 --- a/tests/integration/test_executuon_mode_venv.py +++ b/tests/integration/test_executuon_mode_venv.py @@ -6,10 +6,9 @@ import json import os import re -import subprocess from pex.typing import TYPE_CHECKING -from testing import IS_PYPY, PY_VER, make_env, run_pex_command +from testing import IS_PYPY, PY_VER, make_env, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_inject_env_and_args.py b/tests/integration/test_inject_env_and_args.py index 976fd0076..75045e4fd 100644 --- a/tests/integration/test_inject_env_and_args.py +++ b/tests/integration/test_inject_env_and_args.py @@ -7,7 +7,6 @@ import re import signal import socket -import subprocess from contextlib import closing from textwrap import dedent @@ -16,7 +15,7 @@ from pex.common import safe_open from pex.fetcher import URLFetcher from pex.typing import TYPE_CHECKING -from testing import IS_PYPY, PY_VER, make_env, run_pex_command +from testing import IS_PYPY, PY_VER, make_env, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, Iterable, List, Optional diff --git a/tests/integration/test_inject_python_args.py b/tests/integration/test_inject_python_args.py index faee435c9..3679c9f88 100644 --- a/tests/integration/test_inject_python_args.py +++ b/tests/integration/test_inject_python_args.py @@ -4,14 +4,13 @@ import json import os.path import shutil -import subprocess import sys from textwrap import dedent import pytest from pex.typing import TYPE_CHECKING -from testing import IS_PYPY, run_pex_command +from testing import IS_PYPY, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, Iterable, List diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index a45f41eb1..78dc62e09 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -9,7 +9,6 @@ import re import shlex import shutil -import subprocess import sys from contextlib import closing, contextmanager from textwrap import dedent @@ -53,6 +52,7 @@ run_pex_command, run_simple_pex, run_simple_pex_test, + subprocess, temporary_content, ) from testing.mitmproxy import Proxy @@ -1310,7 +1310,7 @@ def build_and_execute_pex_with_warnings(*extra_build_args, **extra_runtime_env): env.update(**extra_runtime_env) process = subprocess.Popen(cmd, env=env, stderr=subprocess.PIPE) _, stderr = process.communicate() - return stderr + return cast(bytes, stderr) def test_emit_warnings_default(): diff --git a/tests/integration/test_interpreter.py b/tests/integration/test_interpreter.py index 89bbaa2d8..d62d61457 100644 --- a/tests/integration/test_interpreter.py +++ b/tests/integration/test_interpreter.py @@ -1,14 +1,13 @@ # Copyright 2024 Pex project contributors. # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess import sys from pex.compatibility import commonpath from pex.interpreter import PythonInterpreter from pex.typing import TYPE_CHECKING from pex.variables import ENV -from testing import PY310, ensure_python_interpreter, run_pex_command +from testing import PY310, ensure_python_interpreter, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_1018.py b/tests/integration/test_issue_1018.py index 875bfb0f0..7272b7028 100644 --- a/tests/integration/test_issue_1018.py +++ b/tests/integration/test_issue_1018.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess from textwrap import dedent import pytest @@ -10,7 +9,7 @@ from pex.common import safe_open from pex.layout import Layout from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, Iterable, List diff --git a/tests/integration/test_issue_1201.py b/tests/integration/test_issue_1201.py index 6430ac576..b0b934993 100644 --- a/tests/integration/test_issue_1201.py +++ b/tests/integration/test_issue_1201.py @@ -2,10 +2,9 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_1202.py b/tests/integration/test_issue_1202.py index 830418e16..fe39c0577 100644 --- a/tests/integration/test_issue_1202.py +++ b/tests/integration/test_issue_1202.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess import pytest @@ -10,7 +9,7 @@ from pex.pex import PEX from pex.third_party.packaging import tags from pex.typing import TYPE_CHECKING -from testing import PY27, ensure_python_interpreter, run_pex_command +from testing import PY27, ensure_python_interpreter, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_1232.py b/tests/integration/test_issue_1232.py index 693df3793..552792901 100644 --- a/tests/integration/test_issue_1232.py +++ b/tests/integration/test_issue_1232.py @@ -3,11 +3,10 @@ import os import shutil -import subprocess from pex.cache.dirs import CacheDir from pex.typing import TYPE_CHECKING -from testing import PY38, PY310, ensure_python_interpreter, make_env, run_pex_command +from testing import PY38, PY310, ensure_python_interpreter, make_env, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, Dict, FrozenSet, Iterator, List diff --git a/tests/integration/test_issue_1302.py b/tests/integration/test_issue_1302.py index 1f63c43ff..0ee69e87e 100644 --- a/tests/integration/test_issue_1302.py +++ b/tests/integration/test_issue_1302.py @@ -3,10 +3,9 @@ import json import os -import subprocess from pex.typing import TYPE_CHECKING -from testing import built_wheel, make_env, run_pex_command +from testing import built_wheel, make_env, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_1316.py b/tests/integration/test_issue_1316.py index ab13c1997..ce167c575 100644 --- a/tests/integration/test_issue_1316.py +++ b/tests/integration/test_issue_1316.py @@ -2,13 +2,12 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess import sys import pytest from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_1336.py b/tests/integration/test_issue_1336.py index ba59c9a8f..4796cfdf9 100644 --- a/tests/integration/test_issue_1336.py +++ b/tests/integration/test_issue_1336.py @@ -2,11 +2,10 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess from pex.compatibility import commonpath from pex.typing import TYPE_CHECKING -from testing import PY310, ensure_python_interpreter, run_pex_command +from testing import PY310, ensure_python_interpreter, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_1422.py b/tests/integration/test_issue_1422.py index 120a5e57e..0acb46f40 100644 --- a/tests/integration/test_issue_1422.py +++ b/tests/integration/test_issue_1422.py @@ -3,11 +3,18 @@ import os import re -import subprocess import sys from pex.typing import TYPE_CHECKING -from testing import PY38, PY39, PY310, ensure_python_interpreter, make_env, run_pex_command +from testing import ( + PY38, + PY39, + PY310, + ensure_python_interpreter, + make_env, + run_pex_command, + subprocess, +) if TYPE_CHECKING: from typing import Any, Iterable, Optional, Tuple diff --git a/tests/integration/test_issue_1447.py b/tests/integration/test_issue_1447.py index c50e1c04e..096410a3d 100644 --- a/tests/integration/test_issue_1447.py +++ b/tests/integration/test_issue_1447.py @@ -2,13 +2,12 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os import shutil -import subprocess import sys from pex.pex_info import PexInfo from pex.typing import TYPE_CHECKING from pex.variables import unzip_dir -from testing import run_pex_command +from testing import run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_1479.py b/tests/integration/test_issue_1479.py index fa788874e..8efe92da9 100644 --- a/tests/integration/test_issue_1479.py +++ b/tests/integration/test_issue_1479.py @@ -4,12 +4,11 @@ import os.path import platform -import subprocess import sys from pex.common import safe_rmtree from pex.typing import TYPE_CHECKING -from testing import make_env, run_pex_command +from testing import make_env, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_1520.py b/tests/integration/test_issue_1520.py index 46f8b8c67..bbab20475 100644 --- a/tests/integration/test_issue_1520.py +++ b/tests/integration/test_issue_1520.py @@ -3,14 +3,13 @@ import os import shutil -import subprocess from textwrap import dedent import pytest from pex.cache.dirs import CacheDir from pex.typing import TYPE_CHECKING -from testing import IS_LINUX, IS_MAC, PY_VER, run_pex_command +from testing import IS_LINUX, IS_MAC, PY_VER, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_1537.py b/tests/integration/test_issue_1537.py index 9991f4b67..5f2f93382 100644 --- a/tests/integration/test_issue_1537.py +++ b/tests/integration/test_issue_1537.py @@ -5,10 +5,9 @@ import os.path import shutil -import subprocess from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess from testing.mitmproxy import Proxy if TYPE_CHECKING: diff --git a/tests/integration/test_issue_1550.py b/tests/integration/test_issue_1550.py index e9035a135..acc489197 100644 --- a/tests/integration/test_issue_1550.py +++ b/tests/integration/test_issue_1550.py @@ -1,14 +1,13 @@ # Copyright 2021 Pex project contributors. # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess from pex import dist_metadata from pex.dist_metadata import ProjectNameAndVersion from pex.orderedset import OrderedSet from pex.pex_info import PexInfo from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_1560.py b/tests/integration/test_issue_1560.py index 04b287bc7..dfe5772d7 100644 --- a/tests/integration/test_issue_1560.py +++ b/tests/integration/test_issue_1560.py @@ -3,14 +3,20 @@ import os.path import re -import subprocess from textwrap import dedent import pytest from pex.common import safe_open, touch from pex.typing import TYPE_CHECKING -from testing import IntegResults, VenvFactory, all_python_venvs, make_source_dir, run_pex_command +from testing import ( + IntegResults, + VenvFactory, + all_python_venvs, + make_source_dir, + run_pex_command, + subprocess, +) from testing.pytest.tmp import Tempdir from testing.pythonPI import skip_flit_core_39 diff --git a/tests/integration/test_issue_157.py b/tests/integration/test_issue_157.py index c419ef563..c12d0d632 100644 --- a/tests/integration/test_issue_157.py +++ b/tests/integration/test_issue_157.py @@ -4,7 +4,6 @@ from __future__ import absolute_import import os -import subprocess from contextlib import closing, contextmanager from textwrap import dedent from typing import Mapping, Text @@ -18,7 +17,7 @@ from pex.pex_info import PexInfo from pex.typing import TYPE_CHECKING from pex.version import __version__ -from testing import IS_PYPY, make_env, run_pex_command, scie +from testing import IS_PYPY, make_env, run_pex_command, scie, subprocess if TYPE_CHECKING: from typing import Any, Iterable, Iterator, List, Tuple diff --git a/tests/integration/test_issue_1656.py b/tests/integration/test_issue_1656.py index 5524788ec..41689fde4 100644 --- a/tests/integration/test_issue_1656.py +++ b/tests/integration/test_issue_1656.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess import sys import pytest @@ -10,7 +9,7 @@ from pex.interpreter import PythonInterpreter from pex.pex_info import PexInfo from pex.typing import TYPE_CHECKING -from testing import IS_PYPY, PY_VER, make_env, run_pex_command +from testing import IS_PYPY, PY_VER, make_env, run_pex_command, subprocess from testing.pytest.tmp import TempdirFactory if TYPE_CHECKING: diff --git a/tests/integration/test_issue_1683.py b/tests/integration/test_issue_1683.py index e8779b714..073135233 100644 --- a/tests/integration/test_issue_1683.py +++ b/tests/integration/test_issue_1683.py @@ -2,14 +2,13 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess from textwrap import dedent from colors import crossed, red # vendor:skip from pex.common import safe_open from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_1802.py b/tests/integration/test_issue_1802.py index 0754debe6..cfb80962c 100644 --- a/tests/integration/test_issue_1802.py +++ b/tests/integration/test_issue_1802.py @@ -1,7 +1,6 @@ # Copyright 2022 Pex project contributors. # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess from textwrap import dedent import pytest @@ -9,7 +8,7 @@ from pex.common import safe_open from pex.compatibility import PY2 from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_1809.py b/tests/integration/test_issue_1809.py index d2b086308..9b9595251 100644 --- a/tests/integration/test_issue_1809.py +++ b/tests/integration/test_issue_1809.py @@ -3,7 +3,6 @@ import os.path import shutil -import subprocess import sys from textwrap import dedent @@ -11,7 +10,7 @@ from pex.common import safe_open from pex.typing import TYPE_CHECKING -from testing import PY310, ensure_python_distribution, run_pex_command +from testing import PY310, ensure_python_distribution, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_1825.py b/tests/integration/test_issue_1825.py index b04cc8556..537f39b32 100644 --- a/tests/integration/test_issue_1825.py +++ b/tests/integration/test_issue_1825.py @@ -3,7 +3,6 @@ import json import os.path -import subprocess from textwrap import dedent import pytest @@ -12,7 +11,7 @@ from pex.inherit_path import InheritPath from pex.orderedset import OrderedSet from pex.typing import TYPE_CHECKING, cast -from testing import make_env, run_pex_command +from testing import make_env, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, List diff --git a/tests/integration/test_issue_1870.py b/tests/integration/test_issue_1870.py index 92a60d46e..e6fbbf176 100644 --- a/tests/integration/test_issue_1870.py +++ b/tests/integration/test_issue_1870.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess import colors # vendor:skip import pytest @@ -10,7 +9,7 @@ from pex.inherit_path import InheritPath from pex.typing import TYPE_CHECKING from pex.venv.virtualenv import Virtualenv -from testing import PY_VER, make_env, run_pex_command +from testing import PY_VER, make_env, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_1872.py b/tests/integration/test_issue_1872.py index 3b6aa9a78..729415ade 100644 --- a/tests/integration/test_issue_1872.py +++ b/tests/integration/test_issue_1872.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess import sys from pex.pep_440 import Version @@ -12,7 +11,7 @@ from pex.resolve.resolved_requirement import Pin from pex.typing import TYPE_CHECKING from pex.version import __version__ -from testing import PY310, ensure_python_interpreter, make_env, run_pex_command +from testing import PY310, ensure_python_interpreter, make_env, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_1933.py b/tests/integration/test_issue_1933.py index 29c6efd61..8695efa40 100644 --- a/tests/integration/test_issue_1933.py +++ b/tests/integration/test_issue_1933.py @@ -2,12 +2,11 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess import pytest from pex.typing import TYPE_CHECKING -from testing import IS_X86_64, run_pex_command +from testing import IS_X86_64, run_pex_command, subprocess from testing.docker import skip_unless_docker if TYPE_CHECKING: diff --git a/tests/integration/test_issue_1936.py b/tests/integration/test_issue_1936.py index b5fddc5d8..81f92543d 100644 --- a/tests/integration/test_issue_1936.py +++ b/tests/integration/test_issue_1936.py @@ -2,10 +2,9 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess from pex.typing import TYPE_CHECKING -from testing import make_env, run_pex_command +from testing import make_env, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_1995.py b/tests/integration/test_issue_1995.py index 421c0e138..0c86aa475 100644 --- a/tests/integration/test_issue_1995.py +++ b/tests/integration/test_issue_1995.py @@ -2,13 +2,19 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess import sys import pytest from pex.typing import TYPE_CHECKING -from testing import IS_LINUX, PY310, ensure_python_interpreter, make_env, run_pex_command +from testing import ( + IS_LINUX, + PY310, + ensure_python_interpreter, + make_env, + run_pex_command, + subprocess, +) if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_2001.py b/tests/integration/test_issue_2001.py index 1c9aa67d5..8ae5bf73a 100644 --- a/tests/integration/test_issue_2001.py +++ b/tests/integration/test_issue_2001.py @@ -1,9 +1,8 @@ import os.path -import subprocess import sys from pex.typing import TYPE_CHECKING -from testing import make_env, run_pex_command +from testing import make_env, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_2006.py b/tests/integration/test_issue_2006.py index ccf1bd054..0d4debe6f 100644 --- a/tests/integration/test_issue_2006.py +++ b/tests/integration/test_issue_2006.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess import sys import pytest @@ -10,7 +9,7 @@ from pex.compatibility import PY3 from pex.fs import safe_symlink from pex.typing import TYPE_CHECKING -from testing import PY38, ensure_python_interpreter, run_pex_command +from testing import PY38, ensure_python_interpreter, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, List diff --git a/tests/integration/test_issue_2017.py b/tests/integration/test_issue_2017.py index e524d1270..1c08ffba7 100644 --- a/tests/integration/test_issue_2017.py +++ b/tests/integration/test_issue_2017.py @@ -5,7 +5,6 @@ import os.path import shutil -import subprocess import tarfile from textwrap import dedent @@ -18,7 +17,7 @@ from pex.os import is_exe from pex.pip.version import PipVersion, PipVersionValue from pex.typing import TYPE_CHECKING -from testing import IS_LINUX, run_pex_command +from testing import IS_LINUX, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, Iterator diff --git a/tests/integration/test_issue_2023.py b/tests/integration/test_issue_2023.py index e130bde22..b25efb4db 100644 --- a/tests/integration/test_issue_2023.py +++ b/tests/integration/test_issue_2023.py @@ -3,7 +3,6 @@ import os.path import shutil -import subprocess import sys from textwrap import dedent @@ -13,7 +12,7 @@ from pex.layout import Layout from pex.pep_427 import InstallableType from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess from testing.pep_427 import get_installable_type_flag if TYPE_CHECKING: diff --git a/tests/integration/test_issue_2038.py b/tests/integration/test_issue_2038.py index eedbb7989..a784af44d 100644 --- a/tests/integration/test_issue_2038.py +++ b/tests/integration/test_issue_2038.py @@ -5,7 +5,6 @@ import glob import os.path -import subprocess import sys from textwrap import dedent @@ -13,7 +12,7 @@ from pex.common import touch from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_2073.py b/tests/integration/test_issue_2073.py index aa016e876..1bec27767 100644 --- a/tests/integration/test_issue_2073.py +++ b/tests/integration/test_issue_2073.py @@ -3,12 +3,11 @@ import os.path import re -import subprocess from pex.resolve import abbreviated_platforms from pex.targets import AbbreviatedPlatform from pex.typing import TYPE_CHECKING -from testing import IS_LINUX, IntegResults, run_pex_command +from testing import IS_LINUX, IntegResults, run_pex_command, subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/test_issue_2088.py b/tests/integration/test_issue_2088.py index 0c4348a3b..264a9aa85 100644 --- a/tests/integration/test_issue_2088.py +++ b/tests/integration/test_issue_2088.py @@ -1,7 +1,6 @@ # Copyright 2023 Pex project contributors. # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess import sys import pytest @@ -12,7 +11,7 @@ from pex.layout import Layout from pex.typing import TYPE_CHECKING from pex.venv.virtualenv import Virtualenv -from testing import run_pex_command +from testing import run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_2134.py b/tests/integration/test_issue_2134.py index 21e177568..27d58b608 100644 --- a/tests/integration/test_issue_2134.py +++ b/tests/integration/test_issue_2134.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess import sys import pytest @@ -10,7 +9,7 @@ from pex import layout from pex.common import open_zip, touch from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, Iterable, Optional diff --git a/tests/integration/test_issue_2183.py b/tests/integration/test_issue_2183.py index 9d3ea7d02..af6952e6d 100644 --- a/tests/integration/test_issue_2183.py +++ b/tests/integration/test_issue_2183.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess from textwrap import dedent import pytest @@ -14,7 +13,7 @@ from pex.pex import PEX from pex.typing import TYPE_CHECKING from pex.venv.virtualenv import Virtualenv -from testing import PY_VER, make_env, run_pex_command +from testing import PY_VER, make_env, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_2203.py b/tests/integration/test_issue_2203.py index c7fc80a6a..028f84dbb 100644 --- a/tests/integration/test_issue_2203.py +++ b/tests/integration/test_issue_2203.py @@ -3,12 +3,12 @@ import os.path import stat -import subprocess from collections import OrderedDict from pex.common import safe_rmtree from pex.typing import TYPE_CHECKING from pex.venv.virtualenv import InstallationChoice, Virtualenv +from testing import subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_2235.py b/tests/integration/test_issue_2235.py index e037b2439..817b01d3b 100644 --- a/tests/integration/test_issue_2235.py +++ b/tests/integration/test_issue_2235.py @@ -1,11 +1,10 @@ import os -import subprocess import sys import pytest from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_2249.py b/tests/integration/test_issue_2249.py index 37f0915cc..d3b4a8571 100644 --- a/tests/integration/test_issue_2249.py +++ b/tests/integration/test_issue_2249.py @@ -4,7 +4,6 @@ from __future__ import absolute_import import os.path -import subprocess from contextlib import closing from textwrap import dedent from typing import Iterator @@ -15,7 +14,7 @@ from pex.common import safe_rmtree from pex.typing import TYPE_CHECKING -from testing import IS_PYPY, make_env, run_pex_command, scie +from testing import IS_PYPY, make_env, run_pex_command, scie, subprocess if TYPE_CHECKING: from typing import Any, List diff --git a/tests/integration/test_issue_2355.py b/tests/integration/test_issue_2355.py index 4f68b174c..5eec09ed4 100644 --- a/tests/integration/test_issue_2355.py +++ b/tests/integration/test_issue_2355.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import json import os -import subprocess from textwrap import dedent from pex.interpreter import PythonInterpreter @@ -13,7 +12,7 @@ from pex.result import try_ from pex.targets import CompletePlatform, Targets from pex.typing import TYPE_CHECKING -from testing import IS_X86_64, run_pex_command +from testing import IS_X86_64, run_pex_command, subprocess from testing.docker import skip_unless_docker if TYPE_CHECKING: diff --git a/tests/integration/test_issue_2389.py b/tests/integration/test_issue_2389.py index 0ba79c24e..ecda8d390 100644 --- a/tests/integration/test_issue_2389.py +++ b/tests/integration/test_issue_2389.py @@ -2,12 +2,11 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess import sys from pex.interpreter import PythonInterpreter from pex.typing import TYPE_CHECKING -from testing import PY310, ensure_python_interpreter, run_pex_command +from testing import PY310, ensure_python_interpreter, run_pex_command, subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/test_issue_2391.py b/tests/integration/test_issue_2391.py index 84c013a92..9c3fba025 100644 --- a/tests/integration/test_issue_2391.py +++ b/tests/integration/test_issue_2391.py @@ -3,14 +3,13 @@ import os.path import re -import subprocess import sys import pytest from pex.layout import Layout from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_2410.py b/tests/integration/test_issue_2410.py index 3965aa54c..c94df7a2d 100644 --- a/tests/integration/test_issue_2410.py +++ b/tests/integration/test_issue_2410.py @@ -4,14 +4,13 @@ from __future__ import absolute_import import os.path -import subprocess from textwrap import dedent from colors import colors # vendor:skip from pex.common import safe_open from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_2412.py b/tests/integration/test_issue_2412.py index e13a17f0b..29c1180dd 100644 --- a/tests/integration/test_issue_2412.py +++ b/tests/integration/test_issue_2412.py @@ -4,7 +4,6 @@ from __future__ import absolute_import, print_function import os.path -import subprocess from textwrap import dedent import pytest @@ -17,6 +16,7 @@ from pex.resolve.lockfile import json_codec from pex.typing import TYPE_CHECKING from pex.venv.virtualenv import InstallationChoice, Virtualenv +from testing import subprocess from testing.cli import run_pex3 from testing.lock import index_lock_artifacts diff --git a/tests/integration/test_issue_2413.py b/tests/integration/test_issue_2413.py index 6fd7b3dd5..16adbdf9c 100644 --- a/tests/integration/test_issue_2413.py +++ b/tests/integration/test_issue_2413.py @@ -5,7 +5,6 @@ import glob import os.path -import subprocess from textwrap import dedent import pytest @@ -15,6 +14,7 @@ from pex.pep_503 import ProjectName from pex.typing import TYPE_CHECKING from pex.venv.virtualenv import InstallationChoice, Virtualenv +from testing import subprocess if TYPE_CHECKING: from typing import Any, List diff --git a/tests/integration/test_issue_2415.py b/tests/integration/test_issue_2415.py index 0b0dbf000..8542f66b7 100644 --- a/tests/integration/test_issue_2415.py +++ b/tests/integration/test_issue_2415.py @@ -3,7 +3,6 @@ import atexit import os.path -import subprocess import time from textwrap import dedent @@ -12,7 +11,7 @@ from pex.common import safe_mkdir, safe_open from pex.fetcher import URLFetcher from pex.typing import TYPE_CHECKING -from testing import IS_MAC, IS_PYPY, PY_VER, data, run_pex_command +from testing import IS_MAC, IS_PYPY, PY_VER, data, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_2572.py b/tests/integration/test_issue_2572.py index acfe7dc0d..e7b0a36e5 100644 --- a/tests/integration/test_issue_2572.py +++ b/tests/integration/test_issue_2572.py @@ -5,10 +5,9 @@ import os import shutil -import subprocess from pex.fs import safe_symlink -from testing import make_env, run_pex_command +from testing import make_env, run_pex_command, subprocess from testing.pytest.tmp import Tempdir diff --git a/tests/integration/test_issue_2739.py b/tests/integration/test_issue_2739.py index 8913e6290..404ef98f4 100644 --- a/tests/integration/test_issue_2739.py +++ b/tests/integration/test_issue_2739.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess from pex.pep_440 import Version from pex.pep_503 import ProjectName @@ -10,7 +9,7 @@ from pex.resolve.lockfile import json_codec from pex.resolve.resolved_requirement import Pin from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/test_issue_298.py b/tests/integration/test_issue_298.py index 5ce6b54d9..901483a08 100644 --- a/tests/integration/test_issue_298.py +++ b/tests/integration/test_issue_298.py @@ -6,13 +6,13 @@ import os.path import shutil -import subprocess from textwrap import dedent from pex.common import safe_open from pex.fetcher import URLFetcher from pex.os import WINDOWS from pex.typing import TYPE_CHECKING +from testing import subprocess from testing.docker import skip_unless_docker if TYPE_CHECKING: diff --git a/tests/integration/test_issue_455.py b/tests/integration/test_issue_455.py index d705e5b30..62415cc53 100644 --- a/tests/integration/test_issue_455.py +++ b/tests/integration/test_issue_455.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess import sys import pytest @@ -10,7 +9,7 @@ from pex.compatibility import commonpath from pex.typing import TYPE_CHECKING from pex.venv.virtualenv import Virtualenv -from testing import IS_MAC, PY310, ensure_python_venv, run_pex_command +from testing import IS_MAC, PY310, ensure_python_venv, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_issue_539.py b/tests/integration/test_issue_539.py index 1f689ff91..a4956e77b 100644 --- a/tests/integration/test_issue_539.py +++ b/tests/integration/test_issue_539.py @@ -3,14 +3,13 @@ import glob import os -import subprocess import pytest from pex.common import temporary_dir from pex.pip.installation import get_pip from pex.resolve.configured_resolver import ConfiguredResolver -from testing import IS_LINUX_ARM64, IS_PYPY, PY_VER, run_pex_command +from testing import IS_LINUX_ARM64, IS_PYPY, PY_VER, run_pex_command, subprocess @pytest.mark.skipif( diff --git a/tests/integration/test_issue_598.py b/tests/integration/test_issue_598.py index 5237d8e94..41b8a64f3 100644 --- a/tests/integration/test_issue_598.py +++ b/tests/integration/test_issue_598.py @@ -2,10 +2,9 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess from pex.common import temporary_dir -from testing import make_env, run_pex_command +from testing import make_env, run_pex_command, subprocess def test_force_local_implicit_ns_packages(): diff --git a/tests/integration/test_issue_661.py b/tests/integration/test_issue_661.py index 504c30f74..c3027d907 100644 --- a/tests/integration/test_issue_661.py +++ b/tests/integration/test_issue_661.py @@ -2,12 +2,11 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess import pytest from pex.common import temporary_dir -from testing import IS_ARM_64, IS_PYPY, run_pex_command +from testing import IS_ARM_64, IS_PYPY, run_pex_command, subprocess @pytest.mark.skipif( diff --git a/tests/integration/test_issue_736.py b/tests/integration/test_issue_736.py index 4d618fa53..bee244001 100644 --- a/tests/integration/test_issue_736.py +++ b/tests/integration/test_issue_736.py @@ -2,10 +2,9 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess from pex.common import safe_copy, temporary_dir -from testing import built_wheel, make_env, make_source_dir, run_pex_command +from testing import built_wheel, make_env, make_source_dir, run_pex_command, subprocess def test_requirement_setup_py_with_extras(): diff --git a/tests/integration/test_issue_745.py b/tests/integration/test_issue_745.py index ac9d699f6..356c81234 100644 --- a/tests/integration/test_issue_745.py +++ b/tests/integration/test_issue_745.py @@ -2,13 +2,12 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess from textwrap import dedent import pytest from pex.common import safe_open, temporary_dir -from testing import PY27, ensure_python_venv, make_env, run_pex_command +from testing import PY27, ensure_python_venv, make_env, run_pex_command, subprocess def test_extras_isolation(): diff --git a/tests/integration/test_issue_898.py b/tests/integration/test_issue_898.py index e7051472c..3786aa368 100644 --- a/tests/integration/test_issue_898.py +++ b/tests/integration/test_issue_898.py @@ -2,11 +2,10 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess from textwrap import dedent from pex.common import safe_open, temporary_dir -from testing import PY27, PY310, ensure_python_interpreter, make_env, run_pex_command +from testing import PY27, PY310, ensure_python_interpreter, make_env, run_pex_command, subprocess def test_top_level_requirements_requires_python_env_markers(): diff --git a/tests/integration/test_issue_996.py b/tests/integration/test_issue_996.py index 19472d18e..f81e43aa4 100644 --- a/tests/integration/test_issue_996.py +++ b/tests/integration/test_issue_996.py @@ -4,13 +4,20 @@ import multiprocessing import os import re -import subprocess from textwrap import dedent from pex.interpreter import PythonInterpreter from pex.targets import AbbreviatedPlatform from pex.typing import TYPE_CHECKING -from testing import PY39, PY310, IntegResults, ensure_python_interpreter, make_env, run_pex_command +from testing import ( + PY39, + PY310, + IntegResults, + ensure_python_interpreter, + make_env, + run_pex_command, + subprocess, +) from testing.pytest.tmp import Tempdir if TYPE_CHECKING: diff --git a/tests/integration/test_layout.py b/tests/integration/test_layout.py index 305fcbb23..2207af1d2 100644 --- a/tests/integration/test_layout.py +++ b/tests/integration/test_layout.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess import sys import pytest @@ -11,7 +10,7 @@ from pex.layout import Layout from pex.pep_427 import InstallableType from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess from testing.pep_427 import get_installable_type_flag if TYPE_CHECKING: diff --git a/tests/integration/test_lock_resolver.py b/tests/integration/test_lock_resolver.py index f11033a66..adff378c3 100644 --- a/tests/integration/test_lock_resolver.py +++ b/tests/integration/test_lock_resolver.py @@ -6,7 +6,6 @@ import os import re import shutil -import subprocess import sys from textwrap import dedent @@ -23,7 +22,7 @@ from pex.pex_info import PexInfo from pex.typing import TYPE_CHECKING from pex.util import CacheHelper -from testing import IS_PYPY, PY_VER, built_wheel, make_env, run_pex_command +from testing import IS_PYPY, PY_VER, built_wheel, make_env, run_pex_command, subprocess from testing.cli import run_pex3 from testing.lock import index_lock_artifacts from testing.pytest.tmp import Tempdir, TempdirFactory diff --git a/tests/integration/test_no_pre_install_wheels.py b/tests/integration/test_no_pre_install_wheels.py index 6258ff734..e55c6ef08 100644 --- a/tests/integration/test_no_pre_install_wheels.py +++ b/tests/integration/test_no_pre_install_wheels.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import hashlib import os -import subprocess import zipfile from textwrap import dedent @@ -13,7 +12,7 @@ from pex.pex_info import PexInfo from pex.typing import TYPE_CHECKING from pex.util import CacheHelper -from testing import run_pex_command +from testing import run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_overrides.py b/tests/integration/test_overrides.py index c19d5a3eb..03fb3e6fd 100644 --- a/tests/integration/test_overrides.py +++ b/tests/integration/test_overrides.py @@ -6,7 +6,6 @@ import os.path import re import shutil -import subprocess import sys from collections import defaultdict @@ -18,7 +17,16 @@ from pex.pex import PEX from pex.pex_info import PexInfo from pex.typing import TYPE_CHECKING -from testing import PY39, PY310, PY_VER, data, ensure_python_interpreter, make_env, run_pex_command +from testing import ( + PY39, + PY310, + PY_VER, + data, + ensure_python_interpreter, + make_env, + run_pex_command, + subprocess, +) from testing.cli import run_pex3 from testing.lock import extract_lock_option_args, index_lock_artifacts diff --git a/tests/integration/test_pep_427.py b/tests/integration/test_pep_427.py index 3cbefe8d2..ec6ee39fc 100644 --- a/tests/integration/test_pep_427.py +++ b/tests/integration/test_pep_427.py @@ -3,7 +3,6 @@ import os.path import re -import subprocess from glob import glob from textwrap import dedent @@ -14,7 +13,7 @@ from pex.resolve.configured_resolver import ConfiguredResolver from pex.typing import TYPE_CHECKING from pex.venv.virtualenv import InstallationChoice, Virtualenv -from testing import WheelBuilder, make_env +from testing import WheelBuilder, make_env, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_pex_bootstrapper.py b/tests/integration/test_pex_bootstrapper.py index 91966ac49..4cd76bbe1 100644 --- a/tests/integration/test_pex_bootstrapper.py +++ b/tests/integration/test_pex_bootstrapper.py @@ -3,7 +3,6 @@ import json import os.path import re -import subprocess import sys from textwrap import dedent @@ -20,7 +19,15 @@ from pex.typing import TYPE_CHECKING from pex.venv.installer import CollisionError from pex.venv.virtualenv import Virtualenv -from testing import PY38, PY39, PY_VER, ensure_python_interpreter, make_env, run_pex_command +from testing import ( + PY38, + PY39, + PY_VER, + ensure_python_interpreter, + make_env, + run_pex_command, + subprocess, +) from testing.pytest.tmp import Tempdir if TYPE_CHECKING: diff --git a/tests/integration/test_pex_entry_points.py b/tests/integration/test_pex_entry_points.py index e99aa504d..4beca7ea8 100644 --- a/tests/integration/test_pex_entry_points.py +++ b/tests/integration/test_pex_entry_points.py @@ -2,12 +2,11 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess from textwrap import dedent from pex.common import safe_open from pex.typing import TYPE_CHECKING -from testing import make_project, run_pex_command +from testing import make_project, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_pex_import.py b/tests/integration/test_pex_import.py index 4c065c680..4eb82ef65 100644 --- a/tests/integration/test_pex_import.py +++ b/tests/integration/test_pex_import.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess from textwrap import dedent import colors # vendor:skip @@ -17,7 +16,7 @@ from pex.typing import TYPE_CHECKING from pex.variables import ENV from pex.venv.virtualenv import Virtualenv -from testing import make_env, run_pex_command +from testing import make_env, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, List, Text diff --git a/tests/integration/test_reexec.py b/tests/integration/test_reexec.py index 84ce63c9e..2d7abf1c3 100644 --- a/tests/integration/test_reexec.py +++ b/tests/integration/test_reexec.py @@ -3,7 +3,6 @@ import json import os -import subprocess import sys from textwrap import dedent @@ -20,6 +19,7 @@ make_env, run_pex_command, run_simple_pex, + subprocess, ) if TYPE_CHECKING: diff --git a/tests/integration/test_script_metadata.py b/tests/integration/test_script_metadata.py index 2566e070a..40e5f4c00 100644 --- a/tests/integration/test_script_metadata.py +++ b/tests/integration/test_script_metadata.py @@ -5,7 +5,6 @@ import os.path import re -import subprocess import sys from textwrap import dedent @@ -14,7 +13,7 @@ from pex.targets import LocalInterpreter from pex.third_party.packaging.specifiers import SpecifierSet from pex.typing import TYPE_CHECKING -from testing import PY310, ensure_python_interpreter, run_pex_command +from testing import PY310, ensure_python_interpreter, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/test_setproctitle.py b/tests/integration/test_setproctitle.py index ecfda9084..8a4f54dc9 100644 --- a/tests/integration/test_setproctitle.py +++ b/tests/integration/test_setproctitle.py @@ -1,7 +1,6 @@ # Copyright 2022 Pex project contributors. # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess import sys import sysconfig from textwrap import dedent @@ -16,7 +15,7 @@ from pex.pep_427 import InstallableType from pex.pex_info import PexInfo from pex.typing import TYPE_CHECKING -from testing import IS_MAC, run_pex_command +from testing import IS_MAC, run_pex_command, subprocess from testing.pep_427 import get_installable_type_flag if TYPE_CHECKING: diff --git a/tests/integration/test_sh_boot.py b/tests/integration/test_sh_boot.py index d7185d9ad..1936c7f7b 100644 --- a/tests/integration/test_sh_boot.py +++ b/tests/integration/test_sh_boot.py @@ -4,7 +4,6 @@ import json import os import re -import subprocess import sys from textwrap import dedent @@ -14,7 +13,7 @@ from pex.layout import Layout from pex.os import WINDOWS from pex.typing import TYPE_CHECKING -from testing import all_pythons, make_env, run_pex_command +from testing import all_pythons, make_env, run_pex_command, subprocess from testing.pytest.tmp import Tempdir if TYPE_CHECKING: diff --git a/tests/integration/test_shebang_length_limit.py b/tests/integration/test_shebang_length_limit.py index c3986b2f3..0e58ad33d 100644 --- a/tests/integration/test_shebang_length_limit.py +++ b/tests/integration/test_shebang_length_limit.py @@ -7,7 +7,6 @@ import json import os import shutil -import subprocess from textwrap import dedent import colors # vendor:skip @@ -20,7 +19,7 @@ from pex.fs import safe_symlink from pex.os import WINDOWS from pex.typing import TYPE_CHECKING -from testing import IS_PYPY, make_project, run_pex_command +from testing import IS_PYPY, make_project, run_pex_command, subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/test_variables.py b/tests/integration/test_variables.py index 582e168b1..d14b5a2f6 100644 --- a/tests/integration/test_variables.py +++ b/tests/integration/test_variables.py @@ -2,14 +2,13 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess import sys import pytest from pex.layout import Layout from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/tools/commands/test_issue_2105.py b/tests/integration/tools/commands/test_issue_2105.py index cc70e360a..d4743d1de 100644 --- a/tests/integration/tools/commands/test_issue_2105.py +++ b/tests/integration/tools/commands/test_issue_2105.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess from textwrap import dedent import pytest @@ -13,7 +12,7 @@ from pex.pex import PEX from pex.typing import TYPE_CHECKING from pex.venv.virtualenv import InstallationChoice, Virtualenv -from testing import make_env, run_pex_command +from testing import make_env, run_pex_command, subprocess from testing.pytest.tmp import Tempdir, TempdirFactory if TYPE_CHECKING: diff --git a/tests/integration/tools/commands/test_venv.py b/tests/integration/tools/commands/test_venv.py index f3e486492..274717f51 100644 --- a/tests/integration/tools/commands/test_venv.py +++ b/tests/integration/tools/commands/test_venv.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess import sys from textwrap import dedent @@ -12,7 +11,7 @@ from pex.typing import TYPE_CHECKING from pex.util import CacheHelper from pex.venv.virtualenv import Virtualenv -from testing import IntegResults, make_env, run_pex_command +from testing import IntegResults, make_env, run_pex_command, subprocess from testing.venv import assert_venv_site_packages_copy_mode if TYPE_CHECKING: diff --git a/tests/integration/venv_ITs/test_issue_1630.py b/tests/integration/venv_ITs/test_issue_1630.py index 3534ebae5..fd09f934a 100644 --- a/tests/integration/venv_ITs/test_issue_1630.py +++ b/tests/integration/venv_ITs/test_issue_1630.py @@ -3,7 +3,6 @@ import json import os -import subprocess from pex.cache.dirs import CacheDir from pex.dist_metadata import Distribution @@ -12,7 +11,7 @@ from pex.pex_info import PexInfo from pex.typing import TYPE_CHECKING from pex.venv.virtualenv import Virtualenv -from testing import PY38, ensure_python_venv, run_pex_command +from testing import PY38, ensure_python_venv, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, Container, List diff --git a/tests/integration/venv_ITs/test_issue_1637.py b/tests/integration/venv_ITs/test_issue_1637.py index b3a8a55c4..5de4a5624 100644 --- a/tests/integration/venv_ITs/test_issue_1637.py +++ b/tests/integration/venv_ITs/test_issue_1637.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess from textwrap import dedent import pytest @@ -10,8 +9,8 @@ from pex.cache.dirs import CacheDir from pex.common import safe_open, touch -from pex.typing import TYPE_CHECKING -from testing import make_env, run_pex_command +from pex.typing import TYPE_CHECKING, cast +from testing import make_env, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, Iterable, List, Text @@ -83,7 +82,7 @@ def execute_app( stripped_stderr = stderr.decode("utf-8").strip() assert 0 == process.returncode, stripped_stderr assert yellow("*** Flashy UI ***") in stripped_stderr - return stdout.decode("utf-8").splitlines() + return cast("List[Text]", stdout.decode("utf-8").splitlines()) def test_pex_path_dedup(tmpdir): diff --git a/tests/integration/venv_ITs/test_issue_1641.py b/tests/integration/venv_ITs/test_issue_1641.py index c9f4ed8d5..06e398894 100644 --- a/tests/integration/venv_ITs/test_issue_1641.py +++ b/tests/integration/venv_ITs/test_issue_1641.py @@ -1,13 +1,12 @@ # Copyright 2022 Pex project contributors. # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess from textwrap import dedent import pytest from pex.typing import TYPE_CHECKING -from testing import PY_VER, run_pex_command +from testing import PY_VER, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, List diff --git a/tests/integration/venv_ITs/test_issue_1668.py b/tests/integration/venv_ITs/test_issue_1668.py index 4e10069a3..0fb376c5d 100644 --- a/tests/integration/venv_ITs/test_issue_1668.py +++ b/tests/integration/venv_ITs/test_issue_1668.py @@ -2,10 +2,16 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess from pex.typing import TYPE_CHECKING -from testing import PY38, ensure_python_interpreter, make_env, pex_project_dir, run_pex_command +from testing import ( + PY38, + ensure_python_interpreter, + make_env, + pex_project_dir, + run_pex_command, + subprocess, +) if TYPE_CHECKING: from typing import Any diff --git a/tests/integration/venv_ITs/test_issue_1745.py b/tests/integration/venv_ITs/test_issue_1745.py index 223cd1d88..03c8417a5 100644 --- a/tests/integration/venv_ITs/test_issue_1745.py +++ b/tests/integration/venv_ITs/test_issue_1745.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess from textwrap import dedent import pytest @@ -11,7 +10,7 @@ from pex.common import safe_open from pex.enum import Enum from pex.typing import TYPE_CHECKING -from testing import IntegResults, run_pex_command +from testing import IntegResults, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, List, Optional diff --git a/tests/integration/venv_ITs/test_issue_1973.py b/tests/integration/venv_ITs/test_issue_1973.py index eecc7b398..883f537d5 100644 --- a/tests/integration/venv_ITs/test_issue_1973.py +++ b/tests/integration/venv_ITs/test_issue_1973.py @@ -5,14 +5,13 @@ import os.path import shutil -import subprocess import colors # vendor:skip import pytest from pex.interpreter import PythonInterpreter from pex.typing import TYPE_CHECKING -from testing import PY310, ensure_python_distribution, make_env, run_pex_command +from testing import PY310, ensure_python_distribution, make_env, run_pex_command, subprocess from testing.cli import run_pex3 if TYPE_CHECKING: diff --git a/tests/integration/venv_ITs/test_issue_2065.py b/tests/integration/venv_ITs/test_issue_2065.py index a44c9bf6b..c610a9fcf 100644 --- a/tests/integration/venv_ITs/test_issue_2065.py +++ b/tests/integration/venv_ITs/test_issue_2065.py @@ -3,14 +3,13 @@ import json import os -import subprocess from textwrap import dedent import pytest from pex.common import safe_open from pex.typing import TYPE_CHECKING -from testing import make_env, run_pex_command +from testing import make_env, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, List diff --git a/tests/integration/venv_ITs/test_issue_2160.py b/tests/integration/venv_ITs/test_issue_2160.py index 7f3bc433d..807a0be34 100644 --- a/tests/integration/venv_ITs/test_issue_2160.py +++ b/tests/integration/venv_ITs/test_issue_2160.py @@ -1,7 +1,6 @@ # Copyright 2023 Pex project contributors. # Licensed under the Apache License, Version 2.0 (see LICENSE). import os.path -import subprocess import sys from textwrap import dedent @@ -13,7 +12,7 @@ from pex.pep_503 import ProjectName from pex.pex import PEX from pex.typing import TYPE_CHECKING -from testing import WheelBuilder, run_pex_command +from testing import WheelBuilder, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, List diff --git a/tests/integration/venv_ITs/test_issue_2248.py b/tests/integration/venv_ITs/test_issue_2248.py index 9e06a6685..09f5eaabd 100644 --- a/tests/integration/venv_ITs/test_issue_2248.py +++ b/tests/integration/venv_ITs/test_issue_2248.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess import sys from textwrap import dedent @@ -11,7 +10,7 @@ from pex.typing import TYPE_CHECKING from pex.version import __version__ -from testing import IntegResults, run_pex_command +from testing import IntegResults, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, List diff --git a/tests/integration/venv_ITs/test_virtualenv.py b/tests/integration/venv_ITs/test_virtualenv.py index a29a7bbea..81a6d8760 100644 --- a/tests/integration/venv_ITs/test_virtualenv.py +++ b/tests/integration/venv_ITs/test_virtualenv.py @@ -4,7 +4,6 @@ import json import os.path import shutil -import subprocess from textwrap import dedent import pytest @@ -13,7 +12,7 @@ from pex.pep_503 import ProjectName from pex.typing import TYPE_CHECKING from pex.venv.virtualenv import InstallationChoice, InvalidVirtualenvError, Virtualenv -from testing import VenvFactory, all_python_venvs +from testing import VenvFactory, all_python_venvs, subprocess from testing.docker import DockerVirtualenvRunner if TYPE_CHECKING: diff --git a/tests/pip/test_log_analyzer.py b/tests/pip/test_log_analyzer.py index 09810295e..d2999939d 100644 --- a/tests/pip/test_log_analyzer.py +++ b/tests/pip/test_log_analyzer.py @@ -4,7 +4,6 @@ from __future__ import absolute_import import os.path -import subprocess from textwrap import dedent import pytest @@ -13,6 +12,7 @@ from pex.jobs import Job from pex.pip.log_analyzer import ErrorAnalyzer, ErrorMessage, LogAnalyzer, LogScrapeJob from pex.typing import TYPE_CHECKING +from testing import subprocess if TYPE_CHECKING: from typing import Any, Optional diff --git a/tests/resolve/lockfile/test_json_codec.py b/tests/resolve/lockfile/test_json_codec.py index 66eeb03f7..0cb150b6e 100644 --- a/tests/resolve/lockfile/test_json_codec.py +++ b/tests/resolve/lockfile/test_json_codec.py @@ -4,7 +4,6 @@ import json import os import re -import subprocess from textwrap import dedent import pytest @@ -24,6 +23,7 @@ from pex.sorted_tuple import SortedTuple from pex.third_party.packaging import tags from pex.typing import TYPE_CHECKING +from testing import subprocess if TYPE_CHECKING: from typing import Any, Container diff --git a/tests/test_bdist_pex.py b/tests/test_bdist_pex.py index 6d49be612..d55ae53ef 100644 --- a/tests/test_bdist_pex.py +++ b/tests/test_bdist_pex.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess import sys from contextlib import contextmanager from textwrap import dedent @@ -15,7 +14,7 @@ from pex.resolver import resolve from pex.typing import TYPE_CHECKING from pex.venv.virtualenv import InstallationChoice, Virtualenv -from testing import WheelBuilder, make_project, pex_project_dir, temporary_content +from testing import WheelBuilder, make_project, pex_project_dir, subprocess, temporary_content if TYPE_CHECKING: from typing import Dict, Iterable, Iterator, List, Optional, Union diff --git a/tests/test_environment.py b/tests/test_environment.py index 451b3b459..5d4cd7fac 100644 --- a/tests/test_environment.py +++ b/tests/test_environment.py @@ -3,7 +3,6 @@ import os import platform -import subprocess import sys from contextlib import contextmanager from textwrap import dedent @@ -32,6 +31,7 @@ ensure_python_interpreter, install_wheel, make_bdist, + subprocess, temporary_content, temporary_filename, ) diff --git a/tests/test_execution_mode.py b/tests/test_execution_mode.py index dd2f02937..4f6a83d0c 100644 --- a/tests/test_execution_mode.py +++ b/tests/test_execution_mode.py @@ -4,7 +4,6 @@ from __future__ import absolute_import import os.path -import subprocess import sys from subprocess import CalledProcessError @@ -14,7 +13,7 @@ from pex.layout import Layout from pex.pep_427 import InstallableType from pex.typing import TYPE_CHECKING -from testing import run_pex_command +from testing import run_pex_command, subprocess from testing.pep_427 import get_installable_type_flag if TYPE_CHECKING: diff --git a/tests/test_executor.py b/tests/test_executor.py index 7004b8d80..d83291d96 100644 --- a/tests/test_executor.py +++ b/tests/test_executor.py @@ -2,13 +2,13 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess import pytest from pex.common import safe_mkdir, temporary_dir from pex.executor import Executor from pex.typing import TYPE_CHECKING +from testing import subprocess if TYPE_CHECKING: from typing import Callable, List diff --git a/tests/test_interpreter.py b/tests/test_interpreter.py index fffbcc5cb..023c9f5d7 100644 --- a/tests/test_interpreter.py +++ b/tests/test_interpreter.py @@ -7,7 +7,6 @@ import json import os import re -import subprocess import sys from collections import defaultdict from contextlib import contextmanager @@ -35,6 +34,7 @@ ensure_python_interpreter, ensure_python_venv, pushd, + subprocess, ) from testing.pytest.tmp import TempdirFactory diff --git a/tests/test_jobs.py b/tests/test_jobs.py index 7c460aaa8..49f5a9636 100644 --- a/tests/test_jobs.py +++ b/tests/test_jobs.py @@ -5,7 +5,6 @@ import json import os -import subprocess from textwrap import dedent import pytest @@ -13,6 +12,7 @@ from pex.interpreter import PythonInterpreter from pex.jobs import _ABSOLUTE_MAX_JOBS, DEFAULT_MAX_JOBS, Job, SpawnedJob, _sanitize_max_jobs from pex.typing import TYPE_CHECKING, cast +from testing import subprocess if TYPE_CHECKING: from typing import Any, Dict, Iterable diff --git a/tests/test_packaging.py b/tests/test_packaging.py index db6ce1221..608d4bcef 100644 --- a/tests/test_packaging.py +++ b/tests/test_packaging.py @@ -4,14 +4,13 @@ from __future__ import absolute_import import os -import subprocess import sys from pex.interpreter import PythonInterpreter from pex.tools.commands import all_commands from pex.venv.virtualenv import Virtualenv from pex.version import __version__ -from testing import make_env +from testing import make_env, subprocess # N.B.: Our test environments include Pex installed from our pyproject.toml in a Tox managed venv. # This is how Tox works and its critical background to the assumptions made in the tests below. diff --git a/tests/test_pex.py b/tests/test_pex.py index c05d55fa1..e11b7b6cc 100644 --- a/tests/test_pex.py +++ b/tests/test_pex.py @@ -4,7 +4,6 @@ import json import os import site -import subprocess import sys import sysconfig import tempfile @@ -39,6 +38,7 @@ make_bdist, run_simple_pex, run_simple_pex_test, + subprocess, temporary_content, write_simple_pex, ) diff --git a/tests/test_pex_bootstrapper.py b/tests/test_pex_bootstrapper.py index 863a76983..0b1bc1929 100644 --- a/tests/test_pex_bootstrapper.py +++ b/tests/test_pex_bootstrapper.py @@ -3,7 +3,6 @@ import os import shutil -import subprocess import sys from textwrap import dedent @@ -25,7 +24,7 @@ from pex.pex_builder import PEXBuilder from pex.typing import TYPE_CHECKING from pex.variables import ENV -from testing import PY38, PY39, PY310, ensure_python_interpreter +from testing import PY38, PY39, PY310, ensure_python_interpreter, subprocess if TYPE_CHECKING: from typing import Any, Iterable, List, Optional diff --git a/tests/test_pex_builder.py b/tests/test_pex_builder.py index 32cce9dc2..3821e5787 100644 --- a/tests/test_pex_builder.py +++ b/tests/test_pex_builder.py @@ -5,7 +5,6 @@ import os import re import stat -import subprocess import sys import zipfile from contextlib import contextmanager @@ -25,7 +24,15 @@ from pex.pex_warnings import PEXWarning from pex.typing import TYPE_CHECKING from pex.variables import ENV -from testing import IS_PYPY, NonDeterministicWalk, WheelBuilder, install_wheel, make_bdist, make_env +from testing import ( + IS_PYPY, + NonDeterministicWalk, + WheelBuilder, + install_wheel, + make_bdist, + make_env, + subprocess, +) from testing import write_simple_pex as write_pex try: diff --git a/tests/test_resolver.py b/tests/test_resolver.py index 9363a5ae9..e9d9edb29 100644 --- a/tests/test_resolver.py +++ b/tests/test_resolver.py @@ -3,7 +3,6 @@ import os import shutil -import subprocess import sys import zipfile from collections import defaultdict @@ -38,6 +37,7 @@ ensure_python_interpreter, make_project, make_source_dir, + subprocess, ) if TYPE_CHECKING: diff --git a/tests/test_third_party.py b/tests/test_third_party.py index 2fa5da167..3a7323756 100644 --- a/tests/test_third_party.py +++ b/tests/test_third_party.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess import sys from contextlib import contextmanager @@ -11,6 +10,7 @@ from pex.compatibility import commonpath from pex.typing import TYPE_CHECKING from pex.variables import ENV +from testing import subprocess if TYPE_CHECKING: from typing import Dict, Iterator, Tuple diff --git a/tests/test_util.py b/tests/test_util.py index e71dd2b54..aa37b7713 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -2,7 +2,6 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess from hashlib import sha1 from textwrap import dedent @@ -14,6 +13,7 @@ from pex.pex_builder import PEXBuilder from pex.typing import TYPE_CHECKING, cast from pex.util import CacheHelper, DistributionHelper, named_temporary_file +from testing import subprocess if TYPE_CHECKING: from typing import Callable diff --git a/tests/test_vendor.py b/tests/test_vendor.py index 469be698b..a52e25afc 100644 --- a/tests/test_vendor.py +++ b/tests/test_vendor.py @@ -2,12 +2,12 @@ # Licensed under the Apache License, Version 2.0 (see LICENSE). import os -import subprocess import sys from pex.common import touch from pex.typing import TYPE_CHECKING from pex.vendor import VendorSpec +from testing import subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/test_zip_utils.py b/tests/test_zip_utils.py index c10e3652c..6238250df 100644 --- a/tests/test_zip_utils.py +++ b/tests/test_zip_utils.py @@ -5,7 +5,6 @@ import os.path import re import shutil -import subprocess import sys from io import BytesIO @@ -14,7 +13,7 @@ from pex.common import open_zip from pex.typing import TYPE_CHECKING from pex.ziputils import Zip, ZipError -from testing import PY_VER +from testing import PY_VER, subprocess if TYPE_CHECKING: from typing import Any diff --git a/tests/tools/commands/test_repository.py b/tests/tools/commands/test_repository.py index e7f77ad9d..b56b52667 100644 --- a/tests/tools/commands/test_repository.py +++ b/tests/tools/commands/test_repository.py @@ -8,7 +8,6 @@ import json import os import signal -import subprocess from textwrap import dedent import pytest @@ -22,7 +21,14 @@ from pex.resolve.resolver_configuration import BuildConfiguration from pex.third_party.packaging.specifiers import SpecifierSet from pex.typing import TYPE_CHECKING -from testing import PY310, PY_VER, ensure_python_venv, run_command_with_jitter, run_pex_command +from testing import ( + PY310, + PY_VER, + ensure_python_venv, + run_command_with_jitter, + run_pex_command, + subprocess, +) if TYPE_CHECKING: from typing import Any, Dict, Iterator diff --git a/tests/tools/commands/test_venv.py b/tests/tools/commands/test_venv.py index 03d759175..d5c58a9b5 100644 --- a/tests/tools/commands/test_venv.py +++ b/tests/tools/commands/test_venv.py @@ -7,7 +7,6 @@ import multiprocessing import os import shutil -import subprocess import sys import tempfile from subprocess import CalledProcessError @@ -24,7 +23,7 @@ from pex.typing import TYPE_CHECKING, cast from pex.util import named_temporary_file from pex.venv.virtualenv import Virtualenv -from testing import IS_PYPY, PY310, PY_VER, ensure_python_interpreter, run_pex_command +from testing import IS_PYPY, PY310, PY_VER, ensure_python_interpreter, run_pex_command, subprocess if TYPE_CHECKING: from typing import Any, Dict, Iterable, Iterator, List, Optional, Protocol, Set, Text, Tuple