mirror of
https://github.com/KLayout/klayout.git
synced 2026-08-30 01:39:30 +02:00
Unit tests fixed after #526 update.
This commit is contained in:
Vendored
+11
-5
@@ -20,6 +20,12 @@ import pya
|
||||
import unittest
|
||||
import sys
|
||||
|
||||
def astr(a):
|
||||
astr = []
|
||||
for i in a:
|
||||
astr.append(str(i))
|
||||
return "[" + ", ".join(astr) + "]"
|
||||
|
||||
class TLTest(unittest.TestCase):
|
||||
|
||||
def test_1(self):
|
||||
@@ -114,7 +120,7 @@ class TLTest(unittest.TestCase):
|
||||
expr = pya.Expression("x=a&b; y=x; z=y; [x,y,z]", { "a": box1, "b": box2, "x": None, "y": None, "z": None })
|
||||
res = expr.eval()
|
||||
|
||||
self.assertEqual(str(res), "[(50,150;200,300), (50,150;200,300), (50,150;200,300)]")
|
||||
self.assertEqual(astr(res), "[(50,150;200,300), (50,150;200,300), (50,150;200,300)]")
|
||||
|
||||
# all objects are individual copies
|
||||
self.assertNotEqual(id(res[0]), id(box1))
|
||||
@@ -129,7 +135,7 @@ class TLTest(unittest.TestCase):
|
||||
expr = pya.Expression("var x=a&b; var y=x; var z=y; [x,y,z]", { "a": box1, "b": box2 })
|
||||
res = expr.eval()
|
||||
|
||||
self.assertEqual(str(res), "[(50,150;200,300), (50,150;200,300), (50,150;200,300)]")
|
||||
self.assertEqual(astr(res), "[(50,150;200,300), (50,150;200,300), (50,150;200,300)]")
|
||||
|
||||
# all objects are individual copies
|
||||
self.assertNotEqual(id(res[0]), id(box1))
|
||||
@@ -139,7 +145,7 @@ class TLTest(unittest.TestCase):
|
||||
|
||||
# destruction of the expression's object space does not matter since we have copies
|
||||
expr._destroy()
|
||||
self.assertEqual(str(res), "[(50,150;200,300), (50,150;200,300), (50,150;200,300)]")
|
||||
self.assertEqual(astr(res), "[(50,150;200,300), (50,150;200,300), (50,150;200,300)]")
|
||||
|
||||
# -------------------------------------------------
|
||||
|
||||
@@ -178,7 +184,7 @@ class TLTest(unittest.TestCase):
|
||||
expr = pya.Expression("x=a&b; y=x; z=y; [x,y,z]", { "a": region1, "b": region2, "x": None, "y": None, "z": None })
|
||||
res = expr.eval()
|
||||
|
||||
self.assertEqual(str(res), "[(50,150;50,300;200,300;200,150), (50,150;50,300;200,300;200,150), (50,150;50,300;200,300;200,150)]")
|
||||
self.assertEqual(astr(res), "[(50,150;50,300;200,300;200,150), (50,150;50,300;200,300;200,150), (50,150;50,300;200,300;200,150)]")
|
||||
|
||||
# regions are managed objects -> passing the object through the expression persists it's object ID
|
||||
self.assertNotEqual(id(res[0]), id(region1))
|
||||
@@ -195,7 +201,7 @@ class TLTest(unittest.TestCase):
|
||||
expr = pya.Expression("var x=a&b; var y=x; var z=y; [x,y,z]", { "a": region1, "b": region2 })
|
||||
res = expr.eval()
|
||||
|
||||
self.assertEqual(str(res), "[(50,150;50,300;200,300;200,150), (50,150;50,300;200,300;200,150), (50,150;50,300;200,300;200,150)]")
|
||||
self.assertEqual(astr(res), "[(50,150;50,300;200,300;200,150), (50,150;50,300;200,300;200,150), (50,150;50,300;200,300;200,150)]")
|
||||
|
||||
# regions are managed objects -> passing the object through the expression persists it's object ID
|
||||
self.assertNotEqual(id(res[0]), id(region1))
|
||||
|
||||
Reference in New Issue
Block a user