Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 380f5fd

Browse files
test(init): add yaml not a dict test case
1 parent 8ec67c5 commit 380f5fd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎tests/commands/test_init_command.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,19 @@ def test_pre_commit_config_yaml_without_repos(_, default_choice, tmpdir, config)
226226
# Should use DEFAULT_CONFIG since the file content doesn't have 'repos' key
227227
check_pre_commit_config([CZ_HOOK_CONFIG])
228228

229+
def test_pre_commit_config_yaml_not_a_dict(_, default_choice, tmpdir, config):
230+
with tmpdir.as_cwd():
231+
# Write a dictionary YAML content without 'repos' key
232+
p = tmpdir.join(PRE_COMMIT_CONFIG_FILENAME)
233+
p.write(
234+
yaml.safe_dump(["item1", "item2"])
235+
) # Dictionary without 'repos' key
236+
237+
commands.Init(config)()
238+
check_cz_config(default_choice)
239+
# Should use DEFAULT_CONFIG since the file content doesn't have 'repos' key
240+
check_pre_commit_config([CZ_HOOK_CONFIG])
241+
229242
def test_cz_hook_exists_in_pre_commit_config(_, default_choice, tmpdir, config):
230243
with tmpdir.as_cwd():
231244
p = tmpdir.join(PRE_COMMIT_CONFIG_FILENAME)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /