@@ -255,35 +255,53 @@ def test_init_with_invalid_config_content(
255255 config .TomlConfig (data = existing_content , path = path )
256256
257257
258+ @pytest .mark .parametrize (
259+ "config_file, exception_string" ,
260+ [
261+ (".cz.json" , r"\.cz\.json" ),
262+ ("cz.json" , r"cz\.json" ),
263+ ],
264+ ids = [".cz.json" , "cz.json" ],
265+ )
258266class TestJsonConfig :
259- def test_init_empty_config_content (self , tmpdir ):
260- path = tmpdir .mkdir ("commitizen" ).join (".cz.json" )
267+ def test_init_empty_config_content (self , tmpdir , config_file , exception_string ):
268+ path = tmpdir .mkdir ("commitizen" ).join (config_file )
261269 json_config = config .JsonConfig (data = "{}" , path = path )
262270 json_config .init_empty_config_content ()
263271
264272 with open (path , encoding = "utf-8" ) as json_file :
265273 assert json .load (json_file ) == {"commitizen" : {}}
266274
267- def test_init_with_invalid_config_content (self , tmpdir ):
275+ def test_init_with_invalid_config_content (
276+ self , tmpdir , config_file , exception_string
277+ ):
268278 existing_content = "invalid json content"
269- path = tmpdir .mkdir ("commitizen" ).join (".cz.json" )
279+ path = tmpdir .mkdir ("commitizen" ).join (config_file )
270280
271- with pytest .raises (InvalidConfigurationError , match = r"\.cz\.json" ):
281+ with pytest .raises (InvalidConfigurationError , match = exception_string ):
272282 config .JsonConfig (data = existing_content , path = path )
273283
274284
285+ @pytest .mark .parametrize (
286+ "config_file, exception_string" ,
287+ [
288+ (".cz.yaml" , r"\.cz\.yaml" ),
289+ ("cz.yaml" , r"cz\.yaml" ),
290+ ],
291+ ids = [".cz.yaml" , "cz.yaml" ],
292+ )
275293class TestYamlConfig :
276- def test_init_empty_config_content (self , tmpdir ):
277- path = tmpdir .mkdir ("commitizen" ).join (".cz.yaml" )
294+ def test_init_empty_config_content (self , tmpdir , config_file , exception_string ):
295+ path = tmpdir .mkdir ("commitizen" ).join (config_file )
278296 yaml_config = config .YAMLConfig (data = "{}" , path = path )
279297 yaml_config .init_empty_config_content ()
280298
281299 with open (path ) as yaml_file :
282300 assert yaml .safe_load (yaml_file ) == {"commitizen" : {}}
283301
284- def test_init_with_invalid_content (self , tmpdir ):
302+ def test_init_with_invalid_content (self , tmpdir , config_file , exception_string ):
285303 existing_content = "invalid: .cz.yaml: content: maybe?"
286- path = tmpdir .mkdir ("commitizen" ).join (".cz.yaml" )
304+ path = tmpdir .mkdir ("commitizen" ).join (config_file )
287305
288- with pytest .raises (InvalidConfigurationError , match = r"\.cz\.yaml" ):
306+ with pytest .raises (InvalidConfigurationError , match = exception_string ):
289307 config .YAMLConfig (data = existing_content , path = path )
0 commit comments