Your IP : 216.73.216.213


Current Path : /opt/alt/python39/lib64/python3.9/test/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/__pycache__/test_netrc.cpython-39.opt-2.pyc

a

XC?h��@sbddlZddlZddlZddlZddlZddlZddlmZGdd�dej�Z	e
dkr^e��dS)�N)�supportc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	d)dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Ze�ejdkd�d d!��Zd"d#�Zd$d%�Zd&d'�Zd(S)*�
NetrcTestCasecCs|t�|�}d}tjdkr |d7}t��\}}tj||d��}|�|�Wd�n1sZ0Y|�	tj
|�t�|�S)N�w�cygwin�t)�mode)�textwrap�dedent�sys�platform�tempfileZmkstemp�os�fdopen�write�
addCleanup�unlink�netrc)�selfZ	test_datarZtemp_fdZ
temp_filename�fp�r�4/opt/alt/python39/lib64/python3.9/test/test_netrc.py�make_nrcs

(zNetrcTestCase.make_nrccCsP|�d�}|�|jdd�|�|jdd�|�|���}|�|j|j�dS)Nz�            machine host1.domain.com login log1 password pass1 account acct1
            default login log2 password pass2
            zhost1.domain.com)Zlog1Zacct1Zpass1�default)Zlog2NZpass2)r�assertEqual�hosts�__repr__)r�nrcZnrc2rrr�test_defaults
�zNetrcTestCase.test_defaultcCs*|�d�}|�|jddgddgd��dS)Nz�            macdef macro1
            line1
            line2

            macdef macro2
            line3
            line4
            zline1
zline2
zline3
zline4
)Zmacro1Zmacro2)rrZmacros)rrrrr�test_macross
	�zNetrcTestCase.test_macroscCs&|�|�}|�|jddd|f�dS)Nzhost.domain.com�logZacct�rrr�rrZpasswdrrr�_test_passwords+s
zNetrcTestCase._test_passwordscCs|�dd�dS)NzV            machine host.domain.com login log password #pass account acct
            �#pass�r"�rrrr�test_password_with_leading_hash/s�z-NetrcTestCase.test_password_with_leading_hashcCs|�dd�dS)NzV            machine host.domain.com login log password pass# account acct
            zpass#r$r%rrr� test_password_with_trailing_hash4s�z.NetrcTestCase.test_password_with_trailing_hashcCs|�dd�dS)NzV            machine host.domain.com login log password pa#ss account acct
            zpa#ssr$r%rrr� test_password_with_internal_hash9s�z.NetrcTestCase.test_password_with_internal_hash�passcCs8|�|�}|�|jddd|f�|�|jdd�dS)N�foo.domain.com�barzbar.domain.com)ZfooNr)r r!rrr�
_test_comment>s
zNetrcTestCase._test_commentcCs|�d�dS)Nz�            # comment
            machine foo.domain.com login bar password pass
            machine bar.domain.com login foo password pass
            �r,r%rrr� test_comment_before_machine_lineCsz.NetrcTestCase.test_comment_before_machine_linecCs|�d�dS)Nz�            #comment
            machine foo.domain.com login bar password pass
            machine bar.domain.com login foo password pass
            r-r%rrr�)test_comment_before_machine_line_no_spaceJsz7NetrcTestCase.test_comment_before_machine_line_no_spacecCs|�d�dS)Nz�            #
            machine foo.domain.com login bar password pass
            machine bar.domain.com login foo password pass
            r-r%rrr�*test_comment_before_machine_line_hash_onlyQsz8NetrcTestCase.test_comment_before_machine_line_hash_onlycCs|�d�dS)Nz�            machine foo.domain.com login bar password pass # comment
            machine bar.domain.com login foo password pass
            r-r%rrr�#test_comment_at_end_of_machine_lineXsz1NetrcTestCase.test_comment_at_end_of_machine_linecCs|�d�dS)Nz�            machine foo.domain.com login bar password pass #comment
            machine bar.domain.com login foo password pass
            r-r%rrr�,test_comment_at_end_of_machine_line_no_space^sz:NetrcTestCase.test_comment_at_end_of_machine_line_no_spacecCs|�dd�dS)Nz�            machine foo.domain.com login bar password #pass #comment
            machine bar.domain.com login foo password pass
            r#r-r%rrr�1test_comment_at_end_of_machine_line_pass_has_hashds�z?NetrcTestCase.test_comment_at_end_of_machine_line_pass_has_hash�posixzPOSIX only testcCs�tj}t�|�|�tj|�tj�|d�}t|d��}|�	d�Wd�n1sV0Yt�
��^}|�d|�t�|d�t
�
�}|�|jdd�t�|d�|�t
jt
j
�Wd�n1s�0YdS)	N�.netrcZwtz                machine foo.domain.com login bar password pass
                default login foo password pass
                �HOME�r*)r+Nr)i�)r�TESTFNr
�mkdirr�rmtree�path�join�openr�EnvironmentVarGuard�set�chmodrrr�assertRaisesZNetrcParseError)r�d�fn�f�environrrrr�
test_securityks
(
�zNetrcTestCase.test_securitycCsdtj}t�|�|�tj|�t���*}|�d|�|�t	t
j
�Wd�n1sV0YdS)Nr6)rr8r
r9rr:r>r?rA�FileNotFoundErrorr)rrBrErrr�test_file_not_found_in_home�s

z)NetrcTestCase.test_file_not_found_in_homecCs|jttjdd�dS)NZunlikely_netrc)�file)rArGrr%rrr�test_file_not_found_explicit�s
�z*NetrcTestCase.test_file_not_found_explicitcs�tj�t���|�tj��tj��d�}t|d��}|�	d�Wd�n1sV0Yt�
|d�tjj�g����fdd�}t�tjd|��4t
�
�}|�d�\}}}|�|d	�Wd�n1s�0Y|���dS)
Nr5rz.machine foo.domain.com login bar password passr7csZ��|�t���4}|�d��|�d���|�}|Wd�S1sL0YdS)Nr6ZUSERPROFILE)�appendrr>r?)�srE�result�ZcalledZ	fake_homeZorig_expanduserrr�fake_expanduser�s

z8NetrcTestCase.test_home_not_set.<locals>.fake_expanduser�
expanduserr*r+)rr8r
r9rr:r;r<r=rr@rPZ	swap_attrrZauthenticatorsrZ
assertTrue)rZfake_netrc_pathrDrOrZloginZaccountZpasswordrrNr�test_home_not_set�s
(*zNetrcTestCase.test_home_not_setN)r))�__name__�
__module__�__qualname__rrrr"r&r'r(r,r.r/r0r1r2r3�unittestZ
skipUnlessr
�namerFrHrJrQrrrrrs&


r�__main__)rr
rUr
rr�testrZTestCaserrR�mainrrrr�<module>s
0%