本文整理汇总了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"))