mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 00:54:42 +04:00
Refactor fixtures in tests.
This commit is contained in:
parent
3baefd57e2
commit
85a76617c1
43 changed files with 249 additions and 278 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import collections
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import io
|
||||
import os.path
|
||||
from asottile.ordereddict import OrderedDict
|
||||
from asottile.yaml import ordered_dump
|
||||
from plumbum import local
|
||||
|
||||
import pre_commit.constants as C
|
||||
|
|
@ -25,7 +27,7 @@ def git_dir(tmpdir_factory):
|
|||
return path
|
||||
|
||||
|
||||
def make_hooks_repo(tmpdir_factory, repo_source):
|
||||
def make_repo(tmpdir_factory, repo_source):
|
||||
path = git_dir(tmpdir_factory)
|
||||
copy_tree_to_path(get_resource_path(repo_source), path)
|
||||
with local.cwd(path):
|
||||
|
|
@ -51,3 +53,17 @@ def make_config_from_repo(repo_path, sha=None, hooks=None, check=True):
|
|||
return wrapped_config[0]
|
||||
else:
|
||||
return config
|
||||
|
||||
|
||||
def write_config(directory, config):
|
||||
assert type(config) is OrderedDict
|
||||
with io.open(os.path.join(directory, C.CONFIG_FILE), 'w') as config_file:
|
||||
config_file.write(ordered_dump([config], **C.YAML_DUMP_KWARGS))
|
||||
|
||||
|
||||
def make_consuming_repo(tmpdir_factory, repo_source):
|
||||
path = make_repo(tmpdir_factory, repo_source)
|
||||
config = make_config_from_repo(path)
|
||||
git_path = git_dir(tmpdir_factory)
|
||||
write_config(git_path, config)
|
||||
return git_path
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import jsonschema
|
||||
import os
|
||||
import os.path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue