
    dafQ                        d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlmZ	 d dl
Zd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlmZmZmZ 	 d dlZ ej>                  d	       d
ddddg e	j@                  d      d e!d      ddd e	jD                  d       e	jD                  d       e	jD                   ej                  dddddd            dgZ# G d dejH                        Z% G d dejH                        Z& G d d ejH                        Z' G d! d"ejH                        Z( G d# d$ejH                        Z) G d% d&ejH                        Z*dxa+xa,a-dMd'Z.dNd(Z/d) Z0d* Z1 G d+ d,ejH                        Z2 G d- d.e2      Z3 G d/ d0e2      Z4 G d1 d2e2      Z5 G d3 d4e2      Z6 G d5 d6e6      Z7 G d7 d8e6      Z8 ejr                  edu d9       G d: d;e2             Z: ejr                  edu d9       G d< d=ejH                               Z; G d> d?e2      Z< G d@ dAejH                        Z= G dB dCej                  j|                        Z? G dD dEejH                        Z@ej                  dOdF       ZB G dG dHejH                        ZC G dI dJejH                        ZDdK ZEeFdLk(  r ej                          yy# e$ r dZY pw xY w)P    N)mock)support)	os_helper)socket_helper)threading_helper)	ALWAYS_EQLARGESTSMALLESTT)modulezfoo@bar.baz.spamgHzns@i      z.zyx.41   my dog has fleasFu	   䀀怀耀zregular value20050210T11:41:23)	  r   
      )      r      r   r   r   r   r   )astringafloatanint
ashortlonganotherlistabase64b64bytesb64bytearraybooleanunicodeu   ukey䀀	datetime1	datetime2	datetime3c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)XMLRPCTestCasec                     t        j                  t        f      }t        j                  |      }| j	                  t        |d   d          y )Nr   )	xmlrpclibdumpsalistloadsassertEqual)selfdumploads      +/root/Python-3.12.4/Lib/test/test_xmlrpc.pytest_dump_loadzXMLRPCTestCase.test_dump_load2   s8    x(t$Q
+    c                    t        j                   dddddd      }| j                  |t        j                  d             t        j                  |f      }t        j
                  |d	      \  }}|\  }| j                  ||       | j                  t        |      t         j                          | j                  |       t        j
                  |d
	      \  }}|\  }| j                  ||       | j                  t        |      t        j                         | j                  |       t        j
                  |d      \  }}|\  }| j                  ||       | j                  t        |      t         j                          | j                  |       t        j
                  |d
      \  }}|\  }| j                  ||       | j                  t        |      t        j                         | j                  |       y )Nr   r   r   r   r   r   r   Tuse_builtin_typesF)use_datetime	datetimer*   r&   DateTimer'   r)   assertIstypeassertIsNoner+   dtsresultmnewdts         r.   test_dump_bare_datetimez&XMLRPCTestCase.test_dump_bare_datetime7   s   
 tQBB7Y//0CDEOORE"OOA>	#d5k8#4#45!OOA?	#d5k9#5#56!OOAD9	#d5k8#4#45!OOAE:	#d5k9#5#56!r0   c                 V   t        j                   dddddd      }| j                  |t        j                  d             t        j                  |f      }t        j
                  |d	      \  }}|\  }| j                  ||       | j                  t        |      t         j                          | j                  |       t        j
                  |d
	      \  }}|\  }| j                  ||       | j                  t        |      t        j                         | j                  |       y )Nr   r   r   r   r   r   z00010210T11:41:23Tr2   Fr5   r;   s         r.   test_datetime_before_1900z(XMLRPCTestCase.test_datetime_before_1900Y   s    q1b"b"5Y//0CDEOORE"OOA>	#d5k8#4#45!OOA?	#d5k9#5#56!r0   c                 (   t        j                         }t        j                  t        j                  |fd            \  \  }}| j	                  |j
                  t               t        j                  |fd      }| j	                  |t               y )NTmethodresponse)r&   r7   r)   r'   assertIsInstancevaluestr)r+   dnew_ddummyr=   s        r.   test_bug_1164912zXMLRPCTestCase.test_bug_1164912k   sq     %OOIOOQD;?-A B%5ekk3/ OOUHT:a%r0   c                      G d dt               } |       }d|_        d|_        t        j                  t        j
                  |f            \  \  }}| j                  ||j                         y )Nc                       e Zd Zy)-XMLRPCTestCase.test_newstyle_class.<locals>.TN)__name__
__module____qualname__ r0   r.   TrP   v   s    r0   rU   d   Hello)objectxyr&   r)   r'   r*   __dict__)r+   rU   tt2rL   s        r.   test_newstyle_classz"XMLRPCTestCase.test_newstyle_classu   sV    	 	C"!)>?"QZZ(r0   c                 V    | j                  t        t        j                  ddz  f       y )Nr   c   )assertRaisesOverflowErrorr&   r'   r+   s    r.   test_dump_big_longz!XMLRPCTestCase.test_dump_big_long~   s    -1b5(Cr0   c                 T    | j                  t        t        j                  ddif       y )Nr   r      r   ra   	TypeErrorr&   r'   rc   s    r.   test_dump_bad_dictz!XMLRPCTestCase.test_dump_bad_dict   s    )Y__|oFr0   c                     g d}ddd|g}|j                  |       | j                  t        t        j                  |f       y )Nrf   rg         )appendra   ri   r&   r'   )r+   lr\   s      r.   test_dump_recursive_seqz&XMLRPCTestCase.test_dump_recursive_seq   s7    q1I	)Y__qd;r0   c                 n    ddd}d|d}||d<   | j                  t        t        j                  |f       y )Nr   )12rg   )3rJ   r\   rh   r+   rJ   r\   s      r.   test_dump_recursive_dictz'XMLRPCTestCase.test_dump_recursive_dict   s5    NN#)Y__qd;r0   c                 D   t         j                  dkD  r/| j                  t        t        j
                  t        d      f       t	        j
                  t        j                  t        j                  f       | j                  t        t        j
                  t        j                  dz   f       | j                  t        t        j
                  t        j                  dz
  f       d }t	        j                         }|j                  t        j                  |       |j                  t        j                  |       | j                  t        |j                  t        j                  dz   |       | j                  t        |j                  t        j                  dz
  |       y )Ni        r   c                      y NrT   r=   s    r.   dummy_writez5XMLRPCTestCase.test_dump_big_int.<locals>.dummy_write       r0   )sysmaxsizera   rb   r&   r'   intMAXINTMININT
Marshallerdump_intr+   r|   r?   s      r.   test_dump_big_intz XMLRPCTestCase.test_dump_big_int   s#   ;; mY__"5zm- 	))9+;+;<=-$++A-/	1-$++A-/	1	   "	

9##[1	

9##[1-#**1,k	;-#**1,k	;r0   c                    t        j                  t        d      f       t        j                  t        t         j                        t        t         j                        f       t        j                  t        t         j                  dz         t        t         j                  dz
        f       d }t        j
                         }|j                  t         j                  |       |j                  t         j                  |       |j                  t         j                  dz   |       |j                  t         j                  dz
  |       y )Nrx   *   c                      y rz   rT   r{   s    r.   r|   z4XMLRPCTestCase.test_dump_double.<locals>.dummy_write   r}   r0   )r&   r'   floatr   r   r   dump_doubler   s      r.   test_dump_doublezXMLRPCTestCase.test_dump_double   s    w)*y//0y//02 	3y//"45y//"457 	8	   "	i&&4	i&&4	i&&+[9	i&&+[9r0   c                     t         d gz   }t         d gz   f}t        j                  |d      }| j                  |t        j                  |      d   d          | j                  t        t        j                  |f       y )NT)
allow_noner   )r(   r&   r'   r*   r)   ra   ri   )r+   rH   arg1strgs       r.   test_dump_nonezXMLRPCTestCase.test_dump_none   si     t5#//$/215	7)Y__tg>r0   c                    ddi}t        j                  |fd      }d|z   }| j                  t        j                  |      d   d   |       |j	                  dd      }| j                  t        j                  |      d   d   |       t        j                  |fdd	      }| j                  t        j                  |      d   d   |       |j	                  dd      }| j                  t        j                  |      d   d   |       d
}t        j                  |fd|      }| j                  t        j                  |      d   d   |       | j                  t        j                  |      d   |       y )Nu   key€¤u
   value€¤iso-8859-15encodingz,<?xml version='1.0' encoding='iso-8859-15'?>r   xmlcharrefreplaceT)r   rF   u   method€¤)r   
methodnamer   )r&   r'   r*   r)   encode)r+   rH   r   r   s       r.   test_dump_encodingz!XMLRPCTestCase.test_dump_encoding   sM    "$x-@=D.q1!4e<{{=*=>.q1!4e<x-.24.q1!4e<{{=*=>.q1!4e<'
x-*46.q1!4e<.q1:>r0   c                 b   d}| j                  |t        j                  |             t        t        t        j                  fD ]  } ||      }t        j
                  |f      }t        j                  |d      \  }}|\  }| j                  ||       | j                  t        |      t               | j                  |       t        j                  |d      \  }}|\  }| j                  ||       | j                  t        |      t        j                         | j                  |        y )Nr   Tr2   F)
