aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Harring <ferringb@gmail.com>2024-01-21 19:20:33 -0800
committerBrian Harring <ferringb@gmail.com>2024-01-23 00:38:52 -0800
commit7a535fb3d2315fb6b73f3346fbd53468e48ccbfc (patch)
tree9033948c389765d8a61e06bdfc724f2f3b845af4
parentupdate python version in various places (diff)
downloadpkgcore-7a535fb3d2315fb6b73f3346fbd53468e48ccbfc.tar.gz
pkgcore-7a535fb3d2315fb6b73f3346fbd53468e48ccbfc.tar.bz2
pkgcore-7a535fb3d2315fb6b73f3346fbd53468e48ccbfc.zip
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 <ferringb@gmail.com>
-rw-r--r--src/pkgcore/pytest/plugin.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/pkgcore/pytest/plugin.py b/src/pkgcore/pytest/plugin.py
index 0579a45ad..d7231dd3c 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,
)