mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
yaml extensions and ordereddict are now imported from asottile.
This commit is contained in:
parent
c0a0a21680
commit
e58d28aad3
8 changed files with 18 additions and 99 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import pytest
|
||||
from asottile.ordereddict import OrderedDict
|
||||
from asottile.yaml import ordered_load
|
||||
|
||||
from pre_commit.clientlib.validate_base import get_validator
|
||||
from pre_commit.ordereddict import OrderedDict
|
||||
from pre_commit.yaml_extensions import ordered_load
|
||||
from testing.util import get_resource_path
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,11 @@ import pkg_resources
|
|||
import pytest
|
||||
import shutil
|
||||
import stat
|
||||
from asottile.ordereddict import OrderedDict
|
||||
from asottile.yaml import ordered_dump
|
||||
from plumbum import local
|
||||
|
||||
|
||||
import pre_commit.constants as C
|
||||
from pre_commit import git
|
||||
from pre_commit.clientlib.validate_config import CONFIG_JSON_SCHEMA
|
||||
|
|
@ -17,9 +20,7 @@ from pre_commit.commands import RepositoryCannotBeUpdatedError
|
|||
from pre_commit.commands import uninstall
|
||||
from pre_commit.commands import _update_repository
|
||||
from pre_commit.jsonschema_extensions import apply_defaults
|
||||
from pre_commit.ordereddict import OrderedDict
|
||||
from pre_commit.runner import Runner
|
||||
from pre_commit.yaml_extensions import ordered_dump
|
||||
from testing.auto_namedtuple import auto_namedtuple
|
||||
from testing.util import get_resource_path
|
||||
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
import pre_commit.constants as C
|
||||
from pre_commit.ordereddict import OrderedDict
|
||||
from pre_commit.yaml_extensions import ordered_dump
|
||||
from pre_commit.yaml_extensions import ordered_load
|
||||
|
||||
|
||||
def test_ordered_load():
|
||||
ret = ordered_load(
|
||||
'a: herp\n'
|
||||
'c: derp\n'
|
||||
'd: darp\n'
|
||||
'b: harp\n'
|
||||
)
|
||||
# Original behavior
|
||||
assert ret == {'a': 'herp', 'b': 'harp', 'c': 'derp', 'd': 'darp'}
|
||||
# Ordered behavior
|
||||
assert (
|
||||
ret.items() ==
|
||||
[('a', 'herp'), ('c', 'derp'), ('d', 'darp'), ('b', 'harp')]
|
||||
)
|
||||
|
||||
|
||||
def test_ordered_dump():
|
||||
ret = ordered_dump(
|
||||
OrderedDict(
|
||||
(('a', 'herp'), ('c', 'derp'), ('b', 'harp'), ('d', 'darp'))
|
||||
),
|
||||
**C.YAML_DUMP_KWARGS
|
||||
)
|
||||
assert ret == (
|
||||
'a: herp\n'
|
||||
'c: derp\n'
|
||||
'b: harp\n'
|
||||
'd: darp\n'
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue