summaryrefslogtreecommitdiff
path: root/tests/unit/test_cli.py
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2021-11-27 20:28:15 +0100
committerNejc Habjan <hab.nejc@gmail.com>2021-11-27 21:08:47 +0100
commit6b892e3dcb18d0f43da6020b08fd4ba891da3670 (patch)
treee97beaaca3b5b94764f78e0fd99df0c53fd19f8b /tests/unit/test_cli.py
parent70b9870f929c4db32fd2e1406db2122de9958bfd (diff)
downloadgitlab-test/cli-coverage.tar.gz
test(cli): improve basic CLI coveragetest/cli-coverage
Diffstat (limited to 'tests/unit/test_cli.py')
-rw-r--r--tests/unit/test_cli.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/unit/test_cli.py b/tests/unit/test_cli.py
index d5afe69..2ada1c3 100644
--- a/tests/unit/test_cli.py
+++ b/tests/unit/test_cli.py
@@ -25,6 +25,7 @@ from contextlib import redirect_stderr # noqa: H302
import pytest
from gitlab import cli
+from gitlab.exceptions import GitlabError
@pytest.mark.parametrize(
@@ -66,12 +67,19 @@ def test_cls_to_what(class_name, expected_what):
assert cli.cls_to_what(TestClass) == expected_what
-def test_die():
+@pytest.mark.parametrize(
+ "message,error,expected",
+ [
+ ("foobar", None, "foobar\n"),
+ ("foo", GitlabError("bar"), "foo (bar)\n"),
+ ],
+)
+def test_die(message, error, expected):
fl = io.StringIO()
with redirect_stderr(fl):
with pytest.raises(SystemExit) as test:
- cli.die("foobar")
- assert fl.getvalue() == "foobar\n"
+ cli.die(message, error)
+ assert fl.getvalue() == expected
assert test.value.code == 1