Test that the env_file method loads environment variables from a file. Args: tmp_path: The pytest tmp_path object. file_map: A mapping of file names to their contents. env_file: The path to the environment file to load. exp_env_vars: The expected environment vari
(
tmp_path: Path,
file_map: dict[str, str],
env_file: str,
exp_env_vars: dict[str, str],
)
| 502 | ], |
| 503 | ) |
| 504 | def test_env_file( |
| 505 | tmp_path: Path, |
| 506 | file_map: dict[str, str], |
| 507 | env_file: str, |
| 508 | exp_env_vars: dict[str, str], |
| 509 | ) -> None: |
| 510 | """Test that the env_file method loads environment variables from a file. |
| 511 | |
| 512 | Args: |
| 513 | tmp_path: The pytest tmp_path object. |
| 514 | file_map: A mapping of file names to their contents. |
| 515 | env_file: The path to the environment file to load. |
| 516 | exp_env_vars: The expected environment variables after loading the file. |
| 517 | """ |
| 518 | for filename, content in file_map.items(): |
| 519 | (tmp_path / filename).write_text(content) |
| 520 | |
| 521 | _ = rx.Config( |
| 522 | app_name="test_env_file", |
| 523 | env_file=env_file.format(path=tmp_path, sep=os.pathsep), |
| 524 | ) |
| 525 | for key, value in exp_env_vars.items(): |
| 526 | assert os.environ.get(key) == value |
| 527 | |
| 528 | |
| 529 | class TestDisablePlugins: |