MCPcopy Index your code
hub / github.com/commitizen-tools/commitizen / test_manual_edit

Function test_manual_edit

tests/commands/test_commit_command.py:299–320  ·  view source on GitHub ↗
(editor, config, mocker: MockFixture, tmp_path)

Source from the content-addressed store, hash-verified

297@pytest.mark.usefixtures("staging_is_clean")
298@pytest.mark.parametrize("editor", ["vim", None])
299def 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")

Callers

nothing calls this directly

Calls 1

manual_editMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…