summaryrefslogtreecommitdiff
path: root/tests/test_docstring.py
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:40:19 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:40:22 +0900
commit9e05f0b92b0d6cde13d729955af7b911f79ba833 (patch)
treee9bf82708776e0eb586bb1e26742ad4e1c7c5f85 /tests/test_docstring.py
parentd7ab1229ba0f909c4a3ba445441a4c9f89d7b38d (diff)
downloadpygobject2-9e05f0b92b0d6cde13d729955af7b911f79ba833.tar.gz
pygobject2-9e05f0b92b0d6cde13d729955af7b911f79ba833.tar.bz2
pygobject2-9e05f0b92b0d6cde13d729955af7b911f79ba833.zip
Imported Upstream version 3.11.4
Change-Id: I8c3c314d3446d81a7d958b4cbba28bf0e39e7616 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'tests/test_docstring.py')
-rw-r--r--tests/test_docstring.py67
1 files changed, 47 insertions, 20 deletions
diff --git a/tests/test_docstring.py b/tests/test_docstring.py
index 54349b8..a46d2e6 100644
--- a/tests/test_docstring.py
+++ b/tests/test_docstring.py
@@ -4,6 +4,15 @@ import gi.docstring
from gi.repository import GIMarshallingTests
from gi.repository import Gio
+try:
+ import cairo
+ cairo = cairo
+ has_cairo = True
+ from gi.repository import Regress
+ from gi.repository import Gtk
+except ImportError:
+ has_cairo = False
+
class Test(unittest.TestCase):
def test_api(self):
@@ -21,26 +30,6 @@ class Test(unittest.TestCase):
self.assertEqual(gi.docstring.get_doc_string_generator(),
old_func)
- def test_split_args_multi_out(self):
- in_args, out_args = gi.docstring.split_function_info_args(GIMarshallingTests.int_out_out)
- self.assertEqual(len(in_args), 0)
- self.assertEqual(len(out_args), 2)
- self.assertEqual(out_args[0].get_pytype_hint(), 'int')
- self.assertEqual(out_args[1].get_pytype_hint(), 'int')
-
- def test_split_args_inout(self):
- in_args, out_args = gi.docstring.split_function_info_args(GIMarshallingTests.long_inout_max_min)
- self.assertEqual(len(in_args), 1)
- self.assertEqual(len(out_args), 1)
- self.assertEqual(in_args[0].get_name(), out_args[0].get_name())
- self.assertEqual(in_args[0].get_pytype_hint(), out_args[0].get_pytype_hint())
-
- def test_split_args_none(self):
- obj = GIMarshallingTests.Object(int=33)
- in_args, out_args = gi.docstring.split_function_info_args(obj.none_inout)
- self.assertEqual(len(in_args), 1)
- self.assertEqual(len(out_args), 1)
-
def test_final_signature_with_full_inout(self):
self.assertEqual(GIMarshallingTests.Object.full_inout.__doc__,
'full_inout(object:GIMarshallingTests.Object) -> object:GIMarshallingTests.Object')
@@ -57,3 +46,41 @@ class Test(unittest.TestCase):
'progress_callback_data=None)'
self.assertEqual(Gio.File.copy.__doc__, g_file_copy_doc)
+
+ def test_array_length_arg(self):
+ self.assertEqual(GIMarshallingTests.array_in.__doc__,
+ 'array_in(ints:list)')
+
+ def test_init_function(self):
+ # This tests implicit array length args along with skipping a
+ # boolean return
+ self.assertEqual(GIMarshallingTests.init_function.__doc__,
+ 'init_function(argv:list=None) -> argv:list')
+
+ def test_class_doc_constructors(self):
+ doc = GIMarshallingTests.Object.__doc__
+ self.assertTrue('new(int_:int)' in doc)
+
+ def test_struct_doc_constructors(self):
+ doc = GIMarshallingTests.BoxedStruct.__doc__
+ self.assertTrue('new()' in doc)
+ self.assertTrue('BoxedStruct()' in doc)
+
+ @unittest.skipUnless(has_cairo, 'built without cairo support')
+ def test_private_struct_constructors(self):
+ doc = Regress.TestBoxedPrivate.__doc__
+ self.assertTrue('TestBoxedPrivate()' not in doc)
+
+ def test_array_inout_etc(self):
+ self.assertEqual(GIMarshallingTests.array_inout_etc.__doc__,
+ 'array_inout_etc(first:int, ints:list, last:int) -> ints:list, sum:int')
+
+ def test_array_out_etc(self):
+ self.assertEqual(GIMarshallingTests.array_out_etc.__doc__,
+ 'array_out_etc(first:int, last:int) -> ints:list, sum:int')
+
+ @unittest.skipUnless(has_cairo, 'built without cairo support')
+ def test_shared_array_length_with_prior_out_arg(self):
+ # Test the 'iter' out argument does not effect length argument skipping.
+ self.assertEqual(Gtk.ListStore.insert_with_valuesv.__doc__,
+ 'insert_with_valuesv(self, position:int, columns:list, values:list) -> iter:Gtk.TreeIter')