r*   r&   Binarybytes	bytearrayr'   r)   r8   r9   r:   )r+   sampletype_rH   r=   r>   r?   newvalues           r.   test_dump_byteszXMLRPCTestCase.test_dump_bytes   s    $!1!1&!9:Iy'7'77 	!E&ME)A!TBIFA KXXv.MM$x.%0a !UCIFA KXXv.MM$x.)*:*:;a 	!r0   c                     t         j                  }d}| j                  |t         j                  |       d}| j                  |t         j                  |       d}| j                  |t         j                  |       y )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&   ResponseErrorra   r)   )r+   r   datas      r.   test_loads_unsupportedz%XMLRPCTestCase.test_loads_unsupported   sf    !//G-$?4 	-$?5 	-$?r0   c                     d|z  }t        j                  |fi |\  }}|\  }| j                  ||       | j                  t	        |      t	        |             | j                  |       y )Nz1<params><param><value>%s</value></param></params>)r&   r)   r*   r8   r9   r:   )r+   r=   rH   kwargsr,   r>   r?   r   s           r.   check_loadszXMLRPCTestCase.check_loads   s^    BQFOOD3F3	5)d8nd5k2!r0   c                    | j                   } |dd        |dd        |dd        |dd        |dd        |d	d        |d
d        |dd        |dt        j                  d              |ddd        |dt        j                  d              |dt	        j                  dddddd      d        |dddg        |dddd       y )Nstringz<string>string</string>u4   <string>𝔘𝔫𝔦𝔠𝔬𝔡𝔢 string</string>u#   𝔘𝔫𝔦𝔠𝔬𝔡𝔢 stringz<int>2056183947</int>izz<int>-2056183947</int>iuqz<i4>2056183947</i4>z<double>46093.78125</double>g    @z<boolean>0</boolean>Fz%<base64>AGJ5dGUgc3RyaW5n/w==</base64>s    byte stringTr2   z6<dateTime.iso8601>20050210T11:41:23</dateTime.iso8601>r   r   r   r   r   r   r   zR<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)r   r&   r   r7   r6   r+   checks     r.   test_load_standard_typesz'XMLRPCTestCase.test_load_standard_types   s      h!'2DFkl%z2&4#Z0,k:$e,556	85$	>F  !45	7FaRR8 $	& 	  "#Q	) 	  "#+	-r0   c                     | j                   } |dd         |dd         |dd        |dd        |dd        |d	d
        |dd        |dt        j                  d             y )Nz<nil/>z	<ex:nil/>z<i1>205</i1>   z<i2>20561</i2>iQP  z<i8>9876543210</i8>l   `	 z-<biginteger>98765432100123456789</biginteger>l   5?4*UU z<float>93.78125</float>g     rW@z.<bigdecimal>9876543210.0123456789</bigdecimal>z9876543210.0123456789)r   decimalDecimalr   s     r.   test_load_extension_typesz(XMLRPCTestCase.test_load_extension_types  sr      hk4 nc"&#Z0="	$'2>oo56	8r0   c                 `   | j                   }d}t        j                  |      5  d|dz   z  }| j                  t              5   |d| dd        d d d        | j                  t              5   |d| dd        d d d        d d d        y # 1 sw Y   =xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Ni  rr   r   z<int>z</int>z<biginteger>z</biginteger>)r   r   adjust_int_max_str_digitsra   
ValueError)r+   r   	maxdigitsr=   s       r.   test_limit_intzXMLRPCTestCase.test_limit_int$  s      	..y9 	=y1}%A"":. /aS'./"":. =QC}5t<=		= 	=/ /= =		= 	=s;   B$BB$-B;B$B	B$B!	B$$B-c                     t         j                  j                         }| j                  |j	                  d      ddgi f       y )Nzuser@host.tldzhost.tld)AuthorizationzBasic dXNlcg==)xmlrpcclient	Transportr*   get_host_info)r+   transps     r.   test_get_host_infoz!XMLRPCTestCase.test_get_host_info.  sA    ((*--o>%?@"F	Gr0   c                    	 dd l }d}	 t        j                  j	                  d      j                          y # t        $ r d}Y <w xY w# t        $ r | j                  |d       Y y t        $ r | j                  |       Y y w xY w)Nr   TFzhttps://localhost:9999z&xmlrpc client's error with SSL support)
sslImportErrorr   r   ServerProxybad_functionNotImplementedErrorassertFalseOSError
assertTrue)r+   r   has_ssls      r.   test_ssl_presencez XMLRPCTestCase.test_ssl_presence5  s~    	 G	%MM%%&>?LLN  	G	 # 	PW&NO 	%OOG$	%s&   7 -A AAB%B Bc                 t    G d dt         j                  j                        }fd}t         j                  j                  t        j
                  df|      | j                  j                         t        j                  |      }|j                          | j                  |j                          dj                  j                   }t        j                  |      5 }| j!                  |j#                         d       | j!                  |j#                         d       d d d        y # 1 sw Y   y xY w)Nc                        e Zd ZdZdZd Zd Zy)@XMLRPCTestCase.test_keepalive_disconnect.<locals>.RequestHandlerHTTP/1.1Fc                    t        | j                  j                  d            }| j                  j	                  |       | j
                  rd| _        y t        j                  dd      }|j                         }| j                  t        j                  j                         | j                  dt        |             | j!                          | j"                  j%                  |       d| _        d| _        y )NContent-LengthT)rm   rE   F)r   headersgetrfilereadhandledclose_connectionr&   r'   r   send_responsehttp
HTTPStatusOKsend_headerlenend_headerswfilewrite)r+   lengthresponses      r.   do_POSTzHXMLRPCTestCase.test_keepalive_disconnect.<locals>.RequestHandler.do_POSTH  s    T\\--.>?@

'<<,0D)$??4E#??,""4??#5#56  !13x=A  "

  *#(-%r0   c                      y rz   rT   )r+   formatargss      r.   log_messagezLXMLRPCTestCase.test_keepalive_disconnect.<locals>.RequestHandler.log_messageW  s    r0   N)rQ   rR   rS   protocol_versionr   r   r   rT   r0   r.   RequestHandlerr   D  s    )G.r0   r   c                       j                   j                  t        d              j                           j                          y Nr   )socket
settimeoutr   handle_request)servers   r.   
run_serverz<XMLRPCTestCase.test_keepalive_disconnect.<locals>.run_server[  s1    MM$$U1X.!!#!!#r0   r   )targetzhttp://{}:{}/rm   )r   r   BaseHTTPRequestHandler
HTTPServerr   HOST
addCleanupserver_close	threadingThreadstartjoinr   server_addressr&   r   r*   method)r+   r   r   threadurlpr   s         @r.   test_keepalive_disconnectz(XMLRPCTestCase.test_keepalive_disconnectC  s    	T[[?? 	.	$
 ''););Q(?P++,!!4$$o$$f&;&;<""3' 	,1QXXZ+QXXZ+	, 	, 	,s   $AD..D7N)rQ   rR   rS   r/   rA   rC   rM   r^   rd   rj   rp   rv   r   r   r   r   r   r   r   r   r   r   r   r   r  rT   r0   r.   r$   r$   0   su    ,
D$&)DG<<;,: ??*!&@-68=G%%,r0   r$   c                   F    e Zd Z G d de      Zd Zd Zd Zd Zd Z	d Z
y	)
SimpleXMLRPCDispatcherTestCasec                       e Zd ZdZy)*SimpleXMLRPCDispatcherTestCase.DispatchExczSRaised inside the dispatched functions when checking for
        chained exceptionsN)rQ   rR   rS   __doc__rT   r0   r.   DispatchExcr  l  s    	r0   r  c                     d} fd}t         j                  j                         }|j                  |        j	                   j
                        5 }|j                  d|       ddd        j                  j                  j                  |f        j                  |j                  j                          j                  |j                  j                         y# 1 sw Y   {xY w)z$Calls explicitly registered functionrf   c                  &    j                  |       rz   )r  )paramsr+   s    r.   dispatched_funczQSimpleXMLRPCDispatcherTestCase.test_call_registered_func.<locals>.dispatched_funcw  s    ""6**r0   r  N)r   r   SimpleXMLRPCDispatcherregister_functionra   r  	_dispatchr*   	exceptionr   r:   	__cause____context__)r+   
