diff options
author | Gian Mario Tagliaretti <gianmt@src.gnome.org> | 2008-08-02 21:51:10 +0000 |
---|---|---|
committer | Gian Mario Tagliaretti <gianmt@src.gnome.org> | 2008-08-02 21:51:10 +0000 |
commit | 4ae930e278b8fcb99dd85e60a9c708263ca02f74 (patch) | |
tree | a3f1926ce539ff338441c2f89dc739f77742e2c1 /tests | |
parent | c84375e8018d300e2ae43a932cff6948300b03c0 (diff) | |
download | pygobject-4ae930e278b8fcb99dd85e60a9c708263ca02f74.tar.gz pygobject-4ae930e278b8fcb99dd85e60a9c708263ca02f74.tar.xz pygobject-4ae930e278b8fcb99dd85e60a9c708263ca02f74.zip |
Wrap GFile.create_async with docs and test
svn path=/trunk/; revision=920
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_gio.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_gio.py b/tests/test_gio.py index 17642ba..d96d9aa 100644 --- a/tests/test_gio.py +++ b/tests/test_gio.py @@ -72,6 +72,45 @@ class TestFile(unittest.TestCase): loop = glib.MainLoop() loop.run() + def testCreateAsync(self): + def callback(file, result): + try: + stream = file.create_finish(result) + self.failUnless(isinstance(stream, gio.OutputStream)) + w = stream.write("testing") + cont, leng, etag = file.load_contents() + self.assertEqual(cont, "testing") + finally: + if os.path.exists('temp.txt'): + os.unlink("temp.txt") + loop.quit() + + gfile = gio.File("temp.txt") + gfile.create_async(callback, gio.FILE_CREATE_NONE, + glib.PRIORITY_HIGH) + + loop = glib.MainLoop() + loop.run() + + def testCreateAsyncNoargs(self): + def callback(file, result): + try: + stream = file.create_finish(result) + self.failUnless(isinstance(stream, gio.OutputStream)) + w = stream.write("testing") + cont, leng, etag = file.load_contents() + self.assertEqual(cont, "testing") + finally: + if os.path.exists('temp.txt'): + os.unlink("temp.txt") + loop.quit() + + gfile = gio.File("temp.txt") + gfile.create_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") |