o
    $x`Ti                    @   s  d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ e Z	G dd dej
ZG d	d
 d
ej
ZG dd dej
ZG dd dej
ZG dd deeZG dd deZG dd deZG dd deZG dd deeej
ZG dd deej
ZG dd dej
ZG dd dej
ZG dd  d ej
ZG d!d" d"eZG d#d$ d$eZG d%d& d&ej
ZG d'd( d(ej
ZG d)d* d*eZd+d, Zd-d. ZG d/d0 d0eZdS )1zTest Interface implementation
    N)_skip_under_py3k)MissingSomeAttrs)OptimizationTestMixin)CleanUpc                   @      e Zd Zdd Zdd ZdS )Test_invariantc                    sT   ddl m ddl m} dd  G  fdddt}| t||d d gi d S )	Nr   	invariantTAGGED_DATAc                  _      t  NNotImplementedErrorargskw r   E/usr/lib/python3/dist-packages/zope/interface/tests/test_interface.py_check(      z,Test_invariant.test_w_single.<locals>._checkc                       s   e Zd Z  dS )z)Test_invariant.test_w_single.<locals>.FooN__name__
__module____qualname__r   r   r	   r   r   Foo+       r   
invariantszope.interface.interfacer	   r   objectassertEqualgetattrselfr   r   r   r   r   test_w_single$   s   zTest_invariant.test_w_singlec                    s`   ddl m ddl m} dd dd  G  fdd	d	t}| t||d d
 gi d S )Nr   r   r
   c                  _   r   r   r   r   r   r   r   r   5   r   z.Test_invariant.test_w_multiple.<locals>._checkc                  _   r   r   r   r   r   r   r   _another_check8   r   z6Test_invariant.test_w_multiple.<locals>._another_checkc                       s   e Zd Z   dS )z+Test_invariant.test_w_multiple.<locals>.FooNr   r   r'   r   r	   r   r   r   ;   s    r   r   r   r$   r   r(   r   test_w_multiple1   s   
zTest_invariant.test_w_multipleN)r   r   r   r&   r)   r   r   r   r   r   "   s    r   c                   @   $   e Zd Zdd Zdd Zdd ZdS )Test_taggedValuec                    sJ   ddl m  ddl m} G  fdddt}| t||d ddgi d S )Nr   taggedValuer
   c                       s   e Zd Z ddg dS )z+Test_taggedValue.test_w_single.<locals>.FoobarbazNr   r   r,   r   r   r   I       r   r.   r/   r    r-   r   r!   r"   r#   r$   r   r,   r   r&   E   s   zTest_taggedValue.test_w_singlec                    sL   ddl m  ddl m} G  fdddt}| t||d dgdd d S )	Nr   r,   r
   c                       s"   e Zd Z ddg  dd dS )z-Test_taggedValue.test_w_multiple.<locals>.Foor.   r/   quxspamNr   r   r,   r   r   r   S   s    r   r/   r3   r.   r2   r1   r$   r   r,   r   r)   O   s   
z Test_taggedValue.test_w_multiplec                    sJ   ddl m  ddl m} G  fdddt}| t||d ddd d S )	Nr   r,   r
   c                       s,   e Zd Z ddg  dd  dd dS )z9Test_taggedValue.test_w_multiple_overwriting.<locals>.Foor.   r/   r2   r3   frobNr   r   r,   r   r   r   ^   s    
r   r5   r3   r4   r1   r$   r   r,   r   test_w_multiple_overwritingZ   s   z,Test_taggedValue.test_w_multiple_overwritingN)r   r   r   r&   r)   r6   r   r   r   r   r+   C   s    
r+   c                   @   sz   e Zd ZdZdd ZdddZdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd ZdS )ElementTests	AnElementc                 C      ddl m} |S )Nr   )Element)r    r:   )r%   r:   r   r   r   _getTargetClassk      zElementTests._getTargetClassNc                 C   s   |d u r| j }|  |S r   )DEFAULT_NAMEr;   )r%   namer   r   r   _makeOneo   s   zElementTests._makeOnec                 C   s`   |   }| |j| j | | | j | |jd | | d | t| g  d S )N )	r?   r"   r   r=   getName__doc__getDoclistgetTaggedValueTagsr%   elementr   r   r   test_ctor_defaultst   s   zElementTests.test_ctor_defaultsc                 C   s*   |  d}| |jd  | |jd d S )Nz
An Element)r?   r"   r   rB   rF   r   r   r   test_ctor_no_doc_space_in_name|   s   
z+ElementTests.test_ctor_no_doc_space_in_namec                 C      |   }| t|jd d S Nnonesuch)r?   assertRaisesKeyErrorgetTaggedValuerF   r   r   r   test_getTaggedValue_miss      z%ElementTests.test_getTaggedValue_missc                 C   sB   |   }| g t|  |dd | dgt|  d S Nfoor.   )r?   r"   rD   getDirectTaggedValueTagssetTaggedValuerF   r   r   r   test_getDirectTaggedValueTags   s   z*ElementTests.test_getDirectTaggedValueTagsc                 C      |   }| |dd  d S rK   r?   r"   queryTaggedValuerF   r   r   r   test_queryTaggedValue_miss      z'ElementTests.test_queryTaggedValue_missc                 C       |   }| |ddd d S NrL   r.   rX   rF   r   r   r   $test_queryTaggedValue_miss_w_default      z1ElementTests.test_queryTaggedValue_miss_w_defaultc                 C   rJ   rK   )r?   rM   rN   getDirectTaggedValuerF   r   r   r   test_getDirectTaggedValue_miss   rQ   z+ElementTests.test_getDirectTaggedValue_missc                 C   rW   rK   r?   r"   queryDirectTaggedValuerF   r   r   r    test_queryDirectTaggedValue_miss   r[   z-ElementTests.test_queryDirectTaggedValue_missc                 C   r\   r]   rb   rF   r   r   r   *test_queryDirectTaggedValue_miss_w_default   r_   z7ElementTests.test_queryDirectTaggedValue_miss_w_defaultc                 C   sR   |   }|dd | t| dg | |dd | |dd d S rR   )r?   rU   r"   rD   rE   rO   rY   rF   r   r   r   test_setTaggedValue   s
   z ElementTests.test_setTaggedValuec                 C   s.   ddl m} ddlm} |  }||| d S )Nr   )IElementverifyObject)zope.interface.interfacesrg   zope.interface.verifyri   r?   )r%   rg   ri   rG   r   r   r   test_verifies   s   zElementTests.test_verifiesr   )r   r   r   r=   r;   r?   rH   rI   rP   rV   rZ   r^   ra   rd   re   rf   rl   r   r   r   r   r7   g   s    
r7   c                   @   s0   e Zd Zdd ZeZdd Zdd Zdd Zd	S )
GenericSpecificationBaseTestsc                 C   r9   )Nr   )SpecificationBasePy)r    rn   )r%   rn   r   r   r   _getFallbackClass   r<   z/GenericSpecificationBaseTests._getFallbackClassc                 C   s
   |    S r   r;   r%   r   r   r   r?         
z&GenericSpecificationBaseTests._makeOnec                    p   ddl m} ddlm  |  } fdd}t||d | |t  W d    d S 1 s1w   Y  d S )Nr   	interface_emptyc                        S r   r   objrv   r   r   _providedBy      zGGenericSpecificationBaseTests.test_providedBy_miss.<locals>._providedBy
providedBy)	zope.interfaceru   zope.interface.declarationsrw   r?   _MonkeyassertFalser~   r!   )r%   ru   sbr{   r   rv   r   test_providedBy_miss      "z2GenericSpecificationBaseTests.test_providedBy_missc                    rs   )Nr   rt   rv   c                    rx   r   r   ry   rv   r   r   _implementedBy   r|   zMGenericSpecificationBaseTests.test_implementedBy_miss.<locals>._implementedByimplementedBy)	r   ru   r   rw   r?   r   r   r   r!   )r%   ru   r   r   r   rv   r   test_implementedBy_miss   r   z5GenericSpecificationBaseTests.test_implementedBy_missN)r   r   r   ro   r;   r?   r   r   r   r   r   r   rm      s    	rm   c                   @      e Zd Zdd ZdS )SpecificationBaseTestsc                 C   r9   )Nr   )SpecificationBase)r    r   )r%   r   r   r   r   r;      r<   z&SpecificationBaseTests._getTargetClassNr   r   r   r;   r   r   r   r   r          r   c                   @   <   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd ZdS )SpecificationBasePyTestsc                 C   $   |   }i |_| |t  d S r   r?   _impliedr   isOrExtendsr!   r%   r   r   r   r   test___call___miss      z+SpecificationBasePyTests.test___call___missc                 C   *   |   }t }|i i|_| || d S r   r?   r!   r   
assertTruer%   r   testingr   r   r   test___call___hit      
z*SpecificationBasePyTests.test___call___hitc                 C   r   r   r   r   r   r   r   test_isOrExtends_miss   r   z.SpecificationBasePyTests.test_isOrExtends_missc                 C   r   r   r   r   r   r   r   test_isOrExtends_hit   r   z-SpecificationBasePyTests.test_isOrExtends_hitc                    x   ddl m} |  G fdddt  fdd}t||d | t  W d    d S 1 s5w   Y  d S )Nr   rt   c                          e Zd Z i iZdS )z>SpecificationBasePyTests.test_implementedBy_hit.<locals>._DeclNr   r   r   r   r   r   r   r   _Decl   r   r   c                         S r   r   ry   r   r   r   r      r   zGSpecificationBasePyTests.test_implementedBy_hit.<locals>._implementedByr   )r   ru   r?   r!   r   r   r   )r%   ru   r   r   r   r   r   test_implementedBy_hit      "z/SpecificationBasePyTests.test_implementedBy_hitc                    r   )Nr   rt   c                       r   )z;SpecificationBasePyTests.test_providedBy_hit.<locals>._DeclNr   r   r   r   r   r      r   r   c                    r   r   r   ry   r   r   r   r{      r   zASpecificationBasePyTests.test_providedBy_hit.<locals>._providedByr}   )r   ru   r?   r!   r   r   r~   )r%   ru   r{   r   r   r   test_providedBy_hit   r   z,SpecificationBasePyTests.test_providedBy_hitN)	r   r   r   r   r   r   r   r   r   r   r   r   r   r      s    
r   c                   @   r   )!NameAndModuleComparisonTestsMixinc                 C   s   |  ddS )Nab)r?   rq   r   r   r   _makeOneToCompare  s   z3NameAndModuleComparisonTestsMixin._makeOneToComparec              	      s  dd l }|  }t||}t|d| }G  fdddt G dd d }G dd d }| | jd	 | | jd	 | t t| d
 W d    n1 sTw   Y  | t t| d W d    n1 sow   Y  ||fD ]}| 	|| t
 qxG dd d }	| |||	  | 	||	 t
 G dd dt}
| 	||
 t
 | t |||
  W d    n1 sw   Y  G dd dt}| _| | t| d
 W d    n1 sw   Y  | | t| d W d    n	1 sw   Y  ||fD ]:}| | |||  W d    n	1 s)w   Y  | | ||  W d    n	1 sDw   Y  qd S )Nr   z__%s__c                       s   e Zd ZeZ fddZdS )zaNameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.RaisesErrorOnMissingc                    s,   zt | |W S  ty    j}||w r   )r!   __getattribute__AttributeErrorExc)r%   r>   excRaisesErrorOnMissingr   r   r     s   zrNameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.RaisesErrorOnMissing.__getattribute__N)r   r   r   r   r   r   r   r   r   r   r     s    r   c                   @   s    e Zd Zdd Zedd ZdS )z`NameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.RaisesErrorOnModulec                 S   
   d| _ d S NrS   )r   rq   r   r   r   __init__  rr   ziNameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.RaisesErrorOnModule.__init__c                 S      t r   )r   rq   r   r   r   r         zkNameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.RaisesErrorOnModule.__module__N)r   r   r   r   propertyr   r   r   r   RaisesErrorOnModule  s    r   c                   @   r   )z^NameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.RaisesErrorOnNamec                 S   r   r   r   rq   r   r   r   r   %  rr   zgNameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.RaisesErrorOnName.__init__Nr   r   r   r   r   r   r   r   RaisesErrorOnName$  r   r   rS   r   r   c                   @   s(   e Zd Zdd ZeZeZeZeZeZdS )z`NameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.AllowsAnyComparisonc                 S      dS NTr   )r%   otherr   r   r   __eq__6  r|   zgNameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.AllowsAnyComparison.__eq__N	r   r   r   r   __lt____le____gt____ge____ne__r   r   r   r   AllowsAnyComparison5  s    r   c                   @   s$   e Zd ZdZeZeZeZeZeZdS )z_NameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.AllowsNoComparisonNr   r   r   r   r   AllowsNoComparisonB  s    r   c                   @      e Zd ZdS )zXNameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.MyExceptionNr   r   r   r   r   MyExceptionO      r   )operatorr   r#   r!   r"   r   r   rM   r   assertIsNotImplementedr   	TypeError	Exceptionr   )r%   r>   r   ibopmethr   r   clsr   r   r   r   r   r   !__check_NotImplemented_comparison  sT   
		zCNameAndModuleComparisonTestsMixin.__check_NotImplemented_comparisonc                 C      |  d d S )NltC_NameAndModuleComparisonTestsMixin__check_NotImplemented_comparisonrq   r   r   r   test__lt__NotImplemented_     z:NameAndModuleComparisonTestsMixin.test__lt__NotImplementedc                 C   r   )Nler   rq   r   r   r   test__le__NotImplementedb  r   z:NameAndModuleComparisonTestsMixin.test__le__NotImplementedc                 C   r   )Ngtr   rq   r   r   r   test__gt__NotImplementede  r   z:NameAndModuleComparisonTestsMixin.test__gt__NotImplementedc                 C   r   )Nger   rq   r   r   r   test__ge__NotImplementedh  r   z:NameAndModuleComparisonTestsMixin.test__ge__NotImplementedN)	r   r   r   r   r   r   r   r   r   r   r   r   r   r     s    Wr   c                   @   sF   e Zd Zdd Zdd ZdddZd	d
 Zdd Zdd Zdd Z	dS )InterfaceBaseTestsMixinc                 C   r   r   r   rq   r   r   r   r;   o  r|   z'InterfaceBaseTestsMixin._getTargetClassc                 C   r9   )Nr   )InterfaceBasePy)r    r   )r%   r   r   r   r   ro   r  s   z)InterfaceBaseTestsMixin._getFallbackClassFNc                    s"   G  fddd|   }|||S )Nc                       s    e Zd Zdd Z fddZdS )z,InterfaceBaseTestsMixin._makeOne.<locals>.IBc                 S   s   || S r   r   )r%   conformr   r   r   _call_conformy     z:InterfaceBaseTestsMixin._makeOne.<locals>.IB._call_conformc                    rx   r   r   r%   rz   object_should_provider   r   r~   {  r|   z7InterfaceBaseTestsMixin._makeOne.<locals>.IB.providedByN)r   r   r   r   r~   r   r   r   r   IBx  s    r   rp   )r%   r   r>   moduler   r   r   r   r?   w  s   
z InterfaceBaseTestsMixin._makeOnec                    s:   |  d}t  G  fdddt}| ||   d S )NFc                          e Zd Z fddZdS )zUInterfaceBaseTestsMixin.test___call___w___conform___returning_value.<locals>._Adaptedc                    rx   r   r   r%   iface	conformedr   r   __conform__  r|   zaInterfaceBaseTestsMixin.test___call___w___conform___returning_value.<locals>._Adapted.__conform__Nr   r   r   r   r   r   r   r   _Adapted  r0   r   r?   r!   r   )r%   r   r   r   r   r   +test___call___w___conform___returning_value  s   
zCInterfaceBaseTestsMixin.test___call___w___conform___returning_valuec                 C   s8   |  d}||  f}t }t }| |||| d S )NF)r?   r;   r!   r   )r%   r   __traceback_info__adapted	alternater   r   r   7test___call___wo___conform___ob_no_provides_w_alternate  s
   
zOInterfaceBaseTestsMixin.test___call___wo___conform___ob_no_provides_w_alternatec                 C   sT   |  d}| t}|t  W d    n1 sw   Y  | dt|j d S )NFzCould not adapt)r?   rM   r   r!   assertInstr	exception)r%   r   r   r   r   r   7test___call___w___conform___ob_no_provides_wo_alternate  s
   
zOInterfaceBaseTestsMixin.test___call___w___conform___ob_no_provides_wo_alternatec                 C   s   t j| |  dd d S )Nr   )expected_missing)r   test_raisesr?   rq   r   r   r   6test___call___w_no_conform_catches_only_AttributeError  s   zNInterfaceBaseTestsMixin.test___call___w_no_conform_catches_only_AttributeError)FNN)
r   r   r   r;   ro   r?   r   r   r   r  r   r   r   r   r   l  s    
r   c                   @   r   )InterfaceBaseTestsc                 C   r9   )Nr   )InterfaceBase)r    r  )r%   r  r   r   r   r;     r<   z"InterfaceBaseTests._getTargetClassNr   r   r   r   r   r    r   r  c                   @   s*   e Zd ZejZdd Zdd Zdd ZdS )InterfaceBasePyTestsc                 C   s4   |  d}G dd dt}| }| ||| d S )NTc                   @   r   )zSInterfaceBasePyTests.test___call___w___conform___miss_ob_provides.<locals>._Adaptedc                 S      d S r   r   r   r   r   r   r     r|   z_InterfaceBasePyTests.test___call___w___conform___miss_ob_provides.<locals>._Adapted.__conform__Nr   r   r   r   r   r     r   r   r   )r%   r   r   r   r   r   r   ,test___call___w___conform___miss_ob_provides  s   
zAInterfaceBasePyTests.test___call___w___conform___miss_ob_providesc                 C   s&   |  d}t }| ||| d S r   )r?   r!   r   	__adapt__)r%   r   r   r   r   r   test___adapt___ob_provides  s   
z/InterfaceBasePyTests.test___adapt___ob_providesc                    s   ddl m} | d}t }g   fdd}dd }t|||gd | ||| |  ||fg W d    d S 1 s@w   Y  d S )	Nr   rt   Fc                    s     | |f d S r   appendr   rz   _missedr   r   
_hook_miss     zQInterfaceBasePyTests.test___adapt___ob_no_provides_uses_hooks.<locals>._hook_missc                 S      |S r   r   r  r   r   r   	_hook_hit  r|   zPInterfaceBasePyTests.test___adapt___ob_no_provides_uses_hooks.<locals>._hook_hitadapter_hooks)r   ru   r?   r!   r   r   r	  r"   )r%   ru   r   r   r  r  r   r  r   (test___adapt___ob_no_provides_uses_hooks  s   
"z=InterfaceBasePyTests.test___adapt___ob_no_provides_uses_hooksN)	r   r   r   r   ro   r;   r  r
  r  r   r   r   r   r    s
    r  c                   @   s   e Zd Zdd ZefddZdd Zdd Zd	d
 Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!S )"SpecificationTestsc                 C   r9   )Nr   )Specification)r    r  )r%   r  r   r   r   r;     r<   z"SpecificationTests._getTargetClassc                 C   s   |t u r	|   S |  |S r   )_markerr;   )r%   basesr   r   r   r?     s   
zSpecificationTests._makeOnec                 C   sj   ddl m} |  }| |jd | t|jd | ||jv  | ||jv  | t|jd d S )Nr   	Interfacer      )	r    r  r?   r"   	__bases__lenr   r   
dependents)r%   r  specr   r   r   	test_ctor  s   zSpecificationTests.test_ctorc                 C   s@   |   }t }|| | t|jd | |j| d d S N   )r?   DummyDependent	subscriber"   r  r   r%   r!  depr   r   r   test_subscribe_first_time  s
   
z,SpecificationTests.test_subscribe_first_timec                 C   s8   |   }t }|| || | |j| d d S )Nr  )r?   r%  r&  r"   r   r'  r   r   r   test_subscribe_again  s
   

z'SpecificationTests.test_subscribe_againc                 C   s"   |   }t }| t|j| d S r   )r?   r%  rM   rN   unsubscriber'  r   r   r   test_unsubscribe_miss     z(SpecificationTests.test_unsubscribe_missc                 C   s\   |   }t }|| || || | |j| d || | ||jv  d S r#  )r?   r%  r&  r+  r"   r   r   r'  r   r   r   test_unsubscribe  s   



z#SpecificationTests.test_unsubscribec                 C   s   ddl m} |  }t }|| G dd d|}G dd d|}|f|_| |j|g | |j| d |f|_| |j	|d  | |j| d d S )Nr   r  c                   @   r   )zVSpecificationTests.test___setBases_subscribes_bases_and_notifies_dependents.<locals>.INr   r   r   r   r   I  r   r/  c                   @   r   )zVSpecificationTests.test___setBases_subscribes_bases_and_notifies_dependents.<locals>.JNr   r   r   r   r   J  r   r0  r$  )
r    r  r?   r%  r&  r  r"   _changedr   get)r%   r  r!  r(  r/  r0  r   r   r   8test___setBases_subscribes_bases_and_notifies_dependents  s   
zKSpecificationTests.test___setBases_subscribes_bases_and_notifies_dependentsc                 C   s^   ddl m} G dd d|}|  }d|_d|j|< || | |j | ||jv  d S )Nr   r  c                   @   r   )zGSpecificationTests.test_changed_clears_volatiles_and_implied.<locals>.INr   r   r   r   r   r/    r   r/  r   r   )r    r  r?   _v_attrsr   changedassertIsNoner   )r%   r  r/  r!  r   r   r   )test_changed_clears_volatiles_and_implied  s   

z<SpecificationTests.test_changed_clears_volatiles_and_impliedc                 C   sD   ddl m} G dd d|}| ||g}| t| |g d S )Nr   r  c                   @   r   )zCSpecificationTests.test_interfaces_skips_already_seen.<locals>.IFooNr   r   r   r   r   IFoo  r   r8  )r    r  r?   r"   rD   
interfacesr%   r  r8  r!  r   r   r   "test_interfaces_skips_already_seen  s   z5SpecificationTests.test_interfaces_skips_already_seenc                 C   s>   ddl m} G dd d|}| |}| |j|dd d S )Nr   r  c                   @   r   )z<SpecificationTests.test_extends_strict_wo_self.<locals>.IFooNr   r   r   r   r   r8    r   r8  Tstrict)r    r  r?   r   extendsr:  r   r   r   test_extends_strict_wo_self  s   
z.SpecificationTests.test_extends_strict_wo_selfc                 C       |   }| |j|dd d S )NTr<  )r?   r   r>  r%   r!  r   r   r   test_extends_strict_w_self  r_   z-SpecificationTests.test_extends_strict_w_selfc                 C   r@  )NFr<  )r?   r   r>  rA  r   r   r   test_extends_non_strict_w_self  r_   z1SpecificationTests.test_extends_non_strict_w_selfc                 C   s0   |   }t }d|i|_| |d|u  d S r   )r?   r!   r4  r   r2  )r%   r!  rS   r   r   r   test_get_hit_w__v_attrs#  s   
z*SpecificationTests.test_get_hit_w__v_attrsc                    s   ddl m  ddl m} G  fddd|}G  fddd|}| ||g}| |d|du  | |d	|d	u  d S )
Nr   	Attributer  c                          e Zd Z dZdS )zCSpecificationTests.test_get_hit_from_base_wo__v_attrs.<locals>.IFoorS   N)r   r   r   rS   r   rE  r   r   r8  ,  r   r8  c                       rG  )zCSpecificationTests.test_get_hit_from_base_wo__v_attrs.<locals>.IBarr.   Nr   r   r   r.   r   rE  r   r   IBar.  r   rI  rS   r.   )r    rF  r  r?   r   r2  )r%   r  r8  rI  r!  r   rE  r   "test_get_hit_from_base_wo__v_attrs)  s   z5SpecificationTests.test_get_hit_from_base_wo__v_attrsc           
   	   C   s   ddl m} ddlm} ddlm} G dd d|}G dd dt}G d	d
 d
|}G dd d|}||G dd dt}G dd d||}	| ||	j||	||||||t|f d S )Nr   r  implementerr   c                   @   r   )zTSpecificationTests.test_multiple_inheritance_no_interfaces.<locals>.IDefaultViewNameNr   r   r   r   r   IDefaultViewName>  r   rM  c                   @   r   )zKSpecificationTests.test_multiple_inheritance_no_interfaces.<locals>.ContextNr   r   r   r   r   ContextA  r   rN  c                   @   r   )zLSpecificationTests.test_multiple_inheritance_no_interfaces.<locals>.RDBModelNr   r   r   r   r   RDBModelD  r   rO  c                   @   r   )zJSpecificationTests.test_multiple_inheritance_no_interfaces.<locals>.IOtherNr   r   r   r   r   IOtherG  r   rP  c                   @   r   )zMSpecificationTests.test_multiple_inheritance_no_interfaces.<locals>.OtherBaseNr   r   r   r   r   	OtherBaseJ      rQ  c                   @   r   )zISpecificationTests.test_multiple_inheritance_no_interfaces.<locals>.ModelNr   r   r   r   r   ModelN  r   rS  )r    r  r   rL  r   r!   r"   __sro__)
r%   r  rL  r   rM  rN  rO  rP  rQ  rS  r   r   r   'test_multiple_inheritance_no_interfaces4  s(   z:SpecificationTests.test_multiple_inheritance_no_interfacesN)r   r   r   r;   r  r?   r"  r)  r*  r,  r.  r3  r7  r;  r?  rB  rC  rD  rJ  rU  r   r   r   r   r    s"    	
r  c                   @   s  e Zd Zdd Z		dfddZdd	 Zd
d Zdd Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Zd:d; Zd<d= Zd>d? Z d@dA Z!dBdC Z"dDdE Z#dFdG Z$dHdI Z%dJdK Z&dLdM Z'dNdO Z(dPdQ Z)dRdS Z*dTdU Z+dVdW Z,dXdY Z-dZd[ Z.d\d] Z/d^d_ Z0d`da Z1dbdc Z2ddde Z3dS )gInterfaceClassTestsc                 C   r9   )Nr   InterfaceClass)r    rX  )r%   rX  r   r   r   r;   `  r<   z#InterfaceClassTests._getTargetClassITestr   Nc                 C   s   |   |||||S r   rp   )r%   r>   r  attrsrB   r   r   r   r   r?   d  s   zInterfaceClassTests._makeOnec                 C   sN   |   }|d}| |jd | |jd | |jd | | d d S )NITestingr@   r   )r;   r"   r   rB   r  getBases)r%   klassinstr   r   r   rH   h  s   z&InterfaceClassTests.test_ctor_defaultsc                 C   s    |   }| t|dt f d S )Nr[  )r;   rM   r   r!   )r%   r]  r   r   r   test_ctor_bad_basesp  r_   z'InterfaceClassTests.test_ctor_bad_basesc                 C   s   ddl m} ddl m} dd }|dd||d}|  }|d	|d
}| |jd	 | |jd | |jd | | |	  d S )Nr   rE  fromFunctionc                   S   r   	DOCSTRINGNr   r   r   r   r   _barw      zBInterfaceClassTests.test_ctor_w_attrs_attrib_methods.<locals>._barr   r@   rS   r.   r[  rZ  r   )
r    rF  ra  r;   r"   r   rB   r  nameskeys)r%   rF  ra  rd  ATTRSr]  r^  r   r   r    test_ctor_w_attrs_attrib_methodst  s   z4InterfaceClassTests.test_ctor_w_attrs_attrib_methodsc                 C   ^   di i}|   }|d|d}| |jd | |jd | |jd | t| g  d S )N
__locals__r[  rg  r@   r   r;   r"   r   rB   r  rD   rh  r%   rj  r]  r^  r   r   r   test_ctor_attrs_w___locals__     z0InterfaceClassTests.test_ctor_attrs_w___locals__c                 C   rl  )N__annotations__r[  rg  r@   r   rn  ro  r   r   r   !test_ctor_attrs_w___annotations__  rq  z5InterfaceClassTests.test_ctor_attrs_w___annotations__c                 C   sj   ddl m} d|i}|  }|d|d}| |jd | |jd | |jd | t| g  d S )Nr   )_decorator_non_returndropmer[  rg  r@   r   )	r    rt  r;   r"   r   rB   r  rD   rh  )r%   rt  rj  r]  r^  r   r   r   'test_ctor_attrs_w__decorator_non_return  s   z;InterfaceClassTests.test_ctor_attrs_w__decorator_non_returnc                 C   s4   ddl m} dt i}|  }| j||d|d d S )Nr   )InvalidInterfaceinvalidr[  rg  )zope.interface.exceptionsrw  r!   r;   rM   )r%   rw  rj  r]  r   r   r   #test_ctor_attrs_w_invalid_attr_type  s   
z7InterfaceClassTests.test_ctor_attrs_w_invalid_attr_typec                 C   s0   ddi}|   }|d|dd}| |jd d S )NrB   ATTRr[  EXPLICIT)rZ  rB   )r;   r"   rB   ro  r   r   r   test_ctor_w_explicit___doc__  s   z0InterfaceClassTests.test_ctor_w_explicit___doc__c                 C   s"   |   }| t| |g d S r   )r?   r"   rD   r9  r   r   r   r   test_interfaces  s   z#InterfaceClassTests.test_interfacesc                 C   s.   |   }| j d|fd}| | |f d S NISub)r  )r?   r"   r\  r%   r   subr   r   r   test_getBases  s   z!InterfaceClassTests.test_getBasesc                 C   s   |   }| || d S r   )r?   r   isEqualOrExtendedByr   r   r   r   !test_isEqualOrExtendedBy_identity  rQ   z5InterfaceClassTests.test_isEqualOrExtendedBy_identityc                 C   s<   |   }| j d|fd}| || | || d S r  )r?   r   r  r   r  r   r   r   !test_isEqualOrExtendedBy_subiface  s   z5InterfaceClassTests.test_isEqualOrExtendedBy_subifacec                 C   s8   |  d}|  d}| || | || d S )NOneAnother)r?   r   r  )r%   oneanotherr   r   r   "test_isEqualOrExtendedBy_unrelated  s   

z6InterfaceClassTests.test_isEqualOrExtendedBy_unrelatedc                 C   s   ddl m} ddl m} dd }|dd||d}d	|d
di}| jd|d}| jd|f|d}| t|jddd	g d S )Nr   rE  r`  c                   S   r   rb  r   r   r   r   r   rd    re  zFInterfaceClassTests.test_names_w_all_False_ignores_bases.<locals>._barr   r@   rf  r/   BazIBaserg  IDerivedr  rZ  Fallr    rF  ra  r?   r"   sortedrh  r%   rF  ra  rd  
BASE_ATTRSDERIVED_ATTRSbasederivedr   r   r   $test_names_w_all_False_ignores_bases  s   z8InterfaceClassTests.test_names_w_all_False_ignores_basesc                 C   s`   ddl m} ddl m} dd }|dd||d}| j|d	}| t|jd
dddg d S )Nr   rE  r`  c                   S   r   rb  r   r   r   r   r   rd    re  z@InterfaceClassTests.test_names_w_all_True_no_bases.<locals>._barr   r@   rf  rg  Tr  r.   rS   r  r%   rF  ra  rd  rj  r  r   r   r   test_names_w_all_True_no_bases  s    z2InterfaceClassTests.test_names_w_all_True_no_basesc                 C   s   ddl m} ddl m} dd }|dd||d}d	|d
di}| jd|d}| jd|f|d}| t|jddg d d S )Nr   rE  r`  c                   S   r   rb  r   r   r   r   r   rd    re  zFInterfaceClassTests.test_names_w_all_True_w_bases_simple.<locals>._barr   r@   rf  r/   r  r  rg  r  r  Tr  r.   r/   rS   r  r  r   r   r   $test_names_w_all_True_w_bases_simple  s    z8InterfaceClassTests.test_names_w_all_True_w_bases_simplec           	      C   s   ddl m} ddl m} dd }dd }|dd	||d
}|||dd	d}| jd|d}| jd|f|d}| t|jddg d d S )Nr   rE  r`  c                   S   r   rb  r   r   r   r   r   rd    re  zJInterfaceClassTests.test_names_w_all_True_bases_w_same_names.<locals>._barc                   S   r   rb  r   r   r   r   r   _foo  re  zJInterfaceClassTests.test_names_w_all_True_bases_w_same_names.<locals>._foor   r@   rf  r  rS   r/   r  rg  r  r  Tr  r  r  	r%   rF  ra  rd  r  r  r  r  r  r   r   r   (test_names_w_all_True_bases_w_same_names  s    z<InterfaceClassTests.test_names_w_all_True_bases_w_same_namesc           	      C   s   ddl m} ddl m} dd }dd }|dd	||d
}|||dd	d}| jd|d}| jd|f|d}| t|g d d S )Nr   rE  r`  c                   S   r   rb  r   r   r   r   r   rd    re  z/InterfaceClassTests.test___iter__.<locals>._barc                   S   r   rb  r   r   r   r   r   r    re  z/InterfaceClassTests.test___iter__.<locals>._foor   r@   rf  r  r  r  rg  r  r  r  )r    rF  ra  r?   r"   r  r  r   r   r   test___iter__  s   z!InterfaceClassTests.test___iter__c                 C   s   ddl m} ddl m} dd }|dd||d}d	|d
di}| jd|d}| jd|f|d}| t|jddd	|d	 fg d S )Nr   rE  r`  c                   S   r   rb  r   r   r   r   r   rd    re  zUInterfaceClassTests.test_namesAndDescriptions_w_all_False_ignores_bases.<locals>._barr   r@   rf  r/   r  r  rg  r  r  Fr  r    rF  ra  r?   r"   r  namesAndDescriptionsr  r   r   r   3test_namesAndDescriptions_w_all_False_ignores_bases  s   zGInterfaceClassTests.test_namesAndDescriptions_w_all_False_ignores_basesc                 C   sp   ddl m} ddl m} dd }|dd||d}| j|d	}| t|jd
dd|d fd|d fg d S )Nr   rE  r`  c                   S   r   rb  r   r   r   r   r   rd     re  zOInterfaceClassTests.test_namesAndDescriptions_w_all_True_no_bases.<locals>._barr   r@   rf  rg  Fr  r.   rS   r  r  r   r   r   -test_namesAndDescriptions_w_all_True_no_bases  s   

zAInterfaceClassTests.test_namesAndDescriptions_w_all_True_no_basesc                 C   s   ddl m} ddl m} dd }|dd||d}d	|d
di}| jd|d}| jd|f|d}| t|jddd|d fd	|d	 fd|d fg d S )Nr   rE  r`  c                   S   r   rb  r   r   r   r   r   rd  .  re  zMInterfaceClassTests.test_namesAndDescriptions_w_all_True_simple.<locals>._barr   r@   rf  r/   r  r  rg  r  r  Tr  r.   rS   r  r  r   r   r   +test_namesAndDescriptions_w_all_True_simple+  s   


z?InterfaceClassTests.test_namesAndDescriptions_w_all_True_simplec           	      C   s   ddl m} ddl m} dd }dd }|dd	||d
}|||dd	d}| jd|d}| jd|f|d}| t|jddd|d fd|d fd|d fg d S )Nr   rE  r`  c                   S   r   rb  r   r   r   r   r   rd  @  re  zYInterfaceClassTests.test_namesAndDescriptions_w_all_True_bases_w_same_names.<locals>._barc                   S   r   rb  r   r   r   r   r   r  B  re  zYInterfaceClassTests.test_namesAndDescriptions_w_all_True_bases_w_same_names.<locals>._foor   r@   rf  r  r  r  rg  r  r  Tr  r.   r/   rS   r  r  r   r   r   7test_namesAndDescriptions_w_all_True_bases_w_same_names=  s$   


zKInterfaceClassTests.test_namesAndDescriptions_w_all_True_bases_w_same_namesc                 C   rJ   rK   )r?   rM   rN   getDescriptionForr%   r  r   r   r   test_getDescriptionFor_missR  rQ   z/InterfaceClassTests.test_getDescriptionFor_missc                 C   sp   ddl m} ddl m} dd }|dd||d}| j|d	}| |d
|d
  | |d|d  d S )Nr   rE  r`  c                   S   r   rb  r   r   r   r   r   rd  Y  re  z<InterfaceClassTests.test_getDescriptionFor_hit.<locals>._barr   r@   rf  rg  rS   r.   )r    rF  ra  r?   r"   r  r  r   r   r   test_getDescriptionFor_hitV  s   z.InterfaceClassTests.test_getDescriptionFor_hitc                    s$   |     fdd}| t| d S )Nc                      s    d S rK   r   r   r  r   r   _testd  r   z8InterfaceClassTests.test___getitem___miss.<locals>._test)r?   rM   rN   )r%   r  r   r  r   test___getitem___missb  s   z)InterfaceClassTests.test___getitem___missc                 C   sl   ddl m} ddl m} dd }|dd||d}| j|d	}| |d
 |d
  | |d |d  d S )Nr   rE  r`  c                   S   r   rb  r   r   r   r   r   rd  k  re  z6InterfaceClassTests.test___getitem___hit.<locals>._barr   r@   rf  rg  rS   r.   )r    rF  ra  r?   r"   r  r   r   r   test___getitem___hith  s   z(InterfaceClassTests.test___getitem___hitc                 C   s   |   }| d|v  d S rK   )r?   r   r  r   r   r   test___contains___misst  s   z*InterfaceClassTests.test___contains___missc                 C   s`   ddl m} ddl m} dd }|dd||d}| j|d	}| d
