a ze"@sjddlmZddlZddlZddlZddlZddlZddZddZ Gdddej Z e d krfe dS) )DocXMLRPCServerNcs|s ddSfdd}|S)NcSs|SN)funcrrG/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_docxmlrpc.py z)make_request_and_skipIf..csfdd}|S)Ncs&|jdd|jtdS)NGET/)clientrequest getresponseunittestZSkipTestselfreasonrrmake_request_and_skips zImake_request_and_skipIf..decorator..make_request_and_skipr)rrrrr decorator s z*make_request_and_skipIf..decoratorr)Z conditionrrrrrmake_request_and_skipIfs rcCstddd}z|d|d|dGdddt}|||d d }td d d }Gddd}|||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@seZdZddZdS)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. rxyrrradd*szmake_server..addrcSs|S)z Use function annotations. rr!rrr annotation2szmake_server..annotationc@seZdZedddZdS)z(make_server..ClassWithAnnotationr!cSs|Sr)decode)rrrrrmethod_annotation7sz:make_server..ClassWithAnnotation.method_annotationN)rrrbytesr$rrrrClassWithAnnotation6sr&cSs||Srrrrrrr;rzmake_server..) rset_server_titleZset_server_nameset_server_documentationobjectZ register_introspection_functionsZregister_instanceintZregister_function server_close)servrr r"r&rrr make_servers*       r-c@seZdZddZddZddZddZd d Zee j j d kd d dZ ee j j d kd ddZ ddZddZddZdS)DocXMLRPCHTTPGETServercCsLdt_t|_tj|jjd|_|j|jj d}t j d||_ dS)NT)targetz localhost:%d) r_send_traceback_headerr-r, threadingThreadZ serve_foreverthreadstartZserver_addresshttpr ZHTTPConnection)rZPORTrrrsetUpDs   zDocXMLRPCHTTPGETServer.setUpcCs2|jdt_|j|j|jdS)NF) r closerr1r,shutdownr4joinr+rrrrtearDownOs    zDocXMLRPCHTTPGETServer.tearDowncCsD|jdd|j}||jd||dd|dS)Nr r Content-typez text/htmlr r r assertEqualstatusZ getheaderreadrresponserrrtest_valid_get_responseXs  z.DocXMLRPCHTTPGETServer.test_valid_get_responsecCsD|jdd|j}||jd||dd|dS)Nr z/spamir=z text/plainr>rBrrrtest_invalid_get_responsebs  z0DocXMLRPCHTTPGETServer.test_invalid_get_responsecCs,|jdd|j}|d|dS)zTest 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)
Nr r r assertInrArBrrr test_lambdaks  z"DocXMLRPCHTTPGETServer.test_lambdaz)Docstrings are omitted with -O2 and abovecCs,|jdd|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 sN
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.
Nr r r rArGrBrrrtest_autolinkingys  z'DocXMLRPCHTTPGETServer.test_autolinkingcCs,|jdd|j}|d|dS)zTest 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.
NrJrBrrrtest_system_methodss z*DocXMLRPCHTTPGETServer.test_system_methodscCs,|jdd|j}|d|dS)zTTest that selfdot values are made strong automatically in the documentation.r r s-Try self.add, too.NrFrBrrrtest_autolink_dotted_methodss  z3DocXMLRPCHTTPGETServer.test_autolink_dotted_methodscCsH|jdd|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 sysflagsoptimizerGrA)rrCZ docstringrrrtest_annotationss z'DocXMLRPCHTTPGETServer.test_annotationscCs~|jd|jd|d|jj|d|jj|j}td| }td| }|d||d|dS)Nztest_title