fix: TestMain now uses a fake home directory

This prevents tests from reading unexpected settings from the real
`~/.aider.conf.yml` file.

Fixes #1165.
This commit is contained in:
Antti Kaihola 2024-08-28 00:13:36 +03:00
parent ffa30983c7
commit 0746805e43

View file

@ -26,10 +26,14 @@ class TestMain(TestCase):
self.tempdir_obj = IgnorantTemporaryDirectory()
self.tempdir = self.tempdir_obj.name
os.chdir(self.tempdir)
# Fake home directory prevents tests from using the real ~/.aider.conf.yml file:
self.homedir_obj = IgnorantTemporaryDirectory()
os.environ["HOME"] = self.homedir_obj.name
def tearDown(self):
os.chdir(self.original_cwd)
self.tempdir_obj.cleanup()
self.homedir_obj.cleanup()
os.environ.clear()
os.environ.update(self.original_env)