diff --git a/tests/conftest.py b/tests/conftest.py index 8d1fcaf92..c5d5b5ad1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -14,28 +14,28 @@ sys.path.insert(1, str(package_dir)) -@pytest.fixture() +@pytest.fixture def test_data_path() -> Path: p = _this_dir / "test_data" assert p.is_dir() return p -@pytest.fixture() +@pytest.fixture def test_trajectories_path(test_data_path) -> Path: p = test_data_path / "trajectories" assert p.is_dir() return p -@pytest.fixture() +@pytest.fixture def test_data_sources_path(test_data_path) -> Path: p = test_data_path / "data_sources" assert p.is_dir() return p -@pytest.fixture() +@pytest.fixture def test_trajectory_path(test_trajectories_path) -> Path: traj = ( test_trajectories_path @@ -46,6 +46,6 @@ def test_trajectory_path(test_trajectories_path) -> Path: return traj -@pytest.fixture() +@pytest.fixture def test_trajectory(test_trajectory_path): return json.loads(test_trajectory_path.read_text()) diff --git a/tests/test_env.py b/tests/test_env.py index 58f9169e5..a543e3d43 100644 --- a/tests/test_env.py +++ b/tests/test_env.py @@ -58,27 +58,27 @@ def swe_env_context(env_args): env.close() -@pytest.mark.slow() +@pytest.mark.slow def test_init_swe_env(test_env_args): with swe_env_context(test_env_args) as env: env.reset() -@pytest.mark.slow() +@pytest.mark.slow def test_init_swe_env_conservative_clone(test_env_args): with mock.patch.dict("os.environ", {"SWE_AGENT_CLONE_METHOD": "full"}): with swe_env_context(test_env_args) as env: env.reset() -@pytest.mark.slow() +@pytest.mark.slow def test_init_swe_env_non_persistent(test_env_args): test_env_args = dataclasses.replace(test_env_args, container_name=None) with swe_env_context(test_env_args) as env: env.reset() -@pytest.mark.slow() +@pytest.mark.slow def test_init_swe_env_cached_task_image(test_env_args): test_env_args = dataclasses.replace(test_env_args, cache_task_images=True, container_name=None) start = time.perf_counter() @@ -105,7 +105,7 @@ def test_init_swe_env_cached_task_image(test_env_args): client.images.remove(image.id) -@pytest.mark.slow() +@pytest.mark.slow def test_execute_setup_script(tmp_path, test_env_args): test_script = "echo 'hello world'" script_path = Path(tmp_path / "test_script.sh") @@ -115,7 +115,7 @@ def test_execute_setup_script(tmp_path, test_env_args): env.reset() -@pytest.mark.slow() +@pytest.mark.slow def test_execute_environment(tmp_path, test_env_args, capsys): test_env = { "python": "3.6", @@ -134,7 +134,7 @@ def test_execute_environment(tmp_path, test_env_args, capsys): assert "Cloned python conda environment" not in out -@pytest.mark.slow() +@pytest.mark.slow def test_execute_environment_default(test_env_args): env_config_paths = (CONFIG_DIR / "environment_setup").iterdir() assert env_config_paths @@ -151,7 +151,7 @@ def test_execute_environment_default(test_env_args): env.reset() -@pytest.mark.slow() +@pytest.mark.slow def test_execute_environment_clone_python(tmp_path, test_env_args, capsys): """This should clone the existing python 3.10 conda environment for speedup""" test_env = { @@ -171,7 +171,7 @@ def test_execute_environment_clone_python(tmp_path, test_env_args, capsys): assert "Cloned python conda environment" in out -@pytest.mark.slow() +@pytest.mark.slow def test_open_pr(test_env_args): test_env_args = dataclasses.replace( test_env_args, @@ -183,21 +183,21 @@ def test_open_pr(test_env_args): env.open_pr(_dry_run=True, trajectory=[]) -@pytest.mark.slow() +@pytest.mark.slow def test_interrupt_close(test_env_args): with swe_env_context(test_env_args) as env: env.reset() env.interrupt() -@pytest.mark.slow() +@pytest.mark.slow def test_communicate_old(test_env_args): with mock.patch.dict("os.environ", {"SWE_AGENT_COMMUNICATE_METHOD": "processes"}): with swe_env_context(test_env_args) as env: env.reset() -@pytest.mark.slow() +@pytest.mark.slow def test_env_with_hook(test_env_args): with swe_env_context(test_env_args) as env: env.add_hook(EnvHook()) diff --git a/tests/test_models.py b/tests/test_models.py index 4ad209865..ac3f57c87 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -7,7 +7,7 @@ from sweagent.agent.models import GroqModel, ModelArguments, OpenAIModel, TogetherModel -@pytest.fixture() +@pytest.fixture def openai_mock_client(): model = Mock() response = Mock() @@ -21,7 +21,7 @@ def openai_mock_client(): return model -@pytest.fixture() +@pytest.fixture def mock_together_response(): return { "choices": [{"text": "Hello"}], diff --git a/tests/test_replay.py b/tests/test_replay.py index 558633dc7..c45c15a0a 100644 --- a/tests/test_replay.py +++ b/tests/test_replay.py @@ -9,7 +9,7 @@ from sweagent import CONFIG_DIR -@pytest.fixture() +@pytest.fixture def swe_agent_test_repo_clone(tmp_path): local_repo_path = tmp_path / "test-repo" clone_cmd = ["git", "clone", "https://github.com/swe-agent/test-repo", local_repo_path] @@ -17,7 +17,7 @@ def swe_agent_test_repo_clone(tmp_path): return local_repo_path -@pytest.fixture() +@pytest.fixture def swe_agent_test_repo_traj(test_trajectories_path) -> Path: p = ( test_trajectories_path @@ -28,14 +28,14 @@ def swe_agent_test_repo_traj(test_trajectories_path) -> Path: return p -@pytest.fixture() +@pytest.fixture def swe_agent_test_repo_local_problem_stmt(swe_agent_test_repo_clone) -> Path: problem_stmt = swe_agent_test_repo_clone / "problem_statements" / "1.md" assert problem_stmt.is_file() return problem_stmt -@pytest.mark.slow() +@pytest.mark.slow @pytest.mark.parametrize("problem_statement_source", ["github", "local"]) def test_model_replay_github_repo( tmpdir, @@ -64,7 +64,7 @@ def test_model_replay_github_repo( main(**vars(args), forward_args=remaining_args) -@pytest.mark.slow() +@pytest.mark.slow def test_model_replay_from_json(test_trajectories_path, test_data_sources_path): traj_path = ( test_trajectories_path @@ -96,7 +96,7 @@ def test_run_cli_help(): subprocess.run(args, check=True) -@pytest.mark.slow() +@pytest.mark.slow @pytest.mark.parametrize("problem_statement_source", ["github", "local"]) def test_model_replay_local_repo(swe_agent_test_repo_clone, swe_agent_test_repo_traj, problem_statement_source): local_repo_path = swe_agent_test_repo_clone diff --git a/tests/test_run.py b/tests/test_run.py index c8f894ce9..b5bfa5ada 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -17,7 +17,7 @@ from sweagent.environment.swe_env import EnvironmentArguments, SWEEnv -@pytest.mark.slow() +@pytest.mark.slow def test_run_cli_help(): args = [ "python", @@ -27,7 +27,7 @@ def test_run_cli_help(): subprocess.run(args, check=True) -@pytest.fixture() +@pytest.fixture def open_pr_hook_init_for_sop(): hook = OpenPRHook() hook._token = os.environ.get("GITHUB_TOKEN", "") @@ -37,7 +37,7 @@ def open_pr_hook_init_for_sop(): return hook -@pytest.fixture() +@pytest.fixture def info_dict(): return { "submission": "asdf", @@ -100,7 +100,7 @@ def on_instance_start(self, *, index: int, instance: dict[str, Any]): raise ValueError(msg) -@pytest.fixture() +@pytest.fixture def test_script_args(): return ScriptArguments( suffix="", @@ -128,7 +128,7 @@ def test_script_args(): ) -@pytest.mark.slow() +@pytest.mark.slow def test_exception_raised(test_script_args: ScriptArguments): assert test_script_args.raise_exceptions main = Main(test_script_args) @@ -137,7 +137,7 @@ def test_exception_raised(test_script_args: ScriptArguments): main.main() -@pytest.mark.slow() +@pytest.mark.slow class CreateFakeLogFile(MainHook): """Testing the skip functionality""" @@ -153,21 +153,21 @@ def on_instance_start(self, *, index: int, instance: dict[str, Any]): (self._traj_dir / f"{instance_id}.traj").write_text(json.dumps(dct)) -@pytest.mark.slow() +@pytest.mark.slow def test_existing_corrupted_args(test_script_args: ScriptArguments): main = Main(test_script_args) main.add_hook(CreateFakeLogFile()) main.main() -@pytest.mark.slow() +@pytest.mark.slow def test_main_hook(test_script_args: ScriptArguments): main = Main(test_script_args) main.add_hook(MainHook()) main.main() -@pytest.mark.slow() +@pytest.mark.slow def test_agent_with_hook(test_script_args: ScriptArguments): main = Main(test_script_args) main.agent.add_hook(AgentHook()) @@ -177,7 +177,7 @@ def test_agent_with_hook(test_script_args: ScriptArguments): PERSISTENT_CONTAINER_NAME = "sweagent-test-persistent-container" -@pytest.fixture() +@pytest.fixture def _cleanup_persistent_container(): yield client = docker.from_env() @@ -185,7 +185,7 @@ def _cleanup_persistent_container(): container.remove(force=True) -@pytest.mark.slow() +@pytest.mark.slow @pytest.mark.usefixtures("_cleanup_persistent_container") def test_agent_persistent_container(test_script_args: ScriptArguments, capsys): test_script_args = dataclasses.replace( diff --git a/tests/test_server.py b/tests/test_server.py index 304fcfcd7..6b9b2aa06 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -6,14 +6,14 @@ from sweagent.api.server import app, socketio -@pytest.fixture() +@pytest.fixture def client(): with app.test_client() as client: with app.app_context(): yield client -@pytest.fixture() +@pytest.fixture def socket_client(): client = SocketIOTestClient(app, socketio) yield client