ó
[³XMc           @   s  d  Z  d d l m Z d d l m Z d d l Z d d l Z d d d „  ƒ  YZ d e j f d „  ƒ  YZ	 d	 d d
 „  ƒ  YZ
 d d d „  ƒ  YZ d e e f d „  ƒ  YZ d d d „  ƒ  YZ d „  Z d „  Z d „  Z e d ƒ d „ Z d e j f d „  ƒ  YZ e d k re j ƒ  n  d S(   s   
Test cases for explorer
iÿÿÿÿ(   t   unittest(   t   explorerNt   SomeDohickeyc           B   s   e  Z d  „  Z d „  Z RS(   c         G   s   | |  j  d <d  S(   Nt   args(   t   __dict__(   t   selft   a(    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   __init__    s    c         C   s   |  j  S(   N(   R   (   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   bip#   s    (   t   __name__t
   __module__R   R   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyR      s   	t   TestBrowserc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s2   t  j |  _ |  j j ƒ  d t d ƒ g |  _ d  S(   Ns&   How many stairs must a man climb down?i*   (   R   t   explorerPoolt   poolt   clearR   t	   testThing(   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   setUp(   s    c         C   s{   |  j  j |  j d ƒ } |  j | j t |  j ƒ ƒ |  j | j d ƒ | j ƒ  d } |  j | j t |  j d ƒ ƒ d S(   s   Following a chain of Explorers.R   i   N(   R   t   getExplorerR   t   failUnlessEqualt   idt
   identifiert   get_elements(   R   t   xplorert   dxplorer(    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt
   test_chain.   s
    (   R	   R
   R   R   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyR   '   s   	t   Watcherc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   i    c         C   s   g  |  _  d  S(   N(   t   links(   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyR   9   s    c         C   s   |  j  j | ƒ d  S(   N(   R   t   append(   R   t   olink(    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   receiveBrowserObject<   s    c         C   s   t  |  j ƒ |  _ d  S(   N(   t   lenR   t   zero(   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   setZero?   s    c         C   s   t  |  j ƒ |  j S(   N(   R   R   R   (   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyR   B   s    (   R	   R
   R   R   R   R    R   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyR   7   s
   			t   SetattrDohickeyc           B   s   e  Z d  „  Z RS(   c         C   s9   t  t | ƒ ƒ } | j ƒ  t j | d ƒ |  j | <d  S(   Nt    (   t   listt   strt   reverset   stringt   joinR   (   R   t   kt   v(    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   __setattr__G   s    
(   R	   R
   R*   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyR!   F   s   t	   MiddleManc           B   s   e  Z RS(    (   R	   R
   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyR+   L   s   t   FIXME_Watchc           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   sF   t  ƒ  j ƒ  |  _ i  |  _ t j |  j |  j ƒ |  _ t ƒ  |  _ d  S(   N(	   t   globalst   copyt   globalNSt   localNSR   t   ObjectBrowsert   browserR   t   watcher(   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyR   Q   s    	c         C   s”   t  d ƒ } |  j j | d |  j j ƒ |  j j ƒ  d | _ |  j | j d ƒ |  j |  j j	 ƒ  ƒ |  j j
 d } |  j | j t | ƒ ƒ d S(   s6   Triggering a watcher response by setting an attribute.t   pencilR   t	   someValueiÿÿÿÿN(   R   R2   t   watchObjectR3   R   R    t   someAttrR   t
   failUnlessR   R   R   (   R   R   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   test_setAttrPlainW   s    	c         C   s”   t  d ƒ } |  j j | d |  j j ƒ |  j j ƒ  d | _ |  j | j d ƒ |  j |  j j	 ƒ  ƒ |  j j
 d } |  j | j t | ƒ ƒ d S(   s=   Setting an attribute on a watched object that has __setattr__R4   R   t   ZORTt   TROZiÿÿÿÿN(   R+   R2   R6   R3   R   R    R7   R   R8   R   R   R   (   R   R   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   test_setAttrChainf   s    	c         C   s«   x¤ t  d ƒ t d ƒ f D]Š } |  j j | d |  j j ƒ |  j j ƒ  | j ƒ  } |  j | d ƒ |  j	 |  j j
 ƒ  ƒ |  j j d } |  j | j t | ƒ ƒ q Wd S(   s3   Triggering a watcher response by invoking a method.R4   R   iÿÿÿÿN(   s   pencil(   R   R+   R2   R6   R3   R   R    R   R   R8   R   R   R   (   R   R   t   rvalR   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   test_methodv   s    (   R	   R
   R   R9   R<   R>   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyR,   P   s   			c           C   s   d S(   s-   A function which accepts no arguments at all.N(    (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   function_noArgs†   s    c         C   s   |  | | f S(   s+   A function which accepts several arguments.(    (   R   t   bt   c(    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   function_simpleŠ   s    c          O   s
   |  | f S(   s@   A function which accepts a variable number of args and keywords.(    (   R   t   kw(    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   function_variableŽ   s    i   c         K   s   |  \ } } | | | | | f S(   s&   A function with a mad crazy signature.(    (   t   .0RA   t   dRC   t   alphat   beta(    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   function_crazy’   s    	t   TestBrowseFunctionc           B   s>   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s   t  j |  _ |  j j ƒ  d  S(   N(   R   R   R   R   (   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyR   ˜   s    c         C   s{   xt d D]l } t  | ƒ } |  j j | | ƒ } |  j | j t | ƒ ƒ |  j t | t j ƒ ƒ |  j | j	 | ƒ q Wd S(   sv   Basic checks for browse_function.

        Was the proper type returned?  Does it have the right name and ID?
        R?   RB   RD   RI   N(   s   function_noArgss   function_simples   function_variables   function_crazy(
   t   evalR   R   R   R   R8   t
   isinstanceR   t   ExplorerFunctiont   name(   R   t   f_namet   fR   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   test_sanityœ   s    
c         C   s2   |  j  j t d ƒ } |  j t | j ƒ d ƒ d S(   s2   Testing zero-argument function signature.
        R?   i    N(   R   R   R?   R   R   t	   signature(   R   R   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   test_signature_noArgs­   s    c         C   s5   |  j  j t d ƒ } d } |  j | j j | ƒ d S(   s+   Testing simple function signature.
        RB   R   R@   RA   N(   R   R@   RA   (   R   R   RB   R   RR   RN   (   R   R   t   expected_signature(    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   test_signature_simpleµ   s    c         C   sg   |  j  j t d ƒ } d } | j } |  j | j | ƒ |  j | j d ƒ ƒ |  j | j d ƒ ƒ d S(   s6   Testing variable-argument function signature.
        RD   R   RC   i    i   N(   R   s   kw(	   R   R   RD   RR   R   RN   R8   t
   is_varlistt
   is_keyword(   R   R   t   expected_namesRR   (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   test_signature_variable¿   s    		c         C   s'  |  j  j t d ƒ } | j } i d d 6i d d 6t d ƒ d 6i d d 6d d	 6g } |  j | j d
 ƒ ƒ |  j | j d
 ƒ d
 ƒ |  j | j d ƒ d ƒ t	 d „  | j d ƒ d j
 ƒ  ƒ } |  j | j d ƒ d ƒ |  j | t d ƒ ƒ |  j | j d ƒ d ƒ |  j | j d ƒ ƒ d S(   s/   Testing function with crazy signature.
        RI   RA   RN   RF   i   t   defaultRC   i   t   keywordsi    c         S   s   |  j  S(   N(   t   value(   t   l(    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   <lambda>â   s    i   i   N(   R   R   RI   RR   t   rangeR8   t   get_namet   get_defaultR   t   mapR   RW   (   R   R   RR   RT   t   arg_2_default(    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   test_signature_crazyÍ   s     	


	(   R	   R
   R   RQ   RS   RU   RY   Rd   (    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyRJ   –   s   				
	t   __main__(    (    (    (    (   t   __doc__t   twisted.trialR    t   twisted.manholeR   t   typesR&   R   t   TestCaseR   R   R!   R+   R,   R?   RB   RD   R_   RI   RJ   R	   t   main(    (    (    s>   /usr/lib/python2.7/dist-packages/twisted/test/test_explorer.pyt   <module>   s    6			U