|v  | d|v  d S )Nr   rE  r`  c                   S   r   rb  r   r   r   r   r   rd  {  re  z7InterfaceClassTests.test___contains___hit.<locals>._barr   r@   rf  rg  rS   r.   )r    rF  ra  r?   r   r  r   r   r   test___contains___hitx  s   z)InterfaceClassTests.test___contains___hitc                 C   rW   rK   )r?   r"   directr  r   r   r   test_direct_miss  r[   z$InterfaceClassTests.test_direct_missc           	      C   s   ddl m} ddl m} dd }dd }|dd	||d
}|||dd	d}| jd|d}| jd|f|d}| |d|d  | |d|d  | |dd  d S )Nr   rE  r`  c                   S   r   rb  r   r   r   r   r   rd    re  zBInterfaceClassTests.test_direct_hit_local_miss_bases.<locals>._barc                   S   r   rb  r   r   r   r   r   r    re  zBInterfaceClassTests.test_direct_hit_local_miss_bases.<locals>._foor   r@   rf  r  r  r  rg  r  r  rS   r/   r.   )r    rF  ra  r?   r"   r  r  r   r   r    test_direct_hit_local_miss_bases  s   z4InterfaceClassTests.test_direct_hit_local_miss_basesc                 C   rW   rK   )r?   r"   queryDescriptionForr   r   r   r   test_queryDescriptionFor_miss  r[   z1InterfaceClassTests.test_queryDescriptionFor_missc                 C   s@   ddl m} d|ddi}| j|d}| |d|d  d S )Nr   rE  attrTitleDescriptionrg  )r   rF  r?   r"   r  )r%   rF  rj  r   r   r   r   test_queryDescriptionFor_hit  s   z0InterfaceClassTests.test_queryDescriptionFor_hitc                    sV   g   fdd}|   }t }|d|g | ||d  |  |fi fg d S )Nc                          | |f dS r   r  r   _called_withr   r   	_passable     zCInterfaceClassTests.test_validateInvariants_pass.<locals>._passabler   )r?   r!   rU   r"   validateInvariants)r%   r  r   rz   r   r  r   test_validateInvariants_pass  s   z0InterfaceClassTests.test_validateInvariants_passc                    s   ddl m  g fdd}g  fdd}|  }t }|d||g |  |j| | |fi fg | |fi fg d S )Nr   Invalidc                     r  r   r  r   _passable_called_withr   r   r    r  zTInterfaceClassTests.test_validateInvariants_fail_wo_errors_passed.<locals>._passablec                         | |f  r   r  r   r  _fail_called_withr   r   _fail  r  zPInterfaceClassTests.test_validateInvariants_fail_wo_errors_passed.<locals>._failr   ry  r  r?   r!   rU   rM   r  r"   )r%   r  r  r   rz   r   r  r  r  r   -test_validateInvariants_fail_wo_errors_passed  s   zAInterfaceClassTests.test_validateInvariants_fail_wo_errors_passedc                    s   ddl m  g }g  fdd}|  }t }|d|g |  |j|| | |fi fg | t|d | 	t
|d   d S )Nr   r  c                     r  r   r  r   r  r   r   r    r  zOInterfaceClassTests.test_validateInvariants_fail_w_errors_passed.<locals>._failr   r$  ry  r  r?   r!   rU   rM   r  r"   r  r   
isinstance)r%   _errorsr  r   rz   r   r  r   ,test_validateInvariants_fail_w_errors_passed  s   z@InterfaceClassTests.test_validateInvariants_fail_w_errors_passedc                    s   ddl m  g fdd}g  fdd}| d}| d|f}t }|d	|g |d	|g |  |j| | |fi fg | |fi fg d S )
Nr   r  c                     r  r   r  r   r  r   r   r    r  z\InterfaceClassTests.test_validateInvariants_fail_in_base_wo_errors_passed.<locals>._passablec                     r  r   r  r   r  r   r   r    r  zXInterfaceClassTests.test_validateInvariants_fail_in_base_wo_errors_passed.<locals>._failr  r  r   r  )r%   r  r  r  r  rz   r   r  r   5test_validateInvariants_fail_in_base_wo_errors_passed  s   
zIInterfaceClassTests.test_validateInvariants_fail_in_base_wo_errors_passedc                    s   ddl m  g }g fdd}g  fdd}| d}| d|f}t }|d	|g |d	|g |  |j|| | |fi fg | |fi fg | t|d
 | 	t
|d   d S )Nr   r  c                     r  r   r  r   r  r   r   r    r  z[InterfaceClassTests.test_validateInvariants_fail_in_base_w_errors_passed.<locals>._passablec                     r  r   r  r   r  r   r   r    r  zWInterfaceClassTests.test_validateInvariants_fail_in_base_w_errors_passed.<locals>._failr  r  r   r$  r  )r%   r  r  r  r  r  rz   r   r  r   4test_validateInvariants_fail_in_base_w_errors_passed  s    
zHInterfaceClassTests.test_validateInvariants_fail_in_base_w_errors_passedc                    sZ   g   fdd}t  }| d}|d|g | d|f}|| | dt  d S )Nc                     r  r   r  r   r  r   r   r    r  zbInterfaceClassTests.test_validateInvariants_inherited_not_called_multiple_times.<locals>._passabler  r   r  r$  )r!   r?   rU   r  r"   r  )r%   r  rz   r  r  r   r  r   ;test_validateInvariants_inherited_not_called_multiple_times  s   

zOInterfaceClassTests.test_validateInvariants_inherited_not_called_multiple_timesc                 C   s   |  d}| | d d S )NPickleMe)r?   r"   
__reduce__r   r   r   r   test___reduce__  s   
z#InterfaceClassTests.test___reduce__c                 C   s"   |  d}| t|td d S )NHashMe)r  z#zope.interface.tests.test_interface)r?   r"   hashr   r   r   r   test___hash___normal  s   

z(InterfaceClassTests.test___hash___normalc                 C   sR   G dd d|   }| }| t t| W d    d S 1 s"w   Y  d S )Nc                   @   r   )zIInterfaceClassTests.test___hash___missing_required_attrs.<locals>.Derivedc                 S   r  r   r   rq   r   r   r   r     r|   zRInterfaceClassTests.test___hash___missing_required_attrs.<locals>.Derived.__init__Nr   r   r   r   r   Derived  r   r  )r;   rM   r   r  )r%   r  r  r   r   r   $test___hash___missing_required_attrs  s
   
"z8InterfaceClassTests.test___hash___missing_required_attrsc                 C   s   |   }| |d k  | |d k | |d k | |d k | |d k | |d k | d |k  | d |k | d |k | d |k | d |k | d |k d S r   r?   r   r   r   r   r   r   test_comparison_with_None  s   z-InterfaceClassTests.test_comparison_with_Nonec                 C   s`   |   }| ||k  | ||k | ||k | ||k | ||k | ||k d S r   )r?   r   r   r   r   r   r   "test_comparison_with_same_instance*  s   z6InterfaceClassTests.test_comparison_with_same_instancec                 C   s   | j ddd}| j ddd}| ||k  | ||k  | ||k | ||k | ||k | ||k | ||k | ||k | ||k | ||k | ||k | ||k d S )NINamezzope.interface.tests.oner   zzope.interface.tests.otherr  )r%   r  r   r   r   r   8test_comparison_with_same_named_instance_in_other_module5  s   zLInterfaceClassTests.test_comparison_with_same_named_instance_in_other_modulec                    s   G dd dt  G  fddd|  }| d}| ||   | t||   | t |d W d    n1 s?w   Y  ||_| || | t|| |   |d W d    d S 1 sjw   Y  d S )Nc                   @   r   )zDInterfaceClassTests.test_assignment_to__class__.<locals>.MyExceptionNr   r   r   r   r   r   I  r   r   c                       r   )zIInterfaceClassTests.test_assignment_to__class__.<locals>.MyInterfaceClassc                    s    |r   r   )r%   targetr   r   r   __call__M  r   zRInterfaceClassTests.test_assignment_to__class__.<locals>.MyInterfaceClass.__call__Nr   r   r   r  r   r  r   r   MyInterfaceClassL  r0   r  r  r$  )	r   r;   r?   assertIsInstancer   typerM   r   	__class__)r%   r  r8  r   r  r   test_assignment_to__class__G  s   


"z/InterfaceClassTests.test_assignment_to__class__c                 C   s   ddl m} G dd d|  }|d|f}| |dd G dd	 d	|}| |dd G d
d d|}| t |  W d    n1 sIw   Y  ||_| |dd d S )Nr   r  c                   @   r   )zJInterfaceClassTests.test_assignment_to__class__2.<locals>.MyInterfaceClassc                 W   r  r   r   )r%   r   r   r   r   r  d  r|   zSInterfaceClassTests.test_assignment_to__class__2.<locals>.MyInterfaceClass.__call__Nr  r   r   r   r   r  c  r   r  r8  r$  )r$  c                   @   r   )z>InterfaceClassTests.test_assignment_to__class__2.<locals>.IBarNr   r   r   r   r   rI  j  r   rI  c                   @   r   )z?InterfaceClassTests.test_assignment_to__class__2.<locals>.ISpamNr   r   r   r   r   ISpamo  r   r  )r   r  r;   r"   rM   r   r  )r%   r  r  r8  rI  r  r   r   r   test_assignment_to__class__2^  s   z0InterfaceClassTests.test_assignment_to__class__2c                 C   sB   |   }| ttf d|_W d    d S 1 sw   Y  d S )Nzdifferent.module)r?   rM   r   r   r   )r%   r^  r   r   r   test__module__is_readonlyx  s   "z-InterfaceClassTests.test__module__is_readonly)rY  r   NNN)4r   r   r   r;   r?   rH   r_  rk  rp  rs  rv  rz  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  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   rV  ^  sh    
		
rV  c                   @   s  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"dAdB Z#dCdD Z$dEdF Z%e&dGdH Z'dIdJ Z(dKdL Z)dMdN Z*dOdP Z+dQdR Z,dSdT Z-dUdV Z.dWdX Z/dYdZ Z0d[d\ Z1d]d^ Z2d_d` Z3dadb Z4dcdd Z5dedf Z6dgdh Z7didj Z8dkS )lInterfaceTestsc                    sD   ddl m} ddl m  G  fddd|}| |d j|u  d S )Nr   r  rE  c                       rG  )z<InterfaceTests.test_attributes_link_to_interface.<locals>.I1My attrN)r   r   r   r  r   rE  r   r   I1  r   r  r  )r   r  rF  r   ru   r%   r  r  r   rE  r   !test_attributes_link_to_interface  s   z0InterfaceTests.test_attributes_link_to_interfacec                 C   s4   ddl m} G dd d|}| |d j|u  d S )Nr   r  c                   @   r   )z9InterfaceTests.test_methods_link_to_interface.<locals>.I1c                 S   r   zA methodNr   )rS   r.   bingor   r   r   method  re  z@InterfaceTests.test_methods_link_to_interface.<locals>.I1.methodNr   r   r   r  r   r   r   r   r        r  r  )r   r  r   ru   r  r   r   r   test_methods_link_to_interface  s   z-InterfaceTests.test_methods_link_to_interfacec                    s   ddl m} ddl m} ddl m} G dd d| G dd d|}G  fd	d
d
t}| }|  | | || |    |  ||v  | |||v  |  ||v  | |||v  d S )Nr   r  r   r}   c                   @   r   )z<InterfaceTests.test_classImplements_simple.<locals>.ICurrentc                 S   r  r   r   r   r   r   r   r   method1  r|   zDInterfaceTests.test_classImplements_simple.<locals>.ICurrent.method1c                 S   r  r   r   r  r   r   r   method2  r|   zDInterfaceTests.test_classImplements_simple.<locals>.ICurrent.method2N)r   r   r   r  r  r   r   r   r   ICurrent      r  c                   @   r   )z:InterfaceTests.test_classImplements_simple.<locals>.IOtherNr   r   r   r   r   rP    r   rP  c                       s    e Zd Z Zdd Zdd ZdS )z;InterfaceTests.test_classImplements_simple.<locals>.Currentc                 S   r   r   r   r%   r   r   r   r   r   r    r   zCInterfaceTests.test_classImplements_simple.<locals>.Current.method1c                 S   r   r   r   r  r   r   r   r    r   zCInterfaceTests.test_classImplements_simple.<locals>.Current.method2N)r   r   r   __implemented__r  r  r   r  r   r   Current  s    r  )r   r  r   r~   r!   r   r   r"   )r%   r  r   r~   rP  r  currentr   r   r   test_classImplements_simple  s   z*InterfaceTests.test_classImplements_simplec                    s   ddl m} ddl m} ddl m} G dd d| G dd d }G  fd	d
d
}| }|  | | || |  ||v  | |||v  |  ||v  | |||v  d S )Nr   r  r   r}   c                   @   r   )zCInterfaceTests.test_classImplements_base_not_derived.<locals>.IBasec                   S   r  r   r   r   r   r   r   r    r|   zJInterfaceTests.test_classImplements_base_not_derived.<locals>.IBase.methodNr  r   r   r   r   r    r   r  c                   @   r   )zFInterfaceTests.test_classImplements_base_not_derived.<locals>.IDerivedNr   r   r   r   r   r    r   r  c                          e Zd Z Zdd ZdS )zEInterfaceTests.test_classImplements_base_not_derived.<locals>.Currentc                 S   r   r   r   rq   r   r   r   r    r   zLInterfaceTests.test_classImplements_base_not_derived.<locals>.Current.methodN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   %test_classImplements_base_not_derived  s   z4InterfaceTests.test_classImplements_base_not_derivedc                    s   ddl m} ddl m} ddl m} G dd d|}G dd d| G  fd	d
d
t}| }| || |  | | |||v  | ||| v  |  ||v  | |||v  | ||| v  |  ||v  d S )Nr   r  r   r}   c                   @   r   )zCInterfaceTests.test_classImplements_base_and_derived.<locals>.IBasec                   S   r  r   r   r   r   r   r   r    r|   zJInterfaceTests.test_classImplements_base_and_derived.<locals>.IBase.methodNr  r   r   r   r   r    r   r  c                   @   r   )zFInterfaceTests.test_classImplements_base_and_derived.<locals>.IDerivedNr   r   r   r   r   r    r   r  c                       r  )zEInterfaceTests.test_classImplements_base_and_derived.<locals>.Currentc                 S   r   r   r   rq   r   r   r   r    r   zLInterfaceTests.test_classImplements_base_and_derived.<locals>.Current.methodNr  r   r  r   r   r    r  r  )r   r  r   r~   r!   r   r   	flattened)r%   r  r   r~   r  r  r  r   r	  r   %test_classImplements_base_and_derived  s   z4InterfaceTests.test_classImplements_base_and_derivedc                    s   ddl m} ddl m} ddl m} G dd d| G dd d G  fd	d
d
t}G fdddt}G dd d||}| }|  | | | |  ||v  | ||v  |  ||v  | ||v  d S )Nr   r  r   r}   c                   @   r   )z;InterfaceTests.test_classImplements_multiple.<locals>.ILeftc                   S   r  r   r   r   r   r   r   r    r|   zBInterfaceTests.test_classImplements_multiple.<locals>.ILeft.methodNr  r   r   r   r   ILeft  r   r  c                   @   r   )z<InterfaceTests.test_classImplements_multiple.<locals>.IRightNr   r   r   r   r   IRight  r   r  c                       r  )z:InterfaceTests.test_classImplements_multiple.<locals>.Leftc                 S   r   r   r   rq   r   r   r   r    r   zAInterfaceTests.test_classImplements_multiple.<locals>.Left.methodNr  r   r  r   r   Left      r  c                          e Zd Z ZdS )z;InterfaceTests.test_classImplements_multiple.<locals>.RightNr   r   r   r  r   r  r   r   Right      r  c                   @   r   )z:InterfaceTests.test_classImplements_multiple.<locals>.AmbiNr   r   r   r   r   Ambi  r   r  )r   r  r   r~   r!   r   )r%   r  r   r~   r  r  r  ambir   )r  r  r   test_classImplements_multiple  s   z,InterfaceTests.test_classImplements_multiplec                    sL  ddl m} ddl m} ddl m} G dd d| G dd d G d	d
 d
