ó
[³XMc           @   sÈ   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 m	 Z	 d e j
 f d „  ƒ  YZ d e	 j f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d „  Z d e	 j f d „  ƒ  YZ d Z d S(   s'   
Test cases for twisted.python.zshcomp
iÿÿÿÿN(   t   StringIO(   t   unittest(   t   zshcompt   usaget   ZshcompTestCasec           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sT   
    Tests for the zsh completion function builder in twisted/python/zshcomp.py
    c         C   s£   |  j  ƒ  } t j | ƒ g  t j | ƒ D] } | d ^ q) } x] t j D]R } | d | k re qI n  t j j | d | d ƒ } |  j t j j	 | ƒ ƒ qI Wd S(   sn   
        Build all the completion functions for twisted commands - no errors
        should be raised
        i    t   _N(
   t   mktempt   ost   mkdirR   t   makeCompFunctionFilest   generateFort   patht   joint
   failUnlesst   exists(   t   selft   dirnamet   xt   skippedCmdst   infot   funcPath(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_zshcomp.pyt   test_buildAll   s    &c         C   sÞ   t  ƒ  } t j d | d ƒ } t j j ƒ  } | j t  j ƒ t j j ƒ  } | j t  j ƒ |  j | j	 | ƒ |  j | j
 | ƒ |  j | j t j ƒ |  j | j t j ƒ |  j | j t j ƒ |  j | j t j ƒ d S(   sp   
        Test that the zsh_* variables you can place on Option classes gets
        picked up correctly
        t	   dummy_cmdt   dummy_valueN(   t   TestOptions2R   t   ArgumentsGeneratort   TestOptionst   zsh_altArgDescrt   copyt   updatet   zsh_actionDescrt   failUnlessEqualst   altArgDescrt   actionDescrt   multiUset   zsh_multiUset   mutuallyExclusivet   zsh_mutuallyExclusivet   actionst   zsh_actionst   extrast
   zsh_extras(   R   t   optst   agR    R!   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_zshcomp.pyt   test_accumulateMetadata"   s    	
c         C   sl   t  ƒ  } t j d | d ƒ } |  j d | j k o? d | j k ƒ |  j d | j k od d | j k ƒ d S(   s¯   
        Test that we pick up options that are only defined by having an
        appropriately named method on your Options class,
        e.g. def opt_foo(self, foo)
        R   R   t   nocrasht
   difficultyN(   R   R   R   R   t
   optFlags_dt   optAll_dt   optParams_d(   R   R*   R+   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_zshcomp.pyt    test_accumulateAdditionalOptions8   s    	c         C   s?   d t  f d „  ƒ  Y} | ƒ  } |  j t t j d | d ƒ d S(   sf   
        Test that using a parameter/flag name that doesn't exist
        will raise an error
        t
   TmpOptionsc           B   s   e  Z i d  d 6Z RS(   t   foot   detaill(   t   __name__t
   __module__R'   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_zshcomp.pyR3   K   s   R   R   N(   R   t   failUnlessRaisest
   ValueErrorR   R   (   R   R3   R*   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_zshcomp.pyt   test_verifyZshNamesF   s    	c         C   s[   d } t  ƒ  } t ƒ  } t j | | | ƒ } | j ƒ  | j ƒ  |  j | j ƒ  t ƒ d S(   st   
        Generate a completion function, and test the textual output
        against a known correct output
        t   testprogN(	   t   CodeTestOptionsR    R   t   Buildert   writet   resetR   t   readt   testOutput1(   R   t   cmd_nameR*   t   ft   b(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_zshcomp.pyt   test_zshCodeR   s    		

c         C   s˜   d	 g } t  j d | i  ƒ } |  j t | ƒ d ƒ |  j t | d ƒ d ƒ |  j | d d d ƒ |  j t | d d t ƒ ƒ |  j |  t ƒ d S(
   s{   
        Test that makeCompFunctionFiles skips building for commands whos
        script module cannot be imported
        t   test_cmds   no.way.your.gonna.import.thist   Foot   out_diri   i    i   N(   RF   s   no.way.your.gonna.import.thisRG   (   R   R	   t   failUnlessEqualt   lenR   t
   isinstancet   ImportErrort   flushLoggedErrors(   R   R
   t   skips(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_zshcomp.pyt   test_skipBuild_   s    	(	   R6   R7   t   __doc__R   R,   R2   R:   RE   RO   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_zshcomp.pyR      s   					R   c        	   B   sá   e  Z d  Z d d d g d d d g d d d	 g d
 d d g d d d g d d d g d d d g g Z d d" d d g d d d d g g Z i d d 6d d 6Z i d d 6Z d g Z d d d d
 g g Z	 i d  d 6Z
 d! g Z RS(#   s4   
    Command-line options for an imaginary game
    t   fokkerRC   s2   Select the Fokker Dr.I as your dogfighter aircraftt   albatrost   as5   Select the Albatros D-III as your dogfighter aircraftt   spadt   ss1   Select the SPAD S.VII as your dogfighter aircraftt   bristolRD   s4   Select the Bristol Scout as your dogfighter aircraftt   physicst   ps$   Enable secret Twisted physics enginet   jamt   js6   Enable a small chance that your machine guns will jam!t   verboset   vs1   Verbose logging (may be specified more than once)s
   pilot-names   What's your name, Ace?s   Manfred von Richthofent   detailt   ds*   Select the level of rendering detail (1-5)t   3s   Twisted-Physicss   Rendering detail levels   Pick your details   (1 2 3 4 5)s   :saved game file to load:_filesN(   R6   R7   RP   t   optFlagst   Nonet   optParametersR   R   R#   R%   R'   R)   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_zshcomp.pyR   m   s4   	

	R   c           B   sa   e  Z d  Z d d
 d g g Z d d
 d d g g Z i d d 6Z i d d 6Z d „  Z d	 „  Z	 RS(   s½   
    Extend the options and zsh metadata provided by TestOptions. zshcomp must
    accumulate options and metadata from all classes in the hiearchy so this
    is important for testing
    s	   no-stallss+   Turn off the ability to stall your aircrafts   reality-levels)   Select the level of physics reality (1-5)t   5s   Can't stall your planes   Physics reality levelc         C   s   d S(   s&   Select that you can't crash your planeN(    (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_zshcomp.pyt   opt_nocrashž   s    c         C   s   d S(   s   How tough are you? (1-10)N(    (   R   R.   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_zshcomp.pyt   opt_difficulty¡   s    N(
   R6   R7   RP   Ra   R`   Rb   R   R   Rd   Re   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_zshcomp.pyR      s   	c           C   s   d S(   Ns   (1 2 3)(    (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_zshcomp.pyt   _accuracyAction¤   s    R<   c           B   s¹   e  Z d  Z d d d g d d d g d d d	 g g Z d
 d d d g d d d d g g Z i d d 6d d
 6Z i d d
 6d d 6Z d g Z d d g g Z	 i d d
 6e
 d 6Z d g Z RS(   s7   
    Command-line options for an imaginary program
    t   colort   cs   Turn on color outputt   grayt   gs   Turn on gray-scale outputR[   R\   s1   Verbose logging (may be specified more than once)t   optimizations&   Select the level of optimization (1-5)Rc   t   accuracyRS   s"   Select the level of accuracy (1-3)R_   s   Color ons   Optimization levels   Optimization?s	   Accuracy?s   (1 2 3 4 5)s   :output file:_filesN(   R6   R7   RP   R`   Ra   Rb   R   R   R#   R%   Rf   R'   R)   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_zshcomp.pyR<   §   s$   	



	

sO  #compdef testprog
_arguments -s -A "-*" \
':output file:_files' \
'(--accuracy)-a[3]:Accuracy?:(1 2 3)' \
'(-a)--accuracy=[3]:Accuracy?:(1 2 3)' \
'(--gray -g --color)-c[Color on]' \
'(--gray -g -c)--color[Color on]' \
'(--color -c --gray)-g[Turn on gray-scale output]' \
'(--color -c -g)--gray[Turn on gray-scale output]' \
'--help[Display this help and exit.]' \
'--optimization=[Optimization level]:Optimization?:(1 2 3 4 5)' \
'*-v[Verbose logging (may be specified more than once)]' \
'*--verbose[Verbose logging (may be specified more than once)]' \
'--version[version]' \
&& return 0
(   RP   R   t   os.patht	   cStringIOR    t   twisted.trialR   t   twisted.pythonR   R   t   TestCaseR   t   OptionsR   R   Rf   R<   RA   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_zshcomp.pyt   <module>   s   _#	*