[pygobject] fix tests to use the new GLib module



commit 7b068ebe59884ebd9aeb4425dc80cdff73a66fb1
Author: John (J5) Palmieri <johnp redhat com>
Date:   Fri Jul 22 14:13:02 2011 -0400

    fix tests to use the new GLib module
    
    https://bugzilla.gnome.org/show_bug.cgi?id=642048

 tests/test_mainloop.py   |    7 +++----
 tests/test_option.py     |    3 ++-
 tests/test_source.py     |   24 +++++++++++-------------
 tests/test_subprocess.py |   12 +++++-------
 tests/test_thread.py     |   10 ++++------
 tests/test_uris.py       |    4 ++--
 6 files changed, 27 insertions(+), 33 deletions(-)
---
diff --git a/tests/test_mainloop.py b/tests/test_mainloop.py
index 9ca5727..937ecaf 100644
--- a/tests/test_mainloop.py
+++ b/tests/test_mainloop.py
@@ -5,8 +5,7 @@ import sys
 import select
 import unittest
 
-import glib
-from gi.repository import GObject
+from gi.repository import GLib
 
 from compathelper import _bytes
 
@@ -25,8 +24,8 @@ class TestMainLoop(unittest.TestCase):
             loop.quit()
             raise Exception("deadbabe")
 
-        loop = GObject.MainLoop()
-        glib.child_watch_add(pid, child_died, loop)
+        loop = GLib.MainLoop()
+        GLib.child_watch_add(pid, child_died, loop)
 
         os.close(pipe_r)
         os.write(pipe_w, _bytes("Y"))
diff --git a/tests/test_option.py b/tests/test_option.py
index a6ecc98..9233eed 100644
--- a/tests/test_option.py
+++ b/tests/test_option.py
@@ -9,7 +9,8 @@ try:
 except ImportError:
     from io import StringIO
 
-from glib.option import OptionParser, OptionGroup, OptionValueError, \
+# FIXME: we need a way to import the options module from a public module
+from gi._glib.option import OptionParser, OptionGroup, OptionValueError, \
      make_option, BadOptionError
 
 from compathelper import _bytes
diff --git a/tests/test_source.py b/tests/test_source.py
index f4e4644..ad052cc 100644
--- a/tests/test_source.py
+++ b/tests/test_source.py
@@ -2,13 +2,11 @@
 
 import unittest
 
-import glib
+from gi.repository import GLib
 
-from gi.repository import GObject
-
-class Idle(glib.Idle):
+class Idle(GLib.Idle):
     def __init__(self, loop):
-        glib.Idle.__init__(self)
+        GLib.Idle.__init__(self)
         self.count = 0
         self.set_callback(self.callback, loop)
 
@@ -17,9 +15,9 @@ class Idle(glib.Idle):
         return True
 
 
-class MySource(glib.Source):
+class MySource(GLib.Source):
     def __init__(self):
-        glib.Source.__init__(self)
+        GLib.Source.__init__(self)
 
     def prepare(self):
         return True, 0
@@ -40,12 +38,12 @@ class TestSource(unittest.TestCase):
         return True
 
     def setup_timeout(self, loop):
-        timeout = glib.Timeout(500)
+        timeout = GLib.Timeout(500)
         timeout.set_callback(self.timeout_callback, loop)
         timeout.attach()
 
     def testSources(self):
-        loop = GObject.MainLoop()
+        loop = GLib.MainLoop()
 
         self.setup_timeout(loop)
 
@@ -65,9 +63,9 @@ class TestSource(unittest.TestCase):
     def testSourcePrepare(self):
         # this test may not terminate if prepare() is wrapped incorrectly
         dispatched = [False]
-        loop = GObject.MainLoop()
+        loop = GLib.MainLoop()
 
-        class CustomTimeout(glib.Source):
+        class CustomTimeout(GLib.Source):
             def prepare(self):
                 return (False, 10)
 
@@ -93,8 +91,8 @@ class TestSource(unittest.TestCase):
 
 class TestTimeout(unittest.TestCase):
      def test504337(self):
-        timeout_source = glib.Timeout(20)
-        idle_source = glib.Idle()
+        timeout_source = GLib.Timeout(20)
+        idle_source = GLib.Idle()
 
 
 if __name__ == '__main__':
diff --git a/tests/test_subprocess.py b/tests/test_subprocess.py
index 2e831df..14c6283 100644
--- a/tests/test_subprocess.py
+++ b/tests/test_subprocess.py
@@ -3,9 +3,7 @@
 import sys
 import unittest
 
-import glib
-
-from gi.repository import GObject
+from gi.repository import GLib
 
 class TestProcess(unittest.TestCase):
 
@@ -15,11 +13,11 @@ class TestProcess(unittest.TestCase):
 
     def testChildWatch(self):
         self.data = None
-        self.loop = GObject.MainLoop()
+        self.loop = GLib.MainLoop()
         argv = [sys.executable, '-c', 'import sys']
-        pid, stdin, stdout, stderr = glib.spawn_async(
-            argv, flags=glib.SPAWN_DO_NOT_REAP_CHILD)
+        pid, stdin, stdout, stderr = GLib.spawn_async(
+            argv, flags=GLib.SPAWN_DO_NOT_REAP_CHILD)
         pid.close()
-        glib.child_watch_add(pid, self._child_watch_cb, 12345)
+        GLib.child_watch_add(pid, self._child_watch_cb, 12345)
         self.loop.run()
         self.assertEqual(self.data, 12345)
diff --git a/tests/test_thread.py b/tests/test_thread.py
index a7224f1..fa52dfa 100644
--- a/tests/test_thread.py
+++ b/tests/test_thread.py
@@ -1,15 +1,13 @@
 # -*- Mode: Python -*-
 
 import unittest
-
-import glib
 import testhelper
 
-from gi.repository import GObject
+from gi.repository import GLib
 
 class TestThread(unittest.TestCase):
     def setUp(self):
-        self.main = GObject.MainLoop()
+        self.main = GLib.MainLoop()
 
     def from_thread_cb(self, test, enum):
         assert test == self.obj
@@ -22,8 +20,8 @@ class TestThread(unittest.TestCase):
         self.obj.emit('emit-signal')
 
     def testExtensionModule(self):
-        glib.idle_add(self.idle_cb)
-        GObject.timeout_add(50, self.timeout_cb)
+        GLib.idle_add(self.idle_cb)
+        GLib.timeout_add(50, self.timeout_cb)
         self.main.run()
 
     def timeout_cb(self):
diff --git a/tests/test_uris.py b/tests/test_uris.py
index ee24215..8174324 100644
--- a/tests/test_uris.py
+++ b/tests/test_uris.py
@@ -1,6 +1,6 @@
 import unittest
 
-import glib
+from gi.repository import GLib
 
 class TestUris(unittest.TestCase):
     def testExtractUris(self):
@@ -8,7 +8,7 @@ class TestUris(unittest.TestCase):
                         "http://www.huh.org/books/foo.html\n"; + \
                         "http://www.huh.org/books/foo.pdf\n"; + \
                         "ftp://ftp.foo.org/books/foo.txt\n";
-        uri_list = glib.uri_list_extract_uris(uri_list_text)
+        uri_list = GLib.uri_list_extract_uris(uri_list_text)
         assert uri_list[0] == "http://www.huh.org/books/foo.html";
         assert uri_list[1] == "http://www.huh.org/books/foo.pdf";
         assert uri_list[2] == "ftp://ftp.foo.org/books/foo.txt";



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