summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2008-07-26 08:37:59 +0000
committerJohan Dahlin <johan@src.gnome.org>2008-07-26 08:37:59 +0000
commitb94d79214498b07abc22e676897c8314cc386c7c (patch)
treeb73c3e64c8363d9a89c98212a436a7445d57c217 /tests
parent444fcf054cfa845c06cc23e2a67303ed0aa1f402 (diff)
downloadpygobject-b94d79214498b07abc22e676897c8314cc386c7c.tar.gz
pygobject-b94d79214498b07abc22e676897c8314cc386c7c.tar.xz
pygobject-b94d79214498b07abc22e676897c8314cc386c7c.zip
Move over glib constants to gobject
2008-07-26 Johan Dahlin <johan@gnome.org> * glib/glibmodule.c (pyglib_register_constants), (init_glib): * gobject/__init__.py: * gobject/gobjectmodule.c (init_gobject): Move over glib constants to gobject * tests/test_gio.py: * tests/test_mainloop.py: * tests/test_source.py: * tests/test_subprocess.py: * tests/test_thread.py: Update tests to refer to glib when appropriate svn path=/trunk/; revision=858
Diffstat (limited to 'tests')
-rw-r--r--tests/test_gio.py30
-rw-r--r--tests/test_mainloop.py6
-rw-r--r--tests/test_source.py22
-rw-r--r--tests/test_subprocess.py10
-rw-r--r--tests/test_thread.py9
5 files changed, 39 insertions, 38 deletions
diff --git a/tests/test_gio.py b/tests/test_gio.py
index 2d39220..128494f 100644
--- a/tests/test_gio.py
+++ b/tests/test_gio.py
@@ -3,7 +3,7 @@
import os
import unittest
-from common import gio, gobject
+from common import gio, glib
class TestFile(unittest.TestCase):
@@ -29,7 +29,7 @@ class TestFile(unittest.TestCase):
self.file.read_async(callback)
- loop = gobject.MainLoop()
+ loop = glib.MainLoop()
loop.run()
def testReadAsyncError(self):
@@ -87,7 +87,7 @@ class TestFile(unittest.TestCase):
canc = gio.Cancellable()
self.file.load_contents_async(callback, cancellable=canc)
- loop = gobject.MainLoop()
+ loop = glib.MainLoop()
loop.run()
def testMountMountable(self):
@@ -103,7 +103,7 @@ class TestFile(unittest.TestCase):
try:
try:
retval = gfile.mount_enclosing_volume_finish(result)
- except gobject.GError, e:
+ except glib.GError, e:
# If we run the tests too fast
if (e.domain == gio.ERROR and
e.code == gio.ERROR_ALREADY_MOUNTED):
@@ -121,7 +121,7 @@ class TestFile(unittest.TestCase):
gfile.mount_enclosing_volume(mount_operation,
mount_enclosing_volume_done)
- loop = gobject.MainLoop()
+ loop = glib.MainLoop()
loop.run()
def testCopy(self):
@@ -182,7 +182,7 @@ class TestGFileEnumerator(unittest.TestCase):
self.file.enumerate_children_async(
"standard::*", callback)
- loop = gobject.MainLoop()
+ loop = glib.MainLoop()
loop.run()
def testNextFilesAsync(self):
@@ -199,7 +199,7 @@ class TestGFileEnumerator(unittest.TestCase):
enumerator = self.file.enumerate_children(
"standard::*", gio.FILE_QUERY_INFO_NOFOLLOW_SYMLINKS)
enumerator.next_files_async(1000, callback)
- loop = gobject.MainLoop()
+ loop = glib.MainLoop()
loop.run()
@@ -229,7 +229,7 @@ class TestInputStream(unittest.TestCase):
self.stream.read_async(7, callback)
- loop = gobject.MainLoop()
+ loop = glib.MainLoop()
loop.run()
def testReadAsyncError(self):
@@ -239,14 +239,14 @@ class TestInputStream(unittest.TestCase):
self.count += 1
if self.count == 1:
return
- self.assertRaises(gobject.GError, stream.read_finish, result)
+ self.assertRaises(glib.GError, stream.read_finish, result)
finally:
loop.quit()
self.stream.read_async(10240, callback)
self.stream.read_async(10240, callback)
- loop = gobject.MainLoop()
+ loop = glib.MainLoop()
loop.run()
self.assertEquals(self.count, 2)
@@ -273,7 +273,7 @@ class TestInputStream(unittest.TestCase):
self.stream.close_async(callback)
- loop = gobject.MainLoop()
+ loop = glib.MainLoop()
loop.run()
@@ -304,21 +304,21 @@ class TestOutputStream(unittest.TestCase):
self.stream.write_async("testing", callback)
- loop = gobject.MainLoop()
+ loop = glib.MainLoop()
loop.run()
def testWriteAsyncError(self):
def callback(stream, result):
self.assertEquals(result.get_op_res_gssize(), 0)
try:
- self.assertRaises(gobject.GError, stream.write_finish, result)
+ self.assertRaises(glib.GError, stream.write_finish, result)
finally:
loop.quit()
self.stream.close()
self.stream.write_async("testing", callback)
- loop = gobject.MainLoop()
+ loop = glib.MainLoop()
loop.run()
self.assertRaises(TypeError, self.stream.write_async)
@@ -342,7 +342,7 @@ class TestOutputStream(unittest.TestCase):
self.stream.close_async(callback)
- loop = gobject.MainLoop()
+ loop = glib.MainLoop()
loop.run()
diff --git a/tests/test_mainloop.py b/tests/test_mainloop.py
index 8294642..95e5f78 100644
--- a/tests/test_mainloop.py
+++ b/tests/test_mainloop.py
@@ -6,7 +6,7 @@ import sys
import select
import unittest
-from common import gobject
+from common import glib
class TestMainLoop(unittest.TestCase):
def testExceptionHandling(self):
@@ -23,8 +23,8 @@ class TestMainLoop(unittest.TestCase):
loop.quit()
raise Exception("deadbabe")
- loop = gobject.MainLoop()
- gobject.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, "Y")
diff --git a/tests/test_source.py b/tests/test_source.py
index 8e7e81c..a5118a9 100644
--- a/tests/test_source.py
+++ b/tests/test_source.py
@@ -6,11 +6,11 @@ import sys
import select
import unittest
-from common import gobject
+from common import glib, gobject
-class Idle(gobject.Idle):
+class Idle(glib.Idle):
def __init__(self, loop):
- gobject.Idle.__init__(self)
+ glib.Idle.__init__(self)
self.count = 0
self.set_callback(self.callback, loop)
@@ -18,9 +18,9 @@ class Idle(gobject.Idle):
self.count += 1
return True
-class MySource(gobject.Source):
+class MySource(glib.Source):
def __init__(self):
- gobject.Source.__init__(self)
+ glib.Source.__init__(self)
def prepare(self):
return True, 0
@@ -40,12 +40,12 @@ class TestSource(unittest.TestCase):
return True
def setup_timeout(self, loop):
- timeout = gobject.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 +65,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(gobject.Source):
+ class CustomTimeout(glib.Source):
def prepare(self):
return (False, 10)
@@ -93,8 +93,8 @@ class TestSource(unittest.TestCase):
class TestTimeout(unittest.TestCase):
def test504337(self):
- timeout_source = gobject.Timeout(20)
- idle_source = gobject.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 b1c7dde..8495010 100644
--- a/tests/test_subprocess.py
+++ b/tests/test_subprocess.py
@@ -4,7 +4,7 @@ import gc
import unittest
import sys
-from common import gobject
+from common import glib, gobject
class TestProcess(unittest.TestCase):
@@ -14,12 +14,12 @@ 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 = gobject.spawn_async(
- argv, flags=gobject.SPAWN_DO_NOT_REAP_CHILD)
+ pid, stdin, stdout, stderr = glib.spawn_async(
+ argv, flags=glib.SPAWN_DO_NOT_REAP_CHILD)
pid.close()
- gobject.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 f1ec01a..9f77f0b 100644
--- a/tests/test_thread.py
+++ b/tests/test_thread.py
@@ -1,8 +1,9 @@
import os
import unittest
-from common import gobject, testhelper
-main = gobject.MainLoop()
+from common import glib, testhelper
+
+main = glib.MainLoop()
class TestThread(unittest.TestCase):
def from_thread_cb(self, test, enum):
@@ -16,8 +17,8 @@ class TestThread(unittest.TestCase):
self.obj.emit('emit-signal')
def testExtensionModule(self):
- gobject.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)
main.run()
def timeout_cb(self):