@@ -214,31 +214,44 @@ def test_load_empty_pyproject_toml_from_config_argument(_, tmpdir):
214
214
config .read_cfg (filepath = "./not_in_root/pyproject.toml" )
215
215
216
216
217
+ @pytest .mark .parametrize (
218
+ "config_file, exception_string" ,
219
+ [
220
+ (".cz.toml" , r"\.cz\.toml" ),
221
+ ("cz.toml" , r"cz\.toml" ),
222
+ ("pyproject.toml" , r"pyproject\.toml" ),
223
+ ],
224
+ ids = [".cz.toml" , "cz.toml" , "pyproject.toml" ],
225
+ )
217
226
class TestTomlConfig :
218
- def test_init_empty_config_content (self , tmpdir ):
219
- path = tmpdir .mkdir ("commitizen" ).join (".cz.toml" )
227
+ def test_init_empty_config_content (self , tmpdir , config_file , exception_string ):
228
+ path = tmpdir .mkdir ("commitizen" ).join (config_file )
220
229
toml_config = config .TomlConfig (data = "" , path = path )
221
230
toml_config .init_empty_config_content ()
222
231
223
232
with open (path , encoding = "utf-8" ) as toml_file :
224
233
assert toml_file .read () == "[tool.commitizen]\n "
225
234
226
- def test_init_empty_config_content_with_existing_content (self , tmpdir ):
235
+ def test_init_empty_config_content_with_existing_content (
236
+ self , tmpdir , config_file , exception_string
237
+ ):
227
238
existing_content = "[tool.black]\n " "line-length = 88\n "
228
239
229
- path = tmpdir .mkdir ("commitizen" ).join (".cz.toml" )
240
+ path = tmpdir .mkdir ("commitizen" ).join (config_file )
230
241
path .write (existing_content )
231
242
toml_config = config .TomlConfig (data = "" , path = path )
232
243
toml_config .init_empty_config_content ()
233
244
234
245
with open (path , encoding = "utf-8" ) as toml_file :
235
246
assert toml_file .read () == existing_content + "\n [tool.commitizen]\n "
236
247
237
- def test_init_with_invalid_config_content (self , tmpdir ):
248
+ def test_init_with_invalid_config_content (
249
+ self , tmpdir , config_file , exception_string
250
+ ):
238
251
existing_content = "invalid toml content"
239
- path = tmpdir .mkdir ("commitizen" ).join (".cz.toml" )
252
+ path = tmpdir .mkdir ("commitizen" ).join (config_file )
240
253
241
- with pytest .raises (InvalidConfigurationError , match = r"\.cz\.toml" ):
254
+ with pytest .raises (InvalidConfigurationError , match = exception_string ):
242
255
config .TomlConfig (data = existing_content , path = path )
243
256
244
257
0 commit comments