From d5971581b6aa5ee2d9d0fbbec12f43dd53f4b2db Mon Sep 17 00:00:00 2001 From: "Mads Chr. Olesen" Date: Sun, 4 Jan 2009 22:01:20 +0000 Subject: Define methods. 2009-01-04 Mads Chr. Olesen * gio/gio.defs (gio.File.copy_async, gio.File.copy_finish): Define methods. * gio/gfile.override (_wrap_g_file_copy_async): New function. * tests/test_gio.py (TestFile.test_copy_async): Test the methods. svn path=/trunk/; revision=990 --- tests/test_gio.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests') diff --git a/tests/test_gio.py b/tests/test_gio.py index c4e9125..10ef6ac 100644 --- a/tests/test_gio.py +++ b/tests/test_gio.py @@ -295,6 +295,31 @@ class TestFile(unittest.TestCase): finally: os.unlink("copy.txt") + def test_copy_async(self): + if os.path.exists('copy.txt'): + os.unlink("copy.txt") + + source = gio.File('file.txt') + destination = gio.File('copy.txt') + + def copied(source_, result): + self.assert_(source_ is source) + self.failUnless(source_.copy_finish(result)) + + def progress(current, total): + self.assert_(isinstance(current, long)) + self.assert_(isinstance(total, long)) + self.assert_(0 <= current <= total) + + try: + source.copy_async(destination, copied, progress_callback = progress) + + self.failUnless(os.path.exists('copy.txt')) + self.assertEqual(open('file.txt').read(), + open('copy.txt').read()) + finally: + os.unlink("copy.txt") + # See bug 546591. def test_copy_progress(self): source = gio.File('file.txt') -- cgit