From 2370793f3861853591b89f25b12812b679f65bd3 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 10 May 2016 20:07:27 +0200 Subject: [PATCH] Make win_id/count mutually exclusive for ArgInfo --- qutebrowser/commands/command.py | 2 ++ tests/unit/commands/test_cmdutils.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/qutebrowser/commands/command.py b/qutebrowser/commands/command.py index 9048ea4e0..802d4a4bb 100644 --- a/qutebrowser/commands/command.py +++ b/qutebrowser/commands/command.py @@ -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 diff --git a/tests/unit/commands/test_cmdutils.py b/tests/unit/commands/test_cmdutils.py index 6a4bc829b..1fa47d556 100644 --- a/tests/unit/commands/test_cmdutils.py +++ b/tests/unit/commands/test_cmdutils.py @@ -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!"