blob: ce9b99e8fcec06b020cb2f09478909def523f281 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import unittest
from common import gtk, gobject
import weakref
import gc
class TestGlade(unittest.TestCase):
class SimpleTest:
def __init__(self, test):
xml = gtk.glade.XML('leak.glade')
xml.signal_autoconnect(self)
self.test = test
self.window = xml.get_widget("window1")
self.window.destroy()
def on_window1_destroy(self, window):
gobject.idle_add(self.test.leak_check, weakref.ref(self), weakref.ref(self.window))
def leak_check(self, objref, windowref):
while gc.collect():
pass
gtk.main_quit()
self.assertEqual(objref(), None)
self.windowref = windowref
def testAutoconnectLeak(self):
self.SimpleTest(self)
gtk.main()
self.assertEqual(self.windowref(), None)
if __name__ == '__main__':
unittest.main()
|