diff options
author | Johan Dahlin <johan@src.gnome.org> | 2008-07-18 20:21:22 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2008-07-18 20:21:22 +0000 |
commit | 4287c2cc70b02930ed64e9cbec2a0c886ac5d3b7 (patch) | |
tree | 2deb5a2d0b96e4d3e8635d3c9bc65903bad91114 /tests | |
parent | f0e9c1f49c718a34986cf74821f5ef809217c65c (diff) | |
download | pygobject-4287c2cc70b02930ed64e9cbec2a0c886ac5d3b7.tar.gz |
Wrap gio.File.enumerate_children_async, add tests, docstring and an
* examples/gio/directory-async.py:
* gio/gfile.override:
* gio/gfileenumerator.override:
* gio/gio.defs:
* tests/test_gio.py:
Wrap gio.File.enumerate_children_async, add tests, docstring
and an example.
Also document gio.File.enumerate while we're at it.
svn path=/trunk/; revision=828
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_gio.py | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/tests/test_gio.py b/tests/test_gio.py index 7f331370..df82e36f 100644 --- a/tests/test_gio.py +++ b/tests/test_gio.py @@ -61,7 +61,7 @@ class TestFile(unittest.TestCase): self.assertRaises(TypeError, gio.File, foo="bar") self.assertRaises(TypeError, gio.File, uri=1) self.assertRaises(TypeError, gio.File, path=1) - + def testLoadContents(self): self._f.write("testing load_contents") self._f.seek(0) @@ -70,11 +70,11 @@ class TestFile(unittest.TestCase): self.assertEqual(cont, "testing load_contents") self.assertEqual(leng, 21) self.assertNotEqual(etag, '') - + def testLoadContentsAsync(self): self._f.write("testing load_contents_async") self._f.seek(0) - + def callback(contents, result): try: cont, leng, etag = contents.load_contents_finish(result) @@ -83,10 +83,10 @@ class TestFile(unittest.TestCase): self.assertNotEqual(etag, '') finally: loop.quit() - + canc = gio.Cancellable() self.file.load_contents_async(callback, cancellable=canc) - + loop = gobject.MainLoop() loop.run() @@ -103,6 +103,22 @@ class TestGFileEnumerator(unittest.TestCase): else: raise AssertionError + def testEnumerateChildrenAsync(self): + def callback(gfile, result): + try: + for file_info in gfile.enumerate_children_finish(result): + if file_info.get_name() == 'test_gio.py': + break + else: + raise AssertionError + finally: + loop.quit() + + self.file.enumerate_children_async( + "standard::*", callback) + loop = gobject.MainLoop() + loop.run() + class TestInputStream(unittest.TestCase): def setUp(self): @@ -264,14 +280,14 @@ class TestVolumeMonitor(unittest.TestCase): self.failUnless(isinstance(mounts, list)) if not mounts: return - + self.failUnless(isinstance(mounts[0], gio.Mount)) # Bug 538601 icon = mounts[0].get_icon() if not icon: return self.failUnless(isinstance(icon, gio.Icon)) - + class TestThemedIcon(unittest.TestCase): def setUp(self): |