;
Λβ"Ic               @   s½   d  d l  Z  d  d l m Z d   Z Gd   d e  Z Gd   d e  Z d d d  Z	 d	   Z
 d
   Z Gd   d e  j  Z Gd   d e  j  Z d   Z e d k o e   n d S(   i    N(   u   supportc                 s     f d   } | S(   Nc                s   |  j  j    |  S(   N(   u   __dict__u   update(   u   func(   u   kwds(    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   decorate   s    (    (   u   kwdsu   decorate(    (   u   kwdsu1   /mit/python/lib/python3.0/test/test_decorators.pyu	   funcattrs   s    c             B   s   |  Ee  Z e d     Z d S(   c                s     f d   } | S(   Nc                s     |  j  d <|  S(   Nu   author(   u   __dict__(   u   func(   u   name(    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   decorate   s    (    (   u   nameu   decorate(    (   u   nameu1   /mit/python/lib/python3.0/test/test_decorators.pyu   author   s    N(   u   __name__u
   __module__u   staticmethodu   author(   u
   __locals__(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   MiscDecorators
   s   
u   MiscDecoratorsc             B   s   |  Ee  Z d    Z d S(   c             C   s$   t  j |  d | | | | f  d  S(   Nu+   dbcheck %r failed (func=%s args=%s kwds=%s)(   u	   Exceptionu   __init__(   u   selfu   exprstru   funcu   argsu   kwds(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   __init__   s    N(   u   __name__u
   __module__u   __init__(   u
   __locals__(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   DbcheckError   s   
u   DbcheckErrorc                s       f d   } | S(   u+   Decorator to implement debugging assertionsc                s8   t   d  j d          f d   } | S(   Nu
   dbcheck-%su   evalc                 s9   t      p t    |  |   n   |  |   S(   N(   u   evalu   DbcheckError(   u   argsu   kwds(   u   funcu   expru   exprstru   globalsu   locals(    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   check   s    (   u   compileu   __name__(   u   funcu   check(   u   exprstru   globalsu   locals(   u   expru   funcu1   /mit/python/lib/python3.0/test/test_decorators.pyu   decorate   s    (    (   u   exprstru   globalsu   localsu   decorate(    (   u   globalsu   exprstru   localsu1   /mit/python/lib/python3.0/test/test_decorators.pyu   dbcheck   s    c                s     f d   } | S(   u&   Decorator to count calls to a functionc                s5    j    d    <    f d   }   | _  | S(   Ni    c                 s      c d 7< |  |   S(   Ni   (    (   u   argsu   kwds(   u	   func_nameu   countsu   func(    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   call-   s    (   u   __name__(   u   funcu   call(   u   counts(   u	   func_nameu   funcu1   /mit/python/lib/python3.0/test/test_decorators.pyu   decorate*   s
    	
	(    (   u   countsu   decorate(    (   u   countsu1   /mit/python/lib/python3.0/test/test_decorators.pyu
   countcalls(   s    c                s(   i       f d   }  j  | _  | S(   Nc                 s^   y  |  SWnK t  k
 o"   |    } |  |  <| SYn t k
 o   |    SYn Xd  S(   N(   u   KeyErroru	   TypeError(   u   argsu   res(   u   funcu   saved(    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   call8   s    
	(   u   __name__(   u   funcu   call(    (   u   savedu   funcu1   /mit/python/lib/python3.0/test/test_decorators.pyu   memoize6   s    
c             B   sh   |  Ee  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
 S(   c             C   sF   Gd   d t   } |  j | j   d  |  j |   j   d  d  S(   Nc             B   s   |  Ee  Z e d     Z d S(   c               S   s   d S(   Ni*   (    (    (    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   fooK   s    N(   u   __name__u
   __module__u   staticmethodu   foo(   u
   __locals__(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   CJ   s   
u   Ci*   (   u   objectu   assertEqualu   foo(   u   selfu   C(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   test_singleI   s    c             C   s&   t  d    } |  j t | d  d  S(   Nc             S   s   |  S(   N(    (   u   x(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu
   notamethodQ   s    i   (   u   staticmethodu   assertRaisesu	   TypeError(   u   selfu
   notamethod(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   test_staticmethod_functionP   s    c             C   sK   t    } | j d  d    } |  j |   d  |  j | j d  d  S(   Nu   Cleesec               S   s   d S(   Ni*   (    (    (    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   fooX   s    i*   (   u   MiscDecoratorsu   authoru   assertEqual(   u   selfu
   decoratorsu   foo(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   test_dottedV   s    	c             C   sό   d   } d } t  d d d d	  } | | |   d
    } |  j |   d  |  j | j | | f  | d d d d d d d    } |  j |   d  |  j | j d t  d d d d  f  | d d	  d    } |  j | j d i  f  d  S(   Nc                 s      f d   } | S(   Nc                s   t  |  d    f  |  S(   Nu   dbval(   u   setattr(   u   func(   u   argsu   kwds(    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   decorateb   s    (    (   u   argsu   kwdsu   decorate(    (   u   argsu   kwdsu1   /mit/python/lib/python3.0/test/test_decorators.pyu   noteargsa   s    u   Nowu   isu   theu   timeu   onei   u   twoi   c               S   s   d S(   Ni*   (    (    (    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   f1i   s    i*   u   terryu   gilliamu   ericu   idleu   johnu   cleesec               S   s   d S(   NiT   (    (    (    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   f2n   s    iT   c               S   s   d  S(   N(    (    (    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   f3t   s    (   u   Nowu   isu   theu   time(   u   terryu   gilliam(   i   i   (   u   dictu   assertEqualu   dbval(   u   selfu   noteargsu   argsu   kwdsu   f1u   f2u   f3(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   test_argforms]   s    	$c             C   sH   t  d  d    } |  j | d d  d  |  j t | d d   d  S(   Nu   args[1] is not Nonec             S   s   |  | S(   N(    (   u   au   b(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   fy   s    i   i   i   (   u   dbchecku   assertEqualu   assertRaisesu   DbcheckErroru   None(   u   selfu   f(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   test_dbcheckx   s    c             C   s5  i  } t  t |  d     } |  j | j d  |  j | t d d   |  j | d  d  |  j | d d  |  j | d  d  |  j | d d  |  j | d  d  |  j | d d  |  j | d	 g  d	 d	 g  |  j | d d  |  j | d	 g  d	 d	 g  |  j | d d  d  S(
   Nc             S   s   |  d S(   Ni   (    (   u   x(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   double   s    u   doublei    i   i   i   i   i   i
   (   u   memoizeu
   countcallsu   assertEqualu   __name__u   dict(   u   selfu   countsu   double(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   test_memoize   s    c             C   sυ   xJ d d d g D]9 } t  | d d  d | } |  j t t  | d d  q W|  j t t  d d d  d	   } t d
 d  d |  } xj d t f d
 t f d t f d t f g D]> \ } } d | } t  | d d  } |  j | t	 | |  q― Wd  S(   Nu   1+2u   x[3]u   (1, 2)u   testexpru   execu   @%s
def f(): passu   testu   @f1 @f2
def f(): passc             S   s
   t   d  S(   N(   u   NotImplementedError(   u   func(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   unimp«   s    u   nullvalu   unimpu   undefu   nullval.attru$   @%s
def f(): pass
assert f() is None(
   u   compileu   assertRaisesu   SyntaxErroru   dictu   Noneu	   NameErroru	   TypeErroru   AttributeErroru   NotImplementedErroru   eval(   u   selfu   expru   codestru   unimpu   contextu   excu   code(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   test_errors   s"     
			 
c             C   sr   Gd   d t   } |  j |   j   d  |  j | j j d  |  j | j j d  |  j | j j d  d  S(   Nc             B   s;   |  Ee  Z e d  d d d  e d d  d     Z d S(   u   abci   u   xyzu   hahau   boohi*   c             S   s   d S(   Ni*   (    (   u   self(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   fooΉ   s    N(   u   __name__u
   __module__u	   funcattrsu   foo(   u
   __locals__(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   CΈ   s   
u   Ci*   i   u   haha(   u   objectu   assertEqualu   foou   abcu   xyzu   booh(   u   selfu   C(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   test_double·   s
    c             C   sD   d   } | d  | d  d     } |  j  |   d d  d  S(   Nc                s     f d   } | S(   u   Decorator factory that returns a decorator that replaces the
            passed-in function with one that returns the value of 'num'c                s     f d   S(   Nc                  s     S(    (    (    (   u   num(    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   <lambda>Θ   s    (    (   u   func(   u   num(    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   decoΗ   s    (    (   u   numu   deco(    (   u   numu1   /mit/python/lib/python3.0/test/test_decorators.pyu   callnumΔ   s    i   i   c               S   s   d S(   Ni*   (    (    (    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   fooΚ   s    u,   Application order of decorators is incorrect(   u   assertEqual(   u   selfu   callnumu   foo(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu
   test_orderΑ   s
    		c                sV  g      f d    G   f d   d t   } t | d d d g  \ } } } d d d	 d
 d d d d d d d d g } g    | j | j  | j | j  | j | j  d      } |  j |   d  |  j   |  g    d   } | j | j  | j | j  | j | j  |    } |  j |   d  |  j   |  d  S(   Nc                s'    j  d       f d   } | S(   Nu   makedecc                s    j  d    |  S(   Nu   calldec(   u   append(   u   func(   u   tagu   actions(    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   decorateβ   s    (   u   append(   u   tagu   decorate(   u   actions(   u   tagu1   /mit/python/lib/python3.0/test/test_decorators.pyu   make_decoratorΰ   s    c                s)   |  Ee  Z d    Z    f d   Z d S(   c             S   s   | |  _  d  S(   N(   u   index(   u   selfu   index(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   __init__θ   s    c                s{   | d k o d  } } n@ | d k o d t  |  j  } } n d p t d |     j d | |  j f  | S(   Nu   make_decoratoru   evalnameu   argu   evalargsu   Unknown attrname %su   %s%dF(   u   stru   indexu   Falseu   AssertionErroru   append(   u   selfu   fnameu   opnameu   res(   u   actionsu   make_decorator(    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   __getattr__λ   s    N(   u   __name__u
   __module__u   __init__u   __getattr__(   u
   __locals__(   u   actionsu   make_decorator(    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   NameLookupTracerη   s   
	u   NameLookupTraceri   i   i   u	   evalname1u	   evalargs1u   makedec1u	   evalname2u	   evalargs2u   makedec2u	   evalname3u	   evalargs3u   makedec3u   calldec3u   calldec2u   calldec1c               S   s   d S(   Ni*   (    (    (    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   fooύ   s    i*   c               S   s   d S(   Ni*   (    (    (    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   bar  s    (   u   objectu   mapu   make_decoratoru   argu   assertEqual(   u   selfu   NameLookupTraceru   c1u   c2u   c3u   expected_actionsu   foou   bar(    (   u   actionsu   make_decoratoru1   /mit/python/lib/python3.0/test/test_decorators.pyu   test_eval_orderΠ   s&    !			!	<N(   u   __name__u
   __module__u   test_singleu   test_staticmethod_functionu   test_dottedu   test_argformsu   test_dbchecku   test_memoizeu   test_errorsu   test_doubleu
   test_orderu   test_eval_order(   u
   __locals__(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   TestDecoratorsG   s   
								
	u   TestDecoratorsc             B   s)   |  Ee  Z d    Z d   Z d   Z d S(   c             C   s9   d   } | Gd   d t    } |  j | j d  d  S(   Nc             S   s   d |  _  |  S(   Nu   Hello(   u   extra(   u   x(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   plain  s    	c             B   s   |  Ee  Z d  S(   N(   u   __name__u
   __module__(   u
   __locals__(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   C  s   
u   Cu   Hello(   u   objectu   assertEqualu   extra(   u   selfu   plainu   C(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   test_simple  s    	c             C   sH   d   } d   } | | Gd   d t     } |  j | j d  d  S(   Nc             S   s   d |  _  |  S(   Ni
   (   u   extra(   u   x(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   ten  s    	c             S   s   |  j  d 7_  |  S(   Ni   (   u   extra(   u   x(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   add_five  s    c             B   s   |  Ee  Z d  S(   N(   u   __name__u
   __module__(   u
   __locals__(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   C  s   
u   Ci   (   u   objectu   assertEqualu   extra(   u   selfu   tenu   add_fiveu   C(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   test_double  s    		c             C   sH   d   } d   } | | Gd   d t     } |  j | j d  d  S(   Nc             S   s   d |  _  |  S(   Nu   first(   u   extra(   u   x(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   applied_first%  s    	c             S   s   d |  _  |  S(   Nu   second(   u   extra(   u   x(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   applied_second(  s    	c             B   s   |  Ee  Z d  S(   N(   u   __name__u
   __module__(   u
   __locals__(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   C+  s   
u   Cu   second(   u   objectu   assertEqualu   extra(   u   selfu   applied_firstu   applied_secondu   C(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu
   test_order$  s    		N(   u   __name__u
   __module__u   test_simpleu   test_doubleu
   test_order(   u
   __locals__(    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   TestClassDecorators  s   
		u   TestClassDecoratorsc               C   s   t  j t  t  j t  d  S(   N(   u   supportu   run_unittestu   TestDecoratorsu   TestClassDecorators(    (    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu	   test_main0  s    u   __main__(   u   unittestu   testu   supportu	   funcattrsu   objectu   MiscDecoratorsu	   Exceptionu   DbcheckErroru   Noneu   dbchecku
   countcallsu   memoizeu   TestCaseu   TestDecoratorsu   TestClassDecoratorsu	   test_mainu   __name__(    (    (    u1   /mit/python/lib/python3.0/test/test_decorators.pyu   <module>   s   	
		Ζ#	