ó
2(Vc           @   sÎ   d  Z  d d l Z d d l Z d d l m Z d d l m Z d e j f d „  ƒ  YZ d Z d e j f d	 „  ƒ  YZ	 d
 e j f d „  ƒ  YZ
 d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d „  Z d S(   ss  Tests for advice

This module was adapted from 'protocols.tests.advice', part of the Python
Enterprise Application Kit (PEAK).  Please notify the PEAK authors
(pje@telecommunity.com and tsarna@sarna.org) if bugs are found or
Zope-specific changes are required, so that the PEAK version of this module
can be kept in sync.

PEAK is a Python application framework that interoperates with (but does
not require) Zope 3 and Twisted.  It provides tools for manipulating UML
models, object-relational persistence, aspect-oriented programming, and more.
Visit the PEAK home page at http://peak.telecommunity.com for more information.
iÿÿÿÿN(   t   _skip_under_py2(   t   _skip_under_py3kt   FrameInfoTestc           B   s;   e  Z d  „  Z e d „  ƒ Z d „  Z d „  Z d „  Z RS(   c         C   sl   d d l  m } | j \ } } } } |  j | d ƒ x0 | j | | f D] } |  j | | j k ƒ qH Wd  S(   Niÿÿÿÿ(   t   advisory_testingt   module(   t   zope.interface.testsR   t   moduleLevelFrameInfot   assertEqualt   __dict__t
   assertTruet
   my_globals(   t   selfR   t   kindR   t   f_localst	   f_globalst   d(    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_w_module%   s
    c         C   s˜   d d l  m } | j d  k r# d  S| j j \ } } } } |  j | d ƒ |  j | | j j k ƒ x- | j | f D] } |  j | | j k ƒ qt Wd  S(   Niÿÿÿÿ(   R   t   class(	   R   R   t   ClassicClasst   Nonet   classLevelFrameInfoR   R	   R   R
   (   R   R   R   R   R   R   R   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_w_ClassicClass-   s    c         C   sl   d d l  m } | j j \ } } } } |  j | d ƒ x- | j | f D] } |  j | | j k ƒ qH Wd  S(   Niÿÿÿÿ(   R   R   (   R   R   t   NewStyleClassR   R   R   R	   R
   (   R   R   R   R   R   R   R   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_w_NewStyleClass=   s
    c         C   sˆ   d d l  m } | t j ƒ  ƒ \ } } } } |  j | d ƒ |  j | t ƒ  k ƒ x- | j | f D] } |  j | t ƒ  k ƒ qd Wd  S(   Niÿÿÿÿ(   t   getFrameInfos   function call(	   t   zope.interface.adviceR   t   syst	   _getframeR   R	   t   localsR   t   globals(   R   R   R   R   R   R   R   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_inside_function_callH   s    c         B   sŠ   d d l  m } i | d 6} i  } e | | U|  j | d d ƒ |  j | d | k ƒ |  j | d d  k ƒ |  j | d | k ƒ d  S(	   Niÿÿÿÿ(   R   R   R   t   execR   R   R   (   R   R   t   _FUNKY_EXECR   R	   R   (   R   R   t   _globalst   _locals(    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_inside_execP   s    
(   t   __name__t
   __module__R   R   R   R   R   R#   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR   #   s
   			sM   import sys
kind, module, f_locals, f_globals = getFrameInfo(sys._getframe())
t   AdviceTestsc           B   sM   e  Z e d  „  ƒ Z d „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z RS(   c            s   d d l  m ‰ g  ‰  d t f ‡  ‡ f d †  ƒ  Y} x- d D]% } |  j t | t ƒ ƒ | \ } q< W|  j ˆ  d | f d | g f d | g g f g ƒ d  S(	   Niÿÿÿÿ(   t   pingt   Fooc              s/   e  Z ˆ ˆ  d  ƒ ˆ ˆ  d ƒ ˆ ˆ  d ƒ RS(   i   i   i   (   R$   R%   (    (   t   logR'   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR(   f   s   i   i   i   (   i   i   i   (   t%   zope.interface.tests.advisory_testingR'   t   objectR	   t
   isinstancet   listR   (   R   R(   t   i(    (   R)   R'   sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt
   test_orderb   s    c         C   sE   d d l  m } y | g  d ƒ Wn t k
 r4 n Xt d ƒ ‚ d  S(   Niÿÿÿÿ(   R'   i   s.   Should have detected advice outside class body(   R*   R'   t   SyntaxErrort   AssertionError(   R   R'   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   TODOtest_outsider   s    c            sh   d d l  m ‰ d t f d „  ƒ  Y‰  d ˆ  f ‡  ‡ f d †  ƒ  Y} | \ } |  j | j ˆ  k ƒ d  S(   Niÿÿÿÿ(   R'   t	   Metaclassc           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR3   ‚   s   t   Concretec              s   e  Z ˆ  Z ˆ g  d  ƒ RS(   i   (   R$   R%   t   __metaclass__(    (   R3   R'   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR4   …   s   (   R*   R'   t   typeR	   t	   __class__(   R   R4   (    (   R3   R'   sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_single_explicit_meta~   s
    	c            s%  d d l  m ‰ d t f d „  ƒ  Y‰  d t f d „  ƒ  Y‰ d d ‡  f d †  ƒ  Y} d	 d ‡ f d
 †  ƒ  Y} y# d | | f ‡ f d †  ƒ  Y} Wn t k
 r¤ n Xt d ƒ ‚ d ˆ  ˆ f d „  ƒ  Y‰ d | | f ‡ ‡ f d †  ƒ  Y} |  j t | t ƒ ƒ | \ } |  j t | ˆ ƒ ƒ d  S(   Niÿÿÿÿ(   R'   t
   Metaclass1c           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR9   ‘   s   t
   Metaclass2c           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR:   ”   s   t   Base1c              s   e  Z ˆ  Z RS(    (   R$   R%   R5   (    (   R9   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR;   —   s   t   Base2c              s   e  Z ˆ  Z RS(    (   R$   R%   R5   (    (   R:   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR<   š   s   t   Derivedc              s   e  Z ˆ  g  d  ƒ RS(   i   (   R$   R%   (    (   R'   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR=   ž   s   s(   Should have gotten incompatibility errort
   Metaclass3c           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR>   ¦   s   c              s   e  Z ˆ  Z ˆ g  d  ƒ RS(   i   (   R$   R%   R5   (    (   R>   R'   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR=   ©   s   (    (    (   R*   R'   R6   t	   TypeErrorR1   R	   R,   R-   (   R   R;   R<   R=   (    (   R9   R:   R>   R'   sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_mixed_metas   s    #"	c            su   d d l  m ‰  y d d l m } Wn t k
 r8 d  SXd d ‡  f d †  ƒ  Y} | \ } |  j t | ƒ | ƒ d  S(   Niÿÿÿÿ(   R'   (   t	   ClassTypet   Thingc              s   e  Z ˆ  g  d  ƒ RS(   i   (   R$   R%   (    (   R'   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRB   ¸   s   (    (   R*   R'   t   typesRA   t   ImportErrorR   R6   (   R   RA   RB   t   klass(    (   R'   sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_meta_no_bases±   s    	(   R$   R%   R   R/   R2   R8   R@   RF   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR&   `   s
   	$t   Test_isClassAdvisorc           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         O   s   d d l  m } | | | Ž  S(   Niÿÿÿÿ(   t   isClassAdvisor(   R   RH   (   R   t   argst   kwRH   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   _callFUTÀ   s    c         C   s   |  j  |  j |  ƒ t ƒ d  S(   N(   R   RK   t   False(   R   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_w_non_functionÄ   s    c         C   s&   d „  } |  j  |  j | ƒ t ƒ d  S(   Nc           S   s   d  S(   N(    (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   fooÈ   s    (   R   RK   RL   (   R   RN   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_w_normal_functionÇ   s    	c         C   s2   d „  } t  ƒ  | _ |  j |  j | ƒ t ƒ d  S(   Nc           S   s   d  S(   N(    (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   barÍ   s    (   R+   t   previousMetaclassR   RK   t   True(   R   RP   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_w_advisor_functionÌ   s    	(   R$   R%   RK   RM   RO   RS   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRG   ¾   s   			t   Test_determineMetaclassc           B   sŒ   e  Z d  „  Z e d „  ƒ Z d „  Z d „  Z e d „  ƒ Z e d „  ƒ Z	 e d „  ƒ Z
 e d „  ƒ Z e d „  ƒ Z e d	 „  ƒ Z RS(
   c         O   s   d d l  m } | | | Ž  S(   Niÿÿÿÿ(   t   determineMetaclass(   R   RU   (   R   RI   RJ   RU   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRK   Õ   s    c         C   s-   d d l  m } |  j |  j d ƒ | ƒ d  S(   Niÿÿÿÿ(   RA   (    (   RC   RA   R   RK   (   R   RA   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt
   test_emptyÙ   s    c         C   s6   d t  f d „  ƒ  Y} |  j |  j d | ƒ | ƒ d  S(   Nt   Metac           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRW   ß   s   (    (   R6   R   RK   (   R   RW   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_empty_w_explicit_metatypeÞ   s    c         C   s6   d t  f d „  ƒ  Y} |  j |  j | f ƒ t  ƒ d  S(   NRW   c           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRW   ä   s   (   R6   R   RK   (   R   RW   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_singleã   s    c            sU   d t  f d „  ƒ  Y‰  d t  f ‡  f d †  ƒ  Y} |  j |  j | t  f ƒ ˆ  ƒ d  S(   Nt   Metametac           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRZ   ê   s   RW   c              s   e  Z ˆ  Z RS(    (   R$   R%   R5   (    (   RZ   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRW   í   s   (   R6   R   RK   (   R   RW   (    (   RZ   sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_meta_of_classè   s    c         B   s`   d j  d d d d g ƒ } i  } | | U| d } | d } |  j |  j | e f ƒ | ƒ d  S(   Ns   
s   class Metameta(type):s       passs%   class Meta(type, metaclass=Metameta):RW   RZ   (   t   joinR   RK   R6   (   R   t   EXECt   globsRW   RZ   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_meta_of_class_py3kò   s    

c            s‡   d t  f d „  ƒ  Y‰  d ˆ  f d „  ƒ  Y‰ d t  f ‡  f d †  ƒ  Y} d t  f ‡ f d †  ƒ  Y} |  j |  j | | f ƒ ˆ ƒ d  S(	   Nt   Meta_Ac           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR`     s   t   Meta_Bc           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRa     s   t   Ac              s   e  Z ˆ  Z RS(    (   R$   R%   R5   (    (   R`   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRb     s   t   Bc              s   e  Z ˆ  Z RS(    (   R$   R%   R5   (    (   Ra   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRc   
  s   (   R6   R   RK   (   R   Rb   Rc   (    (   R`   Ra   sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_multiple_in_hierarchy  s
    c      	   B   s€   d j  d d d d d d d d g ƒ } i  } | | U| d } | d } | d	 } | d
 } |  j |  j | | f ƒ | ƒ d  S(   Ns   
s   class Meta_A(type):s       passs   class Meta_B(Meta_A):s    class A(type, metaclass=Meta_A):s    class B(type, metaclass=Meta_B):R`   Ra   Rb   Rc   (   R\   R   RK   (   R   R]   R^   R`   Ra   Rb   Rc   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_multiple_in_hierarchy_py3k  s     



c            s„   d t  f d „  ƒ  Y‰  d t  f d „  ƒ  Y‰ d t  f ‡  f d †  ƒ  Y} d t  f ‡ f d †  ƒ  Y} |  j t |  j | | f ƒ d  S(	   NR`   c           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR`   %  s   Ra   c           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRa   '  s   Rb   c              s   e  Z ˆ  Z RS(    (   R$   R%   R5   (    (   R`   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRb   )  s   Rc   c              s   e  Z ˆ  Z RS(    (   R$   R%   R5   (    (   Ra   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRc   +  s   (   R6   t   assertRaisesR?   RK   (   R   Rb   Rc   (    (   R`   Ra   sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_multiple_not_in_hierarchy#  s
    c      	   B   s}   d j  d d d d d d d d g ƒ } i  } | | U| d } | d } | d	 } | d
 } |  j e |  j | | f ƒ d  S(   Ns   
s   class Meta_A(type):s       passs   class Meta_B(type):s    class A(type, metaclass=Meta_A):s    class B(type, metaclass=Meta_B):R`   Ra   Rb   Rc   (   R\   Rf   R?   RK   (   R   R]   R^   R`   Ra   Rb   Rc   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt#   test_multiple_not_in_hierarchy_py3k/  s     



(   R$   R%   RK   R   RV   RX   RY   R[   R    R_   Rd   Re   Rg   Rh   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRT   Ó   s   			
t   Test_minimalBasesc           B   s\   e  Z d  „  Z d „  Z e d „  ƒ Z e d „  ƒ Z d „  Z d „  Z d „  Z	 d „  Z
 RS(   c         C   s   d d l  m } | | ƒ S(   Niÿÿÿÿ(   t   minimalBases(   R   Rj   (   R   t   klassesRj   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRK   G  s    c         C   s   |  j  |  j g  ƒ g  ƒ d  S(   N(   R   RK   (   R   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRV   K  s    c         C   s9   d d d „  ƒ  Y} |  j  |  j t | ƒ g ƒ g  ƒ d  S(   Nt   Cc           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRl   P  s   (    (   R   RK   R6   (   R   Rl   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_w_oldstyle_metaN  s    c         C   s6   d d d „  ƒ  Y} |  j  |  j | g ƒ | g ƒ d  S(   NRl   c           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRl   V  s   (    (   R   RK   (   R   Rl   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_w_oldstyle_classT  s    c         C   s#   |  j  |  j t g ƒ t g ƒ d  S(   N(   R   RK   R6   (   R   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_w_newstyle_metaZ  s    c         C   s9   d t  f d „  ƒ  Y} |  j |  j | g ƒ | g ƒ d  S(   NRl   c           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRl   ^  s   (   R+   R   RK   (   R   Rl   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   test_w_newstyle_class]  s    c         C   s  d t  f d „  ƒ  Y} d | f d „  ƒ  Y} d | f d „  ƒ  Y} d t  f d „  ƒ  Y} |  j |  j | | | g ƒ | g ƒ |  j |  j | | g ƒ | g ƒ |  j |  j | | g ƒ | g ƒ |  j |  j | | g ƒ | g ƒ |  j |  j | | | g ƒ | | g ƒ d  S(	   NRb   c           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRb   c  s   Rc   c           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRc   e  s   Rl   c           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRl   g  s   t   Dc           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRq   i  s   (   R+   R   RK   (   R   Rb   Rc   Rl   Rq   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt#   test_simple_hierarchy_skips_impliedb  s    %"""c         C   sX   d t  f d „  ƒ  Y} d t  f d „  ƒ  Y} |  j |  j | | | g ƒ | | g ƒ d  S(   NRb   c           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRb   r  s   Rc   c           B   s   e  Z RS(    (   R$   R%   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRc   t  s   (   R+   R   RK   (   R   Rb   Rc   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt#   test_repeats_kicked_to_end_of_queueq  s    (   R$   R%   RK   RV   R   Rm   Rn   Ro   Rp   Rr   Rs   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRi   E  s   					c           C   sI   t  j t  j t ƒ t  j t ƒ t  j t ƒ t  j t ƒ t  j t ƒ f ƒ S(   N(   t   unittestt	   TestSuitet	   makeSuiteR   R&   RG   RT   Ri   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt
   test_suitez  s    (   t   __doc__Rt   R   t   zope.interface._compatR    R   t   TestCaseR   R    R&   RG   RT   Ri   Rw   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   <module>   s   ;^r5