Fix hook_types when calling init-templatedir

This commit is contained in:
Anthony Sottile 2019-09-30 10:29:53 -07:00
parent 2d0927d0b3
commit 36609ee305
2 changed files with 28 additions and 6 deletions

View file

@ -13,6 +13,20 @@ from pre_commit.error_handler import FatalError
from testing.auto_namedtuple import auto_namedtuple
@pytest.mark.parametrize(
('argv', 'expected'),
(
((), ['f']),
(('--f', 'x'), ['x']),
(('--f', 'x', '--f', 'y'), ['x', 'y']),
),
)
def test_append_replace_default(argv, expected):
parser = argparse.ArgumentParser()
parser.add_argument('--f', action=main.AppendReplaceDefault, default=['f'])
assert parser.parse_args(argv).f == expected
class Args(object):
def __init__(self, **kwargs):
kwargs.setdefault('command', 'help')