Skip to content

Commit d1bb2be

Browse files
committed
Update test.
1 parent 43f3beb commit d1bb2be

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tests/test_source_cli.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
CliSettingsSource,
3737
CliSubCommand,
3838
CliSuppress,
39+
CliUnknownArgs,
3940
get_subcommand,
4041
)
4142

@@ -1728,14 +1729,26 @@ def test_cli_ignore_unknown_args():
17281729
class Cfg(BaseSettings, cli_ignore_unknown_args=True):
17291730
this: str = 'hello'
17301731
that: int = 123
1732+
ignored_args: CliUnknownArgs
1733+
1734+
cfg = CliApp.run(Cfg, cli_args=['--this=hi', '--that=456'])
1735+
assert cfg.model_dump() == {'this': 'hi', 'that': 456, 'ignored_args': []}
17311736

17321737
cfg = CliApp.run(Cfg, cli_args=['not_my_positional_arg', '--not-my-optional-arg=456'])
1733-
assert cfg.model_dump() == {'this': 'hello', 'that': 123}
1738+
assert cfg.model_dump() == {
1739+
'this': 'hello',
1740+
'that': 123,
1741+
'ignored_args': ['not_my_positional_arg', '--not-my-optional-arg=456'],
1742+
}
17341743

17351744
cfg = CliApp.run(
17361745
Cfg, cli_args=['not_my_positional_arg', '--not-my-optional-arg=456', '--this=goodbye', '--that=789']
17371746
)
1738-
assert cfg.model_dump() == {'this': 'goodbye', 'that': 789}
1747+
assert cfg.model_dump() == {
1748+
'this': 'goodbye',
1749+
'that': 789,
1750+
'ignored_args': ['not_my_positional_arg', '--not-my-optional-arg=456'],
1751+
}
17391752

17401753

17411754
def test_cli_flag_prefix_char():

0 commit comments

Comments
 (0)