66
77from debug_gym .gym .entities import EvalOutput , Event , Observation
88from debug_gym .gym .envs .env import EnvInfo , EventHooks , RepoEnv , TooledEnv
9+ from debug_gym .gym .envs .local import LocalEnv
910from debug_gym .gym .tools .tool import ToolCall
1011from debug_gym .gym .tools .toolbox import Toolbox
1112
1213
1314@pytest .fixture
14- def env_mock ():
15- env = RepoEnv ( )
15+ def env_mock (tmp_path ):
16+ env = LocalEnv ( path = tmp_path )
1617 return env
1718
1819
@@ -109,7 +110,7 @@ def test_tool_names(env_mock):
109110 assert env_mock .tool_names == "tool1, tool2"
110111
111112
112- def test_env_tools ():
113+ def test_env_tools (env_mock ):
113114 tool1 = MagicMock ()
114115 tool1 .name = "tool1"
115116 tool1 .description = "instructions1"
@@ -129,11 +130,10 @@ def test_env_tools():
129130 },
130131 }
131132
132- env = RepoEnv ()
133- env .add_tool (tool1 )
134- env .add_tool (tool2 )
133+ env_mock .add_tool (tool1 )
134+ env_mock .add_tool (tool2 )
135135
136- assert env .tools == [tool1 , tool2 ]
136+ assert env_mock .tools == [tool1 , tool2 ]
137137
138138
139139@pytest .fixture
@@ -147,7 +147,7 @@ def env(tmp_path):
147147 (repo_path / "file2.txt" ).touch ()
148148 (subdir_path / "subfile1.txt" ).touch ()
149149
150- env = RepoEnv (path = repo_path )
150+ env = LocalEnv (path = repo_path )
151151 return env
152152
153153
@@ -186,7 +186,7 @@ def test_step(
186186 mock_pdb_tool .current_frame_file = "file.py"
187187 mock_get_tool .return_value = None
188188
189- env = RepoEnv (path = tmp_path )
189+ env = LocalEnv (path = tmp_path )
190190 env .reset ()
191191 env .last_eval = EvalOutput (success = False , output = "1 failed, 0 passed" )
192192 tool_call = ToolCall (id = "123" , name = "pdb" , arguments = {"command" : "b 10" })
@@ -210,7 +210,7 @@ def test_reset(tmp_path):
210210 (tmp_path / "test.py" ).write_text ("def test_1():\n assert False\n " )
211211 (tmp_path / ".debugignore" ).write_text ("__pycache__/\n .git/\n .pytest_cache/\n " )
212212
213- env = RepoEnv (path = tmp_path , entrypoint = "pytest test.py" )
213+ env = LocalEnv (path = tmp_path , entrypoint = "pytest test.py" )
214214 infos = env .reset ()
215215
216216 assert env .last_eval is None
@@ -224,7 +224,7 @@ def test_reset(tmp_path):
224224 action_reasoning = None ,
225225 action_content = None ,
226226 action_tool_call = None ,
227- instructions = "" ,
227+ instructions = env . instructions ,
228228 score = 0 ,
229229 max_score = None ,
230230 terminated = False ,
@@ -276,7 +276,7 @@ def test_eval(tmp_path):
276276 (tmp_path / "test.py" ).write_text ("def test_1():\n assert False\n " )
277277 (tmp_path / ".debugignore" ).write_text ("__pycache__/\n .git/\n .pytest_cache/\n " )
278278
279- env = RepoEnv (path = tmp_path , entrypoint = "pytest test.py" )
279+ env = LocalEnv (path = tmp_path , entrypoint = "pytest test.py" )
280280 env .reset ()
281281 env .eval ()
282282 assert "FAILED test.py::test_1 - assert False" in env .last_eval .output
@@ -287,7 +287,7 @@ def test_eval_success(tmp_path):
287287 # create a dummy file
288288 with open (tmp_path / "file.py" , "w" ) as f :
289289 f .write ("print('Hello, World!')" )
290- env = RepoEnv (path = working_dir , entrypoint = "python file.py" )
290+ env = LocalEnv (path = working_dir , entrypoint = "python file.py" )
291291 env .reset ()
292292 output = env .eval ()
293293 assert output == EvalOutput (success = True , output = "Hello, World!" )
@@ -298,7 +298,7 @@ def test_eval_timeout(tmp_path):
298298 # runs for longer than the timeout
299299 with open (tmp_path / "file.py" , "w" ) as f :
300300 f .write ("import time; time.sleep(5)" )
301- env = RepoEnv (path = working_dir , entrypoint = "python file.py" , run_timeout = 1 )
301+ env = LocalEnv (path = working_dir , entrypoint = "python file.py" , run_timeout = 1 )
302302 env .reset ()
303303 output = env .eval ()
304304 assert output == EvalOutput (success = False , output = "Timeout expired." )
@@ -371,22 +371,20 @@ def test_event_hooks_notify():
371371 subscriber .on_env_start .assert_called_once ()
372372
373373
374- def test_current_breakpoints_no_breakpoints ():
375- env = RepoEnv ()
376- env .current_breakpoints_state = {}
377- result = env .current_breakpoints ()
374+ def test_current_breakpoints_no_breakpoints (env_mock ):
375+ env_mock .current_breakpoints_state = {}
376+ result = env_mock .current_breakpoints ()
378377 assert result == "No breakpoints are set."
379378
380379
381- def test_current_breakpoints_with_breakpoints (tmp_path ):
382- env = RepoEnv ()
383- env .current_breakpoints_state = {
380+ def test_current_breakpoints_with_breakpoints (tmp_path , env_mock ):
381+ env_mock .current_breakpoints_state = {
384382 "file1.py|||10" : "b file1.py:10" ,
385383 "file1.py|||20" : "b file1.py:20" ,
386384 "file1.py|||30" : "b file1.py:30" ,
387385 "file2.py|||15" : "b file2.py:15" ,
388386 }
389- result = env .current_breakpoints ()
387+ result = env_mock .current_breakpoints ()
390388 expected_result = (
391389 "line 10 in file1.py\n "
392390 "line 20 in file1.py\n "
@@ -424,7 +422,7 @@ def test_queue_and_process_events():
424422
425423
426424def test_has_breakpoint_true_and_false (tmp_path ):
427- env = RepoEnv (path = tmp_path )
425+ env = LocalEnv (path = tmp_path )
428426 env .reset ()
429427 file_path = env .working_dir / "test.py"
430428 file_path .write_text ("print('hello')" )
@@ -438,7 +436,7 @@ def test_has_breakpoint_true_and_false(tmp_path):
438436
439437
440438def test_has_breakpoint_relative_path (tmp_path ):
441- env = RepoEnv (path = tmp_path )
439+ env = LocalEnv (path = tmp_path )
442440 env .reset ()
443441 file_path = env .working_dir / "foo.py"
444442 file_path .write_text ("print('foo')" )
0 commit comments