mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 00:54:42 +04:00
py27+ syntax improvements
This commit is contained in:
parent
0a93f3bfdd
commit
ba75867c93
9 changed files with 31 additions and 34 deletions
|
|
@ -339,13 +339,13 @@ def test_compute_cols(hooks, verbose, expected):
|
|||
@pytest.mark.parametrize(
|
||||
('environ', 'expected_output'),
|
||||
(
|
||||
({}, set([])),
|
||||
({'SKIP': ''}, set([])),
|
||||
({'SKIP': ','}, set([])),
|
||||
({'SKIP': ',foo'}, set(['foo'])),
|
||||
({'SKIP': 'foo'}, set(['foo'])),
|
||||
({'SKIP': 'foo,bar'}, set(['foo', 'bar'])),
|
||||
({'SKIP': ' foo , bar'}, set(['foo', 'bar'])),
|
||||
({}, set()),
|
||||
({'SKIP': ''}, set()),
|
||||
({'SKIP': ','}, set()),
|
||||
({'SKIP': ',foo'}, {'foo'}),
|
||||
({'SKIP': 'foo'}, {'foo'}),
|
||||
({'SKIP': 'foo,bar'}, {'foo', 'bar'}),
|
||||
({'SKIP': ' foo , bar'}, {'foo', 'bar'}),
|
||||
),
|
||||
)
|
||||
def test_get_skips(environ, expected_output):
|
||||
|
|
|
|||
|
|
@ -80,25 +80,22 @@ def get_files_matching_func():
|
|||
|
||||
def test_get_files_matching_base(get_files_matching_func):
|
||||
ret = get_files_matching_func('', '^$')
|
||||
assert ret == set([
|
||||
assert ret == {
|
||||
'pre_commit/main.py',
|
||||
'pre_commit/git.py',
|
||||
'hooks.yaml',
|
||||
'testing/test_symlink'
|
||||
])
|
||||
}
|
||||
|
||||
|
||||
def test_get_files_matching_total_match(get_files_matching_func):
|
||||
ret = get_files_matching_func('^.*\\.py$', '^$')
|
||||
assert ret == set([
|
||||
'pre_commit/main.py',
|
||||
'pre_commit/git.py',
|
||||
])
|
||||
assert ret == {'pre_commit/main.py', 'pre_commit/git.py'}
|
||||
|
||||
|
||||
def test_does_search_instead_of_match(get_files_matching_func):
|
||||
ret = get_files_matching_func('\\.yaml$', '^$')
|
||||
assert ret == set(['hooks.yaml'])
|
||||
assert ret == {'hooks.yaml'}
|
||||
|
||||
|
||||
def test_does_not_include_deleted_fileS(get_files_matching_func):
|
||||
|
|
@ -108,7 +105,7 @@ def test_does_not_include_deleted_fileS(get_files_matching_func):
|
|||
|
||||
def test_exclude_removes_files(get_files_matching_func):
|
||||
ret = get_files_matching_func('', '\\.py$')
|
||||
assert ret == set(['hooks.yaml', 'testing/test_symlink'])
|
||||
assert ret == {'hooks.yaml', 'testing/test_symlink'}
|
||||
|
||||
|
||||
def resolve_conflict():
|
||||
|
|
@ -124,12 +121,12 @@ def test_get_conflicted_files(in_merge_conflict):
|
|||
cmd_output('git', 'add', 'other_file')
|
||||
|
||||
ret = set(git.get_conflicted_files())
|
||||
assert ret == set(('conflict_file', 'other_file'))
|
||||
assert ret == {'conflict_file', 'other_file'}
|
||||
|
||||
|
||||
def test_get_conflicted_files_in_submodule(in_conflicting_submodule):
|
||||
resolve_conflict()
|
||||
assert set(git.get_conflicted_files()) == set(('conflict_file',))
|
||||
assert set(git.get_conflicted_files()) == {'conflict_file'}
|
||||
|
||||
|
||||
def test_get_conflicted_files_unstaged_files(in_merge_conflict):
|
||||
|
|
@ -142,7 +139,7 @@ def test_get_conflicted_files_unstaged_files(in_merge_conflict):
|
|||
bar_only_file.write('new contents!\n')
|
||||
|
||||
ret = set(git.get_conflicted_files())
|
||||
assert ret == set(('conflict_file',))
|
||||
assert ret == {'conflict_file'}
|
||||
|
||||
|
||||
MERGE_MSG = "Merge branch 'foo' into bar\n\nConflicts:\n\tconflict_file\n"
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ def test_languages(tempdir_factory, store):
|
|||
path = make_repo(tempdir_factory, 'python_hooks_repo')
|
||||
config = make_config_from_repo(path)
|
||||
repo = Repository.create(config, store)
|
||||
assert repo.languages == set([('python', 'default')])
|
||||
assert repo.languages == {('python', 'default')}
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
|
|
@ -435,7 +435,7 @@ def test_additional_dependencies(tempdir_factory, store):
|
|||
config = make_config_from_repo(path)
|
||||
config['hooks'][0]['additional_dependencies'] = ['pep8']
|
||||
repo = Repository.create(config, store)
|
||||
assert repo.additional_dependencies['python']['default'] == set(('pep8',))
|
||||
assert repo.additional_dependencies['python']['default'] == {'pep8'}
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue