# Create virtual environment
python -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
# Install development dependencies
pip install -e .
Basic test run:
pytest
Options:
pytest -v # Verbose output
pytest -vv # Extra verbose
pytest -n auto # Parallel execution
pytest tests/specific_test.py # Run specific test file
View coverage in terminal:
pytest --cov=contextor
Generate HTML report:
pytest --cov=contextor --cov-report=html
Open htmlcov/index.html
to view detailed coverage report.
- Create test files in
tests/
directory - Use pytest fixtures for setup/teardown
- Follow existing patterns for similar tests
- Run coverage to ensure new code is tested
Example test:
def test_new_feature(test_dir):
"""Test description"""
result = your_function()
assert result == expected, "Helpful error message"
Project uses pytest.ini
for configuration:
- Test discovery in
tests/
directory - Coverage reporting enabled
- Colored output
- Verbose mode by default
Tests run automatically on GitHub Actions for:
- Pull requests to main
- Push to main branch
- Release tags