Updates for test structure:

1)  Updated test files to run at the top level using the following command:

  python -m unittest discover

NOTE:  More tests need to be converted to the new method.
When they are converted, they will be updated to match the new test structure.
This commit is contained in:
Jeremiah Leary 2017-09-10 19:53:24 -05:00
parent 0216d76fbb
commit 1a7cd0aaa7
19 changed files with 52 additions and 82 deletions

0
tests/__init__.py Normal file
View File

0
tests/line/__init__.py Normal file
View File

View File

@ -1,9 +1,8 @@
import sys
sys.path.append('..\..')
sys.path.append('..')
#from .context import modules
import unittest
import line
from modules import line
class testLineMethods(unittest.TestCase):

View File

View File

@ -1,13 +1,10 @@
import sys
sys.path.append('..\..')
import unittest
import rule_architecture
import os
import vhdlFile
from modules import rule_architecture
from modules import vhdlFile
# Read in test file used for all tests
oFile = vhdlFile.vhdlFile('architecture_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_architecture/architecture_test_input.vhd')
class testRuleArchitectureMethods(unittest.TestCase):

View File

View File

@ -1,13 +1,10 @@
import sys
sys.path.append('..\..')
import unittest
import rule_entity
import os
import vhdlFile
from modules import rule_entity
from modules import vhdlFile
oFile = vhdlFile.vhdlFile('entity_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_entity/entity_test_input.vhd')
class testRuleEntityMethods(unittest.TestCase):

View File

View File

@ -1,13 +1,10 @@
import sys
sys.path.append('..\..')
import unittest
import rule_generic
import os
import vhdlFile
from modules import rule_generic
from modules import vhdlFile
oFile = vhdlFile.vhdlFile('generic_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_generic/generic_test_input.vhd')
class testRuleEntityMethods(unittest.TestCase):

View File

View File

@ -1,20 +1,11 @@
import sys
sys.path.append('..\..')
import unittest
import rule_library
import os
import vhdlFile
from modules import rule_library
from modules import vhdlFile
# Read in test file used for all tests
oFile = vhdlFile.vhdlFile('library_test_input.vhd')
#oFile = []
#with open('library_test_input.vhd') as oFile:
# for sLine in oFile:
# oFile.append(sLine.rstrip())
#oFile.close()
oFile = vhdlFile.vhdlFile('tests/rule_library/library_test_input.vhd')
class testRuleLibraryMethods(unittest.TestCase):

View File

View File

@ -1,13 +1,10 @@
import sys
sys.path.append('..\..')
import unittest
import rule_port
import os
import vhdlFile
from modules import rule_port
from modules import vhdlFile
oFile = vhdlFile.vhdlFile('port_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_port/port_test_input.vhd')
class testRulePortMethods(unittest.TestCase):

View File

View File

@ -1,14 +1,11 @@
import sys
sys.path.append('..\..')
import unittest
import rule_signal
import os
import vhdlFile
from modules import rule_signal
from modules import vhdlFile
# Read in test file used for all tests
oFile = vhdlFile.vhdlFile('signal_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_signal/signal_test_input.vhd')
class testRuleEntityMethods(unittest.TestCase):

View File

View File

