1
0
Fork 0
commitizen/tests/test_cz_utils.py
Daniel Baumann 167a3f8553
Adding upstream version 4.6.0+dfsg.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-04-21 11:40:48 +02:00

26 lines
873 B
Python

import pytest
from pytest_mock import MockFixture
from commitizen.cz import exceptions, utils
def test_required_validator():
assert utils.required_validator("test") == "test"
with pytest.raises(exceptions.AnswerRequiredError):
utils.required_validator("")
def test_multiple_line_breaker():
message = "this is the first line | and this is the second line "
result = utils.multiple_line_breaker(message)
assert result == "this is the first line\nand this is the second line"
result = utils.multiple_line_breaker(message, "is")
assert result == "th\n\nthe first line | and th\n\nthe second line"
def test_get_backup_file_path_no_project_root(mocker: MockFixture):
project_root_mock = mocker.patch("commitizen.git.find_git_project_root")
project_root_mock.return_value = None
assert utils.get_backup_file_path()