Skip to content

Commit

Permalink
test: add coverage for action="count" (#127) (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
neithere committed Sep 3, 2023
1 parent ae94c12 commit 4ee7fd5
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_integration.py
Expand Up @@ -1255,3 +1255,30 @@ def second_func():
"""
)[1:]
)


def test_action_count__only_arg_decorator():
@argh.arg("-v", "--verbose", action="count", default=0)
def func(**kwargs):
verbosity = kwargs.get("verbose")
return f"verbosity: {verbosity}"

p = DebugArghParser()
p.set_default_command(func)

assert run(p, "").out == "verbosity: 0\n"
assert run(p, "-v").out == "verbosity: 1\n"
assert run(p, "-vvvv").out == "verbosity: 4\n"


def test_action_count__mixed():
@argh.arg("-v", "--verbose", action="count")
def func(verbose=0):
return f"verbosity: {verbose}"

p = DebugArghParser()
p.set_default_command(func)

assert run(p, "").out == "verbosity: 0\n"
assert run(p, "-v").out == "verbosity: 1\n"
assert run(p, "-vvvv").out == "verbosity: 4\n"

0 comments on commit 4ee7fd5

Please sign in to comment.