mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-03-29 18:16:52 +00:00
Merge pull request #39 from pre-commit/autopep8_via_config
Respect autopep8 config. Resolves #38.
This commit is contained in:
commit
fc8b97e4ab
3 changed files with 25 additions and 4 deletions
|
|
@ -10,7 +10,7 @@ import autopep8
|
|||
|
||||
def main(argv=None):
|
||||
argv = argv if argv is not None else sys.argv[1:]
|
||||
args = autopep8.parse_args(argv)
|
||||
args = autopep8.parse_args(argv, apply_config=True)
|
||||
|
||||
retv = 0
|
||||
for filename in args.files:
|
||||
|
|
|
|||
2
setup.py
2
setup.py
|
|
@ -27,7 +27,7 @@ setup(
|
|||
packages=find_packages('.', exclude=('tests*', 'testing*')),
|
||||
install_requires=[
|
||||
'argparse',
|
||||
'autopep8',
|
||||
'autopep8>=1.1',
|
||||
'flake8',
|
||||
'plumbum',
|
||||
'pyflakes',
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from __future__ import absolute_import
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import io
|
||||
import os.path
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
@ -17,9 +17,30 @@ from pre_commit_hooks.autopep8_wrapper import main
|
|||
),
|
||||
)
|
||||
def test_main_failing(tmpdir, input_src, expected_ret, output_src):
|
||||
filename = os.path.join(tmpdir.strpath, 'test.py')
|
||||
filename = tmpdir.join('test.py').strpath
|
||||
with io.open(filename, 'w') as file_obj:
|
||||
file_obj.write(input_src)
|
||||
ret = main([filename, '-i', '-v'])
|
||||
assert ret == expected_ret
|
||||
assert io.open(filename).read() == output_src
|
||||
|
||||
|
||||
@pytest.yield_fixture
|
||||
def in_tmpdir(tmpdir):
|
||||
pwd = os.getcwd()
|
||||
os.chdir(tmpdir.strpath)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
os.chdir(pwd)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('in_tmpdir')
|
||||
def test_respects_config_file():
|
||||
with io.open('setup.cfg', 'w') as setup_cfg:
|
||||
setup_cfg.write('[pep8]\nignore=E221')
|
||||
|
||||
with io.open('test.py', 'w') as test_py:
|
||||
test_py.write('print(1 + 2)\n')
|
||||
|
||||
assert main(['test.py', '-i', '-v']) == 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue