(editor, config, mocker: MockFixture, tmp_path)
| 297 | @pytest.mark.usefixtures("staging_is_clean") |
| 298 | @pytest.mark.parametrize("editor", ["vim", None]) |
| 299 | def test_manual_edit(editor, config, mocker: MockFixture, tmp_path): |
| 300 | mocker.patch("commitizen.git.get_core_editor", return_value=editor) |
| 301 | subprocess_mock = mocker.patch("subprocess.call") |
| 302 | |
| 303 | mocker.patch("shutil.which", return_value=editor) |
| 304 | |
| 305 | test_message = "Initial commit message" |
| 306 | temp_file = tmp_path / "temp_commit_message" |
| 307 | temp_file.write_text(test_message) |
| 308 | |
| 309 | mock_temp_file = mocker.patch("tempfile.NamedTemporaryFile") |
| 310 | mock_temp_file.return_value.__enter__.return_value.name = str(temp_file) |
| 311 | |
| 312 | commit_cmd = commands.Commit(config, {"edit": True}) |
| 313 | |
| 314 | if editor is None: |
| 315 | with pytest.raises(RuntimeError): |
| 316 | commit_cmd.manual_edit(test_message) |
| 317 | else: |
| 318 | edited_message = commit_cmd.manual_edit(test_message) |
| 319 | subprocess_mock.assert_called_once_with(["vim", str(temp_file)]) |
| 320 | assert edited_message == test_message.strip() |
| 321 | |
| 322 | |
| 323 | @pytest.mark.usefixtures("staging_is_clean", "prompt_mock_feat") |
nothing calls this directly
no test coverage detected
searching dependent graphs…