예제 #1
0
    def test_boolean_option(self):
        # normal behavior
        option = BoolOption(u"tëst-name", "true", u"Tëst Description")
        self.assertEqual(option.name, u"tëst-name")
        self.assertEqual(option.description, u"Tëst Description")
        self.assertEqual(option.value, True)

        # re-set value
        option.set("False")
        self.assertEqual(option.value, False)

        # Re-set using actual boolean
        option.set(True)
        self.assertEqual(option.value, True)

        # error on incorrect value
        incorrect_values = [
            1, -1, "foo", u"bår", ["foo"], {
                'foo': "bar"
            }, None
        ]
        for value in incorrect_values:
            with self.assertRaisesMessage(
                    RuleOptionError,
                    u"Option 'tëst-name' must be either 'true' or 'false'"):
                option.set(value)
예제 #2
0
파일: rules.py 프로젝트: tommyip/gitlint
class BodyMissing(CommitRule):
    name = "body-is-missing"
    id = "B6"
    options_spec = [BoolOption('ignore-merge-commits', True, "Ignore merge commits")]

    def validate(self, commit):
        # ignore merges when option tells us to, which may have no body
        if self.options['ignore-merge-commits'].value and commit.is_merge_commit:
            return
        if len(commit.message.body) < 2:
            return [RuleViolation(self.id, "Body message is missing", None, 3)]
예제 #3
0
    def test_boolean_option(self):
        # normal behavior
        option = BoolOption("test-name", "true", "Test Description")
        self.assertEqual(option.value, True)

        # re-set value
        option.set("False")
        self.assertEqual(option.value, False)

        # Re-set using actual boolean
        option.set(True)
        self.assertEqual(option.value, True)

        # error on incorrect value
        expected_error = "Option 'test-name' must be either 'true' or 'false'"
        with self.assertRaisesRegexp(RuleOptionError, expected_error):
            option.set("foo")
예제 #4
0
    def test_boolean_option(self):
        # normal behavior
        option = BoolOption("test-name", "true", "Test Description")
        self.assertEqual(option.value, True)

        # re-set value
        option.set("False")
        self.assertEqual(option.value, False)

        # Re-set using actual boolean
        option.set(True)
        self.assertEqual(option.value, True)

        # error on incorrect value
        incorrect_values = [1, -1, "foo", ["foo"], {'foo': "bar"}]
        for value in incorrect_values:
            with self.assertRaisesRegexp(RuleOptionError, "Option 'test-name' must be either 'true' or 'false'"):
                option.set(value)