vhdl-style-guide/vsg/tests/library/test_rule_011.py

48 lines
1.2 KiB
Python

import os
import unittest
from vsg.rules import library
from vsg import vhdlFile
from vsg.tests import utils
sTestDir = os.path.dirname(__file__)
lFile = utils.read_vhdlfile(os.path.join(sTestDir,'rule_011_test_input.vhd'))
lExpected = []
lExpected.append('')
utils.read_file(os.path.join(sTestDir, 'rule_011_test_input.fixed.vhd'), lExpected, False)
class test_library_rule(unittest.TestCase):
def setUp(self):
self.oFile = vhdlFile.vhdlFile(lFile)
def test_rule_011(self):
oRule = library.rule_011()
self.assertTrue(oRule)
self.assertEqual(oRule.name, 'library')
self.assertEqual(oRule.identifier, '011')
lExpected = [7, 7, 7, 9, 9, 10]
oRule.analyze(self.oFile)
self.assertEqual(lExpected, utils.extract_violation_lines(oRule.violations))
def test_fix_rule_011(self):
self.maxDiff = None
oRule = library.rule_011()
oRule.fix(self.oFile)
lActual = []
for oLine in self.oFile.lines:
lActual.append(oLine.line)
self.assertEqual(lExpected, lActual)
oRule.analyze(self.oFile)
self.assertEqual(oRule.violations, [])