Ejemplo n.º 1
0
def test_replaces_autopep8_wrapper(file_config, fake_autoupdatable):
    before = '''\
repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v1.4.0-1
    hooks:
    -   id: trailing-whitespace
    -   id: autopep8-wrapper
        args: [-i]
        files: ^lintme/
    -   id: end-of-file-fixer
-   repo: https://github.com/asottile/reorder_python_imports
    rev: v1.1.0
    hooks:
    -   id: reorder-python-imports
'''
    fake_autoupdatable.init(before)

    ret = main((
        '--config-filename',
        str(file_config.cfg),
        '--repos',
        str(fake_autoupdatable.update_repo),
    ))
    assert not ret

    contents = fake_autoupdatable.repo.join('.pre-commit-config.yaml').read()
    assert contents == '''\
def test_apply_fix_noop(file_config, fake_autoupdatable):
    fake_autoupdatable.init('repos: []')
    ret = main((
        '--config-filename', str(file_config.cfg),
        '--repos', str(fake_autoupdatable.update_repo),
    ))
    assert not ret

    contents = fake_autoupdatable.repo.join('.pre-commit-config.yaml').read()
    assert contents == 'repos: []'
def test_replaces_autopep8_wrapper_one_repo(file_config, fake_autoupdatable):
    before = '''\
repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v1.4.0-1
    hooks:
    -   id: trailing-whitespace
    -   id: autopep8-wrapper
'''
    fake_autoupdatable.init(before)

    ret = main((
        '--config-filename', str(file_config.cfg),
        '--repos', str(fake_autoupdatable.update_repo),
    ))
    assert not ret

    contents = fake_autoupdatable.repo.join('.pre-commit-config.yaml').read()
    assert contents == '''\