HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/distutils/tests/__pycache__/test_upload.cpython-37.opt-2.pyc
B

!��g��@s�ddlZddlZddlmZddlmZddlmZddlm	Z
ddlm	Z	ddlm
Z
ddlmZddlmZmZddlmZmZd	Zd
ZGdd�de�ZGd
d�de�Zdd�Zedkr�ee��dS)�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|_|p$d|_|p.d|_dS)NZOK��)�url�
isinstance�str�req�msg�code)�selfr
rr�r�7/usr/local/lib/python3.7/distutils/tests/test_upload.py�__init__0s

zFakeOpen.__init__cCsddi�|��|�S)Nzcontent-typeztext/plain; charset=utf-8)�get�lower)r�name�defaultrrr�	getheader9szFakeOpen.getheadercCsdS)Nsxyzzyr)rrrr�read>sz
FakeOpen.readcCs|jS)N)r)rrrr�getcodeAszFakeOpen.getcode)NN)N)�__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|_	dS)N)
�superr!�setUp�
upload_mod�urlopen�old_open�_urlopen�	last_open�next_msg�	next_code)r)�	__class__rrr#GszuploadTestCase.setUpcs|jt_tt|���dS)N)r&r$r%r"r!�tearDown)r)r+rrr,OszuploadTestCase.tearDowncCst||j|jd�|_|jS)N)rr)rr)r*r()rr
rrrr'SszuploadTestCase._urlopencCsL|�|jt�t�}t|�}|��x"dD]\}}|�t||�|�q*WdS)N))Zusername�me)�passwordZsecret)ZrealmZpypi)Z
repositoryzhttps://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)r/r0�PYPIRC_NOPASSWORDrrr1r2r.)rr4r5rrr�test_saved_passwordcsz"uploadTestCase.test_saved_passwordcCs|��}tj�|d�}|�|�dd|}}}|||fg}|�|jt�|j|d�\}}t|�}	d|	_	|	�
�|	��t|j
jj�}
|�|
dd�|
d}|�|�d��|�|j
j��d	�d
}|�|j
j��|�|�d|j
jjk�|�d|j
jj�|�t�}
|�|
d
d�dS)Nr8z2.6)�
dist_files�zContent-lengthZ2162zContent-typezmultipart/form-dataZPOSTzhttps://upload.pypi.org/legacy/sxxxsprotocol_version���z�---------------------------------------------------------------------------
xyzzy
---------------------------------------------------------------------------)�mkdtemp�os�path�joinr/r0�PYPIRC_LONG_PASSWORD�create_distr�
show_response�ensure_finalized�run�dictr(r�headersr2Z
assertTrue�
startswithZ
get_methodZget_full_url�data�assertIn�get_logsr)r�tmpr@�command�	pyversion�filenamer;�pkg_dirr4r5rHZcontent_typeZexpected_url�resultsrrr�test_uploadts,

zuploadTestCase.test_uploadcCs�|��}tj�|d�}|j|dd�dd|}}}|||fg}|�|jt�|j|dd�\}}t|�}	d|	_	|	�
�|	��t|j
jj�}
|�|
dd	�|�d
|j
jj�dS)Nr8zyy
)Zcontentz2.6zlong description
)r;�descriptionr<zContent-lengthZ2172slong description
)r>r?r@rAr/r0rBrCrrDrErFrGr(rrHr2rKrJ)rrMr@rNrOrPr;rQr4r5rHrrr�test_upload_correct_cr�s z%uploadTestCase.test_upload_correct_crcCsd|_d|_|�t|j�dS)Nz	Not Foundi�)r)r*�assertRaisesrrS)rrrr�test_upload_fails�sz uploadTestCase.test_upload_failscCs|��}tj�|d�}|�|�dd|fg}|�|jt�|j|d�\}}td�dtft	dddid�dt
fg}x�|D]�\}}}	|jt|�j
d	��xtjd
tj|d�d��V|�|	��t|�}
|
��|
��WdQRX|�t�}|�||d
�|��WdQRXWdQRXqtWdS)Nr8z2.6)r;Zoserrorr
i�Z	httperrorzUpload failed (400): httperror)�	exceptionz distutils.command.upload.urlopen)Zside_effect)�newr=)r>r?r@rAr/r0rBrC�OSErrorrrZsubTest�typer�mockZpatchZMockrVrrErFrLrrKZ
clear_logs)rrMr@r;rQr4ZtestsrXZexpectedZraised_exceptionr5rRrrr�test_wrong_exception_order�s(


z)uploadTestCase.test_wrong_exception_order)
rrr r#r,r'r7r:rSrUrWr]�
__classcell__rr)r+rr!Es r!cCs
t�t�S)N)�unittestZ	makeSuiter!rrrr�
test_suite�sr`�__main__)r?r_Z
unittest.mockr\Zurllib.requestrZtest.supportrZdistutils.commandrr$Zdistutils.command.uploadZdistutils.corerZdistutils.errorsrZ
distutils.logrrZdistutils.tests.test_configr	r
rBr9�objectrr!r`rrrrr�<module>s$