@@ -31,7 +31,7 @@ def ask(self):
3131 'tag_format = "$version"\n '
3232)
3333
34- EXPECTED_JSON_CONFIG = {
34+ EXPECTED_DICT_CONFIG = {
3535 "commitizen" : {
3636 "name" : "cz_conventional_commits" ,
3737 "version" : "0.0.1" ,
@@ -94,7 +94,7 @@ def test_init_without_choosing_tag(config, mocker, tmpdir):
9494
9595
9696class TestPreCommitCases :
97- @pytest .fixture (scope = "function" , params = ["pyproject.toml" , ".cz.json" ])
97+ @pytest .fixture (scope = "function" , params = ["pyproject.toml" , ".cz.json" , ".cz.yaml" ])
9898 def default_choice (_ , request , mocker ):
9999 mocker .patch (
100100 "questionary.select" ,
@@ -108,13 +108,15 @@ def default_choice(_, request, mocker):
108108 mocker .patch ("questionary.confirm" , return_value = FakeQuestion (True ))
109109 return request .param
110110
111- def test_no_existing_pre_commit_json_conifg (_ , default_choice , tmpdir , config ):
111+ def test_no_existing_pre_commit_conifg (_ , default_choice , tmpdir , config ):
112112 with tmpdir .as_cwd ():
113113 commands .Init (config )()
114114
115115 with open (default_choice , "r" ) as file :
116116 if "json" in default_choice :
117- assert json .load (file ) == EXPECTED_JSON_CONFIG
117+ assert json .load (file ) == EXPECTED_DICT_CONFIG
118+ elif "yaml" in default_choice :
119+ assert yaml .load (file ) == EXPECTED_DICT_CONFIG
118120 else :
119121 config_data = file .read ()
120122 assert config_data == expected_config
@@ -132,7 +134,9 @@ def test_empty_pre_commit_config(_, default_choice, tmpdir, config):
132134
133135 with open (default_choice , "r" ) as file :
134136 if "json" in default_choice :
135- assert json .load (file ) == EXPECTED_JSON_CONFIG
137+ assert json .load (file ) == EXPECTED_DICT_CONFIG
138+ elif "yaml" in default_choice :
139+ assert yaml .load (file ) == EXPECTED_DICT_CONFIG
136140 else :
137141 config_data = file .read ()
138142 assert config_data == expected_config
@@ -156,7 +160,9 @@ def test_pre_commit_config_without_cz_hook(_, default_choice, tmpdir, config):
156160
157161 with open (default_choice , "r" ) as file :
158162 if "json" in default_choice :
159- assert json .load (file ) == EXPECTED_JSON_CONFIG
163+ assert json .load (file ) == EXPECTED_DICT_CONFIG
164+ elif "yaml" in default_choice :
165+ assert yaml .load (file ) == EXPECTED_DICT_CONFIG
160166 else :
161167 config_data = file .read ()
162168 assert config_data == expected_config
@@ -176,7 +182,9 @@ def test_cz_hook_exists_in_pre_commit_config(_, default_choice, tmpdir, config):
176182
177183 with open (default_choice , "r" ) as file :
178184 if "json" in default_choice :
179- assert json .load (file ) == EXPECTED_JSON_CONFIG
185+ assert json .load (file ) == EXPECTED_DICT_CONFIG
186+ elif "yaml" in default_choice :
187+ assert yaml .load (file ) == EXPECTED_DICT_CONFIG
180188 else :
181189 config_data = file .read ()
182190 assert config_data == expected_config
0 commit comments