Skip to content

Commit 52d83ac

Browse files
committed
Add test for repr with dest set to improve coverage
1 parent a4f4696 commit 52d83ac

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

testing/test_argparsing_repr_fix.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,16 @@ def test_valid_option_works(self) -> None:
5050
options = parser._anonymous.options
5151
assert len(options) > 0
5252
assert "--shuffle" in options[0].names()
53+
54+
def test_repr_with_dest_set(self) -> None:
55+
"""Test that __repr__ works correctly when dest is set."""
56+
parser = Parser()
57+
parser.addoption("--valid-option", dest="valid_dest", help="A valid option")
58+
59+
# Get the argument object and check its repr
60+
option = parser._anonymous.options[0]
61+
repr_str = repr(option)
62+
63+
# Should contain the dest
64+
assert "dest: 'valid_dest'" in repr_str
65+
assert "<not set>" not in repr_str

0 commit comments

Comments
 (0)