From ce6763317433ca8509f45bd1d471fb4ad2eeffdd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 30 Jan 2023 17:53:22 +0100 Subject: Merging upstream version 3.0.2. Signed-off-by: Daniel Baumann --- tests/commands/migrate_config_test.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests/commands/migrate_config_test.py') diff --git a/tests/commands/migrate_config_test.py b/tests/commands/migrate_config_test.py index b80244e..fca1ad9 100644 --- a/tests/commands/migrate_config_test.py +++ b/tests/commands/migrate_config_test.py @@ -1,6 +1,9 @@ from __future__ import annotations +import pytest + import pre_commit.constants as C +from pre_commit.clientlib import InvalidConfigError from pre_commit.commands.migrate_config import migrate_config @@ -129,3 +132,13 @@ def test_migrate_config_sha_to_rev(tmpdir): ' rev: v1.2.0\n' ' hooks: []\n' ) + + +def test_migrate_config_invalid_yaml(tmpdir): + contents = '[' + cfg = tmpdir.join(C.CONFIG_FILE) + cfg.write(contents) + with tmpdir.as_cwd(), pytest.raises(InvalidConfigError) as excinfo: + migrate_config(C.CONFIG_FILE) + expected = '\n==> File .pre-commit-config.yaml\n=====> ' + assert str(excinfo.value).startswith(expected) -- cgit v1.2.3