exp_paramsr  
dispatcherexc_ctxs   `    r.   test_call_registered_funcz8SimpleXMLRPCDispatcherTestCase.test_call_registered_funcp  s    
 
	+ ]]99;
$$_5t//0 	@G  !2J?	@**//*?'++556'++778		@ 	@s   C  C)c                    d} G d d      }t         j                  j                         }|j                   |              | j	                  | j
                        5 }|j                  d|       ddd       | j                  j                  j                  |f       | j                  |j                  j                         | j                  |j                  j                         y# 1 sw Y   {xY w)z3Calls a registered instance attribute as a functionrf   c                       e Zd Zd Zy)OSimpleXMLRPCDispatcherTestCase.test_call_instance_func.<locals>.DispatchedClassc                 ,    t         j                  |      rz   r  r  )r+   r
  s     r.   r  z_SimpleXMLRPCDispatcherTestCase.test_call_instance_func.<locals>.DispatchedClass.dispatched_func  s    4@@HHr0   N)rQ   rR   rS   r  rT   r0   r.   DispatchedClassr    s    Ir0   r  r  Nr   r   r  register_instancera   r  r  r*   r  r   r:   r  r  )r+   r  r  r  r  s        r.   test_call_instance_funcz6SimpleXMLRPCDispatcherTestCase.test_call_instance_func  s    
 
	I 	I ]]99;
$$_%67t//0 	@G  !2J?	@**//*?'++556'++778		@ 	@s   C))C2c                    d}d} G d d      }t         j                  j                         }|j                   |              | j	                  | j
                        5 }|j                  ||       ddd       | j                  j                  j                  ||f       | j                  |j                  j                         | j                  |j                  j                         y# 1 sw Y   |xY w)z4Calls the registered instance's `_dispatch` functionr   rf   c                       e Zd Zd Zy)LSimpleXMLRPCDispatcherTestCase.test_call_dispatch_func.<locals>.TestInstancec                 .    t         j                  ||      rz   r  )r+   r   r
  s      r.   r  zVSimpleXMLRPCDispatcherTestCase.test_call_dispatch_func.<locals>.TestInstance._dispatch  s    4@@F$ $r0   N)rQ   rR   rS   r  rT   r0   r.   TestInstancer!    s    $r0   r#  Nr  )r+   
exp_methodr  r#  r  r  s         r.   test_call_dispatch_funcz6SimpleXMLRPCDispatcherTestCase.test_call_dispatch_func  s    
 

	$ 	$
 ]]99;
$$\^4t//0 	9G  Z8	9**//*j1IJ'++556'++778		9 	9s   C,,C5c                     t         j                  j                         }|j                  dd       | j	                  t
        d      5  |j                  dd       ddd       y# 1 sw Y   yxY w)z2Calls explicitly registered function which is NoneNr   nameparam)r   r   r  r  assertRaisesRegex	Exceptionr  r+   r  s     r.   test_registered_func_is_nonez;SimpleXMLRPCDispatcherTestCase.test_registered_func_is_none  s^     ]]99;
$$T$9##Ix8 	7  :6	7 	7 	7s   A$$A-c                     t         j                  j                         }|j                  t	                      | j                  t        d      5  |j                  dd       ddd       y# 1 sw Y   yxY w)z>Attempts to call nonexistent function on a registered instancer   r)  N)r   r   r  r  rX   r+  r,  r  r-  s     r.   test_instance_has_no_funcz8SimpleXMLRPCDispatcherTestCase.test_instance_has_no_func  s[     ]]99;
$$VX.##Ix8 	7  :6	7 	7 	7s   A**A3c                     t         j                  j                         }| j                  t        d      5  |j                  dd       ddd       y# 1 sw Y   yxY w)z2Calls a function that the dispatcher cannot locater   r)  N)r   r   r  r+  r,  r  r-  s     r.   test_cannot_locate_funcz6SimpleXMLRPCDispatcherTestCase.test_cannot_locate_func  sK     ]]99;
##Ix8 	7  :6	7 	7 	7s   AAN)rQ   rR   rS   r,  r  r  r  r%  r.  r0  r2  rT   r0   r.   r  r  k  s,    i 9$9&9*777r0   r  c                       e Zd Zd Zy)HelperTestCasec                     | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       y )Nza&bza&amp;bza<bza&lt;bza>bza&gt;b)r*   r&   escaperc   s    r.   test_escapezHelperTestCase.test_escape  sS    ))%0)<))%0(;))%0(;r0   N)rQ   rR   rS   r7  rT   r0   r.   r4  r4    s    <r0   r4  c                       e Zd Zd Zd Zd Zy)FaultTestCasec                     t        j                  dd      }| j                  t        |      d       | j                  t        |      t	        |             y )Nr   
Test Faultz<Fault 42: 'Test Fault'>)r&   Faultr*   reprrI   )r+   fs     r.   	test_reprzFaultTestCase.test_repr  s?    OOB-a"<=a#a&)r0   c                    t        j                  dd      }t        j                  |f      }t        j                  |      \  \  }}| j	                  |ddd       | j	                  |d        t        j
                         j                  |      }| j                  t         j                  t         j                  |       y )Nr   r;  )	faultCodefaultString)r&   r<  r'   r)   r*   r   ra   )r+   r>  r=   newfr?   s        r.   test_dump_faultzFaultTestCase.test_dump_fault  s    OOB-OOQD!__Q'
RMND!  "((+)//9??A>r0   c                     | j                  t        t        j                  j                  t
        d       | j                  t        j                  j	                  t
        d             y N__addtitle)ra   AttributeErrorr   r   resolve_dotted_attributerI   r   rc   s    r.   test_dotted_attributez#FaultTestCase.test_dotted_attribute  sC     	. --@@#w	P>>sGLMr0   N)rQ   rR   rS   r?  rD  rK  rT   r0   r.   r9  r9    s    *
?Nr0   r9  c                   <    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
y	)
DateTimeTestCasec                 B   t        j                  d      5 }t        j                  g d      }||_        t        j
                         }t        j                         }| j                  t        |      t        j                  d|             d d d        y # 1 sw Y   y xY w)Nztime.localtime)	i        r      1   r      r   %Y%m%dT%H:%M:%S)r   patchtimestruct_timereturn_value	localtimer&   r7   r*   rI   strftime)r+   localtime_mocktime_structrY  r\   s        r.   test_defaultzDateTimeTestCase.test_default  s    ZZ() 	J^**35K*5N'(I""$ASV!]]+<iHJ	J 	J 	Js   A6BBc           	          d}t        j                  |      }| j                  t        |      t	        j
                  dt	        j                  |                   y Ngl]ޮArT  )r&   r7   r*   rI   rV  rZ  rY  ru   s      r.   	test_timezDateTimeTestCase.test_time  sD    q!Q'8$..:KL	Nr0   c                 h    d}t        j                  |      }| j                  t        |      d       y )N)	     	   r   &   2   rm      r   z20070609T10:38:50)r&   r7   r*   rI   ru   s      r.   test_time_tuplez DateTimeTestCase.test_time_tuple  s,    'q!Q!45r0   c                     t        j                  d      }t        j                  |      }| j	                  t        |      t        j                  d|             y r_  )rV  rY  r&   r7   r*   rI   rZ  ru   s      r.   test_time_structz!DateTimeTestCase.test_time_struct  sA    NN,-q!Q/@!!DEr0   c                     t        j                   dddddd      }t        j                  |      }| j                  t	        |      d       y )Nrb  r   r   rg   rl   rm   z20070102T03:04:05)r6   r&   r7   r*   rI   ru   s      r.   test_datetime_datetimez'DateTimeTestCase.test_datetime_datetime  sA    d1Qq1-q!Q!45r0   c                     t        j                   dddddd      }t        j                  |      }dt        |      z  }| j	                  t        |      |       y )Nrb  r   r   rg   rl   rm   z%<DateTime '20070102T03:04:05' at %#x>)r6   r&   r7   idr*   r=  )r+   rJ   r\   vals       r.   r?  zDateTimeTestCase.test_repr  sN    d1Qq1-q!4r!u<a#&r0   c           
         d}t        j                         }|j                  |       t        j                  t        j                  dddddd            }| j	                  ||       t        j
                  |      }| j	                  ||       y )Nz 20070908T07:11:13  rb  rd     rO  r      )r&   r7   decoder6   r*   	_datetime)r+   rJ   t1trefr]   s        r.   test_decodezDateTimeTestCase.test_decode  su    "!
		!!!("3"3D1Qr""EFT"  #T"r0   c                    t         j                   j                         }t        j                  |j	                               }| j                  ||k(         | j                  ||k(         |t        j                  d      z   }| j                  ||k\         | j                  ||k         |j                  d      }| j                  ||k(         | j                  ||k(         t        j                  |j	                               }| j                  ||k\         | j                  ||k         |j                  d      }|j	                         }| j                  |dk(         | j                  ||k7         | j                  |t        |      k(         | j                  ||k7         | j                  t              5  |t        d      k   d d d        | j                  t              5  ||kD   d d d        | j                  t              5  |t        |      k   d d d        | j                  t              5  ||k\   d d d        | j                  |t        k(         | j                  |t        k7         | j                  |t        k         | j                  |t        kD         | j                  |t        k         | j                  |t        k\         | j                  |t         k         | j                  |t         kD         | j                  |t         k         | j                  |t         k\         y # 1 sw Y   mxY w# 1 sw Y   WxY w# 1 sw Y   8xY w# 1 sw Y   "xY w)Nrl   )secondsrT  asciii  )r6   nowr&   r7   	timetupler   	timedeltarZ  r   r   r   ra   ri   r   r   r	   r
   )r+   r{  dtimethendstr
dtime_thendbytesdtuples           r.   test_comparisonz DateTimeTestCase.test_comparison  s   ##%""3==?3 	%u%X''22&% ||-.&&''(89

d*+z)* W%$'()F"334(y) 	 E$K	 y) 	FN	y) 	'Yv&&	'y) 	VO	 	*+)+,()()')*)*()(*+)*%	  	 	 		' 	'	 	s0   >L8*MM9M8MMMM)N)rQ   rR   rS   r]  r`  rh  rj  rl  r?  rw  r  rT   r0   r.   rM  rM    s-    JN6
F
6
'#,+r0   rM  c                       e Zd Zd Zd Zd Zy)BinaryTestCasec                 b    t        j                         }| j                  t        |      d       y )N r&   r   r*   rI   )r+   r\   s     r.   r]  zBinaryTestCase.test_defaultE  s$    Q$r0   c                 |    d}t        j                  |      }| j                  t        |      t        |d             y Ns   abc123zlatin-1r  ru   s      r.   test_stringzBinaryTestCase.test_stringI  s2    )QQQ	!23r0   c                 :   d}t        j                  |      }t        j                         }|j	                  |       | j                  t        |      t        |d             t        j                  |      }| j                  t        |      t        |d             y r  )base64encodebytesr&   r   rs  r*   rI   _binary)r+   rJ   deru  r]   s        r.   rw  zBinaryTestCase.test_decodeN  sv    )"
		"R#a"34r"R#a"34r0   N)rQ   rR   rS   r]  r  rw  rT   r0   r.   r  r  >  s    %4
5r0   r  c                     G d d      } G d dt         j                  j                        }|st         j                  j                  } |d||dd      }	 |j	                          |j
                  j                         \  aadt        t        fz  a	|j                          |j                          |j                          |j                  t               |j                  d	 d
       |j                  d        }|j                  d      d        } |       }	|j                  |	d       | j!                          |dkD  r|j#                          |dz  }|dkD  r|j
                  j'                          d a| j!                          y # t$        $ r Y 8w xY w# |j
                  j'                          d a| j!                          w xY w)Nc                   ,    e Zd Zd Zd Z G d d      Zy)&http_server.<locals>.TestInstanceClassc                     ||z  S rz   rT   r+   rY   rZ   s      r.   divz*http_server.<locals>.TestInstanceClass.div`      6Mr0   c                     |dk(  ryy Nr  This is the div functionrT   r+   r(  s     r.   _methodHelpz2http_server.<locals>.TestInstanceClass._methodHelpc      u}1 r0   c                       e Zd Zed        Zy).http_server.<locals>.TestInstanceClass.Fixturec                       y)N42rT   rT   r0   r.   getDataz6http_server.<locals>.TestInstanceClass.Fixture.getDatah  s    r0   N)rQ   rR   rS   staticmethodr  rT   r0   r.   Fixturer  g  s     r0   r  N)rQ   rR   rS   r  r  r  rT   r0   r.   TestInstanceClassr  _  s    		2	 	r0   r  c                       e Zd Zd Zy)#http_server.<locals>.MyXMLRPCServerc                 f    | j                   j                         \  }}|j                  d       ||fS NTr   acceptsetblockingr+   r=   ports      r.   get_requestz/http_server.<locals>.MyXMLRPCServer.get_requestm  /     kk((*GAtMM$d7Nr0   NrQ   rR   rS   r  rT   r0   r.   MyXMLRPCServerr  l      	r0   r  	localhostr   F)r   logRequestsbind_and_activatehttp://%s:%dc                     | S rz   rT   )rY   s    r.   <lambda>zhttp_server.<locals>.<lambda>  s     r0      têštc                       yThis is my functionTrT   rT   r0   r.   my_functionz http_server.<locals>.my_function  s     r0   addr'  c                     | |z   S rz   rT   rY   rZ   s     r.   _zhttp_server.<locals>._  s    q5Lr0   T)allow_dotted_namesr   r   )r   r   SimpleXMLRPCServerSimpleXMLRPCRequestHandlerserver_bindr   getsocknameADDRPORTURLserver_activate register_introspection_functionsregister_multicall_functionsr  powr  setr   TimeoutErrorclose)
evtnumrequestsrequestHandlerr   r  r  servr  r  testInstances
             r.   http_serverr  ^  s    99  AA*N#+&+uFD#[[,,.
d
 dD\)--/))+s#{H5				 
 	 
		U		+	 
,	(*|E	 Ao!1K Ao 		   		s%   DF 	FF FF .G
c                     G d d      }d } G d dt         j                  j                        }|st         j                  j                  } G d d|      } G d d	      } |d
|dd      }|j                  j                  d       |j                          	 |j                  j                         \  aa	dt        t        fz  a
|j                          g d}	|	D ]e  }
|j                  |
t         j                  j                               }|j                          |j                          |j!                  |
fdd       g |j#                  |	d         j!                  t$               |j#                  |	d         j!                  d d       |j                  d |              | j'                          |dkD  r|j)                          |dz  }|dkD  r|j                  j-                          d a	| j'                          y # t*        $ r Y 8w xY w# |j                  j-                          d a	| j'                          w xY w)Nc                       e Zd Zd Zd Zy),http_multi_server.<locals>.TestInstanceClassc                     ||z  S rz   rT   r  s      r.   r  z0http_multi_server.<locals>.TestInstanceClass.div  r  r0   c                     |dk(  ryy r  rT   r  s     r.   r  z8http_multi_server.<locals>.TestInstanceClass._methodHelp  r  r0   N)rQ   rR   rS   r  r  rT   r0   r.   r  r    s    		2r0   r  c                       yr  rT   rT   r0   r.   r  z&http_multi_server.<locals>.my_function  s    r0   c                       e Zd Zd Zy))http_multi_server.<locals>.MyXMLRPCServerc                 f    | j                   j                         \  }}|j                  d       ||fS r  r  r  s      r.   r  z5http_multi_server.<locals>.MyXMLRPCServer.get_request  r  r0   Nr  rT   r0   r.   r  r    r  r0   r  c                       e Zd Zg Zy)+http_multi_server.<locals>.MyRequestHandlerN)rQ   rR   rS   	rpc_pathsrT   r0   r.   MyRequestHandlerr    s    	r0   r  c                       e Zd ZddZy)+http_multi_server.<locals>.BrokenDispatcherNc                     t        d      )Nzbroken dispatcher)RuntimeError)r+   r   dispatch_methodpaths       r.   _marshaled_dispatchz?http_multi_server.<locals>.BrokenDispatcher._marshaled_dispatch  s    233r0   NN)rQ   rR   rS   r  rT   r0   r.   BrokenDispatcherr    s    	4r0   r  r  F)r  r  rg   r  )
/foo/foo/bar/foo?k=v	/foo#frag/foo?k=v#fragr  //RPC2?k=v#fragc                     | S rz   rT   )r   s    r.   r  z#http_multi_server.<locals>.<lambda>  s    q r0   testr   r   c                     | |z   S rz   rT   r  s     r.   r  z#http_multi_server.<locals>.<lambda>  s
    AaC r0   r  
/is/broken)r   r   MultiPathXMLRPCServerr  r   r   r  r  r  r  r  r  add_dispatcherr  r  r  r  get_dispatcherr  r  r   r  r  )r  r  r  r  r  r  r  r  r  pathsr  rJ   s               r.   http_multi_serverr    s   2 2<<  AA> 4 4 *,<&+uFDKK1"[[,,.
d
 dD\)

  	:D##D&--*N*N*PQA..0**, 0&9		:
 	E!H%77<E!H%77OL*:*<=	 Ao!1K Ao 		   		s%   D<H 	HH HH .Ic                     	 | j                   dk(  s| j                  y| j                  j                  d      }|rd|j                         v ryyy# t        $ r t	        |       }Y -w xY w)zReturns 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-exceptionztemporarily unavailable)errcoder   r   rI  rI   lower)eexc_messs     r.   is_unavailable_exceptionr    si    99?aii/99==/
 -1AA Bx	  q6s   A A A'&A'c                     | sd S fd}|S )Nc                     | S rz   rT   )funcs    r.   r  z)make_request_and_skipIf.<locals>.<lambda>  s    D r0   c                     fd}|S )Nc                     	 t        j                  t              j                          t        j                        # t         j                  t
        f$ r}t        |      s Y d }~?d }~ww xY wrz   )	r&   r   r  r  ProtocolErrorr   r  unittestSkipTest)r+   r  reasons     r.   make_request_and_skipzImake_request_and_skipIf.<locals>.decorator.<locals>.make_request_and_skip  s_    %%c*668 ##F++ ++W5 /2 3s   '? A.A))A.rT   )r  r  r  s     r.   	decoratorz*make_request_and_skipIf.<locals>.decorator  s    	, %$r0   rT   )	conditionr  r  s    ` r.   make_request_and_skipIfr    s       % r0   c                   0    e Zd ZdZdZ ee      Zd Zd Z	y)BaseServerTestCaseNr   c                    dt         j                  j                  _        t	        j
                         | _        | j                  | j                  | j                  f}t	        j                  | j                  |      }|j                          | j                  |j                         | j                  j                          | j                  j                          y )NTr   r   )r   r   r  _send_traceback_headerr   Eventr  request_countr  r   
