diff options
author | Mads Chr. Olesen <gnome-bugzilla@shiyee.dk> | 2009-01-04 22:01:20 +0000 |
---|---|---|
committer | Paul Pogonyshev <paulp@src.gnome.org> | 2009-01-04 22:01:20 +0000 |
commit | d5971581b6aa5ee2d9d0fbbec12f43dd53f4b2db (patch) | |
tree | 78bd5148d5a76c1e346cbbe3d333e77aea14ae7c /tests | |
parent | 9359060516f5dfea236fbf147815e48d54dac18a (diff) | |
download | pygobject-d5971581b6aa5ee2d9d0fbbec12f43dd53f4b2db.tar.gz pygobject-d5971581b6aa5ee2d9d0fbbec12f43dd53f4b2db.tar.xz pygobject-d5971581b6aa5ee2d9d0fbbec12f43dd53f4b2db.zip |
Define methods.
2009-01-04 Mads Chr. Olesen <gnome-bugzilla@shiyee.dk>
* 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
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_gio.py | 25 |
1 files changed, 25 insertions, 0 deletions
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') |