|
| 1 | +# H5AD Testing Documentation |
| 2 | + |
| 3 | +## Quick Start |
| 4 | + |
| 5 | +Install development dependencies: |
| 6 | +```bash |
| 7 | +uv sync --extra dev |
| 8 | +``` |
| 9 | + |
| 10 | +Run all tests: |
| 11 | +```bash |
| 12 | +uv run pytest |
| 13 | +``` |
| 14 | + |
| 15 | +Run specific test file: |
| 16 | +```bash |
| 17 | +uv run pytest tests/test_subset.py |
| 18 | +``` |
| 19 | + |
| 20 | +Run specific test class: |
| 21 | +```bash |
| 22 | +uv run pytest tests/test_subset.py::TestSubsetH5ad |
| 23 | +``` |
| 24 | + |
| 25 | +Run specific test function: |
| 26 | +```bash |
| 27 | +uv run pytest tests/test_subset.py::TestSubsetH5ad::test_subset_h5ad_obs_only |
| 28 | +``` |
| 29 | + |
| 30 | +Run with coverage: |
| 31 | +```bash |
| 32 | +uv run pytest --cov=h5ad --cov-report=html |
| 33 | +``` |
| 34 | + |
| 35 | +Run verbose: |
| 36 | +```bash |
| 37 | +uv run pytest -v |
| 38 | +``` |
| 39 | + |
| 40 | +Run and show print statements: |
| 41 | +```bash |
| 42 | +uv run pytest -s |
| 43 | +``` |
| 44 | + |
| 45 | +Run with short tracebacks: |
| 46 | +```bash |
| 47 | +uv run pytest --tb=short |
| 48 | +``` |
| 49 | + |
| 50 | +## Test Structure |
| 51 | + |
| 52 | +- **`conftest.py`** - Pytest fixtures for test h5ad files (dense, CSR sparse, CSC sparse, categorical) |
| 53 | +- **`test_info_read.py`** - Tests for info.py and read.py utility functions (58 tests total) |
| 54 | + - Axis length calculation |
| 55 | + - String decoding (bytes/unicode/object arrays) |
| 56 | + - Categorical column reading with caching |
| 57 | + - Column chunk reading |
| 58 | +- **`test_subset.py`** - Tests for subsetting operations |
| 59 | + - Name file reading and parsing |
| 60 | + - Index matching with chunked processing |
| 61 | + - Axis group subsetting (including categorical columns) |
| 62 | + - Dense matrix subsetting (chunked) |
| 63 | + - Sparse matrix subsetting (CSR and CSC formats) |
| 64 | + - Integration tests for complete subset workflows |
| 65 | +- **`test_cli.py`** - CLI command integration tests |
| 66 | + - `info` command (file structure inspection) |
| 67 | + - `table` command (CSV export with filters) |
| 68 | + - `subset` command (file subsetting) |
| 69 | + - Error handling and validation |
| 70 | + |
| 71 | +## Test Coverage |
| 72 | + |
| 73 | +The test suite provides comprehensive coverage: |
| 74 | + |
| 75 | +- ✅ **CLI Commands**: All commands (info, table, subset) with various options |
| 76 | +- ✅ **Dense Matrices**: Chunked reading and subsetting |
| 77 | +- ✅ **Sparse Matrices**: CSR and CSC format support |
| 78 | +- ✅ **Categorical Data**: Proper handling of categorical columns |
| 79 | +- ✅ **Chunked Processing**: Memory-efficient operations on large datasets |
| 80 | +- ✅ **Error Handling**: Invalid inputs, missing files, malformed data |
| 81 | +- ✅ **Edge Cases**: Empty results, missing names, single row/column |
| 82 | + |
| 83 | +**Current Status**: 58 tests, all passing ✅ |
| 84 | + |
| 85 | +## Test Fixtures |
| 86 | + |
| 87 | +### Available Fixtures |
| 88 | + |
| 89 | +- `temp_dir`: Temporary directory for test files |
| 90 | +- `sample_h5ad_file`: Basic h5ad file with dense matrix |
| 91 | +- `sample_sparse_csr_h5ad`: H5ad file with CSR sparse matrix |
| 92 | +- `sample_sparse_csc_h5ad`: H5ad file with CSC sparse matrix |
| 93 | +- `sample_categorical_h5ad`: H5ad file with categorical columns |
| 94 | + |
| 95 | +## Coverage Reports |
| 96 | + |
| 97 | +Generate terminal coverage report: |
| 98 | +```bash |
| 99 | +uv run pytest --cov=h5ad --cov-report=term-missing |
| 100 | +``` |
| 101 | + |
| 102 | +Generate HTML coverage report: |
| 103 | +```bash |
| 104 | +uv run pytest --cov=h5ad --cov-report=html |
| 105 | +``` |
| 106 | + |
| 107 | +View HTML report: |
| 108 | +```bash |
| 109 | +open htmlcov/index.html # macOS |
| 110 | +xdg-open htmlcov/index.html # Linux |
| 111 | +``` |
| 112 | + |
| 113 | +Coverage configuration is in `pyproject.toml` under `[tool.coverage.*]`. |
0 commit comments