mirror of https://github.com/KLayout/klayout.git
Merge pull request #1292 from thomaslima/issue-1265
added test for issue 1265 (writing and reading pngs)
This commit is contained in:
commit
81ccc22600
|
|
@ -106,10 +106,10 @@ PYTHONTEST (dbLayoutToNetlist, "dbLayoutToNetlist.py")
|
||||||
PYTHONTEST (dbLayoutVsSchematic, "dbLayoutVsSchematic.py")
|
PYTHONTEST (dbLayoutVsSchematic, "dbLayoutVsSchematic.py")
|
||||||
PYTHONTEST (dbNetlistCrossReference, "dbNetlistCrossReference.py")
|
PYTHONTEST (dbNetlistCrossReference, "dbNetlistCrossReference.py")
|
||||||
PYTHONTEST (layLayers, "layLayers.py")
|
PYTHONTEST (layLayers, "layLayers.py")
|
||||||
|
PYTHONTEST (layPixelBuffer, "layPixelBuffer.py")
|
||||||
PYTHONTEST (tlTest, "tlTest.py")
|
PYTHONTEST (tlTest, "tlTest.py")
|
||||||
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
||||||
PYTHONTEST (qtbinding, "qtbinding.py")
|
PYTHONTEST (qtbinding, "qtbinding.py")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,20 +22,23 @@ import dbLayoutToNetlist
|
||||||
import dbLayoutVsSchematic
|
import dbLayoutVsSchematic
|
||||||
import dbNetlistCrossReference
|
import dbNetlistCrossReference
|
||||||
import layLayers
|
import layLayers
|
||||||
|
import layPixelBuffer
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(tlTest.TLTest)
|
loader = unittest.TestLoader()
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(dbPCells.DBPCellTests)
|
suite = unittest.TestSuite()
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(dbLayoutTest.DBLayoutTest)
|
suite.addTests(loader.loadTestsFromTestCase(tlTest.TLTest))
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(dbPolygonTest.DBPolygonTests)
|
suite.addTests(loader.loadTestsFromTestCase(dbPCells.DBPCellTests))
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(dbReaders.DBReadersTests)
|
suite.addTests(loader.loadTestsFromTestCase(dbLayoutTest.DBLayoutTest))
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(dbRegionTest.DBRegionTest)
|
suite.addTests(loader.loadTestsFromTestCase(dbPolygonTest.DBPolygonTests))
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(dbTransTest.DBTransTests)
|
suite.addTests(loader.loadTestsFromTestCase(dbReaders.DBReadersTests))
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(dbLayoutToNetlist.DBLayoutToNetlistTests)
|
suite.addTests(loader.loadTestsFromTestCase(dbRegionTest.DBRegionTest))
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(dbLayoutVsSchematic.DBLayoutVsSchematicTests)
|
suite.addTests(loader.loadTestsFromTestCase(dbTransTest.DBTransTests))
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(dbNetlistCrossReference.DBNetlistCrossReferenceTests)
|
suite.addTests(loader.loadTestsFromTestCase(dbLayoutToNetlist.DBLayoutToNetlistTests))
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(layLayers.LAYLayersTests)
|
suite.addTests(loader.loadTestsFromTestCase(dbLayoutVsSchematic.DBLayoutVsSchematicTests))
|
||||||
|
suite.addTests(loader.loadTestsFromTestCase(dbNetlistCrossReference.DBNetlistCrossReferenceTests))
|
||||||
|
suite.addTests(loader.loadTestsFromTestCase(layLayers.LAYLayersTests))
|
||||||
|
suite.addTests(loader.loadTestsFromTestCase(layPixelBuffer.LAYPixelBufferTests))
|
||||||
|
|
||||||
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
|
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,7 @@ end;
|
||||||
def test_13_ReadAndWrite(self):
|
def test_13_ReadAndWrite(self):
|
||||||
|
|
||||||
ut_testsrc = os.getenv("TESTSRC")
|
ut_testsrc = os.getenv("TESTSRC")
|
||||||
ut_testtmp = os.getenv("TESTTMP")
|
ut_testtmp = os.getenv("TESTTMP", "")
|
||||||
|
|
||||||
l2n = pya.LayoutToNetlist()
|
l2n = pya.LayoutToNetlist()
|
||||||
|
|
||||||
|
|
@ -725,4 +725,3 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
|
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ class DBLayoutVsSchematicTests(unittest.TestCase):
|
||||||
def test_3_ReadAndWrite(self):
|
def test_3_ReadAndWrite(self):
|
||||||
|
|
||||||
ut_testsrc = os.getenv("TESTSRC")
|
ut_testsrc = os.getenv("TESTSRC")
|
||||||
ut_testtmp = os.getenv("TESTTMP")
|
ut_testtmp = os.getenv("TESTTMP", "")
|
||||||
|
|
||||||
lvs = pya.LayoutVsSchematic()
|
lvs = pya.LayoutVsSchematic()
|
||||||
|
|
||||||
|
|
@ -181,4 +181,3 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
|
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
# KLayout Layout Viewer
|
||||||
|
# Copyright (C) 2006-2023 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 pya
|
||||||
|
import unittest
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
class LAYPixelBufferTests(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_4(self):
|
||||||
|
pb = pya.PixelBuffer(10, 20)
|
||||||
|
pb.transparent = True
|
||||||
|
pb.fill(0xf0010203)
|
||||||
|
|
||||||
|
png = pb.to_png_data()
|
||||||
|
|
||||||
|
# some range because implementations may differ
|
||||||
|
self.assertGreater(len(png), 20)
|
||||||
|
self.assertLess(len(png), 200)
|
||||||
|
pb_copy = pya.PixelBuffer.from_png_data(png)
|
||||||
|
self.assertEqual(pb, pb_copy)
|
||||||
|
|
||||||
|
ut_testtmp = os.getenv("TESTTMP", ".")
|
||||||
|
tmp = os.path.join(ut_testtmp, "tmp.png")
|
||||||
|
|
||||||
|
pb.write_png(tmp)
|
||||||
|
pb_copy = pya.PixelBuffer.read_png(tmp)
|
||||||
|
self.assertEqual(pb, pb_copy)
|
||||||
|
|
||||||
|
|
||||||
|
# run unit tests
|
||||||
|
if __name__ == '__main__':
|
||||||
|
suite = unittest.TestLoader().loadTestsFromTestCase(LAYPixelBufferTests)
|
||||||
|
|
||||||
|
if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful():
|
||||||
|
sys.exit(1)
|
||||||
Loading…
Reference in New Issue