WIP: unit tests for pykl, some build errors fixed.

This commit is contained in:
Matthias Koefferlein 2018-06-03 23:36:06 +02:00
parent 655e59d11a
commit f3f6e2e7ba
19 changed files with 751 additions and 0 deletions

View File

@ -539,6 +539,7 @@ qmake_options=(
RUBYINCLUDE2="$RUBYINCLUDE2"
RUBYVERSIONCODE="$RUBYVERSIONCODE"
HAVE_RUBY="$HAVE_RUBY"
PYTHON="$PYTHON"
PYTHONLIBFILE="$PYTHONLIBFILE"
PYTHONINCLUDE="$PYTHONINCLUDE"
HAVE_PYTHON="$HAVE_PYTHON"

View File

@ -12,6 +12,12 @@ DEPENDPATH += $$TL_INC $$GSI_INC $$QTBASIC_INC
LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_qtbasic
# because QQbject is used as base class for many classes, we need this:
LIBS += -lklayout_QtCore
# because QWidget is used for some UI stuff, we need this:
LIBS += -lklayout_QtWidgets
SOURCES += \
HEADERS += \

View File

@ -33,3 +33,7 @@ equals(HAVE_QTBINDINGS, "1") {
}
}
ALL_DIRS = $$SUBDIRS
SUBDIRS += unit_tests
unit_tests.depends += $$ALL_DIRS

View File

@ -0,0 +1,74 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2018 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
*/
#define STRINGIFY(s) _STRINGIFY(s)
#define _STRINGIFY(s) #s
#include "tlUnitTest.h"
#include <QProcess>
#include <QProcessEnvironment>
int run_pymodtest (tl::TestBase * /*_this*/, const std::string &fn)
{
QProcess process;
process.setProcessChannelMode (QProcess::ForwardedChannels);
QStringList args;
std::string fp (tl::testsrc ());
fp += "/testdata/pymod/";
fp += fn;
args << tl::to_qstring (fp);
QProcessEnvironment env = QProcessEnvironment::systemEnvironment ();
env.insert("PYTHONPATH", STRINGIFY(PYTHONPATH));
process.setProcessEnvironment(env);
process.start (tl::to_qstring (STRINGIFY (PYTHON)), args);
process.waitForFinished (-1);
return process.exitCode ();
}
#define PYMODTEST(n, file) \
TEST(n) { EXPECT_EQ (run_pymodtest(_this, file), 0); }
PYMODTEST (import_tl, "import_tl.py")
PYMODTEST (import_db, "import_db.py")
PYMODTEST (import_lay, "import_lay.py")
PYMODTEST (import_QtCore, "import_QtCore.py")
PYMODTEST (import_QtGui, "import_QtGui.py")
PYMODTEST (import_QtXml, "import_QtXml.py")
PYMODTEST (import_QtSql, "import_QtSql.py")
PYMODTEST (import_QtNetwork, "import_QtNetwork.py")
PYMODTEST (import_QtDesigner, "import_QtDesigner.py")
#if QT_VERSION >= 0x50000
PYMODTEST (import_QtWidgets, "import_QtWidgets.py")
PYMODTEST (import_QtMultimedia, "import_QtMultimedia.py")
PYMODTEST (import_QtPrintSupport, "import_QtPrintSupport.py")
PYMODTEST (import_QtSvg, "import_QtSvg.py")
PYMODTEST (import_QtXmlPatterns, "import_QtXmlPatterns.py")
#endif

View File

@ -0,0 +1,20 @@
DESTDIR_UT = $$OUT_PWD/../..
TARGET = bd_tests
include($$PWD/../../klayout.pri)
include($$PWD/../../lib_ut.pri)
SOURCES = \
pymod_tests.cc
DEFINES += \
PYTHON=$$PYTHON \
PYTHONPATH=$$DESTDIR_UT
INCLUDEPATH += $$BD_INC $$DB_INC $$TL_INC $$GSI_INC
DEPENDPATH += $$BD_INC $$DB_INC $$TL_INC $$GSI_INC
LIBS += -L$$DESTDIR_UT -lklayout_bd -lklayout_db -lklayout_tl -lklayout_gsi

47
testdata/pymod/import_QtCore.py vendored Normal file
View File

@ -0,0 +1,47 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2018 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 pykl.QtCore as QtCore
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("QBuffer" in QtCore.__all__, True)
def test_2(self):
# Some smoke test
b = QtCore.QBuffer()
b.setData("all you can eat")
b.open(QtCore.QIODevice.ReadOnly)
self.assertEqual(b.read(3), "all")
b.read(1)
self.assertEqual(b.read(3), "you")
# 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)

42
testdata/pymod/import_QtDesigner.py vendored Normal file
View File

@ -0,0 +1,42 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2018 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 pykl.QtCore as QtCore
import pykl.QtDesigner as QtDesigner
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("QFormBuilder" in QtDesigner.__all__, True)
def test_2(self):
q = QtDesigner.QFormBuilder()
# 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_QtGui.py vendored Normal file
View File

