ó
Š]c           @   s  d  Z  d d l Z d d l Z d d l 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 d l m Z d	 Z d
 Z d Z d e j e j e j e j f d „  ƒ  YZ d „  Z e d k re e ƒ  ƒ n  d S(   s"   Tests for distutils.pypirc.pypirc.iÿÿÿÿN(   t   PyPIRCCommand(   t   Distribution(   t   set_threshold(   t   WARN(   t   support(   t   run_unittests´   [distutils]

index-servers =
    server1
    server2

[server1]
username:me
password:secret

[server2]
username:meagain
password: secret
realm:acme
repository:http://another.pypi/
s.   [server-login]
username:tarek
password:secret
sI   [distutils]
index-servers =
    pypi

[pypi]
username:tarek
password:xxx
t   PyPIRCCommandTestCasec           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   s‹   t  t |  ƒ j ƒ  |  j ƒ  |  _ |  j t j d <t j j |  j d ƒ |  _	 t
 ƒ  |  _ d t f d „  ƒ  Y} | |  _ t t ƒ |  _ d S(   s   Patches the environment.t   HOMEs   .pypirct   commandc           B   s    e  Z d  „  Z d „  Z e Z RS(   c         S   s   t  j |  | ƒ d  S(   N(   R    t   __init__(   t   selft   dist(    (    s,   lib/python2.7/distutils/tests/test_config.pyR	   A   s    c         S   s   d  S(   N(    (   R
   (    (    s,   lib/python2.7/distutils/tests/test_config.pyt   initialize_optionsC   s    (   t   __name__t
   __module__R	   R   t   finalize_options(    (    (    s,   lib/python2.7/distutils/tests/test_config.pyR   @   s   		N(   t   superR   t   setUpt   mkdtempt   tmp_dirt   ost   environt   patht   joint   rcR   R   R    t   _cmdR   R   t   old_threshold(   R
   R   (    (    s,   lib/python2.7/distutils/tests/test_config.pyR   8   s    	c         C   s$   t  |  j ƒ t t |  ƒ j ƒ  d S(   s   Removes the patch.N(   R   R   R   R   t   tearDown(   R
   (    (    s,   lib/python2.7/distutils/tests/test_config.pyR   J   s    c         C   sÊ   |  j  |  j t ƒ |  j |  j ƒ } | j ƒ  } | j ƒ  } | j ƒ  d d d d d g } |  j | | ƒ |  j  |  j t	 ƒ | j ƒ  } | j ƒ  } | j ƒ  d d d d d g } |  j | | ƒ d  S(   Nt   passwordt   secrett   realmt   pypit
   repositorys   https://upload.pypi.org/legacy/t   servert   server1t   usernamet   mes   server-logint   tarek(   R   R   (   R   R   (   R    s   https://upload.pypi.org/legacy/(   R!   R"   (   R#   R$   (   R   R   (   R   R   (   R    s   https://upload.pypi.org/legacy/(   R!   s   server-login(   R#   R%   (
   t
   write_fileR   t   PYPIRCR   R   t   _read_pypirct   itemst   sortt   assertEqualt
   PYPIRC_OLD(   R
   t   cmdt   configt   waited(    (    s,   lib/python2.7/distutils/tests/test_config.pyt   test_server_registrationO   s"    

c         C   sž   |  j  |  j ƒ } | j ƒ  } |  j t j j | ƒ ƒ | j d d ƒ |  j t j j | ƒ ƒ t	 | ƒ } z  | j
 ƒ  } |  j | t ƒ Wd  | j ƒ  Xd  S(   NR%   t   xxx(   R   R   t   _get_rc_filet   assertFalseR   R   t   existst   _store_pypirct
   assertTruet   opent   readR+   t   WANTEDt   close(   R
   R-   R   t   ft   content(    (    s,   lib/python2.7/distutils/tests/test_config.pyt   test_server_empty_registrationj   s    (   R   R   R   R   R0   R=   (    (    (    s,   lib/python2.7/distutils/tests/test_config.pyR   3   s   			c           C   s   t  j t ƒ S(   N(   t   unittestt	   makeSuiteR   (    (    (    s,   lib/python2.7/distutils/tests/test_config.pyt
   test_suitew   s    t   __main__(   t   __doc__t   sysR   R>   t   tempfilet   shutilt   distutils.coreR    R   t   distutils.logR   R   t   distutils.testsR   t   test.test_supportR   R'   R,   R9   t   TempdirManagert   LoggingSilencert   EnvironGuardt   TestCaseR   R@   R   (    (    (    s,   lib/python2.7/distutils/tests/test_config.pyt   <module>   s*   
	A	