diff options
author | Nejc Habjan <hab.nejc@gmail.com> | 2021-11-28 02:17:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-28 02:17:56 +0100 |
commit | 09a973ee379d82af05a5080decfaec16d2f4eab3 (patch) | |
tree | df53d3f94109d124f4e8625d10417110f164d35a /tests/unit/test_cli.py | |
parent | 93a3893977d4e3a3e1916a94293e66373b1458fb (diff) | |
parent | 381c748415396e0fe54bb1f41a3303bab89aa065 (diff) | |
download | gitlab-09a973ee379d82af05a5080decfaec16d2f4eab3.tar.gz |
Merge pull request #1721 from python-gitlab/test/cli-coverage
test(cli): improve basic CLI coverage
Diffstat (limited to 'tests/unit/test_cli.py')
-rw-r--r-- | tests/unit/test_cli.py | 14 |
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 |