[pygobject] Fix TestSource.testSources() test case



commit 15f7442bd0c45db25073e3d8494094f1c284ffa4
Author: Martin Pitt <martinpitt gnome org>
Date:   Mon Oct 22 13:38:23 2012 +0200

    Fix TestSource.testSources() test case
    
    PyGObject has established the assumption that the destruction of a GLib.Source
    Python object does not destroy the actual GSource, as shown in
    TestSource.setup_timeout(), TestTimeout.test504337(), and
    https://bugzilla.gnome.org/show_bug.cgi?id=504337.
    
    So we need to explicitly destroy our MySource and Idle objects after using
    them, as their callbacks always return True and we do not want them to spill
    over into other tests.
    
    Also fix the assertions to actually verify that MySources' callback was callied
    (pos > 0, not pos >= 0), and use the unittest comparison API instead of a
    simple assert statement.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=686627

 tests/test_source.py |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/tests/test_source.py b/tests/test_source.py
index fe674cd..ec47d0e 100644
--- a/tests/test_source.py
+++ b/tests/test_source.py
@@ -59,7 +59,13 @@ class TestSource(unittest.TestCase):
 
         loop.run()
 
-        assert self.pos >= 0 and idle.count >= 0
+        m.destroy()
+        idle.destroy()
+
+        self.assertGreater(self.pos, 0)
+        self.assertGreaterEqual(idle.count, 0)
+        self.assertTrue(m.is_destroyed())
+        self.assertTrue(idle.is_destroyed())
 
     def testSourcePrepare(self):
         # this test may not terminate if prepare() is wrapped incorrectly



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