Your IP : 216.73.217.129


Current Path : /opt/alt/python38/lib64/python3.8/test/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/test/__pycache__/test_xmlrpc.cpython-38.pyc

U

i�f^��@sddlZddlZddlZddlZddlZddlZddlmZddlmZ	ddl
ZddlZ
ddl
Z
ddlZ
ddlZddlZddlZddlZddlZddlmZzddlZWnek
r�dZYnXdddddge	�d	�d	ed	�d
dde	�d
�e	�d�e	�e�dddddd��d�gZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Z Gdd�dej�Z!Gdd �d ej�Z"da#a$a%dNd!d"�Z&dOd#d$�Z'd%d&�Z(d'd(�Z)Gd)d*�d*ej�Z*Gd+d,�d,e*�Z+Gd-d.�d.e*�Z,Gd/d0�d0e*�Z-Gd1d2�d2e*�Z.Gd3d4�d4e.�Z/Gd5d6�d6e.�Z0e�1edkd7�Gd8d9�d9e*��Z2e�1edkd7�Gd:d;�d;ej��Z3Gd<d=�d=e*�Z4Gd>d?�d?ej�Z5Gd@dA�dAe
jj6�Z7GdBdC�dCej�Z8ej9dPdEdF��Z:GdGdH�dHej�Z;GdIdJ�dJej�Z<ej=dKdL��Z>e?dMk�r�e>�dS)Q�N)�mock)�supportzfoo@bar.baz.spamgH�zns�@i�z.zyx.41�my dog has fleasFu	䀀怀耀z
regular value�20050210T11:41:23)	��r�
��)�r����rrr	r
r)ZastringZafloatZanintZ
ashortlongZanotherlistZabase64Zb64bytesZb64bytearrayZbooleanZunicodeuukey䀀Z	datetime1Z	datetime2Z	datetime3c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-S).�XMLRPCTestCasecCs.t�tf�}t�|�}|�t|dd�dS)Nr)�	xmlrpclib�dumps�alist�loads�assertEqual)�self�dump�load�r�5/opt/alt/python38/lib64/python3.8/test/test_xmlrpc.py�test_dump_load,s
zXMLRPCTestCase.test_dump_loadcCs6t�dddddd�}|�|t�d��t�|f�}tj|dd	�\}}|\}|�||�|�t|�tj�|�|�tj|d
d	�\}}|\}|�||�|�t|�tj�|�|�tj|dd�\}}|\}|�||�|�t|�tj�|�|�tj|d
d�\}}|\}|�||�|�t|�tj�|�|�dS)Nrrrr	r
rrT��use_builtin_typesF)Zuse_datetime�	�datetimerr�DateTimerr�assertIs�type�assertIsNone�rZdt�s�result�mZnewdtrrr�test_dump_bare_datetime1s.


z&XMLRPCTestCase.test_dump_bare_datetimecCs�t�dddddd�}|�|t�d��t�|f�}tj|dd	�\}}|\}|�||�|�t|�tj�|�|�tj|d
d	�\}}|\}|�||�|�t|�tj�|�|�dS)Nrrrr	r
rz00010210T11:41:23TrFrr"rrr�test_datetime_before_1900Ss
z(XMLRPCTestCase.test_datetime_before_1900cCsRt��}t�tj|fdd��\\}}|�|jt�tj|fdd�}|�|t�dS)NT��methodresponse)rrrrZassertIsInstance�value�str)r�dZnew_d�dummyr#rrr�test_bug_1164912es�zXMLRPCTestCase.test_bug_1164912cCsLGdd�dt�}|�}d|_d|_t�t�|f��\\}}|�||j�dS)Nc@seZdZdS)z-XMLRPCTestCase.test_newstyle_class.<locals>.TN)�__name__�
__module__�__qualname__rrrr�Tpsr2�dZHello)�object�x�yrrrr�__dict__)rr2�t�t2r-rrr�test_newstyle_classosz"XMLRPCTestCase.test_newstyle_classcCs|�ttjddf�dS)Nr�c)�assertRaises�
OverflowErrorrr�rrrr�test_dump_big_longxsz!XMLRPCTestCase.test_dump_big_longcCs|�ttjddif�dS)N�rr�r�r<�	TypeErrorrrr>rrr�test_dump_bad_dict{sz!XMLRPCTestCase.test_dump_bad_dictcCs6dddg}ddd|g}|�|�|�ttj|f�dS)NrrrA��)�appendr<rCrr)r�lr8rrr�test_dump_recursive_seq~s

z&XMLRPCTestCase.test_dump_recursive_seqcCs2ddd�}d|d�}||d<|�ttj|f�dS)Nr)�1�2rA)�3r,r8rB�rr,r8rrr�test_dump_recursive_dict�s

z'XMLRPCTestCase.test_dump_recursive_dictcCs�tjdkr |�ttjtd�f�t�tjtjf�|�ttjtjdf�|�ttjtjdf�dd�}t�	�}|�
tj|�|�
tj|�|�t|j
tjd|�|�t|j
tjd|�dS)Ni����rcSsdS�Nr�r#rrr�dummy_write�sz5XMLRPCTestCase.test_dump_big_int.<locals>.dummy_write)�sys�maxsizer<r=rr�int�MAXINT�MININT�
MarshallerZdump_int�rrRr%rrr�test_dump_big_int�s.

�

�

