diff options
author | Paul Pogonyshev <pogonyshev@gmx.net> | 2008-08-09 15:01:29 +0000 |
---|---|---|
committer | Paul Pogonyshev <paulp@src.gnome.org> | 2008-08-09 15:01:29 +0000 |
commit | 2a778d5bc55e812d549c02266d42b3f454627bd5 (patch) | |
tree | 7b54ef2c4d7220e685972fe6320205c32f7fdfe9 /tests | |
parent | 1a20d6e43a3cc24feb7d4d5573face04b6d2492a (diff) | |
download | pygobject-2a778d5bc55e812d549c02266d42b3f454627bd5.tar.gz pygobject-2a778d5bc55e812d549c02266d42b3f454627bd5.tar.xz pygobject-2a778d5bc55e812d549c02266d42b3f454627bd5.zip |
Bug 546591 – File.copy progress_callback does not work
2008-08-09 Paul Pogonyshev <pogonyshev@gmx.net>
Bug 546591 – File.copy progress_callback does not work
* gio/gfile.override (file_progress_callback_marshal): Use
PyObject_CallFunction() instead of PyEval_CallFunction(). Use "K"
instead of "k" (the latter is not correct for 32-bit platforms).
Don't free 'notify' here.
(_wrap_g_file_copy): Free 'notify'.
(_wrap_g_file_move): Likewise.
* gio/gio.override (pygio_free_notify): New function.
(async_result_callback_marshal): Use it.
* tests/test_gio.py (TestFile.test_copy_progress.progress): New
test.
svn path=/trunk/; revision=932
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_gio.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_gio.py b/tests/test_gio.py index 930d8fb..ad186fe 100644 --- a/tests/test_gio.py +++ b/tests/test_gio.py @@ -295,6 +295,28 @@ class TestFile(unittest.TestCase): finally: os.unlink("copy.txt") + # See bug 546591. + def test_copy_progress(self): + source = gio.File('file.txt') + destination = gio.File('copy.txt') + + def progress(current, total): + self.assert_(isinstance(current, long)) + self.assert_(isinstance(total, long)) + self.assert_(0 <= current <= total) + + try: + retval = source.copy(destination, + flags=gio.FILE_COPY_OVERWRITE, + progress_callback=progress) + self.failUnless(retval) + + self.failUnless(os.path.exists('copy.txt')) + self.assertEqual(open('file.txt').read(), + open('copy.txt').read()) + finally: + os.unlink("copy.txt") + def testMove(self): if os.path.exists('move.txt'): os.unlink("move.txt") |