当前位置: 首页>>代码示例>>Python>>正文


Python config.parse_options函数代码示例

本文整理汇总了Python中pylama.config.parse_options函数的典型用法代码示例。如果您正苦于以下问题:Python parse_options函数的具体用法?Python parse_options怎么用?Python parse_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parse_options函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_config

    def test_config(self):
        from pylama.config import get_parser, get_config

        parser = get_parser()
        self.assertTrue(parser)

        config = get_config()
        self.assertTrue(config)

        options = parse_options()
        self.assertTrue(options)
        self.assertTrue(options.skip)
        self.assertEqual(options.path, 'pylama')

        options = parse_options(['-l', 'pep257,pep8', '-i', 'E'])
        self.assertEqual(set(options.linters), set(['pep257', 'pep8']))
        self.assertEqual(options.ignore, ['E'])

        options = parse_options(['-l', 'gjslint,pep8', '-i', 'E:0010'])
        self.assertEqual(set(options.linters), set(['gjslint', 'pep8']))
        self.assertEqual(options.ignore, ['E:0010'])

        options = parse_options('-o dummy dummy.py'.split())
        self.assertEqual(
            set(options.linters), set(['pep8', 'mccabe', 'pyflakes']))
        self.assertEqual(options.skip, [])
开发者ID:pyjosh,项目名称:pythonprojects,代码行数:26,代码来源:tests.py

示例2: test_prepare_params

def test_prepare_params():
    p1 = dict(ignore='W', select='R01', skip='0')
    p2 = dict(ignore='E34,R45', select='E')
    options = parse_options(ignore=['D'], config=False)
    params = prepare_params(p1, p2, options)
    assert params == {
        'ignore': set(['R45', 'E34', 'W', 'D']), 'select': set(['R01', 'E']), 'skip': False}
开发者ID:EricSchles,项目名称:pylama,代码行数:7,代码来源:tests.py

示例3: test_pep8

def test_pep8():
    options = parse_options(linters=['pep8'], config=False)
    errors = run('dummy.py', options=options)
    assert len(errors) == 3

    options.linters_params['pep8'] = dict(max_line_length=60)
    errors = run('dummy.py', options=options)
    assert len(errors) == 11
开发者ID:EricSchles,项目名称:pylama,代码行数:8,代码来源:tests.py

示例4: test_linters_params

def test_linters_params():
    options = parse_options(linters='mccabe', config=False)
    options.linters_params['mccabe'] = dict(complexity=2)
    errors = run('dummy.py', options=options)
    assert len(errors) == 13

    options.linters_params['mccabe'] = dict(complexity=20)
    errors = run('dummy.py', options=options)
    assert not errors
开发者ID:EricSchles,项目名称:pylama,代码行数:9,代码来源:tests.py

示例5: test_pyflakes

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
开发者ID:klen,项目名称:pylama,代码行数:9,代码来源:test_linters.py

示例6: test_pycodestyle

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
开发者ID:eriksf,项目名称:dotfiles,代码行数:9,代码来源:test_pylama.py

示例7: test_pyflakes

def test_pyflakes():
    options = parse_options(linters=['pyflakes'], config=False)
    assert options.linters
    errors = run('dummy.py', code="""
import sys

def test():
    unused = 1
""", options=options)
    assert len(errors) == 2
开发者ID:brifordwylie,项目名称:pylama,代码行数:10,代码来源:tests.py

示例8: test_shell

def test_shell():
    errors = shell('-o dummy dummy.py'.split(), error=False)
    assert errors

    options = parse_options()
    errors = check_files(['dummy.py'], options=options, error=False)
    assert errors

    errors = shell(['unknown.py'], error=False)
    assert not errors
开发者ID:brifordwylie,项目名称:pylama,代码行数:10,代码来源:tests.py

示例9: test_config

def test_config():
    config = get_config()
    assert config

    options = parse_options()
    assert options
    assert options.skip
    assert not options.verbose
    assert options.paths == ['pylama']

    options = parse_options(['-l', 'pydocstyle,pycodestyle', '-i', 'E'])
    linters, _ = zip(*options.linters)
    assert set(linters) == set(['pydocstyle', 'pycodestyle'])
    assert options.ignore == ['E']

    options = parse_options('-o dummy dummy.py'.split())
    linters, _ = zip(*options.linters)
    assert set(linters) == set(['pycodestyle', 'mccabe', 'pyflakes'])
    assert options.skip == []
开发者ID:klen,项目名称:pylama,代码行数:19,代码来源:test_config.py

示例10: test_shell

    def test_shell(self):
        from pylama.main import shell, check_files

        errors = shell('-o dummy dummy.py'.split(), error=False)
        self.assertTrue(errors)

        options = parse_options()
        errors = check_files(['dummy.py'], options=options, error=False)
        self.assertTrue(errors)

        errors = shell(['unknown.py'], error=False)
        self.assertFalse(errors)
开发者ID:sethwoodworth,项目名称:pylama,代码行数:12,代码来源:tests.py

示例11: test_pycodestyle

def test_pycodestyle():
    options = parse_options(linters=['pycodestyle'], config=False)
    assert len(options.linters) == 1
    errors = run('dummy.py', options=options)
    numbers = [error.number for error in errors]
    assert len(errors) == 4
    assert 'E265' in numbers
    assert 'E301' in numbers
    assert 'E501' in numbers

    options.linters_params['pycodestyle'] = dict(max_line_length=60)
    errors = run('dummy.py', options=options)
    assert len(errors) == 13
开发者ID:klen,项目名称:pylama,代码行数:13,代码来源:test_linters.py

示例12: test_ignore_select

def test_ignore_select():
    options = parse_options()
    options.ignore = ['E301', 'D102']
    options.linters = ['pep8', 'pep257', 'pyflakes', 'mccabe']
    errors = run('dummy.py', options=options)
    assert len(errors) == 16

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

    options.select = ['E301']
    errors = run('dummy.py', options=options)
    assert len(errors) == 2
    assert errors[0]['col']
开发者ID:EricSchles,项目名称:pylama,代码行数:15,代码来源:tests.py

示例13: test_ignore_select

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) == 17

    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']
开发者ID:eriksf,项目名称:dotfiles,代码行数:15,代码来源:test_pylama.py

示例14: test_pylint

def test_pylint():
    from pylama.core import run
    from pylama.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) == 4
    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
开发者ID:klen,项目名称:pylama_pylint,代码行数:18,代码来源:tests.py

示例15: test_pylint

def test_pylint():
    from pylama.core import run
    from pylama.config import parse_options

    options = parse_options(linters=['pylint'], config=False)
    options.ignore = set(['R0912', 'C0111'])
    errors = run('pylama_pylint/pylint/utils.py', options=options)
    assert len(errors) == 29
    assert errors[0].number == 'W0622'

    options.linters_params['pylint'] = dict(disable="W")
    errors = run('pylama_pylint/pylint/utils.py', options=options)
    assert len(errors) == 21
    assert errors[0].number == 'C0301'

    options.linters_params['pylint']['max-line_length'] = 200
    errors = run('pylama_pylint/pylint/utils.py', options=options)
    assert len(errors) == 3
开发者ID:EricSchles,项目名称:pylama_pylint,代码行数:18,代码来源:tests.py


注:本文中的pylama.config.parse_options函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。