mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-06 20:16:53 +00:00
Simplify the tests
This commit is contained in:
parent
b64436cdda
commit
a99475afa0
14 changed files with 144 additions and 201 deletions
|
|
@ -1,8 +1,6 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import io
|
||||
|
||||
import pytest
|
||||
|
||||
from pre_commit_hooks.autopep8_wrapper import main
|
||||
|
|
@ -16,20 +14,15 @@ from pre_commit_hooks.autopep8_wrapper import main
|
|||
),
|
||||
)
|
||||
def test_main_failing(tmpdir, input_src, expected_ret, output_src):
|
||||
filename = tmpdir.join('test.py').strpath
|
||||
with io.open(filename, 'w') as file_obj:
|
||||
file_obj.write(input_src)
|
||||
ret = main([filename, '-i', '-v'])
|
||||
path = tmpdir.join('test.py')
|
||||
path.write(input_src)
|
||||
ret = main([path.strpath, '-i', '-v'])
|
||||
assert ret == expected_ret
|
||||
assert io.open(filename).read() == output_src
|
||||
assert path.read() == output_src
|
||||
|
||||
|
||||
@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
|
||||
def test_respects_config_file(tmpdir):
|
||||
with tmpdir.as_cwd():
|
||||
tmpdir.join('setup.cfg').write('[pep8]\nignore=E221')
|
||||
tmpdir.join('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