Make win_id/count mutually exclusive for ArgInfo

This commit is contained in:
Florian Bruhin 2016-05-10 20:07:27 +02:00
parent 35135c4b0d
commit 2370793f38
2 changed files with 11 additions and 0 deletions

View File

@ -40,6 +40,8 @@ class ArgInfo:
"""Information about an argument."""
def __init__(self, win_id=False, count=False, flag=None):
if win_id and count:
raise TypeError("Argument marked as both count/win_id!")
self.win_id = win_id
self.count = count
self.flag = flag

View File

@ -294,3 +294,12 @@ class TestArgument:
"@cmdutils.register for fun!")
assert str(excinfo.value) == text
def test_count_and_win_id_same_arg(self):
with pytest.raises(TypeError) as excinfo:
@cmdutils.argument('arg', count=True, win_id=True)
def fun(arg=0):
"""Blah."""
pass
assert str(excinfo.value) == "Argument marked as both count/win_id!"