threadFuncr   r   r   waitclearr+   	serv_argsr   s      r.   setUpzBaseServerTestCase.setUp  s    BF((???$XXt1143F3FG	!!yI$ 	r0   c                 v    | j                   j                          dt        j                  j                  _        y NF)r  r  r   r   r  r  rc   s    r.   tearDownzBaseServerTestCase.tearDown  s%     CH((?r0   )
rQ   rR   rS   r  r  r  r  r  r"  r%  rT   r0   r.   r  r    s!    NMk*JHr0   r  c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	 e
ej                  j                  dk\  d	      d
        Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)SimpleServerTestCasec           
      *   	 t        j                  t              }| j                  |j	                  dd      d       y # t         j
                  t        f$ r;}t        |      s&| j                  |dt        |dd             Y d }~y Y d }~y d }~ww xY w)Nrc  rq    
r   r  )
r&   r   r  r*   r  r  r   r  failgetattrr+   r   r  s      r.   test_simple1z!SimpleServerTestCase.test_simple1#  sy    	E%%c*AQUU1QZ.''1 	E+A.		aIr)BCDD /	Es   ;> B,BBc           
      8   d}d}	 t        j                  t              }| j                  |j	                  ||      ||z          y # t         j
                  t        f$ r;}t        |      s&| j                  |dt        |dd             Y d }~y Y d }~y d }~ww xY w)Nu   Pŷtu   hơnr*  r   r  )
r&   r   r  r*   r  r  r   r  r+  r,  r+   start_string
end_stringr   r  s        r.   test_nonasciiz"SimpleServerTestCase.test_nonascii-  s    C;
	E%%c*AQUU<<)J68''1 	E+A.		aIr)BCDD /	Es   >A B,BBc           
      P   d}d}	 t        j                  t        d      }| j                  |j	                  ||      ||z          y # t         j
                  t        j                  f$ r;}t        |      s&| j                  |dt        |dd             Y d }~y Y d }~y d }~ww xY w)N   €   ¤r   r   r*  r   r  r&   r   r  r*   r  r  r   errorr  r+  r,  r0  s        r.   test_client_encodingz)SimpleServerTestCase.test_client_encoding:  s    
	E%%cMBAQUU<<)J68''6 	E+A.		aIr)BCDD /	Es   A A #B%*,B  B%c           
      @   	 t        j                  t        d      }| j                  |j	                  d      d       y # t         j
                  t        j                  f$ r;}t        |      s&| j                  |dt        |dd             Y d }~y Y d }~y d }~ww xY w)Nrz  r   r   r*  r   r  )r&   r   r  r*      têštr  r   r8  r  r+  r,  r-  s      r.   test_nonascii_methodnamez-SimpleServerTestCase.test_nonascii_methodnameH  s}    	E%%cG<AQXXb\2.''6 	E+A.		aIr)BCDD /	Es   <? #B",BBc                 X   t        j                  t        j                  j	                  t
        t                    5 }|j                  dd       |j                         }d d d        | j                  j                  d       | j                  |j                  d       y # 1 sw Y   BxY w)NPOSTz/this-is-not-validi  z	Not Found)
contextlibclosingr   r   HTTPConnectionr  r  requestgetresponser*   statusr  )r+   connr   s      r.   test_404zSimpleServerTestCase.test_404R  s      : :4 FG 	*4LL!56'')H	* 	#.+6	* 	*s   #B  B)c           
      j   t        g d      }	 t        j                  t              }|j                  j                         }| j                  t        |      |       y # t        j                  t        f$ r;}t        |      s&| j                  |dt        |dd             Y d }~y Y d }~y d }~ww xY w)N)
r  r  r  r  r  zsystem.listMethodszsystem.methodHelpzsystem.methodSignaturezsystem.multicallr  r*  r   r  )r  r&   r   r  systemlistMethodsr*   r  r   r  r+  r,  )r+   expected_methodsr   methr  s        r.   test_introspection1z(SimpleServerTestCase.test_introspection1\  s      + ,	E%%c*A88'')DSY(89''1 	E+A.		aIr)BCDD /	Es   AA B27,B--B2c           
      @   	 t        j                  t              }|j                  j	                  d      }| j                  |d       y # t         j                  t        f$ r;}t        |      s&| j                  |dt        |dd             Y d }~y Y d }~y d }~ww xY w)Nr  r  r*  r   r  r&   r   r  rH  
methodHelpr*   r  r   r  r+  r,  )r+   r   divhelpr  s       r.   test_introspection2z(SimpleServerTestCase.test_introspection2l  s    		E%%c*Ahh))%0GW&@A''1 	E+A.		aIr)BCDD /	E   AA	 	B",BBr   z)Docstrings are omitted with -O2 and abovec           
      @   	 t        j                  t              }|j                  j	                  d      }| j                  |d       y # t         j                  t        f$ r;}t        |      s&| j                  |dt        |dd             Y d }~y Y d }~y d }~ww xY w)Nr  r  r*  r   r  rN  )r+   r   
myfunctionr  s       r.   test_introspection3z(SimpleServerTestCase.test_introspection3x  s    		E%%c*A,,];JZ)>?''1 	E+A.		aIr)BCDD /	ErR  c           
      @   	 t        j                  t              }|j                  j	                  d      }| j                  |d       y # t         j                  t        f$ r;}t        |      s&| j                  |dt        |dd             Y d }~y Y d }~y d }~ww xY w)Nr  zsignatures not supportedr*  r   r  )r&   r   r  rH  methodSignaturer*   r  r   r  r+  r,  )r+   r   divsigr  s       r.   test_introspection4z(SimpleServerTestCase.test_introspection4  s    	E%%c*AXX--e4FV%?@''1 	E+A.		aIr)BCDD /	ErR  c           
         	 t        j                  t              }t        j                  |      }|j	                  dd       |j                  dd       |j                  dd        |       \  }}}| j                  |d       | j                  |d       | j                  |d       y # t         j                  t        f$ r;}t        |      s&| j                  |d	t        |d
d             Y d }~y Y d }~y d }~ww xY w)Nr   rg   rc  rq     r   rm   r)  r*  r   r  )r&   r   r  	MultiCallr  r  r  r*   r  r   r  r+  r,  )r+   r   	multicall
add_result
pow_result
div_resultr  s          r.   test_multicallz#SimpleServerTestCase.test_multicall  s    	E%%c*A!++A.IMM!AMM!AMM#b!1:.J
JZ-Z.Z1''1 	E+A.		aIr)BCDD /	Es   B%B( (C<,C77C<c           
         	 t        j                  t              }t        j                  |      }|j	                           |       }| j                  |j                  d   d   d       | j                  |j                  d   d   d       y # t         j                  t        f$ r;}t        |      s&| j                  |dt        |dd             Y d }~y Y d }~y d }~ww xY w)	Nr   rA  r   rB  z@<class 'Exception'>:method "this_is_not_exists" is not supportedr*  r   r  )r&   r   r  r\  this_is_not_existsr*   resultsr  r   r  r+  r,  )r+   r   r]  r>   r  s        r.   test_non_existing_multicallz0SimpleServerTestCase.test_non_existing_multicall  s    	E%%c*A!++A.I((*[F V^^A.{;Q?V^^A.}=#$ ''1 	E+A.		aIr)BCDD /	Es   B	B C %,CC c                     | j                  t        t        j                  j                  t
        d       | j                  t        j                  j	                  t
        d             | j                          y rF  )ra   rI  r   r   rJ  rI   r   r.  rc   s    r.   rK  z*SimpleServerTestCase.test_dotted_attribute  sQ    . --@@#w	P 	>>sGLM 	r0   c                     t        j                  dt        t        fz        }|j                  j                         }| j                  |d       y )Nhttp://%s:%d/RPC2r  )r&   r   r  r  r  r  r*   )r+   r   r   s      r.   test_allow_dotted_names_truez1SimpleServerTestCase.test_allow_dotted_names_true  s>    &&':dD\'IJ~~%%'t$r0   c                     t        j                  dt        t        fz        }| j	                  |j                  dd      d       y )Nrh  r      éu   aé)r&   r   r  r  r*   r  r+   r   s     r.   test_unicode_hostz&SimpleServerTestCase.test_unicode_host  s7    &&':dD\'IJC0':r0   c                     t        j                  t        j                  t        t
        f            5 }|j                  dt         dt
         dj                  d             d d d        y # 1 sw Y   y xY w)Nz@POST /RPC2 HTTP/1.0
Content-Length: 100

bye HTTP/1.1
Host: :z2
Accept-Encoding: identity
Content-Length: 0

rz  )r?  r@  r   create_connectionr  r  sendr   )r+   rE  s     r.   test_partial_postz&SimpleServerTestCase.test_partial_post  sn     8 8$ FG 	C4II   $fAdV ,22
 39&/C	C 	C 	Cs   0A,,A5c                    t        j                  t              5 }|j                  dd       | j	                   |d      j
                  d       d d d        | j                   d      j
                  d       y # 1 sw Y   ,xY w)Nr   rg   	transportr  )r&   r   r  r  assertNotEqual_connectionr*   rl  s     r.   test_context_managerz)SimpleServerTestCase.test_context_manager  ss    ""3' 	.6JJq!{ 3 ? ? ,.	. 	,88%	'		. 	.s   5A::Bc                     	 t        j                  t              5 }|j                  dd       d d d        | j                   d      j                  d       y # 1 sw Y   ,xY w# t         j                  $ r Y Dw xY w)Nr   r   rt  r  )r&   r   r  r  r<  r*   rv  rl  s     r.   !test_context_manager_method_errorz6SimpleServerTestCase.test_context_manager_method_error  so    	&&s+ #v

1c"# 	,88%	'	# # 		s'   A% AA% A"A% %A;:A;N)rQ   rR   rS   r.  r3  r9  r<  rF  rL  rQ  r  r~   flagsoptimizerU  rY  ra  re  rK  ri  rm  rr  rw  ry  rT   r0   r.   r'  r'  "  s    EEEE7E 
E SYY//14@B
EB
EEE"E*%;C''r0   r'  c                   $    e Zd Zedd       Zd Zy)SimpleServerEncodingTestCaseNc                      t        | ||d       y )Nr   )r  )r  r  r  r   s       r.   r  z'SimpleServerEncodingTestCase.threadFunc  s    CnmDr0   c           
      L   d}d}	 t        j                  t              }| j                  |j	                  ||      ||z          y # t         j
                  t        j                  f$ r;}t        |      s&| j                  |dt        |dd             Y d }~y Y d }~y d }~ww xY w)Nr5  r6  r*  r   r  r7  r0  s        r.   test_server_encodingz1SimpleServerEncodingTestCase.test_server_encoding  s    
	E%%c*AQUU<<)J68''6 	E+A.		aIr)BCDD /	Es   >A #B#(,BB#r  )rQ   rR   rS   r  r  r  rT   r0   r.   r}  r}    s    E EEr0   r}  c                      e Zd Z ee      ZdZd Zd Z e	j                  d      d        Z e	j                  d      d        Z e	j                  d      d        Z e	j                  d      d        Z e	j                  d      d	        Z e	j                  d      d
        Z e	j                  d      d        Z e	j                  d      d        Z e	j                  d      d        Zy)MultiPathServerTestCaser   c                     t        j                  t        dz         }| j                  |j	                  dd      d       | j                  t         j                  |j                  dd       y )Nr  rc  rq  r)  )r&   r   r  r*   r  ra   r<  r  r+   r   s     r.   
test_path1z"MultiPathServerTestCase.test_path1   sL    !!#f*-qT*)//155!Q7r0   c                     t        j                  t        dz         }| j                  |j	                  dd      d       | j                  t         j                  |j                  dd       y )Nr  rc  rq     )r&   r   r  r*   r  ra   r<  r  r  s     r.   
test_path2z"MultiPathServerTestCase.test_path2  sL    !!#j.1qS))//155!Q7r0   walltimec                     t        j                  t        dz         }| j                  t         j                  |j
                  dd       y )Nr  rc  rq  r&   r   r  ra   r<  r  r  s     r.   
test_path3z"MultiPathServerTestCase.test_path3
  s3    !!#l"23)//155!Q7r0   c                     t        j                  t        dz         }| j                  t         j                  |j
                  dd       y )Nz/invalidrc  rq  r  r  s     r.   test_invalid_pathz)MultiPathServerTestCase.test_invalid_path  s2    !!#j.1)//155!Q7r0   c                 |    t        j                  t        dz         }| j                  |j	                         d       y )Nr  r&   r   r  r*   r  r  s     r.   test_path_query_fragmentz0MultiPathServerTestCase.test_path_query_fragment  s-    !!#o"56?3r0   c                 |    t        j                  t        dz         }| j                  |j	                         d       y )Nr  r  r  s     r.   test_path_fragmentz*MultiPathServerTestCase.test_path_fragment  s,    !!#k/2;/r0   c                 |    t        j                  t        dz         }| j                  |j	                         d       y )Nr  r  r  s     r.   test_path_queryz'MultiPathServerTestCase.test_path_query  s,    !!#j.1:.r0   c                 v    t        j                  t              }| j                  |j	                         d       y )Nr  r  r  s     r.   test_empty_pathz'MultiPathServerTestCase.test_empty_path#  s(    !!#&7+r0   c                 |    t        j                  t        dz         }| j                  |j	                         d       y )Nr  r  r  s     r.   test_root_pathz&MultiPathServerTestCase.test_root_path(  s,    !!#),3'r0   c                 |    t        j                  t        dz         }| j                  |j	                         d       y )Nr  r  r  s     r.   test_empty_path_queryz-MultiPathServerTestCase.test_empty_path_query-  s,    !!#,/6*r0   c                 |    t        j                  t        dz         }| j                  |j	                         d       y )Nr  r  r  s     r.   test_empty_path_fragmentz0MultiPathServerTestCase.test_empty_path_fragment2  s,    !!#-07+r0   N)rQ   rR   rS   r  r  r  r  r  r  r   requires_resourcer  r  r  r  r  r  r  r  r  rT   r0   r.   r  r    sE   /0JM8
8
 Wz*8 +8 Wz*8 +8 Wz*4 +4 Wz*0 +0 Wz*/ +/ Wz*, +, Wz*( +( Wz*+ ++ Wz*, +,r0   r  c                   T    e Zd Z G d dej                  j
                        ZeZd Zy)BaseKeepaliveServerTestCasec                   L    e Zd Zej                  j
                  ZdZg Zd Z	d Z
y)*BaseKeepaliveServerTestCase.RequestHandlerr   c                     | j                   j                  g        t        | j                         dz
  | _        | j                  j                  |       S r   )
myRequestsrn   r   reqidxparentClasshandlerc   s    r.   r  z1BaseKeepaliveServerTestCase.RequestHandler.handleA  s@    OO""2&doo.q0DK##**400r0   c                     | j                   j                  |       }| j                  | j                     j	                  | j
                         |S rz   )r  handle_one_requestr  r  rn   raw_requestline)r+   r>   s     r.   r  z=BaseKeepaliveServerTestCase.RequestHandler.handle_one_requestE  s>    %%88>FOODKK(//0D0DEMr0   N)rQ   rR   rS   r   r   r  r  r   r  r  r  rT   r0   r.   r   r  =  s&    mm>>%
	1	r0   r   c                 N    g | j                   _        t        j                  |       S rz   )r   r  r  r"  rc   s    r.   r"  z!BaseKeepaliveServerTestCase.setUpK  s!    )+&!''--r0   N)	rQ   rR   rS   r   r   r  r   r  r"  rT   r0   r.   r  r  :  s$    AA  $N.r0   r  c                       e Zd Zd Zy)KeepaliveServerTestCase1c                    t        j                  t              }| j                  |j	                  dd      d       | j                  |j	                  dd      d       | j                  |j	                  dd      d         |d              | j                  t        | j                  j                        d       | j                  t        | j                  j                  d         d       y )Nrc  rq  r)  r  r   r   r   	r&   r   r  r*   r  r   r   r  assertGreaterEqualr  s     r.   test_twoz!KeepaliveServerTestCase1.test_twoS  s    !!#&qT*qT*qT*'
 	T00;;<a@ 	D$7$7$B$B2$F GKr0   N)rQ   rR   rS   r  rT   r0   r.   r  r  R  s    Lr0   r  c                       e Zd ZdZd Zd Zy)KeepaliveServerTestCase2r   c                 (   t        j                  t              }| j                  |j	                  dd      d       | j                  |j	                  dd      d       | j                  |j	                  dd      d         |d              | j                  |j	                  dd      d       | j                  |j	                  dd      d       | j                  |j	                  dd      d         |d              | j                  t        | j                  j                        d       | j                  t        | j                  j                  d         d       | j                  t        | j                  j                  d         d       y )Nrc  rq  r)  r  r   r   r  r  s     r.   
test_closez#KeepaliveServerTestCase2.test_closei  s3   !!#&qT*qT*qT*'
qT*qT*qT*'
 	T00;;<a@D$7$7$B$B2$F GKD$7$7$B$B2$F GKr0   c                 b   t        j                  t              }| j                  |j	                  dd      d        |d      j                          | j                  |j	                  dd      d         |d              | j                  t        | j                  j                        d       y )Nrc  rq  r)  rt  r  r   )	r&   r   r  r*   r  r  r   r   r  r  s     r.   test_transportz'KeepaliveServerTestCase2.test_transport|  s    !!#&qT*	+qT*'
T00;;<a@r0   N)rQ   rR   rS   r  r  r  rT   r0   r.   r  r  e  s    ML&Ar0   r  zrequires gzipc                       e Zd Z G d dej                  j
                        ZeZ G d dej                        Z	d Z
d Zd Zd Zy	)
GzipServerTestCasec                   B    e Zd Zej                  j
                  ZdZd Zy)!GzipServerTestCase.RequestHandlerr   c                     t        | j                  d         | j                  _        | j                  j                  |       S )Ncontent-length)r   r   	__class__content_lengthr  r   rc   s    r.   r   z)GzipServerTestCase.RequestHandler.do_POST  s4    ,/=M0N,ODNN)##++D11r0   N)	rQ   rR   rS   r   r   r  r  r   r   rT   r0   r.   r   r    s    mm>>%	2r0   r   c                       e Zd ZdZd Zd Zy)GzipServerTestCase.TransportFc                     t        |j                  dd            | _        t        j                  j                  | |      S )Nr  r   )r   	getheaderresponse_lengthr&   r   parse_response)r+   r   s     r.   r  z+GzipServerTestCase.Transport.parse_response  s6    !$X%7%78H!%L!MD &&55dHEEr0   c                     | j                   r|j                  dd       t        j                  j	                  | ||      S )NzContent-Encodinggzip)	fake_gzip	putheaderr&   r   send_content)r+   
connectionbodys      r.   r  z)GzipServerTestCase.Transport.send_content  s5    ~~$$%7@&&33D*dKKr0   N)rQ   rR   rS   r  r  r  rT   r0   r.   r   r    s    		F	Lr0   r   c                 .    t         j                  |        y rz   )r  r"  rc   s    r.   r"  zGzipServerTestCase.setUp  s      &r0   c                    | j                         }d |_        t        j                  t        |      }| j                  |j                  dd      d       | j                  j                  }d|_        | j                  |j                  dd      d       | j                  j                  }| j                  ||kD           |d              y Nrt  rc  rq  r)  r   r  )
r   encode_thresholdr&   r   r  r*   r  r   r  r   )r+   r\   r   r   r   s        r.   test_gzip_requestz$GzipServerTestCase.test_gzip_request  s    NN!!!#3qT*..qT*..!'
r0   c                 H   | j                         }d |_        d|_        t        j                  t
        |      }| j                  t        j                  t        j                  d            }|5  |j                  dd       d d d          |d              y # 1 sw Y   xY w)NTr  z\b400\brc  rq  r  )r   r  r  r&   r   r  r+  r  recompiler  )r+   r\   r   cms       r.   test_bad_gzip_requestz(GzipServerTestCase.test_bad_gzip_request  s    NN!!!#3##I$;$;$&JJz$:< 	EE!QK	'
	 	s   /BB!c                    | j                         }t        j                  t        |      }| j                  j
                  }d | j                  _        | j                  |j                  dd      d       |j                  }d| j                  _        | j                  |j                  dd      d         |d              |j                  }|| j                  _        | j                  ||kD         y r  )
r   r&   r   r  r  r  r*   r  r  r   )r+   r\   r   oldr   r   s         r.   test_gzip_responsez%GzipServerTestCase.test_gzip_response  s    NN!!#3!!22/3,qT*/0,qT*'
/2,!r0   N)rQ   rR   rS   r   r   r  r   r  r&   r   r"  r  r  r  rT   r0   r.   r  r    sG    2AA 2 $NLI'' L'
	r0   r  c                       e Zd Zd Zy)GzipUtilTestCasec                    d}d|z  }t        j                  |      }t        j                  |      }| j                  t	        |      |       d|dz   z  }t        j                  |      }| j                  t        d      5  t        j                  |       d d d        t        j                  |d       y # 1 sw Y   !xY w)Ni  @    r   z#max gzipped payload length exceededr   )
max_decode)r&   gzip_encodegzip_decoder*   r   r+  r   )r+   max_gzip_decoder   encodeddecodeds        r.   test_gzip_decode_limitz'GzipUtilTestCase.test_gzip_decode_limit  s    *&''-''0W7!+,''-##J$IK 	+!!'*	+ 	g"5		+ 	+s    B66B?N)rQ   rR   rS   r  rT   r0   r.   r  r    s    6r0   r  c                        e Zd Z G d dej                  j
                        ZeZg dZ fdZ	d Z
d Zd Zd Zd	 Zd
 Z xZS )HeadersServerTestCasec                   "     e Zd ZdZ fdZ xZS )$HeadersServerTestCase.RequestHandlerNc                 V    | j                   | j                  _        t        |          S rz   )r   r  test_headerssuperr   r+   r  s    r.   r   z,HeadersServerTestCase.RequestHandler.do_POST  s     *.,,DNN'7?$$r0   )rQ   rR   rS   r  r   __classcell__r  s   @r.   r   r    s    	% 	%r0   r   )HostzAccept-EncodingzContent-Typez
User-Agentr   c                 B    d | j                   _        t        |          S rz   )r   r  r  r"  r  s    r.   r"  zHeadersServerTestCase.setUp  s    +/(w}r0   c                 &   t        | j                  t        |j                               z         }| j	                  t        |j                               |       |j                         D ]&  \  }}| j                  |j                  |      |       ( y rz   )sortedstandard_headerslistkeysassertListEqualitemsr*   r   )r+   r   
additionalexpected_keyskeyrH   s         r.   assertContainsAdditionalHeadersz5HeadersServerTestCase.assertContainsAdditionalHeaders  ss    t44tJOO<M7NNOVGLLN3]C$**, 	6JCW[[-u5	6r0   c                     t        j                  t        dg      }| j                  |j	                  dd      d       | j
                  j                  }| j                  |ddi       y )NX-Testfoor   rc  rq  r)  r   r  r&   r   r  r*   r  r   r  r  r+   r   r   s      r.   test_headerz!HeadersServerTestCase.test_header  sX    !!#0A/BCq!d+%%22,,Wx6GHr0   c                     t        j                  t        ddg      }| j                  |j	                  dd      d       | j
                  j                  }| j                  |ddd	       y )
Nr  )X-Test-Secondbarr  rc  rq  r)  r  r  )r   r  r  r  s      r.   test_header_manyz&HeadersServerTestCase.test_header_many  sc    !!+-EFHq!d+%%22,,>	@r0   c                     t        j                  t        g       }| j                  |j	                  dd      d       | j
                  j                  }| j                  |i        y )Nr  rc  rq  r)  r  r  s      r.   test_header_emptyz'HeadersServerTestCase.test_header_empty  sO    !!#r2q!d+%%22,,Wb9r0   c                     t        j                  t        d      }| j                  |j	                  dd      d       | j
                  j                  }| j                  |ddi       y )N)r  r  rc  rq  r)  r   r  r  r  s      r.   test_header_tuplez'HeadersServerTestCase.test_header_tuple  sU    !!#/CDq!d+%%22,,Wx6GHr0   c                     t        j                  t        ddij                               }| j	                  |j                  dd      d       | j                  j                  }| j                  |ddi       y )Nr   r  r  rc  rq  r)  )	r&   r   r  r  r*   r  r   r  r  r  s      r.   test_header_itemsz'HeadersServerTestCase.test_header_items  sb    !!#%/@/F/F/HIq!d+%%22,,Wx6GHr0   )rQ   rR   rS   r   r   r  r   r  r  r"  r  r  r	  r  r  r  r  r  s   @r.   r  r    sO    %AA % $N6I@:IIr0   r  c                       e Zd Zd Zd Zd Zy)ServerProxyTestCasec                 P    t         j                  j                  |        d| _        y )Nzhttp://fake.localhost)r  TestCaser"  r   rc   s    r.   r"  zServerProxyTestCase.setUp  s    % +r0   c                 |    t        j                  | j                        }| j                    |d             d        y )Nr  )r&   r   r   r*   r  s     r.   r  zServerProxyTestCase.test_close$  s.    !!$((+7t,r0   c                     t        j                         }t        j                  | j                  |      }| j	                   |d      |       y )Nr  rt  )r&   r   r   r   r*   )r+   r\   r   s      r.   r  z"ServerProxyTestCase.test_transport(  s:    !!!$((a8;+r0   N)rQ   rR   rS   r"  r  r  rT   r0   r.   r  r    s    +-,r0   r  c                         e Zd Zd fd	Z xZS )FailingMessageClassc                 P    |j                         }|dk(  ryt        | 	  ||      S )Nr  zI am broken)r  r  r   )r+   r  failobjr  s      r.   r   zFailingMessageClass.get1  s+    iik"" w{3((r0   rz   )rQ   rR   rS   r   r  r  s   @r.   r  r  0  s    ) )r0   r  c                   *    e Zd Zd Zd Zd Zd Zd Zy)FailingServerTestCasec                 F   t        j                         | _        | j                  df}t        j                  t        |      }|j                          | j                  |j                         | j                  j                          | j                  j                          y )Nr   r  )
r   r  r  r   r  r   r   r   r  r  r   s      r.   r"  zFailingServerTestCase.setUp9  se    ??$XXqM	!!9E$ 	r0   c                     | j                   j                          dt        j                  j                  _        t        j                  j                  }|t        j                  j                  _
        y r$  )r  r  r   r   r  r  r   r   HTTPMessager  MessageClass)r+   default_classs     r.   r%  zFailingServerTestCase.tearDownE  sB    BG((?//@M00=r0   c           
         t         j                  j                  j                  }| j	                  |d       dt         j                  j                  _        	 t        j                  t              }| j	                  |j                  dd      d       y # t
        j                  t        f$ r;}t        |      s&| j                  |dt        |dd             Y d }~y Y d }~y d }~ww xY w)	NFTrc  rq  r)  r*  r   r  )r   r   r  r  r*   r&   r   r  r  r  r   r  r+  r,  )r+   flagvalr   r  s       r.   
test_basicz FailingServerTestCase.test_basicN  s    --22II%( CG((?	E%%c*AQUU1QZ.''1 	E+A.		aIr)BCDD /	Es   ;B C',,C""C'c                    t         t        j                  j                  _        	 t        j                  t              }|j                  dd       | j                  d       y # t
        j                  t        f$ r}t        |      snt        |d      r]| j                  |j                  j!                  d      d u        | j                  |j                  j!                  d      d u        Y d }~y Y d }~y Y d }~y d }~ww xY w)Nrc  rq  ProtocolError not raisedr   r  X-traceback)r  r   r   r  r  r&   r   r  r  r+  r  r   r  hasattrr   r   r   r-  s      r.   test_fail_no_infoz'FailingServerTestCase.test_fail_no_info`  s    @S00=
	2%%c*AEE!AJ II01 ''1 	F+A.71i3H		m < DE		m < DEE 4I.	Fs   +A" "C>;A/C99C>c                 B   t         t        j                  j                  _        dt        j                  j
                  _        	 t        j                  t              }|j                  dd       | j                  d       y # t        j                  t        f$ r}t        |      sot        |d      r^d}| j!                  |j"                  j%                  d      |       | j'                  |j"                  j%                  d      d u       Y d }~y Y d }~y Y d }~y d }~ww xY w)	NTrc  rq  r%  r   z5invalid literal for int() with base 10: 'I am broken'r  r&  )r  r   r   r  r  r  r  r&   r   r  r  r+  r  r   r  r'  r*   r   r   r   )r+   r   r  expected_errs       r.   test_fail_with_infoz)FailingServerTestCase.test_fail_with_infop  s    @S00= CG((?	2%%c*AEE!AJ II01 ''1 	J+A.71i3HV  }!=|L		m <D HII	 4I.	Js   +B DA0DDN)rQ   rR   rS   r"  r%  r#  r(  r+  rT   r0   r.   r  r  8  s    
NE$2 2r0   r  c              #      K   t         j                  }t        j                  t        j                         |       t         _        	 t         j                   |t         _        y# |t         _        w xY ww)zhA variation on support.captured_stdout() which gives a text stream
    having a `buffer` attribute.
    r   N)r~   stdoutioTextIOWrapperBytesIO)r   orig_stdouts     r.   captured_stdoutr2    sH     
 **K!!"**,BCJ!jj 
[
s   AA4A$ A4$A11A4c                   $    e Zd Zd Zd Zd Zd Zy)CGIHandlerTestCasec                 J    t         j                  j                         | _        y rz   )r   r   CGIXMLRPCRequestHandlercgirc   s    r.   r"  zCGIHandlerTestCase.setUp  s    ==88:r0   c                     d | _         y rz   )r7  rc   s    r.   r%  zCGIHandlerTestCase.tearDown  s	    r0   c                    t        j                         5 }d|d<   t        | j                  j                        5 }| j                  j                          d d d        j                  d       |j                         }|j                         d   }dj                  |j                         dd       }| j                  |d	       | j                  |d
       d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)NGETREQUEST_METHODr   r   r    r   rl   400zBad Request)r   EnvironmentVarGuardr2  r7  r   r   seekr   splitr   r*   )r+   envdata_outr  rD  messages         r.   test_cgi_getzCGIHandlerTestCase.test_cgi_get  s    **, 	5$)C ! !$((*;*;< *'')* MM!]]_F\\^A&Fhhv||~a23GVU+Wm4	5 	5* *		5 	5s#   &C-C!BC-!C*	&C--C6c                    d}t        j                         5 }t        | j                  j                        5 }t        j                         5 }|j                  |       |j                  d       t        t        |            |d<   | j                  j                          d d d        d d d        d d d        j                  d       |j                         }| j                  t        j                  t        j                   |dd         ||j#                  d      d  }| j%                  t'        t)        j*                  d|      j-                  d            t        |             y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w)	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>
        r   r   CONTENT_LENGTH,   z<?xmlzContent-Length: (\d+)r   )r   r>  r2  r7  r   r   captured_stdinr   r?  rI   r   r   r   ra   r&   r<  r)   findr*   r   r  searchgroup)r+   r   rA  rB  data_inr  contents          r.   test_cgi_xmlrpc_responsez+CGIHandlerTestCase.test_cgi_xmlrpc_response  s?    **, 	&dhh&7&78	&<D##%	&)0MM$LLO$'D	NC !HH##%	& 	& 	& 	a  	)//9??F23KH W-./		2F;AA!DEL	/	& 	& 	& 	& 	& 	&s;   !F E4AE(!E4)F (E1-E44E=	9F  F	N)rQ   rR   rS   r"  r%  rD  rN  rT   r0   r.   r4  r4    s    ;5$(r0   r4  c                       e Zd Zd Zd Zd Zy)UseBuiltinTypesTestCasec                 B    g  _         d}t        j                  dddddd      }t        j                  ||fd      } fd	}t        j
                  j                  d
d d
      }|j                  |       |j                  |        j                  t         j                         d        j                   \  }} j                   j                   ||g        j                  t        |      t        j                          j                  t        |      t               y )Nr   i  rm               foobarc                  <    j                   j                  |        y rz   )logextend)r   r+   s    r.   rV  z>UseBuiltinTypesTestCase.test_use_builtin_types.<locals>.foobar  s    HHOOD!r0   T)r   r   r3   r   )rX  r6   r&   r'   r   r   r  r  r  r*   r   r8   r9   r   )r+   expected_bytesexpected_date	marshaledrV  handlermybytesmydates   `       r.   test_use_builtin_typesz.UseBuiltinTypesTestCase.test_use_builtin_types  s     , ))$2r2rBOO^]$CXN		"--66dd 7 D!!&)##I.TXX*((NM#BCd6lH$5$56d7mU+r0   c                 z    t         j                  j                  d      }| j                  |j                         y )NTr2   )r   r   r6  r   r3   )r+   r]  s     r.   *test_cgihandler_has_use_builtin_types_flagzBUseBuiltinTypesTestCase.test_cgihandler_has_use_builtin_types_flag  s+    --77$7O112r0   c                     t         j                  j                  dd      }|j                          | j	                  |j
                         y )Nr  Tr2   )r   r   r  r   r   r3   rl  s     r.   ,test_xmlrpcserver_has_use_builtin_types_flagzDUseBuiltinTypesTestCase.test_xmlrpcserver_has_use_builtin_types_flag  s?    112B" 2 $001r0   N)rQ   rR   rS   r`  rb  rd  rT   r0   r.   rP  rP    s    ,(32r0   rP  c                  t    t        j                         } t        j                  t         j                  g|   y rz   )r   threading_setupr  addModuleCleanupthreading_cleanup)thread_infos    r.   setUpModulerj    s*    "224K.@@O;Or0   __main__r  rz   )zutf-8)Hr  r6   r   r~   rV  r  r   xmlrpc.clientr   r&   xmlrpc.serverr   http.clientr   http.serverr   r   r  r.  r?  r  r   test.supportr   r   r   r   r	   r
   r  r   requires_working_socketr   r   r7   r(   r  r$   r  r4  r9  rM  r  r  r  r  r  r  r  r  r  r'  r}  r  r  r  r  skipIfr  r  r  r  r  r  r  contextmanagerr2  r4  rP  rj  rQ   mainrT   r0   r.   <module>ru     s(      
    !      	 	   " & ) 5 5    t ,'#%Y%%&9:)#$78)')y))*=>)y));=)y)))))$2r2rBD
 	$x,X&& x,v	T7X%6%6 T7n<X&& <NH%% N.\+x(( \+~5X&& 56   tc
>@DP" H** H6D'- D'NE#5 E(8,0 8,z."4 .0L: L&A: AD /@+ @ 0@F /6x(( 6 06&:I. :I|,(++ ,&)$++11 )K2H-- K2\ 	! 	!A** AH2h// 2BP
 zHMMO I/  Ds   ,K K! K!