Source code for behave_kit.env.config
"""Wiring: load `behave.toml` and attach the resolved config to the Behave context."""
from __future__ import annotations
from pathlib import Path
from behave_kit._core.config import KitConfig
from behave_kit._core.types import Context
[docs]
def load_env_config(
context: Context,
env: str,
config_file: str | Path = "behave.toml",
*,
overrides: dict[str, str] | None = None,
) -> KitConfig:
"""Load ``config_file``, resolve the ``env`` profile, and attach it to the context.
The resolved `KitConfig` is stored on ``context.kit_config`` — Behave's own
``context.config`` (which exposes ``userdata`` and other runner settings) is
left untouched.
"""
config = KitConfig.from_toml(Path(config_file), env=env, overrides=overrides)
context.kit_config = config
return config