Python module tests generalized

This commit is contained in:
Matthias Koefferlein 2022-05-15 20:17:23 +02:00
parent 104975a14e
commit 249642d5f3
7 changed files with 45 additions and 67 deletions

View File

@ -5,6 +5,7 @@ test-command = [
"python {package}/testdata/pymod/import_rdb.py",
"python {package}/testdata/pymod/import_tl.py",
"python {package}/testdata/pymod/import_lib.py",
"python {package}/testdata/pymod/import_lay.py",
"python {package}/testdata/pymod/pya_tests.py"
]
# Disable building PyPy wheels on all platforms
@ -24,4 +25,4 @@ environment-pass = ["HOST_CCACHE_DIR"]
[tool.cibuildwheel.macos]
# Don't repair macOS wheels
repair-wheel-command = ""
repair-wheel-command = ""

View File

@ -6,3 +6,4 @@ from klayout.db import * # noqa
from klayout.lib import * # noqa
from klayout.tl import * # noqa
from klayout.rdb import * # noqa
from klayout.lay import * # noqa

View File

@ -16,10 +16,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import testprep
import klayout.QtCore
import klayout.QtGui
if not "QApplication" in klayout.QtGui.__all__:
import klayout.QtWidgets # Qt5
import klayout.db as db
import klayout.lay as lay
import unittest
import sys
@ -29,15 +26,12 @@ import sys
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("Annotation" in lay.__all__, True)
def test_2(self):
# Some smoke test
ant = lay.Annotation()
ant.style = lay.Annotation.StyleRuler
self.assertEqual(str(ant.style), str(lay.Annotation.StyleRuler))
ant.fmt_x = "abc"
self.assertEqual(ant.fmt_x, "abc")
lv = lay.LayoutView()
lv.resize(800, 600)
lv.zoom_box(db.DBox(-42, -17, 142, 117))
bx = lv.box()
self.assertEqual(str(bx), "(-42.09,-19.09;141.91,118.91)")
# run unit tests
if __name__ == '__main__':

View File

@ -18,6 +18,10 @@ import dbPolygonTest
import dbReaders
import dbRegionTest
import dbTransTest
import dbLayoutToNetlist
import dbLayoutVsSchematic
import dbNetlistCrossReference
import layLayers
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(tlTest.TLTest)
@ -27,6 +31,10 @@ if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(dbReaders.DBReadersTests)
suite = unittest.TestLoader().loadTestsFromTestCase(dbRegionTest.DBRegionTest)
suite = unittest.TestLoader().loadTestsFromTestCase(dbTransTest.DBTransTests)
suite = unittest.TestLoader().loadTestsFromTestCase(dbLayoutToNetlist.DBLayoutToNetlistTests)
suite = unittest.TestLoader().loadTestsFromTestCase(dbLayoutVsSchematic.DBLayoutVsSchematicTests)
suite = unittest.TestLoader().loadTestsFromTestCase(dbNetlistCrossReference.DBNetlistCrossReferenceTests)
suite = unittest.TestLoader().loadTestsFromTestCase(layLayers.LAYLayersTests)
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
sys.exit(1)

View File

@ -23,7 +23,7 @@ import unittest
import sys
import os
class DBLayoutToNetlistTests(unittest.TestCase):
class DBLayoutVsSchematicTests(unittest.TestCase):
def test_1_Basic(self):

View File

@ -23,7 +23,7 @@ import unittest
import sys
import os
class DBLayoutToNetlistTests(unittest.TestCase):
class DBNetlistCrossReferenceTests(unittest.TestCase):
def test_1_Basic(self):

View File

