예제 #1
0
    def test_005(self):
        oRule = whitespace.rule_005()
        self.assertTrue(oRule)
        self.assertEqual(oRule.name, 'whitespace')
        self.assertEqual(oRule.identifier, '005')
        self.assertEqual(oRule.phase, 2)

        dExpected = utils.add_violation_list([1,3,5])
        self.oFile.lines.append(line.line('  This is a test of parenthesis ( failure'))
        self.oFile.lines.append(line.line('  This is a test of parenthesis (pass'))
        self.oFile.lines.append(line.line('  This is a test of parentehsis (  failure'))
        self.oFile.lines.append(line.line('  This is a test of parentehsis (  7 pass'))
        self.oFile.lines.append(line.line('  This is a test of parenthesis ( pass) --  ( pass'))
        self.oFile.lines.append(line.line(' --  This is a test of parenthesis ( pass)'))
        self.oFile.lines[5].hasComment = True
        self.oFile.lines[6].isComment = True
        oRule.analyze(self.oFile)
        self.assertEqual(oRule.violations, dExpected)
        oRule.fix(self.oFile)
        oRule.analyze(self.oFile)
        self.assertEqual(oRule.violations, [])
        self.assertEqual(self.oFile.lines[1].line, '  This is a test of parenthesis (failure')
        self.assertEqual(self.oFile.lines[2].line, '  This is a test of parenthesis (pass')
        self.assertEqual(self.oFile.lines[3].line, '  This is a test of parentehsis (failure')
        self.assertEqual(self.oFile.lines[4].line, '  This is a test of parentehsis (  7 pass')
        self.assertEqual(self.oFile.lines[5].line, '  This is a test of parenthesis (pass) --  ( pass')
        self.assertEqual(self.oFile.lines[6].line, ' --  This is a test of parenthesis ( pass)')
예제 #2
0
    def test_rule_005(self):
        oRule = whitespace.rule_005()
        self.assertTrue(oRule)
        self.assertEqual(oRule.name, 'whitespace')
        self.assertEqual(oRule.identifier, '005')

        lExpected = [12]

        oRule.analyze(self.oFile)
        self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
예제 #3
0
    def test_fix_rule_005(self):
        oRule = whitespace.rule_005()

        oRule.fix(self.oFile)

        lActual = self.oFile.get_lines()

        self.assertEqual(lExpected, lActual)

        oRule.analyze(self.oFile)
        self.assertEqual(oRule.violations, [])