aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Lehmann <Patrick.Lehmann@plc2.de>2020-12-28 18:17:24 +0100
committerPatrick Lehmann <Patrick.Lehmann@plc2.de>2020-12-28 18:17:24 +0100
commit1c912a59c73a1ecb4c8b4d5d16bfc097d63d8546 (patch)
tree569a35810d19ce128c3a518e78af22ad91de0dab
parentcb9c6cf42ecfd89272d7cb7d3c7f490d4147b6e3 (diff)
downloadghdl-1c912a59c73a1ecb4c8b4d5d16bfc097d63d8546.tar.gz
ghdl-1c912a59c73a1ecb4c8b4d5d16bfc097d63d8546.tar.bz2
ghdl-1c912a59c73a1ecb4c8b4d5d16bfc097d63d8546.zip
Improved testcase ' SimpleEntity' for pyGHDL.dom.
-rw-r--r--pyGHDL/dom/Misc.py4
-rw-r--r--testsuite/pyunit/dom/SimpleEntity.py28
-rw-r--r--testsuite/pyunit/libghdl/Initialize.py2
3 files changed, 25 insertions, 9 deletions
diff --git a/pyGHDL/dom/Misc.py b/pyGHDL/dom/Misc.py
index ab47576fc..82c1f8fac 100644
--- a/pyGHDL/dom/Misc.py
+++ b/pyGHDL/dom/Misc.py
@@ -45,10 +45,12 @@ class Document(VHDLModel_Document):
__ghdlSourceFileEntry: Any
__ghdlFile: Any
- def __init__(self, path : Path = None):
+ def __init__(self, path : Path = None, dontParse: bool = False):
super().__init__(path)
self.__ghdl_init()
+ if (dontParse == False):
+ self.parse()
def __ghdl_init(self):
# Read input file
diff --git a/testsuite/pyunit/dom/SimpleEntity.py b/testsuite/pyunit/dom/SimpleEntity.py
index 429c1a5a8..046d5ceff 100644
--- a/testsuite/pyunit/dom/SimpleEntity.py
+++ b/testsuite/pyunit/dom/SimpleEntity.py
@@ -1,7 +1,8 @@
from pathlib import Path
from unittest import TestCase
-from pyVHDLModel.VHDLModel import Design, Library, Document, Entity
+from pyGHDL.dom.Misc import Design, Library, Document
+from pyGHDL.dom.DesignUnit import Entity, Architecture
if __name__ == "__main__":
@@ -10,16 +11,29 @@ if __name__ == "__main__":
exit(1)
-class Instantiate(TestCase):
+class SimpleEntity(TestCase):
+ _path: Path = Path("testsuite/pyunit/SimpleEntity.vhdl")
+
def test_Design(self):
design = Design()
- def test_Library(self):
- library = Library()
+ self.assertIsNotNone(design)
+
+ # def test_Library(self):
+ # library = Library()
def test_Document(self):
- path = Path("tests.vhdl")
- document = Document(path)
+ design = Design()
+ document = Document(self._path)
+ design.Documents.append(document)
+
+ self.assertTrue(len(design.Documents) == 1)
def test_Entity(self):
- entity = Entity("entity_1")
+ design = Design()
+ document = Document(self._path)
+ design.Documents.append(document)
+
+ self.assertEqual(len(design.Documents[0].Entities), 1)
+ self.assertTrue(design.Documents[0].Entities[0].Name == "e1")
+
diff --git a/testsuite/pyunit/libghdl/Initialize.py b/testsuite/pyunit/libghdl/Initialize.py
index 1db2eed18..8bbc0e954 100644
--- a/testsuite/pyunit/libghdl/Initialize.py
+++ b/testsuite/pyunit/libghdl/Initialize.py
@@ -16,7 +16,7 @@ if __name__ == "__main__":
class Instantiate(TestCase):
- _filename : Path = Path("testsuite/pyunit/libghdl/simpleEntity.vhdl")
+ _filename : Path = Path("testsuite/pyunit/SimpleEntity.vhdl")
@staticmethod
def getIdentifier(node):