@@ -31,7 +31,7 @@ def ask(self):
31
31
'tag_format = "$version"\n '
32
32
)
33
33
34
- EXPECTED_JSON_CONFIG = {
34
+ EXPECTED_DICT_CONFIG = {
35
35
"commitizen" : {
36
36
"name" : "cz_conventional_commits" ,
37
37
"version" : "0.0.1" ,
@@ -94,7 +94,7 @@ def test_init_without_choosing_tag(config, mocker, tmpdir):
94
94
95
95
96
96
class TestPreCommitCases :
97
- @pytest .fixture (scope = "function" , params = ["pyproject.toml" , ".cz.json" ])
97
+ @pytest .fixture (scope = "function" , params = ["pyproject.toml" , ".cz.json" , ".cz.yaml" ])
98
98
def default_choice (_ , request , mocker ):
99
99
mocker .patch (
100
100
"questionary.select" ,
@@ -108,13 +108,15 @@ def default_choice(_, request, mocker):
108
108
mocker .patch ("questionary.confirm" , return_value = FakeQuestion (True ))
109
109
return request .param
110
110
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 ):
112
112
with tmpdir .as_cwd ():
113
113
commands .Init (config )()
114
114
115
115
with open (default_choice , "r" ) as file :
116
116
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
118
120
else :
119
121
config_data = file .read ()
120
122
assert config_data == expected_config
@@ -132,7 +134,9 @@ def test_empty_pre_commit_config(_, default_choice, tmpdir, config):
132
134
133
135
with open (default_choice , "r" ) as file :
134
136
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
136
140
else :
137
141
config_data = file .read ()
138
142
assert config_data == expected_config
@@ -156,7 +160,9 @@ def test_pre_commit_config_without_cz_hook(_, default_choice, tmpdir, config):
156
160
157
161
with open (default_choice , "r" ) as file :
158
162
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
160
166
else :
161
167
config_data = file .read ()
162
168
assert config_data == expected_config
@@ -176,7 +182,9 @@ def test_cz_hook_exists_in_pre_commit_config(_, default_choice, tmpdir, config):
176
182
177
183
with open (default_choice , "r" ) as file :
178
184
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
180
188
else :
181
189
config_data = file .read ()
182
190
assert config_data == expected_config
0 commit comments