From 4a3fe6b0915114315ac47bc82f058d5a6a299ff3 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Fri, 24 Feb 2023 13:36:03 +0000 Subject: [PATCH 1/2] `stubtest_stdlib.py`: suppress output from pip --- tests/stubtest_stdlib.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/stubtest_stdlib.py b/tests/stubtest_stdlib.py index 75e1238fdba1..2e007123a1d3 100755 --- a/tests/stubtest_stdlib.py +++ b/tests/stubtest_stdlib.py @@ -23,6 +23,7 @@ def run_stubtest(typeshed_dir: Path) -> int: combined_allowlist = f"{sys.platform}-py{sys.version_info.major}{sys.version_info.minor}.txt" with tempfile.TemporaryDirectory() as tmp: venv_dir = Path(tmp) + print("Setting up an isolated virtual environment...") try: pip_exe, python_exe = make_venv(venv_dir) except Exception: @@ -30,10 +31,20 @@ def run_stubtest(typeshed_dir: Path) -> int: raise # Install the same mypy version as in "requirements-tests.txt" - subprocess.run([pip_exe, "install", get_mypy_req()], check=True) + try: + install_command = [pip_exe, "install", get_mypy_req()] + ret = subprocess.run(install_command, check=True, text=True, capture_output=True) + except subprocess.CalledProcessError as e: + print(e.stderr) + raise # Uninstall setuptools from the venv so we can test stdlib's distutils - subprocess.run([pip_exe, "uninstall", "-y", "setuptools"], check=True) + try: + uninstall_command = [pip_exe, "uninstall", "-y", "setuptools"] + ret = subprocess.run(uninstall_command, check=True, text=True, capture_output=True) + except subprocess.CalledProcessError as e: + print(e.stderr) + raise cmd = [ python_exe, From 87e1fa83aac3bc568f4cfebd34ee2f66d19ea0eb Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Fri, 24 Feb 2023 13:41:54 +0000 Subject: [PATCH 2/2] Update stubtest_stdlib.py --- tests/stubtest_stdlib.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/stubtest_stdlib.py b/tests/stubtest_stdlib.py index 2e007123a1d3..496e28a3745a 100755 --- a/tests/stubtest_stdlib.py +++ b/tests/stubtest_stdlib.py @@ -23,7 +23,7 @@ def run_stubtest(typeshed_dir: Path) -> int: combined_allowlist = f"{sys.platform}-py{sys.version_info.major}{sys.version_info.minor}.txt" with tempfile.TemporaryDirectory() as tmp: venv_dir = Path(tmp) - print("Setting up an isolated virtual environment...") + print("Setting up an isolated virtual environment...", file=sys.stderr) try: pip_exe, python_exe = make_venv(venv_dir) except Exception: @@ -33,17 +33,17 @@ def run_stubtest(typeshed_dir: Path) -> int: # Install the same mypy version as in "requirements-tests.txt" try: install_command = [pip_exe, "install", get_mypy_req()] - ret = subprocess.run(install_command, check=True, text=True, capture_output=True) + subprocess.run(install_command, check=True, text=True, capture_output=True) except subprocess.CalledProcessError as e: - print(e.stderr) + print(e.stderr, file=sys.stderr) raise # Uninstall setuptools from the venv so we can test stdlib's distutils try: uninstall_command = [pip_exe, "uninstall", "-y", "setuptools"] - ret = subprocess.run(uninstall_command, check=True, text=True, capture_output=True) + subprocess.run(uninstall_command, check=True, text=True, capture_output=True) except subprocess.CalledProcessError as e: - print(e.stderr) + print(e.stderr, file=sys.stderr) raise cmd = [