To run tests, use the provided test runner script:
./run_tests.shOr manually:
# Activate virtual environment
source venv/bin/activate
# Install package in editable mode (if not already installed)
pip install -e .
# Install test dependencies (if not already installed)
pip install -e ".[dev]"
# Run tests
pytest tests/ -v
# Run tests with coverage
pytest tests/ -v --cov=klrfome --cov-report=html --cov-report=termThis error typically occurs when:
- pytest is run from outside the virtual environment
- The package is not installed in the virtual environment
- pytest-cov is having issues finding the Python executable
Solution:
- Always activate the virtual environment first:
source venv/bin/activate - Install the package:
pip install -e . - Use
python -m pytestinstead of justpytest
The virtual environment doesn't have dependencies installed.
Solution:
source venv/bin/activate
pip install -e .The package is not installed in editable mode.
Solution:
source venv/bin/activate
pip install -e .# Run a specific test file
pytest tests/test_kernels.py -v
# Run a specific test function
pytest tests/test_kernels.py::test_rbf_kernel_properties -v
# Run tests matching a pattern
pytest tests/ -k "kernel" -vAfter running tests with coverage, view the HTML report:
# Generate coverage report
pytest tests/ --cov=klrfome --cov-report=html
# Open the report (macOS)
open htmlcov/index.htmltests/conftest.py- Shared fixturestests/test_kernels.py- Kernel implementation teststests/test_klr.py- Kernel Logistic Regression teststests/test_prediction.py- Focal prediction teststests/test_data.py- Data structure teststests/test_integration.py- End-to-end workflow tests