-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/file_.pre-commit-config.yaml_240603-22…
…5641
- Loading branch information
Showing
12 changed files
with
761 additions
and
31 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
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 |
---|---|---|
|
@@ -170,7 +170,3 @@ def main() -> None: | |
cli.args_sanity() | ||
cli.ensure_isolated() | ||
cli.run() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,92 @@ | ||
"""Tests for the arg_parser module.""" | ||
|
||
import pytest | ||
|
||
from ansible_dev_environment.arg_parser import ( | ||
ArgumentParser, | ||
CustomHelpFormatter, | ||
_group_titles, | ||
) | ||
|
||
|
||
def test_no_option_string( | ||
capsys: pytest.CaptureFixture[str], | ||
) -> None: | ||
"""Test an argument without an option string. | ||
Args: | ||
capsys: Pytest fixture. | ||
""" | ||
parser = ArgumentParser( | ||
formatter_class=CustomHelpFormatter, | ||
) | ||
parser.add_argument( | ||
dest="test", | ||
action="store_true", | ||
help="Test this", | ||
) | ||
parser.print_help() | ||
captured = capsys.readouterr() | ||
assert "Test this" in captured.out | ||
|
||
|
||
def test_one_string( | ||
capsys: pytest.CaptureFixture[str], | ||
) -> None: | ||
"""Test an argument without an option string. | ||
Args: | ||
capsys: Pytest fixture. | ||
""" | ||
parser = ArgumentParser( | ||
formatter_class=CustomHelpFormatter, | ||
) | ||
parser.add_argument( | ||
"-t", | ||
dest="test", | ||
action="store_true", | ||
help="Test this", | ||
) | ||
parser.print_help() | ||
captured = capsys.readouterr() | ||
assert "-t Test this" in captured.out | ||
|
||
|
||
def test_too_many_string( | ||
monkeypatch: pytest.MonkeyPatch, | ||
) -> None: | ||
"""Test an argument with too many option strings. | ||
Args: | ||
monkeypatch: Pytest fixture. | ||
""" | ||
monkeypatch.setattr("sys.argv", ["prog", "--help"]) | ||
|
||
parser = ArgumentParser( | ||
formatter_class=CustomHelpFormatter, | ||
) | ||
parser.add_argument( | ||
"-t", | ||
"-test", | ||
"--test", | ||
action="store_true", | ||
help="Test this", | ||
) | ||
with pytest.raises(ValueError, match="Too many option strings"): | ||
parser.parse_args() | ||
|
||
|
||
def test_group_no_title(capsys: pytest.CaptureFixture[str]) -> None: | ||
"""Test a group without a title. | ||
Args: | ||
capsys: Pytest fixture. | ||
""" | ||
parser = ArgumentParser( | ||
formatter_class=CustomHelpFormatter, | ||
) | ||
parser.add_argument_group() | ||
_group_titles(parser) | ||
parser.print_help() | ||
captured = capsys.readouterr() | ||
assert "--help" in captured.out |
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
Oops, something went wrong.