a 5êdg±"ã@sjddlmZddlZddlZddlZddlZddlZdd„Zdd„Z Gdd„dej ƒZ e d krfe  ¡dS) é)ÚDocXMLRPCServerNcs|s dd„S‡fdd„}|S)NcSs|S©N©)Úfuncrrú//usr/local/lib/python3.9/test/test_docxmlrpc.pyÚ óz)make_request_and_skipIf..cs‡fdd„}|S)Ncs&|j dd¡|j ¡t ˆ¡‚dS)NÚGETú/)ÚclientÚrequestÚ getresponseÚunittestZSkipTest©Úself©ÚreasonrrÚmake_request_and_skips zImake_request_and_skipIf..decorator..make_request_and_skipr)rrrrrÚ decorator s z*make_request_and_skipIf..decoratorr)Z conditionrrrrrÚmake_request_and_skipIfs rcCsÂtddd}zš| d¡| d¡| d¡Gdd„dtƒ}| ¡| |ƒ¡d d „}td œd d „}Gdd„dƒ}| |¡| dd„¡| |¡| |ƒ¡|WS|  ¡‚Yn0dS)N)Ú localhostrF)Z logRequestsz"DocXMLRPCServer Test DocumentationzDocXMLRPCServer Test DocszmThis is an XML-RPC server's documentation, but the server can be used by POSTing to /RPC2. Try self.add, too.c@seZdZdd„ZdS)zmake_server..TestClasscSs ||_dS)z7Test method's docs. This method truly does very little.N)Úarg)rrrrrÚ test_method#sz*make_server..TestClass.test_methodN)Ú__name__Ú __module__Ú __qualname__rrrrrÚ TestClass"srcSs||S)aAdd two instances together. This follows PEP008, but has nothing to do with RFC1952. Case should matter: pEp008 and rFC1952. Things that start with http and ftp should be auto-linked, too: http://google.com. r©ÚxÚyrrrÚadd*szmake_server..add©rcSs|S)z Use function annotations. rr!rrrÚ annotation2szmake_server..annotationc@seZdZedœdd„ZdS)z(make_server..ClassWithAnnotationr!cSs| ¡Sr)Údecode)rrrrrÚmethod_annotation7sz:make_server..ClassWithAnnotation.method_annotationN)rrrÚbytesr$rrrrÚClassWithAnnotation6sr&cSs||Srrrrrrr;rzmake_server..) rÚset_server_titleZset_server_nameÚset_server_documentationÚobjectZ register_introspection_functionsZregister_instanceÚintZregister_functionÚ server_close)Úservrr r"r&rrrÚ make_servers*   ÿ    r-c@s€eZdZdd„Zdd„Zdd„Zdd„Zd d „Zee j j d kd ƒd d„ƒZ ee j j d kd ƒdd„ƒZ dd„Zdd„Zdd„ZdS)ÚDocXMLRPCHTTPGETServercCsLdt_tƒ|_tj|jjd|_|j ¡|jj d}t j   d|¡|_ dS)NT)Útargetéz localhost:%d) rÚ_send_traceback_headerr-r,Ú threadingÚThreadZ serve_foreverÚthreadÚstartZserver_addressÚhttpr ZHTTPConnection)rZPORTrrrÚsetUpDs   zDocXMLRPCHTTPGETServer.setUpcCs2|j ¡dt_|j ¡|j ¡|j ¡dS)NF) r Úcloserr1r,Úshutdownr4Újoinr+rrrrÚtearDownOs    zDocXMLRPCHTTPGETServer.tearDowncCsD|j dd¡|j ¡}| |jd¡| | d¡d¡| ¡dS)Nr r éÈú Content-typez text/html©r r r Ú assertEqualÚstatusZ getheaderÚread©rÚresponserrrÚtest_valid_get_responseXs  z.DocXMLRPCHTTPGETServer.test_valid_get_responsecCsD|j dd¡|j ¡}| |jd¡| | d¡d¡| ¡dS)Nr z/spami”r=z text/plainr>rBrrrÚtest_invalid_get_responsebs  z0DocXMLRPCHTTPGETServer.test_invalid_get_responsecCs,|j dd¡|j ¡}| d| ¡¡dS)zéTest that lambda functionality stays the same. The output produced currently is, I suspect invalid because of the unencoded brackets in the HTML, "". The subtraction lambda method is tested. r r sU
<lambda>(x, y)
N©r r r ÚassertInrArBrrrÚ test_lambdaks  þz"DocXMLRPCHTTPGETServer.test_lambdaéz)Docstrings are omitted with -O2 and abovecCs,|j dd¡|j ¡ ¡}| d|¡dS)aTest that the server correctly automatically wraps references to PEPS and RFCs with links, and that it linkifies text starting with http or ftp protocol prefixes. The documentation for the "add" method contains the test material. r r sM
add(x, y)
Add two instances together. This follows PEP008, but has nothing
to do with RFC1952. Case should matter: pEp008 and rFC1952.  Things
that start with http and ftp should be auto-linked, too:
http://google.com.
N©r r r rArGrBrrrÚtest_autolinkingys  öz'DocXMLRPCHTTPGETServer.test_autolinkingcCs,|j dd¡|j ¡ ¡}| d|¡dS)z³Test the presence of three consecutive system.* methods. This also tests their use of parameter type recognition and the systems related to that process. r r sÕ
system.methodHelp(method_name)
system.methodHelp('add') => "Adds two integers together"
 
Returns a string containing documentation for the specified method.
system.methodSignature(method_name)
system.methodSignature('add') => [double, int, int]
 
Returns a list describing the signature of the method. In the
above example, the add method takes two integers as arguments
and returns a double result.
 
This server does NOT support system.methodSignature.
NrJrBrrrÚtest_system_methods‘s ðz*DocXMLRPCHTTPGETServer.test_system_methodscCs,|j dd¡|j ¡}| d| ¡¡dS)zTTest that selfdot values are made strong automatically in the documentation.r r s-Try self.add, too.NrFrBrrrÚtest_autolink_dotted_methods®s  ÿz3DocXMLRPCHTTPGETServer.test_autolink_dotted_methodscCsH|j dd¡|j ¡}tjjdkr(dnd}| d|d| ¡¡dS) z) Test that annotations works as expected r r rIrs5
Use function annotations.
sJ
annotation(x: int)
se
method_annotation(x: bytes)
N)r r r ÚsysÚflagsÚoptimizerGrA)rrCZ docstringrrrÚtest_annotations·s ÿÿÿûz'DocXMLRPCHTTPGETServer.test_annotationscCs~|j d¡|j d¡| d|jj¡| d|jj¡|j ¡}t d|¡  ¡}t d|¡  ¡}| d|¡| d|¡dS)Nztest_title