Test that the config replaces defaults with values from the environment. Args: monkeypatch: The pytest monkeypatch object. config_kwargs: The config kwargs. env_vars: The environment variables. set_persistent_vars: The values passed to config._set_persistent vari
(
monkeypatch,
config_kwargs,
env_vars,
set_persistent_vars,
exp_config_values,
)
| 181 | ], |
| 182 | ) |
| 183 | def test_replace_defaults( |
| 184 | monkeypatch, |
| 185 | config_kwargs, |
| 186 | env_vars, |
| 187 | set_persistent_vars, |
| 188 | exp_config_values, |
| 189 | ): |
| 190 | """Test that the config replaces defaults with values from the environment. |
| 191 | |
| 192 | Args: |
| 193 | monkeypatch: The pytest monkeypatch object. |
| 194 | config_kwargs: The config kwargs. |
| 195 | env_vars: The environment variables. |
| 196 | set_persistent_vars: The values passed to config._set_persistent variables. |
| 197 | exp_config_values: The expected config values. |
| 198 | """ |
| 199 | mock_os_env = os.environ.copy() |
| 200 | monkeypatch.setattr(nextpy.build.config.os, "environ", mock_os_env) # type: ignore |
| 201 | mock_os_env.update({k: str(v) for k, v in env_vars.items()}) |
| 202 | c = xt.Config(app_name="a", **config_kwargs) |
| 203 | c._set_persistent(**set_persistent_vars) |
| 204 | for key, value in exp_config_values.items(): |
| 205 | assert getattr(c, key) == value |