- Remove outdated macOS C++ compatibility warnings from README - Simplify CI workflow by removing macOS-specific failure handling - All tests now pass consistently on macOS after ABI fixes
2.1 KiB
2.1 KiB
LEANN Tests
This directory contains automated tests for the LEANN project using pytest.
Test Files
test_readme_examples.py
Tests the examples shown in README.md:
- The basic example code that users see first
- Import statements work correctly
- Different backend options (HNSW, DiskANN)
- Different LLM configuration options
test_basic.py
Basic functionality tests that verify:
- All packages can be imported correctly
- C++ extensions (FAISS, DiskANN) load properly
- Basic index building and searching works for both HNSW and DiskANN backends
- Uses parametrized tests to test both backends
test_main_cli.py
Tests the main CLI example functionality:
- Tests with facebook/contriever embeddings
- Tests with OpenAI embeddings (if API key is available)
- Tests error handling with invalid parameters
- Verifies that normalized embeddings are detected and cosine distance is used
Running Tests
Install test dependencies:
# Using extras
uv pip install -e ".[test]"
Run all tests:
pytest tests/
# Or with coverage
pytest tests/ --cov=leann --cov-report=html
# Run in parallel (faster)
pytest tests/ -n auto
Run specific tests:
# Only basic tests
pytest tests/test_basic.py
# Only tests that don't require OpenAI
pytest tests/ -m "not openai"
# Skip slow tests
pytest tests/ -m "not slow"
Run with specific backend:
# Test only HNSW backend
pytest tests/test_basic.py::test_backend_basic[hnsw]
# Test only DiskANN backend
pytest tests/test_basic.py::test_backend_basic[diskann]
CI/CD Integration
Tests are automatically run in GitHub Actions:
- After building wheel packages
- On multiple Python versions (3.9 - 3.13)
- On both Ubuntu and macOS
- Using pytest with appropriate markers and flags
pytest.ini Configuration
The pytest.ini file configures:
- Test discovery paths
- Default timeout (600 seconds)
- Environment variables (HF_HUB_DISABLE_SYMLINKS, TOKENIZERS_PARALLELISM)
- Custom markers for slow and OpenAI tests
- Verbose output with short tracebacks
Known Issues
- OpenAI tests are automatically skipped if no API key is provided