"""Tests for Code Debugging Challenge environment.""" import pytest from server.debug_environment import DebugEnvironment from models import DebugAction def test_environment_reset(): """Test environment reset.""" env = DebugEnvironment() obs = env.reset() assert obs.buggy_code is not None assert obs.expected_output is not None assert obs.attempts_remaining == 5 assert not obs.success def test_analyze_action(): """Test analyze action.""" env = DebugEnvironment() env.reset() action = DebugAction(action_type="analyze") obs = env.step(action) reward = env.reward(obs) assert reward == 0.1 assert not env.terminated(obs) def test_successful_fix(): """Test successful bug fix.""" env = DebugEnvironment() env.reset() correct_fix = env.current_problem["fixed_code"] action = DebugAction(action_type="fix", content=correct_fix) obs = env.step(action) reward = env.reward(obs) assert obs.success assert reward == 1.0 assert env.terminated(obs) if __name__ == "__main__": pytest.main([__file__, "-v"])