�
�
�z XMLRPCTestCase.test_dump_big_intcCs�t�td�f�t�ttj�ttj�f�t�ttjd�ttjd�f�dd�}t��}|�tj|�|�tj|�|�tjd|�|�tjd|�dS)NrO�*cSsdSrPrrQrrrrR�sz4XMLRPCTestCase.test_dump_double.<locals>.dummy_write)rr�floatrVrWrXZdump_doublerYrrr�test_dump_double�s��zXMLRPCTestCase.test_dump_doublecCsTtdg}tdgf}tj|dd�}|�|t�|�dd�|�ttj|f�dS)NT)�
allow_noner)rrrrrr<rC)rr*Zarg1�strgrrr�test_dump_none�s
�zXMLRPCTestCase.test_dump_nonecCs�ddi}tj|fdd�}d|}|�t�|�dd|�|�dd�}|�t�|�dd|�tj|fddd	�}|�t�|�dd|�|�dd�}|�t�|�dd|�d
}tj|fd|d�}|�t�|�dd|�|�t�|�d|�dS)
Nukey€¤u
value€¤�iso-8859-15��encodingz,<?xml version='1.0' encoding='iso-8859-15'?>r�xmlcharrefreplaceT)rcr)umethod€¤)rc�
methodnamer)rrrr�encode)rr*r_rerrr�test_dump_encoding�s(�
�
�z!XMLRPCTestCase.test_dump_encodingcCs�d}|�|t�|��tttjfD]�}||�}t�|f�}tj|dd�\}}|\}|�||�|�t|�t�|�	|�tj|dd�\}}|\}|�||�|�t|�tj�|�	|�q"dS)NrTrF)
rr�Binary�bytes�	bytearrayrrrr r!)rZsampleZtype_r*r#r$r%�newvaluerrr�test_dump_bytes�s
zXMLRPCTestCase.test_dump_bytescCsFtj}d}|�|tj|�d}|�|tj|�d}|�|tj|�dS)Nz6<params><param><value><spam/></value></param></params>zT<params><param><value><array><value><spam/></value></array></value></param></params>z�<params><param><value><struct><member><name>a</name><value><spam/></value></member><member><name>b</name><value><spam/></value></member></struct></value></param></params>)r�
ResponseErrorr<r)rrm�datarrr�test_loads_unsupported�sz%XMLRPCTestCase.test_loads_unsupportedcKsNd|}tj|f|�\}}|\}|�||�|�t|�t|��|�|�dS)Nz1<params><param><value>%s</value></param></params>)rrrrr r!)rr#r*�kwargsrr$r%rkrrr�check_loads�szXMLRPCTestCase.check_loadsc
Cs�|j}|dd�|dd�|dd�|dd�|dd�|d	d�|d
d�|dd
�|dt�d��|dddd�|dt�d��|dt�dddddd�dd�|dddg�|dddd��dS)N�stringz<string>string</string>u4<string>𝔘𝔫𝔦𝔠𝔬𝔡𝔢 string</string>u#𝔘𝔫𝔦𝔠𝔬𝔡𝔢 stringz<int>2056183947</int>i��zz<int>-2056183947</int>iuq�z<i4>2056183947</i4>z<double>46093.78125</double>g���@z<boolean>0</boolean>Fz%<base64>AGJ5dGUgc3RyaW5n/w==</base64>s
byte string�Trz6<dateTime.iso8601>20050210T11:41:23</dateTime.iso8601>rrrrr	r
rzR<array><data><value><int>1</int></value><value><int>2</int></value></data></array>rz�<struct><member><name>b</name><value><int>2</int></value></member><member><name>a</name><value><int>1</int></value></member></struct>)�a�b)rqrrhrr�r�checkrrr�test_load_standard_types�s:







������z'XMLRPCTestCase.test_load_standard_typescCs`|j}|dd�|dd�|dd�|dd�|dd�|d	d
�|dd�|d
t�d��dS)Nz<nil/>z	<ex:nil/>z<i1>205</i1>��z<i2>20561</i2>iQPz<i8>9876543210</i8>l�`	z-<biginteger>98765432100123456789</biginteger>l5�?�4*UUz<float>93.78125</float>grW@z.<bigdecimal>9876543210.0123456789</bigdecimal>z9876543210.0123456789)rq�decimalZDecimalrurrr�test_load_extension_typess




�
�z(XMLRPCTestCase.test_load_extension_typesc
Cs�|j}d}t�|��bd|d}|�t��|d|�d�d�W5QRX|�t��|d|�d�d�W5QRXW5QRXdS)Ni�rJrz<int>z</int>z<biginteger>z
</biginteger>)rqrZadjust_int_max_str_digitsr<�
ValueError)rrvZ	maxdigitsr#rrr�test_limit_intszXMLRPCTestCase.test_limit_intcCs(tj��}|�|�d�ddgif�dS)Nz
user@host.tldzhost.tld)Z
AuthorizationzBasic dXNlcg==)�xmlrpc�client�	TransportrZ
get_host_info)rZtransprrr�test_get_host_info(s
��z!XMLRPCTestCase.test_get_host_infocCs�zddl}Wntk
r$d}YnXd}ztj�d���Wn<tk
r^|�|d�Yntk
rz|�	|�YnXdS)NrFTzhttps://localhost:9999z&xmlrpc client's error with SSL support)
�ssl�ImportErrorr}r~�ServerProxyZbad_function�NotImplementedErrorZassertFalse�OSError�
assertTrue)rr�Zhas_sslrrr�test_ssl_presence/s
z XMLRPCTestCase.test_ssl_presencec	s�Gdd�dtjj�}�fdd�}tj�tjdf|��|��j�tj	|d�}|�
�|�|j�dj�j
�}t�|��&}|�|��d�|�|��d�W5QRXdS)	Nc@s$eZdZdZdZdd�Zdd�ZdS)z@XMLRPCTestCase.test_keepalive_disconnect.<locals>.RequestHandler�HTTP/1.1FcSs�t|j�d��}|j�|�|jr,d|_dStjddd�}|�	�}|�
tjj
�|�dt|��|��|j�|�d|_d|_dS)N�Content-LengthT)rFr(F)rU�headers�getZrfile�read�handledZclose_connectionrrrfZ
send_response�httpZ
HTTPStatusZOKZsend_header�lenZend_headersZwfile�write)rZlength�responserrr�do_POSTBszHXMLRPCTestCase.test_keepalive_disconnect.<locals>.RequestHandler.do_POSTcWsdSrPr)r�format�argsrrr�log_messageQszLXMLRPCTestCase.test_keepalive_disconnect.<locals>.RequestHandler.log_messageN)r/r0r1�protocol_versionr�r�r�rrrr�RequestHandler>sr�cs$�j�td��������dS�Nr)�socket�
settimeoutr\�handle_requestr��serverrr�
run_serverUsz<XMLRPCTestCase.test_keepalive_disconnect.<locals>.run_serverr)�targetz
http://{}:{}/rF)r�r�ZBaseHTTPRequestHandlerZ
HTTPServerrZHOST�
addCleanup�server_close�	threading�Thread�start�joinr�Zserver_addressrr�r�method)rr�r��thread�url�prr�r�test_keepalive_disconnect=sz(XMLRPCTestCase.test_keepalive_disconnectN)r/r0r1rr&r'r.r:r?rDrIrNrZr]r`rgrlrorqrwrzr|r�r�r�rrrrr*s,"
	

rc@sLeZdZGdd�de�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�SimpleXMLRPCDispatcherTestCasec@seZdZdZdS)z*SimpleXMLRPCDispatcherTestCase.DispatchExczSRaised inside the dispatched functions when checking for
        chained exceptionsN)r/r0r1�__doc__rrrr�DispatchExcfsr�c	szd}�fdd�}tj��}|�|����j��}|�d|�W5QRX��|jj	|f���
|jj���
|jj�dS)z$Calls explicitly registered functionr@cs��|��dSrP)r�)�paramsr>rr�dispatched_funcqszQSimpleXMLRPCDispatcherTestCase.test_call_registered_func.<locals>.dispatched_funcr�N)
r}r��SimpleXMLRPCDispatcher�register_functionr<r��	_dispatchr�	exceptionr�r!�	__cause__�__context__)r�
exp_paramsr��
dispatcher�exc_ctxrr>r�test_call_registered_funcjs

z8SimpleXMLRPCDispatcherTestCase.test_call_registered_funcc	Cs~d}Gdd�d�}tj��}|�|��|�|j��}|�d|�W5QRX|�|jj	|f�|�
|jj�|�
|jj�dS)z3Calls a registered instance attribute as a functionr@c@seZdZdd�ZdS)zOSimpleXMLRPCDispatcherTestCase.test_call_instance_func.<locals>.DispatchedClasscWst�|��dSrP�r�r�)rr�rrrr��sz_SimpleXMLRPCDispatcherTestCase.test_call_instance_func.<locals>.DispatchedClass.dispatched_funcN)r/r0r1r�rrrr�DispatchedClass�sr�r�N�
r}r�r��register_instancer<r�r�rr�r�r!r�r�)rr�r�r�r�rrr�test_call_instance_func|s
z6SimpleXMLRPCDispatcherTestCase.test_call_instance_funcc	Cs�d}d}Gdd�d�}tj��}|�|��|�|j��}|�||�W5QRX|�|jj	||f�|�
|jj�|�
|jj�dS)z4Calls the registered instance's `_dispatch` functionr�r@c@seZdZdd�ZdS)zLSimpleXMLRPCDispatcherTestCase.test_call_dispatch_func.<locals>.TestInstancecSst�||��dSrPr�)rr�r�rrrr��s�zVSimpleXMLRPCDispatcherTestCase.test_call_dispatch_func.<locals>.TestInstance._dispatchN)r/r0r1r�rrrr�TestInstance�sr�Nr�)rZ
exp_methodr�r�r�r�rrr�test_call_dispatch_func�s
z6SimpleXMLRPCDispatcherTestCase.test_call_dispatch_funcc	Cs@tj��}|jddd�|�td��|�dd�W5QRXdS)z2Calls explicitly registered function which is NoneNr���name�Zparam)r}r�r�r��assertRaisesRegex�	Exceptionr��rr�rrr�test_registered_func_is_none�s
z;SimpleXMLRPCDispatcherTestCase.test_registered_func_is_nonec	Cs>tj��}|�t��|�td��|�dd�W5QRXdS)z>Attempts to call nonexistent function on a registered instancer�r�N)r}r�r�r�r4r�r�r�r�rrr�test_instance_has_no_func�s
z8SimpleXMLRPCDispatcherTestCase.test_instance_has_no_funcc	Cs2tj��}|�td��|�dd�W5QRXdS)z2Calls a function that the dispatcher cannot locater�r�N)r}r�r�r�r�r�r�rrr�test_cannot_locate_func�s
z6SimpleXMLRPCDispatcherTestCase.test_cannot_locate_funcN)r/r0r1r�r�r�r�r�r�r�r�rrrrr�esr�c@seZdZdd�ZdS)�HelperTestCasecCs:|�t�d�d�|�t�d�d�|�t�d�d�dS)Nza&bza&amp;bza<bza&lt;bza>bza&gt;b)rr�escaper>rrr�test_escape�szHelperTestCase.test_escapeN)r/r0r1r�rrrrr��sr�c@s$eZdZdd�Zdd�Zdd�ZdS)�
FaultTestCasecCs4t�dd�}|�t|�d�|�t|�t|��dS)Nr[�
Test Faultz<Fault 42: 'Test Fault'>)r�Faultr�reprr+)r�frrr�	test_repr�szFaultTestCase.test_reprcCsjt�dd�}t�|f�}t�|�\\}}|�|ddd��|�|d�t���|�}|�tjtj|�dS)Nr[r�)�	faultCode�faultString)rr�rrrrXr<)rr�r#Znewfr%rrr�test_dump_fault�szFaultTestCase.test_dump_faultcCs,|�ttjjtd�|�tj�td��dS�NZ__add�title)r<�AttributeErrorr}r��resolve_dotted_attributer+r�r>rrr�test_dotted_attribute�s�z#FaultTestCase.test_dotted_attributeN)r/r0r1r�r�r�rrrrr��s
r�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�DateTimeTestCasecCsdt�d��P}t�dddddddddg	�}||_t��}t��}|�t	|�t�
d	|��W5QRXdS)
Nztime.localtimei���r��1���%Y%m%dT%H:%M:%S)rZpatch�time�struct_timeZreturn_value�	localtimerrrr+�strftime)rZlocaltime_mockZtime_structr�r8rrr�test_default�s�

�zDateTimeTestCase.test_defaultc	Cs0d}t�|�}|�t|�t�dt�|���dS�Ngl]�ޮ��Ar�)rrrr+r�r�r�rMrrr�	test_time�s


