Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/test/__pycache__/test_exceptions.cpython-34.pyo

�
g f/��@s	ddlZddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZm
Z
mZmZmZGdd�de�ZGdd�de�ZGdd�dej�ZGd	d
�d
ej�Zedkrej�ndS)�N)
�TESTFN�captured_output�check_impl_detail�check_warnings�cpython_only�
gc_collect�run_unittest�
no_tracing�unlink�
import_modulec@seZdZdd�ZdS)�NaiveExceptioncCs
||_dS)N)�x)�selfr
�r�9/opt/alt/python34/lib64/python3.4/test/test_exceptions.py�__init__szNaiveException.__init__N)�__name__�
__module__�__qualname__rrrrrrsrc@s"eZdZdZdd�ZdS)�SlottedNaiveExceptionr
cCs
||_dS)N)r
)rr
rrrrszSlottedNaiveException.__init__N)r
)rrr�	__slots__rrrrrrsrc@sAeZdZdd�Zdd�Zdd�Zdd�Zed	d
��Zdd�Z	e
jej
d
kd�dd��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zed!d"��Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Z d3d4�Z!d5d6�Z"d7d8�Z#d9d:�Z$d;d<�Z%d=d>�Z&d?d@�Z'dAdB�Z(dCdD�Z)dEdF�Z*dGdH�Z+edIdJ��Z,edKdL��Z-edMdN��Z.edOdP��Z/edQdR��Z0dSdT�Z1dUS)V�ExceptionTestscCs�y|d��Wn1|k
rC}zt|�}WYdd}~XnXy|d��Wn1|k
r�}zt|�}WYdd}~XnX|j||�|j|j|�dS)NZspam)�str�assertEqualr)r�excZexcname�errZbuf1Zbuf2rrr�raise_catchszExceptionTests.raise_catchcFCs�|jtd�|jtttd�|jtd�ttd�}|j�ttd�}tj	}z6yddl
}|jd�Wntk
r�YnXWd|t_	|j�tt�X|jt
d�|jt
td	d�|jtd
�|jttd�|jtd�g}|jt|jd
�|jtd�i}|jt|jd�|jtd�|jtd�|jtd�y
t}Wntk
r�YnX|jtd�d}xtd�D]}||7}q�W|jtd�|jtd�ytd�Wntk
r'YnX|jtd�|jtd�ytddd�Wntk
rpYnX|jd�|jt d�|jt!d �|jt!tj"d�|jt#d!�ygfWnt#k
r�YnX|jt$d"�|jt$t%d'�|jt&d%�ydd}Wnt&k
r:YnX|jt'd&�ydd}Wn%t'k
r�}zWYdd}~XnXdS)(N�AttributeErrorZundefined_attribute�EOFError�w�rr��OSErrorzthis file does not exist�ImportErrorZundefined_module�
IndexError�
�KeyError�key�KeyboardInterrupt�MemoryError�	NameError�
OverflowError���RuntimeError�SyntaxErrorz/
�IndentationError�TabErrorz"try:
	1/0
    	1/0
finally:
 pass
z<string>�execzTabError not raised�SystemError�
SystemExit�	TypeError�
ValueError���ZeroDivisionError�	Exceptioni)(rr�assertRaises�getattr�sysr�openr�close�stdin�marshal�loadsr
r"r#�
__import__r$�__getitem__r&r(r)r*Zundefined_variabler+�ranger.r/r2r0r1�compile�failr3r4�exitr5r6�chrr9r:)r�fpZ	savestdinrAr
Zdummy�errr�testRaising's�
	
		







zExceptionTests.testRaisingcs^�fdd�}d}tjjd�s:||d�nd}||d�|dd�dS)	Ncsyyt|dd�WnQtk
rg}z1|j|krU�jd||jf�nWYdd}~XnX�jd�dS)Nz
<fragment>r2zexpected %s, got %sz"failed to get expected SyntaxError)rFr/�msgrG)�srcrMrK)rrr�ckmsg|s0z4ExceptionTests.testSyntaxErrorMessage.<locals>.ckmsgz\while 1:
            try:
                pass
            finally:
                continue�javaz0'continue' not supported inside 'finally' clausezHif 1:
        try:
            continue
        except:
            passz'continue' not properly in loopz	continue
)r=�platform�
startswith)rrO�sr)rr�testSyntaxErrorMessagexs

