@@ -214,31 +214,44 @@ def test_load_empty_pyproject_toml_from_config_argument(_, tmpdir):
214214 config .read_cfg (filepath = "./not_in_root/pyproject.toml" )
215215
216216
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+ )
217226class 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 )
220229 toml_config = config .TomlConfig (data = "" , path = path )
221230 toml_config .init_empty_config_content ()
222231
223232 with open (path , encoding = "utf-8" ) as toml_file :
224233 assert toml_file .read () == "[tool.commitizen]\n "
225234
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+ ):
227238 existing_content = "[tool.black]\n " "line-length = 88\n "
228239
229- path = tmpdir .mkdir ("commitizen" ).join (".cz.toml" )
240+ path = tmpdir .mkdir ("commitizen" ).join (config_file )
230241 path .write (existing_content )
231242 toml_config = config .TomlConfig (data = "" , path = path )
232243 toml_config .init_empty_config_content ()
233244
234245 with open (path , encoding = "utf-8" ) as toml_file :
235246 assert toml_file .read () == existing_content + "\n [tool.commitizen]\n "
236247
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+ ):
238251 existing_content = "invalid toml content"
239- path = tmpdir .mkdir ("commitizen" ).join (".cz.toml" )
252+ path = tmpdir .mkdir ("commitizen" ).join (config_file )
240253
241- with pytest .raises (InvalidConfigurationError , match = r"\.cz\.toml" ):
254+ with pytest .raises (InvalidConfigurationError , match = exception_string ):
242255 config .TomlConfig (data = existing_content , path = path )
243256
244257
0 commit comments