vhdl-style-guide/vsg/tests/entity/test_rule_020.py

77 lines
2.2 KiB
Python

import os
import unittest
from vsg.rules import entity
from vsg import vhdlFile
from vsg.tests import utils
sTestDir = os.path.dirname(__file__)
lFile, eError =vhdlFile.utils.read_vhdlfile(os.path.join(sTestDir,'rule_020_test_input.vhd'))
class test_entity_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
self.assertIsNone(eError)
def test_rule_020_with_combined_generic(self):
oRule = entity.rule_020()
oRule.separate_generic_port_alignment = False
self.assertTrue(oRule)
self.assertEqual(oRule.name, 'entity')
self.assertEqual(oRule.identifier, '020')
lExpected = [5, 6, 7, 10, 11]
lExpected.extend([19, 20, 21, 25, 26])
oRule.analyze(self.oFile)
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
def test_fix_rule_020_with_combined_generic(self):
oRule = entity.rule_020()
oRule.separate_generic_port_alignment = False
oRule.fix(self.oFile)
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_020_test_input.fixed_combined_generic.vhd'), lExpected)
lActual = self.oFile.get_lines()
self.assertEqual(lExpected, lActual)
oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])
def test_rule_020_with_seperate_generic(self):
oRule = entity.rule_020()
self.assertTrue(oRule)
self.assertEqual(oRule.name, 'entity')
self.assertEqual(oRule.identifier, '020')
lExpected = [10, 11, 19, 21, 25, 26]
oRule.analyze(self.oFile)
self.assertEqual(lExpected, utils.extract_violation_lines_from_violation_object(oRule.violations))
def test_fix_rule_020_with_seperate_generic(self):
oRule = entity.rule_020()
oRule.fix(self.oFile)
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_020_test_input.fixed_seperate_generic.vhd'), lExpected)
lActual = self.oFile.get_lines()
self.assertEqual(lExpected, lActual)
oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])