Fixed pymod tests

This commit is contained in:
Matthias Koefferlein 2021-12-10 01:23:54 +01:00
parent f15db66fc4
commit 0aca56b1c6
6 changed files with 223 additions and 2 deletions

View File

@ -13,6 +13,8 @@ DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC $$QTBASIC_INC
LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_qtbasic
LIBS += -lklayout_QtCore
SOURCES += \
HEADERS += \

View File

@ -93,7 +93,11 @@ PYMODTEST (import_rdb, "import_rdb.py")
PYMODTEST (import_lay, "import_lay.py")
PYMODTEST (import_QtCore, "import_QtCore.py")
#if QT_VERSION >= 0x60000
PYMODTEST (import_QtGui, "import_QtGui_Qt6.py")
#else
PYMODTEST (import_QtGui, "import_QtGui.py")
#endif
#if defined(HAVE_QT_XML)
PYMODTEST (import_QtXml, "import_QtXml.py")
#endif
@ -103,7 +107,7 @@ PYMODTEST (import_QtSql, "import_QtSql.py")
#if defined(HAVE_QT_NETWORK)
PYMODTEST (import_QtNetwork, "import_QtNetwork.py")
#endif
#if defined(HAVE_QT_DESIGNER)
#if defined(HAVE_QT_DESIGNER) && QT_VERSION < 0x60000
PYMODTEST (import_QtDesigner, "import_QtDesigner.py")
#endif
#if defined(HAVE_QT_UITOOLS)
@ -112,7 +116,11 @@ PYMODTEST (import_QtUiTools, "import_QtUiTools.py")
#if QT_VERSION >= 0x50000
#if QT_VERSION >= 0x60000
PYMODTEST (import_QtWidgets, "import_QtWidgets_Qt6.py")
#else
PYMODTEST (import_QtWidgets, "import_QtWidgets.py")
#endif
#if defined(HAVE_QT_MULTIMEDIA)
PYMODTEST (import_QtMultimedia, "import_QtMultimedia.py")
#endif
@ -120,12 +128,20 @@ PYMODTEST (import_QtMultimedia, "import_QtMultimedia.py")
PYMODTEST (import_QtPrintSupport, "import_QtPrintSupport.py")
#endif
#if defined(HAVE_QT_SVG)
#if QT_VERSION >= 0x60000
PYMODTEST (import_QtSvg, "import_QtSvg_Qt6.py")
#else
PYMODTEST (import_QtSvg, "import_QtSvg.py")
#endif
#if defined(HAVE_QT_XML)
#endif
#if defined(HAVE_QT_XML) && QT_VERSION < 0x60000
PYMODTEST (import_QtXmlPatterns, "import_QtXmlPatterns.py")
#endif
#if QT_VERSION >= 0x50000
PYMODTEST (import_QtCore5Compat, "import_QtCore5Compat.py")
#endif
#endif
PYMODTEST (import_pya, "pya_tests.py")

43
testdata/pymod/import_QtCore5Compat.py vendored Executable file
View File

@ -0,0 +1,43 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2021 Matthias Koefferlein
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import testprep
import klayout.QtCore5Compat as QtCore5Compat
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("QRegExp" in QtCore5Compat.__all__, True)
def test_2(self):
# Some smoke test
re = QtCore5Compat.QRegExp("a.*b")
self.assertEqual(re.indexIn("xauby"), 1)
# run unit tests
if __name__ == '__main__':
suite = unittest.TestSuite()
suite = unittest.TestLoader().loadTestsFromTestCase(BasicTest)
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
sys.exit(1)

67
testdata/pymod/import_QtGui_Qt6.py vendored Executable file
View File

@ -0,0 +1,67 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2021 Matthias Koefferlein
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import testprep
import klayout.QtCore as QtCore
import klayout.QtWidgets as QtWidgets
import klayout.QtGui as QtGui
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("QColor" in QtGui.__all__, True)
self.assertEqual("QAction" in QtGui.__all__, True)
def test_2(self):
# Some smoke test
v = QtGui.QColor(12, 34, 68)
self.assertEqual(v.red, 12)
v.red = 17
self.assertEqual(v.red, 17)
self.assertEqual(v.green, 34)
self.assertEqual(v.blue, 68)
trg = 0
def onTrigger(self):
self.trg += 17
def test_3(self):
app = QtWidgets.QApplication([ "progname" ])
a = QtGui.QAction(None)
a.text = "myaction"
self.assertEqual(a.text, "myaction")
self.trg = 0
a.triggered = self.onTrigger
a.trigger()
self.assertEqual(self.trg, 17)
a.trigger()
self.assertEqual(self.trg, 34)
# run unit tests
if __name__ == '__main__':
suite = unittest.TestSuite()
suite = unittest.TestLoader().loadTestsFromTestCase(BasicTest)
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
sys.exit(1)

45
testdata/pymod/import_QtSvg_Qt6.py vendored Executable file
View File

@ -0,0 +1,45 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2021 Matthias Koefferlein
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import testprep
import klayout.QtCore as QtCore
import klayout.QtGui as QtGui
import klayout.QtWidgets as QtWidgets
import klayout.QtSvg as QtSvg
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("QSvgRenderer" in QtSvg.__all__, True)
def test_2(self):
# Smoke test
q = QtSvg.QSvgRenderer()
# run unit tests
if __name__ == '__main__':
suite = unittest.TestSuite()
suite = unittest.TestLoader().loadTestsFromTestCase(BasicTest)
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
sys.exit(1)

48
testdata/pymod/import_QtWidgets_Qt6.py vendored Executable file
View File

@ -0,0 +1,48 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2021 Matthias Koefferlein
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import testprep
import klayout.QtCore as QtCore
import klayout.QtGui as QtGui
import klayout.QtWidgets as QtWidgets
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("QGraphicsLineItem" in QtWidgets.__all__, True)
def test_2(self):
i = QtWidgets.QGraphicsLineItem()
i.line = QtCore.QLineF(1, 2, 3, 4)
self.assertEqual(i.line.x1(), 1)
self.assertEqual(i.line.y1(), 2)
self.assertEqual(i.line.x2(), 3)
self.assertEqual(i.line.y2(), 4)
# run unit tests
if __name__ == '__main__':
suite = unittest.TestSuite()
suite = unittest.TestLoader().loadTestsFromTestCase(BasicTest)
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
sys.exit(1)