mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Use asottile/add-trailing-comma
This commit is contained in:
parent
1a07a24d13
commit
0c70fa4229
32 changed files with 74 additions and 70 deletions
|
|
@ -208,7 +208,7 @@ def test_validate_manifest_main(args, expected_output):
|
|||
}],
|
||||
True,
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
def test_valid_manifests(manifest_obj, expected):
|
||||
ret = is_valid_according_to_schema(manifest_obj, MANIFEST_SCHEMA)
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ def test_out_of_date_repo(out_of_date_repo, runner_with_mocked_store):
|
|||
|
||||
|
||||
def test_autoupdate_out_of_date_repo(
|
||||
out_of_date_repo, in_tmpdir, mock_out_store_directory
|
||||
out_of_date_repo, in_tmpdir, mock_out_store_directory,
|
||||
):
|
||||
# Write out the config
|
||||
config = make_config_from_repo(
|
||||
|
|
@ -181,7 +181,7 @@ def hook_disappearing_repo(tempdir_factory):
|
|||
|
||||
|
||||
def test_hook_disppearing_repo_raises(
|
||||
hook_disappearing_repo, runner_with_mocked_store
|
||||
hook_disappearing_repo, runner_with_mocked_store,
|
||||
):
|
||||
config = make_config_from_repo(
|
||||
hook_disappearing_repo.path,
|
||||
|
|
@ -193,7 +193,7 @@ def test_hook_disppearing_repo_raises(
|
|||
|
||||
|
||||
def test_autoupdate_hook_disappearing_repo(
|
||||
hook_disappearing_repo, in_tmpdir, mock_out_store_directory
|
||||
hook_disappearing_repo, in_tmpdir, mock_out_store_directory,
|
||||
):
|
||||
config = make_config_from_repo(
|
||||
hook_disappearing_repo.path,
|
||||
|
|
@ -222,7 +222,7 @@ def test_autoupdate_local_hooks(tempdir_factory):
|
|||
|
||||
|
||||
def test_autoupdate_local_hooks_with_out_of_date_repo(
|
||||
out_of_date_repo, in_tmpdir, mock_out_store_directory
|
||||
out_of_date_repo, in_tmpdir, mock_out_store_directory,
|
||||
):
|
||||
stale_config = make_config_from_repo(
|
||||
out_of_date_repo.path, sha=out_of_date_repo.original_sha, check=False,
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ NORMAL_PRE_COMMIT_RUN = re.compile(
|
|||
r'Bash hook\.+Passed\r?\n'
|
||||
r'\[master [a-f0-9]{7}\] Commit!\r?\n' +
|
||||
FILES_CHANGED +
|
||||
r' create mode 100644 foo\r?\n$'
|
||||
r' create mode 100644 foo\r?\n$',
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -259,7 +259,7 @@ FAILING_PRE_COMMIT_RUN = re.compile(
|
|||
r'\r?\n'
|
||||
r'Fail\r?\n'
|
||||
r'foo\r?\n'
|
||||
r'\r?\n$'
|
||||
r'\r?\n$',
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -277,7 +277,7 @@ EXISTING_COMMIT_RUN = re.compile(
|
|||
r'^legacy hook\r?\n'
|
||||
r'\[master [a-f0-9]{7}\] Commit!\r?\n' +
|
||||
FILES_CHANGED +
|
||||
r' create mode 100644 baz\r?\n$'
|
||||
r' create mode 100644 baz\r?\n$',
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -332,7 +332,7 @@ def test_install_existing_hook_no_overwrite_idempotent(tempdir_factory):
|
|||
FAIL_OLD_HOOK = re.compile(
|
||||
r'fail!\r?\n'
|
||||
r'\[INFO\] Initializing environment for .+\.\r?\n'
|
||||
r'Bash hook\.+Passed\r?\n'
|
||||
r'Bash hook\.+Passed\r?\n',
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -448,7 +448,7 @@ PRE_INSTALLED = re.compile(
|
|||
r'Bash hook\.+Passed\r?\n'
|
||||
r'\[master [a-f0-9]{7}\] Commit!\r?\n' +
|
||||
FILES_CHANGED +
|
||||
r' create mode 100644 foo\r?\n$'
|
||||
r' create mode 100644 foo\r?\n$',
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ def test_show_diff_on_failure(
|
|||
True,
|
||||
),
|
||||
({}, (b'Bash hook', b'(no files to check)', b'Skipped'), 0, False),
|
||||
)
|
||||
),
|
||||
)
|
||||
def test_run(
|
||||
cap_out,
|
||||
|
|
@ -259,7 +259,7 @@ def test_run_output_logfile(
|
|||
git_path, {},
|
||||
expected_output,
|
||||
expected_ret=1,
|
||||
stage=True
|
||||
stage=True,
|
||||
)
|
||||
logfile_path = os.path.join(git_path, 'test.log')
|
||||
assert os.path.exists(logfile_path)
|
||||
|
|
@ -301,7 +301,7 @@ def test_always_run_alt_config(
|
|||
(b'Bash hook', b'Passed'),
|
||||
0,
|
||||
stage=False,
|
||||
config_file=alt_config_file
|
||||
config_file=alt_config_file,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -311,7 +311,7 @@ def test_always_run_alt_config(
|
|||
('master', 'master', False),
|
||||
('master', '', True),
|
||||
('', 'master', True),
|
||||
)
|
||||
),
|
||||
)
|
||||
def test_origin_source_error_msg(
|
||||
repo_with_passing_hook, origin, source, expect_failure,
|
||||
|
|
@ -588,7 +588,7 @@ def test_lots_of_files(mock_out_store_directory, tempdir_factory):
|
|||
('commit', [], ['commit'], [b'hook 1', b'hook 2']),
|
||||
('commit', ['push'], ['commit'], [b'', b'hook 2']),
|
||||
('commit', ['commit'], ['push'], [b'hook 1', b'']),
|
||||
)
|
||||
),
|
||||
)
|
||||
def test_local_hook_for_stages(
|
||||
cap_out,
|
||||
|
|
@ -606,15 +606,15 @@ def test_local_hook_for_stages(
|
|||
('entry', 'python -m flake8.__main__'),
|
||||
('language', 'system'),
|
||||
('files', r'\.py$'),
|
||||
('stages', stage_for_first_hook)
|
||||
('stages', stage_for_first_hook),
|
||||
)), OrderedDict((
|
||||
('id', 'do_not_commit'),
|
||||
('name', 'hook 2'),
|
||||
('entry', 'DO NOT COMMIT'),
|
||||
('language', 'pcre'),
|
||||
('files', '^(.*)$'),
|
||||
('stages', stage_for_second_hook)
|
||||
))))
|
||||
('stages', stage_for_second_hook),
|
||||
)))),
|
||||
))
|
||||
add_config_to_repo(repo_with_passing_hook, config)
|
||||
|
||||
|
|
@ -628,7 +628,7 @@ def test_local_hook_for_stages(
|
|||
{'hook_stage': hook_stage},
|
||||
expected_outputs=expected_output,
|
||||
expected_ret=0,
|
||||
stage=False
|
||||
stage=False,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -649,7 +649,7 @@ def test_local_hook_passes(
|
|||
('entry', 'DO NOT COMMIT'),
|
||||
('language', 'pcre'),
|
||||
('files', '^(.*)$'),
|
||||
))))
|
||||
)))),
|
||||
))
|
||||
add_config_to_repo(repo_with_passing_hook, config)
|
||||
|
||||
|
|
@ -678,7 +678,7 @@ def test_local_hook_fails(
|
|||
('entry', 'sh -c "! grep -iI todo $@" --'),
|
||||
('language', 'system'),
|
||||
('files', ''),
|
||||
))])
|
||||
))]),
|
||||
))
|
||||
add_config_to_repo(repo_with_passing_hook, config)
|
||||
|
||||
|
|
@ -770,7 +770,7 @@ def test_files_running_subdir(
|
|||
(False, [], b''),
|
||||
(True, ['some', 'args'], b'some args foo.py'),
|
||||
(False, ['some', 'args'], b'some args'),
|
||||
)
|
||||
),
|
||||
)
|
||||
def test_pass_filenames(
|
||||
cap_out, repo_with_passing_hook, mock_out_store_directory,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@ from pre_commit.util import CalledProcessError
|
|||
def test_docker_is_running_process_error():
|
||||
with mock.patch(
|
||||
'pre_commit.languages.docker.cmd_output',
|
||||
side_effect=CalledProcessError(*(None,) * 4)
|
||||
side_effect=CalledProcessError(*(None,) * 4),
|
||||
):
|
||||
assert docker.docker_is_running() is False
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ def test_CalledProcessError_str():
|
|||
|
||||
def test_CalledProcessError_str_nooutput():
|
||||
error = CalledProcessError(
|
||||
1, [str('git'), str('status')], 0, (str(''), str(''))
|
||||
1, [str('git'), str('status')], 0, (str(''), str('')),
|
||||
)
|
||||
assert str(error) == (
|
||||
"Command: ['git', 'status']\n"
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ def test_python_hook(tempdir_factory, store):
|
|||
_test_hook_repo(
|
||||
tempdir_factory, store, 'python_hooks_repo',
|
||||
'foo', [os.devnull],
|
||||
b"['" + five.to_bytes(os.devnull) + b"']\nHello World\n"
|
||||
b"['" + five.to_bytes(os.devnull) + b"']\nHello World\n",
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ def test_python_hook_args_with_spaces(tempdir_factory, store):
|
|||
'hooks': [{
|
||||
'id': 'foo',
|
||||
'args': ['i have spaces', 'and"\'quotes', '$and !this'],
|
||||
}]
|
||||
}],
|
||||
},
|
||||
)
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ def test_python_hook_weird_setup_cfg(tempdir_factory, store):
|
|||
_test_hook_repo(
|
||||
tempdir_factory, store, 'python_hooks_repo',
|
||||
'foo', [os.devnull],
|
||||
b"['" + five.to_bytes(os.devnull) + b"']\nHello World\n"
|
||||
b"['" + five.to_bytes(os.devnull) + b"']\nHello World\n",
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ def test_run_a_failing_docker_hook(tempdir_factory, store):
|
|||
tempdir_factory, store, 'docker_hooks_repo',
|
||||
'docker-hook-failing',
|
||||
['Hello World from docker'], b'',
|
||||
expected_return_code=1
|
||||
expected_return_code=1,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ def test_run_ruby_hook_with_disable_shared_gems(
|
|||
tmpdir.join('.bundle').mkdir()
|
||||
tmpdir.join('.bundle', 'config').write(
|
||||
'BUNDLE_DISABLE_SHARED_GEMS: true\n'
|
||||
'BUNDLE_PATH: vendor/gem\n'
|
||||
'BUNDLE_PATH: vendor/gem\n',
|
||||
)
|
||||
with cwd(tmpdir.strpath):
|
||||
_test_hook_repo(
|
||||
|
|
@ -322,7 +322,7 @@ def test_run_hook_with_curly_braced_arguments(tempdir_factory, store):
|
|||
'hooks': [{
|
||||
'id': 'arg-per-line',
|
||||
'args': ['hi {1}', "I'm {a} problem"],
|
||||
}]
|
||||
}],
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ def test_local_hooks(tempdir_factory, mock_out_store_directory):
|
|||
('entry', 'DO NOT COMMIT'),
|
||||
('language', 'pcre'),
|
||||
('files', '^(.*)$'),
|
||||
))))
|
||||
)))),
|
||||
))
|
||||
git_path = git_dir(tempdir_factory)
|
||||
add_config_to_repo(git_path, config)
|
||||
|
|
@ -101,7 +101,7 @@ def test_local_hooks_alt_config(tempdir_factory, mock_out_store_directory):
|
|||
('entry', 'DO NOT COMMIT'),
|
||||
('language', 'pcre'),
|
||||
('files', '^(.*)$'),
|
||||
))))
|
||||
)))),
|
||||
))
|
||||
git_path = git_dir(tempdir_factory)
|
||||
alt_config_file = 'alternate_config.yaml'
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ def test_load_from_filename_fails_load_strategy(tmpdir):
|
|||
_assert_exception_trace(
|
||||
excinfo.value.args[0],
|
||||
# ANY is json's error message
|
||||
('File {}'.format(f.strpath), mock.ANY)
|
||||
('File {}'.format(f.strpath), mock.ANY),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ def test_get_default_directory_defaults_to_home():
|
|||
|
||||
def test_uses_environment_variable_when_present():
|
||||
with mock.patch.dict(
|
||||
os.environ, {'PRE_COMMIT_HOME': '/tmp/pre_commit_home'}
|
||||
os.environ, {'PRE_COMMIT_HOME': '/tmp/pre_commit_home'},
|
||||
):
|
||||
ret = _get_default_directory()
|
||||
assert ret == '/tmp/pre_commit_home'
|
||||
|
|
@ -89,7 +89,7 @@ def test_clone(store, tempdir_factory, log_info_mock):
|
|||
ret = store.clone(path, sha)
|
||||
# Should have printed some stuff
|
||||
assert log_info_mock.call_args_list[0][0][0].startswith(
|
||||
'Initializing environment for '
|
||||
'Initializing environment for ',
|
||||
)
|
||||
|
||||
# Should return a directory inside of the store
|
||||
|
|
@ -138,7 +138,7 @@ def test_clone_when_repo_already_exists(store):
|
|||
with sqlite3.connect(store.db_path) as db:
|
||||
db.execute(
|
||||
'INSERT INTO repos (repo, ref, path) '
|
||||
'VALUES ("fake_repo", "fake_ref", "fake_path")'
|
||||
'VALUES ("fake_repo", "fake_ref", "fake_path")',
|
||||
)
|
||||
|
||||
assert store.clone('fake_repo', 'fake_ref') == 'fake_path'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue