summaryrefslogtreecommitdiff
path: root/tests/unit/test_cli.py
diff options
context:
space:
mode:
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