Testing configuration
Test the repository directly for isolated behavior, then use real temporary files and the application container for integration behavior.
from titanspan import Applicationfrom titanspan.config import Repositoryfrom titanspan.facades import Config
application = Application()repository = Repository({"app": {"debug": False}})
with application.context(): with Config.use(repository): assert Config.boolean("app.debug") is FalseConfig.use() replaces the repository through the active application’s
Container. It requires an application context and follows Container override
rules. The replacement object remains caller-owned. Use Config.override()
for task-local values and verify restoration after exceptions.
Use ConfigManager with a temporary root for file discovery, dotenv
precedence, package defaults, and cache tests. Avoid the developer’s real
environment files by supplying isolated paths and controlling process
environment variables with the test framework.
The real FastAPI and Dishka integration test verifies that dependency injection, HTTP request facade access, and application state share one repository instance. Run focused checks with:
uv run --locked pytest tests/unit/config -quv run --locked pytest tests/integration/config -qThe component does not provide a separate testing framework or config fake. Use the native Repository instance as a deterministic test value.
