本文整理汇总了Python中gitlint.config.LintConfig.set_rule_option方法的典型用法代码示例。如果您正苦于以下问题:Python LintConfig.set_rule_option方法的具体用法?Python LintConfig.set_rule_option怎么用?Python LintConfig.set_rule_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gitlint.config.LintConfig
的用法示例。
在下文中一共展示了LintConfig.set_rule_option方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_set_rule_option
# 需要导入模块: from gitlint.config import LintConfig [as 别名]
# 或者: from gitlint.config.LintConfig import set_rule_option [as 别名]
def test_set_rule_option(self):
config = LintConfig()
# assert default title line-length
self.assertEqual(config.get_rule_option('title-max-length', 'line-length'), 72)
# change line length and assert it is set
config.set_rule_option('title-max-length', 'line-length', 60)
self.assertEqual(config.get_rule_option('title-max-length', 'line-length'), 60)
示例2: test_set_rule_option_negative
# 需要导入模块: from gitlint.config import LintConfig [as 别名]
# 或者: from gitlint.config.LintConfig import set_rule_option [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'. " + \
r"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")