diff options
author | Gian Mario Tagliaretti <gianmt@src.gnome.org> | 2008-08-03 20:11:13 +0000 |
---|---|---|
committer | Gian Mario Tagliaretti <gianmt@src.gnome.org> | 2008-08-03 20:11:13 +0000 |
commit | 9d36ba462c82a52ef41a9e1a3d3e849d8430a129 (patch) | |
tree | 1a45e4ee87524834fce0608791a1f635a7d76df9 /tests | |
parent | cc630ab67b9483f9c3c71ffa2ecffee7d61bed8c (diff) | |
download | pygobject-9d36ba462c82a52ef41a9e1a3d3e849d8430a129.tar.gz |
Wrap GFile.replace_async and query_info_async with docs and test.
svn path=/trunk/; revision=923
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_gio.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/test_gio.py b/tests/test_gio.py index d96d9aa9..c3210761 100644 --- a/tests/test_gio.py +++ b/tests/test_gio.py @@ -111,6 +111,49 @@ class TestFile(unittest.TestCase): loop = glib.MainLoop() loop.run() + def testReplaceAsync(self): + self._f.write("testing") + self._f.close() + + def callback(file, result): + try: + stream = file.replace_finish(result) + self.failUnless(isinstance(stream, gio.OutputStream)) + stream.write("some new string") + stream.close() + cont, leng, etag = file.load_contents() + self.assertEqual(cont, "some new string") + finally: + loop.quit() + + + self.file.replace_async(callback, None, True, gio.FILE_CREATE_NONE, + glib.PRIORITY_HIGH) + + loop = glib.MainLoop() + loop.run() + + def testReplaceAsyncNoargs(self): + self._f.write("testing") + self._f.close() + + def callback(file, result): + try: + stream = file.replace_finish(result) + self.failUnless(isinstance(stream, gio.OutputStream)) + stream.write("some new string") + stream.close() + cont, leng, etag = file.load_contents() + self.assertEqual(cont, "some new string") + finally: + loop.quit() + + + self.file.replace_async(callback) + + loop = glib.MainLoop() + loop.run() + def testReadAsyncError(self): self.assertRaises(TypeError, self.file.read_async) self.assertRaises(TypeError, self.file.read_async, "foo", "bar") @@ -169,6 +212,20 @@ class TestFile(unittest.TestCase): loop = glib.MainLoop() loop.run() + def testQueryInfoAsync(self): + def callback(file, result): + try: + info = file.query_info_finish(result) + self.failUnless(isinstance(info, gio.FileInfo)) + self.failUnless(info.get_name(), "file.txt") + finally: + loop.quit() + + self.file.query_info_async(callback, "standard") + + loop = glib.MainLoop() + loop.run() + def testMountMountable(self): gfile = gio.File('localtest:') def unmount_done(mount, result): |