z%ExceptionTests.testSyntaxErrorMessagecsf�fdd�}|ddd�|ddd�|d	d
d�|ddd�|d
dd�dS)NcsX�jt��}t|dd�WdQX�j|jj|��j|jj|�dS)Nz
<fragment>r2)r;r/rFr�	exception�lineno�offset)rNrVrW�cm)rrr�check�sz3ExceptionTests.testSyntaxErrorOffset.<locals>.checkzdef fact(x):
	return x!
�r%z1 +
r,�z def spam():
  print(1)
 print(2)�zPython = "Python" +�uPython = "Ṕýţĥòñ" +r)rrYr)rr�testSyntaxErrorOffset�sz$ExceptionTests.testSyntaxErrorOffsetcs�Gdd�dt��Gdd�d����fdd�}��fdd�}��fd	d
�}tjjd�s�|�|�|�ndS)Nc@seZdZdd�ZdS)z9ExceptionTests.testSettingException.<locals>.BadExceptioncSstd��dS)Nzcan't instantiate BadException)r.)Zself_rrrr�szBExceptionTests.testSettingException.<locals>.BadException.__init__N)rrrrrrrr�BadException�sr_c@seZdZdS)z=ExceptionTests.testSettingException.<locals>.InvalidExceptionN)rrrrrrr�InvalidException�sr`cs�ddl}y|j�d�Wnrtk
r�}zRtj�\}}}|jj}�j|jd��j	|j
jd��WYdd}~XnX�jd�dS)Nrr,�
test_capi1ztest_exceptions.pyzExpected exception)
�	_testcapi�raise_exceptionr5r=�exc_info�tb_frame�f_coder�co_name�
assertTrue�co_filename�endswithrG)rbrr�tb�co)r_rrrra�s,z7ExceptionTests.testSettingException.<locals>.test_capi1cs�ddl}y|j�d�Wn�tk
r�}zttj�\}}}|jj}�j|jd��j	|j
jd��|jjj}�j|jd�WYdd}~XnX�j
d�dS)Nrrztest_exceptions.py�
test_capi2zExpected exception)rbrcr.r=rdrerfrrgrhrirj�f_backrG)rbrrrkrlZco2)r_rrrrm�s&z7ExceptionTests.testSettingException.<locals>.test_capi2cs)ddl}�jt|j�d�dS)Nrr,)rbr;r3rc)rb)r`rrr�
test_capi3�sz7ExceptionTests.testSettingException.<locals>.test_capi3rP)r:r=rQrR)rrarmror)r_r`rr�testSettingException�sz#ExceptionTests.testSettingExceptionc
Cs<ytWntk
rYnX|jtt�|jttd��d�|jttdd��d�tddd�}|j|jd�|j|jd�|jt|�d�td	ddd
�}|j|jd�|j|jd
�|j|jd�|j|j	d�|j|j
d�|jt|�d�td	ddd�}|j|jd
�|j|jd�|j|jd�|j|j	d�|j|j
d�|jt|�d�tdd�}|j|jd�|j|jd�|j|jd�|j|j	d�|j|j
d�dS)Ni�Z1001�messagez[Errno 1001] message�	�foo�barz[Errno 9] foo: 'bar'rr\rZz[WinError 3] foo: 'bar'�z[WinError 1001] foo)�WindowsErrorr*�assertIsr"rr�errno�winerror�strerror�filename�	filename2)rrrrr�test_WindowsError�s@
z ExceptionTests.test_WindowsError�win32ztest specific to Windowsc	CsCtd�}d}|jtd|��|jj|�WdQXdS)z:Should fill in unknown error code in Windows error message�ctypeslcs�@zWindows Error 0x%xN)rZassertRaisesRegexr"Z	pythonapiZPyErr_SetFromWindowsErr)rr�coderrr�test_windows_message�sz#ExceptionTests.test_windows_messagecCsztfifd6ftd-id.d6ftd/id0d6ftd1id2d6ftd3id4d6dd6ftd5id6d6dd6dd6dd6dd6ftd7id8d6dd6dd6dd6d	d6ftd9id:d6d
d6dd6dd6d	d6ftd;id<d6d
d6dd6ftd=id>d6d
d6dd6dd6ftd?id@d6dd6d
d6dd6dd6ftfidd6dd6dd6dd6dd6dd6ftdAidBd6dd6dd6dd6dd6dd6dd6ftdDidd6dd6dFd6dd6dd6dd6dd6ftdGidd6dHd6dd6dd6dd6dd6dd6ftfifd6ftdIidJd6dd6dd6dd6dd 6ftdtd!�dddfidtd!�dddfd6dd6d!d6dd6dd 6ftdKidLd6dd6d!d6dd6dd 6ftdMidNd6d"d6d#d 6dd6dd$6ft	dOidPd6dd%6ft
dQidRd6dd%6fg}yD|jtdSidTd6d
d6dd&6dd6dd6dd6f�Wnt
k
r�YnXx�|D]�\}}}y||�}Wn(td'||fd(tj��Yq�Xt|�jjd)�si|jt|�jd*�nt|�}xT|D]L}t||�}|jt|�t||�d+|||||f�q|Wx�tgD]�}	x�t|	jd�D]z}
|	j||
�}|	j|�}xP|D]H}tt||��}t||�}
|j||
d,||f�qWq�Wq�Wq�WdS)UN�argsr,rsr�r{r|rxrzrt�baz�quux�errnoStr�strErrorStr�filenameStrrM�textrVrW�print_file_and_line�msgStr�	linenoStr�	offsetStr�textStr�print_file_and_lineStr�ascii�ar�ordinal not in range�encoding�object�start�reason���あ�ouch�endr
ryz
exc=%r, args=%r�filer�builtinsz%r.%s == %r, expected %rzpickled "%r", attribute "%s)r,)r,)�foo)r�)r�r,)r�r,)r�)r�)r�)r�)r��bar)r�r�)r�r�r�)r�r�)r�r�r�Nr�)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�r�)r�r�r�r�r�r�)r�r�r�r�r�r�)�asciir�rr,r�)r�r�rr,r�)r�r�rr,r�)r�r�rr,r�)r�rr,r�)r�rr,r�)r�)r�)r�)r�)r,r�r�)r,r�)�
BaseExceptionr4r"r/�UnicodeError�UnicodeEncodeError�UnicodeDecodeError�	bytearray�UnicodeTranslateErrorrr�appendrvr*�printr=�stderr�typerrjrrrr<�repr�picklerEZHIGHEST_PROTOCOL�dumpsrB)rZ
exceptionListrr�ZexpectedrKrSZcheckArgName�value�pZprotocol�newZgotZwantrrr�testAttributess�














zExceptionTests.testAttributesc
Cs�ytd��Wntj�d}YnXt�j|�}|j|t�|j|j|�td�j|�}|j|t�|j|j|�Gdd�dt�}|�j|�}|j||�|j|j|�dS)Nr[rZ�c@seZdZdS)z5ExceptionTests.testWithTraceback.<locals>.MyExceptionN)rrrrrrr�MyException�sr�)	r$r=rdr��with_traceback�assertIsInstancer�
__traceback__r:)rrkrKr�rrr�testWithTraceback�sz ExceptionTests.testWithTracebackcCs_ydt�_Wn;tk
rM}z|jdt|��WYdd}~XnX|jd�dS)Nr�z!__traceback__ must be a tracebackzNo exception raised)r:r�r5�assertInrrG)rrKrrr�testInvalidTraceback�s
)z#ExceptionTests.testInvalidTracebackcCsn|jttt�dd�|jttt�d�|jttt�dd�|jttt�d�dS)N�	__cause__r,�__context__)r;r5�setattrr:�delattr)rrrr�testInvalidAttrs�szExceptionTests.testInvalidAttrsc	Cs]ytd��Wntj�d}YnXt�}||_d|_|j|jd�dS)Nr[rZ)r$r=rdr:r�r)rrkrKrrr�testNoneClearsTracebackAttr�s			z*ExceptionTests.testNoneClearsTracebackAttrcCs�t�}|j|j�|j|j�t�}|j|j�|j|j�Gdd�dt�}|�}|j|j�|j|j�dS)Nc@seZdZdS)z5ExceptionTests.testChainingAttrs.<locals>.MyExceptionN)rrrrrrrr��sr�)r:�assertIsNoner�r�r5r")rrKr�rrr�testChainingAttrs�s			z ExceptionTests.testChainingAttrscCs�y
t��Wn+tk
r:}z|}WYdd}~XnX|j|j�|j|j�|j|j�t�|_d|_|j|jt�|j|j�|j|j�d|_|j|j�dS)NF)	r:r�r�r�ZassertFalse�__suppress_context__r*r�rh)rrrKrrr�testChainingDescriptors�s
		z&ExceptionTests.testChainingDescriptorscCsR|jttdd�Gdd�dt�}|dd�}|j|jd�dS)Nr�r,c@seZdZdd�ZdS)z8ExceptionTests.testKeywordArgs.<locals>.DerivedExceptioncSstj|�||_dS)N)r�r�	fancy_arg)rr�rrrr�s
