File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,8 @@ def _migrate_map(contents: str) -> str:
4747
4848
4949def _preserve_style (n : ScalarNode , * , s : str ) -> str :
50- return f'{ n .style } { s } { n .style } '
50+ style = n .style or ''
51+ return f'{ style } { s } { style } '
5152
5253
5354def _fix_stage (n : ScalarNode ) -> str :
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ from unittest import mock
4+
35import pytest
6+ import yaml
47
58import pre_commit .constants as C
69from pre_commit .clientlib import InvalidConfigError
710from pre_commit .commands .migrate_config import migrate_config
11+ from pre_commit .yaml import yaml_compose
12+
13+
14+ @pytest .fixture (autouse = True , params = ['c' , 'pure' ])
15+ def switch_pyyaml_impl (request ):
16+ if request .param == 'c' :
17+ yield
18+ else :
19+ with mock .patch .dict (
20+ yaml_compose .keywords ,
21+ {'Loader' : yaml .SafeLoader },
22+ ):
23+ yield
824
925
1026def test_migrate_config_normal_format (tmpdir , capsys ):
You can’t perform that action at this time.
0 commit comments