�zDateTimeTestCase.test_timecCs"d}t�|�}|�t|�d�dS)N)	����	r�&�2rF�rz20070609T10:38:50)rrrr+rMrrr�test_time_tuple�s
z DateTimeTestCase.test_time_tuplecCs0t�d�}t�|�}|�t|�t�d|��dSr�)r�r�rrrr+r�rMrrr�test_time_struct�s

z!DateTimeTestCase.test_time_structcCs2t�dddddd�}t�|�}|�t|�d�dS)Nr�rrrArErFz20070102T03:04:05)rrrrr+rMrrr�test_datetime_datetime�s
z'DateTimeTestCase.test_datetime_datetimecCs>t�dddddd�}t�|�}dt|�}|�t|�|�dS)Nr�rrrArErFz%<DateTime '20070102T03:04:05' at %#x>)rrr�idrr�)rr,r8�valrrrr��s
zDateTimeTestCase.test_reprc
CsVd}t��}|�|�t�t�dddddd��}|�||�t�|�}|�||�dS)Nz 20070908T07:11:13  r�r��r�r	�
)rr�decoderrZ	_datetime)rr,�t1Ztrefr9rrr�test_decode�s

zDateTimeTestCase.test_decodec	Cs�tj��}t�|���}|�||k�|�||k�|tjdd�}|�||k�|�||k�|�d�}|�||k�|�||k�t�|���}|�||k�|�||k�|�d�}|��}|�	t
��|dkW5QRX|�	t
��||kW5QRX|�	t
��|t|�kW5QRX|�	t
��||kW5QRX|�	t
��|td�kW5QRX|�	t
��||kW5QRX|�	t
��|t|�kW5QRX|�	t
��||kW5QRXdS)NrE)Zsecondsr��asciii�)
r�nowrrZ	timetupler�Z	timedeltar�rfr<rCrjr\)rr�ZdtimeZthenZdstrZ
dtime_thenZdbytesZdtuplerrr�test_comparison	s>


z DateTimeTestCase.test_comparisonN)r/r0r1r�r�r�r�r�r�r�r�rrrrr��s

r�c@s$eZdZdd�Zdd�Zdd�ZdS)�BinaryTestCasecCst��}|�t|�d�dS)N��rrhrr+)rr8rrrr�7szBinaryTestCase.test_defaultcCs(d}t�|�}|�t|�t|d��dS�Nsabc123��zlatin-1r�rMrrr�test_string;s
zBinaryTestCase.test_stringcCsZd}t�|�}t��}|�|�|�t|�t|d��t�|�}|�t|�t|d��dSr�)�base64Zencodebytesrrhr�rr+Z_binary)rr,Zder�r9rrrr�@s


zBinaryTestCase.test_decodeN)r/r0r1r�rr�rrrrr�0sr�c
Cs,Gdd�d�}Gdd�dtjj�}|s.tjj}|d||ddd�}z�z�|��|j�	�\a
adt
tfa|��|�
�|��|�t�|�d	d
�d�|jdd
��}|jdd�dd��}|�}	|j|	dd�|��|dkr�|��|d8}q�Wntjk
�r
YnXW5|j��da|��XdS)Nc@s*eZdZdd�Zdd�ZGdd�d�ZdS)z&http_server.<locals>.TestInstanceClasscSs||SrPr�rr5r6rrr�divRsz*http_server.<locals>.TestInstanceClass.divcSs|dkrdSdS�Nr�This is the div functionr�rr�rrr�_methodHelpUsz2http_server.<locals>.TestInstanceClass._methodHelpc@seZdZedd��ZdS)z.http_server.<locals>.TestInstanceClass.FixturecSsdS)N�42rrrrr�getDataZsz6http_server.<locals>.TestInstanceClass.Fixture.getDataN)r/r0r1�staticmethodr	rrrr�FixtureYsrN)r/r0r1rrrrrrr�TestInstanceClassQsrc@seZdZdd�ZdS)z#http_server.<locals>.MyXMLRPCServercSs |j��\}}|�d�||fS�NT�r�ZacceptZsetblocking�rr#Zportrrr�get_request_s
z/http_server.<locals>.MyXMLRPCServer.get_requestN�r/r0r1rrrrr�MyXMLRPCServer^sr�Z	localhostrF)rc�logRequests�bind_and_activate�http://%s:%dcSs|SrPr)r5rrr�<lambda>x�zhttp_server.<locals>.<lambda>�têštcSsdS��This is my functionTrrrrr�my_functionysz http_server.<locals>.my_function�addr�cSs||SrPr�r5r6rrr�_}szhttp_server.<locals>._T)Zallow_dotted_namesrr)r}r��SimpleXMLRPCServer�SimpleXMLRPCRequestHandlerr��close�PORT�set�server_bind�getsockname�ADDR�URL�server_activate� register_introspection_functions�register_multicall_functionsr��powr�r��timeout)
�evt�numrequests�requestHandlerrcrr�servrrZtestInstancerrr�http_serverPsB
�





r2cCspGdd�d�}dd�}Gdd�dtjj�}|s6tjj}Gdd�d|�}Gd	d
�d
�}|d|ddd
�}|j�d�|��z�z�|j�
�\aadttfa|�
�ddg}	|	D]&}
|�|
tj���}|��|��q�|�|	d��t�|�|	d��dd�d�|�d|��|�	�|dk�r4|��|d8}�qWntjk
�rNYnXW5|j��da|�	�XdS)Nc@seZdZdd�Zdd�ZdS)z,http_multi_server.<locals>.TestInstanceClasscSs||SrPrrrrrr�sz0http_multi_server.<locals>.TestInstanceClass.divcSs|dkrdSdSrrrrrrr�sz8http_multi_server.<locals>.TestInstanceClass._methodHelpN)r/r0r1rrrrrrr�srcSsdSrrrrrrr�sz&http_multi_server.<locals>.my_functionc@seZdZdd�ZdS)z)http_multi_server.<locals>.MyXMLRPCServercSs |j��\}}|�d�||fSr
rrrrrr�s
z5http_multi_server.<locals>.MyXMLRPCServer.get_requestNrrrrrr�src@seZdZgZdS)z+http_multi_server.<locals>.MyRequestHandlerN)r/r0r1Z	rpc_pathsrrrr�MyRequestHandler�sr3c@seZdZddd�ZdS)z+http_multi_server.<locals>.BrokenDispatcherNcSstd��dS)Nzbroken dispatcher)�RuntimeError)rrnZdispatch_method�pathrrr�_marshaled_dispatch�sz?http_multi_server.<locals>.BrokenDispatcher._marshaled_dispatch)NN)r/r0r1r6rrrr�BrokenDispatcher�sr7rF)rrrAr�/foo�/foo/barrrcSs||SrPrrrrrr�rz#http_multi_server.<locals>.<lambda>r�
/is/broken)r}r�ZMultiPathXMLRPCServerr!r�r�r%r"r#r$r&r'r(r)Zadd_dispatcherr�r*r+Zget_dispatcherr�r,r�r-)r.r/r0rrrr3r7r1�pathsr5r,rrr�http_multi_server�sD�



r<cCs`z*|jdks|jdkrWdS|j�d�}Wntk
rFt|�}YnX|r\d|��kr\dSdS)z�Returns True if the given ProtocolError is the product of a server-side
       exception caused by the 'temporarily unavailable' response sometimes
       given by operations on non-blocking sockets.r
NT�X-exceptionztemporarily unavailable)Zerrcoder�r�r�r+�lower)�eZexc_messrrr�is_unavailable_exception�sr@cs|sdd�S�fdd�}|S)NcSs|SrPr)�funcrrrr�rz)make_request_and_skipIf.<locals>.<lambda>cs�fdd�}|S)Nc
sTzt�t���Wn2tjtfk
rD}zt|�s4�W5d}~XYnXt����dSrP)	rr�r(r�
ProtocolErrorr�r@�unittestZSkipTest)rr?��reasonrr�make_request_and_skip�szImake_request_and_skipIf.<locals>.decorator.<locals>.make_request_and_skipr)rArFrDrr�	decorator�sz*make_request_and_skipIf.<locals>.decoratorr)Z	conditionrErGrrDr�make_request_and_skipIf�s	rHc@s,eZdZdZdZee�Zdd�Zdd�Z	dS)�BaseServerTestCaseNrcCs`dtjj_t��|_|j|j|jf}tj	|j
|d�}|��|�|j
�|j��|j��dS)NT�r�r�)r}r�r �_send_traceback_headerr��Eventr.�
request_countr0r��
threadFuncr�r�r��wait�clear�rZ	serv_argsr�rrr�setUp�s


zBaseServerTestCase.setUpcCs|j��dtjj_dS�NF)r.rOr}r�r rKr>rrr�tearDowns
zBaseServerTestCase.tearDown)
r/r0r1r0rMr
r2rNrRrTrrrrrI�s
rIc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	e
ejj
dkd�dd��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%S)&�SimpleServerTestCasecCsrz"t�t�}|�|�dd�d�WnJtjtfk
rl}z&t|�s\|�d|t	|dd�f�W5d}~XYnXdS)Nr�r����%s
%sr�r�)
rr�r(rr,rBr�r@�fail�getattr�rr�r?rrr�test_simple1s
z!SimpleServerTestCase.test_simple1cCs~d}d}z&t�t�}|�|�||�||�WnJtjtfk
rx}z&t|�sh|�d|t	|dd�f�W5d}~XYnXdS)NuPŷtuhơnrWr�r�)
rr�r(rrrBr�r@rXrY�rZstart_stringZ
end_stringr�r?rrr�
test_nonasciis
�z"SimpleServerTestCase.test_nonasciicCs�d}d}z*tjtdd�}|�|�||�||�WnLtjtjfk
r~}z&t|�sn|�	d|t
|dd�f�W5d}~XYnXdS)N�€�¤rarbrWr�r��rr�r(rrrBr��errorr@rXrYr\rrr�test_client_encoding's�z)SimpleServerTestCase.test_client_encodingcCsvz$tjtdd�}|�|�d�d�WnLtjtjfk
rp}z&t|�s`|�	d|t
|dd�f�W5d}~XYnXdS)Nr�rbr[rWr�r�)rr�r(rttêštrBr�rar@rXrYrZrrr�test_nonascii_methodname5sz-SimpleServerTestCase.test_nonascii_methodnamec	CsTt�tj�tt���}|�dd�|��}W5QRX|�	|j
d�|�	|jd�dS)NZPOSTz/this-is-not-validi�z	Not Found)�
contextlib�closingr�r~ZHTTPConnectionr'r#ZrequestZgetresponser�statusrE)r�connr�rrr�test_404?s
zSimpleServerTestCase.test_404cCs�tddddddddd	d
g
�}z(t�t�}|j��}|�t|�|�WnJtjtfk
r�}z&t	|�s~|�
d|t|dd
�f�W5d}~XYnXdS)Nr,rrrrzsystem.listMethodszsystem.methodHelpzsystem.methodSignaturezsystem.multicallrrWr�r�)r$rr�r(�systemZlistMethodsrrBr�r@rXrY)rZexpected_methodsr�Zmethr?rrr�test_introspection1Is�

z(SimpleServerTestCase.test_introspection1cCsvz&t�t�}|j�d�}|�|d�WnJtjtfk
rp}z&t|�s`|�	d|t
|dd�f�W5d}~XYnXdS)NrrrWr�r��rr�r(riZ
methodHelprrBr�r@rXrY)rr�Zdivhelpr?rrr�test_introspection2Ys
z(SimpleServerTestCase.test_introspection2rz)Docstrings are omitted with -O2 and abovecCsvz&t�t�}|j�d�}|�|d�WnJtjtfk
rp}z&t|�s`|�	d|t
|dd�f�W5d}~XYnXdS)NrrrWr�r�rk)rr�Z
myfunctionr?rrr�test_introspection3es
z(SimpleServerTestCase.test_introspection3cCsvz&t�t�}|j�d�}|�|d�WnJtjtfk
rp}z&t|�s`|�	d|t
|dd�f�W5d}~XYnXdS)Nrzsignatures not supportedrWr�r�)rr�r(riZmethodSignaturerrBr�r@rXrY)rr�Zdivsigr?rrr�test_introspection4ss
z(SimpleServerTestCase.test_introspection4cCs�zlt�t�}t�|�}|�dd�|�dd�|�dd�|�\}}}|�|d�|�|d�|�|d�WnJtjt	fk
r�}z&t
|�s�|�d	|t|d
d�f�W5d}~XYnXdS)NrrAr�r��r[rFrVrWr�r�)
rr�r(�	MultiCallrr,rrrBr�r@rXrY)rr��	multicallZ
add_resultZ
pow_resultZ
div_resultr?rrr�test_multicall�s

z#SimpleServerTestCase.test_multicallcCs�zRt�t�}t�|�}|��|�}|�|jddd�|�|jddd�WnJtjtfk
r�}z&t	|�s�|�
d|t|dd�f�W5d}~XYnXdS)	Nrr�rr�z@<class 'Exception'>:method "this_is_not_exists" is not supportedrWr�r�)rr�r(rpZthis_is_not_existsrZresultsrBr�r@rXrY)rr�rqr$r?rrr�test_non_existing_multicall�s

�z0SimpleServerTestCase.test_non_existing_multicallcCs4|�ttjjtd�|�tj�td��|��dSr�)r<r�r}r�r�r+r�r[r>rrrr��s�z*SimpleServerTestCase.test_dotted_attributecCs,t�dttf�}|j��}|�|d�dS)N�http://%s:%d/RPC2r)rr�r'r#rr	r)rr�rnrrr�test_allow_dotted_names_true�s
z1SimpleServerTestCase.test_allow_dotted_names_truecCs*t�dttf�}|�|�dd�d�dS)Nrtrs�éuaé)rr�r'r#rr�rr�rrr�test_unicode_host�sz&SimpleServerTestCase.test_unicode_hostc	CsBt�t�ttf���$}|�dt�dt�d��d��W5QRXdS)Nz@POST /RPC2 HTTP/1.0
Content-Length: 100

bye HTTP/1.1
Host: �:z2
Accept-Encoding: identity
Content-Length: 0

r�)rdrer�Zcreate_connectionr'r#�sendrf)rrgrrr�test_partial_post�s�z&SimpleServerTestCase.test_partial_postc	CsJt�t��$}|�dd�|�|d�jd�W5QRX|�|d�jd�dS)NrrA�	transport�NN)rr�r(rZassertNotEqual�_connectionrrwrrr�test_context_manager�s��z)SimpleServerTestCase.test_context_managerc	CsTz&t�t��}|�dd�W5QRXWntjk
r<YnX|�|d�jd�dS)Nrrsr|r})rr�r(rr�rr~rwrrr�!test_context_manager_method_error�s�z6SimpleServerTestCase.test_context_manager_method_errorN)r/r0r1r[r]rbrcrhrjrlrHrS�flags�optimizermrnrrrsr�rurxr{rr�rrrrrUs(



�



rUc@s"eZdZeddd��Zdd�ZdS)�SimpleServerEncodingTestCaseNcCst|||d�dS)Nra)r2)r.r/r0rcrrrrN�sz'SimpleServerEncodingTestCase.threadFunccCs�d}d}z&t�t�}|�|�||�||�WnLtjtjfk
rz}z&t|�sj|�	d|t
|dd�f�W5d}~XYnXdS)Nr^r_rWr�r�r`r\rrr�test_server_encoding�s
�z1SimpleServerEncodingTestCase.test_server_encoding)NN)r/r0r1r
rNr�rrrrr��sr�c@s0eZdZee�ZdZdd�Zdd�Zdd�Z	dS)	�MultiPathServerTestCasercCs:t�td�}|�|�dd�d�|�tj|jdd�dS)Nr8r�r�rV)rr�r(rr,r<r�r�rr�rrr�
test_path1�sz"MultiPathServerTestCase.test_path1cCs:t�td�}|�|�dd�d�|�tj|jdd�dS)Nr9r�r��)rr�r(rrr<r�r,r�rrr�
test_path2�sz"MultiPathServerTestCase.test_path2cCs&t�td�}|�tj|jdd�dS)Nr:r�r�)rr�r(r<r�rr�rrr�
test_path3�sz"MultiPathServerTestCase.test_path3N)
r/r0r1r
r<rNrMr�r�r�rrrrr��s
r�c@s,eZdZGdd�dejj�ZeZdd�ZdS)�BaseKeepaliveServerTestCasec@s,eZdZejjZdZgZdd�Z	dd�Z
dS)z*BaseKeepaliveServerTestCase.RequestHandlerr�cCs(|j�g�t|j�d|_|j�|�Sr�)�
myRequestsrGr��reqidx�parentClass�handler>rrrr�sz1BaseKeepaliveServerTestCase.RequestHandler.handlecCs$|j�|�}|j|j�|j�|SrP)r��handle_one_requestr�r�rGZraw_requestline)rr$rrrr�sz=BaseKeepaliveServerTestCase.RequestHandler.handle_one_requestN)r/r0r1r}r�r!r�r�r�r�r�rrrrr�s
r�cCsg|j_t�|�SrP)r�r�rIrRr>rrrrRsz!BaseKeepaliveServerTestCase.setUpN)	r/r0r1r}r�r!r�r0rRrrrrr��s
r�c@seZdZdd�ZdS)�KeepaliveServerTestCase1cCs�t�t�}|�|�dd�d�|�|�dd�d�|�|�dd�d�|d��|�t|jj�d�|�t|jjd�d�dS)Nr�r�rVr"rr
r�	rr�r(rr,r�r�r�ZassertGreaterEqualr�rrr�test_twos

z!KeepaliveServerTestCase1.test_twoN)r/r0r1r�rrrrr�sr�c@s eZdZdZdd�Zdd�ZdS)�KeepaliveServerTestCase2rcCs�t�t�}|�|�dd�d�|�|�dd�d�|�|�dd�d�|d��|�|�dd�d�|�|�dd�d�|�|�dd�d�|d��|�t|jj�d�|�t|jjd�d�|�t|jjd�d�dS)Nr�r�rVr"rr
���r�r�rrr�
test_close,s


z#KeepaliveServerTestCase2.test_closecCs`t�t�}|�|�dd�d�|d���|�|�dd�d�|d��|�t|jj�d�dS)Nr�r�rVr|r"r)	rr�r(rr,r"r�r�r�r�rrr�test_transport?s

z'KeepaliveServerTestCase2.test_transportN)r/r0r1rMr�r�rrrrr�(sr�z
requires gzipc@sVeZdZGdd�dejj�ZeZGdd�dej	�Z	dd�Z
dd�Zd	d
�Zdd�Z
d
S)�GzipServerTestCasec@s eZdZejjZdZdd�ZdS)z!GzipServerTestCase.RequestHandlerr�cCst|jd�|j_|j�|�S)N�content-length)rUr��	__class__�content_lengthr�r�r>rrrr�Rsz)GzipServerTestCase.RequestHandler.do_POSTN)	r/r0r1r}r�r!r�r�r�rrrrr�Nsr�c@s eZdZdZdd�Zdd�ZdS)zGzipServerTestCase.TransportFcCs t|�dd��|_tj�||�S)Nr�r)rUZ	getheader�response_lengthrr�parse_response)rr�rrrr�[sz+GzipServerTestCase.Transport.parse_responsecCs"|jr|�dd�tj�|||�S)NzContent-Encoding�gzip)�	fake_gzipZ	putheaderrr�send_content)rZ
connectionZbodyrrrr�_sz)GzipServerTestCase.Transport.send_contentN)r/r0r1r�r�r�rrrrrXsrcCst�|�dSrP)rIrRr>rrrrReszGzipServerTestCase.setUpcCsv|��}d|_tjt|d�}|�|�dd�d�|jj}d|_|�|�dd�d�|jj}|�	||k�|d��dS�N�r|r�r�rVrr")
r�encode_thresholdrr�r(rr,r�r�r�)rr8r�rsrtrrr�test_gzip_requesthsz$GzipServerTestCase.test_gzip_requestc	Cs`|��}d|_d|_tjt|d�}|�tjt�	d��}|�|�
dd�W5QRX|d��dS)NTr�z\b400\br�r�r")rr�r�rr�r(r�rB�re�compiler,)rr8r��cmrrr�test_bad_gzip_requestts�z(GzipServerTestCase.test_bad_gzip_requestcCs�|��}tjt|d�}|jj}d|j_|�|�dd�d�|j}d|j_|�|�dd�d�|d��|j}||j_|�	||k�dSr�)
rrr�r(r0r�rr,r�r�)rr8r��oldrsrtrrr�test_gzip_responses
z%GzipServerTestCase.test_gzip_responseN)r/r0r1r}r�r!r�r0rrrRr�r�r�rrrrr�Js
r�c@seZdZdd�ZdS)�GzipUtilTestCasec	Cszd}d|}t�|�}t�|�}|�t|�|�d|d}t�|�}|�td��t�|�W5QRXtj|dd�dS)Ni@�rz#max gzipped payload length exceededr
)Z
max_decode)rZgzip_encodeZgzip_decoderr�r�r{)rZmax_gzip_decodernZencodedZdecodedrrr�test_gzip_decode_limit�s


�z'GzipUtilTestCase.test_gzip_decode_limitN)r/r0r1r�rrrrr��sr�csreZdZGdd�dejj�ZeZdddddgZ�fdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Z�ZS)�HeadersServerTestCasecs eZdZdZ�fdd�Z�ZS)z$HeadersServerTestCase.RequestHandlerNcs|j|j_t���SrP)r�r��test_headers�superr�r>�r�rrr��s
z,HeadersServerTestCase.RequestHandler.do_POST)r/r0r1r�r��
__classcell__rrr�rr��sr�ZHostzAccept-EncodingzContent-Typez
User-Agentr�csd|j_t���SrP)r�r�r�rRr>r�rrrR�szHeadersServerTestCase.setUpcCsRt|jt|����}|�t|���|�|��D]\}}|�|�|�|�q2dSrP)�sorted�standard_headers�list�keysZassertListEqual�itemsrr�)rr�Z
additionalZ
expected_keys�keyr*rrr�assertContainsAdditionalHeaders�sz5HeadersServerTestCase.assertContainsAdditionalHeaderscCs@tjtdgd�}|�|�dd�d�|jj}|�|ddi�dS)N��X-Test�foo�r�r�r�rVr�r��rr�r(rr,r�r�r��rr�r�rrr�test_header�sz!HeadersServerTestCase.test_headercCsDtjtddgd�}|�|�dd�d�|jj}|�|ddd	��dS)
Nr�)�
X-Test-Second�barr�r�r�rVr�r�)r�r�r�r�rrr�test_header_many�s��z&HeadersServerTestCase.test_header_manycCs:tjtgd�}|�|�dd�d�|jj}|�|i�dS)Nr�r�r�rVr�r�rrr�test_header_empty�sz'HeadersServerTestCase.test_header_emptycCs>tjtdd�}|�|�dd�d�|jj}|�|ddi�dS)N)r�r�r�r�rVr�r�r�r�rrr�test_header_tuple�sz'HeadersServerTestCase.test_header_tuplecCsFtjtddi��d�}|�|�dd�d�|jj}|�|ddi�dS)Nr�r�r�r�r�rV)	rr�r(r�rr,r�r�r�r�rrr�test_header_items�sz'HeadersServerTestCase.test_header_items)r/r0r1r}r�r!r�r0r�rRr�r�r�r�r�r�r�rrr�rr��s�	r�c@s$eZdZdd�Zdd�Zdd�ZdS)�ServerProxyTestCasecCstj�|�d|_dS)Nzhttp://fake.localhost)rC�TestCaserRr�r>rrrrR�szServerProxyTestCase.setUpcCs"t�|j�}|�|d��d�dS)Nr")rr�r�rr�rrrr��szServerProxyTestCase.test_closecCs,t��}tj|j|d�}|�|d�|�dS)Nr�r|)rrr�r�r)rr8r�rrrr��sz"ServerProxyTestCase.test_transportN)r/r0r1rRr�r�rrrrr��sr�cseZdZd�fdd�	Z�ZS)�FailingMessageClassNcs"|��}|dkrdSt��||�S)Nr�zI am broken)r>r�r�)rr�Zfailobjr�rrr��szFailingMessageClass.get)N)r/r0r1r�r�rrr�rr��sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�FailingServerTestCasecCsNt��|_|jdf}tjt|d�}|��|�|j�|j��|j�	�dS)NrrJ)
r�rLr.r�r2r�r�r�rOrPrQrrrrR�s


zFailingServerTestCase.setUpcCs*|j��dtjj_tjj}|tjj	_
dSrS)r.rOr}r�r rKr�r~�HTTPMessager!�MessageClass)rZ
default_classrrrrTs

zFailingServerTestCase.tearDowncCs�tjjj}|�|d�dtjj_z"t�t�}|�|�dd�d�WnJtj	t
fk
r�}z&t|�s||�d|t
|dd�f�W5d}~XYnXdS)	NFTr�r�rVrWr�r�)r}r�r rKrrr�r(r,rBr�r@rXrY)rZflagvalr�r?rrr�
test_basics


z FailingServerTestCase.test_basicc
Cs�ttjj_zt�t�}|�dd�Wnftj	t
fk
r�}zBt|�szt|d�rz|�
|j�d�dk�|�
|j�d�dk�W5d}~XYnX|�d�dS)Nr�r�r�r=�X-traceback�ProtocolError not raised)r�r}r�r!r�rr�r(r,rBr�r@�hasattrr�r�r�rXrZrrr�test_fail_no_info#s

(z'FailingServerTestCase.test_fail_no_infoc
Cs�ttjj_dtjj_zt�t	�}|�
dd�Wnhtjtfk
r�}zDt
|�s�t|d�r�d}|�|j�d�|�|�|j�d�dk	�W5d}~XYnX|�d�dS)	NTr�r�r�z5invalid literal for int() with base 10: 'I am broken'r=r�r�)r�r}r�r!r�r rKrr�r(r,rBr�r@r�rr�r�r�rX)rr�r?Zexpected_errrrr�test_fail_with_info3s


(z)FailingServerTestCase.test_fail_with_infoN)r/r0r1rRrTr�r�r�rrrrr��s
	r��utf-8ccs4tj}tjt��|d�t_ztjVW5|t_XdS)zhA variation on support.captured_stdout() which gives a text stream
    having a `buffer` attribute.
    rbN)rS�stdout�io�
TextIOWrapper�BytesIO)rcZorig_stdoutrrr�captured_stdoutIs
r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�CGIHandlerTestCasecCstj��|_dSrP)r}r��CGIXMLRPCRequestHandler�cgir>rrrrRWszCGIHandlerTestCase.setUpcCs
d|_dSrP)r�r>rrrrTZszCGIHandlerTestCase.tearDownc
Cs�t���~}d|d<t|jjd��}|j��W5QRX|�d�|��}|��d}d�	|��dd��}|�
|d	�|�
|d
�W5QRXdS)NZGETZREQUEST_METHODrbrr� rrEZ400zBad Request)r�EnvironmentVarGuardr�r�rcr��seekr��splitr�r)r�env�data_outr�rf�messagerrr�test_cgi_get]s

zCGIHandlerTestCase.test_cgi_getcCs�d}t���b}t|jjd��H}t���4}|�|�|�d�tt	|��|d<|j�
�W5QRXW5QRXW5QRX|�d�|��}|�t
jt
j|dd��||�d�d�}|�tt�d|��d��t	|��dS)	Naw<?xml version='1.0'?>
        <methodCall>
            <methodName>test_method</methodName>
            <params>
                <param>
                    <value><string>foo</string></value>
                </param>
                <param>
                    <value><string>bar</string></value>
                </param>
            </params>
        </methodCall>
        rbrZCONTENT_LENGTH�,z<?xmlzContent-Length: (\d+)r)rr�r�r�rcZcaptured_stdinr�r�r+r�r�r�r<rr�r�findrrUr��search�group)rrnr�r�Zdata_inr�Zcontentrrr�test_cgi_xmlrpc_responseos(
��

(
�z+CGIHandlerTestCase.test_cgi_xmlrpc_responseN)r/r0r1rRrTr�r�rrrrr�Vsr�c@s$eZdZdd�Zdd�Zdd�ZdS)�UseBuiltinTypesTestCasecs�g�_d}t�dddddd�}t�||fd�}�fd	d
�}tjjdddd�}|�|�|�|���	t
�j�d
��j\}}��	�j||g���t|�tj���t|�t
�dS)Nri�rF�����foobarcs�j�|�dSrP)�log�extend)r�r>rrr��sz>UseBuiltinTypesTestCase.test_use_builtin_types.<locals>.foobarT)r^rcrr)r�rrrr}r�r�r�r6rr�rr ri)rZexpected_bytesZ
expected_dateZ	marshaledr��handlerZmybytesZmydaterr>r�test_use_builtin_types�s"�


z.UseBuiltinTypesTestCase.test_use_builtin_typescCstjjdd�}|�|j�dS)NTr)r}r�r�r�r)rr�rrr�*test_cgihandler_has_use_builtin_types_flag�szBUseBuiltinTypesTestCase.test_cgihandler_has_use_builtin_types_flagcCs(tjjddd�}|��|�|j�dS)NrTr)r}r�r r�r�rrwrrr�,test_xmlrpcserver_has_use_builtin_types_flag�s
�zDUseBuiltinTypesTestCase.test_xmlrpcserver_has_use_builtin_types_flagN)r/r0r1r�r�r�rrrrr��sr�cCs0t�tttttttt	t
ttt
tttttt�dSrP)rZrun_unittestrr�r�r�r�r�rUr�r�r�r�r�r�r�r�r�r�r�rrrr�	test_main�s"
�r��__main__)NN)N)r�)@rrryrSr�rCrZ
xmlrpc.clientr~rZ
xmlrpc.serverr}Zhttp.clientr�Zhttp.serverr�r�r�r�rdZtestrr�r�rhrjrrr�rr�r�r�r�r�r'r#r(r2r<r@rHrIrUr�r�r�r�r�ZskipIfr�r�r�r�r�r�r��contextmanagerr�r�r�Zreap_threadsr�r/rrrr�<module>s�
���=WW
@
CH"C>ND!