SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
Doc: Add note about running tests (#435)
Kilian Lieret8e109b1fdb3f
diff --git a/docs/dev/contribute.md b/docs/dev/contribute.mdindex d389436d..8bce1ed0 100644--- a/docs/dev/contribute.md+++ b/docs/dev/contribute.md@@ -31,6 +31,20 @@ Some issues can be automatically fixed with [`ruff`](https://github.com/charlierpipx run ruff check --fix```+## Running tests++We provide a lot of tests that can be very helpful for rapid development.+Run them with++```bash+pytest+```++Some of the tests might be slwoer than others. You can exclude them with++```bash+pytest -+## Tips for pull requests* Please open separate PRs for separate issues. This makes it easier to incorporate part of your changes.@@ -38,6 +52,8 @@ pipx run ruff check --fix* When changing the behavior of the agent, we need to have some indication that it actually improves the success rate of SWE-agent.However, if you make the behavior optional without complicating SWE-agent (for example by providing new [commands](../config/commands.md)),we might be less strict.+* Please add simple unit tests or integration tests wherever possible. Take a look in the [tests directory](https://github.com/princeton-nlp/SWE-agent/tree/main/tests)+ for inspiration. We emphasize simple easy-tow-rite tests that get a lot of coverage.## Building the documentationdiff --git a/tests/test_run.py b/tests/test_run.pyindex 1f4bf1dc..4c1efae9 100644--- a/tests/test_run.py+++ b/tests/test_run.py@@ -14,6 +14,7 @@ from sweagent.agent.models import ModelArgumentsfrom sweagent.environment.swe_env import EnvironmentArguments, SWEEnvdef test_run_cli_help():args = ["python",@@ -122,6 +123,7 @@ def test_script_args():)def test_exception_raised(test_script_args):assert test_script_args.raise_exceptionsmain = Main(test_script_args)@@ -130,6 +132,7 @@ def test_exception_raised(test_script_args):main.main()class CreateFakeLogFile(MainHook):"""Testing the skip functionality"""@@ -145,18 +148,21 @@ class CreateFakeLogFile(MainHook):(self._traj_dir / f"{instance_id}.traj").write_text(json.dumps(dct))def test_existing_corrupted_args(test_script_args):main = Main(test_script_args)main.add_hook(CreateFakeLogFile())main.main()def test_main_hook(test_script_args):main = Main(test_script_args)main.add_hook(MainHook())main.main()def test_agent_with_hook(test_script_args):main = Main(test_script_args)main.agent.add_hook(AgentHook())