diff options
author | R David Murray <rdmurray@bitdance.com> | 2013-08-10 16:01:47 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2013-08-10 16:01:47 (GMT) |
commit | f22b62e26137e334e9a0beffd0de531955daf8ce (patch) | |
tree | a98d5fb518d5e09480cb70daea8bfdb62b4b908e /Lib/test/test_docxmlrpc.py | |
parent | 319163244aa00dd17c021aea0775c94a13bc8c97 (diff) | |
download | cpython-f22b62e26137e334e9a0beffd0de531955daf8ce.zip cpython-f22b62e26137e334e9a0beffd0de531955daf8ce.tar.gz cpython-f22b62e26137e334e9a0beffd0de531955daf8ce.tar.bz2 |
#8112: Update the documenting xmlrpc server to use getfullargspec.
Before this patch it would raise an error when trying to display
documentation for a method that used annotations.
Patch by Claudiu Popa.
Diffstat (limited to 'Lib/test/test_docxmlrpc.py')
-rw-r--r-- | Lib/test/test_docxmlrpc.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/Lib/test/test_docxmlrpc.py b/Lib/test/test_docxmlrpc.py index d6ca458..7086d9a 100644 --- a/Lib/test/test_docxmlrpc.py +++ b/Lib/test/test_docxmlrpc.py @@ -54,8 +54,18 @@ def server(evt, numrequests): """ return x + y + def annotation(x: int): + """ Use function annotations. """ + return x + + class ClassWithAnnotation: + def method_annotation(self, x: bytes): + return x.decode() + serv.register_function(add) serv.register_function(lambda x, y: x-y) + serv.register_function(annotation) + serv.register_instance(ClassWithAnnotation()) while numrequests > 0: serv.handle_request() @@ -177,10 +187,7 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase): b'method takes two integers as arguments' b'<br>\nand returns a double result.<br>\n ' b'<br>\nThis server does NOT support system' - b'.methodSignature.</tt></dd></dl>\n<dl><dt><a name="-test_method">' - b'<strong>test_method</strong></a>(arg)</dt><dd><tt>Test ' - b'method\'s docs. This method truly does' - b' very little.</tt></dd></dl>'), response) + b'.methodSignature.</tt></dd></dl>'), response) def test_autolink_dotted_methods(self): """Test that selfdot values are made strong automatically in the @@ -191,6 +198,18 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase): self.assertIn(b"""Try self.<strong>add</strong>, too.""", response.read()) + def test_annotations(self): + """ Test that annotations works as expected """ + self.client.request("GET", "/") + response = self.client.getresponse() + self.assertIn( + (b'<dl><dt><a name="-annotation"><strong>annotation</strong></a>' + b'(x: int)</dt><dd><tt>Use function annotations.</tt>' + b'</dd></dl>\n<dl><dt><a name="-method_annotation"><strong>' + b'method_annotation</strong></a>(x: bytes)</dt></dl>'), + response.read()) + + def test_main(): support.run_unittest(DocXMLRPCHTTPGETServer) |