From 21846f3897bf1f4800a373b9c33e5392979f0341 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Feb 2026 01:52:47 +0000 Subject: [PATCH] fix: disable gpg signing in test git fixtures and skip root-only permission test Test fixtures that create temporary git repos now set commit.gpgsign=false to avoid failures in environments with global commit signing configured. The permission error test is skipped when running as root since file permissions don't apply to the root user. https://claude.ai/code/session_018u1fAx2GihSGctYS64tD4H --- .../self_coding/test_codebase_indexer_errors.py | 17 ++++++++++------- tests/self_coding/test_git_safety.py | 8 +++++++- tests/self_coding/test_git_safety_errors.py | 9 +++++++++ .../self_coding/test_self_coding_integration.py | 6 +++++- tests/self_coding/test_self_edit_tool.py | 6 +++++- 5 files changed, 36 insertions(+), 10 deletions(-) diff --git a/tests/self_coding/test_codebase_indexer_errors.py b/tests/self_coding/test_codebase_indexer_errors.py index 98b356c..93d5eca 100644 --- a/tests/self_coding/test_codebase_indexer_errors.py +++ b/tests/self_coding/test_codebase_indexer_errors.py @@ -273,31 +273,34 @@ except ImportError: async def test_permission_error(self): """Should handle permission errors gracefully.""" + import os + if os.geteuid() == 0: + pytest.skip("Permission tests are ineffective when running as root") + with tempfile.TemporaryDirectory() as tmpdir: repo_path = Path(tmpdir) src_path = repo_path / "src" src_path.mkdir() - + # Create file file_path = src_path / "locked.py" file_path.write_text("def test(): pass") - + # Remove read permission (if on Unix) - import os try: os.chmod(file_path, 0o000) - + indexer = CodebaseIndexer( repo_path=repo_path, db_path=repo_path / "index.db", src_dirs=["src"], ) - + stats = await indexer.index_all() - + # Should count as failed assert stats["failed"] == 1 - + finally: # Restore permission for cleanup os.chmod(file_path, 0o644) diff --git a/tests/self_coding/test_git_safety.py b/tests/self_coding/test_git_safety.py index fea9e17..c987055 100644 --- a/tests/self_coding/test_git_safety.py +++ b/tests/self_coding/test_git_safety.py @@ -43,7 +43,13 @@ def temp_git_repo(): check=True, capture_output=True, ) - + subprocess.run( + ["git", "config", "commit.gpgsign", "false"], + cwd=repo_path, + check=True, + capture_output=True, + ) + # Create initial file and commit (repo_path / "README.md").write_text("# Test Repo") subprocess.run(["git", "add", "."], cwd=repo_path, check=True, capture_output=True) diff --git a/tests/self_coding/test_git_safety_errors.py b/tests/self_coding/test_git_safety_errors.py index 61dde53..88c513d 100644 --- a/tests/self_coding/test_git_safety_errors.py +++ b/tests/self_coding/test_git_safety_errors.py @@ -36,6 +36,7 @@ class TestGitSafetyErrors: subprocess.run(["git", "init"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.email", "test@test.com"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.name", "Test"], cwd=repo_path, check=True, capture_output=True) + subprocess.run(["git", "config", "commit.gpgsign", "false"], cwd=repo_path, check=True, capture_output=True) safety = GitSafety(repo_path=repo_path) @@ -50,6 +51,7 @@ class TestGitSafetyErrors: subprocess.run(["git", "init"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.email", "test@test.com"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.name", "Test"], cwd=repo_path, check=True, capture_output=True) + subprocess.run(["git", "config", "commit.gpgsign", "false"], cwd=repo_path, check=True, capture_output=True) # Create initial file (repo_path / "file.txt").write_text("original") @@ -81,6 +83,7 @@ class TestGitSafetyErrors: subprocess.run(["git", "init"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.email", "test@test.com"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.name", "Test"], cwd=repo_path, check=True, capture_output=True) + subprocess.run(["git", "config", "commit.gpgsign", "false"], cwd=repo_path, check=True, capture_output=True) safety = GitSafety(repo_path=repo_path) @@ -109,6 +112,7 @@ class TestGitSafetyErrors: subprocess.run(["git", "init"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.email", "test@test.com"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.name", "Test"], cwd=repo_path, check=True, capture_output=True) + subprocess.run(["git", "config", "commit.gpgsign", "false"], cwd=repo_path, check=True, capture_output=True) # Need an initial commit for HEAD to exist (repo_path / "initial.txt").write_text("initial") @@ -135,6 +139,7 @@ class TestGitSafetyErrors: subprocess.run(["git", "init"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.email", "test@test.com"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.name", "Test"], cwd=repo_path, check=True, capture_output=True) + subprocess.run(["git", "config", "commit.gpgsign", "false"], cwd=repo_path, check=True, capture_output=True) safety = GitSafety(repo_path=repo_path) @@ -162,6 +167,7 @@ class TestGitSafetyErrors: subprocess.run(["git", "init"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.email", "test@test.com"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.name", "Test"], cwd=repo_path, check=True, capture_output=True) + subprocess.run(["git", "config", "commit.gpgsign", "false"], cwd=repo_path, check=True, capture_output=True) # Need an initial commit for HEAD to exist (repo_path / "initial.txt").write_text("initial") @@ -187,6 +193,7 @@ class TestGitSafetyErrors: subprocess.run(["git", "init"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.email", "test@test.com"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.name", "Test"], cwd=repo_path, check=True, capture_output=True) + subprocess.run(["git", "config", "commit.gpgsign", "false"], cwd=repo_path, check=True, capture_output=True) # Initial commit (repo_path / "file.txt").write_text("content") @@ -207,6 +214,7 @@ class TestGitSafetyErrors: subprocess.run(["git", "init"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.email", "test@test.com"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.name", "Test"], cwd=repo_path, check=True, capture_output=True) + subprocess.run(["git", "config", "commit.gpgsign", "false"], cwd=repo_path, check=True, capture_output=True) safety = GitSafety(repo_path=repo_path) @@ -235,6 +243,7 @@ class TestGitSafetyErrors: subprocess.run(["git", "init"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.email", "test@test.com"], cwd=repo_path, check=True, capture_output=True) subprocess.run(["git", "config", "user.name", "Test"], cwd=repo_path, check=True, capture_output=True) + subprocess.run(["git", "config", "commit.gpgsign", "false"], cwd=repo_path, check=True, capture_output=True) # Initial commit on master (default branch name) (repo_path / "main.txt").write_text("main branch content") diff --git a/tests/self_coding/test_self_coding_integration.py b/tests/self_coding/test_self_coding_integration.py index 8bf9d82..5e17cca 100644 --- a/tests/self_coding/test_self_coding_integration.py +++ b/tests/self_coding/test_self_coding_integration.py @@ -39,7 +39,11 @@ def self_coding_env(): ["git", "config", "user.name", "Test User"], cwd=repo_path, check=True, capture_output=True, ) - + subprocess.run( + ["git", "config", "commit.gpgsign", "false"], + cwd=repo_path, check=True, capture_output=True, + ) + # Create src directory with real Python files src_path = repo_path / "src" / "myproject" src_path.mkdir(parents=True) diff --git a/tests/self_coding/test_self_edit_tool.py b/tests/self_coding/test_self_edit_tool.py index fdc2fd1..fee2569 100644 --- a/tests/self_coding/test_self_edit_tool.py +++ b/tests/self_coding/test_self_edit_tool.py @@ -40,7 +40,11 @@ def temp_repo(): ["git", "config", "user.name", "Test"], cwd=repo_path, check=True, capture_output=True, ) - + subprocess.run( + ["git", "config", "commit.gpgsign", "false"], + cwd=repo_path, check=True, capture_output=True, + ) + # Create src structure src_path = repo_path / "src" / "myproject" src_path.mkdir(parents=True)