From 94f37bc49a4d093c3cd8fc0fe4e407226cb88e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Fraire=20Willemo=C3=ABs?= Date: Mon, 18 Nov 2019 10:24:29 +0100 Subject: [PATCH] fix(test_cli): testing the version command --- pyproject.toml | 2 +- tests/test_cli.py | 9 ++++++--- tests/test_commands.py | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9b4f23913b..1b068f3156 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,7 @@ classifiers = [ [tool.poetry.dependencies] python = "^3.6" -questionary = "^1.4" +questionary = "^1.4.0" decli = "^0.5.0" colorama = "^0.4.1" termcolor = "^1.1" diff --git a/tests/test_cli.py b/tests/test_cli.py index 601311b603..619f1c5057 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -22,6 +22,9 @@ def test_ls(mocker, capsys): def test_version(mocker): testargs = ["cz", "--version"] - with pytest.raises(SystemExit): - mocker.patch.object(sys, "argv", testargs) - cli.main() + mocker.patch.object(sys, "argv", testargs) + error_mock = mocker.patch("commitizen.out.error") + + cli.main() + + error_mock.assert_called_once() diff --git a/tests/test_commands.py b/tests/test_commands.py index 249c046c2a..bd08c3da8f 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -96,7 +96,8 @@ def test_commit_when_nothing_to_commit(mocker): def test_commit_when_customized_expected_raised(mocker, capsys): _err = ValueError() _err.__context__ = CzException("This is the root custom err") - + git_mock = mocker.patch("commitizen.git.is_staging_clean") + git_mock.return_value = False prompt_mock = mocker.patch("questionary.prompt") prompt_mock.side_effect = _err