@ -1,11 +1,8 @@
import sys
sys.path.append('..\..')
import unittest
import rule_whitespace
import os
import vhdlFile
import line
from modules import rule_whitespace
from modules import vhdlFile
from modules import line
class testRuleWhitespaceMethods(unittest.TestCase):
@ -16,7 +13,7 @@ class testRuleWhitespaceMethods(unittest.TestCase):
self.assertEqual(oRule.name, 'whitespace')
self.assertEqual(oRule.identifier, '001')
oFile = vhdlFile.vhdlFile('whitespace_test_input.txt')
oFile = vhdlFile.vhdlFile('tests/rule_whitespace/whitespace_test_input.txt')
dExpected = [2,4]
oFile.lines.append(line.line(' This is a test of ending whitespace'))
@ -33,7 +30,7 @@ class testRuleWhitespaceMethods(unittest.TestCase):
self.assertEqual(oRule.name, 'whitespace')
self.assertEqual(oRule.identifier, '002')
oFile = vhdlFile.vhdlFile('whitespace_test_input.txt')
oFile = vhdlFile.vhdlFile('tests/rule_whitespace/whitespace_test_input.txt')
dExpected = [1,2,5]
oFile.lines.append(line.line(' This is a test of tabs\t'))
@ -51,7 +48,7 @@ class testRuleWhitespaceMethods(unittest.TestCase):
self.assertEqual(oRule.name, 'whitespace')
self.assertEqual(oRule.identifier, '003')
oFile = vhdlFile.vhdlFile('whitespace_test_input.txt')
oFile = vhdlFile.vhdlFile('tests/rule_whitespace/whitespace_test_input.txt')
dExpected = [2,4,6]
oFile.lines.append(line.line(' This is a test of tabs;'))
@ -69,7 +66,7 @@ class testRuleWhitespaceMethods(unittest.TestCase):
self.assertEqual(oRule.name, 'whitespace')
self.assertEqual(oRule.identifier, '004')
oFile = vhdlFile.vhdlFile('whitespace_test_input.txt')
oFile = vhdlFile.vhdlFile('tests/rule_whitespace/whitespace_test_input.txt')
dExpected = [2,4,6]
oFile.lines.append(line.line(' This is a test of tabs,'))

View File

View File

