ó
Y[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 Z d d l m Z d d l	 m
 Z
 d d l m Z d e f d „  ƒ  YZ d „  Z e d	 k r¶ e j ƒ  n  d S(
   s   Test certbot.display.completer.iÿÿÿÿN(   t   reload_module(   t   List(   t   TempDirTestCaset   CompleterTestc           B   sw   e  Z d  Z d „  Z d „  Z d „  Z d „  Z e j d d e	 ƒd „  ƒ Z
 e j d d e	 ƒd „  ƒ Z d	 „  Z RS(
   s)   Test certbot.display.completer.Completer.c         C   s½   t  t |  ƒ j ƒ  |  j d t j k r> |  j t j 7_ n  g  |  _ xo t j D]d } t j	 j
 |  j | ƒ } |  j j | ƒ t | ƒ d rŸ t j | ƒ qQ t | d ƒ  Wd  QXqQ Wd  S(   Niÿÿÿÿi   t   w(   t   superR   t   setUpt   tempdirt   ost   sept   pathst   stringt   ascii_lowercaset   patht   joint   appendt   ordt   mkdirt   open(   t   selft   cR   (    (    sH   /usr/lib/python2.7/dist-packages/certbot/tests/display/completer_test.pyR      s    	c         C   s¶   d d l  m } | j ƒ  } t |  j ƒ } xO t | ƒ D]A } | j |  j | ƒ } |  j | |  j k ƒ |  j j	 | ƒ q8 W|  j
 |  j ƒ | j |  j | ƒ } |  j | d  ƒ d  S(   Niÿÿÿÿ(   t	   completer(   t   certbot.displayR   t	   Completert   lenR
   t   ranget   completeR   t
   assertTruet   removet   assertFalset   assertEqualt   None(   R   R   t   my_completert	   num_pathst   it
   completion(    (    sH   /usr/lib/python2.7/dist-packages/certbot/tests/display/completer_test.pyt   test_complete$   s    c         C   s5   t  j d } d  t  j d <|  j ƒ  | t  j d <d  S(   Nt   readline(   t   syst   modulesR   t+   test_context_manager_with_unmocked_readline(   R   t   original_readline(    (    sH   /usr/lib/python2.7/dist-packages/certbot/tests/display/completer_test.pyt   test_import_error2   s    
c         C   su   d d l  m } t | ƒ t j ƒ  } t j ƒ  } | j ƒ   Wd  QX|  j t j ƒ  | ƒ |  j t j ƒ  | ƒ d  S(   Niÿÿÿÿ(   R   (   R   R   R    R%   t   get_completert   get_completer_delimsR   R   (   R   R   t   original_completert   original_delims(    (    sH   /usr/lib/python2.7/dist-packages/certbot/tests/display/completer_test.pyR(   :   s    
s"   certbot.display.completer.readlinet   autospecc         C   s   d | _  |  j | ƒ d  S(   Nt   libedit(   t   __doc__t(   _test_context_manager_with_mock_readline(   R   t   mock_readline(    (    sH   /usr/lib/python2.7/dist-packages/certbot/tests/display/completer_test.pyt   test_context_manager_libeditG   s    	c         C   s   d | _  |  j | ƒ d  S(   Ns   GNU readline(   R1   R2   (   R   R3   (    (    sH   /usr/lib/python2.7/dist-packages/certbot/tests/display/completer_test.pyt   test_context_manager_readlineL   s    	c         C   sF   d d l  m } t | j _ | j ƒ   Wd  QX|  j | j j ƒ d  S(   Niÿÿÿÿ(   R   (   R   R   t   enable_tab_completiont   parse_and_bindt   side_effectR   R   t   called(   R   R3   R   (    (    sH   /usr/lib/python2.7/dist-packages/certbot/tests/display/completer_test.pyR2   Q   s
    (   t   __name__t
   __module__R1   R   R$   R*   R(   t   mockt   patcht   TrueR4   R5   R2   (    (    (    sH   /usr/lib/python2.7/dist-packages/certbot/tests/display/completer_test.pyR      s   				c         C   s2   d t  j k } | r d n d } t  j | ƒ d S(   sA   Enables readline tab completion using the system specific syntax.R0   s   bind ^I rl_completes   tab: completeN(   R%   R1   R7   (   t   unused_commandR0   t   command(    (    sH   /usr/lib/python2.7/dist-packages/certbot/tests/display/completer_test.pyR6   \   s    t   __main__(   R1   R   R%   R   R&   t   unittestR<   t	   six.movesR    t   acme.magic_typingR   t   certbot.tests.utilR   R   R6   R:   t   main(    (    (    sH   /usr/lib/python2.7/dist-packages/certbot/tests/display/completer_test.pyt   <module>   s   N	