Skip to content
Prev Previous commit
Next Next commit
Reformat test with ruff
  • Loading branch information
asymness committed Jan 17, 2026
commit fd3950cad1a69350059cf2b59a2cdfd5a866caaa
18 changes: 12 additions & 6 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ def test_run_with_command_flags(dotenv_path):
assert result.returncode == 0
assert result.stdout.strip() == "--version"


def test_run_with_dotenv_and_command_flags(cli, dotenv_path):
"""
Check that dotenv flags supersede command flags.
Expand All @@ -305,15 +306,21 @@ def test_run_with_dotenv_and_command_flags(cli, dotenv_path):
@pytest.mark.parametrize(
"files,file_contents,expected",
(
(['.env'], ['a=1'], {"a": "1"}),
(['.env', '.env.secondary'], ['a=1', 'b=2'], {"a": "1", "b": "2"}),
(['.env', '.env.secondary', '.env.extra'], ['a=1', 'a=3\nb=2', 'a=5\nc=3'], {"a": "5", "b": "2", "c": "3"}),
([".env"], ["a=1"], {"a": "1"}),
([".env", ".env.secondary"], ["a=1", "b=2"], {"a": "1", "b": "2"}),
(
[".env", ".env.secondary", ".env.extra"],
["a=1", "a=3\nb=2", "a=5\nc=3"],
{"a": "5", "b": "2", "c": "3"},
),
),
)
def test_run_with_multiple_env_files(tmp_path, files: Sequence[str], file_contents: Sequence[str], expected: dict):
def test_run_with_multiple_env_files(
tmp_path, files: Sequence[str], file_contents: Sequence[str], expected: dict
):
"""
Test loading variables from two separate env files using file arguments.

This demonstrates the pattern shown in the README where multiple env files
are loaded (e.g., .env.shared and .env.secret) and all variables from both
files are accessible.
Expand All @@ -327,4 +334,3 @@ def test_run_with_multiple_env_files(tmp_path, files: Sequence[str], file_conten
for key, value in expected.items():
result = invoke_sub([*file_args, "run", "printenv", key])
assert result.stdout.strip() == value

Loading