commit: f1e580aa96256cc3aadb555a3e811804b1c153cb Author: Brian Harring <ferringb <AT> gmail <DOT> com> AuthorDate: Tue Oct 28 09:35:28 2025 +0000 Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> CommitDate: Tue Oct 28 15:38:05 2025 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=f1e580aa
use a fake $HOME for tests git uses both repo/.git/config and $HOME/.gitconfig, thus the tests have been picking up my commit.gpgsign=1 . Whilst pkgcore's git repo fixture can be tweaked to add that suppression, hygenically it's better to disconnect the users persona configuration from tests in full. TL;dr: this stops tests from popping a gpg key decrypt randomly for my local dev. Signed-off-by: Brian Harring <ferringb <AT> gmail.com> Part-of: https://github.com/pkgcore/pkgdev/pull/215 Closes: https://github.com/pkgcore/pkgdev/pull/215 Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org> tests/conftest.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index dc42ba5..feb90ea 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,13 +1,35 @@ +import os +import shutil +import tempfile + import pytest +from snakeoil.cli import arghparse + from pkgdev.cli import Tool from pkgdev.scripts import pkgdev -from snakeoil.cli import arghparse pytest_plugins = ["pkgcore"] @pytest.fixture(scope="session") -def tool(): +def temporary_home(): + """Generate a temporary directory and set$HOME to it.""" + old_home = os.environ.get("HOME") + new_home = None + try: + new_home = tempfile.mkdtemp() + os.environ["HOME"] = new_home + yield + finally: + if old_home is None: + del os.environ["HOME"] + else: + os.environ["HOME"] = old_home + shutil.rmtree(new_home) # pyright: ignore[reportArgumentType] + + [email protected](scope="session") +def tool(temporary_home): """Generate a tool utility for running pkgdev.""" return Tool(pkgdev.argparser)
