From 4777faab0d31bd883bf2eee600bf8bd32f119600 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Thu, 24 Jul 2008 21:38:50 +0000 Subject: Wrap gio.File.copy, add tests and documentation. Rename 2008-07-24 Johan Dahlin * gio/gfile.override: * gio/gfileenumerator.override: * gio/ginputstream.override: * gio/gio.defs: * gio/gio.override: * gio/goutputstream.override: * tests/test_gio.py: Wrap gio.File.copy, add tests and documentation. Rename PyGAsyncRequestNotify to PyGIONotify and reuse it. svn path=/trunk/; revision=850 --- tests/test_gio.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests') diff --git a/tests/test_gio.py b/tests/test_gio.py index bac9cfc..2d39220 100644 --- a/tests/test_gio.py +++ b/tests/test_gio.py @@ -124,6 +124,37 @@ class TestFile(unittest.TestCase): loop = gobject.MainLoop() loop.run() + def testCopy(self): + if os.path.exists('copy.txt'): + os.unlink("copy.txt") + + source = gio.File('file.txt') + destination = gio.File('copy.txt') + try: + retval = source.copy(destination) + 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") + + self.called = False + def callback(current, total): + self.called = True + source = gio.File('file.txt') + destination = gio.File('copy.txt') + try: + retval = source.copy(destination, callback) + self.failUnless(retval) + + self.failUnless(os.path.exists('copy.txt')) + self.assertEqual(open('file.txt').read(), + open('copy.txt').read()) + self.failUnless(self.called) + finally: + os.unlink("copy.txt") class TestGFileEnumerator(unittest.TestCase): def setUp(self): -- cgit