ó
ŠV]c           @   s   d  d l  Z  d  d l m Z y d  d l m Z Wn! e k
 rS d  d l m Z n Xd d l m Z d d l m	 Z	 d e f d     YZ
 d S(	   iÿÿÿÿN(   t   TestCase(   t   StringIOi   (   t   Options(   t   parse_command_linet   CmdLineParserTestc           B   s>   e  Z d    Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s@   i  } x* t  t  j   D] \ } } | | | <q W| |  _ d  S(   N(   t   varsR   t   itemst   _options_backup(   t   selft   backupt   namet   value(    (    s@   lib/python2.7/site-packages/Cython/Compiler/Tests/TestCmdLine.pyt   setUp   s    c         C   sX   t    } xH |  j j   D]7 \ } } t t | |  | k r t t | |  q q Wd  S(   N(   t   objectR   R   t   getattrR   t   setattr(   R   t   no_valueR
   t
   orig_value(    (    s@   lib/python2.7/site-packages/Cython/Compiler/Tests/TestCmdLine.pyt   tearDown   s    	c         C   sA  t  d d d d d d d d d d d	 g  \ } } |  j |  |  j | j  |  j | j  |  j | j  |  j | j  |  j | j d
 k  |  j t j	  |  j t j
  |  j t j  |  j | j d
  t  d d d g  \ } } |  j |  |  j t |  d k  |  j | j  |  j | j d  d  S(   Ns   -Vs   -ls   -+s   -ts   -vs   -ps   -Ds   -as   -3i   s   -fs   -2s
   source.pyxi   i   (   R   t   assertFalset
   assertTruet   show_versiont   use_listing_filet   cplust
   timestampst   verboseR   t   embed_pos_in_docstringt
   docstringst   annotatet   assertEqualt   language_levelt   len(   R   t   optionst   sources(    (    s@   lib/python2.7/site-packages/Cython/Compiler/Tests/TestCmdLine.pyt   test_short_options   s$    0c         C   sN  t  d d d d d d d d d d d	 d
 g  \ } } |  j |  |  j | j  |  j | j  |  j | j  |  j t j d  |  j | j	  |  j | j
 d k  |  j t j  |  j t j  |  j t j  |  j t j  |  j t j  t  d d g  \ } } |  j |  |  j t |  d k  |  j | j	  d  S(   Ns	   --versions   --create-listings   --cpluss   --embeds   --timestampss	   --verboses   --embed-positionss   --no-docstringss
   --annotates	   --lenientt   maini   s   --forces
   source.pyxi   (   R   R   R   R   R   R   R   R   t   embedR   R   R   R   R   t   error_on_unknown_namest   error_on_uninitializedR   (   R   R    R!   (    (    s@   lib/python2.7/site-packages/Cython/Compiler/Tests/TestCmdLine.pyt   test_long_options1   s*    	c         C   s  t  d d d d d d d d d	 d
 d d d g  \ } } |  j | d g  |  j t j d  |  j | j d d d g  |  j | j d  |  j | j d  |  j t j d  |  j t j d  |  j	 t j
  |  j t j d  |  j	 | j  |  j | j d  d  S(   Ns   --embed=huhus   -I/test/include/dir1s    --include-dir=/test/include/dir2s   --include-dirs   /test/include/dir3s   --working=/work/dirs
   source.pyxs   --output-file=/output/dirs   --pre-import=/pre/imports   --cleanup=3s   --annotate-coverage=cov.xmls   --gdb-outdir=/gdb/outdirs   --directive=wraparound=falset   huhus   /test/include/dir1s   /test/include/dir2s	   /work/dirs   /output/dirs   /pre/importi   s   cov.xmls   /gdb/outdir(   R   R   R   R$   t   include_patht   working_patht   output_filet
   pre_importt   generate_cleanup_codeR   R   t   annotate_coverage_xmlt	   gdb_debugt
   output_dir(   R   R    R!   (    (    s@   lib/python2.7/site-packages/Cython/Compiler/Tests/TestCmdLine.pyt   test_options_with_valuesK   s.    c            sc     f d   } | d  | d  | d  | d  | d  | d  | d  | d  d  S(	   Nc             sZ   t  j } t   } t  _ z   j t t t |    Wd  | t  _ X  j | j    d  S(   N(	   t   syst   stderrR   t   assertRaisest
   SystemExitR   t   listR   t   getvalue(   t   argst
   old_stderrR3   (   R   (    s@   lib/python2.7/site-packages/Cython/Compiler/Tests/TestCmdLine.pyt   errorf   s    	
s   -1s   -Is   --version=-as   --version=--annotate=trues	   --workings   --verbose=1s	   --cleanup(    (   R   R:   (    (   R   s@   lib/python2.7/site-packages/Cython/Compiler/Tests/TestCmdLine.pyt   test_errorse   s    	






(   t   __name__t
   __module__R   R   R"   R'   R1   R;   (    (    (    s@   lib/python2.7/site-packages/Cython/Compiler/Tests/TestCmdLine.pyR      s   					(   R2   t   unittestR    R   t   ImportErrort   iot    R   t   CmdLineR   R   (    (    (    s@   lib/python2.7/site-packages/Cython/Compiler/Tests/TestCmdLine.pyt   <module>   s   