Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 332e8b4

Browse files
committed
Merge pull request #117 from pre-commit/refactor_tests
Refactor tests
2 parents 92aa55f + 85a7661 commit 332e8b4

48 files changed

Lines changed: 483 additions & 429 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pre_commit/clientlib/validate_base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import print_function
2+
from __future__ import unicode_literals
23

34
import argparse
45
import jsonschema

pre_commit/clientlib/validate_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import unicode_literals
2+
13
import sys
24

35
from pre_commit.clientlib.validate_base import get_run_function

pre_commit/clientlib/validate_manifest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import unicode_literals
2+
13
import sys
24

35
from pre_commit.clientlib.validate_base import get_run_function

pre_commit/color.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import unicode_literals
2+
13
import sys
24

35
RED = '\033[41m'

pre_commit/commands/autoupdate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def _update_repository(repo_config, runner):
3030
repo = Repository.create(repo_config, runner.store)
3131

3232
with local.cwd(repo.repo_path_getter.repo_path):
33-
local['git']['fetch']()
34-
head_sha = local['git']['rev-parse', 'origin/master']().strip()
33+
local['git']('fetch')
34+
head_sha = local['git']('rev-parse', 'origin/master').strip()
3535

3636
# Don't bother trying to update if our sha is the same
3737
if head_sha == repo_config['sha']:

pre_commit/constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
from __future__ import unicode_literals
2+
3+
14
CONFIG_FILE = '.pre-commit-config.yaml'
25

36
MANIFEST_FILE = 'hooks.yaml'
47

58
YAML_DUMP_KWARGS = {
69
'default_flow_style': False,
10+
# Use unicode
11+
'encoding': None,
712
'indent': 4,
813
}

pre_commit/five.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import unicode_literals
2+
13
"""five: six, redux"""
24
# pylint:disable=invalid-name
35
PY2 = (str is bytes)

pre_commit/git.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import unicode_literals
2+
13
import functools
24
import logging
35
import os
@@ -49,21 +51,21 @@ def get_conflicted_files():
4951
# This will get the rest of the changes made after the merge.
5052
# If they resolved the merge conflict by choosing a mesh of both sides
5153
# this will also include the conflicted files
52-
tree_hash = local['git']['write-tree']().strip()
53-
merge_diff_filenames = local['git'][
54+
tree_hash = local['git']('write-tree').strip()
55+
merge_diff_filenames = local['git'](
5456
'diff', '-m', tree_hash, 'HEAD', 'MERGE_HEAD', '--name-only',
55-
]().splitlines()
57+
).splitlines()
5658
return set(merge_conflict_filenames) | set(merge_diff_filenames)
5759

5860

5961
@memoize_by_cwd
6062
def get_staged_files():
61-
return local['git']['diff', '--staged', '--name-only']().splitlines()
63+
return local['git']('diff', '--staged', '--name-only').splitlines()
6264

6365

6466
@memoize_by_cwd
6567
def get_all_files():
66-
return local['git']['ls-files']().splitlines()
68+
return local['git']('ls-files').splitlines()
6769

6870

6971
def get_files_matching(all_file_list_strategy):

pre_commit/jsonschema_extensions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import unicode_literals
2+
13
import copy
24
import jsonschema
35
import jsonschema.validators

pre_commit/languages/all.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import unicode_literals
2+
13
from pre_commit.languages import node
24
from pre_commit.languages import python
35
from pre_commit.languages import ruby

0 commit comments

Comments
 (0)