Your IP : 216.73.216.213


Current Path : /proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/test_docxmlrpc.cpython-34.pyo

�
g fK!�@s�ddlmZddlZddlZddlmZejd�Zddl	Z	ddl
Z
ddlZdadd�Z
dd�ZGd	d
�d
ej�Zdd�Zed
kr�e�ndS)�)�DocXMLRPCServerN)�support�	threadingcs&|sdd�S�fdd�}|S)NcSs|S)N�)�funcrr�8/opt/alt/python34/lib64/python3.4/test/test_docxmlrpc.py�<lambda>sz)make_request_and_skipIf.<locals>.<lambda>cs�fdd�}|S)Ncs3|jjdd�|jj�tj���dS)N�GET�/)�client�request�getresponse�unittestZSkipTest)�self)�reasonrr�make_request_and_skips
zImake_request_and_skipIf.<locals>.decorator.<locals>.make_request_and_skipr)rr)rrr�	decoratorsz*make_request_and_skipIf.<locals>.decoratorr)Z	conditionrrr)rr�make_request_and_skipIfs
rcCsVtddd�}z"y|jj�da|jd�|jd�|jd�Gd	d
�d
t�}|j�|j	|��dd�}t
d
dd��}Gdd�d�}|j|�|jdd��|j|�|j	|��x$|dkr|j�|d8}q�WWntj
k
r2YnXWd|j�da|j�XdS)N�	localhostrZlogRequestsF�z"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)zserver.<locals>.TestClasscSs
||_dS)z7Test method's docs. This method truly does very little.N)�arg)rrrrr�test_method*sz%server.<locals>.TestClass.test_methodN)�__name__�
__module__�__qualname__rrrrr�	TestClass)srcSs||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�add1szserver.<locals>.add)rcSs|S)z Use function annotations. r)rrrr�
annotation9szserver.<locals>.annotationc@s%eZdZeddd��ZdS)z#server.<locals>.ClassWithAnnotation)rcSs
|j�S)N)�decode)rrrrr�method_annotation>sz5server.<locals>.ClassWithAnnotation.method_annotationN)rrr�bytesr!rrrr�ClassWithAnnotation=sr#cSs||S)Nr)rrrrrrBszserver.<locals>.<lambda>)rr)r�socketZgetsockname�PORTZset_server_titleZset_server_nameZset_server_documentation�objectZ register_introspection_functionsZregister_instance�intZregister_functionZhandle_requestZtimeoutZserver_close�set)�evtZnumrequestsZservrrrr#rrr�servers2





	
r*c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zee	j
jdkd�d
d��Zee	j
jdkd�dd��Z
dd�Zdd�ZdS)�DocXMLRPCHTTPGETServercCs�tj�|_dt_tj�|_tjdt	d|jdf�j
�d}x3|dkr�tdkr�tj
d�|d8}qUWtjjdt�|_dS)	NT�target�argsri�rg����MbP?zlocalhost:%d)rZthreading_setup�_threadsr�_send_traceback_headerrZEventr)ZThreadr*�startr%�timeZsleep�httprZHTTPConnection)r�nrrr�setUpQs	%
zDocXMLRPCHTTPGETServer.setUpcCs7|jj�|jj�dt_tj|j�dS)NF)	r�closer)�waitrr/rZthreading_cleanupr.)rrrr�tearDownas

	zDocXMLRPCHTTPGETServer.tearDowncCs\|jjdd�|jj�}|j|jd�|j|jd�d�|j�dS)Nr	r
��zContent-typez	text/html)rrr
�assertEqual�status�	getheader�read)r�responserrr�test_valid_get_responsejs
z.DocXMLRPCHTTPGETServer.test_valid_get_responsecCs\|jjdd�|jj�}|j|jd�|j|jd�d�|j�dS)Nr	z/spami�zContent-typez
text/plain)rrr
r9r:r;r<)rr=rrr�test_invalid_get_responsets
z0DocXMLRPCHTTPGETServer.test_invalid_get_responsecCs<|jjdd�|jj�}|jd|j��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, "<lambda>".

        The subtraction lambda method is tested.
        r	r
sU<dl><dt><a name="-&lt;lambda&gt;"><strong>&lt;lambda&gt;</strong></a>(x, y)</dt></dl>N)rrr
�assertInr<)rr=rrr�test_lambda}s	z"DocXMLRPCHTTPGETServer.test_lambda�z)Docstrings are omitted with -O2 and abovecCs<|jjdd�|jj�j�}|jd|�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<dl><dt><a name="-add"><strong>add</strong></a>(x, y)</dt><dd><tt>Add&nbsp;two&nbsp;instances&nbsp;together.&nbsp;This&nbsp;follows&nbsp;<a href="http://www.python.org/dev/peps/pep-0008/">PEP008</a>,&nbsp;but&nbsp;has&nbsp;nothing<br>
to&nbsp;do&nbsp;with&nbsp;<a href="http://www.rfc-editor.org/rfc/rfc1952.txt">RFC1952</a>.&nbsp;Case&nbsp;should&nbsp;matter:&nbsp;pEp008&nbsp;and&nbsp;rFC1952.&nbsp;&nbsp;Things<br>
that&nbsp;start&nbsp;with&nbsp;http&nbsp;and&nbsp;ftp&nbsp;should&nbsp;be&nbsp;auto-linked,&nbsp;too:<br>
<a href="http://google.com">http://google.com</a>.</tt></dd></dl>N)rrr
r<r@)rr=rrr�test_autolinking�s
		z'DocXMLRPCHTTPGETServer.test_autolinkingcCs<|jjdd�|jj�j�}|jd|�dS)z�Test the precense of three consecutive system.* methods.

        This also tests their use of parameter type recognition and the
        systems related to that process.
        r	r
s�<dl><dt><a name="-system.methodHelp"><strong>system.methodHelp</strong></a>(method_name)</dt><dd><tt><a href="#-system.methodHelp">system.methodHelp</a>('add')&nbsp;=&gt;&nbsp;"Adds&nbsp;two&nbsp;integers&nbsp;together"<br>
&nbsp;<br>
Returns&nbsp;a&nbsp;string&nbsp;containing&nbsp;documentation&nbsp;for&nbsp;the&nbsp;specified&nbsp;method.</tt></dd></dl>
<dl><dt><a name="-system.methodSignature"><strong>system.methodSignature</strong></a>(method_name)</dt><dd><tt><a href="#-system.methodSignature">system.methodSignature</a>('add')&nbsp;=&gt;&nbsp;[double,&nbsp;int,&nbsp;int]<br>
&nbsp;<br>
Returns&nbsp;a&nbsp;list&nbsp;describing&nbsp;the&nbsp;signature&nbsp;of&nbsp;the&nbsp;method.&nbsp;In&nbsp;the<br>
above&nbsp;example,&nbsp;the&nbsp;add&nbsp;method&nbsp;takes&nbsp;two&nbsp;integers&nbsp;as&nbsp;arguments<br>
and&nbsp;returns&nbsp;a&nbsp;double&nbsp;result.<br>
&nbsp;<br>
This&nbsp;server&nbsp;does&nbsp;NOT&nbsp;support&nbsp;system.methodSignature.</tt></dd></dl>N)rrr
r<r@)rr=rrr�test_system_methods�s
z*DocXMLRPCHTTPGETServer.test_system_methodscCs<|jjdd�|jj�}|jd|j��dS)zTTest that selfdot values are made strong automatically in the
        documentation.r	r
s-Try&nbsp;self.<strong>add</strong>,&nbsp;too.N)rrr
r@r<)rr=rrr�test_autolink_dotted_methods�s	z3DocXMLRPCHTTPGETServer.test_autolink_dotted_methodscCsb|jjdd�|jj�}tjjdkr:dnd}|jd|d|j��dS)	z) Test that annotations works as expected r	r
rB�s5<dd><tt>Use&nbsp;function&nbsp;annotations.</tt></dd>sJ<dl><dt><a name="-annotation"><strong>annotation</strong></a>(x: int)</dt>se</dl>
<dl><dt><a name="-method_annotation"><strong>method_annotation</strong></a>(x: bytes)</dt></dl>N)rrr
�sys�flags�optimizer@r<)rr=Z	docstringrrr�test_annotations�sz'DocXMLRPCHTTPGETServer.test_annotationsN)rrrr4r7r>r?rArrGrHrIrCrDrErJrrrrr+Ps	
		r+cCstjt�dS)N)rZrun_unittestr+rrrr�	test_main�srK�__main__)Z
xmlrpc.serverrZhttp.clientr2rGZtestr�
import_modulerr1r$rr%rr*ZTestCaser+rKrrrrr�<module>s6