conftest.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from __future__ import annotations
  2. import json
  3. import sys
  4. from pathlib import Path
  5. import pytest
  6. # this is a hack and should be removed when we have a better solution
  7. _this_dir = Path(__file__).resolve().parent
  8. root_dir = _this_dir.parent
  9. package_dir = root_dir / "sweagent"
  10. sys.path.insert(0, str(root_dir))
  11. sys.path.insert(1, str(package_dir))
  12. @pytest.fixture()
  13. def test_data_path() -> Path:
  14. p = _this_dir / "test_data"
  15. assert p.is_dir()
  16. return p
  17. @pytest.fixture()
  18. def test_trajectories_path(test_data_path) -> Path:
  19. p = test_data_path / "trajectories"
  20. assert p.is_dir()
  21. return p
  22. @pytest.fixture()
  23. def test_data_sources_path(test_data_path) -> Path:
  24. p = test_data_path / "data_sources"
  25. assert p.is_dir()
  26. return p
  27. @pytest.fixture()
  28. def test_trajectory_path(test_trajectories_path) -> Path:
  29. traj = (
  30. test_trajectories_path
  31. / "gpt4__klieret__swe-agent-test-repo__default_from_url__t-0.00__p-0.95__c-3.00__install-1"
  32. / "klieret__swe-agent-test-repo-i1.traj"
  33. )
  34. assert traj.exists()
  35. return traj
  36. @pytest.fixture()
  37. def test_trajectory(test_trajectory_path):
  38. return json.loads(test_trajectory_path.read_text())