コード例 #1
0
def test_disabled():
    cfg = get_default_config()
    cfg['disabled'] = ['foo']
    collector = Collector(cfg)

    collector.add_issues([
        TidyPyIssue('code1', 'message 1', 'test1.py', 2),
        TidyPyIssue('foo', 'message 2', 'test2.py', 3),
    ])

    assert collector.issue_count() == 1
    assert collector.issue_count(include_unclean=True) == 2
    assert collector.get_issues()[0].code == 'code1'
コード例 #2
0
def test_noqa_disabled(tmpdir):
    project_dir = tmpdir.mkdir('noqa')
    py_file = project_dir.join('file.py')
    py_file.write(
        '\nsomething  # noqa: test1\n\n# NoQA\n\n\n\n# NOqa: tidypy:test6,foobar,@bar'
    )
    yaml_file = project_dir.join('file.yaml')

    cfg = get_default_config()
    cfg['merge-issues'] = False
    cfg['noqa'] = False

    collector = Collector(cfg)
    good_issues = [
        TidyPyIssue('test', 'test message', str(py_file), 2),
        TidyPyIssue('test4', 'test message', str(py_file), 6),
        TidyPyIssue('test5', 'test message', str(yaml_file), 2),
        TidyPyIssue('test7', 'test message', str(py_file), 8),
        BarIssue('test8', 'test message', str(py_file), 7),
    ]
    filtered_issues = [
        TidyPyIssue('test1', 'test message', str(py_file), 2),
        TidyPyIssue('test2', 'test message', str(py_file), 4),
        TidyPyIssue('test3', 'test message', str(py_file), 4),
        TidyPyIssue('test6', 'test message', str(py_file), 8),
        BarIssue('test9', 'test message', str(py_file), 8),
    ]
    collector.add_issues(good_issues)
    collector.add_issues(filtered_issues)

    assert good_issues + filtered_issues == collector.get_issues(
        sortby=collector.NO_SORT)
    assert collector.issue_count() == len(good_issues + filtered_issues)
    assert collector.issue_count(include_unclean=True) == len(good_issues +
                                                              filtered_issues)
コード例 #3
0
def test_merging_dupes():
    collector = Collector(get_default_config())
    issues = [
        TidyPyIssue('test', 'test message', 'test/file.ext', 2),
        TidyPyIssue('test', 'test message', 'test/file.ext', 2),
        TidyPyIssue('test2', 'test message', 'test/file.ext', 2),
        TidyPyIssue('test', 'test message', 'test/file.ext', 3),
        TidyPyIssue('test2', 'test message', 'test/file2.ext', 2),
    ]
    collector.add_issues(issues)

    assert collector.get_issues() == [issues[0]] + issues[2:]
    assert collector.issue_count() == 4
    assert collector.issue_count(include_unclean=True) == 5
コード例 #4
0
def test_disabled():
    cfg = get_default_config()
    cfg['disabled'] = ['test']
    collector = Collector(cfg)
    issues = [
        TidyPyIssue('test', 'test message', 'test/file.ext', 2),
        TidyPyIssue('test2', 'test message', 'test/file.ext', 2),
        TidyPyIssue('test3', 'test message', 'test/file.ext', 2),
    ]
    collector.add_issues(issues)

    assert collector.get_issues() == issues[1:]
    assert collector.issue_count() == 2
    assert collector.issue_count(include_unclean=True) == 3
コード例 #5
0
from tidypy import execute_reports, get_default_config, Collector, TidyPyIssue

ISSUES = [
    TidyPyIssue(
        'code1',
        'Message 1',
        'someproject/foo.py',
        5,
        23,
    ),
    TidyPyIssue(
        'code2',
        'Message 2',
        'someproject/foo.py',
        2,
    ),
    TidyPyIssue(
        'code1',
        'Message 1',
        'someproject/blah/bar.py',
        28,
    ),
    TidyPyIssue(
        'code3',
        'Message 3',
        'someproject/subdir/foobar.json',
        5,
        23,
    ),
]
コード例 #6
0
import sys

from six import PY2
from tidypy import execute_reports, get_default_config, Collector, TidyPyIssue

ISSUES = [
    TidyPyIssue(
        'code1',
        'Message 1',
        'someproject/foo.py',
        5,
        23,
    ),
    TidyPyIssue(
        'code2',
        'Message 2',
        'someproject/foo.py',
        2,
    ),
    TidyPyIssue(
        'code1',
        'Message 1',
        'someproject/blah/bar.py',
        28,
    ),
    TidyPyIssue(
        'code3',
        'Message 3',
        'someproject/subdir/foobar.json',
        5,
        23,