Ghost an object to save the dict
(self)
| 36 | |
| 37 | class TestGhost(Testing.vtkTest): |
| 38 | def testGhostForDict(self): |
| 39 | """Ghost an object to save the dict""" |
| 40 | o = vtkObject() |
| 41 | o.customattr = 'hello' |
| 42 | a = vtkVariantArray() |
| 43 | a.InsertNextValue(o) |
| 44 | i = id(o) |
| 45 | del o |
| 46 | |
| 47 | # Force garbage collection to ensure object is deallocated |
| 48 | # This is especially important in free-threading mode |
| 49 | if hasattr(sys, "_is_gil_enabled") and not sys._is_gil_enabled(): |
| 50 | gc.collect() |
| 51 | |
| 52 | o = vtkObject() |
| 53 | o = a.GetValue(0).ToVTKObject() |
| 54 | # make sure the id has changed, but dict the same |
| 55 | self.assertEqual(o.customattr, 'hello') |
| 56 | self.assertNotEqual(i, id(o)) |
| 57 | |
| 58 | def testGhostForClass(self): |
| 59 | """Ghost an object to save the class""" |
nothing calls this directly
no test coverage detected