Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_netrc.cpython-39.opt-1.pyc

a

��g��@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�tempfile�mkstemp�os�fdopen�write�
addCleanup�unlink�netrc)�selfZ	test_datarZtemp_fdZ
temp_filename�fp�r�+/usr/local/lib/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)�log2NZpass2)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�rr�passwdrrr�_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
            r0r(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
            r0r(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
            r0r(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
            r0r(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&r0r(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)Nr9)rr;rr<rr=rArBrD�FileNotFoundErrorr)rrErHrrr�test_file_not_found_in_home�s

z)NetrcTestCase.test_file_not_found_in_homecCs|jttjdd�dS)NZunlikely_netrc)�file)rDrJrr(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)
Nr8rz.machine foo.domain.com login bar password passr:csZ��|�t���4}|�d��|�d���|�}|Wd�S1sL0YdS)Nr9�USERPROFILE)�appendrrArB)�srH�result�ZcalledZ	fake_homeZorig_expanduserrr�fake_expanduser�s

z8NetrcTestCase.test_home_not_set.<locals>.fake_expanduser�
expanduserr-r.)rr;rr<rr=r>r?r@rrCrTZ	swap_attrrZauthenticatorsrZ
assertTrue)rZfake_netrc_pathrGrSrZloginZaccount�passwordrrRr�test_home_not_set�s
(*zNetrcTestCase.test_home_not_setN)r,)�__name__�
__module__�__qualname__rrr r%r)r*r+r/r1r2r3r4r5r6�unittestZ
skipUnlessr�namerIrKrMrVrrrrrs&


r�__main__)rrrZr
rr�testrZTestCaserrW�mainrrrr�<module>s
0%

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists