|
15 | 15 | import yaml
|
16 | 16 |
|
17 | 17 | from ansible_dev_environment.arg_parser import parse
|
18 |
| -from ansible_dev_environment.cli import Cli |
| 18 | +from ansible_dev_environment.cli import Cli, main |
19 | 19 | from ansible_dev_environment.config import Config
|
20 | 20 | from ansible_dev_environment.subcommands.installer import Installer
|
21 | 21 | from ansible_dev_environment.utils import subprocess_run
|
@@ -737,6 +737,25 @@ def test_collection_pre_install(
|
737 | 737 | assert sorted({c.name for c in subdirs}) == ["posix", "utils"]
|
738 | 738 |
|
739 | 739 |
|
| 740 | +def test_args_sanity(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]) -> None: |
| 741 | + """Test the args_sanity method. |
| 742 | +
|
| 743 | + Args: |
| 744 | + monkeypatch: The monkeypatch fixture. |
| 745 | + capsys: The capsys fixture. |
| 746 | + """ |
| 747 | + # Adds invalid entry in PATH to detect that we can detect it and exit |
| 748 | + monkeypatch.setenv("PATH", "~/bin", prepend=os.pathsep) |
| 749 | + monkeypatch.setattr("sys.argv", ["ade", "check"]) |
| 750 | + |
| 751 | + with pytest.raises(SystemExit) as exc: |
| 752 | + main(dry=True) |
| 753 | + assert exc.value.code == 1 |
| 754 | + |
| 755 | + captured = capsys.readouterr() |
| 756 | + assert "~ character was found inside PATH" in captured.err |
| 757 | + |
| 758 | + |
740 | 759 | @pytest.mark.parametrize("first", (True, False), ids=["editable", "not_editable"])
|
741 | 760 | @pytest.mark.parametrize("second", (True, False), ids=["editable", "not_editable"])
|
742 | 761 | def test_reinstall_local_collection( # pylint: disable=too-many-positional-arguments
|
|
0 commit comments