@ -1,22 +1,20 @@
import sys
sys.path.append('..\..')
import unittest
import vhdlFile
from modules import vhdlFile
class testVhdlFileMethods(unittest.TestCase):
def test_vhdlFile_class_exists(self):
oFile = vhdlFile.vhdlFile('../rule_library/library_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_library/library_test_input.vhd')
self.assertTrue(oFile)
self.assertEqual(oFile.filename, '../rule_library/library_test_input.vhd')
self.assertEqual(oFile.filename, 'tests/rule_library/library_test_input.vhd')
def test_loading_of_file(self):
oFile = vhdlFile.vhdlFile('../rule_library/library_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_library/library_test_input.vhd')
# Read in test file used for all tests
lExpected = ['']
with open('../rule_library/library_test_input.vhd') as oExpectedFile:
with open('tests/rule_library/library_test_input.vhd') as oExpectedFile:
for sLine in oExpectedFile:
lExpected.append(sLine.rstrip())
oExpectedFile.close()
@ -25,7 +23,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertEqual(oLine.line, lExpected[iIndex])
def test_blank_line_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_library/library_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_library/library_test_input.vhd')
# Compare
for iIndex, oLine in enumerate(oFile.lines):
@ -37,7 +35,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertFalse(oLine.isBlank)
def test_library_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_library/library_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_library/library_test_input.vhd')
lExpected = [3,7,9,13,20,21]
# Compare
for iIndex, oLine in enumerate(oFile.lines):
@ -48,7 +46,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertFalse(oLine.isLibrary)
def test_library_use_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_library/library_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_library/library_test_input.vhd')
lExpected = [4,5,10,14,16,23,24,26,27,29]
# Compare
for iIndex, oLine in enumerate(oFile.lines):
@ -59,7 +57,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertFalse(oLine.isLibraryUse)
def test_insideEntity_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_entity/entity_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_entity/entity_test_input.vhd')
lExpected = [0,1,2,17,18,48,64,79,92,93,104,105,106,107,108,109,110,111,112,124,125,126,134,135]
# Generic actual list
lActual = []
@ -70,7 +68,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertEqual(lActual, lExpected)
def test_isEntityDeclaration_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_entity/entity_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_entity/entity_test_input.vhd')
lExpected = [3,19,34,49,65,80,94,113,127]
# Generic actual list
lActual = []
@ -81,7 +79,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertEqual(lActual, lExpected)
def test_isEndEntityDeclaration_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_entity/entity_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_entity/entity_test_input.vhd')
lExpected = [16,33,47,63,78,91,103,123,133]
# Generic actual list
lActual = []
@ -92,7 +90,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertEqual(lActual, lExpected)
def test_insidePortMap_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_port/port_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_port/port_test_input.vhd')
lExpected = [8,9,10,11,12,13,14,15,25,26,27,28,29,30,31,39,40,41,42,43,44,45,46,56,57,58,59,60,61,62,70,71,72,73,74,75,76,77,86,87,88,89,90,98,99,100,101,102,118,119,120,121,122,128,129,130,131,132]
# Generic actual list
lActual = []
@ -103,7 +101,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertEqual(lActual, lExpected)
def test_isPortKeyword_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_port/port_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_port/port_test_input.vhd')
lExpected = [8,25,39,56,70,86,98,118,128]
# Generic actual list
lActual = []
@ -114,7 +112,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertEqual(lActual, lExpected)
def test_isEndPortMap_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_port/port_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_port/port_test_input.vhd')
lExpected = [15,31,46,62,77,90,102,122,132]
# Generic actual list
lActual = []
@ -125,7 +123,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertEqual(lActual, lExpected)
def test_isPortDeclaration_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_port/port_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_port/port_test_input.vhd')
lExpected = [9,10,11,12,13,14,26,27,28,29,30,31,40,41,42,43,44,45,57,58,59,60,61,62,71,72,73,74,75,76,87,88,89,99,100,101,119,120,121,129,130,131]
# Generic actual list
lActual = []
@ -137,7 +135,7 @@ class testVhdlFileMethods(unittest.TestCase):
def test_insideGenericMap_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_generic/generic_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_generic/generic_test_input.vhd')
lExpected = [4,5,6,7,20,21,22,23,35,36,37,38,51,52,53,54,66,67,68,69,82,83,84,85,95,96,97,114,115,116,117]
# Generic actual list
lActual = []
@ -148,7 +146,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertEqual(lActual, lExpected)
def test_isGenericKeyword_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_generic/generic_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_generic/generic_test_input.vhd')
lExpected = [4,20,35,51,66,82,95,114]
# Generic actual list
lActual = []
@ -159,7 +157,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertEqual(lActual, lExpected)
def test_isEndGenericMap_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_generic/generic_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_generic/generic_test_input.vhd')
lExpected = [7,23,38,54,69,85,97,117]
# Generic actual list
lActual = []
@ -170,7 +168,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertEqual(lActual, lExpected)
def test_isPortDeclaration_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_generic/generic_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_generic/generic_test_input.vhd')
lExpected = [5,6,21,22,36,37,52,53,67,68,83,84,96,97,115,116]
# Generic actual list
lActual = []
@ -181,7 +179,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertEqual(lActual, lExpected)
def test_insideArchitecture_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_architecture/architecture_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_architecture/architecture_test_input.vhd')
lExpected = [3,4,5,6,7,9,10,11,12,13,14,15,16,17,18,20,21,22,23,24,26,27,28,29,30,31,33,34,35]
# Generic actual list
lActual = []
@ -192,7 +190,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertEqual(lActual, lExpected)
def test_isArchitectureBegin_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_architecture/architecture_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_architecture/architecture_test_input.vhd')
lExpected = [5,11,16,22,29,34]
# Generic actual list
lActual = []
@ -203,7 +201,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertEqual(lActual, lExpected)
def test_isArchitectureKeyword_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_architecture/architecture_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_architecture/architecture_test_input.vhd')
lExpected = [3,9,14,20,26,33]
# Generic actual list
lActual = []
@ -214,7 +212,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertEqual(lActual, lExpected)
def test_isEndArchitecture_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_architecture/architecture_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_architecture/architecture_test_input.vhd')
lExpected = [7,13,18,24,31,35]
# Generic actual list
lActual = []
@ -225,7 +223,7 @@ class testVhdlFileMethods(unittest.TestCase):
self.assertEqual(lActual, lExpected)
def test_isSignal_assignment(self):
oFile = vhdlFile.vhdlFile('../rule_signal/signal_test_input.vhd')
oFile = vhdlFile.vhdlFile('tests/rule_signal/signal_test_input.vhd')
lExpected = [5,6,7,8,9,10,11,12,13,14,15,16,18,19,20,21]
# Generic actual list
lActual = []