def test_register_parse_from_config(parser): """Verify we append to config_options on registration.""" options.register(parser, '--select', default='E123,W504', parse_from_config=True) assert 'select' in parser.config_options
def test_register_with_store_callback(parser): """Verify we handle typical no-custom-callback case (integration test).""" options.register(parser, '--foo', default=['path/file.py'], type='string', comma_separated_list=True, normalize_paths=True) values, _ = parser.parse_args([]) assert values.foo == ['path/file.py'] # default is used in its entirety values, _ = parser.parse_args(['--foo=file.py,path/file.py']) assert values.foo == ['file.py', os.path.abspath('path/file.py')]
def test_register_normalize_paths(parser): """Verify we register the normalize_paths_callback.""" options.register(parser, '--exclude', default='file.py', normalize_paths=True) option = parser.get_option('--exclude') assert option.callback is options.normalize_paths_callback
def test_register_comma_separated_list(parser): """Verify we register the comma_separated_callback.""" options.register(parser, '--select', default='E123,W504', comma_separated_list=True) option = parser.get_option('--select') assert option.callback is options.comma_separated_callback
def test_register_with_custom_callback(parser): """Verify we handle custom callback (integration test).""" def custom_callback(option, opt_str, value, parser, *args, **kwargs): parser.values.count = len(value) options.register(parser, '--foo', type='string', callback=custom_callback, comma_separated_list=True, normalize_paths=True) values, _ = parser.parse_args(['--foo=file.py,path/file.py']) assert values.count == 2
def add_options(cls, parser): options.register( parser, '--return-check-methods', default='', type='string', help='Names of the method should be checked return.', parse_from_config=True, comma_separated_list=True, )
def test_register_comma_separated_paths(parser): """Verify we register a composed hook.""" options.register(parser, '--exclude', default='file.py', normalize_paths=True, comma_separated_list=True) option = parser.get_option('--exclude') assert option.callback is not options.normalize_paths_callback assert option.callback is not options.comma_separated_callback assert option.callback is not None
def test_register_with_store_callback(parser): """Verify we handle typical no-custom-callback case (integration test).""" options.register(parser, '--foo', default=['path/file.py'], type='string', comma_separated_list=True, normalize_paths=True) values, _ = parser.parse_args([]) assert values.foo == ['path/file.py'] # default is used in its entirety values, _ = parser.parse_args(['--foo=file.py,path/file.py']) assert values.foo == ['file.py', os.path.abspath('path/file.py')]
def test_register_with_custom_callback(parser): """Verify we handle custom callback (integration test).""" def custom_callback(option, opt_str, value, parser, *args, **kwargs): parser.values.count = len(value) options.register(parser, '--foo', type='string', callback=custom_callback, comma_separated_list=True, normalize_paths=True) values, _ = parser.parse_args(['--foo=file.py,path/file.py']) assert values.count == 2
def add_options(cls, parser): # pragma: no cover '''Add custom options to the global parser.''' options.register( parser, '--radon-max-cc', default=-1, action='store', type='int', help='Radon complexity threshold', parse_from_config=True ) options.register( parser, '--radon-no-assert', dest='no_assert', action='store_true', default=False, help='Radon will ignore assert statements', parse_from_config=True, )
def add_options(cls, parser): # pragma: no cover '''Add custom options to the global parser.''' options.register( parser, '--radon-max-cc', default=-1, action='store', type='int', help='Radon complexity threshold', parse_from_config=True ) options.register( parser, '--radon-no-assert', dest='no_assert', action='store_true', default=False, help='Radon will ignore assert statements', parse_from_config=True, )
def add_options(cls, parser): options.register( parser, '--return-check-methods', default='', type='string', help='Names of the method should be checked return.', parse_from_config=True, comma_separated_list=True, ) options.register( parser, '--forbid-chinese-char', default=0, type='int', help='whether forbid chinese character in code.', parse_from_config=True, )
def add_options(cls, parser): options.register( parser, '--license-type', type='choice', choices=['proprietary', 'apache'], default='apache', action='store', parse_from_config=True, help='Checks for specific type of license header.' ) options.register( parser, '--license-min-file-size', type='int', default=1, action='store', parse_from_config=True, help='Minimum number of characters in a file before requiring a license header.' )
def add_options(cls, parser): options.register(parser, '--ignore-names', default=_default_ignore_names, action='store', type='string', parse_from_config=True, comma_separated_list=True, help='List of names or glob patterns the pep8-naming ' 'plugin should ignore. (Defaults to %default)') options.register(parser, '--classmethod-decorators', default=_default_classmethod_decorators, action='store', type='string', parse_from_config=True, comma_separated_list=True, help='List of method decorators pep8-naming plugin ' 'should consider classmethods (Defaults to ' '%default)') options.register(parser, '--staticmethod-decorators', default=_default_staticmethod_decorators, action='store', type='string', parse_from_config=True, comma_separated_list=True, help='List of method decorators pep8-naming plugin ' 'should consider staticmethods (Defaults to ' '%default)')
def add_options(cls, parser): options.register(parser, '--ignore-names', default=_default_ignore_names, action='store', type='string', parse_from_config=True, comma_separated_list=True, help='List of names the pep8-naming plugin should ' 'ignore. (Defaults to %default)') options.register(parser, '--classmethod-decorators', default=_default_classmethod_decorators, action='store', type='string', parse_from_config=True, comma_separated_list=True, help='List of method decorators pep8-naming plugin ' 'should consider classmethods (Defaults to ' '%default)') options.register(parser, '--staticmethod-decorators', default=_default_staticmethod_decorators, action='store', type='string', parse_from_config=True, comma_separated_list=True, help='List of method decorators pep8-naming plugin ' 'should consider staticmethods (Defaults to ' '%default)')
def add_options(cls, parser): options.register( parser, '--snippets', default='', metavar='patterns', parse_from_config=True, help="Comma separated code snippets to find")
def test_register_parse_from_config(parser): """Verify we append to config_options on registration.""" options.register(parser, '--select', default='E123,W504', parse_from_config=True) assert 'select' in parser.config_options