[pygi] check refcounting of callback userdata in unit tests



commit c171579ee22681e1ee4ad33441c89f1053bdc3d1
Author: John (J5) Palmieri <johnp redhat com>
Date:   Mon May 24 11:48:16 2010 -0400

    check refcounting of callback userdata in unit tests

 tests/test_everything.py |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/tests/test_everything.py b/tests/test_everything.py
index fb6bc25..41bc765 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -5,6 +5,7 @@ import unittest
 
 import sys
 sys.path.insert(0, "../")
+from sys import getrefcount
 
 import cairo
 
@@ -168,6 +169,23 @@ class TestCallbacks(unittest.TestCase):
             
         self.assertEquals(TestCallbacks.called, 100)
 
+    def testCallbackUserdataRefCount(self):
+        TestCallbacks.called = False
+        def callback(userdata):
+            TestCallbacks.called = True
+            return 1
+
+        ud = "Test User Data"
+
+        start_ref_count = getrefcount(ud)
+        for i in range(100):
+            Everything.test_callback_destroy_notify(callback, ud)
+
+        Everything.test_callback_thaw_notifications()
+        end_ref_count = getrefcount(ud)
+
+        self.assertEquals(start_ref_count, end_ref_count)
+
     def testAsyncReadyCallback(self):
         TestCallbacks.called = False
         TestCallbacks.main_loop = GObject.MainLoop()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]