diff --git a/commitizen/cz/base.py b/commitizen/cz/base.py index cdc147669..427ba8c3f 100644 --- a/commitizen/cz/base.py +++ b/commitizen/cz/base.py @@ -84,18 +84,18 @@ def style(self) -> Style: ] ) # type: ignore[return-value] + @abstractmethod def example(self) -> str: """Example of the commit message.""" - raise NotImplementedError("Not Implemented yet") + @abstractmethod def schema(self) -> str: """Schema definition of the commit message.""" - raise NotImplementedError("Not Implemented yet") + @abstractmethod def schema_pattern(self) -> str: """Regex matching the schema used for message validation.""" - raise NotImplementedError("Not Implemented yet") + @abstractmethod def info(self) -> str: """Information about the standardized commit message.""" - raise NotImplementedError("Not Implemented yet") diff --git a/tests/conftest.py b/tests/conftest.py index 324ef9beb..61b64ae8d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -215,6 +215,18 @@ def message(self, answers: Mapping) -> str: subject = answers.get("subject", "default message").trim() return f"{prefix}: {subject}" + def example(self) -> str: + return "" + + def schema(self) -> str: + return "" + + def schema_pattern(self) -> str: + return "" + + def info(self) -> str: + return "" + @pytest.fixture() def use_cz_semver(mocker): @@ -229,6 +241,18 @@ def questions(self) -> list[CzQuestion]: def message(self, answers: Mapping) -> str: return "" + def example(self) -> str: + return "" + + def schema(self) -> str: + return "" + + def schema_pattern(self) -> str: + return "" + + def info(self) -> str: + return "" + @pytest.fixture def mock_plugin(mocker: MockerFixture, config: BaseConfig) -> BaseCommitizen: diff --git a/tests/test_cz_base.py b/tests/test_cz_base.py deleted file mode 100644 index 0ee5a23fb..000000000 --- a/tests/test_cz_base.py +++ /dev/null @@ -1,46 +0,0 @@ -from collections.abc import Mapping - -import pytest - -from commitizen.cz.base import BaseCommitizen - - -class DummyCz(BaseCommitizen): - def questions(self): - return [{"type": "input", "name": "commit", "message": "Initial commit:\n"}] - - def message(self, answers: Mapping): - return answers["commit"] - - -def test_base_raises_error(config): - with pytest.raises(TypeError): - BaseCommitizen(config) - - -def test_questions(config): - cz = DummyCz(config) - assert isinstance(cz.questions(), list) - - -def test_message(config): - cz = DummyCz(config) - assert cz.message({"commit": "holis"}) == "holis" - - -def test_example(config): - cz = DummyCz(config) - with pytest.raises(NotImplementedError): - cz.example() - - -def test_schema(config): - cz = DummyCz(config) - with pytest.raises(NotImplementedError): - cz.schema() - - -def test_info(config): - cz = DummyCz(config) - with pytest.raises(NotImplementedError): - cz.info()