MCPcopy Create free account
hub / github.com/commitizen-tools/commitizen / test_manual_edit

Function test_manual_edit

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

Source from the content-addressed store, hash-verified

350@pytest.mark.usefixtures("staging_is_clean")
351@pytest.mark.parametrize("editor", ["vim", None])
352def test_manual_edit(editor, config, mocker: MockFixture, tmp_path):
353 mocker.patch("commitizen.git.get_core_editor", return_value=editor)
354 subprocess_mock = mocker.patch("subprocess.call")
355
356 mocker.patch("shutil.which", return_value=editor)
357
358 test_message = "Initial commit message"
359 temp_file = tmp_path / "temp_commit_message"
360 temp_file.write_text(test_message)
361
362 mock_temp_file = mocker.patch("tempfile.NamedTemporaryFile")
363 mock_temp_file.return_value.__enter__.return_value.name = str(temp_file)
364
365 commit_cmd = commands.Commit(config, {"edit": True})
366
367 if editor is None:
368 with pytest.raises(RuntimeError):
369 commit_cmd.manual_edit(test_message)
370 else:
371 edited_message = commit_cmd.manual_edit(test_message)
372 subprocess_mock.assert_called_once_with(["vim", str(temp_file)])
373 assert edited_message == test_message.strip()
374
375
376@pytest.mark.usefixtures("staging_is_clean")

Callers

nothing calls this directly

Calls 1

manual_editMethod · 0.95

Tested by

no test coverage detected