summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Feltman <sfeltman@src.gnome.org>2014-01-16 16:33:41 -0800
committerSimon Feltman <sfeltman@src.gnome.org>2014-01-16 16:36:47 -0800
commitdf21dbbc84fa319af2a0f0664de436ca30df616e (patch)
tree50a617aea43f2221eaaa886b5fa904a0426aa0eb
parent7222a37a4b4955fe6c1dcc86e0eb798d653711e8 (diff)
downloadpygobject-df21dbbc84fa319af2a0f0664de436ca30df616e.tar.gz
tests: Add skipped test for GLib.Source inheritance problems
Add test showing memory problems with sub-classes of GLib.Source. https://bugzilla.gnome.org/show_bug.cgi?id=722387
-rw-r--r--tests/test_source.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_source.py b/tests/test_source.py
index 6f69927b..e0910f9d 100644
--- a/tests/test_source.py
+++ b/tests/test_source.py
@@ -220,6 +220,51 @@ class TestSource(unittest.TestCase):
del source
self.assertTrue(self.finalized)
+ @unittest.skip('https://bugzilla.gnome.org/show_bug.cgi?id=722387')
+ def test_python_unref_with_active_source(self):
+ # Tests a Python derived Source which is free'd in the context of
+ # Python, but remains active in the MainContext (via source.attach())
+ self.dispatched = False
+ self.finalized = False
+
+ class S(GLib.Source):
+ def prepare(s):
+ return (True, 1)
+
+ def check(s):
+ pass
+
+ def dispatch(s, callback, args):
+ self.dispatched = True
+ return False
+
+ def finalize(s):
+ self.finalized = True
+
+ source = S()
+ id = source.attach()
+ self.assertFalse(self.finalized)
+ self.assertFalse(source.is_destroyed())
+
+ # Delete the source from Python but should still remain
+ # active in the main context.
+ del source
+
+ context = GLib.MainContext.default()
+ while context.iteration(may_block=False):
+ pass
+
+ self.assertTrue(self.dispatched)
+ self.assertFalse(self.finalized)
+
+ source = context.find_source_by_id(id)
+ source.destroy() # Remove from main context.
+ self.assertTrue(source.is_destroyed())
+
+ # Source should be finalized called after del
+ del source
+ self.assertTrue(self.finalized)
+
def test_extra_init_args(self):
class SourceWithInitArgs(GLib.Source):
def __init__(self, arg, kwarg=None):