Skip to content

Commit 353ceb3

Browse files
committed
Remove apply_patch from FroggyAgent
1 parent 41cb3c4 commit 353ceb3

File tree

2 files changed

+0
-54
lines changed

2 files changed

+0
-54
lines changed

debug_gym/agents/froggy_agent.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -159,25 +159,3 @@ def _default_system_prompt(self, info) -> str:
159159
system_prompt_dict["Shortcut features"] = shortcut_features
160160

161161
return self.to_pretty_json(system_prompt_dict)
162-
163-
def apply_patch(self, patch_path: str) -> bool:
164-
patch_command = ["patch", "-p1"]
165-
try:
166-
# Open the patch file
167-
with open(patch_path, "r") as patch:
168-
# Run the patch command
169-
result = subprocess.run(
170-
patch_command,
171-
stdin=patch,
172-
stdout=subprocess.PIPE,
173-
stderr=subprocess.PIPE,
174-
text=True,
175-
check=True,
176-
)
177-
print("Patch applied successfully.")
178-
print("Output:", result.stdout)
179-
return True
180-
except subprocess.CalledProcessError as e:
181-
print("Failed to apply patch.")
182-
print("Error:", e.stderr)
183-
return False

tests/agents/test_agents.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -565,38 +565,6 @@ def test_run_exception_handling(agent_setup, build_env_info):
565565
agent.run(env)
566566

567567

568-
def test_apply_patch_success(agent_setup, tmp_path):
569-
"""Test successful patch application"""
570-
agent, _, _ = next(agent_setup(DebugAgent))
571-
572-
# Create a test patch file
573-
patch_content = "--- a/test.txt\n+++ b/test.txt\n@@ -1 +1 @@\n-old\n+new\n"
574-
patch_file = tmp_path / "test.patch"
575-
patch_file.write_text(patch_content)
576-
577-
with patch("subprocess.run") as mock_run:
578-
mock_run.return_value = MagicMock(stdout="Patch applied successfully")
579-
result = agent.apply_patch(str(patch_file))
580-
assert result is True
581-
mock_run.assert_called_once()
582-
583-
584-
def test_apply_patch_failure(agent_setup, tmp_path):
585-
"""Test failed patch application"""
586-
agent, _, _ = next(agent_setup(DebugAgent))
587-
588-
# Create a test patch file
589-
patch_file = tmp_path / "test.patch"
590-
patch_file.write_text("invalid patch content")
591-
592-
with patch("subprocess.run") as mock_run:
593-
mock_run.side_effect = subprocess.CalledProcessError(
594-
1, "patch", stderr="Patch failed"
595-
)
596-
result = agent.apply_patch(str(patch_file))
597-
assert result is False
598-
599-
600568
def test_save_patch(agent_setup, tmp_path):
601569
"""Test patch saving functionality"""
602570
agent, env, _ = next(agent_setup(DebugAgent))

0 commit comments

Comments
 (0)