@ -27,7 +27,7 @@ def astr(a):
astr.append(str(i))
return "[" + ", ".join(astr) + "]"
class LAYLayersTest(unittest.TestCase):
class LAYLayersTests(unittest.TestCase):
def lnode_str(self, space, l):
return space + l.current().source_(True) + "\n";
@ -57,14 +57,9 @@ class LAYLayersTest(unittest.TestCase):
def test_1(self):
app = pya.Application.instance()
mw = app.main_window()
mw.close_all()
mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", 1)
mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", 2)
cv = mw.current_view()
cv = pya.LayoutView()
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True)
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", True)
cv.clear_layers()
@ -203,18 +198,15 @@ class LAYLayersTest(unittest.TestCase):
self.assertEqual(self.lnodes_str("", cv.begin_layers()), "*/*@*\n 1/0@1\n 1/0@2\n%5@2\n %5@2\n")
mw.close_all()
cv._destroy()
def test_1a(self):
app = pya.Application.instance()
mw = app.main_window()
mw.close_all()
mgr = pya.Manager()
mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", 1)
mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", 2)
cv = mw.current_view()
cv = pya.LayoutView(False, mgr)
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True)
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", True)
cv.clear_layers()
@ -396,7 +388,7 @@ class LAYLayersTest(unittest.TestCase):
cv.delete_layers(0, a)
self.assertEqual(cv.begin_layers(0).at_end(), True)
cv.commit()
mw.cm_undo()
mgr.undo()
self.assertEqual(cv.begin_layers(0).at_end(), False)
cv.transaction("Delete")
@ -407,10 +399,10 @@ class LAYLayersTest(unittest.TestCase):
self.assertEqual(i, 2)
self.assertEqual(cv.begin_layers(0).at_end(), True)
cv.commit()
mw.cm_undo()
mgr.undo()
self.assertEqual(cv.begin_layers(0).at_end(), False)
mw.close_all()
cv._destroy()
def test_2(self):
@ -655,14 +647,10 @@ class LAYLayersTest(unittest.TestCase):
# direct replacement of objects and attributes
def test_3(self):
app = pya.Application.instance()
mw = app.main_window()
mw.close_all()
cv = pya.LayoutView()
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", pya.LoadLayoutOptions(), "", True)
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", pya.LoadLayoutOptions(), "", True)
mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", pya.LoadLayoutOptions(), "", 1)
mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", pya.LoadLayoutOptions(), "", 2)
cv = mw.current_view()
self.assertEqual(self.lnodes_str("", cv.begin_layers()), "1/0@1\n2/0@1\n1/0@2\n2/0@2\n3/0@2\n3/1@2\n4/0@2\n5/0@2\n6/0@2\n6/1@2\n7/0@2\n8/0@2\n8/1@2\n")
cv.clear_layers()
@ -772,19 +760,14 @@ class LAYLayersTest(unittest.TestCase):
self.assertEqual(self.lnodes_str("", cv.begin_layers()), "TOP@1\n nn1@1\n nn1@1\n")
self.assertEqual(self.lnodes_str2(cv), "TOP@1\nnn1@1\nnn1@1")
mw.close_all()
cv._destroy()
# propagation of "real" attributes through the hierarchy
def test_4(self):
app = pya.Application.instance()
mw = app.main_window()
mw.close_all()
mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", 1)
mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", 2)
cv = mw.current_view()
cv = pya.LayoutView()
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True)
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", True)
cv.clear_layers()
@ -807,18 +790,14 @@ class LAYLayersTest(unittest.TestCase):
self.assertEqual(pos.first_child().current().visible_(True), False)
self.assertEqual(pos.first_child().current().visible_(False), True)
mw.close_all()
cv._destroy()
# delete method of iterator
def test_5(self):
app = pya.Application.instance()
mw = app.main_window()
mw.close_all()
cv = pya.LayoutView()
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True)
mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", 1)
cv = mw.current_view()
cv.clear_layers()
new_p = pya.LayerProperties()
@ -899,18 +878,13 @@ class LAYLayersTest(unittest.TestCase):
self.assertEqual(pc.at_end(), True)
self.assertEqual(pc.current().is_valid(), False)
mw.close_all()
cv._destroy()
# custom stipples and line styles
def test_6(self):
app = pya.Application.instance()
mw = app.main_window()
mw.close_all()
mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", 1)
cv = mw.current_view()
cv = pya.LayoutView()
cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True)
cv.clear_stipples()
@ -944,7 +918,7 @@ class LAYLayersTest(unittest.TestCase):
cv.clear_line_styles()
self.assertEqual(cv.get_line_style(index), "")
mw.close_all()
cv._destroy()
# run unit tests