예제 #1
0
 def test_macro(self):
     """
     Tests for undesired deletions of weakly referenced signal processing objects.
     """
     sumpf.collect_garbage() # collect garbage from tests, that might have failed before
     # check if the signal processing chain works, even when not all processing objects are stored in persistent variables
     macro = MacroTestClass()
     macro.SetSignal(sumpf.Signal())
     # check if the non-persistently stored objects are deleted by reference counting, when all connections to them are disconnected
     macro.Destroy()
     del macro
     self.assertEqual(gc.collect(), 0)   # the objects should have been deleted by reference counting, rather than the garbage collector
예제 #2
0
 def test_object_deletion(self):
     """
     Checks that Connectors do not inhibit clean object deletion.
     """
     # deletion without explicit garbage collection
     gc.collect()
     rel = sumpf.modules.RelabelSignal()
     rel.SetSignal(sumpf.Signal())
     del rel
     self.assertEqual(gc.collect(), 0)
     # sumpf.collect_garbage
     sumpf.connect(self.obj1.GetValue, self.obj2.SetValue)
     sumpf.connect(self.obj2.GetText, self.obj1.SetText)
     sumpf.disconnect_all(self.obj1)
     gc.collect()
     current_instance_count = ExampleClass.instance_count
     sumpf.destroy_connectors(self.obj1)
     del self.obj1
     gc.collect()
     if ExampleClass.instance_count != current_instance_count - 1:
         for o in gc.garbage:
             if isinstance(o, ExampleClass):
                 collected = sumpf.collect_garbage()
                 self.assertIsInstance(collected, int)  # sumpf.collect_garbage shall return the integer number of collected items
                 self.assertEqual(gc.garbage, [])       # garbage collection should have removed all garbage
                 return
         self.fail("The object has neither been deleted, nor has it been marked as garbage")
예제 #3
0
 def tearDown(self):
     sumpf.collect_garbage()