mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
fix migrate-config for purelib yaml
This commit is contained in:
parent
3d5548b487
commit
222c62bc5d
2 changed files with 18 additions and 1 deletions
|
|
@ -47,7 +47,8 @@ def _migrate_map(contents: str) -> str:
|
||||||
|
|
||||||
|
|
||||||
def _preserve_style(n: ScalarNode, *, s: str) -> str:
|
def _preserve_style(n: ScalarNode, *, s: str) -> str:
|
||||||
return f'{n.style}{s}{n.style}'
|
style = n.style or ''
|
||||||
|
return f'{style}{s}{style}'
|
||||||
|
|
||||||
|
|
||||||
def _fix_stage(n: ScalarNode) -> str:
|
def _fix_stage(n: ScalarNode) -> str:
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,26 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from unittest import mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import yaml
|
||||||
|
|
||||||
import pre_commit.constants as C
|
import pre_commit.constants as C
|
||||||
from pre_commit.clientlib import InvalidConfigError
|
from pre_commit.clientlib import InvalidConfigError
|
||||||
from pre_commit.commands.migrate_config import migrate_config
|
from pre_commit.commands.migrate_config import migrate_config
|
||||||
|
from pre_commit.yaml import yaml_compose
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True, params=['c', 'pure'])
|
||||||
|
def switch_pyyaml_impl(request):
|
||||||
|
if request.param == 'c':
|
||||||
|
yield
|
||||||
|
else:
|
||||||
|
with mock.patch.dict(
|
||||||
|
yaml_compose.keywords,
|
||||||
|
{'Loader': yaml.SafeLoader},
|
||||||
|
):
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
def test_migrate_config_normal_format(tmpdir, capsys):
|
def test_migrate_config_normal_format(tmpdir, capsys):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue