HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_xmlrpc.cpython-37.pyc
B

��g���@s�ddlZddlZddlZddlZddlZddlZddlmZddlmZ	ddl
ZddlZ
ddl
Z
ddlZ
ddlZddlZddlZddlZddlZddlmZy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%dLd!d"�Z&dMd#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=ej�Z4Gd>d?�d?e
jj5�Z6Gd@dA�dAej�Z7ej8dNdCdD��Z9GdEdF�dFej�Z:GdGdH�dHej�Z;ej<dIdJ��Z=e>dKk�r�e=�dS)O�N)�mock)�supportzfoo@bar.baz.spamgH�zns�@i�z.zyx.41smy dog has fleasFu	䀀怀耀z
regular valuez20050210T11:41:23)	i�r�
��)�r����i�rrrr)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+S),�XMLRPCTestCasecCs.t�tf�}t�|�}|�t|dd�dS)Nr)�	xmlrpclib�dumps�alist�loads�assertEqual)�self�dump�load�r�,/usr/local/lib/python3.7/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)Ni�rrrrrz20050210T11:41:23T)�use_builtin_typesF)Zuse_datetime)	�datetimerr�DateTimer
r�assertIs�type�assertIsNone)r�dt�s�result�m�newdtrrr�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	rrrrrz00010210T11:41:23T)rF)	rrrrr
rrrr)rrrrr r!rrr�test_datetime_before_1900Ss
z(XMLRPCTestCase.test_datetime_before_1900cCsRt��}t�tj|fdd��\\}}|�|jt�tj|fdd�}|�|t�dS)NT)�methodresponse)rrrr
ZassertIsInstance�value�str)r�dZnew_d�dummyrrrr�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�Tpsr-�dZHello)�object�x�yrrr
r�__dict__)rr-�t�t2r(rrr�test_newstyle_classosz"XMLRPCTestCase.test_newstyle_classcCs|�ttjddf�dS)Nr�c)�assertRaises�
OverflowErrorrr
)rrrr�test_dump_big_longxsz!XMLRPCTestCase.test_dump_big_longcCs|�ttjddif�dS)N)r	r�r	)r7�	TypeErrorrr
)rrrr�test_dump_bad_dict{sz!XMLRPCTestCase.test_dump_bad_dictcCs6dddg}ddd|g}|�|�|�ttj|f�dS)Nr	rr:��)�appendr7r;rr
)r�lr3rrr�test_dump_recursive_seq~s

z&XMLRPCTestCase.test_dump_recursive_seqcCs2ddd�}d|d�}||d<|�ttj|f�dS)Nr	)�1�2r:)�3r'r3)r7r;rr
)rr'r3rrr�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���lr	cSsdS)Nr)rrrr�dummy_write�sz5XMLRPCTestCase.test_dump_big_int.<locals>.dummy_write)�sys�maxsizer7r8rr
�int�MAXINT�MININT�
MarshallerZdump_int)rrFr 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)Nl�*cSsdS)Nr)rrrrrF�sz4XMLRPCTestCase.test_dump_double.<locals>.dummy_write)rr
�floatrJrKrLZdump_double)rrFr rrr�test_dump_double�szXMLRPCTestCase.test_dump_doublecCsTtdg}tdgf}tj|dd�}|�|t�|�dd�|�ttj|f�dS)NT)�
allow_noner)rrr
rrr7r;)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€¤ziso-8859-15)�encodingz,<?xml version='1.0' encoding='iso-8859-15'?>r�xmlcharrefreplaceT)rTr$umethod€¤)rT�
methodnamer	)rr
rr�encode)rr%rRrVrrr�test_dump_encoding�s"

z!XMLRPCTestCase.test_dump_encodingcCs�d}|�|t�|��x�tttjfD]�}||�}t�|f�}tj|dd�\}}|\}|�||�|�t|�t�|�	|�tj|dd�\}}|\}|�||�|�t|�tj�|�	|�q$WdS)Nsmy dog has fleasT)rF)
rr�Binary�bytes�	bytearrayr
rrrr)rZsampleZtype_r%rrr �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�
ResponseErrorr7r)rr^�datarrr�test_loads_unsupported�sz%XMLRPCTestCase.test_loads_unsupportedcKsNd|}tj|f|�\}}|\}|�||�|�t|�t|��|�|�dS)Nz1<params><param><value>%s</value></param></params>)rrrrrr)rrr%�kwargsrrr r\rrr�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�T)rz6<dateTime.iso8601>20050210T11:41:23</dateTime.iso8601>z20050210T11:41:23i�rrrrrzR<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)rbrrYrr)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)rb�decimalZDecimal)rrfrrr�test_load_extension_typess





z(XMLRPCTestCase.test_load_extension_typescCs(tj��}|�|�d�ddgif�dS)Nz
user@host.tldzhost.tld)Z
AuthorizationzBasic dXNlcg==)�xmlrpc�client�	TransportrZ
get_host_info)rZtransprrr�test_get_host_infos
z!XMLRPCTestCase.test_get_host_infocCs�yddl}Wntk
r$d}YnXd}ytj�d���Wn<tk
r^|�|d�Yntk
rz|�	|�YnXdS)NrFTzhttps://localhost:9999z&xmlrpc client's error with SSL support)
�ssl�ImportErrorrkrl�ServerProxyZbad_function�NotImplementedErrorZassertFalse�OSError�
assertTrue)rroZhas_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�WdQRXdS)	Nc@s$eZdZdZdZdd�Zdd�ZdS)z@XMLRPCTestCase.test_keepalive_disconnect.<locals>.RequestHandlerzHTTP/1.1FcSs�t|j�d��}|j�|�|jr,d|_dStjddd�}|�	�}|�
tjj
�|�dt|��|��|j�|�d|_d|_dS)NzContent-LengthT)r>)r$F)rI�headers�getZrfile�read�handledZclose_connectionrr
rWZ
send_response�httpZ
HTTPStatusZOKZsend_header�lenZend_headersZwfile�write)r�length�responserrr�do_POST8szHXMLRPCTestCase.test_keepalive_disconnect.<locals>.RequestHandler.do_POSTcWsdS)Nr)r�format�argsrrr�log_messageGszLXMLRPCTestCase.test_keepalive_disconnect.<locals>.RequestHandler.log_messageN)r*r+r,�protocol_versionryrr�rrrr�RequestHandler4sr�cs$�j�td��������dS)Nr	)�socket�
settimeoutrO�handle_requestr)�serverrr�
run_serverKsz<XMLRPCTestCase.test_keepalive_disconnect.<locals>.run_serverr)�targetz
http://{}:{}/r>)rzr�ZBaseHTTPRequestHandlerZ
HTTPServerrZHOST�
addCleanup�server_close�	threading�Thread�start�joinr�Zserver_addressrrqr�method)rr�r��thread�url�pr)r�r�test_keepalive_disconnect3sz(XMLRPCTestCase.test_keepalive_disconnectN)r*r+r,rr"r#r)r5r9r<rArErMrPrSrXr]r`rbrgrjrnrur�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*r+r,�__doc__rrrr�DispatchExc\sr�c	szd}�fdd�}tj��}|�|����j��}|�d|�WdQRX��|jj	|f���
|jj���
|jj�dS)z$Calls explicitly registered function)r	rr:cs��|��dS)N)r�)�params)rrr�dispatched_funcgszQSimpleXMLRPCDispatcherTestCase.test_call_registered_func.<locals>.dispatched_funcr�N)
rkr��SimpleXMLRPCDispatcher�register_functionr7r��	_dispatchr�	exceptionr�r�	__cause__�__context__)r�
exp_paramsr��
dispatcher�exc_ctxr)rr�test_call_registered_func`s

z8SimpleXMLRPCDispatcherTestCase.test_call_registered_funcc	Cs~d}Gdd�d�}tj��}|�|��|�|j��}|�d|�WdQRX|�|jj	|f�|�
|jj�|�
|jj�dS)z3Calls a registered instance attribute as a function)r	rr:c@seZdZdd�ZdS)zOSimpleXMLRPCDispatcherTestCase.test_call_instance_func.<locals>.DispatchedClasscWst�|��dS)N)r�r�)rr�rrrr�zsz_SimpleXMLRPCDispatcherTestCase.test_call_instance_func.<locals>.DispatchedClass.dispatched_funcN)r*r+r,r�rrrr�DispatchedClassysr�r�N)
rkr�r��register_instancer7r�r�rr�r�rr�r�)rr�r�r�r�rrr�test_call_instance_funcrs
z6SimpleXMLRPCDispatcherTestCase.test_call_instance_funcc	Cs�d}d}Gdd�d�}tj��}|�|��|�|j��}|�||�WdQRX|�|jj	||f�|�
|jj�|�
|jj�dS)z4Calls the registered instance's `_dispatch` functionr�)r	rr:c@seZdZdd�ZdS)zLSimpleXMLRPCDispatcherTestCase.test_call_dispatch_func.<locals>.TestInstancecSst�||��dS)N)r�r�)rr�r�rrrr��szVSimpleXMLRPCDispatcherTestCase.test_call_dispatch_func.<locals>.TestInstance._dispatchN)r*r+r,r�rrrr�TestInstance�sr�N)
rkr�r�r�r7r�r�rr�r�rr�r�)rZ
exp_methodr�r�r�r�rrr�test_call_dispatch_func�s
z6SimpleXMLRPCDispatcherTestCase.test_call_dispatch_funcc	Cs@tj��}|jddd�|�td��|�dd�WdQRXdS)z2Calls explicitly registered function which is NoneNr�)�name)�param)rkr�r�r��assertRaisesRegex�	Exceptionr�)rr�rrr�test_registered_func_is_none�s
z;SimpleXMLRPCDispatcherTestCase.test_registered_func_is_nonec	Cs>tj��}|�t��|�td��|�dd�WdQRXdS)z>Attempts to call nonexistent function on a registered instancer�)r�N)rkr�r�r�r/r�r�r�)rr�rrr�test_instance_has_no_func�s
z8SimpleXMLRPCDispatcherTestCase.test_instance_has_no_funcc	Cs2tj��}|�td��|�dd�WdQRXdS)z2Calls a function that the dispatcher cannot locater�)r�N)rkr�r�r�r�r�)rr�rrr�test_cannot_locate_func�s
z6SimpleXMLRPCDispatcherTestCase.test_cannot_locate_funcN)r*r+r,r�r�r�r�r�r�r�r�rrrrr�[sr�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�escape)rrrr�test_escape�szHelperTestCase.test_escapeN)r*r+r,r�rrrrr��sr�c@s$eZdZdd�Zdd�Zdd�ZdS)�
FaultTestCasecCs4t�dd�}|�t|�d�|�t|�t|��dS)NrNz
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)NrNz
Test Fault)�	faultCode�faultString)rr�r
rrrLr7)rr�rZnewfr rrr�test_dump_fault�szFaultTestCase.test_dump_faultcCs,|�ttjjtd�|�tj�td��dS)N�__add�title)r7�AttributeErrorrkr��resolve_dotted_attributer&rt)rrrr�test_dotted_attribute�sz#FaultTestCase.test_dotted_attributeN)r*r+r,r�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	|��WdQRXdS)
Nztime.localtimei���r��1��z%Y%m%dT%H:%M:%S)rZpatch�timeZstruct_timeZreturn_value�	localtimerrrr&�strftime)rZlocaltime_mockZtime_structr�r3rrr�test_default�s
zDateTimeTestCase.test_defaultc	Cs0d}t�|�}|�t|�t�dt�|���dS)Ngl]�ޮ��Az%Y%m%dT%H:%M:%S)rrrr&r�r�r�)rr'r3rrr�	test_time�s

zDateTimeTestCase.test_timecCs"d}t�|�}|�t|�d�dS)N)	i���	r�&�2r>�rz20070609T10:38:50)rrrr&)rr'r3rrr�test_time_tuple�s
z DateTimeTestCase.test_time_tuplecCs0t�d�}t�|�}|�t|�t�d|��dS)Ngl]�ޮ��Az%Y%m%dT%H:%M:%S)r�r�rrrr&r�)rr'r3rrr�test_time_struct�s

z!DateTimeTestCase.test_time_structcCs2t�dddddd�}t�|�}|�t|�d�dS)Ni�r	rr:r=r>z20070102T03:04:05)rrrrr&)rr'r3rrr�test_datetime_datetime�s
z'DateTimeTestCase.test_datetime_datetimecCs>t�dddddd�}t�|�}dt|�}|�t|�|�dS)Ni�r	rr:r=r>z%<DateTime '20070102T03:04:05' at %#x>)rrr�idrr�)rr'r3�valrrrr��s
zDateTimeTestCase.test_reprc
CsVd}t��}|�|�t�t�dddddd��}|�||�t�|�}|�||�dS)Nz 20070908T07:11:13  i�r��r�r�
)rr�decoderrZ	_datetime)rr'�t1Ztrefr4rrr�test_decode�s

zDateTimeTestCase.test_decodec	Cs�tj��}t�|���}|�||k�|�||k�|tjdd�}|�||k�|�||k�|�d�}|�||k�|�||k�t�|���}|�||k�|�||k�|�d�}|��}|�	t
��|dkWdQRX|�	t
��||kWdQRX|�	t
��|t|�kWdQRX|�	t
��||kWdQRX|�	t
��|td�kWdQRX|�	t
��||kWdQRX|�	t
��|t|�kWdQRX|�	t
��||kWdQRXdS)Nr=)Zsecondsz%Y%m%dT%H:%M:%S�asciii�)
r�nowrrZ	timetuplertZ	timedeltar�rWr7r;r[rO)rr�ZdtimeZthenZdstrZ
dtime_thenZdbytesZdtuplerrr�test_comparison�s>


z DateTimeTestCase.test_comparisonN)r*r+r,r�r�r�r�r�r�r�r�rrrrr��s

r�c@s$eZdZdd�Zdd�Zdd�ZdS)�BinaryTestCasecCst��}|�t|�d�dS)N�)rrYrr&)rr3rrrr�-szBinaryTestCase.test_defaultcCs(d}t�|�}|�t|�t|d��dS)Nsabc123��zlatin-1)rrYrr&)rr'r3rrr�test_string1s
zBinaryTestCase.test_stringcCsZd}t�|�}t��}|�|�|�t|�t|d��t�|�}|�t|�t|d��dS)Nsabc123��zlatin-1)�base64ZencodebytesrrYr�rr&Z_binary)rr'�der�r4rrrr�6s


zBinaryTestCase.test_decodeN)r*r+r,r�r�r�rrrrr�&sr�c
Cs0Gdd�d�}Gdd�dtjj�}|s.tjj}|d||ddd�}z�y�|��|j��\aadttfa	|�
�|��|��|�
t�|�
d	d
�d�|j
dd
��}|j
dd�dd��}|�}	|j|	dd�|��x|dkr�|��|d8}q�WWntjk
�rYnXWd|j��da|��XdS)Nc@s*eZdZdd�Zdd�ZGdd�d�ZdS)z&http_server.<locals>.TestInstanceClasscSs||S)Nr)rr0r1rrr�divHsz*http_server.<locals>.TestInstanceClass.divcSs|dkrdSdS)Nr�zThis is the div functionr)rr�rrr�_methodHelpKsz2http_server.<locals>.TestInstanceClass._methodHelpc@seZdZedd��ZdS)z.http_server.<locals>.TestInstanceClass.FixturecSsdS)N�42rrrrr�getDataPsz6http_server.<locals>.TestInstanceClass.Fixture.getDataN)r*r+r,�staticmethodr�rrrr�FixtureOsr�N)r*r+r,r�r�r�rrrr�TestInstanceClassGsr�c@seZdZdd�ZdS)z#http_server.<locals>.MyXMLRPCServercSs |j��\}}|�d�||fS)NT)r��accept�setblocking)rr�portrrr�get_requestUs
z/http_server.<locals>.MyXMLRPCServer.get_requestN)r*r+r,r�rrrr�MyXMLRPCServerTsr�)�	localhostrF)rT�logRequests�bind_and_activatezhttp://%s:%dcSs|S)Nr)r0rrr�<lambda>n�zhttp_server.<locals>.<lambda>utêštcSsdS)zThis is my functionTrrrrr�my_functionosz http_server.<locals>.my_function�add)r�cSs||S)Nr)r0r1rrr�_sszhttp_server.<locals>._T)Zallow_dotted_namesrr	)rkr��SimpleXMLRPCServer�SimpleXMLRPCRequestHandler�server_bindr��getsockname�ADDR�PORT�URL�server_activate� register_introspection_functions�register_multicall_functionsr��powr��setr��timeout�close)
�evt�numrequests�requestHandlerrTr�r��servr�r�ZtestInstancerrr�http_serverFs:





r	cCsxGdd�d�}dd�}Gdd�dtjj�}|s6tjj}Gdd�d|�}Gd	d
�d
�}|d|ddd
�}|j�d�|��z�y�|j��\aa	dtt	fa
|��ddg}	x.|	D]&}
|�|
tj�
��}|��|��q�W|�|	d��t�|�|	d��dd�d�|�d|��|��x |dk�r:|��|d8}�qWWntjk
�rVYnXWd|j��da	|��XdS)Nc@seZdZdd�Zdd�ZdS)z,http_multi_server.<locals>.TestInstanceClasscSs||S)Nr)rr0r1rrrr��sz0http_multi_server.<locals>.TestInstanceClass.divcSs|dkrdSdS)Nr�zThis is the div functionr)rr�rrrr��sz8http_multi_server.<locals>.TestInstanceClass._methodHelpN)r*r+r,r�r�rrrrr��sr�cSsdS)zThis is my functionTrrrrrr��sz&http_multi_server.<locals>.my_functionc@seZdZdd�ZdS)z)http_multi_server.<locals>.MyXMLRPCServercSs |j��\}}|�d�||fS)NT)r�r�r�)rrr�rrrr��s
z5http_multi_server.<locals>.MyXMLRPCServer.get_requestN)r*r+r,r�rrrrr��sr�c@seZdZgZdS)z+http_multi_server.<locals>.MyRequestHandlerN)r*r+r,Z	rpc_pathsrrrr�MyRequestHandler�sr
c@seZdZddd�ZdS)z+http_multi_server.<locals>.BrokenDispatcherNcSstd��dS)Nzbroken dispatcher)�RuntimeError)rr_Zdispatch_method�pathrrr�_marshaled_dispatch�sz?http_multi_server.<locals>.BrokenDispatcher._marshaled_dispatch)NN)r*r+r,r
rrrr�BrokenDispatcher�sr)r�rF)r�r�r:zhttp://%s:%dz/fooz/foo/barrr	cSs||S)Nr)r0r1rrrr��r�z#http_multi_server.<locals>.<lambda>r�z
/is/broken)rkr�ZMultiPathXMLRPCServerr�r�r�r�r�r�r�r�r�Zadd_dispatcherr�r�rZget_dispatcherr�rrr�rr)rrrr�r�r�r
rr�pathsrr'rrr�http_multi_server�s@



rcCs^y(|jdks|jdkrdS|j�d�}Wntk
rDt|�}YnX|rZd|��krZdSdS)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
NTzX-exceptionztemporarily unavailable)Zerrcodervrwr�r&�lower)�eZexc_messrrr�is_unavailable_exception�srcs|sdd�S�fdd�}|S)NcSs|S)Nr)�funcrrrr��r�z)make_request_and_skipIf.<locals>.<lambda>cs�fdd�}|S)Nc
sTyt�t���Wn2tjtfk
rD}zt|�s4�Wdd}~XYnXt����dS)N)	rrqr�r��
ProtocolErrorrsr�unittestZSkipTest)rr)�reasonrr�make_request_and_skip�szImake_request_and_skipIf.<locals>.decorator.<locals>.make_request_and_skipr)rr)rrr�	decorator�sz*make_request_and_skipIf.<locals>.decoratorr)Z	conditionrrr)rr�make_request_and_skipIf�s	rc@s,eZdZdZdZee�Zdd�Zdd�Z	dS)�BaseServerTestCaseNr	cCs`dtjj_t��|_|j|j|jf}tj	|j
|d�}|��|�|j
�|j��|j��dS)NT)r�r�)rkr�r��_send_traceback_headerr��Eventr�
request_countrr��
threadFuncr�r�r��wait�clear)r�	serv_argsr�rrr�setUp�s


zBaseServerTestCase.setUpcCs|j��dtjj_dS)NF)rr rkr�r�r)rrrr�tearDown�s
zBaseServerTestCase.tearDown)
r*r+r,rrr�r	rr#r$rrrrr�s
rc@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)&�SimpleServerTestCasecCsry"t�t�}|�|�dd�d�WnJtjtfk
rl}z&t|�s\|�d|t	|dd�f�Wdd}~XYnXdS)Nr�r�i�z%s
%srvr�)
rrqr�rrrrsr�fail�getattr)rr�rrrr�test_simple1s
z!SimpleServerTestCase.test_simple1cCs~d}d}y&t�t�}|�|�||�||�WnJtjtfk
rx}z&t|�sh|�d|t	|dd�f�Wdd}~XYnXdS)NuPŷtuhơnz%s
%srvr�)
rrqr�rr�rrsrr&r')r�start_string�
end_stringr�rrrr�
test_nonasciis
z"SimpleServerTestCase.test_nonasciicCs�d}d}y*tjtdd�}|�|�||�||�WnLtjtjfk
r~}z&t|�sn|�	d|t
|dd�f�Wdd}~XYnXdS)Nu€�¤ziso-8859-15)rTz%s
%srvr�)rrqr�rr�rr��errorrr&r')rr)r*r�rrrr�test_client_encodingsz)SimpleServerTestCase.test_client_encodingcCsvy$tjtdd�}|�|�d�d�WnLtjtjfk
rp}z&t|�s`|�	d|t
|dd�f�Wdd}~XYnXdS)Nr�)rTrNz%s
%srvr�)rrqr�rttêštrr�r-rr&r')rr�rrrr�test_nonascii_methodname+sz-SimpleServerTestCase.test_nonascii_methodnamecCsJtj�tt�}|�dd�|��}|��|�|j	d�|�|j
d�dS)NZPOSTz/this-is-not-validi�z	Not Found)rzrl�HTTPConnectionr�r�ZrequestZgetresponserr�statusr)r�connr~rrr�test_4045szSimpleServerTestCase.test_404cCs�tddddddddd	d
g
�}y(t�t�}|j��}|�t|�|�WnJtjtfk
r�}z&t	|�s~|�
d|t|dd
�f�Wdd}~XYnXdS)Nrr�r�r�utêštzsystem.listMethodszsystem.methodHelpzsystem.methodSignaturezsystem.multicallr�z%s
%srvr�)rrrqr��systemZlistMethodsrrrsrr&r')rZexpected_methodsr�Zmethrrrr�test_introspection1@s

z(SimpleServerTestCase.test_introspection1cCsvy&t�t�}|j�d�}|�|d�WnJtjtfk
rp}z&t|�s`|�	d|t
|dd�f�Wdd}~XYnXdS)Nr�zThis is the div functionz%s
%srvr�)rrqr�r4�
methodHelprrrsrr&r')rr�Zdivhelprrrr�test_introspection2Ps
z(SimpleServerTestCase.test_introspection2rz)Docstrings are omitted with -O2 and abovecCsvy&t�t�}|j�d�}|�|d�WnJtjtfk
rp}z&t|�s`|�	d|t
|dd�f�Wdd}~XYnXdS)Nr�zThis is my functionz%s
%srvr�)rrqr�r4r6rrrsrr&r')rr�Z
myfunctionrrrr�test_introspection3\s
z(SimpleServerTestCase.test_introspection3cCsvy&t�t�}|j�d�}|�|d�WnJtjtfk
rp}z&t|�s`|�	d|t
|dd�f�Wdd}~XYnXdS)Nr�zsignatures not supportedz%s
%srvr�)rrqr�r4ZmethodSignaturerrrsrr&r')rr�Zdivsigrrrr�test_introspection4js
z(SimpleServerTestCase.test_introspection4cCs�ylt�t�}t�|�}|�dd�|�dd�|�dd�|�\}}}|�|d�|�|d�|�|d�WnJtjt	fk
r�}z&t
|�s�|�d	|t|d
d�f�Wdd}~XYnXdS)Nrr:r�r��rNr>i�z%s
%srvr�)
rrqr��	MultiCallr�rr�rrrsrr&r')rr��	multicallZ
add_resultZ
pow_resultZ
div_resultrrrr�test_multicallws

z#SimpleServerTestCase.test_multicallcCs�yRt�t�}t�|�}|��|�}|�|jddd�|�|jddd�WnJtjtfk
r�}z&t	|�s�|�
d|t|dd�f�Wdd}~XYnXdS)	Nrr�r	r�z@<class 'Exception'>:method "this_is_not_exists" is not supportedz%s
%srvr�)rrqr�r;Zthis_is_not_existsr�resultsrrsrr&r')rr�r<rrrrr�test_non_existing_multicall�s


z0SimpleServerTestCase.test_non_existing_multicallcCs4|�ttjjtd�|�tj�td��|��dS)Nr�r�)r7r�rkr�r�r&rtr()rrrrr��sz*SimpleServerTestCase.test_dotted_attributecCs,t�dttf�}|j��}|�|d�dS)Nzhttp://%s:%d/RPC2r�)rrqr�r�r�r�r)rr�r_rrr�test_allow_dotted_names_true�s
z1SimpleServerTestCase.test_allow_dotted_names_truecCs*t�dttf�}|�|�dd�d�dS)Nzhttp://%s:%d/RPC2rd�éuaé)rrqr�r�rr�)rr�rrr�test_unicode_host�sz&SimpleServerTestCase.test_unicode_hostcCs8tj�tt�}|�dt�dt�d��d��|��dS)Nz@POST /RPC2 HTTP/1.0
Content-Length: 100

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

r�)rzrlr0r�r��sendrWr)rr2rrr�test_partial_post�sz&SimpleServerTestCase.test_partial_postc	CsJt�t��$}|�dd�|�|d�jd�WdQRX|�|d�jd�dS)Nrr:�	transport)NN)rrqr�r�ZassertNotEqual�_connectionr)rr�rrr�test_context_manager�sz)SimpleServerTestCase.test_context_managerc	CsTy&t�t��}|�dd�WdQRXWntjk
r<YnX|�|d�jd�dS)NrrdrF)NN)rrqr�r�r�rrG)rr�rrr�!test_context_manager_method_error�sz6SimpleServerTestCase.test_context_manager_method_errorN)r*r+r,r(r+r.r/r3r5r7rrG�flags�optimizer8r9r=r?r�r@rBrErHrIrrrrr%s$





r%c@s"eZdZeddd��Zdd�ZdS)�SimpleServerEncodingTestCaseNcCst|||d�dS)Nziso-8859-15)r	)rrrrTrrrr�sz'SimpleServerEncodingTestCase.threadFunccCs�d}d}y&t�t�}|�|�||�||�WnLtjtjfk
rz}z&t|�sj|�	d|t
|dd�f�Wdd}~XYnXdS)Nu€r,z%s
%srvr�)rrqr�rr�rr�r-rr&r')rr)r*r�rrrr�test_server_encoding�s
z1SimpleServerEncodingTestCase.test_server_encoding)NN)r*r+r,r�rrMrrrrrL�srLc@s0eZdZee�ZdZdd�Zdd�Zdd�Z	dS)	�MultiPathServerTestCasercCs:t�td�}|�|�dd�d�|�tj|jdd�dS)Nz/foor�r�i�)rrqr�rrr7r�r�)rr�rrr�
test_path1�sz"MultiPathServerTestCase.test_path1cCs:t�td�}|�|�dd�d�|�tj|jdd�dS)Nz/foo/barr�r��)rrqr�rr�r7r�r)rr�rrr�
test_path2�sz"MultiPathServerTestCase.test_path2cCs&t�td�}|�tj|jdd�dS)Nz
/is/brokenr�r�)rrqr�r7r�r�)rr�rrr�
test_path3�sz"MultiPathServerTestCase.test_path3N)
r*r+r,r�rrrrOrQrRrrrrrN�s
rNc@s,eZdZGdd�dejj�ZeZdd�ZdS)�BaseKeepaliveServerTestCasec@s,eZdZejjZdZgZdd�Z	dd�Z
dS)z*BaseKeepaliveServerTestCase.RequestHandlerzHTTP/1.1cCs(|j�g�t|j�d|_|j�|�S)Nr	)�
myRequestsr?r{�reqidx�parentClass�handle)rrrrrW�sz1BaseKeepaliveServerTestCase.RequestHandler.handlecCs$|j�|�}|j|j�|j�|S)N)rV�handle_one_requestrTrUr?Zraw_requestline)rrrrrrXsz=BaseKeepaliveServerTestCase.RequestHandler.handle_one_requestN)r*r+r,rkr�r�rVr�rTrWrXrrrrr��s
r�cCsg|j_t�|�S)N)r�rTrr#)rrrrr#sz!BaseKeepaliveServerTestCase.setUpN)	r*r+r,rkr�r�r�rr#rrrrrS�s
rSc@seZdZdd�ZdS)�KeepaliveServerTestCase1cCs�t�t�}|�|�dd�d�|�|�dd�d�|�|�dd�d�|d��|�t|jj�d�|�t|jjd�d�dS)Nr�r�i�rr	r
r)	rrqr�rrr{r�rT�assertGreaterEqual)rr�rrr�test_twos

z!KeepaliveServerTestCase1.test_twoN)r*r+r,r[rrrrrY
srYc@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�i�rrr
���)	rrqr�rrr{r�rTrZ)rr�rrr�
test_close$s


z#KeepaliveServerTestCase2.test_closecCs`t�t�}|�|�dd�d�|d���|�|�dd�d�|d��|�t|jj�d�dS)Nr�r�i�rFrr)	rrqr�rrrr{r�rT)rr�rrr�test_transport7s

z'KeepaliveServerTestCase2.test_transportN)r*r+r,rr^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.RequestHandlerzHTTP/1.1cCst|jd�|j_|j�|�S)Nzcontent-length)rIrv�	__class__�content_lengthrVr)rrrrrJsz)GzipServerTestCase.RequestHandler.do_POSTN)	r*r+r,rkr�r�rVr�rrrrrr�Fsr�c@s eZdZdZdd�Zdd�ZdS)zGzipServerTestCase.TransportFcCs t|�dd��|_tj�||�S)Nzcontent-lengthr)rIZ	getheader�response_lengthrrm�parse_response)rr~rrrrdSsz+GzipServerTestCase.Transport.parse_responsecCs"|jr|�dd�tj�|||�S)NzContent-Encoding�gzip)�	fake_gzipZ	putheaderrrm�send_content)rZ
connectionZbodyrrrrgWsz)GzipServerTestCase.Transport.send_contentN)r*r+r,rfrdrgrrrrrmPsrmcCst�|�dS)N)rr#)rrrrr#]szGzipServerTestCase.setUpcCsv|��}d|_tjt|d�}|�|�dd�d�|jj}d|_|�|�dd�d�|jj}|�	||k�|d��dS)N)rFr�r�i�rr)
rm�encode_thresholdrrqr�rrr�rbrt)rr3r�rdrerrr�test_gzip_request`sz$GzipServerTestCase.test_gzip_requestc	Cs`|��}d|_d|_tjt|d�}|�tjt�	d��}|�|�
dd�WdQRX|d��dS)NT)rFz\b400\br�r�r)rmrhrfrrqr�r�r�re�compiler)rr3r��cmrrr�test_bad_gzip_requestlsz(GzipServerTestCase.test_bad_gzip_requestcCs�|��}tjt|d�}|jj}d|j_|�|�dd�d�|j}d|j_|�|�dd�d�|d��|j}||j_|�	||k�dS)N)rFr�r�i�rr)
rmrrqr�rrhrrrcrt)rr3r��oldrdrerrr�test_gzip_responsews
z%GzipServerTestCase.test_gzip_responseN)r*r+r,rkr�r�r�rrrmr#rirmrorrrrr`Bs
r`c@seZdZdd�ZdS)�GzipUtilTestCasec	Cszd}d|}t�|�}t�|�}|�t|�|�d|d}t�|�}|�td��t�|�WdQRXtj|dd�dS)Ni@�r	z#max gzipped payload length exceededr
)Z
max_decode)rZgzip_encodeZgzip_decoderr{r��
ValueError)rZmax_gzip_decoder_ZencodedZdecodedrrr�test_gzip_decode_limit�s


z'GzipUtilTestCase.test_gzip_decode_limitN)r*r+r,rsrrrrrp�srpc@s$eZdZdd�Zdd�Zdd�ZdS)�ServerProxyTestCasecCstj�|�d|_dS)Nzhttp://fake.localhost)r�TestCaser#r�)rrrrr#�szServerProxyTestCase.setUpcCs"t�|j�}|�|d��d�dS)Nr)rrqr�r)rr�rrrr^�szServerProxyTestCase.test_closecCs,t��}tj|j|d�}|�|d�|�dS)N)rFrF)rrmrqr�r)rr3r�rrrr_�sz"ServerProxyTestCase.test_transportN)r*r+r,r#r^r_rrrrrt�srtcseZdZd�fdd�	Z�ZS)�FailingMessageClassNcs"|��}|dkrdSt��||�S)Nzcontent-lengthzI am broken)r�superrw)r�keyZfailobj)rarrrw�szFailingMessageClass.get)N)r*r+r,rw�
__classcell__rr)rarrv�srvc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�FailingServerTestCasecCsNt��|_|jdf}tjt|d�}|��|�|j�|j��|j�	�dS)Nr	)r�r�)
r�rrr�r	r�r�r�r r!)rr"r�rrrr#�s


zFailingServerTestCase.setUpcCs*|j��dtjj_tjj}|tjj	_
dS)NF)rr rkr�r�rrzrl�HTTPMessager��MessageClass)rZ
default_classrrrr$�s

zFailingServerTestCase.tearDowncCs�tjjj}|�|d�dtjj_y"t�t�}|�|�dd�d�WnJtj	t
fk
r�}z&t|�s||�d|t
|dd�f�Wdd}~XYnXdS)	NFTr�r�i�z%s
%srvr�)rkr�r�rrrrqr�rrrsrr&r')rZflagvalr�rrrr�
test_basic�s


z FailingServerTestCase.test_basicc
Cs�ttjj_yt�t�}|�dd�Wnftj	t
fk
r�}zBt|�szt|d�rz|�
|j�d�dk�|�
|j�d�dk�Wdd}~XYnX|�d�dS)Nr�r�rvzX-exceptionzX-tracebackzProtocolError not raised)rvrkr�r�r|rrqr�rrrsr�hasattrrtrvrwr&)rr�rrrr�test_fail_no_info�s

(z'FailingServerTestCase.test_fail_no_infoc
Cs�ttjj_dtjj_yt�t	�}|�
dd�Wnhtjtfk
r�}zDt
|�s�t|d�r�d}|�|j�d�|�|�|j�d�dk	�Wdd}~XYnX|�d�dS)	NTr�r�rvz5invalid literal for int() with base 10: 'I am broken'zX-exceptionzX-tracebackzProtocolError not raised)rvrkr�r�r|r�rrrqr�rrrsrr~rrvrwrtr&)rr�rZexpected_errrrr�test_fail_with_info�s


(z)FailingServerTestCase.test_fail_with_infoN)r*r+r,r#r$r}rr�rrrrrz�s
	rz�utf-8ccs4tj}tjt��|d�t_ztjVWd|t_XdS)zhA variation on support.captured_stdout() which gives a text stream
    having a `buffer` attribute.
    )rTN)rG�stdout�io�
TextIOWrapper�BytesIO)rTZorig_stdoutrrr�captured_stdouts
r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�CGIHandlerTestCasecCstj��|_dS)N)rkr��CGIXMLRPCRequestHandler�cgi)rrrrr#szCGIHandlerTestCase.setUpcCs
d|_dS)N)r�)rrrrr$szCGIHandlerTestCase.tearDownc
Cs�t���~}d|d<t|jjd��}|j��WdQRX|�d�|��}|��d}d�	|��dd��}|�
|d	�|�
|d
�WdQRXdS)NZGETZREQUEST_METHOD)rTrr	� rr=Z400zBad Request)r�EnvironmentVarGuardr�r�rTr��seekrx�splitr�r)r�env�data_outrWr1�messagerrr�test_cgi_gets

zCGIHandlerTestCase.test_cgi_getcCs�d}t���b}t|jjd��H}t���4}|�|�|�d�tt	|��|d<|j�
�WdQRXWdQRXWdQRX|�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>
        )rTrZCONTENT_LENGTH�,z<?xmlzContent-Length: (\d+)r	)rr�r�r�rTZcaptured_stdinr|r�r&r{r�rxr7rr�r�findrrIrj�search�group)rr_r�r�Zdata_inrWZcontentrrr�test_cgi_xmlrpc_response*s




(
z+CGIHandlerTestCase.test_cgi_xmlrpc_responseN)r*r+r,r#r$r�r�rrrrr�sr�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)Nsmy dog has fleasi�r>�����foobarcs�j�|�dS)N)�log�extend)r�)rrrr�_sz>UseBuiltinTypesTestCase.test_use_builtin_types.<locals>.foobarT)rQrTrr)r�rrr
rkr�r�r�r
rr{rrrZ)rZexpected_bytesZ
expected_dateZ	marshaledr��handlerZmybytesZmydater)rr�test_use_builtin_typesWs


z.UseBuiltinTypesTestCase.test_use_builtin_typescCstjjdd�}|�|j�dS)NT)r)rkr�r�rtr)rr�rrr�*test_cgihandler_has_use_builtin_types_flagkszBUseBuiltinTypesTestCase.test_cgihandler_has_use_builtin_types_flagcCs(tjjddd�}|��|�|j�dS)N)r�rT)r)rkr�r�r�rtr)rr�rrr�,test_xmlrpcserver_has_use_builtin_types_flagoszDUseBuiltinTypesTestCase.test_xmlrpcserver_has_use_builtin_types_flagN)r*r+r,r�r�r�rrrrr�Usr�cCs.t�tttttttt	t
ttt
ttttt�dS)N)rZrun_unittestrr�r�r�r�r�r%rLrYr\r`rprNrtrzr�r�rrrr�	test_mainvs
r��__main__)NN)N)r�)?r�rrirGr�rrZ
xmlrpc.clientrlrZ
xmlrpc.serverrkZhttp.clientrzZhttp.serverr�r�rjr��
contextlibZtestrrerprYr[rrrurr�r�r�r�r�r�r�r�r	rrrrr%rLrNrSrYr\ZskipIfr`rprtr{rvrz�contextmanagerr�r�r�Zreap_threadsr�r*rrrr�<module>s�
3WW
@
CJ"C
ND!