Skip to content

SWE-agent[bot] PR to fix: Feat: Add basic testing #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ docs = [
"mkdocstrings[python]>=0.18",
"mike",
]
test = [
"pytest>=7.0.0",
"pytest-cov>=4.0.0",
]

[tool.setuptools]
include-package-data = true
Expand All @@ -71,3 +75,10 @@ namespaces = false

[tool.ruff]
exclude = ["notebooks"]

[tool.pytest]
testpaths = ["tests"]
python_files = "test_*.py"
python_classes = "Test*"
python_functions = "test_*"
addopts = "--ignore=swesmith"
35 changes: 35 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SWE-smith Tests

This directory contains tests for the SWE-smith package.

## Structure

- `conftest.py`: Common pytest fixtures and configuration
- `test_data/`: Directory containing test data files
- `test_*.py`: Test files for different components of SWE-smith

## Running Tests

To run the tests, you can use pytest:

```bash
# Install test dependencies
pip install -e ".[test]"

# Run all tests
pytest

# Run tests with coverage
pytest --cov=swesmith

# Run a specific test file
pytest tests/test_specific_file.py
```

## Adding Tests

When adding new tests:

1. Create a new file named `test_*.py` for the component you're testing
2. Use pytest fixtures from `conftest.py` where appropriate
3. Add any necessary test data to the `test_data/` directory
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file makes the tests directory a Python package
18 changes: 18 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""
Common pytest fixtures and configuration for SWE-smith tests.
"""

import os
import sys
import pytest

# Add the repository root to the Python path to ensure imports work correctly
repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
if repo_root not in sys.path:
sys.path.insert(0, repo_root)


@pytest.fixture
def sample_repo_path():
"""Return a path to a sample repository for testing."""
return os.path.join(os.path.dirname(__file__), "test_data", "sample_repo")