def test_rule_032(self): oRule = if_statement.rule_032() self.assertTrue(oRule) self.assertEqual(oRule.name, 'if') self.assertEqual(oRule.identifier, '032') lExpected = [{ 'lines': [{ 'number': 17 }], 'indent': 2 }, { 'lines': [{ 'number': 16 }], 'indent': 2 }, { 'lines': [{ 'number': 15 }], 'indent': 2 }, { 'lines': [{ 'number': 21 }], 'indent': 2 }, { 'lines': [{ 'number': 20 }], 'indent': 2 }] oRule.analyze(oFileIf) self.assertEqual(oRule.violations, lExpected)
def test_fix_rule_032(self): oRule = if_statement.rule_032() oRule.fix(self.oFile) lActual = self.oFile.get_lines() self.assertEqual(lExpected, lActual) oRule.analyze(self.oFile) self.assertEqual(oRule.violations, [])
def test_rule_032(self): oRule = if_statement.rule_032() self.assertTrue(oRule) self.assertEqual(oRule.name, 'if') self.assertEqual(oRule.identifier, '032') lExpected = [31, 37, 39] oRule.analyze(self.oFile) self.assertEqual( lExpected, utils.extract_violation_lines_from_violation_object( oRule.violations))
def test_rule_032(self): oRule = if_statement.rule_032() lExpected = [] oRule.fix(oFileIf) oRule.analyze(oFileIf) self.assertEqual(oFileIf.lines[15].indentLevel, 2) self.assertEqual(oFileIf.lines[16].indentLevel, 2) self.assertEqual(oFileIf.lines[17].indentLevel, 2) self.assertEqual(oFileIf.lines[15].line, ' -- This is a comment') self.assertEqual(oFileIf.lines[16].line, ' -- to describe the elsif') self.assertEqual(oFileIf.lines[17].line, ' -- code') self.assertEqual(oFileIf.lines[20].indentLevel, 2) self.assertEqual(oFileIf.lines[21].indentLevel, 2) self.assertEqual(oFileIf.lines[20].line, ' -- Yet more code comments') self.assertEqual(oFileIf.lines[21].line, ' -- for the next elsif') self.assertEqual(oRule.violations, lExpected)