Your IP : 216.73.216.85


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_uu.cpython-35.opt-1.pyc



��Yf��@sdZddlZddlmZddlZddlZddlZddlmZddlZdZ	dZ
Gdd�dej�Zd	d
�Z
Gdd�dej�ZGd
d�dej�ZGdd�dej�Zdd�Zedkr�e�dS)z%
Tests for uu module.
Nick Mathewson
�N)�support)�BytesIOs5The smooth-scaled python crept over the sleeping dog
sKM5&AE('-M;V]T:"US8V%L960@<'ET:&]N(&-R97!T(&]V97(@=&AE('-L965P
(:6YG(&1O9PH cs@eZdZdZdddd�fdd�Zdd	�Z�S)
�FakeIOz�Text I/O implementation using an in-memory buffer.

    Can be a used as a drop-in replacement for sys.stdin and sys.stdout.
    �zutf-8�strict�
cstt|�jtj�d|d|d|�||_||_|r{t|t�sat|�}|j	|�|j
d�dS)N�encoding�errors�newliner)�superr�__init__�ior�	_encoding�_errors�
isinstance�str�write�seek)�selfZ
initial_valuerr	r
)�	__class__��1/opt/alt/python35/lib64/python3.5/test/test_uu.pyrs		
zFakeIO.__init__cCs)|j�|jj�j|j|j�S)N)�flush�buffer�getvalue�decoderr)rrrrr+s
zFakeIO.getvalue)�__name__�
__module__�__qualname__�__doc__rrrr)rrrs
rcCstd||fd�tdS)Nzbegin %03o %s
�asciis
 
end
)�bytes�encodedtext)�mode�filenamerrr�encodedtextwrapped0sr%c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�UUTestcCs�tjt�}tj�}tj||d�|j|j�tdd��tjt�}tj�}tj||dd�|j|j�tdd��dS)N�t1i�i�)r
r�	plaintext�uu�encode�assertEqualrr%)r�inp�outrrr�test_encode6szUUTest.test_encodecCs�tjtdd��}tj�}tj||�|j|j�t�tjddtdd��}tj�}tj||�|j|j�t�dS)Ni�r's(UUencoded files may contain many lines,
s%even some that have 'begin' in them.
)r
rr%r)rr+rr()rr,r-rrr�test_decode@szUUTest.test_decodecCs�tjdt�}tj�}y!tj||�|jd�Wn>tjk
r�}z|jt|�d�WYdd}~XnXdS)Ns
begin 644 t1
zNo exception raisedzTruncated input file)	r
rr"r)r�fail�Errorr+r)rr,r-�errr�test_truncatedinputNszUUTest.test_truncatedinputcCs�tjd�}tj�}y!tj||�|jd�Wn>tjk
r|}z|jt|�d�WYdd}~XnXdS)N�zNo exception raisedz'No valid begin line found in input file)r
rr)rr0r1r+r)rr,r-r2rrr�test_missingbeginWszUUTest.test_missingbegincCs�d}d}|jd��Ltj|�}tj�}tj||dd�|j|j�|�WdQRX|jd��3ddl}|j|d�}|j||�WdQRXdS)Nsbegin 644 file
!,___
 
end
s3zuu.decode()�quietT�uu_codecr)ZsubTestr
rr)rr+r�codecs)rr"r(r,r-r8Zdecodedrrr�test_garbage_padding`szUUTest.test_garbage_paddingN)rrrr.r/r3r5r9rrrrr&4s

		r&c@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�UUStdIOTestcCstj|_tj|_dS)N)�sys�stdin�stdout)rrrr�setUpxszUUStdIOTest.setUpcCs|jt_|jt_dS)N)r<r;r=)rrrr�tearDown|szUUStdIOTest.tearDowncCsittjd��t_t�t_tjdddd�|jtjj	�t
dd�jd��dS)Nr �-r'i�)rr(rr;r<r=r)r*r+rr%)rrrrr.�s
zUUStdIOTest.test_encodecCs�ttdd�jd��t_t�t_tjdd�tj}|jt_|jt_|j|j�t	jd��dS)Ni�r'r r@)
rr%rr;r<r=r)r+rr()rr=rrrr/�s!	zUUStdIOTest.test_decodeN)rrrr>r?r.r/rrrrr:vsr:c@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�
UUFileTestcCs�|dkrdSy|j�Wn"ttfk
r;�YnYnXytj|j�Wn"ttfk
rt�YnYnXdS)N)�close�
SystemExit�KeyboardInterrupt�os�unlink�name)r�frrr�_kill�szUUFileTest._killcCs$tjd|_tjd|_dS)N�i�o)rZTESTFN�tmpin�tmpout)rrrrr>�szUUFileTest.setUpcCs|`|`dS)N)rLrM)rrrrr?�szUUFileTest.tearDowncCsgd}}z;tj|j�t|jd�}|jt�|j�t|jd�}t|jd�}tj	|||jdd�|j�|j�t|jd�}|j
�}|j�|j|td|j��tj	|j|j|jdd�t|jd�}|j
�}|j�|j|td|j��Wd|j
|�|j
|�XdS)N�wb�rbr#i�)rrFrL�openrr(rBrMr)r*�readr+r%rI)rZfinZfout�srrrr.�s,





"
 
zUUFileTest.test_encodecCs�d}z�tj|j�t|jd�}|jtd|j��|j�t|jd�}tj	|�|j�t|jd�}|j
�}|j�|j|t�Wd|j
|�XdS)NrNi�rO)rrFrLrPrr%rMrBr)rrQr+r(rI)rrHrRrrrr/�s



zUUFileTest.test_decodecCs�d}z�tj|j�t|jd�}|jtd|j��|j�tj	|j�t|jd�}|j
�}|j�|j|t�Wd|j
|�XdS)NrNi�rO)rrFrLrPrr%rMrBr)rrQr+r(rI)rrHrRrrr�test_decode_filename�s

zUUFileTest.test_decode_filenamecCs�d}z}tjtd|j��}t|jd�}tj|�|j�t|jd�}|j	tj
tj|�|j�Wd|j|�XdS)Ni�rO)r
rr%rMrPrLr)rrBZassertRaisesr1rI)rrHrrr�test_decodetwice�s

zUUFileTest.test_decodetwiceN)
rrrrIr>r?r.r/rSrTrrrrrA�srAcCstjttt�dS)N)rZrun_unittestr&r:rArrrr�	test_main�s	rU�__main__)rZunittestZtestrr;rEr)r
rr(r"�
TextIOWrapperrr%ZTestCaser&r:rArUrrrrr�<module>s Bn