clan-core/pkgs/clan-cli/tests/test_cli.py

23 lines
566 B
Python
Raw Normal View History

import sys
2023-07-21 10:48:26 +00:00
import pytest
2023-07-21 12:01:56 +00:00
import clan_cli
2023-07-21 12:01:56 +00:00
def test_no_args(
capsys: pytest.CaptureFixture, monkeypatch: pytest.MonkeyPatch
) -> None:
2023-07-21 12:07:38 +00:00
monkeypatch.setattr(sys, "argv", [""])
2023-07-21 11:30:35 +00:00
clan_cli.main()
captured = capsys.readouterr()
assert captured.out.startswith("usage:")
2023-07-21 11:34:35 +00:00
def test_help(capsys: pytest.CaptureFixture, monkeypatch: pytest.MonkeyPatch) -> None:
2023-07-21 00:01:39 +00:00
monkeypatch.setattr(sys, "argv", ["", "--help"])
with pytest.raises(SystemExit):
2023-07-21 11:30:35 +00:00
clan_cli.main()
captured = capsys.readouterr()
2023-07-21 00:01:39 +00:00
assert captured.out.startswith("usage:")