You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cd code/backend
# All tests
pytest
# Verbose output
pytest -v
# Stop on first failure
pytest -x
# Show print output
pytest -s
Targeted Execution
# Service layer only (fast, no DB setup)
pytest tests/test_pricing.py tests/test_curve_builder.py -v
# API layer only
pytest tests/test_bonds_api.py tests/test_portfolios_api.py -v
# Single test class
pytest tests/test_pricing.py::TestYTMSolver -v
# Single test
pytest tests/test_pricing.py::TestYTMSolver::test_round_trips -v
With Coverage
pip install pytest-cov
# Coverage for services and apps
pytest --cov=services --cov=apps --cov-report=term-missing
# HTML report
pytest --cov=services --cov=apps --cov-report=html
# Open htmlcov/index.html
Test Architecture
Service Layer Tests (No Database)
Tests in test_pricing.py and test_curve_builder.py operate entirely on
Python dataclasses (BondSchema, CurvePointSchema) with no Django or database
dependency. They run fast and can be used in CI without a database.
Tests in test_bonds_api.py and test_portfolios_api.py use the
@pytest.mark.django_db marker and DRF's APIClient. The test database
is created and torn down automatically by pytest-django.