@@ -112,15 +112,28 @@ def test_file_keyword_with_suffix_is_accepted(tmp_path: Path, cfg_file: str, cfg
112
112
113
113
114
114
def test_multiple_config_files (tmp_path : Path ):
115
+ """If there are multiple config files, the first one with content wins."""
115
116
setup_cfg = tmp_path / "setup.cfg"
116
- setup_cfg .write_text ("[bumpversion] \n " "current_version: 0.10.2 \n " "tag: true \n " )
117
+ setup_cfg .write_text ("[metadata] \n name: just-a-name \n " )
117
118
bumpversion_cfg = tmp_path / ".bumpversion.cfg"
118
- bumpversion_cfg .write_text ("[bumpversion]\n " "current_version: 0.10.2\n " "tag: false\n " )
119
-
120
- cfg_file = config .find_config_file ()
121
- cfg = config .get_configuration (cfg_file )
119
+ bumpversion_cfg .write_text ("\n " )
120
+ pyproject_toml = tmp_path / "pyproject.toml"
121
+ pyproject_toml .write_text (
122
+ "[tool.bumpversion]\n "
123
+ 'current_version = "0.10.5"\n '
124
+ 'parse = "(?P<major>\\ \\ d+)\\ \\ .(?P<minor>\\ \\ d+)\\ \\ .(?P<patch>\\ \\ d+)(\\ \\ -(?P<release>[a-z]+))?"\n '
125
+ "serialize = [\n "
126
+ ' "{major}.{minor}.{patch}-{release}",\n '
127
+ ' "{major}.{minor}.{patch}"\n '
128
+ "]\n "
129
+ )
130
+ with inside_dir (tmp_path ):
131
+ cfg_file = config .find_config_file ()
132
+ cfg = config .get_configuration (cfg_file )
122
133
123
- assert cfg .tag is True
134
+ assert cfg .current_version == "0.10.5"
135
+ assert cfg .parse == "(?P<major>\\ d+)\\ .(?P<minor>\\ d+)\\ .(?P<patch>\\ d+)(\\ -(?P<release>[a-z]+))?"
136
+ assert cfg .serialize == ["{major}.{minor}.{patch}-{release}" , "{major}.{minor}.{patch}" ]
124
137
125
138
126
139
def test_utf8_message_from_config_file (tmp_path : Path , cfg_file ):
0 commit comments