zAExceptionTests.testKeywordArgs.<locals>.DerivedException.__init__N)rrrrrrrr�DerivedException�sr�r��*)r;r5r�rr�)rr�r
rrr�testKeywordArgs�szExceptionTests.testKeywordArgscsH�fdd��|jt���fdd��|jt��dS)Ncs��S)Nrr)�frrr��sz/ExceptionTests.testInfiniteRecursion.<locals>.fcs(y��SWntk
r#dSYnXdS)Nr,���)r6r)�grrr��s
z/ExceptionTests.testInfiniteRecursion.<locals>.g)r;r.)rr)r�r�r�testInfiniteRecursion�sz$ExceptionTests.testInfiniteRecursioncCsL|jtt��|jttd���|jttdd���dS)Nr��b)rhrr:)rrrr�test_str�szExceptionTests.test_strcCs\y
t��Wn5tk
rD}z|j|�~WYdd}~XnX|jdt��dS)NrK)r:rhZassertNotIn�locals)rrKrrr�testExceptionCleanupNames�s

z(ExceptionTests.testExceptionCleanupNamescHs�Gdd�dt��Gdd�d�}��fdd�}|��tj��}y|�Wn%�k
r�}zWYdd}~XnXd�|��|j�dkd��|��tj��}y|�Wn�k
r�YnXd�|��|j�dkd��|��tj��}y|�WnYnXd�|��|j�dkd��|��tj��}x(dgD]}y|�Wq�PYq�Xq�Wd�|��|j�dkd��|��tj��}y y|�Wnt�YnXWnptk
r�}zPd|_d�|��td	d
�rTt�n|j�dkd��WYdd}~XnX|��tj��}y|�Wn9�k
r�yz�Wd�XWn�k
r�YnXYnXd�td	d
�r�t�n|��|j�dkd��Gdd�d�}|��tj��}|��|�WdQXd�td	d
�r�t�n|��|j�dkd��dS)
Nc@seZdZdd�ZdS)z=ExceptionTests.testExceptionCleanupState.<locals>.MyExceptioncSs
||_dS)N)�obj)rr�rrrrszFExceptionTests.testExceptionCleanupState.<locals>.MyException.__init__N)rrrrrrrrr�sr�c@seZdZdS)z7ExceptionTests.testExceptionCleanupState.<locals>.MyObjN)rrrrrrr�MyObjsr�cs�}����dS)Nr)Z	local_ref)r�r�rr�inner_raising_funcszDExceptionTests.testExceptionCleanupState.<locals>.inner_raising_funcz%srZcpythonFc@s(eZdZdd�Zdd�ZdS)z9ExceptionTests.testExceptionCleanupState.<locals>.ContextcSs|S)Nr)rrrr�	__enter__cszCExceptionTests.testExceptionCleanupState.<locals>.Context.__enter__cSsdS)NTr)r�exc_type�	exc_valueZexc_tbrrr�__exit__eszBExceptionTests.testExceptionCleanupState.<locals>.Context.__exit__N)rrrr�r�rrrr�Contextbsr�)r:�weakref�refrhr&r�rr)rr�r��wrrK�ir�r)r�r�r�testExceptionCleanupState�s�			
				
				
-	



		


	z(ExceptionTests.testExceptionCleanupStatecsM�fdd�}ytWn,tk
