diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/line/__init__.py b/tests/line/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/line/line_tests.py b/tests/line/test_line.py similarity index 98% rename from tests/line/line_tests.py rename to tests/line/test_line.py index 9302013b..dfcb0acc 100644 --- a/tests/line/line_tests.py +++ b/tests/line/test_line.py @@ -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): diff --git a/tests/rule_architecture/__init__.py b/tests/rule_architecture/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/rule_architecture/rule_architecture_tests.py b/tests/rule_architecture/test_rule_architecture.py similarity index 97% rename from tests/rule_architecture/rule_architecture_tests.py rename to tests/rule_architecture/test_rule_architecture.py index 87cfc904..be9559c0 100644 --- a/tests/rule_architecture/rule_architecture_tests.py +++ b/tests/rule_architecture/test_rule_architecture.py @@ -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): diff --git a/tests/rule_entity/__init__.py b/tests/rule_entity/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/rule_entity/rule_entity_tests.py b/tests/rule_entity/test_rule_entity.py similarity index 97% rename from tests/rule_entity/rule_entity_tests.py rename to tests/rule_entity/test_rule_entity.py index 03b3276f..bd7189f6 100644 --- a/tests/rule_entity/rule_entity_tests.py +++ b/tests/rule_entity/test_rule_entity.py @@ -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): diff --git a/tests/rule_generic/__init__.py b/tests/rule_generic/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/rule_generic/rule_generic_tests.py b/tests/rule_generic/test_rule_generic.py similarity index 96% rename from tests/rule_generic/rule_generic_tests.py rename to tests/rule_generic/test_rule_generic.py index 30c1d637..f9a54421 100644 --- a/tests/rule_generic/rule_generic_tests.py +++ b/tests/rule_generic/test_rule_generic.py @@ -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): diff --git a/tests/rule_library/__init__.py b/tests/rule_library/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/rule_library/rule_library_tests.py b/tests/rule_library/test_rule_library.py similarity index 90% rename from tests/rule_library/rule_library_tests.py rename to tests/rule_library/test_rule_library.py index c12e5743..68897a08 100644 --- a/tests/rule_library/rule_library_tests.py +++ b/tests/rule_library/test_rule_library.py @@ -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): diff --git a/tests/rule_port/__init__.py b/tests/rule_port/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/rule_port/rule_port_tests.py b/tests/rule_port/test_rule_port.py similarity index 97% rename from tests/rule_port/rule_port_tests.py rename to tests/rule_port/test_rule_port.py index 1c7e15c8..f45b718f 100644 --- a/tests/rule_port/rule_port_tests.py +++ b/tests/rule_port/test_rule_port.py @@ -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): diff --git a/tests/rule_signal/__init__.py b/tests/rule_signal/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/rule_signal/rule_signal_tests.py b/tests/rule_signal/test_rule_signal.py similarity index 96% rename from tests/rule_signal/rule_signal_tests.py rename to tests/rule_signal/test_rule_signal.py index 9401cd98..35845a93 100644 --- a/tests/rule_signal/rule_signal_tests.py +++ b/tests/rule_signal/test_rule_signal.py @@ -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): diff --git a/tests/rule_whitespace/__init__.py b/tests/rule_whitespace/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/rule_whitespace/rule_whitespace_001.py b/tests/rule_whitespace/test_rule_whitespace.py similarity index 87% rename from tests/rule_whitespace/rule_whitespace_001.py rename to tests/rule_whitespace/test_rule_whitespace.py index d9e71c44..bb718a57 100644 --- a/tests/rule_whitespace/rule_whitespace_001.py +++ b/tests/rule_whitespace/test_rule_whitespace.py @@ -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,')) diff --git a/tests/vhdlFile/__init__.py b/tests/vhdlFile/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/vhdlFile/vhdlFile_tests.py b/tests/vhdlFile/test_vhdlFile.py similarity index 80% rename from tests/vhdlFile/vhdlFile_tests.py rename to tests/vhdlFile/test_vhdlFile.py index 516e2cf8..64664ece 100644 --- a/tests/vhdlFile/vhdlFile_tests.py +++ b/tests/vhdlFile/test_vhdlFile.py @@ -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 = []