Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/distutils/tests/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/distutils/tests/__pycache__/test_upload.cpython-34.pyc

�
i fm�@s�dZddlZddlZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZddlmZmZd	Zd
ZGdd�de�ZGd
d�de�Zdd�Zedkr�ee��ndS)z#Tests for distutils.command.upload.�N)�run_unittest)�upload)�Distribution)�DistutilsError)�INFO)�PYPIRC�PyPIRCCommandTestCasez�[distutils]

index-servers =
    server1
    server2

[server1]
username:me
password:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

[server2]
username:meagain
password: secret
realm:acme
repository:http://another.pypi/
z@[distutils]

index-servers =
    server1

[server1]
username:me
c@sIeZdZdddd�Zddd�Zdd�Zdd	�ZdS)
�FakeOpenNcCsO||_t|t�s$||_n	d|_|p6d|_|pEd|_dS)NZOK��)�url�
isinstance�str�req�msg�code)�selfrrr�r�@/opt/alt/python34/lib64/python3.4/distutils/tests/test_upload.py�__init__-s		zFakeOpen.__init__cCsidd6j|j�|�S)Nztext/plain; charset=utf-8zcontent-type)�get�lower)r�name�defaultrrr�	getheader6s
zFakeOpen.getheadercCsdS)Nsxyzzyr)rrrr�read;sz
FakeOpen.readcCs|jS)N)r)rrrr�getcode>szFakeOpen.getcode)�__name__�
__module__�__qualname__rrrrrrrrr	+s	r	cspeZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	�S)�uploadTestCasecsJtt|�j�tj|_|jt_d|_d|_d|_	dS)N)
�superr�setUp�
upload_mod�urlopen�old_open�_urlopen�	last_open�next_msg�	next_code)r)�	__class__rrr!Ds		zuploadTestCase.setUpcs#|jt_tt|�j�dS)N)r$r"r#r r�tearDown)r)r)rrr*LszuploadTestCase.tearDowncCs(t|d|jd|j�|_|jS)Nrr)r	r'r(r&)rrrrrr%Ps!zuploadTestCase._urlopencCsf|j|jt�t�}t|�}|j�x-d
D]%\}}|jt||�|�q9WdS)N�username�me�password�secret�realm�pypi�
repository�https://upload.pypi.org/legacy/�r+zme�zpasswordr.�r/r0�r1r2)r3r4r5r6)�
write_file�rcrrr�finalize_options�assertEqual�getattr)r�dist�cmd�attrZwaitedrrr�test_finalize_optionsTs	
z$uploadTestCase.test_finalize_optionscCs{|j|jt�t�}t|�}|j�|j|jd�d|_t|�}|j�|j|jd�dS)N�xxx)r7r8�PYPIRC_NOPASSWORDrrr9r:r-)rr<r=rrr�test_saved_password`s	
	
z"uploadTestCase.test_saved_passwordcCsr|j�}tjj|d�}|j|�dd|}}}|||fg}|j|jt�|jd|�\}}t|�}	d|	_	|	j
�|	j�t|j
jj�}
|j|
dd�|
d}|j|jd��|j|j
jj�d	�d
}|j|j
jj�|�|jd|j
jjk�|jt�}
|jd|
d
�dS)Nr@z2.6�
dist_files�zContent-lengthZ2161zContent-typezmultipart/form-dataZPOSTzhttps://upload.pypi.org/legacy/sxxxzxyzzy
���)Zmkdtemp�os�path�joinr7r8�PYPIRC_LONG_PASSWORDZcreate_distrZ
show_responseZensure_finalizedZrun�dictr&r�headersr:Z
assertTrue�
startswithZ
get_methodZget_full_url�dataZget_logsrZassertIn)rZtmprGZcommandZ	pyversion�filenamerCZpkg_dirr<r=rKZcontent_typeZexpected_urlZresultsrrr�test_uploadqs*
	


zuploadTestCase.test_uploadcCs)d|_d|_|jt|j�dS)Nz	Not Foundi�)r'r(ZassertRaisesrrO)rrrr�test_upload_fails�s		z uploadTestCase.test_upload_fails)
rrrr!r*r%r?rBrOrPrr)r)rrBsrcCs
tjt�S)N)�unittestZ	makeSuiterrrrr�
test_suite�srR�__main__)�__doc__rFrQZtest.supportrZdistutils.commandrr"Zdistutils.command.uploadZdistutils.corerZdistutils.errorsrZ
distutils.logrZdistutils.tests.test_configrrrIrA�objectr	rrRrrrrr�<module>s Q