summaryrefslogtreecommitdiff
path: root/tests/test_docstring.py
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:39:06 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-07-12 08:39:09 +0900
commit23384e73cb73bc8875384183d5916e33af4196d4 (patch)
treebe92faf8967d24f2be88a92b4f7506e9d65fbf3d /tests/test_docstring.py
parent705bf16f6a14a07ccdc0c1a5fe1b31d92c3bd96e (diff)
downloadpygobject2-23384e73cb73bc8875384183d5916e33af4196d4.tar.gz
pygobject2-23384e73cb73bc8875384183d5916e33af4196d4.tar.bz2
pygobject2-23384e73cb73bc8875384183d5916e33af4196d4.zip
Imported Upstream version 3.10.0
Change-Id: Ib97d541be276a6a70923c214755d8273c4437a2f 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.')