From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 44D7C15838C for ; Tue, 23 Jan 2024 19:01:36 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 07438E2AA1; Tue, 23 Jan 2024 19:01:35 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C4FB6E2A9E for ; Tue, 23 Jan 2024 19:01:34 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id BEFF834310F for ; Tue, 23 Jan 2024 19:01:33 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2F6DFF7D for ; Tue, 23 Jan 2024 19:01:32 +0000 (UTC) From: "Arthur Zamarin" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Arthur Zamarin" Message-ID: <1705999132.7a535fb3d2315fb6b73f3346fbd53468e48ccbfc.arthurzam@gentoo> Subject: [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/pytest/ X-VCS-Repository: proj/pkgcore/pkgcore X-VCS-Files: src/pkgcore/pytest/plugin.py X-VCS-Directories: src/pkgcore/pytest/ X-VCS-Committer: arthurzam X-VCS-Committer-Name: Arthur Zamarin X-VCS-Revision: 7a535fb3d2315fb6b73f3346fbd53468e48ccbfc X-VCS-Branch: master Date: Tue, 23 Jan 2024 19:01:32 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: f5231141-cbac-4ce2-9c0b-6928fb8217ad X-Archives-Hash: b20c9fb5cddf616eedf09a15943a5e1d commit: 7a535fb3d2315fb6b73f3346fbd53468e48ccbfc Author: Brian Harring gmail com> AuthorDate: Mon Jan 22 03:20:33 2024 +0000 Commit: Arthur Zamarin gentoo org> CommitDate: Tue Jan 23 08:38:52 2024 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=7a535fb3 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 gmail.com> 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 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, )