|
1 | 1 | import json |
2 | 2 | import re |
3 | | -from unittest.mock import patch |
| 3 | +from unittest.mock import MagicMock, patch |
4 | 4 |
|
5 | 5 | import pytest |
6 | 6 | from pydantic import BaseModel |
|
9 | 9 | from minisweagent.models.test_models import DeterministicModel, make_output |
10 | 10 | from minisweagent.run.benchmarks.swebench import ( |
11 | 11 | filter_instances, |
| 12 | + get_sb_environment, |
12 | 13 | get_swebench_docker_image_name, |
13 | 14 | main, |
14 | 15 | remove_from_preds_file, |
@@ -103,6 +104,20 @@ def test_get_image_name_with_complex_instance_id(): |
103 | 104 | assert get_swebench_docker_image_name(instance) == expected |
104 | 105 |
|
105 | 106 |
|
| 107 | +def test_get_sb_environment_runs_startup_command_as_dict(): |
| 108 | + """startup_command must be passed to env.execute() as a dict, not a bare string.""" |
| 109 | + fake_env = MagicMock() |
| 110 | + fake_env.execute.return_value = {"returncode": 0, "output": ""} |
| 111 | + instance = {"instance_id": "repo1__test1", "image_name": "custom/image:tag"} |
| 112 | + # The startup_command with {{instance_id}} tested the Jinja render as well. |
| 113 | + config = {"run": {"env_startup_command": "echo {{instance_id}}"}} |
| 114 | + |
| 115 | + with patch("minisweagent.run.benchmarks.swebench.get_environment", return_value=fake_env): |
| 116 | + get_sb_environment(config, instance) |
| 117 | + |
| 118 | + fake_env.execute.assert_called_once_with({"command": "echo repo1__test1"}) |
| 119 | + |
| 120 | + |
106 | 121 | def test_filter_instances_no_filters(): |
107 | 122 | """Test filter_instances with no filtering applied""" |
108 | 123 | instances = [{"instance_id": "repo1__test1"}, {"instance_id": "repo2__test2"}, {"instance_id": "repo3__test3"}] |
|
0 commit comments