Your IP : 216.73.216.213


Current Path : /opt/alt/python310/lib64/python3.10/distutils/tests/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/distutils/tests/__pycache__/test_upload.cpython-310.opt-1.pyc

o

0�i��@s�dZddlZddlZddlmZddlmZddlmZddl	m
Zddlm
Z
ddl
mZddlmZddlmZmZdd	lmZmZd
ZdZGdd
�d
e�ZGdd�de�Zdd�Zedkrgee��dSdS)z#Tests for distutils.command.upload.�N)�	HTTPError)�run_unittest)�upload)�Distribution)�DistutilsError)�ERROR�INFO)�PYPIRC�BasePyPIRCCommandTestCasez�[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@s0eZdZd
dd�Zddd�Zdd�Zdd	�ZdS)�FakeOpenNcCs6||_t|t�s||_nd|_|pd|_|pd|_dS)NZOK��)�url�
isinstance�str�req�msg�code)�selfr
rr�r�B/opt/alt/python310/lib64/python3.10/distutils/tests/test_upload.py�__init__0s

zFakeOpen.__init__cCsddi�|��|�S)Nzcontent-typeztext/plain; charset=utf-8)�get�lower)r�name�defaultrrr�	getheader9s��zFakeOpen.getheadercCsdS)Nsxyzzyr�rrrr�read>sz
FakeOpen.readcCs|jS�N)rrrrr�getcodeAszFakeOpen.getcode)NNr)�__name__�
__module__�__qualname__rrrrrrrrr.s


	rcs`eZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Z�ZS)�uploadTestCasecs4tt|���tj|_|jt_d|_d|_d|_	dSr)
�superr#�setUp�
upload_mod�urlopen�old_open�_urlopen�	last_open�next_msg�	next_coder��	__class__rrr%Gs
zuploadTestCase.setUpcs|jt_tt|���dSr)r(r&r'r$r#�tearDownrr-rrr/OszuploadTestCase.tearDowncCst||j|jd�|_|jS)N)rr)rr+r,r*)rr
rrrr)SszuploadTestCase._urlopencCsH|�|jt�t�}t|�}|��dD]
\}}|�t||�|�qdS)N))Zusername�me)�passwordZsecret)ZrealmZpypi)Z
repository�https://upload.pypi.org/legacy/)�
write_file�rcr	rr�finalize_options�assertEqual�getattr)r�dist�cmd�attrZwaitedrrr�test_finalize_optionsWs�z$uploadTestCase.test_finalize_optionscCsZ|�|jt�t�}t|�}|��|�|jd�d|_t|�}|��|�|jd�dS)N�xxx)r3r4�PYPIRC_NOPASSWORDrrr5r6r1)rr8r9rrr�test_saved_passwordcsz"uploadTestCase.test_saved_passwordcCs^|��}tj�|d�}|�|�dd|}}}|||fg}|�|jt�|j|d�\}}t|�}	d|	_	|	�
�|	��t|j
jj�}
|�t|
d�d�|
d}|�|�d��|�|j
j��d	�d
}|�|j
j��|�|j
jj}
|�d|
�|�d|
�|�d
|
�|�d|
�d|
vr�|�d|
�d|
vr�|�d|
�|�t�}|�|dd�dS)Nr<�2.6��
dist_files��Content-lengthirzContent-typezmultipart/form-dataZPOSTr2sxxxsprotocol_versions
sha256_digests@cd2eb0837c9b4c962c22d2ff8b5441b7b45805887f051d39bf133b583baf6860s
md5_digests f561aaf6ef0bf14d4208bb46a4ccb3adsblake2_256_digests�b6f289a27d4fe90da63c503bfe0a9b761a8f76bb86148565065f040be6d1c3044cf7ded78ef800509bccb4b648e507d88dc6383d67642aadccce443f1534330a���z�---------------------------------------------------------------------------
xyzzy
---------------------------------------------------------------------------)�mkdtemp�os�path�joinr3r4�PYPIRC_LONG_PASSWORD�create_distr�
show_response�ensure_finalized�run�dictr*r�headers�assertGreaterEqual�intZ
assertTrue�
startswithr6Z
get_methodZget_full_url�data�assertIn�get_logsr)r�tmprG�command�	pyversion�filenamerA�pkg_dirr8r9rOZcontent_typeZexpected_urlrS�resultsrrr�test_uploadtsF

��
zuploadTestCase.test_uploadcCs�|��}tj�|d�}|j|dd�dd|}}}|||fg}|�|jt�|j|dd�\}}t|�}	d|	_	|	�
�|	��t|j
jj�}
|�t|
d�d	�|�d
|j
jj�dS)Nr<zyy
)Zcontentr?zlong description
)rA�descriptionrBrCi|slong description
)rErFrGrHr3r4rIrJrrKrLrMrNr*rrOrPrQrTrS)rrVrGrWrXrYrArZr8r9rOrrr�test_upload_correct_cr�s"
�z%uploadTestCase.test_upload_correct_crcCsd|_d|_|�t|j�dS)Nz	Not Foundi�)r+r,�assertRaisesrr\rrrr�test_upload_fails�sz uploadTestCase.test_upload_failscCsN|��}tj�|d�}|�|�dd|fg}|�|jt�|j|d�\}}td�dtft	dddid�dt
fg}|D]k\}}}	|jt|�j
d	��Utjd
tj|d�d��:|�|	��t|�}
|
��|
��Wd�n1spwY|�t�}|�||d
�|��Wd�n1s�wYWd�n1s�wYq9dS)Nr<r?r@Zoserrorr
i�Z	httperrorzUpload failed (400): httperror)�	exceptionz distutils.command.upload.urlopen)Zside_effect)�newrD)rErFrGrHr3r4rIrJ�OSErrorrrZsubTest�typer �mockZpatchZMockr_rrLrMrUrrTZ
clear_logs)rrVrGrArZr8ZtestsraZexpectedZraised_exceptionr9r[rrr�test_wrong_exception_order�s:
��
�
�

�����z)uploadTestCase.test_wrong_exception_order)
r r!r"r%r/r)r;r>r\r^r`rf�
__classcell__rrr-rr#Es0r#cCs
t�t�Sr)�unittestZ	makeSuiter#rrrr�
test_suite�s
ri�__main__)�__doc__rFrhZ
unittest.mockreZurllib.errorrZtest.supportrZdistutils.commandrr&Zdistutils.command.uploadZdistutils.corerZdistutils.errorsrZ
distutils.logrrZdistutils.tests.test_configr	r
rIr=�objectrr#rir rrrr�<module>s*
