MCPcopy Create free account
hub / github.com/Kitware/VTK / testGhostForDict

Method testGhostForDict

Common/Core/Testing/Python/TestGhost.py:38–56  ·  view source on GitHub ↗

Ghost an object to save the dict

(self)

Source from the content-addressed store, hash-verified

36
37class 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"""

Callers

nothing calls this directly

Calls 6

idFunction · 0.85
vtkObjectClass · 0.50
vtkVariantArrayClass · 0.50
InsertNextValueMethod · 0.45
ToVTKObjectMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected