From cf4aa52cdc7347b776bb9ad564b1be0ef211aee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anna=20=E2=80=9CCyberTailor=E2=80=9D?= Date: Sun, 3 Nov 2024 21:46:13 +0500 Subject: [PATCH] Use temporary home directory for `test_env_file_home_directory` Issue: https://github.com/pydantic/pydantic-settings/issues/463 --- tests/test_settings.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_settings.py b/tests/test_settings.py index 7321fde..8e6297e 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -1116,9 +1116,13 @@ class Settings(BaseSettings): @pytest.fixture -def home_tmp(): +def home_tmp(tmp_path, env): + env.set('HOME', str(tmp_path)) + env.set('USERPROFILE', str(tmp_path)) + env.set('HOMEPATH', str(tmp_path)) + tmp_filename = f'{uuid.uuid4()}.env' - home_tmp_path = Path.home() / tmp_filename + home_tmp_path = tmp_path / tmp_filename yield home_tmp_path, tmp_filename home_tmp_path.unlink()