π OpenHands: AI-Driven Development
Fix the tests (#1737)
Robert Brennanefd0d61e706d
diff --git a/tests/unit/test_sandbox.py b/tests/unit/test_sandbox.pyindex 6ba183f3f1..d3ee13d6b8 100644--- a/tests/unit/test_sandbox.py+++ b/tests/unit/test_sandbox.py@@ -111,42 +111,29 @@ def test_ssh_box_run_as_devin(temp_dir):)assert output.strip() == 'total 0'- exit_code, output = box.execute('mkdir test')- assert exit_code == 0, (- 'The exit code should be 0 for ' + box.__class__.__name__- )- assert output.strip() == ''-assert config.workspace_base == temp_direxit_code, output = box.execute('ls -l')assert exit_code == 0, 'The exit code should be 0.'assert output.strip() == 'total 0'+ exit_code, output = box.execute('mkdir test')+ assert exit_code == 0, 'The exit code should be 0.'+ assert output.strip() == ''+exit_code, output = box.execute('ls -l')assert exit_code == 0, 'The exit code should be 0.'- assert 'opendevin' in output, (- "The output should contain username 'opendevin' for "- + box.__class__.__name__- )- assert 'test' in output, (- 'The output should contain the test directory for '- + box.__class__.__name__- )+ assert (+ 'opendevin' in output+ ), "The output should contain username 'opendevin'"+ assert 'test' in output, 'The output should contain the test directory'exit_code, output = box.execute('touch test/foo.txt')- assert exit_code == 0, (- 'The exit code should be 0. for ' + box.__class__.__name__- )+ assert exit_code == 0, 'The exit code should be 0.'assert output.strip() == ''exit_code, output = box.execute('ls -l test')- assert exit_code == 0, (- 'The exit code should be 0. for ' + box.__class__.__name__- )- assert 'foo.txt' in output, (- 'The output should contain the foo.txt file for '- + box.__class__.__name__- )+ assert exit_code == 0, 'The exit code should be 0.'+ assert 'foo.txt' in output, 'The output should contain the foo.txt file'def test_ssh_box_multi_line_cmd_run_as_devin(temp_dir):@@ -216,14 +203,10 @@ def test_ssh_box_failed_cmd_run_as_devin(temp_dir):def test_single_multiline_command(temp_dir):- with patch.dict(- config.config,- {- config.ConfigType.WORKSPACE_BASE: temp_dir,- config.ConfigType.RUN_AS_DEVIN: 'true',- config.ConfigType.SANDBOX_TYPE: 'ssh',- },- clear=True,+ with patch.object(config, 'workspace_base', new=temp_dir), patch.object(+ config, 'workspace_mount_path', new=temp_dir+ ), patch.object(config, 'run_as_devin', new='true'), patch.object(+ config, 'sandbox_type', new='ssh'):for box in [DockerSSHBox(), DockerExecBox()]:exit_code, output = box.execute('echo \\\n -e "foo"')@@ -244,14 +227,10 @@ def test_single_multiline_command(temp_dir):def test_multiline_echo(temp_dir):- with patch.dict(- config.config,- {- config.ConfigType.WORKSPACE_BASE: temp_dir,- config.ConfigType.RUN_AS_DEVIN: 'true',- config.ConfigType.SANDBOX_TYPE: 'ssh',- },- clear=True,+ with patch.object(config, 'workspace_base', new=temp_dir), patch.object(+ config, 'workspace_mount_path', new=temp_dir+ ), patch.object(config, 'run_as_devin', new='true'), patch.object(+ config, 'sandbox_type', new='ssh'):for box in [DockerSSHBox(), DockerExecBox()]:exit_code, output = box.execute('echo -e "hello\nworld"')@@ -273,14 +252,10 @@ def test_multiline_echo(temp_dir):def test_sandbox_whitespace(temp_dir):# get a temporary directory- with patch.dict(- config.config,- {- config.ConfigType.WORKSPACE_BASE: temp_dir,- config.ConfigType.RUN_AS_DEVIN: 'true',- config.ConfigType.SANDBOX_TYPE: 'ssh',- },- clear=True,+ with patch.object(config, 'workspace_base', new=temp_dir), patch.object(+ config, 'workspace_mount_path', new=temp_dir+ ), patch.object(config, 'run_as_devin', new='true'), patch.object(+ config, 'sandbox_type', new='ssh'):for box in [DockerSSHBox(), DockerExecBox()]:# test the ssh box