Bengal maintains high code quality through a multi-layered testing strategy with 4,000+ tests.
Test Layers
Unit Tests
Fast & Focused (tests/unit/)
Test individual classes/functions. Mock external deps.
Target: 90%+ coverage.
Integration Tests
Workflows (tests/integration/)
Test subsystem interactions and build flows. Verify cache.
Benchmarks
Performance (tests/performance/)
Measure speed on large sites. Catch regressions.
Quick Start
1 2 3 4 5 6 7 8 | |
Test Infrastructure
Test Roots
Minimal, reusable site structures intests/roots/:
| Root | Purpose | Pages |
|---|---|---|
test-basic |
Minimal smoke test | 1 |
test-directives |
Card, admonition, glossary | 4+ |
test-navigation |
Multi-level hierarchy | 8 |
test-large |
Performance testing | 100+ |
1 2 3 4 | |
Canonical Mocks
Use shared mocks instead of inline class definitions:
1 2 3 4 | |
Module-Scoped Fixtures
Rendering tests use module-scoped parser for efficiency:
1 2 3 4 | |
Key Testing Patterns
1. Declarative Test Sites
1 2 3 | |
2. Property-Based Testing
For critical utilities, we usehypothesisto test edge cases (116 tests, 11,600+ examples).
3. Parallel Safety
Mark tests with internal parallelism:
1 2 3 4 | |
Continuous Integration
Every PR runs:
- Linting:
ruffcheck and format - Type Checking:
mypystrict mode - Test Suite: Unit + integration (
-m "not slow") - Full Suite: On main/release branches
Seetests/README.mdfor complete documentation.