ó
ÔËŢKc           @   sz   d  Z  d d l Z d d l Z d d l Z d e j f d     YZ e j d d f k rd d   Z n  d   Z d	   Z	 d S(
   s   Test Interface implementation
i˙˙˙˙Nt   InterfaceTestsc           B   sł   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   c            s   d d l  m } d d l  m   d | f   f d     Y} d | f d     Y} d | f d	     Y} d
 | f d     Y} | S(   Ni˙˙˙˙(   t	   Interface(   t	   Attributet   _I1c              s/   e  Z   d   Z d   Z d   Z d e _ RS(   s   This is an attributec           S   s   d  S(   N(    (    (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   f11   s    c           S   s   d  S(   N(    (    (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   f12   s    i   (   t   __name__t
   __module__t   a1R   R   t   optional(    (   R   (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyR      s   		t   _I1_c           B   s   e  Z RS(    (   R   R   (    (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyR
   #   s   t   _I1__c           B   s   e  Z RS(    (   R   R   (    (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyR   &   s   t   _I2c           B   s    e  Z d    Z d   Z e Z RS(   c           S   s   d  S(   N(    (    (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   f21*   s    c           S   s   d  S(   N(    (    (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   f22,   s    (   R   R   R   R   t   f23(    (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyR   )   s   		(   t   zope.interfaceR   R   (   t   selfR   R   R
   R   R   (    (   R   sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   _makeDerivedInterface   s    
c         C   sB   d d l  m } |  j | d j |  |  j | d j |  d  S(   Ni˙˙˙˙(   t   FooInterfacet   foobart   aMethod(   t!   zope.interface.tests.unitfixturesR   t   assertEqualt	   interface(   R   R   (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   testInterfaceSetOnAttributes2   s
    c   	      C   sd  d d l  m } d d l  m } d d l  m } d d l  m } d d l  m } d d l  m } d d l  m } d d	 l  m } |  j	 | j
 |   |  j	 | j
 |   |  j	 | j
 |   |  j	 | j
 |   |  j	 | j
 |   |  j	 | j
 |   |  j	 | j
 |   |  j	 | j
 |   |  j	 | j
 |   |  j	 | j
 |   d  S(
   Ni˙˙˙˙(   t   A(   t   B(   t   C(   t   D(   t   E(   t   I1(   t   I2(   t   IC(   R   R   R   R   R   R   R   R    R!   t   assert_t   implementedBy(	   R   R   R   R   R   R   R   R    R!   (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   testClassImplements9   s$    c   	      C   s  d d l  m } d d l  m } d d l m } d d l m } d d l m } d d l m } d d l m } d d	 l m	 } |  j
 | | |  k  |  j
 | | |  k  |  j
 | | |  k  |  j
 | | |  k  |  j
 | | |  k  |  j
 | | |    k  |  j
 | | |    k  |  j
 | | |    k  |  j
 | | |    k  |  j
 | | |    k  d  S(
   Ni˙˙˙˙(   R#   (   t
   providedBy(   R   (   R   (   R   (   R   (   R    (   R!   (   R   R#   R%   R   R   R   R   R   R    R!   R"   (	   R   R#   R%   R   R   R   R   R    R!   (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   testUtilS   s$    c   	      C   s  d d l  m } d d l  m } d d l  m } d d l  m } d d l  m } d d l  m } d d l  m } d d	 l  m } |  j	 | j
 |     |  j	 | j
 |     |  j	 | j
 |     |  j	 | j
 |     |  j	 | j
 |     |  j	 | j
 |     |  j	 | j
 |     |  j	 | j
 |     |  j	 | j
 |     |  j	 | j
 |     d  S(
   Ni˙˙˙˙(   R   (   R   (   R   (   R   (   R   (   R   (   R    (   R!   (   R   R   R   R   R   R   R   R    R!   R"   R%   (	   R   R   R   R   R   R   R   R    R!   (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   testObjectImplementsi   s$    c         C   s@   d d l  m } d d l m } |   } |  j | | j  d  S(   Ni˙˙˙˙(   R   (   t   BrokenImplementation(   R   R   t   zope.interface.exceptionsR(   t   assertRaisest   ma(   R   R   R(   t   a(    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   testDeferredClass   s    	c         C   sá   d d l  m } d d l  m } d d l  m } d d l  m } |  j | j |   |  j | j |   |  j | j |   |  j | j |   |  j | j |   |  j | j |   |  j | j |   d  S(   Ni˙˙˙˙(   t   BazInterface(   t   BarInterface(   t   BobInterface(   t   FunInterface(   R   R.   R/   R0   R1   R"   t   extends(   R   R.   R/   R0   R1   (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   testInterfaceExtendsInterface   s    c         C   s   d d l  m } d d l m } d d l m } d d l m } d d l m } |  j | | |   |  j | j	 |   d  S(   Ni˙˙˙˙(   t   verifyClass(   R   (   t   Foo(   R   (   R   (
   t   zope.interface.verifyR4   R   R   R   R5   R   R   R"   R%   (   R   R4   R   R5   R   R   (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   testVerifyImplementation   s    c         C   s   |  j    } t | j    } | j   |  j | d d d g  t | j d t   } | j   |  j | d d d d d d g  d  S(   NR   R   R   t   allR   R   R   (   R   t   listt   namest   sortR   t   True(   R   t   ifaceR:   R8   (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt
   test_names    s    

c         C   sŰ   |  j    } g  | j   D] } | d ^ q } | j   |  j | d d d g  g  | j d  D] } | d ^ qb } | j   |  j | d d d d d d g  x0 | j d  D] \ } } |  j | | j  q´ Wd  S(	   Ni    R   R   R   i   R   R   R   (   R   t   namesAndDescriptionsR;   R   R   (   R   R=   t   ndR:   t   namet   d(    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   test_namesAndDescriptionsŠ   s    #
&
"c         C   sz   |  j    } |  j | j d  j d  |  j | j d  j d  |  j | j d |   |   |  j t | j d  d  S(   NR   R   t   f33(   R   R   t   getDescriptionForR   t   queryDescriptionForR*   t   KeyError(   R   R=   (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   test_getDescriptionForľ   s
    c         C   sp   |  j    } |  j | d j d  |  j | d j d  |  j | j d |   |   |  j t | j d  d  S(   NR   R   RD   (   R   R   R   t   getR*   RG   t   __getitem__(   R   R=   (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   test___getitem__ź   s
    c         C   s6   |  j    } |  j d | k  |  j d | k  d  S(   NR   RD   (   R   t
   failUnlesst   failIf(   R   R=   (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   test___contains__Ă   s    c         C   sN   |  j    } t t |   } | j   |  j | d d d d d d g  d  S(   NR   R   R   R   R   R   (   R   R9   t   iterR;   R   (   R   R=   R:   (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   test___iter__Č   s    
c         C   sE   |  j    } | j d  } |  j | j d  |  j | j d  d  S(   NR   s   This is an attribute(   R   RE   R   R   t   __doc__(   R   R=   t   description(    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   testAttrÎ   s    c         C   sM   d d l  m } d | f d     Y} | d } |  j | j d  d  d  S(   Ni˙˙˙˙(   R   t   ITestc           B   s   e  Z d    Z d e _ RS(   c           S   s   d  S(   N(    (    (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   methodŘ   s    i   (   R   R   RU   R	   (    (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyRT   ×   s   	RU   R	   i   (   R   R   R   t   getTaggedValue(   R   R   RT   RU   (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   testFunctionAttributesÔ   s    
c   
         s  d d l  m   d d l m } d d l m } d d l m } d d l m  d d l m } d d l m	 } |   } | |   d     f d	  } |  j  j d
  | g  |  j  j |  d   d | _ |  j  j |  d   d | _ |  j  j |  d   | ` | |  | d d g  |  j | j d
  | g  |   } | | |  d | _ | |  | d d g |  d | _ d | _ | |  | d d g |  d | _ d | _ | |  | d d d g |  d | _ d | _ |  j  j |  d   |   } | |   d | _  j d
  } | }	 |	 j |   j d
 |	  | |  | d d g  d | _ d | _ | |  | d d g  d | _ d | _ | |  | d d d g  d | _ d | _ |  j  j |  d    j d
 |  d  S(   Ni˙˙˙˙(   t   Invalid(   t   directlyProvides(   t   BarGreaterThanFoo(   t   ifFooThenBar(   t
   IInvariant(   t
   InvariantC(   t   ISubInvariantc   	         sí   | d  k r  } n  |  j   | j |  g  } y | j | |  Wn*   k
 rq } |  j | j d |  n X|  j d  |  j t |  |  g  | D] } | j d ^ q } | j   x' | D] } |  j | | j d   qĆ Wd  S(   Ni    (	   t   NoneR*   t   validateInvariantst   assertEqualst   argst   _assertt   lenR;   t   pop(	   R   t   ot	   error_lent
   error_msgsR=   t   et   errort   msgst   msg(   RX   R\   (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   errorsEqualë   s    	 
t
   invariantsi   i*   i   s   If Foo, then Bar!i   s%   Please, Boo MUST be greater than Foo!i    (   R)   RX   R   RY   R   RZ   R[   R\   R]   R^   R_   Ra   RV   R`   t   bart   foot   appendt   setTaggedValue(
   R   RY   RZ   R[   R]   R^   Rf   Rm   t   old_invariantsRn   (    (   RX   R\   sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   testInvariantß   sp    	
		
														
		c            sŤ   d d l  m } d d l  m   d | f d     Y} |  j | j d  |  j t |  g   d | f   f d     Y} |  j | j d  |  j t |  d	 g  d  S(
   Ni˙˙˙˙(   R   (   R   t   Ic           B   s   e  Z d  Z RS(   t   xxx(   R   R   RQ   (    (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyRu   D  s   Rv   c              s   e  Z d  Z   d  Z RS(   Rv   s   the doc(   R   R   RQ   (    (   R   (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyRu   J  s   t    RQ   (   R   R   R   R   RQ   R9   (   R   R   Ru   (    (   R   sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   test___doc___elementA  s    c         C   sj   d d l  m } t j d d k r' d  Sd | f d     Y} d d	 d     Y} |  j t | j |  d  S(
   Ni˙˙˙˙(   R   i    t   3Ru   c           B   s   e  Z d  Z RS(   Rv   (   R   R   RQ   (    (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyRu   X  s   t   Badc           B   s   e  Z d  Z RS(   N(   R   R   R_   t   __providedBy__(    (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyRz   Z  s   (    (   R   R   t   syst   versiont   failUnlessRaisest   AttributeErrorR%   (   R   R   Ru   Rz   (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   testIssue228R  s    (   R   R   R   R   R$   R&   R'   R-   R3   R7   R>   RC   RH   RK   RN   RP   RS   RW   Rt   Rx   R   (    (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyR       s&   																			b	i   i   c           C   s   d S(   sn  Invaiants can be deined in line

          >>> from zope.interface.exceptions import Invalid
          >>> from zope.interface import Interface
          >>> from zope.interface import Attribute
          >>> from zope.interface import implements
          >>> from zope.interface import invariant
          >>> class IRange(Interface):
          ...     min = Attribute("Lower bound")
          ...     max = Attribute("Upper bound")
          ...
          ...     @invariant
          ...     def range_invariant(ob):
          ...         if ob.max < ob.min:
          ...             raise Invalid('max < min')


          >>> class Range(object):
          ...     implements(IRange)
          ...
          ...     def __init__(self, min, max):
          ...         self.min, self.max = min, max

          >>> from zope.interface.exceptions import Invalid
          >>> IRange.validateInvariants(Range(1,2))
          >>> IRange.validateInvariants(Range(1,1))
          >>> try:
          ...     IRange.validateInvariants(Range(2,1))
          ... except Invalid, e:
          ...     str(e)
          'max < min'


        N(    (    (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   test_invariant_as_decoratorc  s    c           C   s   d S(   s   See https://bugs.launchpad.net/zope.interface/+bug/185974

There was a bug where the cache used by Specification.get() was not
cleared when the bases were changed.

    >>> from zope.interface import Interface
    >>> from zope.interface import Attribute
    >>> class I1(Interface):
    ...     a = Attribute('a')

    >>> class I2(I1):
    ...     pass

    >>> class I3(I2):
    ...     pass

    >>> I3.get('a') is I1.get('a')
    True
    >>> I2.__bases__ = (Interface,)
    >>> I3.get('a') is None
    True
    N(    (    (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt!   test_description_cache_management  s    c          C   s´   t  j t  }  |  j t j d   t j d
 k rJ |  j t j    n  |  j t j d d i d d 6d t j	 t j
 B |  j t j d	 d i d d 6d t j	 t j
 B |  S(   Ns   zope.interface.interfacei   i   s   ../README.txtt   globst   __main__R   t   optionflagss   ../README.ru.txt(   i   i   (   t   unittestt	   makeSuiteR    t   addTestt   doctestt   DocTestSuiteR|   t   version_infot   DocFileSuitet   NORMALIZE_WHITESPACEt   ELLIPSIS(   t   suite(    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt
   test_suiteĄ  s    (
   RQ   R   R   R|   t   TestCaseR    R   R   R   R   (    (    (    sG   /usr/lib/python2.7/dist-packages/zope/interface/tests/test_interface.pyt   <module>   s   ˙ N%	