@ -0,0 +1,48 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2018 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 pykl.QtCore
import pykl.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)
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)
# 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)

44
testdata/pymod/import_QtMultimedia.py vendored Normal file
View File

@ -0,0 +1,44 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2018 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 pykl.QtCore as QtCore
import pykl.QtGui as QtGui
import pykl.QtWidgets as QtWidgets
import pykl.QtMultimedia as QtMultimedia
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("QVideoFrame" in QtMultimedia.__all__, True)
def test_2(self):
q = QtMultimedia.QVideoFrame()
# 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)

44
testdata/pymod/import_QtNetwork.py vendored Normal file
View File

@ -0,0 +1,44 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2018 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 pykl.QtCore as QtCore
import pykl.QtNetwork as QtNetwork
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("QNetworkRequest" in QtNetwork.__all__, True)
def test_2(self):
q = QtNetwork.QNetworkRequest()
q.setRawHeader("abc", "xyz")
self.assertEqual(q.rawHeader("abc"), "xyz")
# 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_QtPrintSupport.py vendored Normal file
View File

@ -0,0 +1,45 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2018 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 pykl.QtCore as QtCore
import pykl.QtGui as QtGui
import pykl.QtWidgets as QtWidgets
import pykl.QtPrintSupport as QtPrintSupport
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("QPrinter" in QtPrintSupport.__all__, True)
def test_2(self):
app = QtCore.QCoreApplication([ "progname" ])
q = QtPrintSupport.QPrinter()
# 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)

42
testdata/pymod/import_QtSql.py vendored Normal file
View File

@ -0,0 +1,42 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2018 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 pykl.QtCore as QtCore
import pykl.QtSql as QtSql
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("QSqlQuery" in QtSql.__all__, True)
def test_2(self):
q = QtSql.QSqlQuery()
# 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.py vendored Normal file
View File

@ -0,0 +1,45 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2018 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 pykl.QtCore as QtCore
import pykl.QtGui as QtGui
import pykl.QtWidgets as QtWidgets
import pykl.QtSvg as QtSvg
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("QSvgWidget" in QtSvg.__all__, True)
def test_2(self):
app = QtWidgets.QApplication([ "progname" ])
q = QtSvg.QSvgWidget()
# 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)

56
testdata/pymod/import_QtWidgets.py vendored Normal file
View File

@ -0,0 +1,56 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2018 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 pykl.QtCore as QtCore
import pykl.QtGui as QtGui
import pykl.QtWidgets as QtWidgets
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
trg = 0
def test_1(self):
self.assertEqual("QAction" in QtWidgets.__all__, True)
def onTrigger(self):
self.trg += 17
def test_2(self):
a = QtWidgets.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)

50
testdata/pymod/import_QtXml.py vendored Normal file
View File

@ -0,0 +1,50 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2018 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 pykl.QtCore as QtCore
import pykl.QtXml as QtXml
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("QDomDocument" in QtXml.__all__, True)
def test_2(self):
# Some smoke test
b = QtCore.QBuffer()
b.setData("<doc><e>abc</e></doc>")
b.open(QtCore.QIODevice.ReadOnly)
doc = QtXml.QDomDocument()
doc.setContent(b)
b.close()
self.assertEqual(doc.documentElement().tagName, "doc")
self.assertEqual(doc.documentElement().firstChild().toElement().tagName, "e")
# 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)

42
testdata/pymod/import_QtXmlPatterns.py vendored Normal file
View File

@ -0,0 +1,42 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2018 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 pykl.QtCore as QtCore
import pykl.QtXmlPatterns as QtXmlPatterns
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("QXmlItem" in QtXmlPatterns.__all__, True)
def test_2(self):
q = QtXmlPatterns.QXmlItem()
# 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_db.py vendored Normal file
View File

@ -0,0 +1,45 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2018 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 pykl.db as db
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("Box" in db.__all__, True)
def test_2(self):
# Some smoke test
v = db.Box()
self.assertEqual(str(v), "()")
v = db.Box(1, 2, 3, 4)
self.assertEqual(str(v), "(1,2;3,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)

49
testdata/pymod/import_lay.py vendored Normal file
View File

@ -0,0 +1,49 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2018 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 pykl.QtCore
import pykl.QtGui
import pykl.QtWidgets
import pykl.lay as lay
import unittest
import sys
# Tests the basic abilities of the module
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")
# 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)

47
testdata/pymod/import_tl.py vendored Normal file
View File

@ -0,0 +1,47 @@
# KLayout Layout Viewer
# Copyright (C) 2006-2018 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 pykl.tl as tl
import unittest
import sys
# Tests the basic abilities of the module
class BasicTest(unittest.TestCase):
def test_1(self):
self.assertEqual("Value" in tl.__all__, True)
def test_2(self):
# Some smoke test
v = tl.Value()
self.assertEqual(v.value, None)
v = tl.Value(1)
self.assertEqual(v.value, 1)
v = tl.Value("abc")
self.assertEqual(v.value, "abc")
# 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)