|G  fdddG fdddt}G fdddtG fddd|}| }|  | | | | | |  ||v  | ||v  | ||v  |  ||v  | ||v  | ||v  d S )Nr   r  r   r}   c                   @   r   )zPInterfaceTests.test_classImplements_multiple_w_explict_implements.<locals>.ILeftc                   S   r  r   r   r   r   r   r   r    r|   zWInterfaceTests.test_classImplements_multiple_w_explict_implements.<locals>.ILeft.methodNr  r   r   r   r   r    r  r  c                   @   r   )zQInterfaceTests.test_classImplements_multiple_w_explict_implements.<locals>.IRightNr   r   r   r   r   r    r   r  c                   @   r   )zQInterfaceTests.test_classImplements_multiple_w_explict_implements.<locals>.IOtherNr   r   r   r   r   rP    r   rP  c                       r  )zOInterfaceTests.test_classImplements_multiple_w_explict_implements.<locals>.Leftc                 S   r   r   r   rq   r   r   r   r    r   zVInterfaceTests.test_classImplements_multiple_w_explict_implements.<locals>.Left.methodNr  r   r  r   r   r    r  r  c                       r  )zPInterfaceTests.test_classImplements_multiple_w_explict_implements.<locals>.RightNr  r   r  r   r   r    r  r  c                       r  )zPInterfaceTests.test_classImplements_multiple_w_explict_implements.<locals>.OtherNr  r   )rP  r   r   Other   r  r  c                       s   e Zd Z jjfZdS )zPInterfaceTests.test_classImplements_multiple_w_explict_implements.<locals>.MixedNr  r   )r  r  r   r   Mixed#  r0   r  )r   r  r   r~   r!   r   r   )r%   r  r   r~   r  r  mixedr   )r  rP  r  r  r  r   2test_classImplements_multiple_w_explict_implements  s(   zAInterfaceTests.test_classImplements_multiple_w_explict_implementsc                 C   s   ddl m} |j}|d}|d|f}|d}|d||f}| || | || | || | || | || | || | || d S )Nr   r  FunInterfaceBarInterfaceBobInterfaceBazInterface)r   r  r  r   r>  r   )r%   r  newr  r  r  r   r   r   r   testInterfaceExtendsInterface2  s   z,InterfaceTests.testInterfaceExtendsInterfacec                    s`   ddl m  ddl m} ddlm} G  fddd|G fdddt}| || d S )	Nr   rE  r  )verifyClassc                          e Zd Z dZdd ZdS )z1InterfaceTests.test_verifyClass.<locals>.ICheckMer  c                   S   r   r  r   r   r   r   r   r  L  re  z8InterfaceTests.test_verifyClass.<locals>.ICheckMe.methodNr   r   r   r  r  r   rE  r   r   ICheckMeI  r  r&  c                          e Zd Z ZdZdd ZdS )z0InterfaceTests.test_verifyClass.<locals>.CheckMevaluec                 S   r   r   r   rq   r   r   r   r  S  r   z7InterfaceTests.test_verifyClass.<locals>.CheckMe.methodNr   r   r   r  r  r  r   r&  r   r   CheckMeO      r+  )r   rF  r  rk   r#  r!   r   )r%   r  r#  r+  r   rF  r&  r   test_verifyClassC  s   zInterfaceTests.test_verifyClassc                    sf   ddl m  ddl m} ddlm} G  fddd|G fdddt}| }| || d S )	Nr   rE  r  rh   c                       r$  )z2InterfaceTests.test_verifyObject.<locals>.ICheckMer  c                   S   r   r  r   r   r   r   r   r  a  re  z9InterfaceTests.test_verifyObject.<locals>.ICheckMe.methodNr%  r   rE  r   r   r&  ^  r  r&  c                       r'  )z1InterfaceTests.test_verifyObject.<locals>.CheckMer(  c                 S   r   r   r   rq   r   r   r   r  h  r   z8InterfaceTests.test_verifyObject.<locals>.CheckMe.methodNr)  r   r*  r   r   r+  d  r,  r+  )r   rF  r  rk   ri   r!   r   )r%   r  ri   r+  check_mer   r-  r   test_verifyObjectX  s   z InterfaceTests.test_verifyObjectc                 C   s0   ddl m} G dd d|}| || d S )Nr   r  c                   @   r   )zLInterfaceTests.test_interface_object_provides_Interface.<locals>.AnInterfaceNr   r   r   r   r   AnInterfacer  r   r1  )r   r  r   r~   )r%   r  r1  r   r   r   (test_interface_object_provides_Interfaceo     z7InterfaceTests.test_interface_object_provides_Interfacec                    sH   ddl m  ddl m} G  fddd|}| t| ddg d S )Nr   rE  r  c                       r$  )z1InterfaceTests.test_names_simple.<locals>.ISimpler  c                   S   r  r   r   r   r   r   r   r    r|   z8InterfaceTests.test_names_simple.<locals>.ISimple.methodNr%  r   rE  r   r   ISimple|  r  r4  r  r  r   rF  r  r"   r  rh  r%   r  r4  r   rE  r   test_names_simplew     z InterfaceTests.test_names_simplec                    sx   ddl m  ddl m} G  fddd|}G  fddd|}| t| g d | t|jd	d
g d d S )Nr   rE  r  c                       r$  )z0InterfaceTests.test_names_derived.<locals>.IBaser  c                   S   r  r   r   r   r   r   r   r    r|   z7InterfaceTests.test_names_derived.<locals>.IBase.methodNr%  r   rE  r   r   r    r  r  c                       $   e Zd Z dZdd Zdd ZdS )z3InterfaceTests.test_names_derived.<locals>.IDerivedMy attr2c                   S   r  r   r   r   r   r   r   r    r|   z:InterfaceTests.test_names_derived.<locals>.IDerived.methodc                   S   r  r   r   r   r   r   r   r    r|   z;InterfaceTests.test_names_derived.<locals>.IDerived.method2Nr   r   r   attr2r  r  r   rE  r   r   r        r  )r<  r  r  Tr  r  r<  r  r  r5  r%   r  r  r  r   rE  r   test_names_derived  s   	z!InterfaceTests.test_names_derivedc                    s  ddl m  ddlm} ddl m} G  fddd|}t| }| t|d | |d d d | 	t
|d d	   | |d d	 jd | |d d	 jd
 | |d	 d d | 	t
|d	 d	 | | |d	 d	 jd | |d	 d	 jd d S )Nr   rE  Methodr  c                       r$  )z@InterfaceTests.test_namesAndDescriptions_simple.<locals>.ISimpler  c                   S   r   	My methodNr   r   r   r   r   r    re  zGInterfaceTests.test_namesAndDescriptions_simple.<locals>.ISimple.methodNr%  r   rE  r   r   r4    r  r4  r  r  r$  r  r  rD  )r   rF  r    rB  r  r  r  r"   r  r   r  r   rB   )r%   rB  r  r4  name_valuesr   rE  r    test_namesAndDescriptions_simple  s   z/InterfaceTests.test_namesAndDescriptions_simplec                    s  ddl m  ddl m} ddlm} G  fddd|}G  fddd|}t| }| t|d	 | |d d d
 | 	t
|d d   | |d d jd
 | |d d jd | |d d d | 	t
|d d | | |d d jd | |d d jd | |d d d | 	t
|d d | | |d d jd | |d d jd t|jdd}| t|d | |d d d | 	t
|d d   | |d d jd | |d d jd | |d d d
 | 	t
|d d   | |d d jd
 | |d d jd | |d d d | 	t
|d d | | |d d jd | |d d jd | |d	 d d | 	t
|d	 d | | |d	 d jd | |d	 d jd d S )Nr   rE  r  rA  c                       r$  )z?InterfaceTests.test_namesAndDescriptions_derived.<locals>.IBaser  c                   S   r   rC  r   r   r   r   r   r    re  zFInterfaceTests.test_namesAndDescriptions_derived.<locals>.IBase.methodNr%  r   rE  r   r   r    r  r  c                       r9  )zBInterfaceTests.test_namesAndDescriptions_derived.<locals>.IDerivedr:  c                   S   r   My method, overriddenNr   r   r   r   r   r    re  zIInterfaceTests.test_namesAndDescriptions_derived.<locals>.IDerived.methodc                   S   r   
My method2Nr   r   r   r   r   r    re  zJInterfaceTests.test_namesAndDescriptions_derived.<locals>.IDerived.method2Nr;  r   rE  r   r   r    r=  r     r<  r$  r:  r  rH  r  r  rJ  Tr     r  r  )r   rF  r  r    rB  r  r  r"   r  r   r  r   rB   )r%   r  rB  r  r  rE  r   rE  r   !test_namesAndDescriptions_derived  sJ   	z0InterfaceTests.test_namesAndDescriptions_derivedc                 C   0   ddl m} G dd d|}| t|jd d S )Nr   r  c                   @   r   )zIInterfaceTests.test_getDescriptionFor_nonesuch_no_default.<locals>.IEmptyNr   r   r   r   r   IEmpty  r   rO  rL   )r   r  rM   rN   r  r%   r  rO  r   r   r   *test_getDescriptionFor_nonesuch_no_default  r3  z9InterfaceTests.test_getDescriptionFor_nonesuch_no_defaultc                    s   ddl m  ddlm} ddl m} G  fddd|}|d}| t|  | |j	d | |j
d |d	}| t|| | |j	d	 | |j
d
 d S )Nr   rE  rA  r  c                       r$  )z=InterfaceTests.test_getDescriptionFor_simple.<locals>.ISimpler  c                   S   r   rC  r   r   r   r   r   r    re  zDInterfaceTests.test_getDescriptionFor_simple.<locals>.ISimple.methodNr%  r   rE  r   r   r4    r  r4  r  r  r  rD  r   rF  r    rB  r  r  r   r  r"   r   rB   r%   rB  r  r4  a_descm_descr   rE  r   test_getDescriptionFor_simple  s   

z,InterfaceTests.test_getDescriptionFor_simplec           	         s(  ddl m  ddlm} ddl m} G  fddd|}G  fddd|}|d	}| t|  | |j	d	 | |j
d
 |d}| t|| | |j	d | |j
d |d}| t|  | |j	d | |j
d |d}| t|| | |j	d | |j
d d S )Nr   rE  rA  r  c                       r$  )z<InterfaceTests.test_getDescriptionFor_derived.<locals>.IBaser  c                   S   r   rC  r   r   r   r   r   r    re  zCInterfaceTests.test_getDescriptionFor_derived.<locals>.IBase.methodNr%  r   rE  r   r   r    r  r  c                       r9  )z?InterfaceTests.test_getDescriptionFor_derived.<locals>.IDerivedr:  c                   S   r   rG  r   r   r   r   r   r    re  zFInterfaceTests.test_getDescriptionFor_derived.<locals>.IDerived.methodc                   S   r   rI  r   r   r   r   r   r    re  zGInterfaceTests.test_getDescriptionFor_derived.<locals>.IDerived.method2Nr;  r   rE  r   r   r    r=  r  r  r  r  rH  r<  r:  r  rJ  rR  	r%   rB  r  r  r  rT  rU  a2_descm2_descr   rE  r   test_getDescriptionFor_derived  s*   
	


z-InterfaceTests.test_getDescriptionFor_derivedc                 C   rN  )Nr   r  c                   @   r   )z7InterfaceTests.test___getitem__nonesuch.<locals>.IEmptyNr   r   r   r   r   rO  8  r   rO  rL   )r   r  rM   rN   __getitem__rP  r   r   r   test___getitem__nonesuch5  r3  z'InterfaceTests.test___getitem__nonesuchc                    s   ddl m  ddlm} ddl m} G  fddd|}|d }| t|  | |jd | |j	d |d	 }| t|| | |jd	 | |j	d
 d S )Nr   rE  rA  r  c                       r$  )z6InterfaceTests.test___getitem__simple.<locals>.ISimpler  c                   S   r   rC  r   r   r   r   r   r  F  re  z=InterfaceTests.test___getitem__simple.<locals>.ISimple.methodNr%  r   rE  r   r   r4  C  r  r4  r  r  r  rD  
r   rF  r    rB  r  r   r  r"   r   rB   rS  r   rE  r   test___getitem__simple=  s   z%InterfaceTests.test___getitem__simplec           	         s   ddl m  ddlm} ddl m} G  fddd|}G  fddd|}|d	 }| t|  | |jd	 | |j	d
 |d }| t|| | |jd | |j	d |d }| t|  | |jd | |j	d |d }| t|| | |jd | |j	d d S )Nr   rE  rA  r  c                       r$  )z6InterfaceTests.test___getitem___derived.<locals>.IBaser  c                   S   r   rC  r   r   r   r   r   r  \  re  z=InterfaceTests.test___getitem___derived.<locals>.IBase.methodNr%  r   rE  r   r   r  Y  r  r  c                       r9  )z9InterfaceTests.test___getitem___derived.<locals>.IDerivedr:  c                   S   r   rG  r   r   r   r   r   r  b  re  z@InterfaceTests.test___getitem___derived.<locals>.IDerived.methodc                   S   r   rI  r   r   r   r   r   r  e  re  zAInterfaceTests.test___getitem___derived.<locals>.IDerived.method2Nr;  r   rE  r   r   r  _  r=  r  r  r  r  rH  r<  r:  r  rJ  r]  rW  r   rE  r   test___getitem___derivedS  s*   	z'InterfaceTests.test___getitem___derivedc                 C   s.   ddl m} G dd d|}| d|v  d S )Nr   r  c                   @   r   )z8InterfaceTests.test___contains__nonesuch.<locals>.IEmptyNr   r   r   r   r   rO    r   rO  rL   )r   r  r   rP  r   r   r   test___contains__nonesuch|  s   z(InterfaceTests.test___contains__nonesuchc                    sL   ddl m  ddl m} G  fddd|}| d|v  | d|v  d S )Nr   rE  r  c                       r$  )z7InterfaceTests.test___contains__simple.<locals>.ISimpler  c                   S   r   rC  r   r   r   r   r   r    re  z>InterfaceTests.test___contains__simple.<locals>.ISimple.methodNr%  r   rE  r   r   r4    r  r4  r  r  r   rF  r  r   r6  r   rE  r   test___contains__simple  s
   z&InterfaceTests.test___contains__simplec                    s|   ddl m  ddl m} G  fddd|}G  fddd|}| d|v  | d	|v  | d
|v  | d|v  d S )Nr   rE  r  c                       r$  )z6InterfaceTests.test___contains__derived.<locals>.IBaser  c                   S   r   rC  r   r   r   r   r   r    re  z=InterfaceTests.test___contains__derived.<locals>.IBase.methodNr%  r   rE  r   r   r    r  r  c                       r9  )z9InterfaceTests.test___contains__derived.<locals>.IDerivedr:  c                   S   r   rG  r   r   r   r   r   r    re  z@InterfaceTests.test___contains__derived.<locals>.IDerived.methodc                   S   r   rI  r   r   r   r   r   r    re  zAInterfaceTests.test___contains__derived.<locals>.IDerived.method2Nr;  r   rE  r   r   r    r=  r  r  r  r<  r  ra  r?  r   rE  r   test___contains__derived  s   	z'InterfaceTests.test___contains__derivedc                 C   s0   ddl m} G dd d|}| t|g  d S )Nr   r  c                   @   r   )z1InterfaceTests.test___iter__empty.<locals>.IEmptyNr   r   r   r   r   rO    r   rO  )r   r  r"   rD   rP  r   r   r   test___iter__empty  r3  z!InterfaceTests.test___iter__emptyc                    sH   ddl m  ddl m} G  fddd|}| tt|ddg d S )Nr   rE  r  c                       r$  )z3InterfaceTests.test___iter__simple.<locals>.ISimpler  c                   S   r   rC  r   r   r   r   r   r    re  z:InterfaceTests.test___iter__simple.<locals>.ISimple.methodNr%  r   rE  r   r   r4    r  r4  r  r  r   rF  r  r"   r  rD   r6  r   rE  r   test___iter__simple  r8  z"InterfaceTests.test___iter__simplec                    s\   ddl m  ddl m} G  fddd|}G  fddd|}| tt|g d d S )	Nr   rE  r  c                       r$  )z2InterfaceTests.test___iter__derived.<locals>.IBaser  c                   S   r   rC  r   r   r   r   r   r    re  z9InterfaceTests.test___iter__derived.<locals>.IBase.methodNr%  r   rE  r   r   r    r  r  c                       r9  )z5InterfaceTests.test___iter__derived.<locals>.IDerivedr:  c                   S   r   rG  r   r   r   r   r   r    re  z<InterfaceTests.test___iter__derived.<locals>.IDerived.methodc                   S   r   rI  r   r   r   r   r   r    re  z=InterfaceTests.test___iter__derived.<locals>.IDerived.method2Nr;  r   rE  r   r   r    r=  r  r>  re  r?  r   rE  r   test___iter__derived  s   	z#InterfaceTests.test___iter__derivedc                 C   s:   ddl m} G dd d|}|d }| |dd d S )Nr   r  c                   @   s   e Zd Zdd Zde_dS )zLInterfaceTests.test_function_attributes_become_tagged_values.<locals>.ITagMec                   S   r  r   r   r   r   r   r   r    r|   zSInterfaceTests.test_function_attributes_become_tagged_values.<locals>.ITagMe.methodr$  N)r   r   r   r  optionalr   r   r   r   ITagMe  s    
ri  r  rh  r$  )r   r  r"   rO   )r%   r  ri  r  r   r   r   -test_function_attributes_become_tagged_values  s   z<InterfaceTests.test_function_attributes_become_tagged_valuesc                 C   s>   ddl m} G dd d|}| |jd | t|g  d S )Nr   r  c                   @      e Zd ZdZdS )z@InterfaceTests.test___doc___non_element.<locals>.IHaveADocStringxxxNr   r   r   rB   r   r   r   r   IHaveADocString  r  rn  rl  )r   r  r"   rB   rD   r%   r  rn  r   r   r   test___doc___non_element  s   z'InterfaceTests.test___doc___non_elementc                    sP   ddl m  ddl m} G  fddd|}| |jd | t|dg d S )Nr   rE  r  c                          e Zd ZdZ dZdS )z?InterfaceTests.test___doc___as_element.<locals>.IHaveADocStringrl  the docNrm  r   rE  r   r   rn    r  rn  r@   rB   )r   rF  r  r"   rB   rD   ro  r   rE  r   test___doc___as_element  s
   z&InterfaceTests.test___doc___as_elementc           
   
   C   s   ddl m} | ||j| g }z||| | d W n |y8 } z| |jd | W Y d }~nd }~ww | t|| dd |D }|  |D ]}	| |	|	d qNd S )Nr   r  z&validateInvariants should always raisec                 S   s   g | ]}|j d  qS )r   r   ).0errorr   r   r   
<listcomp>  s    z/InterfaceTests._errorsEqual.<locals>.<listcomp>)
ry  r  rM   r  failr"   r   r  sortpop)
r%   has_invariant	error_len
error_msgsr   r  erv  msgsmsgr   r   r   _errorsEqual  s    zInterfaceTests._errorsEqualc                    s   ddl m  ddl m} ddl m} ddl m G  fddd|}G dd	 d	t}| }||| | |d
tg | |	|d  d|_
| |	|d  d|_| |	|d  |`
| |ddg| d S )Nr   rE  r  directlyProvidesr   c                       $   e Zd Z dZ dZe dS )z8InterfaceTests.test_invariant_simple.<locals>.IInvariantrS   *bar; must eval to Boolean True if foo doesNr   r   r   rS   r.   _ifFooThenBarr   rF  r	   r   r   
IInvariant      r  c                   @   r   )z:InterfaceTests.test_invariant_simple.<locals>.HasInvariantNr   r   r   r   r   HasInvariant  r   r  r      *   r$  If Foo, then Bar!)r   rF  r  r  r	   r!   r"   rO   r  r  r.   rS   r  )r%   r  r  r  r  r{  r   r  r   test_invariant_simple  s(   
z$InterfaceTests.test_invariant_simplec                    s  ddl m  ddl m} ddl m} ddl m G  fddd|}G fdd	d	|}G d
d dt}| |dtg | }||| d|_	| 
|ddg| d|_	d|_| 
|ddg| d|_	d|_| 
|dddg| d|_	d|_| ||d  d S )Nr   rE  r  r  r   c                       r  )z8InterfaceTests.test_invariant_nested.<locals>.IInvariantrS   r  Nr  r   r  r   r   r  *  r  r  c                       s   e Zd Z e dS )z;InterfaceTests.test_invariant_nested.<locals>.ISubInvariantN)r   r   r   _barGreaterThanFoor   r   r   r   ISubInvariant/  r   r  c                   @   r   )z:InterfaceTests.test_invariant_nested.<locals>.HasInvariantNr   r   r   r   r   r  2  r   r  r   r  r$  r  r  %Please, Boo MUST be greater than Foo!)r   rF  r  r  r	   r!   r"   rO   r  rS   r  r.   r  )r%   r  r  r  r  r  r{  r   r  r   test_invariant_nested$  sB   
z$InterfaceTests.test_invariant_nestedc                    s  ddl m  ddl m} ddl m} ddl m G  fddd|}G dd	 d	t}| }||| d
|_|d}|d d  }|t	 |
d| | |ddg| d|_d|_| |ddg| d|_d|_| |dddg| d|_d|_| ||d  |
d| d S )Nr   rE  r  r  r   c                       r  )z:InterfaceTests.test_invariant_mutandis.<locals>.IInvariantrS   r  Nr  r   r  r   r   r  Y  r  r  c                   @   r   )z<InterfaceTests.test_invariant_mutandis.<locals>.HasInvariantNr   r   r   r   r   r  ^  r   r  r  r   r$  r  r  r  )r   rF  r  r  r	   r!   rS   rO   r  r  rU   r  r.   r"   r  )r%   r  r  r  r  r{  old_invariantsr   r   r  r   test_invariant_mutandisS  sB   


z&InterfaceTests.test_invariant_mutandisc                    s~   ddl m} ddl m  G dd d|}| |jd | t|g  G  fddd|}| |jd	 | t|d
g d S )Nr   r  rE  c                   @   rk  )z7InterfaceTests.test___doc___element.<locals>.IDocstringrl  Nrm  r   r   r   r   
IDocstring  r  r  rl  c                       rq  )zCInterfaceTests.test___doc___element.<locals>.IDocstringAndAttributerl  rr  Nrm  r   rE  r   r   IDocstringAndAttribute  r  r  r@   rB   )r   r  rF  r"   rB   rD   )r%   r  r  r  r   rE  r   test___doc___element  s   z#InterfaceTests.test___doc___elementc                 C   s>   ddl m} G dd d|}G dd d}| t|j| d S )Nr   r  c                   @   rk  )z&InterfaceTests.testIssue228.<locals>.Irl  Nrm  r   r   r   r   r/    r  r/  c                   @   s   e Zd ZdZdS )z-InterfaceTests.testIssue228.<locals>.OldStyleN)r   r   r   __providedBy__r   r   r   r   OldStyle  r  r  )r   r  rM   r   r~   )r%   r  r/  r  r   r   r   testIssue228  s   zInterfaceTests.testIssue228c              
      s   ddl m} ddl m  ddl m} ddl m ddlm G  fddd|}||G d	d
 d
t}||dd ||dd z||dd W d S  yl } z| 	t
|d W Y d }~d S d }~ww )Nr   r  rE  rK  r   r  c                       s,   e Zd Z dZ dZfddZdS )z:InterfaceTests.test_invariant_as_decorator.<locals>.IRangezLower boundzUpper boundc                    s   | j | jk r
 dd S )N	max < min)maxmin)obr  r   r   range_invariant  s   zJInterfaceTests.test_invariant_as_decorator.<locals>.IRange.range_invariantN)r   r   r   r  r  r  r   rF  r  r	   r   r   IRange  s
    r  c                   @   r   )z9InterfaceTests.test_invariant_as_decorator.<locals>.Rangec                 S   s   ||| _ | _d S r   )r  r  )r%   r  r  r   r   r   r     r  zBInterfaceTests.test_invariant_as_decorator.<locals>.Range.__init__Nr   r   r   r   r   Range  s    r  r$  r  r  )r   r  rF  rL  r	   ry  r  r!   r  r"   r   )r%   r  rL  r  r  r~  r   r  r   test_invariant_as_decorator  s    	z*InterfaceTests.test_invariant_as_decoratorc                    s   ddl m  ddl m} ddl m G  fddd|}G fddd|}G d	d
 d
|}| |dd | t|jd | t|	 dg | |dd | |dd | t
|	 t
ddg d S )Nr   rE  r  r,   c                       s&   e Zd Z dZ dZdd dS )z0InterfaceTests.test_taggedValue.<locals>.ITaggedrS   r  r2   SpamN)r   r   r   rS   r.   r   rF  r-   r   r   ITagged  s    r  c                       s    e Zd Z dd  dd dS )z1InterfaceTests.test_taggedValue.<locals>.IDerivedr2   	Spam SpamrS   r.   Nr   r   r,   r   r   r    s    
r  c                   @   r   )z2InterfaceTests.test_taggedValue.<locals>.IDerived2Nr   r   r   r   r   	IDerived2  r   r  r2   r  rS   r  r.   )r   rF  r  r-   r"   rO   rM   rN   rD   rE   set)r%   r  r  r  r  r   r  r   test_taggedValue  s    zInterfaceTests.test_taggedValuec           	         s   ddl m ddl m  |}G  fddd|}G  fddd|}G  fdd	d	|}G  fd
dd||}G dd d||}G dd d||}|S )Nr   r,   rE  c                          e Zd Zdd  dZdS )z0InterfaceTests._make_taggedValue_tree.<locals>.FtagFNr   r   r   r  r   r  r   r   r        
r  c                       r  )z0InterfaceTests._make_taggedValue_tree.<locals>.Er  ENr  r   r  r   r   r    r  r  c                       r  )z0InterfaceTests._make_taggedValue_tree.<locals>.Dr  DNr  r   r  r   r   r    r  r  c                       r  )z0InterfaceTests._make_taggedValue_tree.<locals>.Cr  CNr  r   r  r   r   r    r  r  c                   @   r   )z0InterfaceTests._make_taggedValue_tree.<locals>.BNr   r   r   r   r   B  r   r  c                   @   r   )z0InterfaceTests._make_taggedValue_tree.<locals>.ANr   r   r   r   r   A  r   r  )r   r-   rF  )	r%   r  Or  r  r  r  r  r  r   r  r   _make_taggedValue_tree  s   z%InterfaceTests._make_taggedValue_treec                 C   s   ddl m} | t}| |jjd | |}| |d jd | |dd | |dd |j	d jdks=J |j	d 
dd | |dd d S )Nr   r  r  r  r  )r   r  r  r!   r"   r  r   rO   rY   r  rU   )r%   r  class_Aiface_Ar   r   r   "test_getTaggedValue_follows__iro__  s   

z1InterfaceTests.test_getTaggedValue_follows__iro__c                 C   s  ddl m} | |}| |d | g t|  | t	 |
d W d    n1 s2w   Y  |dd | |dd | |
dd | dgt|  |jd jdksdJ |jd }| |dd | |
dd | dgt|  d S )Nr   r  r  r  r$  r  )r   r  r  r6  rc   r"   rD   rT   rM   rN   r`   rU   r  r   )r%   r  r  r  r   r   r   (test_getDirectTaggedValue_ignores__iro__
  s    

z7InterfaceTests.test_getDirectTaggedValue_ignores__iro__c                    s   ddl m} ddl m  G  fddd|}G dd d|}G dd	 d	|}| |d
|d
u  |f|_| |d
d u  d S )Nr   r  rE  c                       rG  )z<InterfaceTests.test_description_cache_management.<locals>.I1r   N)r   r   r   r   r   rE  r   r   r  '  r   r  c                   @   r   )z<InterfaceTests.test_description_cache_management.<locals>.I2Nr   r   r   r   r   I2*  r   r  c                   @   r   )z<InterfaceTests.test_description_cache_management.<locals>.I3Nr   r   r   r   r   I3-  r   r  r   )r   r  rF  r   r2  r  )r%   r  r  r  r  r   rE  r   !test_description_cache_management   s   z0InterfaceTests.test_description_cache_managementc                 C   sV   ddl m} ddl m} G dd d|}||G dd dt}| || d d S )Nr   r  rK  c                   @   r   )z>InterfaceTests.test___call___defers_to___conform___.<locals>.INr   r   r   r   r   r/  9  r   r/  c                   @   r   )z>InterfaceTests.test___call___defers_to___conform___.<locals>.Cc                 S   r   )Nr   r   )r%   protor   r   r   r   >  r|   zJInterfaceTests.test___call___defers_to___conform___.<locals>.C.__conform__Nr   r   r   r   r   r  <  r  r  )r   r  rL  r!   r"   )r%   r  rL  r/  r  r   r   r   $test___call___defers_to___conform___5  s   z3InterfaceTests.test___call___defers_to___conform___c                 C   s\   ddl m} ddl m} G dd d|}||G dd dt}| }| |||u  d S )Nr   r  rK  c                   @   r   )z9InterfaceTests.test___call___object_implements.<locals>.INr   r   r   r   r   r/  G  r   r/  c                   @   r   )z9InterfaceTests.test___call___object_implements.<locals>.CNr   r   r   r   r   r  J  rR  r  )r   r  rL  r!   r   )r%   r  rL  r/  r  cr   r   r   test___call___object_implementsC  s   z.InterfaceTests.test___call___object_implementsc                 C   sD   ddl m} G dd d|}G dd dt}| }| t|| d S )Nr   r  c                   @   r   )z9InterfaceTests.test___call___miss_wo_alternate.<locals>.INr   r   r   r   r   r/  T  r   r/  c                   @   r   )z9InterfaceTests.test___call___miss_wo_alternate.<locals>.CNr   r   r   r   r   r  W  r   r  )r   r  r!   rM   r   r%   r  r/  r  r  r   r   r   test___call___miss_wo_alternateQ  s
   z.InterfaceTests.test___call___miss_wo_alternatec                 C   sJ   ddl m} G dd d|}G dd dt}| }| ||| | u  d S )Nr   r  c                   @   r   )z8InterfaceTests.test___call___miss_w_alternate.<locals>.INr   r   r   r   r   r/  `  r   r/  c                   @   r   )z8InterfaceTests.test___call___miss_w_alternate.<locals>.CNr   r   r   r   r   r  c  r   r  )r   r  r!   r   r  r   r   r   test___call___miss_w_alternate]  s
   z-InterfaceTests.test___call___miss_w_alternatec           	   
      s   ddl m} ddlm} dd } fdd}G dd	 d	|}G d
d dt}| }|d d  }||g|d d < z || u  W ||d d < d S ||d d < w )Nr   r  r  c                 S   r  r   r   r  r   r   r   _missm  r|   z:InterfaceTests.test___call___w_adapter_hook.<locals>._missc                    rx   r   r   r  rq   r   r   _hitp  r|   z9InterfaceTests.test___call___w_adapter_hook.<locals>._hitc                   @   r   )z6InterfaceTests.test___call___w_adapter_hook.<locals>.INr   r   r   r   r   r/  s  r   r/  c                   @   r   )z6InterfaceTests.test___call___w_adapter_hook.<locals>.CNr   r   r   r   r   r  v  r   r  )r   r  r    r  r!   r   )	r%   r  r  r  r  r/  r  r  old_adapter_hooksr   rq   r   test___call___w_adapter_hooki  s   z+InterfaceTests.test___call___w_adapter_hookc                    sx   ddl m} ddl m  ddl m} G  fddd|}||G dd dt}| d	|t  | d	||  d S )
Nr   r  interfacemethodrK  c                          e Zd Z dd ZdS )z:InterfaceTests.test___call___w_overridden_adapt.<locals>.Ic                 S   r   Nr  r   r   r   r   r   r	    r   zDInterfaceTests.test___call___w_overridden_adapt.<locals>.I.__adapt__Nr   r   r   r	  r   r  r   r   r/    s    r/  c                   @   r   )z:InterfaceTests.test___call___w_overridden_adapt.<locals>.ONr   r   r   r   r   r    rR  r  r  )r   r  r  rL  r!   r"   )r%   r  rL  r/  r  r   r  r    test___call___w_overridden_adapt  s   z/InterfaceTests.test___call___w_overridden_adaptc                    s   ddl m} ddl m  ddl m} G  fddd|}G dd d|}||G d	d
 d
t}||G dd dt}| d|t  | d||  | d||  | t ||  W d    n1 slw   Y  | d||  d S )Nr   r  r  rK  c                       r  )zKInterfaceTests.test___call___w_overridden_adapt_and_conform.<locals>.IAdaptc                 S   r   r  r   r   r   r   r   r	    r   zUInterfaceTests.test___call___w_overridden_adapt_and_conform.<locals>.IAdapt.__adapt__Nr  r   r  r   r   IAdapt      r  c                   @   rk  )zLInterfaceTests.test___call___w_overridden_adapt_and_conform.<locals>.ISimplezNothing special.Nrm  r   r   r   r   r4    r  r4  c                   @   r   )zNInterfaceTests.test___call___w_overridden_adapt_and_conform.<locals>.Conform24c                 S   r   N   r   r   r   r   r   r     r|   zZInterfaceTests.test___call___w_overridden_adapt_and_conform.<locals>.Conform24.__conform__Nr   r   r   r   r   	Conform24  r  r  c                   @   r   )zPInterfaceTests.test___call___w_overridden_adapt_and_conform.<locals>.ConformNonec                 S   r  r   r   r   r   r   r   r     r|   z\InterfaceTests.test___call___w_overridden_adapt_and_conform.<locals>.ConformNone.__conform__Nr   r   r   r   r   ConformNone  r  r  r  r  )r   r  r  rL  r!   r"   rM   r   )r%   r  rL  r  r4  r  r  r   r  r   ,test___call___w_overridden_adapt_and_conform  s    z;InterfaceTests.test___call___w_overridden_adapt_and_conformc                    s   dd l ddlm} ddlm ddlm} G  fddd| | G dd dt}| d	 t  | }| | | d S )
Nr   r  r  rK  c                       s$   e Zd Z fddZ  ZS )zEInterfaceTests.test___call___w_overridden_adapt_call_super.<locals>.Ic                    s@   |  |sdS jd d dkrt |S tt | |S )Nr  r  )rK     )r~   version_infosuperr	  r  r   )r/  r  sysr   r   r	    s
   
zOInterfaceTests.test___call___w_overridden_adapt_call_super.<locals>.I.__adapt__)r   r   r   r	  __classcell__r   r/  r  r  )r  r   r/    s    r/  c                   @   r   )zEInterfaceTests.test___call___w_overridden_adapt_call_super.<locals>.ONr   r   r   r   r   r    rR  r  r  )r  r   r  r  rL  r!   r"   r   )r%   r  rL  r  or   r  r   +test___call___w_overridden_adapt_call_super  s   z:InterfaceTests.test___call___w_overridden_adapt_call_superc                    sV   ddl m} ddl m  G  fddd|}| d|t  | |d  d d S )	Nr   r  r  c                       s    e Zd Z dd Zdd ZdS )zEInterfaceTests.test___adapt___as_method_and_implementation.<locals>.Ic                 S   r   r  r   r   r   r   r   r	    r   zOInterfaceTests.test___adapt___as_method_and_implementation.<locals>.I.__adapt__c                 S   r   )zThis is a protocolNr   )to_adaptr   r   r   r	    re  Nr  r   r  r   r   r/    s    
r/  r  r	  z
(to_adapt))r   r  r  r"   r!   getSignatureStringr%   r  r/  r   r  r   +test___adapt___as_method_and_implementation  s
   z:InterfaceTests.test___adapt___as_method_and_implementationc           	         sN  ddl m} ddl m  G dd d|}G  fddd|}G dd	 d	|}G d
d d|}G dd d|||}G  fddd|}| d|t  |||||fD ]	}| t|j qR|||fD ]}| t|t| qa| t|t| | t|t| | 	|t| | d|t  | t|t| | 	|t| d S )Nr   r  r  c                   @   rk  )z@InterfaceTests.test___adapt__inheritance_and_type.<locals>.IRootRootNrm  r   r   r   r   IRoot  r  r  c                       r  )zEInterfaceTests.test___adapt__inheritance_and_type.<locals>.IWithAdaptc                 S   r   r  r   r   r   r   r   r	    r   zOInterfaceTests.test___adapt__inheritance_and_type.<locals>.IWithAdapt.__adapt__Nr  r   r  r   r   
IWithAdapt  r  r  c                   @   rk  )zAInterfaceTests.test___adapt__inheritance_and_type.<locals>.IOtherzSecond branchNrm  r   r   r   r   rP    r  rP  c                   @   rk  )zEInterfaceTests.test___adapt__inheritance_and_type.<locals>.IUnrelated	UnrelatedNrm  r   r   r   r   
IUnrelated  r  r  c                   @   rk  )zHInterfaceTests.test___adapt__inheritance_and_type.<locals>.IDerivedAdaptzInherits an adaptNrm  r   r   r   r   IDerivedAdapt  r  r  c                       s   e Zd ZdZ dd ZdS )zIInterfaceTests.test___adapt__inheritance_and_type.<locals>.IDerived2Adaptz$Overrides an inherited custom adapt.c                 S   r   r  r   r   r   r   r   r	    r   zSInterfaceTests.test___adapt__inheritance_and_type.<locals>.IDerived2Adapt.__adapt__N)r   r   r   rB   r	  r   r  r   r   IDerived2Adapt  s    r  r  r  )
r   r  r  r"   r!   r   r   r  assertNotEqualr  )	r%   r  r  r  rP  r  r  r  r   r   r  r   "test___adapt__inheritance_and_type  s&   z1InterfaceTests.test___adapt__inheritance_and_typec                    sP   ddl m} ddl m  G  fddd|}| || d | | d d S )Nr   r  r  c                       s$   e Zd Z dd Z dd ZdS )z9InterfaceTests.test_interfacemethod_is_general.<locals>.Ic                 S   r   )zReplace an existing methodr  r   r   r   r   r   r  	  s   zBInterfaceTests.test_interfacemethod_is_general.<locals>.I.__call__c                 S   r   r  r   rq   r   r   r   this_is_new	  r   zEInterfaceTests.test_interfacemethod_is_general.<locals>.I.this_is_newN)r   r   r   r  r  r   r  r   r   r/  	  s
    
r/  r  )r   r  r  r"   r  r  r   r  r   test_interfacemethod_is_general	  s
   z.InterfaceTests.test_interfacemethod_is_generalN)9r   r   r   r  r  r  r  r  r  r  r"  r.  r0  r2  r7  r@  rF  rM  rQ  rV  rZ  r\  r^  r_  r`  rb  rc  rd  rf  rg  rj  rp  rs  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   r    sn    	
