當前位置: 首頁>>代碼示例>>Python>>正文


Python LintConfig.verbosity方法代碼示例

本文整理匯總了Python中gitlint.config.LintConfig.verbosity方法的典型用法代碼示例。如果您正苦於以下問題:Python LintConfig.verbosity方法的具體用法?Python LintConfig.verbosity怎麽用?Python LintConfig.verbosity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gitlint.config.LintConfig的用法示例。


在下文中一共展示了LintConfig.verbosity方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_config

# 需要導入模塊: from gitlint.config import LintConfig [as 別名]
# 或者: from gitlint.config.LintConfig import verbosity [as 別名]
def get_config(ctx, target, config_path, c, ignore, verbose, silent):
    """ Creates a LintConfig object based on a set of commandline parameters. """
    try:
        # Config precedence:
        # First, load default config or config from configfile
        lint_config = load_config_from_path(ctx, config_path)
        # default to default configuration when no config file was loaded
        if lint_config:
            click.echo("Using config from {0}".format(lint_config.config_path))
        else:
            lint_config = LintConfig()

        # Then process any commandline configuration flags
        lint_config.apply_config_options(c)

        # Finally, overwrite with any convenience commandline flags
        lint_config.apply_on_csv_string(ignore, lint_config.disable_rule)
        if silent:
            lint_config.verbosity = 0
        elif verbose > 0:
            lint_config.verbosity = verbose

        # Set target
        lint_config.target = target
        return lint_config
    except LintConfigError as e:
        click.echo("Config Error: {0}".format(str(e)))
    ctx.exit(CONFIG_ERROR_CODE)  # return CONFIG_ERROR_CODE on config error
開發者ID:cimarron-pistoncloud,項目名稱:gitlint,代碼行數:30,代碼來源:cli.py

示例2: test_set_general_option_negative

# 需要導入模塊: from gitlint.config import LintConfig [as 別名]
# 或者: from gitlint.config.LintConfig import verbosity [as 別名]
    def test_set_general_option_negative(self):
        config = LintConfig()

        with self.assertRaisesRegex(LintConfigError, "'foo' is not a valid gitlint option"):
            config.set_general_option("foo", "bar")

        # try setting _config_path, this is a real attribute of LintConfig, but the code should prevent it from
        # being set
        with self.assertRaisesRegex(LintConfigError, "'_config_path' is not a valid gitlint option"):
            config.set_general_option("_config_path", "bar")

        # invalid verbosity`
        incorrect_values = [-1, "foo"]
        for value in incorrect_values:
            expected_msg = r"Option 'verbosity' must be a positive integer \(current value: '{0}'\)".format(value)
            with self.assertRaisesRegex(LintConfigError, expected_msg):
                config.verbosity = value

        incorrect_values = [4]
        for value in incorrect_values:
            with self.assertRaisesRegex(LintConfigError, "Option 'verbosity' must be set between 0 and 3"):
                config.verbosity = value

        # invalid ignore_merge_commits
        incorrect_values = [-1, 4, "foo"]
        for value in incorrect_values:
            with self.assertRaisesRegex(LintConfigError,
                                        r"Option 'ignore-merge-commits' must be either 'true' or 'false'"):
                config.ignore_merge_commits = value

        # invalid ignore -> not here because ignore is a ListOption which converts everything to a string before
        # splitting which means it it will accept just about everything

        # invalid debug
        with self.assertRaisesRegex(LintConfigError, r"Option 'debug' must be either 'true' or 'false'"):
            config.debug = "foobar"

        # invalid extra-path
        with self.assertRaisesRegex(LintConfigError,
                                    r"Option extra-path must be an existing directory \(current value: 'foo/bar'\)"):
            config.extra_path = "foo/bar"

        # invalid target
        with self.assertRaisesRegex(LintConfigError,
                                    r"Option target must be an existing directory \(current value: 'foo/bar'\)"):
            config.target = "foo/bar"
開發者ID:jorisroovers,項目名稱:gitlint,代碼行數:48,代碼來源:test_config.py

示例3: test_rebuild_config

# 需要導入模塊: from gitlint.config import LintConfig [as 別名]
# 或者: from gitlint.config.LintConfig import verbosity [as 別名]
    def test_rebuild_config(self):
        # normal config build
        config_builder = LintConfigBuilder()
        config_builder.set_option('general', 'verbosity', 3)
        lint_config = config_builder.build()
        self.assertEqual(lint_config.verbosity, 3)

        # check that existing config changes when we rebuild it
        existing_lintconfig = LintConfig()
        existing_lintconfig.verbosity = 2
        lint_config = config_builder.build(existing_lintconfig)
        self.assertEqual(lint_config.verbosity, 3)
開發者ID:jorisroovers,項目名稱:gitlint,代碼行數:14,代碼來源:test_config_builder.py

示例4: test_set_general_option_negative

# 需要導入模塊: from gitlint.config import LintConfig [as 別名]
# 或者: from gitlint.config.LintConfig import verbosity [as 別名]
    def test_set_general_option_negative(self):
        config = LintConfig()

        with self.assertRaisesRegexp(LintConfigError, "'foo' is not a valid gitlint option"):
            config.set_general_option("foo", "bar")

        # invalid verbosity
        incorrect_values = [-1, "foo"]
        for value in incorrect_values:
            expected_msg = r"Option 'verbosity' must be a positive integer \(current value: '{0}'\)".format(value)
            with self.assertRaisesRegexp(LintConfigError, expected_msg):
                config.verbosity = value

        incorrect_values = [4]
        for value in incorrect_values:
            with self.assertRaisesRegexp(LintConfigError, "Option 'verbosity' must be set between 0 and 3"):
                config.verbosity = value

        # invalid ignore_merge_commits
        incorrect_values = [-1, 4, "foo"]
        for value in incorrect_values:
            with self.assertRaisesRegexp(LintConfigError,
                                         r"Option 'ignore-merge-commits' must be either 'true' or 'false'"):
                config.ignore_merge_commits = value
開發者ID:cimarron-pistoncloud,項目名稱:gitlint,代碼行數:26,代碼來源:test_config.py

示例5: test_set_rule_option_negative

# 需要導入模塊: from gitlint.config import LintConfig [as 別名]
# 或者: from gitlint.config.LintConfig import verbosity [as 別名]
    def test_set_rule_option_negative(self):
        config = LintConfig()

        # non-existing rule
        expected_error_msg = "No such rule 'foobar'"
        with self.assertRaisesRegexp(LintConfigError, expected_error_msg):
            config.set_rule_option('foobar', 'line-length', 60)

        # non-existing option
        expected_error_msg = "Rule 'title-max-length' has no option 'foobar'"
        with self.assertRaisesRegexp(LintConfigError, expected_error_msg):
            config.set_rule_option('title-max-length', 'foobar', 60)

        # invalid option value
        expected_error_msg = "'foo' is not a valid value for option 'title-max-length.line-length'. " + \
                             "Option 'line-length' must be a positive integer \(current value: 'foo'\)."
        with self.assertRaisesRegexp(LintConfigError, expected_error_msg):
            config.set_rule_option('title-max-length', 'line-length', "foo")

        # invalid verbosity
        with self.assertRaisesRegexp(LintConfigError, "verbosity must be set between 0 and 3"):
            config.verbosity = -1
        with self.assertRaisesRegexp(LintConfigError, "verbosity must be set between 0 and 3"):
            config.verbosity = 4
開發者ID:tobyoxborrow,項目名稱:gitlint,代碼行數:26,代碼來源:test_config.py


注:本文中的gitlint.config.LintConfig.verbosity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。