rH�z|�WYdd��XnXdS)Ncs�dS)Nrr)rKrr�print_errortszIExceptionTests.test_exception_target_in_nested_scope.<locals>.print_error)Z	somethingr:)rr�r)rKr�%test_exception_target_in_nested_scopeqs
z4ExceptionTests.test_exception_target_in_nested_scopecCsPdd�}|�}|jt|�t�|jtj�dd�|jt|�t�|jtj�dd�|jt|�d�ytd��Wn�tk
rK|�}|jt|�t�|jtj�dt�|jt|�t�|jtj�dt�|jt|�t�~|jtj�dt�YnXdS)NcssVytd��Wn0tk
rBtj�dVtj�dVYnXtj�dVdS)NZcaughtr)r&r=rdrrrr�yield_raises
z:ExceptionTests.test_generator_leaking.<locals>.yield_raiserrs)r�nextr&r=rdr5)rr�r�rrr�test_generator_leaking|s$	
	z%ExceptionTests.test_generator_leakingcCs{dd�}y
t�Wn%tk
r=|�}t|�YnXyt|�Wntk
r`YnX|jtj�d�dS)Ncss	dVdS)Nrrrrrr��sz1ExceptionTests.test_generator_leaking2.<locals>.g)NNN)r.r��
StopIterationrr=rd)rr��itrrr�test_generator_leaking2�s

	
z&ExceptionTests.test_generator_leaking2cCs�dd�}|�}t|�yddWnxtk
r�}zX|jtj�d|�|j|�}|jtj�d|�|j||�WYdd}~XnX|jtj�d�dS)Ncss1y	dVWn!tk
r,tj�dVYnXdS)Nr,)r9r=rdrrrrr��s	
z1ExceptionTests.test_generator_leaking3.<locals>.gr,r)NNN)r�r9rwr=rd�throwr)rr�r�rKZgen_excrrr�test_generator_leaking3�s	
#z&ExceptionTests.test_generator_leaking3cCs�dd�}|�}y
t�Wntk
r?t|�}YnX|j|t�yt|�Wn?tk
r�}z|jtj�d|�WYdd}~XnX|jtj�d�dS)Ncss7yddWn$tk
r2tj�dV�YnXdS)Nr,r)r9r=rdrrrrr��s

z1ExceptionTests.test_generator_leaking4.<locals>.gr,)NNN)r5r�rwr9r=rdr)rr�r�ZtprKrrr�test_generator_leaking4�s	

-z&ExceptionTests.test_generator_leaking4cs[�fdd�}|�}y
t�Wntk
rCt|�YnX�jtt|�dS)Nc3s9�jtj�dt�dV�jtj�d�dS)Nr,)NNN)r�r=rdr.rr)rrrr��sz>ExceptionTests.test_generator_doesnt_retain_old_exc.<locals>.g)r.r�r;r�)rr�r�r)rr�$test_generator_doesnt_retain_old_exc�s	

z3ExceptionTests.test_generator_doesnt_retain_old_exccsFdd���fdd�}|�t�|jtj�d�dS)Ncss	dVdS)Nr,rrrrr�
simple_gen�szIExceptionTests.test_generator_finalizing_and_exc_info.<locals>.simple_gencs6��}y
t�Wntk
r1t|�SYnXdS)N)r.r�)�gen)r�rr�run_gen�s
	

zFExceptionTests.test_generator_finalizing_and_exc_info.<locals>.run_gen)NNN)rrr=rd)rr�r)r�r�&test_generator_finalizing_and_exc_info�s
z5ExceptionTests.test_generator_finalizing_and_exc_infocs�Gdd�dt��Gdd�d�}��fdd�}|��tj��}|�}t|�||�d}�|��|j�d�dS)Nc@seZdZdd�ZdS)zFExceptionTests._check_generator_cleanup_exc_state.<locals>.MyExceptioncSs
||_dS)N)r�)rr�rrrr�szOExceptionTests._check_generator_cleanup_exc_state.<locals>.MyException.__init__N)rrrrrrrrr��sr�c@seZdZdS)z@ExceptionTests._check_generator_cleanup_exc_state.<locals>.MyObjN)rrrrrrrr��sr�c3s.y����Wn�k
r)dVYnXdS)Nrr)r�r�rr�raising_gen�s
zFExceptionTests._check_generator_cleanup_exc_state.<locals>.raising_gen)r:r�r�r�rw)rZtestfuncr�r�r�r�r)r�r�r�"_check_generator_cleanup_exc_state�s		


	z1ExceptionTests._check_generator_cleanup_exc_statecCsdd�}|j|�dS)NcSs-y|jt��Wntk
r(YnXdS)N)r�r.)r�rrr�do_throw
s
zGExceptionTests.test_generator_throw_cleanup_exc_state.<locals>.do_throw)r�)rr�rrr�&test_generator_throw_cleanup_exc_state	sz5ExceptionTests.test_generator_throw_cleanup_exc_statecCsdd�}|j|�dS)NcSs|j�dS)N)r?)r�rrr�do_closeszGExceptionTests.test_generator_close_cleanup_exc_state.<locals>.do_close)r�)rr�rrr�&test_generator_close_cleanup_exc_statesz5ExceptionTests.test_generator_close_cleanup_exc_statecCsdd�}|j|�dS)NcSs
d}dS)Nr)r�rrr�do_delszCExceptionTests.test_generator_del_cleanup_exc_state.<locals>.do_del)r�)rr�rrr�$test_generator_del_cleanup_exc_statesz3ExceptionTests.test_generator_del_cleanup_exc_statecs#�fdd�}�j|�dS)Ncs4yt|�Wntk
r"YnX�jd�dS)Nz should have raised StopIteration)r�r�rG)r�)rrr�do_nexts

zEExceptionTests.test_generator_next_cleanup_exc_state.<locals>.do_next)r�)rr�r)rr�%test_generator_next_cleanup_exc_statesz4ExceptionTests.test_generator_next_cleanup_exc_statecs#�fdd�}�j|�dS)Ncs7y|jd�Wntk
r%YnX�jd�dS)Nz should have raised StopIteration)�sendr�rG)r�)rrr�do_send&s

zEExceptionTests.test_generator_send_cleanup_exc_state.<locals>.do_send)r�)rr�r)rr�%test_generator_send_cleanup_exc_state%sz4ExceptionTests.test_generator_send_cleanup_exc_statecsQG�fdd�d�}f�yt|���WnYnX|j�d�dS)Ncs"eZdZ�fdd�ZdS)z*ExceptionTests.test_3114.<locals>.MyObjectcstj��dS)N)r=rd)r)rKrr�__del__3sz2ExceptionTests.test_3114.<locals>.MyObject.__del__N)rrrr�r)rKrr�MyObject2sr�)NNN)r:r)rr�r)rKr�	test_3114/szExceptionTests.test_3114cCs�tddddd�}|jt|�d�d|_|jt|�d�d|_d	|_|jt|�d
�d|_|jt|�d�d
|_|jt|�d�tddddd�}|jt|�d�d|_|jt|�d�d|_d	|_|jt|�d�d|_|jt|�d�d
|_|jt|�d�tdddd�}|jt|�d�d|_|jt|�d�d|_d	|_|jt|�d�d
|_|jt|�d�dS)Nr�Zxxxxxr,r�rsz8'baz' codec can't encode characters in position 1-4: foorZz<'baz' codec can't encode character '\x78' in position 1: foolESh
MQ)EzJ'baz' codec can't encode characters in position 1-4: 965230951443685724997i�zK'4000' codec can't encode characters in position 1-4: 965230951443685724997i�zN'4000' codec can't encode characters in position 1000-4: 965230951443685724997sxxxxxz3'baz' codec can't decode bytes in position 1-4: fooz5'baz' codec can't decode byte 0x78 in position 1: foozE'baz' codec can't decode bytes in position 1-4: 965230951443685724997zF'4000' codec can't decode bytes in position 1-4: 965230951443685724997zI'4000' codec can't decode bytes in position 1000-4: 965230951443685724997Zxxxxz/can't translate characters in position 1-4: fooz3can't translate character '\x78' in position 1: foozAcan't translate characters in position 1-4: 965230951443685724997zDcan't translate characters in position 1000-4: 965230951443685724997)	r�rrr�r�r�r�r�r�)r�urrr�test_unicode_change_attributes=s>														z-ExceptionTests.test_unicode_change_attributescCsCtttf}x-|D]%}|jt|j|��d�qWdS)N�)r�r�r�rr�__new__)rZklasses�klassrrr�test_unicode_errors_no_objectbs
z,ExceptionTests.test_unicode_errors_no_objectcsGdd�dt�}Gdd�dtd|�}td��{}y
t��WnW|k
r�}z|jd�WYdd}~Xn3tk
r�Yn"|jd�YnX|jd�WdQX�fd	d
����\}}}|jt|t�t|��|jdt	|��dS)Nc@seZdZdd�ZdS)z/ExceptionTests.test_badisinstance.<locals>.MetacSs
t��dS)N)r6)�cls�subclassrrr�__subclasscheck__mszAExceptionTests.test_badisinstance.<locals>.Meta.__subclasscheck__N)rrrrrrrr�Metalsrc@seZdZdS)z6ExceptionTests.test_badisinstance.<locals>.MyExceptionN)rrrrrrrr�osr��	metaclassr�z%exception should not be a MyExceptionzShould have raised KeyErrorcs.y��SWntk
r)tj�SYnXdS)N)r.r=rdr)r�rrr�~s
z,ExceptionTests.test_badisinstance.<locals>.gz maximum recursion depth exceeded)
r�r:rr&rGrh�
isinstancer.r�r)rrr�r�rK�vrkr)r�r�test_badisinstancehs 

z!ExceptionTests.test_badisinstancecsZddl�ddlm����fdd�}|�}|�}�j||�dS)Nr)�raise_memoryerrorcsVy��Wn.tk
r;}z|j}WYdd}~XnX�jd��j|�S)Nz Should have raises a MemoryError)r)r�rG�	format_tb)rKrk)rr�	tracebackrr�
raiseMemError�s
z6ExceptionTests.test_MemoryError.<locals>.raiseMemError)r
rbrr)rrZtb1Ztb2r)rrr
r�test_MemoryError�s			zExceptionTests.test_MemoryErrorc
Cs�ddl}d}d}|jt|jd�|jd�}|jt|�t�|jt|t��|j	|j
�|jd|�}|j|j
|�|jdd|�}|jt||��Gd	d
�d
t�}|jd|||f�}|jt||��|jt||��|j|j
|�|jdd
|idd6�}	|jt|	|��|j|	j
d�|j|	j
d
�dS)NrzThis is a test docstring.zThis is another test docstring.�error1z_testcapi.error1z_testcapi.error2z_testcapi.error3�basec@seZdZdS)z1ExceptionTests.test_exception_with_doc.<locals>.CN)rrrrrrr�C�srz_testcapi.error4z_testcapi.error5r�r,r�)rbr;r3Zmake_exception_with_docrwr�rh�
issubclassr:r��__doc__rr�r�)
rrbZdoc2Zdoc4rZerror2Zerror3rZerror4Zerror5rrr�test_exception_with_doc�s2	z&ExceptionTests.test_exception_with_doccs�ddlm�Gdd�d��d����fdd�}y|�Wn8tk
r�}z|j��d�WYdd}~XnX|jd�|j��d�dS)Nr)rc@seZdZdS)z3ExceptionTests.test_memory_error_cleanup.<locals>.CN)rrrrrrrr�srcs#��}tj|����dS)N)r�r�)�c)rrr�rr�inner�s	z7ExceptionTests.test_memory_error_cleanup.<locals>.innerzMemoryError not raised)rbrr)�assertNotEqualrGr)rrrKr)rrr�r�test_memory_error_cleanup�s&
z(ExceptionTests.test_memory_error_cleanupcs�Gdd�d��d����fdd��y��Wn8tk
rv}z|j��d�WYdd}~XnX|jd�|j��d�dS)Nc@seZdZdS)z6ExceptionTests.test_recursion_error_cleanup.<locals>.CN)rrrrrrrr�srcs#��}tj|����dS)N)r�r�)r)rrr�rrr�s	z:ExceptionTests.test_recursion_error_cleanup.<locals>.innerzRuntimeError not raised)r.rrGr)rrKr)rrr�r�test_recursion_error_cleanup�s&
z+ExceptionTests.test_recursion_error_cleanupc
CsH|jt��}tjt�WdQX|j|jjtj|j�dS)N)	r;r"�os�listdir�__file__rrUrx�ENOTDIR)rrXrrr�test_errno_ENOTDIR�sz!ExceptionTests.test_errno_ENOTDIRN)2rrrrrLrTr^rrpr}�unittestZ
skipUnlessr=rQr�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�r�r�r�rr
rrrrrrrrrrsTQ
0'	~


t

% (rc@s(eZdZdd�Zdd�ZdS)�ImportErrorTestscCs�td�}|j|j�|j|j�tddd�}|j|jd�|j|j�tddd�}|j|jd�|j|j�tddddd�}|j|jd�|j|jd�dS)NZtest�nameZ
somemodule�pathZsomepathZsomename)r#r�r"r#r)rrrrr�test_attributes�sz ImportErrorTests.test_attributescCsQtdtfdd��3d}t|�}|jt|�t|��WdQXdS)Nr��quietTsabc)r�BytesWarningr#rr)r�argrrrr�test_non_str_argumentsz&ImportErrorTests.test_non_str_argumentN)rrrr$r(rrrrr!�sr!�__main__)rr=r r�r�rxZtest.supportrrrrrrrr	r
rr:rrZTestCaserr!r�mainrrrr�<module>sF����