!+9))	/5
$,r  c                   @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )AttributeTestsTestAttributec                 C   r9   )Nr   rE  )r    rF  )r%   rF  r   r   r   r;   &	  r<   zAttributeTests._getTargetClassc                 C   sJ   |   }t| |_t|}| |d| | |dt d | d S )N-<zope.interface.interface.Attribute object at z.AttributeTests.TestAttribute>)r?   r  ru   reprr   
startswithendswithr   r%   r  rr   r   r   test__repr__w_interface*	  s
   
z&AttributeTests.test__repr__w_interfacec                 C   s8   |   }t|}| |d| | |d| d S )Nr  z TestAttribute>)r?   r  r   r  r  r  r   r   r   test__repr__wo_interface1	  s   z'AttributeTests.test__repr__wo_interfacec                 C   s.   |   }t| |_t|}| |td  d S )Nz.AttributeTests.TestAttribute)r?   r  ru   r   r"   r   r  r   r   r   test__str__w_interface7	  s   
z%AttributeTests.test__str__w_interfacec                 C   s    |   }t|}| |d d S )Nr  )r?   r   r"   r  r   r   r   test__str__wo_interface=	  s   z&AttributeTests.test__str__wo_interfaceN)	r   r   r   r=   r;   r  r  r  r  r   r   r   r   r  "	  s    r  c                   @   sx   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd ZdS )MethodTests
TestMethodc                 C   r9   )Nr   rA  )r    rB  )r%   rB  r   r   r   r;   G	  r<   zMethodTests._getTargetClassc                 C   sH   |   }| |ji  ddi|_| |jddi |`| |ji  d S rR   )r?   r"   rh  r%   r  r   r   r   test_optional_as_propertyK	  s   
z%MethodTests.test_optional_as_propertyc              
   C   sr   ddl m} |  }z|  W n" |y1 } z| |jd  | |j| j W Y d }~d S d }~ww | d d S )Nr   )BrokenImplementationz*__call__ should raise BrokenImplementation)ry  r  r?   r"   ru   r>   r=   rx  )r%   r  r  r~  r   r   r   )test___call___raises_BrokenImplementationS	  s   
z5MethodTests.test___call___raises_BrokenImplementationc                 C   sl   |   }| }| t|d g  | t|d g  | |d i  | |d d  | |d d  d S )N
positionalrequiredrh  varargskwargs)r?   getSignatureInfor"   rD   )r%   r  infor   r   r   test_getSignatureInfo_bare^	  s   z&MethodTests.test_getSignatureInfo_barec                 C   s   |   }| | d d S )Nz())r?   r"   r  r  r   r   r   test_getSignatureString_bareg	  rQ   z(MethodTests.test_getSignatureString_barec                 C   s*   |   }dg |_|_| | d d S )NrS   z(foo))r?   r  r  r"   r  r  r   r   r   'test_getSignatureString_w_only_requiredk	  s   z3MethodTests.test_getSignatureString_w_only_requiredc                 C   s4   |   }dg |_|_ddi|_| | d d S )NrS   r.   z(foo='bar'))r?   r  r  rh  r"   r  r  r   r   r   "test_getSignatureString_w_optionalp	  s   
z.MethodTests.test_getSignatureString_w_optionalc                 C   "   |   }d|_| | d d S )Nr   z(*args))r?   r  r"   r  r  r   r   r   !test_getSignatureString_w_varargsv	  r-  z-MethodTests.test_getSignatureString_w_varargsc                 C   r  )Nr   z(**kw))r?   r  r"   r  r  r   r   r    test_getSignatureString_w_kwargs{	  r-  z,MethodTests.test_getSignatureString_w_kwargsc                 C   sP   |   }d|_t| |_t|}| |d| | |dt d | d S )Nr   *<zope.interface.interface.Method object atr  z.MethodTests.TestMethod(**kw)>)	r?   r  r  ru   r  r   r  r  r   r  r   r   r   r  	  s   
z#MethodTests.test__repr__w_interfacec                 C   s>   |   }d|_t|}| |d| | |d| d S )Nr   r  z TestMethod(**kw)>)r?   r  r  r   r  r  r  r   r   r   r  	  s
   z$MethodTests.test__repr__wo_interfacec                 C   s4   |   }d|_t| |_t|}| |td  d S )Nr   z.MethodTests.TestMethod(**kw))r?   r  r  ru   r   r"   r   r  r   r   r   r  	  s
   
z"MethodTests.test__str__w_interfacec                 C   s&   |   }d|_t|}| |d d S )Nr   zTestMethod(**kw))r?   r  r   r"   r  r   r   r   r  	  s   z#MethodTests.test__str__wo_interfaceN)r   r   r   r=   r;   r  r   r  r  r	  r
  r  r  r  r  r  r  r   r   r   r   r  C	  s    	r  c                   @   s\   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd ZdS )Test_fromFunctionc                 O      ddl m} ||i |S )Nr   r`  )r    ra  )r%   r   r   ra  r   r   r   _callFUT	     zTest_fromFunction._callFUTc                 C      dd }|  |}| | d | | d | |jd  | t| g  | }| t|d g  | t|d g  | |d i  | |d d  | |d	 d  d S )
Nc                   S   r   rb  r   r   r   r   r   _func	  re  z*Test_fromFunction.test_bare.<locals>._funcr  rc  r  r  rh  r  r  r  r"   rA   rC   ru   rD   rE   r  r%   r  r  r  r   r   r   	test_bare	     
zTest_fromFunction.test_barec                 C   sD   ddl m} G dd d|}dd }| j||d}| |j| d S )Nr   rW  c                   @   r   )z0Test_fromFunction.test_w_interface.<locals>.IFooNr   r   r   r   r   r8  	  r   r8  c                   S   r   rb  r   r   r   r   r   r  	  re  z1Test_fromFunction.test_w_interface.<locals>._funcrt   )r    rX  r  r"   ru   )r%   rX  r8  r  r  r   r   r   test_w_interface	  s
   z"Test_fromFunction.test_w_interfacec                 C   s*   dd }| j |dd}| | d d S )Nc                   S   r   rb  r   r   r   r   r   r  	  re  z,Test_fromFunction.test_w_name.<locals>._funcanotherName)r>   )r  r"   rA   )r%   r  r  r   r   r   test_w_name	  s   zTest_fromFunction.test_w_namec                 C   sz   dd }|  |}| }| t|d dg | t|d dg | |d i  | |d d  | |d d  d S )	Nc                 S   r   rb  r   rS   r   r   r   r  	  re  z5Test_fromFunction.test_w_only_required.<locals>._funcr  rS   r  rh  r  r  r  r  r"   rD   r  r   r   r   test_w_only_required	  s   
z&Test_fromFunction.test_w_only_requiredc                 C   s~   d
dd}|  |}| }| t|d dg | t|d g  | |d ddi | |d d  | |d	 d  d S )Nr.   c                 S   r   rb  r   r  r   r   r   r  	  re  z0Test_fromFunction.test_w_optional.<locals>._funcr  rS   r  rh  r  r  r.   r  r  r   r   r   test_w_optional	  s   

z!Test_fromFunction.test_w_optionalc                 C   s|   ddd}| j |dd}| }| t|d g  | t|d g  | |d i  | |d	 d  | |d
 d  d S )Nr.   c                 S   r   rb  r   rq   r   r   r   r  	  re  z5Test_fromFunction.test_w_optional_self.<locals>._funcr$  )imlevelr  r  rh  r  r  r  r  r  r   r   r   test_w_optional_self	  s   
z&Test_fromFunction.test_w_optional_selfc                 C   sv   dd }|  |}| }| t|d g  | t|d g  | |d i  | |d d | |d d  d S )	Nc                  W   r   rb  r   rt  r   r   r   r  	  re  z/Test_fromFunction.test_w_varargs.<locals>._funcr  r  rh  r  r   r  r  r  r   r   r   test_w_varargs	     
z Test_fromFunction.test_w_varargsc                 C   sv   dd }|  |}| }| t|d g  | t|d g  | |d i  | |d d  | |d d d S )	Nc                  [   r   rb  r   )r   r   r   r   r  	  re  z.Test_fromFunction.test_w_kwargs.<locals>._funcr  r  rh  r  r  r   r  r  r   r   r   test_w_kwargs	  r$  zTest_fromFunction.test_w_kwargsc                 C   s   ddd}|  |}| }| t|d ddg | t|d dg | |d ddi | |d	 d
 | |d d d S )Nr/   c                 _   r   rb  r   )rS   r.   r   r   r   r   r   r   
  re  z3Test_fromFunction.test_full_spectrum.<locals>._funcr  rS   r.   r  rh  r  r   r  r   r/   r  r  r   r   r   test_full_spectrum	  s   

z$Test_fromFunction.test_full_spectrumN)r   r   r   r  r  r  r  r  r   r"  r#  r%  r'  r   r   r   r   r  	  s    	r  c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
Test_fromMethodc                 O   r  )Nr   )
fromMethod)r    r)  )r%   r   r   r)  r   r   r   r  
  r  zTest_fromMethod._callFUTc                 C   s   G dd dt }| |j}| | d | | d | |jd  | t| g  |	 }| t|d g  | t|d g  | |d i  | |d d  | |d	 d  d S )
Nc                   @   r   )z)Test_fromMethod.test_no_args.<locals>.Fooc                 S   r   rb  r   rq   r   r   r   r.   
  re  z-Test_fromMethod.test_no_args.<locals>.Foo.barNrH  r   r   r   r   r   
  r   r   r.   rc  r  r  rh  r  r  )
r!   r  r.   r"   rA   rC   ru   rD   rE   r  r%   r   r  r  r   r   r   test_no_args
  s   zTest_fromMethod.test_no_argsc                 C   s   G dd dt }| |j}| }| t|d ddg | t|d dg | |d ddi | |d	 d
 | |d d d S )Nc                   @   s   e Zd ZdddZdS )z/Test_fromMethod.test_full_spectrum.<locals>.Foor/   c                 _   r   rb  r   )r%   rS   r.   r   r   r   r   r   r.   #
  re  z3Test_fromMethod.test_full_spectrum.<locals>.Foo.barNr&  rH  r   r   r   r   r   "
  s    r   r  rS   r.   r  rh  r/   r  r   r  r   )r!   r  r.   r  r"   rD   r*  r   r   r   r'  !
  s   z"Test_fromMethod.test_full_spectrumc                 C   r  )
Nc                   S   r   rb  r   r   r   r   r   rS   .
  re  z.Test_fromMethod.test_w_non_method.<locals>.foorS   rc  r  r  rh  r  r  r  )r%   rS   r  r  r   r   r   test_w_non_method-
  r  z!Test_fromMethod.test_w_non_methodN)r   r   r   r  r+  r'  r,  r   r   r   r   r(  
  s
    r(  c                   @   r   )r%  c                 C   s
   g | _ d S r   )r1  rq   r   r   r   r   >
  rr   zDummyDependent.__init__c                 C   s   | j | d S r   )r1  r  )r%   originally_changedr   r   r   r5  A
  s   zDummyDependent.changedN)r   r   r   r   r5  r   r   r   r   r%  <
  s    r%  c                 C   sV   ddl m} t| dd }t| dd }|d ur%t|t|r'||ks)|dd S d S d S )Nr   r  rS   r.   r  )ry  r  r#   r  r  )rz   r  rS   r.   r   r   r   r  E
  s   r  c                 C   s4   ddl m} t| dd rt| dd s|dd S d S )Nr   r  rS   r.   r  )ry  r  r#   )rz   r  r   r   r   r  Q
  s   r  c                   @   r*   )r   c                    s<    | _  fdd|D | _| D ]
\}}t || qd S )Nc                    s   i | ]}|t  |qS r   )r#   )ru  keyr   r   r   
<dictcomp>[
  s    z$_Monkey.__init__.<locals>.<dictcomp>)r   
to_restoreitemssetattr)r%   r   r   r.  r(  r   r/  r   r   Y
  s
   z_Monkey.__init__c                 C   s   | S r   r   rq   r   r   r   	__enter___
  r|   z_Monkey.__enter__c                 C   s&   | j  D ]\}}t| j|| qd S r   )r1  r2  r3  r   )r%   exc_typeexc_valexc_tbr.  r(  r   r   r   __exit__b
  s   z_Monkey.__exit__N)r   r   r   r   r4  r8  r   r   r   r   r   W
  s    r   ) rB   unittestzope.interface._compatr   zope.interface.testsr   r   r   r!   r  TestCaser   r+   r7   rm   r   r   r   r   r  r  r  rV  r  r  r  r  r(  r%  r  r  r   r   r   r   r   <module>   s^   
!$H.i-	     &         +!Zn1	