mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 11:36:54 +00:00
Use asottile/add-trailing-comma
This commit is contained in:
parent
286962eeb7
commit
2a902e0a07
19 changed files with 48 additions and 43 deletions
|
|
@ -19,7 +19,7 @@ TESTS = (
|
|||
'"foo"\n',
|
||||
1,
|
||||
'{filename}:2 Module docstring appears after code '
|
||||
'(code seen on line 1).\n'
|
||||
'(code seen on line 1).\n',
|
||||
),
|
||||
# Test double docstring
|
||||
(
|
||||
|
|
@ -28,7 +28,7 @@ TESTS = (
|
|||
'"fake docstring"\n',
|
||||
1,
|
||||
'{filename}:3 Multiple module docstrings '
|
||||
'(first docstring on line 1).\n'
|
||||
'(first docstring on line 1).\n',
|
||||
),
|
||||
# Test multiple lines of code above
|
||||
(
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ def f1_is_a_conflict_file(tmpdir):
|
|||
'child\n'
|
||||
'=======\n'
|
||||
'parent\n'
|
||||
'>>>>>>>'
|
||||
'>>>>>>>',
|
||||
) or f1.startswith(
|
||||
'<<<<<<< HEAD\n'
|
||||
'child\n'
|
||||
|
|
@ -53,7 +53,7 @@ def f1_is_a_conflict_file(tmpdir):
|
|||
'||||||| merged common ancestors\n'
|
||||
'=======\n'
|
||||
'parent\n'
|
||||
'>>>>>>>'
|
||||
'>>>>>>>',
|
||||
) or f1.startswith(
|
||||
# .gitconfig with [pull] rebase = preserve causes a rebase which
|
||||
# flips parent / child
|
||||
|
|
@ -61,7 +61,7 @@ def f1_is_a_conflict_file(tmpdir):
|
|||
'parent\n'
|
||||
'=======\n'
|
||||
'child\n'
|
||||
'>>>>>>>'
|
||||
'>>>>>>>',
|
||||
)
|
||||
assert os.path.exists(os.path.join('.git', 'MERGE_MSG'))
|
||||
yield
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ def test_returns_one_form_1(ast_with_debug_import_form_1):
|
|||
visitor = ImportStatementParser()
|
||||
visitor.visit(ast_with_debug_import_form_1)
|
||||
assert visitor.debug_import_statements == [
|
||||
DebugStatement('ipdb', 3, 0)
|
||||
DebugStatement('ipdb', 3, 0),
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ def test_returns_one_form_2(ast_with_debug_import_form_2):
|
|||
visitor = ImportStatementParser()
|
||||
visitor.visit(ast_with_debug_import_form_2)
|
||||
assert visitor.debug_import_statements == [
|
||||
DebugStatement('pudb', 3, 0)
|
||||
DebugStatement('pudb', 3, 0),
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,14 +21,14 @@ from testing.util import get_resource_path
|
|||
(
|
||||
{
|
||||
'AWS_DUMMY_KEY': '/foo', 'AWS_CONFIG_FILE': '/bar',
|
||||
'AWS_CREDENTIAL_FILE': '/baz'
|
||||
'AWS_CREDENTIAL_FILE': '/baz',
|
||||
},
|
||||
{'/bar', '/baz'}
|
||||
),
|
||||
(
|
||||
{
|
||||
'AWS_CONFIG_FILE': '/foo', 'AWS_CREDENTIAL_FILE': '/bar',
|
||||
'AWS_SHARED_CREDENTIALS_FILE': '/baz'
|
||||
'AWS_SHARED_CREDENTIALS_FILE': '/baz',
|
||||
},
|
||||
{'/foo', '/bar', '/baz'}
|
||||
),
|
||||
|
|
@ -51,7 +51,7 @@ def test_get_aws_credentials_file_from_env(env_vars, values):
|
|||
({'AWS_DUMMY_KEY': 'foo', 'AWS_SECRET_ACCESS_KEY': 'bar'}, {'bar'}),
|
||||
(
|
||||
{'AWS_SECRET_ACCESS_KEY': 'foo', 'AWS_SECURITY_TOKEN': 'bar'},
|
||||
{'foo', 'bar'}
|
||||
{'foo', 'bar'},
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
@ -66,7 +66,7 @@ def test_get_aws_secrets_from_env(env_vars, values):
|
|||
(
|
||||
(
|
||||
'aws_config_with_secret.ini',
|
||||
{'z2rpgs5uit782eapz5l1z0y2lurtsyyk6hcfozlb'}
|
||||
{'z2rpgs5uit782eapz5l1z0y2lurtsyyk6hcfozlb'},
|
||||
),
|
||||
('aws_config_with_session_token.ini', {'foo'}),
|
||||
('aws_config_with_secret_and_session_token.ini',
|
||||
|
|
@ -77,8 +77,8 @@ def test_get_aws_secrets_from_env(env_vars, values):
|
|||
'7xebzorgm5143ouge9gvepxb2z70bsb2rtrh099e',
|
||||
'z2rpgs5uit782eapz5l1z0y2lurtsyyk6hcfozlb',
|
||||
'ixswosj8gz3wuik405jl9k3vdajsnxfhnpui38ez',
|
||||
'foo'
|
||||
}
|
||||
'foo',
|
||||
},
|
||||
),
|
||||
('aws_config_without_secrets.ini', set()),
|
||||
('nonsense.txt', set()),
|
||||
|
|
@ -121,7 +121,7 @@ def test_non_existent_credentials(mock_secrets_env, mock_secrets_file, capsys):
|
|||
mock_secrets_file.return_value = set()
|
||||
ret = main((
|
||||
get_resource_path('aws_config_without_secrets.ini'),
|
||||
"--credentials-file=testing/resources/credentailsfilethatdoesntexist"
|
||||
"--credentials-file=testing/resources/credentailsfilethatdoesntexist",
|
||||
))
|
||||
assert ret == 2
|
||||
out, _ = capsys.readouterr()
|
||||
|
|
@ -141,6 +141,6 @@ def test_non_existent_credentials_with_allow_flag(mock_secrets_env, mock_secrets
|
|||
ret = main((
|
||||
get_resource_path('aws_config_without_secrets.ini'),
|
||||
"--credentials-file=testing/resources/credentailsfilethatdoesntexist",
|
||||
"--allow-missing-credentials"
|
||||
"--allow-missing-credentials",
|
||||
))
|
||||
assert ret == 0
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ from pre_commit_hooks.file_contents_sorter import PASS
|
|||
(b'@\n-\n_\n#\n', FAIL, b'#\n-\n@\n_\n'),
|
||||
(b'extra\n\n\nwhitespace\n', FAIL, b'extra\nwhitespace\n'),
|
||||
(b'whitespace\n\n\nextra\n', FAIL, b'extra\nwhitespace\n'),
|
||||
)
|
||||
),
|
||||
)
|
||||
def test_integration(input_s, expected_retval, output, tmpdir):
|
||||
path = tmpdir.join('file.txt')
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ def test_integration_remove_ok(tmpdir):
|
|||
b'# -*- coding: utf-8 -*-\n'
|
||||
b'foo = "bar"\n'
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
def test_ok_inputs(input_str):
|
||||
bytesio = io.BytesIO(input_str)
|
||||
|
|
@ -100,7 +100,7 @@ def test_ok_inputs(input_str):
|
|||
(b'#!/usr/bin/env python\n', b''),
|
||||
(b'#!/usr/bin/env python\n#coding: utf8\n', b''),
|
||||
(b'#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n', b''),
|
||||
)
|
||||
),
|
||||
)
|
||||
def test_not_ok_inputs(input_str, output):
|
||||
bytesio = io.BytesIO(input_str)
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ from pre_commit_hooks.requirements_txt_fixer import Requirement
|
|||
(
|
||||
b'-e git+ssh://git_url@tag#egg=ocflib\nDjango\nPyMySQL\n',
|
||||
FAIL,
|
||||
b'Django\n-e git+ssh://git_url@tag#egg=ocflib\nPyMySQL\n'
|
||||
b'Django\n-e git+ssh://git_url@tag#egg=ocflib\nPyMySQL\n',
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
def test_integration(input_s, expected_retval, output, tmpdir):
|
||||
path = tmpdir.join('file.txt')
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ def test_markdown_linebreak_ext_opt(filename, input_s, output, tmpdir):
|
|||
path = tmpdir.join(filename)
|
||||
path.write(input_s)
|
||||
ret = fix_trailing_whitespace((
|
||||
'--markdown-linebreak-ext=TxT', path.strpath
|
||||
'--markdown-linebreak-ext=TxT', path.strpath,
|
||||
))
|
||||
assert ret == 1
|
||||
assert path.read() == output
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue