mirror of
https://github.com/KLayout/klayout.git
synced 2026-08-29 01:14:35 +02:00
Fixed issue #2396 (support weak refs in Python)
This commit is contained in:
Vendored
+15
@@ -22,6 +22,7 @@ import os
|
||||
import sys
|
||||
import gc
|
||||
import copy
|
||||
import weakref
|
||||
|
||||
# Set this to True to disable some tests involving exceptions
|
||||
leak_check = "TEST_LEAK_CHECK" in os.environ
|
||||
@@ -3352,6 +3353,20 @@ class BasicTest(unittest.TestCase):
|
||||
self.assertEqual(bc.str(), "xyz")
|
||||
self.assertEqual(bnc.str(), "xyz")
|
||||
|
||||
# weak refs
|
||||
def test_94(self):
|
||||
|
||||
b = pya.B()
|
||||
b.set_str("abc")
|
||||
|
||||
r = weakref.ref(b)
|
||||
self.assertEqual(r() is None, False)
|
||||
self.assertEqual(r().str(), "abc")
|
||||
|
||||
b = None
|
||||
self.assertEqual(r() is None, True)
|
||||
|
||||
|
||||
# run unit tests
|
||||
if __name__ == '__main__':
|
||||
suite = unittest.TestSuite()
|
||||
|
||||
Reference in New Issue
Block a user