本文整理匯總了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")