本文整理匯總了Python中gitlint.config.LintConfig.get_rule方法的典型用法代碼示例。如果您正苦於以下問題:Python LintConfig.get_rule方法的具體用法?Python LintConfig.get_rule怎麽用?Python LintConfig.get_rule使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gitlint.config.LintConfig
的用法示例。
在下文中一共展示了LintConfig.get_rule方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_get_rule
# 需要導入模塊: from gitlint.config import LintConfig [as 別名]
# 或者: from gitlint.config.LintConfig import get_rule [as 別名]
def test_get_rule(self):
config = LintConfig()
# get by id
expected = rules.TitleMaxLength()
rule = config.get_rule('T1')
self.assertEqual(rule, expected)
# get by name
expected = rules.TitleTrailingWhitespace() # pylint: disable=redefined-variable-type
rule = config.get_rule('title-trailing-whitespace')
self.assertEqual(rule, expected)
# get non-existing
rule = config.get_rule('foo')
self.assertIsNone(rule)
示例2: test_extra_path
# 需要導入模塊: from gitlint.config import LintConfig [as 別名]
# 或者: from gitlint.config.LintConfig import get_rule [as 別名]
def test_extra_path(self):
config = LintConfig()
config.set_general_option("extra-path", self.get_rule_rules_path())
self.assertEqual(config.extra_path, self.get_rule_rules_path())
actual_rule = config.get_rule('TUC1')
self.assertTrue(actual_rule.user_defined)
self.assertEqual(str(type(actual_rule)), "<class 'my_commit_rules.MyUserCommitRule'>")
self.assertEqual(actual_rule.id, 'TUC1')
self.assertEqual(actual_rule.name, 'my-user-commit-rule')
self.assertEqual(actual_rule.target, None)
expected_rule_option = IntOption('violation-count', 1, "Number of violations to return")
self.assertListEqual(actual_rule.options_spec, [expected_rule_option])
self.assertDictEqual(actual_rule.options, {'violation-count': expected_rule_option})
# reset value (this is a different code path)
config.set_general_option("extra-path", self.SAMPLES_DIR)
self.assertEqual(config.extra_path, self.SAMPLES_DIR)
self.assertIsNone(config.get_rule("TUC1"))