-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add linting test to ensure use of ExtendOverwriteDefault for nargs=*/+
- Loading branch information
Showing
3 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Originally based on tests/help.py from the Nextstrain CLI project.¹ | ||
# | ||
# ¹ <https://github.com/nextstrain/cli/blob/4a00d7100eff811eab6df34db73c7f6d4196e22b/tests/help.py> | ||
import pytest | ||
from argparse import ArgumentParser | ||
from typing import List, Tuple | ||
|
||
from augur import make_parser | ||
from augur.argparse_ import walk_commands, ExtendOverwriteDefault | ||
|
||
|
||
# Walking commands is slow, so do it only once and use it for all tests in this | ||
# file (though currently n=1). | ||
commands = list(walk_commands(make_parser())) | ||
|
||
|
||
# Ensure we always use ExtendOverwriteDefault for options that take a variable | ||
# number of arguments. See <https://github.com/nextstrain/augur/pull/1709>. | ||
@pytest.mark.parametrize("action", [ | ||
pytest.param(action, id = " ".join(command) + " " + "/".join(action.option_strings)) | ||
for command, parser in commands | ||
for action in parser._actions | ||
if action.nargs in {"+", "*"} | ||
]) | ||
def test_ExtendOverwriteDefault(action): | ||
assert isinstance(action, ExtendOverwriteDefault) |