File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2325,6 +2325,31 @@ def dump_cli(name, tag):
23252325 assert 'tag = ["x", "y"]' in result .stdout
23262326
23272327
2328+ def test_dump_config_captures_environment (invoke ):
2329+ """Values resolved from environment variables are reflected in the dump."""
2330+
2331+ @command
2332+ @option ("--city" , default = "Lisbon" )
2333+ @option ("--limit" , type = int , default = 5 )
2334+ def dump_cli (city , limit ):
2335+ echo ("ran" )
2336+
2337+ result = invoke (
2338+ dump_cli ,
2339+ "--city" ,
2340+ "Berlin" ,
2341+ "--dump-config" ,
2342+ "toml" ,
2343+ color = False ,
2344+ env = {"DUMP_CLI_CITY" : "Tokyo" , "DUMP_CLI_LIMIT" : "30" },
2345+ )
2346+ assert result .exit_code == 0
2347+ # The command line wins over the environment...
2348+ assert 'city = "Berlin"' in result .stdout
2349+ # ...but an environment-only value is still captured, keeping its type.
2350+ assert "limit = 30" in result .stdout
2351+
2352+
23282353def test_dump_config_numeric_values_keep_their_type (invoke ):
23292354 """A command-line numeric scalar is dumped as a number, not a quoted string."""
23302355
You can’t perform that action at this time.
0 commit comments