Pass through python used for type check to the test code from before the env is sanitized

This commit is contained in:
Kovid Goyal 2022-09-25 14:36:12 +05:30
parent 98eacb2067
commit 5ea0519f62
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 2 deletions

View File

@ -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')

View File

@ -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')()