def test_006(self): oRule = whitespace.rule_006() self.assertTrue(oRule) self.assertEqual(oRule.name, 'whitespace') self.assertEqual(oRule.identifier, '006') self.assertEqual(oRule.phase, 2) dExpected = [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(' ) pass')) self.oFile.lines.append( line.line(' This is a test of parentehsis (pass ) -- ) pass')) self.oFile.lines[5].hasComment = 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, ' ) pass') self.assertEqual(self.oFile.lines[5].line, ' This is a test of parentehsis (pass) -- ) pass')
def test_fix_rule_006(self): oRule = whitespace.rule_006() oRule.fix(self.oFile) lActual = self.oFile.get_lines() self.assertEqual(lExpected, lActual) oRule.analyze(self.oFile) self.assertEqual(oRule.violations, [])
def test_rule_006(self): oRule = whitespace.rule_006() self.assertTrue(oRule) self.assertEqual(oRule.name, 'whitespace') self.assertEqual(oRule.identifier, '006') lExpected = [6, 16, 16, 16] oRule.analyze(self.oFile) self.assertEqual( lExpected, utils.extract_violation_lines_from_violation_object( oRule.violations))