[pygobject] test_gi: Add tests for type "filename"
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] test_gi: Add tests for type "filename"
- Date: Wed, 14 Nov 2012 10:59:51 +0000 (UTC)
commit 8ce0d028fe79e2ce52cfecbb682afba6651a7a70
Author: Martin Pitt <martinpitt gnome org>
Date: Wed Nov 14 11:57:21 2012 +0100
test_gi: Add tests for type "filename"
tests/test_gi.py | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 612424b..e5b8b7e 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -688,6 +688,36 @@ class TestUtf8(unittest.TestCase):
self.assertEqual("", GIMarshallingTests.utf8_full_inout(CONSTANT_UTF8))
+class TestFilename(unittest.TestCase):
+ def setUp(self):
+ self.workdir = tempfile.mkdtemp()
+
+ def tearDown(self):
+ shutil.rmtree(self.workdir)
+
+ def test_filename_in(self):
+ fname = os.path.join(self.workdir, 'testÃÃ.txt')
+ self.assertRaises(GLib.GError, GLib.file_get_contents, fname)
+
+ with open(fname.encode('UTF-8'), 'wb') as f:
+ f.write(b'hello world!\n\x01\x02')
+
+ (result, contents) = GLib.file_get_contents(fname)
+ self.assertEqual(result, True)
+ self.assertEqual(contents, b'hello world!\n\x01\x02')
+
+ def test_filename_out(self):
+ self.assertRaises(GLib.GError, GLib.Dir.make_tmp, 'test')
+
+ dirname = GLib.Dir.make_tmp('testÃÃ.XXXXXX')
+ self.assertTrue('/testÃÃ.' in dirname, dirname)
+ self.assertTrue(os.path.isdir(dirname.encode('UTF-8')))
+ os.rmdir(dirname.encode('UTF-8'))
+
+ def test_filename_type_error(self):
+ self.assertRaises(TypeError, GLib.file_get_contents, 23)
+
+
class TestArray(unittest.TestCase):
def test_array_fixed_int_return(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]