ó
ÔËÞKc           @   s-  d  Z  d d l Z d d l m Z m Z m Z d d l m Z m Z d d l m Z d d l	 Z	 d „  Z
 y' d d l m Z d d d	 „  ƒ  YZ Wn e k
 r£ n Xd
 d d „  ƒ  YZ e e	 j ƒ  ƒ Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ e e f Z d „  Z e d k r)e j d d ƒ n  d S(   s®  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.

$Id: test_advice.py 110736 2010-04-11 10:59:30Z regebro $
iÿÿÿÿN(   t   TestCaset	   makeSuitet	   TestSuite(   t   addClassAdvisort   determineMetaclass(   t   getFrameInfoc            s    ‡ ‡  f d †  } t  | ƒ d  S(   Nc            s   ˆ j  ˆ  |  f ƒ |  g S(   N(   t   append(   t   klass(   t   valuet   log(    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   pong'   s    (   R   (   R	   R   R
   (    (   R	   R   sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   ping%   s    (   t	   ClassTypet   ClassicClassc           B   s    e  Z e Z e e j ƒ  ƒ Z RS(    (   t   __name__t
   __module__R   t   __metaclass__R   t   syst	   _getframet   classLevelFrameInfo(    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR   0   s   t   NewStyleClassc           B   s    e  Z e Z e e j ƒ  ƒ Z RS(    (   R   R   t   typeR   R   R   R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR   6   s   t   FrameInfoTestc           B   s>   e  Z e e j ƒ  ƒ Z d  „  Z d „  Z d „  Z d „  Z	 RS(   c         C   sY   t  \ } } } } |  j | d ƒ x0 | j | | f D] } |  j | t ƒ  k ƒ q5 Wd  S(   Nt   module(   t   moduleLevelFrameInfot   assertEqualst   __dict__t   assert_t   globals(   t   selft   kindR   t   f_localst	   f_globalst   d(    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   checkModuleInfo@   s    c         C   so   t  j \ } } } } |  j | d ƒ |  j | t  j k ƒ x- | j | f D] } |  j | t ƒ  k ƒ qK Wd  S(   Nt   class(   R   R   R   R   R   R   (   R   R   R   R   R    R!   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   checkClassicClassInfoF   s
    c         C   sY   t  j \ } } } } |  j | d ƒ x- | j | f D] } |  j | t ƒ  k ƒ q5 Wd  S(   NR#   (   R   R   R   R   R   R   (   R   R   R   R   R    R!   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   checkNewStyleClassInfoN   s    c         C   sx   t  t j ƒ  ƒ \ } } } } |  j | d ƒ |  j | t ƒ  k ƒ x- | j | f D] } |  j | t ƒ  k ƒ qT Wd  S(   Ns   function call(   R   R   R   R   R   t   localsR   R   (   R   R   R   R   R    R!   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   checkCallInfoU   s
    (
   R   R   R   R   R   R   R"   R$   R%   R'   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR   <   s
   			t   AdviceTestsc           B   s>   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c            sŠ   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(   Nt   Fooc              s/   e  Z e ˆ  d  ƒ e ˆ  d ƒ e ˆ  d ƒ RS(   i   i   i   (   R   R   R   (    (   R	   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR)   a   s   i   i   i   (   i   i   i   (   t   objectR   t
   isinstancet   listR   (   R   R)   t   i(    (   R	   sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt
   checkOrder_   s    c         C   s5   y t  g  d ƒ Wn t k
 r$ n Xt d ƒ ‚ d  S(   Ni   s.   Should have detected advice outside class body(   R   t   SyntaxErrort   AssertionError(   R   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   TODOcheckOutsidem   s    c         C   sO   t  j d k r d  Sd t t f d „  ƒ  Y} | \ } |  j | j t k ƒ d  S(   Ni  t   aTypec           B   s   e  Z e g  d  ƒ RS(   i   (   R   R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR2   {   s   (   R   t
   hexversionR   R   t	   __class__(   R   R2   (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   checkDoubleTypex   s
    	c            sU   d t  f d „  ƒ  Y‰  d ˆ  f ‡  f d †  ƒ  Y} | \ } |  j | j ˆ  k ƒ d  S(   Nt   Mc           B   s   e  Z RS(    (   R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR6   ‚   s   t   Cc              s   e  Z ˆ  Z e g  d  ƒ RS(   i   (   R   R   R   R   (    (   R6   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR7   …   s   (   R   R   R4   (   R   R7   (    (   R6   sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   checkSingleExplicitMeta€   s    	c            s  d t  f d „  ƒ  Y‰ d t  f d „  ƒ  Y‰ d d ‡ f d †  ƒ  Y} d d ‡ f d †  ƒ  Y} y d	 | | 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(   Nt   M1c           B   s   e  Z RS(    (   R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR9      s    t   M2c           B   s   e  Z RS(    (   R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR:      s    t   B1c              s   e  Z ˆ  Z RS(    (   R   R   R   (    (   R9   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR;   ’   s    t   B2c              s   e  Z ˆ  Z RS(    (   R   R   R   (    (   R:   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR<   “   s    R7   c           B   s   e  Z e g  d  ƒ RS(   i   (   R   R   R   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR7   –   s   s(   Should have gotten incompatibility errort   M3c           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 e g  d  ƒ RS(   i   (   R   R   R   R   (    (   R=   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR7   Ÿ   s   (    (    (   R   t	   TypeErrorR0   R   R+   R,   (   R   R;   R<   R7   (    (   R=   R9   R:   sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   checkMixedMetas   s    	c            sR   d t  f d „  ƒ  Y‰  d t  f ‡  f d †  ƒ  Y} |  j t | 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.pyR@   ©   s   t   metac              s   e  Z ˆ  Z RS(    (   R   R   R   (    (   R@   (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyRA   ¬   s   (   R   R   R   (   R   RA   (    (   R@   sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   checkMetaOfClass§   s    (   R   R   R.   R1   R5   R8   R?   RB   (    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyR(   ]   s   					c          C   sA   t  j d d k r9 t g  t D] }  t |  d ƒ ^ q ƒ Sg  Sd  S(   Ni    t   2t   check(   R   t   versionR   t   TestClassesR   (   t   t(    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt
   test_suite³   s    &t   __main__t   defaultTestRH   (    (    (   t   __doc__t   unittestR    R   R   t   zope.interface.adviceR   R   R   R   R   t   typesR   R   t   ImportErrorR   R   R   R   R(   RF   RH   R   t   main(    (    (    sD   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_advice.pyt   <module>   s&   	!T	