Skip to content

Commit e4a50c3

Browse files
committed
add description/tests for empty *args
1 parent d7c9a79 commit e4a50c3

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

plan.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ This feature will not disrupt explicitly declared flags/options.
6060
./command.py --flag input.txt --option val --unknown val2 -- arg1 arg2
6161
```
6262

63+
Empty args are handled gracefully.
64+
65+
```bash
66+
# both of the following produce args = ()
67+
./command.py input.txt
68+
./command.py input.txt --
69+
```
70+
6371
Unknown options *must* have values.
6472
(To emulate a boolean flag, simply pass a value so that `kwargs.get("unknown_flag")` is truthy.)
6573

tests/test_kwargs.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,21 @@ def cmd(*args: str, option: str = "default") -> None:
202202
result = runner.invoke(app, ["--option", "custom", "a", "b"])
203203
assert result.exit_code == 0, result.output
204204
assert json.loads(result.output.strip()) == {"args": ["a", "b"], "option": "custom"}
205+
206+
207+
def test_empty_args_without_separator() -> None:
208+
"""./command.py input.txt → args = ()"""
209+
_kitchen_sink_helper(
210+
["input.txt"],
211+
expected_filepath="input.txt",
212+
expected_args=[],
213+
)
214+
215+
216+
def test_empty_args_with_separator() -> None:
217+
"""./command.py input.txt -- → args = ()"""
218+
_kitchen_sink_helper(
219+
["input.txt", "--"],
220+
expected_filepath="input.txt",
221+
expected_args=[],
222+
)

0 commit comments

Comments
 (0)