Comprehensive pytest suite for testing Python bindings of KortexDL framework.
- Build Python bindings first:
cd python_bindings
mkdir build && cd build
cmake ..
make _kortexdl_core- Install test dependencies:
pip install pytest pytest-cov numpycd python_bindings
pytest tests/ -vpytest tests/test_cnn.py -vpytest tests/ --cov=. --cov-report=htmlpytest tests/ -m cnn -vpytest tests/ -m "not requires_build"tests/
├── conftest.py # Shared fixtures and configuration
├── test_cnn.py # CNN layer tests (Conv2d, MaxPool, etc.)
├── test_network.py # Network class tests
├── test_optimizers.py # Optimizer tests
└── test_utils.py # Utility function tests
@pytest.mark.cnn- CNN layer tests@pytest.mark.core- Core component tests@pytest.mark.optimizer- Optimizer tests@pytest.mark.integration- Integration tests@pytest.mark.slow- Time-consuming tests@pytest.mark.requires_build- Tests needing compiled bindings
View coverage report:
pytest tests/ --cov=. --cov-report=html
open htmlcov/index.htmlTests automatically run in GitHub Actions CI pipeline for every push/PR.
- Add test file:
tests/test_<component>.py - Use fixtures from
conftest.py - Mark with appropriate pytest markers
- Follow naming convention:
test_<functionality>
Example:
import pytest
import _kortexdl_core as bd
@pytest.mark.requires_build
@pytest.mark.cnn
def test_my_cnn_feature(sample_conv_input):
conv = bd.Conv2d(3, 16, 3)
output = conv.forward(sample_conv_input)
assert output.shape[1] == 16ImportError: No module named '_kortexdl_core':
- Build the Python bindings first
- Set PYTHONPATH:
export PYTHONPATH=../build:$PYTHONPATH
Tests skipped:
- Tests marked with
requires_buildwill skip if bindings aren't built - This is expected - build bindings to run all tests
For more information, see the main project README.