|
1 | 1 | """Tests for the bump module."""
|
2 | 2 |
|
3 | 3 | from pathlib import Path
|
| 4 | +import shutil |
4 | 5 | from textwrap import dedent
|
5 | 6 | from unittest.mock import MagicMock, patch
|
6 | 7 |
|
@@ -125,6 +126,34 @@ def test_passing_new_version_sets_version(self, mock_update_config_file, mock_mo
|
125 | 126 | assert mock_update_config_file.call_args[0][3] == version_config.parse(new_version)
|
126 | 127 | assert mock_update_config_file.call_args[0][5] is dry_run
|
127 | 128 |
|
| 129 | + @patch("bumpversion.bump.commit_and_tag") |
| 130 | + @patch("bumpversion.bump.update_config_file") |
| 131 | + def test_doesnt_commit_if_modify_error( |
| 132 | + self, mock_update_config_file, mock_commit_and_tag, tmp_path: Path, fixtures_path: Path |
| 133 | + ): |
| 134 | + from bumpversion import config |
| 135 | + |
| 136 | + # Arrange |
| 137 | + setup_py_path = tmp_path / "setup.py" |
| 138 | + setup_py_path.touch() |
| 139 | + init_path = tmp_path / "bumpversion/__init__.py" |
| 140 | + init_path.parent.mkdir(parents=True) |
| 141 | + init_path.touch() |
| 142 | + orig_config_path = fixtures_path / "basic_cfg.toml" |
| 143 | + dest_config_path = tmp_path / "pyproject.toml" |
| 144 | + shutil.copyfile(orig_config_path, dest_config_path) |
| 145 | + version_part = "patch" |
| 146 | + |
| 147 | + # Act |
| 148 | + with inside_dir(tmp_path): |
| 149 | + config = config.get_configuration(config_file=dest_config_path) |
| 150 | + bump.do_bump(version_part, None, config) |
| 151 | + |
| 152 | + # Assert |
| 153 | + mock_commit_and_tag.assert_not_called() |
| 154 | + |
| 155 | + mock_update_config_file.assert_not_called() |
| 156 | + |
128 | 157 | @patch("bumpversion.files.modify_files")
|
129 | 158 | @patch("bumpversion.bump.update_config_file")
|
130 | 159 | def test_when_new_equals_current_nothing_happens(self, mock_update_config_file, mock_modify_files, tmp_path: Path):
|
|
0 commit comments