From 5ea0519f62c8562633f269ce0ea147629ea6334a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 25 Sep 2022 14:36:12 +0530 Subject: [PATCH] Pass through python used for type check to the test code from before the env is sanitized --- kitty_tests/main.py | 2 +- test.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kitty_tests/main.py b/kitty_tests/main.py index 3a2419944..e5e254a85 100644 --- a/kitty_tests/main.py +++ b/kitty_tests/main.py @@ -66,7 +66,7 @@ def type_check() -> NoReturn: generate_stub() from kittens.tui.operations_stub import generate_stub # type: ignore generate_stub() - py = shutil.which('python') or shutil.which('python3') + py = os.environ.get('PYTHON_FOR_TYPE_CHECK') or shutil.which('python') or shutil.which('python3') os.execlp(py, py, '-m', 'mypy', '--pretty') diff --git a/test.py b/test.py index c117ffed8..3ee637842 100755 --- a/test.py +++ b/test.py @@ -3,6 +3,7 @@ import importlib import os +import shutil import warnings from contextlib import contextmanager from tempfile import TemporaryDirectory @@ -30,13 +31,14 @@ def main() -> None: path = os.pathsep.join(x for x in paths if not x.startswith(current_home)) launcher_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'kitty', 'launcher') path = f'{launcher_dir}{os.pathsep}{path}' + PYTHON_FOR_TYPE_CHECK = shutil.which('python') or shutil.which('python3') or '' with TemporaryDirectory() as tdir, env_vars( PYTHONWARNINGS='error', HOME=tdir, USERPROFILE=tdir, PATH=path, XDG_CONFIG_HOME=os.path.join(tdir, '.config'), XDG_CONFIG_DIRS=os.path.join(tdir, '.config'), XDG_DATA_DIRS=os.path.join(tdir, '.local', 'xdg'), XDG_CACHE_HOME=os.path.join(tdir, '.cache'), - KITTY_PREWARM_SOCKET='', + PYTHON_FOR_TYPE_CHECK=PYTHON_FOR_TYPE_CHECK, ): m = importlib.import_module('kitty_tests.main') getattr(m, 'run_tests')()