From 7a535fb3d2315fb6b73f3346fbd53468e48ccbfc Mon Sep 17 00:00:00 2001 From: Brian Harring Date: Sun, 21 Jan 2024 19:20:33 -0800 Subject: fix: suppress $HOME for tests. Suppressing $HOME is necessary for hygenic tests; to avoid anything in the dev's environment becoming relied upon for the test passing. A slightly more salient point for me; every `git commit` test was asking for my gpg unlock for git commits; obviously annoying, also obviously unhygenic (I could have modified default git commit template for example). Signed-off-by: Brian Harring --- src/pkgcore/pytest/plugin.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pkgcore/pytest/plugin.py b/src/pkgcore/pytest/plugin.py index 0579a45a..d7231dd3 100644 --- a/src/pkgcore/pytest/plugin.py +++ b/src/pkgcore/pytest/plugin.py @@ -41,6 +41,8 @@ class GitRepo: self.add(pjoin(self.path, ".init"), create=True) def run(self, cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, **kwargs): + env = os.environ.copy() + env["HOME"] = self.path return subprocess.run( cmd, cwd=self.path, @@ -48,6 +50,7 @@ class GitRepo: check=True, stdout=stdout, stderr=stderr, + env=env, **kwargs, ) -- cgit v1.2.3-65-gdbad