From ca436fe7785fd24b0f0e65f2f8c9fa6478277682 Mon Sep 17 00:00:00 2001 From: Gian Mario Tagliaretti Date: Fri, 1 Jan 2010 13:30:24 +0100 Subject: Wrap gio.File.create_readwrite_async() and add a test --- tests/test_gio.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests') diff --git a/tests/test_gio.py b/tests/test_gio.py index a9ef159..feafc70 100644 --- a/tests/test_gio.py +++ b/tests/test_gio.py @@ -92,6 +92,30 @@ class TestFile(unittest.TestCase): loop = glib.MainLoop() loop.run() + def testCreateReadWriteAsync(self): + def callback(file, result): + try: + iostream = file.create_readwrite_finish(result) + self.failUnless(isinstance(iostream, gio.FileIOStream)) + + ostream = iostream.get_output_stream() + self.failUnless(isinstance(ostream, gio.OutputStream)) + + w = ostream.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_readwrite_async(callback, gio.FILE_CREATE_NONE, + glib.PRIORITY_HIGH) + + loop = glib.MainLoop() + loop.run() + def testCreateAsyncNoargs(self): def callback(file, result): try: -- cgit