clan-cli: write some unit tests

This commit is contained in:
DavHau
2023-07-21 02:01:39 +02:00
committed by Jörg Thalheim
parent a0701bf988
commit 4c4ff01b64
5 changed files with 42 additions and 15 deletions

View File

@@ -1,16 +1,19 @@
import sys
import my_tool
import pytest
import clan
def test_no_args(capsys):
my_tool.my_cli()
clan.clan()
captured = capsys.readouterr()
assert captured.out.startswith("usage:")
def test_version(capsys, monkeypatch):
monkeypatch.setattr(sys, "argv", ["", "--version"])
my_tool.my_cli()
def test_help(capsys, monkeypatch):
monkeypatch.setattr(sys, "argv", ["", "--help"])
with pytest.raises(SystemExit):
clan.clan()
captured = capsys.readouterr()
assert captured.out.startswith("Version:")
assert captured.out.startswith("usage:")