Run tests with HOME set to a tempdir

This commit is contained in:
Kovid Goyal 2021-10-31 08:20:46 +05:30
parent 80ab60f1b6
commit 99d9cb0b0d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -6,6 +6,7 @@ import importlib
import os
import sys
import warnings
from tempfile import TemporaryDirectory
base = os.path.dirname(os.path.abspath(__file__))
@ -17,9 +18,11 @@ def init_env() -> None:
def main() -> None:
warnings.simplefilter('error')
os.environ['PYTHONWARNINGS'] = 'error'
init_env()
m = importlib.import_module('kitty_tests.main')
m.run_tests() # type: ignore
with TemporaryDirectory() as tdir:
os.environ['HOME'] = os.environ['USERPROFILE'] = tdir
init_env()
m = importlib.import_module('kitty_tests.main')
m.run_tests() # type: ignore
if __name__ == '__main__':