示例#1
0
    def test_create_list_with_configuration(self):
        dConfiguration = {}
        dConfiguration['severity'] = {}
        dSeverity = {}
        dSeverity['type'] = 'warning'
        dConfiguration['severity']['Guideline'] = dSeverity
        dSeverity = {}
        dSeverity['type'] = 'error'
        dConfiguration['severity']['Todo'] = dSeverity

        oSeverityList = severity.create_list(dConfiguration)

        lExpected = []
        lExpected.append(severity.error('Error'))
        lExpected.append(severity.warning('Warning'))
        lExpected.append(severity.warning('Guideline'))
        lExpected.append(severity.error('Todo'))

        lActual = oSeverityList.lSeverities

        self.assertEqual(len(lActual), len(lExpected))

        for iIndex, oExpected in enumerate(lExpected):
            self.assertEqual(lActual[iIndex].name, oExpected.name)
            self.assertEqual(lActual[iIndex].type, oExpected.type)
示例#2
0
 def __init__(self, name, identifier):
     rule.Rule.__init__(self, name=name, identifier=identifier)
     self.phase = 7
     self.fixable = False  # The user will have to fix line length violations
     self.severity = severity.warning('Warning')
     self.length = 2000
     self.configuration.append('length')
 def __init__(self, name, identifier, oLeftToken, oRightToken, iLines):
     rule.Rule.__init__(self, name=name, identifier=identifier)
     self.phase = 7
     self.fixable = False  # The user will have to fix line length violations
     self.severity = severity.warning('Warning')
     self.length = iLines
     self.configuration.append('length')
     self.oLeftToken = oLeftToken
     self.oRightToken = oRightToken
示例#4
0
 def __init__(self, name, identifier):
     rule.Rule.__init__(self, name=name, identifier=identifier)
     self.phase = 7
     self.fixable = False  # The user will have to fix line length violations
     self.disable = False
     self.severity = severity.warning('Warning')
     self.length = 120
     self.configuration.append('length')
     self.solution = 'Reduce line to less than ' + str(
         self.length) + ' characters'
示例#5
0
    def test_create_list_add_severity_method(self):
        oSeverityList = severity.create_list({})
        self.assertEqual(len(oSeverityList.lSeverities), 2)

        oSeverity = severity.warning('Guideline')
        oSeverityList.add_severity(oSeverity)

        self.assertEqual(len(oSeverityList.lSeverities), 3)

        self.assertEqual(
            oSeverityList.get_severity_named('Error').name, 'Error')
        self.assertEqual(
            oSeverityList.get_severity_named('Warning').name, 'Warning')
        self.assertEqual(
            oSeverityList.get_severity_named('Guideline').name, 'Guideline')
        self.assertEqual(
            oSeverityList.get_severity_named('Guideline').type, 'warning')
示例#6
0
 def test_warning_class_exists(self):
     oSeverity = severity.warning('Warning')
     self.assertTrue(oSeverity)
     self.assertEqual(oSeverity.name, 'Warning')
     self.assertEqual(oSeverity.type, 'warning')