Beispiel #1
0
def test_pycodestyle():
    options = parse_options(linters=['pycodestyle'], config=False)
    assert len(options.linters) == 1
    errors = run('dummy.py', options=options)
    assert len(errors) == 2

    options.linters_params['pycodestyle'] = dict(max_line_length=60)
    errors = run('dummy.py', options=options)
    assert len(errors) == 11
Beispiel #2
0
def test_linters_params():
    options = parse_options(linters='mccabe', config=False)
    options.linters_params['mccabe'] = dict(complexity=1)
    errors = run('dummy.py', options=options)
    assert len(errors) == 1

    options.linters_params['mccabe'] = dict(complexity=20)
    errors = run('dummy.py', options=options)
    assert not errors
Beispiel #3
0
def test_ignore_select():
    options = parse_options()
    options.ignore = ['E301', 'D102']
    options.linters = ['pycodestyle', 'pydocstyle', 'pyflakes', 'mccabe']
    errors = run('dummy.py', options=options)
    assert len(errors) == 29

    options.ignore = ['E3', 'D']
    errors = run('dummy.py', options=options)
    assert len(errors) == 0

    options.select = ['E301']
    errors = run('dummy.py', options=options)
    assert len(errors) == 1
    assert errors[0]['col']
Beispiel #4
0
def test_pyflakes():
    options = parse_options(linters=['pyflakes'], config=False)
    assert options.linters
    errors = run('dummy.py',
                 code="\n".join(
                     ["import sys", "def test():", "    unused = 1"]),
                 options=options)
    assert len(errors) == 2
Beispiel #5
0
def test_pylint():
    from pylava.core import run
    from pylava.config import parse_options

    options = parse_options(linters=['pylint'], config=False)
    options.ignore = set(['R0912', 'C0111', 'I0011', 'F0401'])
    errors = run('dummy.py', options=options)
    assert len(errors) == 3
    assert errors[0].number == 'W0611'

    options.linters_params['pylint'] = dict(disable="W")
    errors = run('dummy.py', options=options)
    assert len(errors) == 1
    assert errors[0].number == 'E0602'

    options.linters_params['pylint']['max-line_length'] = 200
    errors = run('dummy.py', options=options)
    assert len(errors) == 1
Beispiel #6
0
def test_pydocstyle():
    options = parse_options(linters=['pydocstyle'])
    assert len(options.linters) == 1
    errors = run('dummy.py', options=options)
    assert errors
Beispiel #7
0
def test_sort():
    options = parse_options()
    options.sort = ['C', 'D']
    errors = run('dummy.py', options=options)
    assert errors[0].type == 'C'