summaryrefslogtreecommitdiff
path: root/tests/test_docstring.py
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:50:11 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:50:14 +0900
commit321841ba84f12124d94039cd8bbf60b3d342f6e3 (patch)
tree7c15db86760a48a4e8eb11380e81600425a01e25 /tests/test_docstring.py
parent2d8c9073fa23a0fde76a3b8ecf8cb518d162d101 (diff)
downloadpygobject2-321841ba84f12124d94039cd8bbf60b3d342f6e3.tar.gz
pygobject2-321841ba84f12124d94039cd8bbf60b3d342f6e3.tar.bz2
pygobject2-321841ba84f12124d94039cd8bbf60b3d342f6e3.zip
Imported Upstream version 3.9.5
Change-Id: I5c00e3743d666bd221bb85dff935baa1a9838070 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'tests/test_docstring.py')
-rw-r--r--tests/test_docstring.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/test_docstring.py b/tests/test_docstring.py
new file mode 100644
index 0000000..1628295
--- /dev/null
+++ b/tests/test_docstring.py
@@ -0,0 +1,49 @@
+import unittest
+
+import gi.docstring
+from gi.repository import GIMarshallingTests
+
+
+class Test(unittest.TestCase):
+ def test_api(self):
+ new_func = lambda info: 'docstring test'
+ old_func = gi.docstring.get_doc_string_generator()
+
+ gi.docstring.set_doc_string_generator(new_func)
+ self.assertEqual(gi.docstring.get_doc_string_generator(),
+ new_func)
+ self.assertEqual(gi.docstring.generate_doc_string(None),
+ 'docstring test')
+
+ # Set back to original generator
+ gi.docstring.set_doc_string_generator(old_func)
+ 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')
+
+ def test_overridden_doc_is_not_clobbered(self):
+ self.assertEqual(GIMarshallingTests.OverridesObject.method.__doc__,
+ 'Overridden doc string.')