Hypothesis Property Test Profiles
This document explains the different Hypothesis profiles used for property-based testing in this project.Overview
Property-based testing with Hypothesis uses different profiles to balance speed vs thoroughness:| Profile | Examples | Use Case | Speed | Thoroughness |
|---|---|---|---|---|
| dev | 25 | Local development, git pre-push hooks | β‘ Fast | β Good |
| ci | 100 | CI/CD, make validate-pre-push | π’ Slow | βββ Comprehensive |
When to Use Each Profile
Dev Profile (25 examples) - Default
Used by:- Git pre-push hooks (automatic)
make test-property- Local test runs:
pytest -m property
- Fast iteration: ~4x faster than CI profile
- Good coverage: Catches 80-90% of property violations
- Developer-friendly: Doesnβt slow down TDD workflow
- Active development with frequent test runs
- Quick validation before committing code
- Iterating on property test logic
CI Profile (100 examples) - Thorough
Used by:- CI/CD workflows (GitHub Actions)
make validate-pre-push(Makefile target)HYPOTHESIS_PROFILE=ci pytest -m property
- Comprehensive: Tests 4x more examples
- High confidence: Catches rare edge cases
- Slower: Takes 4x longer to run
- Before pushing changes that modify property-tested code
- Final validation before creating pull requests
- Investigating property test failures in CI
Usage Examples
Running with Dev Profile (Fast)
Running with CI Profile (Thorough)
Running with CI Parity (Integration Tests + CI Profile)
Configuration
Hypothesis profiles are configured in:- pyproject.toml (lines 505-513): Default dev profile settings
- tests/conftest.py: CI profile registration
Dev Profile (pyproject.toml)
CI Profile (conftest.py)
Troubleshooting
Property test fails in CI but passes locally
Problem: Test passes with dev profile (25 examples) but fails with CI profile (100 examples) Solution:- Run locally with CI profile:
HYPOTHESIS_PROFILE=ci pytest -m property - Hypothesis will find the failing example
- Fix the property or the code
- Verify:
HYPOTHESIS_PROFILE=ci pytest -m property
Property tests are too slow locally
Problem:git push takes too long due to property tests
Current behavior: This is expected! Property tests with 25 examples typically add ~30-60s to pre-push
Options:
- Accept the delay: 30-60s is reasonable for quality assurance
- Skip pre-push (not recommended):
git push --no-verify - Run tests separately:
make test-property && git push
Want faster feedback during development
Use pytest-testmon for change-aware testing:References
- OpenAI Codex Finding 2c: Property test profile split documentation
- Hypothesis Docs: https://hypothesis.readthedocs.io/en/latest/settings.html#profiles
- Test Strategy:
TESTING.md - CI/CD Parity:
CONTRIBUTING.md
Summary
- Local development: Use dev profile (25 examples, automatic)
- Pre-push validation: Use CI profile via
make validate-pre-push - CI/CD: Always uses CI profile (100 examples)
- Debugging CI failures: Run locally with
HYPOTHESIS_PROFILE=ci