
    e                         d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 dZd	Zd
Z G d de
j        e
j        e
j        ej                  Z G d de          Zedk    r ej                     dS dS )z"Tests for distutils.pypirc.pypirc.    N)PyPIRCCommand)Distribution)set_threshold)WARN)supportz[distutils]

index-servers =
    server1
    server2
    server3

[server1]
username:me
password:secret

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

[server3]
username:cbiggles
password:yh^%#rest-of-my-password
z.[server-login]
username:tarek
password:secret
zI[distutils]
index-servers =
    pypi

[pypi]
username:tarek
password:xxx
c                   (     e Zd Z fdZ fdZ xZS )BasePyPIRCCommandTestCasec                    t          t          |                                            |                                 | _        | j        t
          j        d<   | j        t
          j        d<   t
          j                            | j        d          | _	        t                      | _         G d dt                    }|| _        t          t                    | _        dS )zPatches the environment.HOMEUSERPROFILEz.pypircc                       e Zd Zd Zd ZeZdS )0BasePyPIRCCommandTestCase.setUp.<locals>.commandc                 0    t          j        | |           d S N)r   __init__)selfdists     -  /home/conda/feedstock_root/build_artifacts/python-split_1708115622739/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/python3.11/distutils/tests/test_config.pyr   z9BasePyPIRCCommandTestCase.setUp.<locals>.command.__init__C   s    &tT22222    c                     d S r    )r   s    r   initialize_optionszCBasePyPIRCCommandTestCase.setUp.<locals>.command.initialize_optionsE   s    r   N)__name__
__module____qualname__r   r   finalize_optionsr   r   r   commandr   B   s4        3 3 3  1r   r   N)superr	   setUpmkdtemptmp_dirosenvironpathjoinrcr   r   r   _cmdr   r   old_threshold)r   r   	__class__s     r   r   zBasePyPIRCCommandTestCase.setUp9   s    '..44666||~~!\
6$(L
=!',,t|Y77 NN		2 	2 	2 	2 	2m 	2 	2 	2 	*400r   c                 ~    t          | j                   t          t          |                                            dS )zRemoves the patch.N)r   r(   r   r	   tearDown)r   r)   s    r   r+   z"BasePyPIRCCommandTestCase.tearDownL   s7    d()))'..7799999r   )r   r   r   r   r+   __classcell__)r)   s   @r   r	   r	   4   sQ        
1 1 1 1 1&: : : : : : : : :r   r	   c                        e Zd Zd Zd Zd ZdS )PyPIRCCommandTestCasec                 *   |                      | j        t                     |                     | j                  }|                                }t          t          |                                                    }g d}| 	                    ||           |                      | j        t                     |                                }t          t          |                                                    }g d}| 	                    ||           d S )N)passwordsecretrealmpypi
repositoryzhttps://upload.pypi.org/legacy/)serverserver1)usernameme)r0   r3   r6   )r8   zserver-login)r:   tarek)
write_filer&   PYPIRCr'   r   _read_pypirclistsorteditemsassertEqual
PYPIRC_OLDr   cmdconfigwaiteds       r   test_server_registrationz.PyPIRCCommandTestCase.test_server_registrationT   s     	(((ii	""!!##fV\\^^,,--= = = 	((( 	,,,!!##fV\\^^,,--E E E 	(((((r   c                 .   |                      | j                  }|                                }|                     t          j                            |                     |                    dd           |                     t          j                            |                     t          |          }	 |
                                }|                     |t                     |                                 d S # |                                 w xY w)Nr<   xxx)r'   r   _get_rc_fileassertFalser"   r$   exists_store_pypirc
assertTrueopenreadrC   WANTEDclose)r   rF   r&   fcontents        r   test_server_empty_registrationz4PyPIRCCommandTestCase.test_server_empty_registrationm   s    ii	""++,,,'5)))r**+++HH	ffhhGWf---GGIIIIIAGGIIIIs   9/C> >Dc                 @   |                      | j        t                     |                     | j                  }d|_        |                                }t          t          |	                                                    }g d}| 
                    ||           d S )Nserver3))r1   zyh^%#rest-of-my-passwordr3   r6   )r8   rY   )r:   cbiggles)r=   r&   r>   r'   r   r7   r?   r@   rA   rB   rC   rE   s       r   test_config_interpolationz/PyPIRCCommandTestCase.test_config_interpolationz   s    (((ii	"""!!##fV\\^^,,--C C C 	(((((r   N)r   r   r   rI   rW   r[   r   r   r   r.   r.   R   sA        ) ) )2  ) ) ) ) )r   r.   __main__)__doc__r"   unittestdistutils.corer   r   distutils.logr   r   distutils.testsr   r>   rD   rS   TempdirManagerLoggingSilencerEnvironGuardTestCaser	   r.   r   mainr   r   r   <module>rg      s   ( ( 				  ( ( ( ( ( ( ' ' ' ' ' ' ' ' ' ' ' '       # # # # # #
.

: : : : : 6#3#0$-: : :<3) 3) 3) 3) 3)5 3) 3) 3)l zHMOOOOO r   