summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGustavo J. A. M. Carneiro <gjc@src.gnome.org>2007-05-03 10:28:56 +0000
committerGustavo J. A. M. Carneiro <gjc@src.gnome.org>2007-05-03 10:28:56 +0000
commit25e96042c91016286b59639b83c42cb7444561f5 (patch)
tree3ff584b9b7a6c197cd32082b905c74dd55279403 /tests
parent514aec8f9571c3212a6ae1640f83f6a6cf713f7b (diff)
downloadpygtk-25e96042c91016286b59639b83c42cb7444561f5.tar.gz
Fix some unit tests to account for the new memory management model in pygobject 2.13.
svn path=/trunk/; revision=2818
Diffstat (limited to 'tests')
-rw-r--r--tests/test_actiongroup.py27
-rw-r--r--tests/test_gdk.py24
2 files changed, 33 insertions, 18 deletions
diff --git a/tests/test_actiongroup.py b/tests/test_actiongroup.py
index a4fb97d8..56423d1c 100644
--- a/tests/test_actiongroup.py
+++ b/tests/test_actiongroup.py
@@ -102,17 +102,22 @@ class ActionGroupTest(unittest.TestCase):
uimanager.remove_ui(self.merge_id0)
uimanager.remove_action_group(ag0)
- gc.collect() # Clean out unreachable objects
-
- del ag0
- self.assertEqual(gc.collect(), 1) # Collect just the ActionGroup
-
- uimanager.ensure_update()
- self.assertEqual(gc.collect(), 6) # Now the GtkActions have lost their last
- # GObject reference; they should be collected.
- # We have a ToggleAction, an Action and a
- # RadioAction, plus self.cb is bound in three
- # closures.
+ if gobject.pygobject_version >= (2,13):
+ ag0ref = ag0.weak_ref()
+ del ag0
+ self.assertEqual(ag0ref(), None)
+ else:
+ gc.collect() # Clean out unreachable objects
+
+ del ag0
+ self.assertEqual(gc.collect(), 1) # Collect just the ActionGroup
+
+ uimanager.ensure_update()
+ self.assertEqual(gc.collect(), 6) # Now the GtkActions have lost their last
+ # GObject reference; they should be collected.
+ # We have a ToggleAction, an Action and a
+ # RadioAction, plus self.cb is bound in three
+ # closures.
gtk.main_quit()
diff --git a/tests/test_gdk.py b/tests/test_gdk.py
index e23c4583..d589f6fd 100644
--- a/tests/test_gdk.py
+++ b/tests/test_gdk.py
@@ -1,7 +1,7 @@
import unittest
import gc
-from common import gtk
+from common import gtk, gobject
class CallOnDel:
def __init__(self, callback):
@@ -52,7 +52,7 @@ class GdkTest(unittest.TestCase):
while True:
x = gc.collect()
cnt += x
- if x:
+ if x == 0:
break
return cnt
@@ -61,13 +61,23 @@ class GdkTest(unittest.TestCase):
pass
display = gtk.gdk.Display(None)
- del display
-
- self.assertEquals(self._collect(), 1)
+ if gobject.pygobject_version >= (2,13):
+ dispref = display.weak_ref()
+ del display
+ self.assertEqual(dispref(), None)
+ else:
+ del display
+ self.assertEquals(self._collect(), 1)
display = gtk.gdk.Display(None)
self.assertEquals(display.__grefcount__, 1)
display.close()
self.assertEquals(display.__grefcount__, 1)
- del display
- self.assertEquals(self._collect(), 1)
+
+ if gobject.pygobject_version >= (2,13):
+ dispref = display.weak_ref()
+ del display
+ self.assertEqual(dispref(), None)
+ else:
+ del display
+ self.assertEquals(self._collect(), 1)