o
    h-j                    @   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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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*Zd+d, Zd-d. ZG d/d0 d0ZG d1d2 d2ej	ZdS )3zTest Interface implementation
    N)CleanUp)MissingSomeAttrs)OptimizationTestMixin)SubclassableMixinc                   @      e Zd Zdd Zdd ZdS )Test_invariantc                    sR   ddl m} ddl m dd  G  fddd}| t||d d gi d S )	Nr   TAGGED_DATA	invariantc                  _      t  NNotImplementedErrorargskw r   V/var/www/html/venv/lib/python3.10/site-packages/zope/interface/tests/test_interface.py_check1      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   Foo4       r   
invariantszope.interface.interfacer	   r   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||d d
 gi d S )Nr   r   r
   c                  _   r   r   r   r   r   r   r   r   >   r   z.Test_invariant.test_w_multiple.<locals>._checkc                  _   r   r   r   r   r   r   r   _another_checkA   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   D   s    r   r   r   r#   r   r'   r   test_w_multiple:   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                    sH   ddl m} ddl m  G  fddd}| t||d ddgi d S )Nr   r   taggedValuec                       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   R       r   r-   r.   r    r	   r,   r!   r"   r#   r   r+   r   r%   N   s   zTest_taggedValue.test_w_singlec                    sJ   ddl m} ddl m  G  fddd}| 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    r   r.   r2   r-   r1   r0   r#   r   r+   r   r(   X   s   
z Test_taggedValue.test_w_multiplec                    sH   ddl m} ddl m  G  fddd}| 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.   r1   r2   frobNr   r   r+   r   r   r   g   s    
r   r4   r2   r3   r0   r#   r   r+   r   test_w_multiple_overwritingc   s   z,Test_taggedValue.test_w_multiple_overwritingN)r   r   r   r%   r(   r5   r   r   r   r   r*   L   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 )ElementTestsZ	AnElementc                 C      ddl m} |S )Nr   )Element)r    r8   )r$   r8   r   r   r   _getTargetClasst      zElementTests._getTargetClassNc                 C   s   |d u r| j }|  |S r   )DEFAULT_NAMEr9   )r$   namer   r   r   _makeOnex   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_defaults}   s   zElementTests.test_ctor_defaultsc                 C   s*   |  d}| |jd  | |jd d S )Nz
An Element)r=   r!   r   r@   rD   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getTaggedValuerD   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!   rB   getDirectTaggedValueTagssetTaggedValuerD   r   r   r   test_getDirectTaggedValueTags   s   z*ElementTests.test_getDirectTaggedValueTagsc                 C      |   }| |dd  d S rI   r=   r!   queryTaggedValuerD   r   r   r   test_queryTaggedValue_miss      z'ElementTests.test_queryTaggedValue_missc                 C       |   }| |ddd d S NrJ   r-   rV   rD   r   r   r   $test_queryTaggedValue_miss_w_default      z1ElementTests.test_queryTaggedValue_miss_w_defaultc                 C   rH   rI   )r=   rK   rL   getDirectTaggedValuerD   r   r   r   test_getDirectTaggedValue_miss   rO   z+ElementTests.test_getDirectTaggedValue_missc                 C   rU   rI   r=   r!   queryDirectTaggedValuerD   r   r   r    test_queryDirectTaggedValue_miss   rY   z-ElementTests.test_queryDirectTaggedValue_missc                 C   rZ   r[   r`   rD   r   r   r   *test_queryDirectTaggedValue_miss_w_default   s   z7ElementTests.test_queryDirectTaggedValue_miss_w_defaultc                 C   sR   |   }|dd | t| dg | |dd | |dd d S rP   )r=   rS   r!   rB   rC   rM   rW   rD   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)Zzope.interface.interfacesre   zope.interface.verifyrg   r=   )r$   re   rg   rE   r   r   r   test_verifies   s   zElementTests.test_verifiesr   )r   r   r   r;   r9   r=   rF   rG   rN   rT   rX   r\   r_   rb   rc   rd   ri   r   r   r   r   r6   p   s    
r6   c                   @   s0   e Zd Zdd ZeZdd Zdd Zdd Zd	S )
GenericSpecificationBaseTestsc                 C   r7   )Nr   )SpecificationBasePy)r    rk   )r$   rk   r   r   r   _getFallbackClass   r:   z/GenericSpecificationBaseTests._getFallbackClassc                 C   s
   |    S r   r9   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   objrs   r   r   _providedBy      zGGenericSpecificationBaseTests.test_providedBy_miss.<locals>._providedBy
providedBy)	zope.interfacerr   zope.interface.declarationsrt   r=   _MonkeyassertFalser{   object)r$   rr   sbrx   r   rs   r   test_providedBy_miss      "z2GenericSpecificationBaseTests.test_providedBy_missc                    rp   )Nr   rq   rs   c                    ru   r   r   rv   rs   r   r   _implementedBy   ry   zMGenericSpecificationBaseTests.test_implementedBy_miss.<locals>._implementedByimplementedBy)	r|   rr   r}   rt   r=   r~   r   r   r   )r$   rr   r   r   r   rs   r   test_implementedBy_miss   r   z5GenericSpecificationBaseTests.test_implementedBy_missN)r   r   r   rl   r9   r=   r   r   r   r   r   r   rj      s    rj   c                   @      e Zd Zdd ZdS )SpecificationBaseTestsc                 C   r7   )Nr   )SpecificationBase)r    r   )r$   r   r   r   r   r9      r:   z&SpecificationBaseTests._getTargetClassNr   r   r   r9   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   Z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   Z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                    v   ddl m} |  G fddd  fdd}t||d | t  W d    d S 1 s4w   Y  d S )Nr   rq   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   rv   r   r   r   r     r   zGSpecificationBasePyTests.test_implementedBy_hit.<locals>._implementedByr   )r|   rr   r=   r~   r   r   r   )r$   rr   r   r   r   r   r   test_implementedBy_hit     "z/SpecificationBasePyTests.test_implementedBy_hitc                    r   )Nr   rq   c                       r   )z;SpecificationBasePyTests.test_providedBy_hit.<locals>._DeclNr   r   r   r   r   r     r   r   c                    r   r   r   rv   r   r   r   rx     r   zASpecificationBasePyTests.test_providedBy_hit.<locals>._providedByrz   )r|   rr   r=   r~   r   r{   r   )r$   rr   rx   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=   rn   r   r   r   _makeOneToCompare  s   z3NameAndModuleComparisonTestsMixin._makeOneToComparec              	      s  dd l }|  }t||}t|d| }G  fddd G dd d }G dd d }| | jd	 | | jd	 | t t| d
 W d    n1 sSw   Y  | t t| d W d    n1 snw   Y  ||fD ]}| || t	 qwG dd d }	| 
|||	  | ||	 t	 G dd d}
| ||
 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 sBw   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   0  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 NrQ   )r   rn   r   r   r   __init__8  ro   ziNameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.RaisesErrorOnModule.__init__c                 S      t r   )r   rn   r   r   r   r   ;     zkNameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.RaisesErrorOnModule.__module__N)r   r   r   r   propertyr   r   r   r   RaisesErrorOnModule7  s    r   c                   @   r   )z^NameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.RaisesErrorOnNamec                 S   r   r   r   rn   r   r   r   r   @  ro   zgNameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.RaisesErrorOnName.__init__Nr   r   r   r   r   r   r   r   RaisesErrorOnName?  r   r   rQ   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__Q  ry   zgNameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.AllowsAnyComparison.__eq__N	r   r   r   r   __lt____le____gt____ge____ne__r   r   r   r   AllowsAnyComparisonP  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   AllowsNoComparison]  s    r   c                   @      e Zd ZdS )zXNameAndModuleComparisonTestsMixin.__check_NotImplemented_comparison.<locals>.MyExceptionNr   r   r   r   r   MyExceptionj      r   )operatorr   r"   r!   r   r   rK   r   assertIsNotImplementedr   	TypeError	Exceptionr   )r$   r<   r   ibopmethr   r   clsr   r   r   r   r   r   Z!__check_NotImplemented_comparison!  sT   

	zCNameAndModuleComparisonTestsMixin.__check_NotImplemented_comparisonc                 C      |  d d S )NltC_NameAndModuleComparisonTestsMixin__check_NotImplemented_comparisonrn   r   r   r   test__lt__NotImplementedz     z:NameAndModuleComparisonTestsMixin.test__lt__NotImplementedc                 C   r   )Nler   rn   r   r   r   test__le__NotImplemented}  r   z:NameAndModuleComparisonTestsMixin.test__le__NotImplementedc                 C   r   )Ngtr   rn   r   r   r   test__gt__NotImplemented  r   z:NameAndModuleComparisonTestsMixin.test__gt__NotImplementedc                 C   r   )Nger   rn   r   r   r   test__ge__NotImplemented  r   z:NameAndModuleComparisonTestsMixin.test__ge__NotImplementedN)	r   r   r   r   r   r   r   r   r   r   r   r   r   r     s    Y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   rn   r   r   r   r9     ry   z'InterfaceBaseTestsMixin._getTargetClassc                 C   r7   )Nr   )InterfaceBasePy)r    r   )r$   r   r   r   r   rl     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$   Zconformr   r   r   _call_conform     z:InterfaceBaseTestsMixin._makeOne.<locals>.IB._call_conformc                    ru   r   r   r$   rw   object_should_provider   r   r{     ry   z7InterfaceBaseTestsMixin._makeOne.<locals>.IB.providedByN)r   r   r   r   r{   r   r   r   r   IB  s    r   rm   )r$   r   r<   moduler   r   r   r   r=     s   
z InterfaceBaseTestsMixin._makeOnec                    s8   |  d}t  G  fddd}| ||   d S )NFc                          e Zd Z fddZdS )zUInterfaceBaseTestsMixin.test___call___w___conform___returning_value.<locals>._Adaptedc                    ru   r   r   r$   ifaceZ	conformedr   r   __conform__  ry   zaInterfaceBaseTestsMixin.test___call___w___conform___returning_value.<locals>._Adapted.__conform__Nr   r   r   r   r   r   r   r   _Adapted  r/   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=   r9   r   r   )r$   r   Z__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=   rK   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   )Zexpected_missing)r   Ztest_raisesr=   rn   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   r9   rl   r=   r   r   r   r   r   r   r   r   r     s    

r   c                   @   r   )InterfaceBaseTestsc                 C   r7   )Nr   )InterfaceBase)r    r   )r$   r   r   r   r   r9     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   s2   |  d}G dd d}| }| ||| d S )NTc                   @   r   )zSInterfaceBasePyTests.test___call___w___conform___miss_ob_provides.<locals>._Adaptedc                 S      d S r   r   r   r   r   r   r     ry   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   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   rq   Fc                    s     | |f d S r   appendr   rw   Z_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  ry   zPInterfaceBasePyTests.test___adapt___ob_no_provides_uses_hooks.<locals>._hook_hitadapter_hooks)r|   rr   r=   r   r~   r   r   r!   )r$   rr   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   rl   r9   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   r7   )Nr   )Specification)r    r  )r$   r  r   r   r   r9     r:   z"SpecificationTests._getTargetClassc                 C   s   |t u r	|   S |  |S r   )_markerr9   )r$   basesr   r   r   r=     s   
zSpecificationTests._makeOnec                 C   sf   ddl m} |  }| |jd | t|jd | ||j | ||j | 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  rK   rL   unsubscriber  r   r   r   test_unsubscribe_miss     z(SpecificationTests.test_unsubscribe_missc                 C   sZ   |   }t }|| || || | |j| d || | ||j d S r  )r=   r  r  r  r!   r  assertNotInr  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   )zYSpecificationTests.test___setBases_subscribes_bases_and_notifies_dependents.<locals>.IFooNr   r   r   r   r   IFoo#  r   r$  c                   @   r   )zYSpecificationTests.test___setBases_subscribes_bases_and_notifies_dependents.<locals>.IBarNr   r   r   r   r   IBar&  r   r%  r  )
r    r  r=   r  r  r  r!   _changedr  get)r$   r  r  r  r$  r%  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 d S )Nr   r  c                   @   r   )zJSpecificationTests.test_changed_clears_volatiles_and_implied.<locals>.IFooNr   r   r   r   r   r$  3  r   r$  r   r   )r    r  r=   _v_attrsr   changedassertIsNoner"  r$   r  r$  r  r   r   r   )test_changed_clears_volatiles_and_implied0  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   r$  @  r   r$  )r    r  r=   r!   rB   
interfacesr,  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   r$  I  r   r$  Tstrict)r    r  r=   r   extendsr,  r   r   r   test_extends_strict_wo_selfF  s   
z.SpecificationTests.test_extends_strict_wo_selfc                 C       |   }| |j|dd d S )NTr0  )r=   r   r2  r$   r  r   r   r   test_extends_strict_w_selfO  r]   z-SpecificationTests.test_extends_strict_w_selfc                 C   r4  )NFr0  )r=   r   r2  r5  r   r   r   test_extends_non_strict_w_selfS  r]   z1SpecificationTests.test_extends_non_strict_w_selfc                 C   s.   |   }t }d|i|_| |d| d S r   )r=   r   r)  r   r'  )r$   r  rQ   r   r   r   test_get_hit_w__v_attrsW  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 | |d	|d	 d S )
Nr   	Attributer  c                          e Zd Z dZdS )zCSpecificationTests.test_get_hit_from_base_wo__v_attrs.<locals>.IFoorQ   N)r   r   r   rQ   r   r9  r   r   r$  a  r   r$  c                       r;  )zCSpecificationTests.test_get_hit_from_base_wo__v_attrs.<locals>.IBarr-   Nr   r   r   r-   r   r9  r   r   r%  d  r   r%  rQ   r-   )r    r:  r  r=   r   r'  )r$   r  r$  r%  r  r   r9  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}G d	d
 d
|}G dd d|}||G dd d}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   IDefaultViewNameu  r   r@  c                   @   r   )zKSpecificationTests.test_multiple_inheritance_no_interfaces.<locals>.ContextNr   r   r   r   r   Contextx  r   rA  c                   @   r   )zLSpecificationTests.test_multiple_inheritance_no_interfaces.<locals>.RDBModelNr   r   r   r   r   RDBModel{  r   rB  c                   @   r   )zJSpecificationTests.test_multiple_inheritance_no_interfaces.<locals>.IOtherNr   r   r   r   r   IOther~  r   rC  c                   @   r   )zMSpecificationTests.test_multiple_inheritance_no_interfaces.<locals>.OtherBaseNr   r   r   r   r   	OtherBase      rD  c                   @   r   )zISpecificationTests.test_multiple_inheritance_no_interfaces.<locals>.ModelNr   r   r   r   r   Model  r   rF  )r}   r   r?  r    r  r!   Z__sro__r   )
r$   r   r?  r  r@  rA  rB  rC  rD  rF  r   r   r   'test_multiple_inheritance_no_interfacesk  s(   z:SpecificationTests.test_multiple_inheritance_no_interfacesN)r   r   r   r9   r  r=   r  r  r  r   r#  r(  r-  r/  r3  r6  r7  r8  r=  rG  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   r7   )Nr   InterfaceClass)r    rJ  )r$   rJ  r   r   r   r9     r:   z#InterfaceClassTests._getTargetClassITestr   Nc                 C   s   |   |||||S r   rm   )r$   r<   r  attrsr@   r   r   r   r   r=     s   zInterfaceClassTests._makeOnec                 C   sN   |   }|d}| |jd | |jd | |jd | | d d S )NITestingr>   r   )r9   r!   r   r@   r  getBases)r$   klassinstr   r   r   rF     s   z&InterfaceClassTests.test_ctor_defaultsc                 C   s    |   }| t|dt f d S )NrM  )r9   rK   r   r   )r$   rO  r   r   r   test_ctor_bad_bases  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   r9  fromFunctionc                   S   r   	DOCSTRINGNr   r   r   r   r   _bar      zBInterfaceClassTests.test_ctor_w_attrs_attrib_methods.<locals>._barr   r>   rQ   r-   rM  rL  r   )
r    r:  rS  r9   r!   r   r@   r  nameskeys)r$   r:  rS  rV  ATTRSrO  rP  r   r   r    test_ctor_w_attrs_attrib_methods  s   z4InterfaceClassTests.test_ctor_w_attrs_attrib_methodsc                 C   ^   di i}|   }|d|d}| |jd | |jd | |jd | t| g  d S )NZ
__locals__rM  rY  r>   r   r9   r!   r   r@   r  rB   rZ  r$   r\  rO  rP  r   r   r   test_ctor_attrs_w___locals__     z0InterfaceClassTests.test_ctor_attrs_w___locals__c                 C   r^  )N__annotations__rM  rY  r>   r   r_  r`  r   r   r   !test_ctor_attrs_w___annotations__  rb  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_returnZdropmerM  rY  r>   r   )	r    re  r9   r!   r   r@   r  rB   rZ  )r$   re  r\  rO  rP  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invalidrM  rY  )zope.interface.exceptionsrg  r   r9   rK   )r$   rg  r\  rO  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 )Nr@   ZATTRrM  ZEXPLICIT)rL  r@   )r9   r!   r@   r`  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!   rB   r.  r   r   r   r   test_interfaces  s   z#InterfaceClassTests.test_interfacesc                 C   s.   |   }| j d|fd}| | |f d S NZISub)r  )r=   r!   rN  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  rO   z5InterfaceClassTests.test_isEqualOrExtendedBy_identityc                 C   s<   |   }| j d|fd}| || | || d S rm  )r=   r   rq  r   rn  r   r   r   !test_isEqualOrExtendedBy_subiface  s   z5InterfaceClassTests.test_isEqualOrExtendedBy_subifacec                 C   s8   |  d}|  d}| || | || d S )NZOneZAnother)r=   r   rq  )r$   oneZ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   r9  rR  c                   S   r   rT  r   r   r   r   r   rV    rW  zFInterfaceClassTests.test_names_w_all_False_ignores_bases.<locals>._barr   r>   rX  r.   BazIBaserY  IDerivedr  rL  Fallr    r:  rS  r=   r!   sortedrZ  r$   r:  rS  rV  
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   r9  rR  c                   S   r   rT  r   r   r   r   r   rV    rW  z@InterfaceClassTests.test_names_w_all_True_no_bases.<locals>._barr   r>   rX  rY  Trz  r-   rQ   r|  r$   r:  rS  rV  r\  rt  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   r9  rR  c                   S   r   rT  r   r   r   r   r   rV  "  rW  zFInterfaceClassTests.test_names_w_all_True_w_bases_simple.<locals>._barr   r>   rX  r.   rv  rw  rY  rx  ry  Trz  r-   r.   rQ   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   r9  rR  c                   S   r   rT  r   r   r   r   r   rV  6  rW  zJInterfaceClassTests.test_names_w_all_True_bases_w_same_names.<locals>._barc                   S   r   rT  r   r   r   r   r   _foo9  rW  zJInterfaceClassTests.test_names_w_all_True_bases_w_same_names.<locals>._foor   r>   rX  rv  rQ   r.   rw  rY  rx  ry  Trz  r  r|  	r$   r:  rS  rV  r  r  r  r  r  r   r   r   (test_names_w_all_True_bases_w_same_names2  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   r9  rR  c                   S   r   rT  r   r   r   r   r   rV  N  rW  z/InterfaceClassTests.test___iter__.<locals>._barc                   S   r   rT  r   r   r   r   r   r  Q  rW  z/InterfaceClassTests.test___iter__.<locals>._foor   r>   rX  rv  r  rw  rY  rx  ry  r  )r    r:  rS  r=   r!   r}  r  r   r   r   test___iter__J  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   r9  rR  c                   S   r   rT  r   r   r   r   r   rV  d  rW  zUInterfaceClassTests.test_namesAndDescriptions_w_all_False_ignores_bases.<locals>._barr   r>   rX  r.   rv  rw  rY  rx  ry  Frz  r    r:  rS  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   r9  rR  c                   S   r   rT  r   r   r   r   r   rV  z  rW  zOInterfaceClassTests.test_namesAndDescriptions_w_all_True_no_bases.<locals>._barr   r>   rX  rY  Frz  r-   rQ   r  r  r   r   r   -test_namesAndDescriptions_w_all_True_no_basesv  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   r9  rR  c                   S   r   rT  r   r   r   r   r   rV    rW  zMInterfaceClassTests.test_namesAndDescriptions_w_all_True_simple.<locals>._barr   r>   rX  r.   rv  rw  rY  rx  ry  Trz  r-   rQ   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   r9  rR  c                   S   r   rT  r   r   r   r   r   rV    rW  zYInterfaceClassTests.test_namesAndDescriptions_w_all_True_bases_w_same_names.<locals>._barc                   S   r   rT  r   r   r   r   r   r    rW  zYInterfaceClassTests.test_namesAndDescriptions_w_all_True_bases_w_same_names.<locals>._foor   r>   rX  rv  r  rw  rY  rx  ry  Trz  r-   r.   rQ   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   rH   rI   )r=   rK   rL   getDescriptionForr$   rt  r   r   r   test_getDescriptionFor_miss  rO   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   r9  rR  c                   S   r   rT  r   r   r   r   r   rV    rW  z<InterfaceClassTests.test_getDescriptionFor_hit.<locals>._barr   r>   rX  rY  rQ   r-   )r    r:  rS  r=   r!   r  r  r   r   r   test_getDescriptionFor_hit  s   z.InterfaceClassTests.test_getDescriptionFor_hitc                    s$   |     fdd}| t| d S )Nc                      s    d S rI   r   r   rt  r   r   _test  r   z8InterfaceClassTests.test___getitem___miss.<locals>._test)r=   rK   rL   )r$   r  r   r  r   test___getitem___miss  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   r9  rR  c                   S   r   rT  r   r   r   r   r   rV    rW  z6InterfaceClassTests.test___getitem___hit.<locals>._barr   r>   rX  rY  rQ   r-   )r    r:  rS  r=   r!   r  r   r   r   test___getitem___hit  s   z(InterfaceClassTests.test___getitem___hitc                 C   s   |   }| d| d S rI   )r=   r"  r  r   r   r   test___contains___miss  s   z*InterfaceClassTests.test___contains___missc                 C   s\   ddl m} ddl m} dd }|dd||d}| j|d	}| d
| | d| d S )Nr   r9  rR  c                   S   r   rT  r   r   r   r   r   rV    rW  z7InterfaceClassTests.test___contains___hit.<locals>._barr   r>   rX  rY  rQ   r-   )r    r:  rS  r=   r   r  r   r   r   test___contains___hit  s   z)InterfaceClassTests.test___contains___hitc                 C   rU   rI   )r=   r!   directr  r   r   r   test_direct_miss  rY   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   r9  rR  c                   S   r   rT  r   r   r   r   r   rV    rW  zBInterfaceClassTests.test_direct_hit_local_miss_bases.<locals>._barc                   S   r   rT  r   r   r   r   r   r    rW  zBInterfaceClassTests.test_direct_hit_local_miss_bases.<locals>._foor   r>   rX  rv  r  rw  rY  rx  ry  rQ   r.   r-   )r    r:  rS  r=   r!   r  r  r   r   r    test_direct_hit_local_miss_bases  s   z4InterfaceClassTests.test_direct_hit_local_miss_basesc                 C   rU   rI   )r=   r!   queryDescriptionForr   r   r   r   test_queryDescriptionFor_miss  rY   z1InterfaceClassTests.test_queryDescriptionFor_missc                 C   s@   ddl m} d|ddi}| j|d}| |d|d  d S )Nr   r9  attrZTitleDescriptionrY  )r|   r:  r=   r!   r  )r$   r:  r\  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   Z_called_withr   r   	_passable#     zCInterfaceClassTests.test_validateInvariants_pass.<locals>._passabler   )r=   r   rS   r!   validateInvariants)r$   r  r   rw   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  1  r  zTInterfaceClassTests.test_validateInvariants_fail_wo_errors_passed.<locals>._passablec                         | |f  r   r   r   r  _fail_called_withr   r   _fail7  r  zPInterfaceClassTests.test_validateInvariants_fail_wo_errors_passed.<locals>._failr   ri  r  r=   r   rS   rK   r  r!   )r$   r  r  r   rw   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 | 	|d   d S )Nr   r  c                     r  r   r   r   r  r   r   r  G  r  zOInterfaceClassTests.test_validateInvariants_fail_w_errors_passed.<locals>._failr   r  
ri  r  r=   r   rS   rK   r  r!   r  assertIsInstance)r$   _errorsr  r   rw   r   r  r   ,test_validateInvariants_fail_w_errors_passedB  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  W  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>._failrw  rx  r   r  )r$   r  r  r  r  rw   r   r  r   5test_validateInvariants_fail_in_base_wo_errors_passedS  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
 | 	|d   d S )Nr   r  c                     r  r   r   r   r  r   r   r  o  r  z[InterfaceClassTests.test_validateInvariants_fail_in_base_w_errors_passed.<locals>._passablec                     r  r   r   r   r  r   r   r  u  r  zWInterfaceClassTests.test_validateInvariants_fail_in_base_w_errors_passed.<locals>._failrw  rx  r   r  r  )r$   r  r  r  r  r  rw   r   r  r   4test_validateInvariants_fail_in_base_w_errors_passedj  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>._passablerw  r   rx  r  )r   r=   rS   r  r!   r  )r$   r  rw   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 )NZ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   rn   r   r   r   r     ry   zRInterfaceClassTests.test___hash___missing_required_attrs.<locals>.Derived.__init__Nr   r   r   r   r   Derived  r   r  )r9   rK   r   r  )r$   r  r  r   r   r   $test___hash___missing_required_attrs  s
   
"z8InterfaceClassTests.test___hash___missing_required_attrsc                 C   s   |   }| |d  | |d  | |d  | |d  | |d k | |d k | d |k  | d |k | d | | d | | d | | d | d S r   )r=   
assertLessassertLessEqualassertNotEqualr   assertGreaterEqualassertGreaterr   r   r   r   test_comparison_with_None  s   z-InterfaceClassTests.test_comparison_with_Nonec                 C   sX   |   }| ||k  | || | || | || | || | ||k d S r   )r=   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 | || d S )NINamezzope.interface.tests.oner   zzope.interface.tests.other)r=   r  r   r  r  r  r  )r$   rt  r   r   r   r   8test_comparison_with_same_named_instance_in_other_module  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     r   r   c                       r   )zIInterfaceClassTests.test_assignment_to__class__.<locals>.MyInterfaceClassc                    s    |r   r   )r$   targetr   r   r   __call__  r   zRInterfaceClassTests.test_assignment_to__class__.<locals>.MyInterfaceClass.__call__Nr   r   r   r  r   r  r   r   MyInterfaceClass  r/   r  r  r  )	r   r9   r=   r  r   typerK   r   	__class__)r$   r  r$  r   r  r   test_assignment_to__class__  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    ry   zSInterfaceClassTests.test_assignment_to__class__2.<locals>.MyInterfaceClass.__call__Nr  r   r   r   r   r    r   r  r$  r  )r  c                   @   r   )z>InterfaceClassTests.test_assignment_to__class__2.<locals>.IBarNr   r   r   r   r   r%    r   r%  c                   @   r   )z?InterfaceClassTests.test_assignment_to__class__2.<locals>.ISpamNr   r   r   r   r   ISpam  r   r  )r|   r  r9   r!   rK   r   r  )r$   r  r  r$  r%  r  r   r   r   test_assignment_to__class__2  s   z0InterfaceClassTests.test_assignment_to__class__2c                 C   s>   |   }| t d|_W d    d S 1 sw   Y  d S )Nzdifferent.module)r=   rK   r   r   )r$   rP  r   r   r   test__module__is_readonly  s   "z-InterfaceClassTests.test__module__is_readonly)rK  r   NNN)4r   r   r   r9   r=   rF   rQ  r]  ra  rd  rf  rj  rk  rl  rp  rr  rs  ru  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   rH    sh    
		

rH  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%dGdH Z&dIdJ Z'dKdL Z(dMdN Z)dOdP Z*dQdR Z+dSdT Z,dUdV Z-dWdX Z.dYdZ Z/d[d\ Z0d]d^ Z1d_d` Z2dadb Z3dcdd Z4dedf Z5dgdh Z6diS )jInterfaceTestsc                    sB   ddl m  ddl m} G  fddd|}| |d j| d S )Nr   r9  r  c                       r;  )z<InterfaceTests.test_attributes_link_to_interface.<locals>.I1My attrN)r   r   r   r  r   r9  r   r   I1  r   r  r  )r|   r:  r  r   rr   r$   r  r  r   r9  r   !test_attributes_link_to_interface  s   z0InterfaceTests.test_attributes_link_to_interfacec                 C   s2   ddl m} G dd d|}| |d j| d S )Nr   r  c                   @   r   )z9InterfaceTests.test_methods_link_to_interface.<locals>.I1c                 S   r   zA methodNr   )rQ   r-   Zbingor   r   r   method  rW  z@InterfaceTests.test_methods_link_to_interface.<locals>.I1.methodNr   r   r   r  r   r   r   r   r    r   r  r  )r|   r  r   rr   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
}| }|  | | || |    |  || | ||| |  || | ||| d S )Nr   r  r   rz   c                   @   r   )z<InterfaceTests.test_classImplements_simple.<locals>.ICurrentc                 S   r   	docstringNr   r   r   r   r   r   method1'  rW  zDInterfaceTests.test_classImplements_simple.<locals>.ICurrent.method1c                 S   r   r  r   r  r   r   r   method2*  rW  zDInterfaceTests.test_classImplements_simple.<locals>.ICurrent.method2N)r   r   r   r  r  r   r   r   r   ICurrent&  s    r  c                   @   r   )z:InterfaceTests.test_classImplements_simple.<locals>.IOtherNr   r   r   r   r   rC  -  r   rC  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  3  r   zCInterfaceTests.test_classImplements_simple.<locals>.Current.method1c                 S   r   r   r   r  r   r   r   r  6  r   zCInterfaceTests.test_classImplements_simple.<locals>.Current.method2N)r   r   r   __implemented__r  r  r   r  r   r   Current0  s    r  )	r|   r  r   r{   r   r   r!   r   r"  )r$   r  r   r{   rC  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
}| }|  | | || |  || | ||| |  || | ||| d S )Nr   r  r   rz   c                   @   r   )zCInterfaceTests.test_classImplements_base_not_derived.<locals>.IBasec                   S   r   r  r   r   r   r   r   r  I  rW  zJInterfaceTests.test_classImplements_base_not_derived.<locals>.IBase.methodNr  r   r   r   r   rw  H  r   rw  c                   @   r   )zFInterfaceTests.test_classImplements_base_not_derived.<locals>.IDerivedNr   r   r   r   r   rx  L  r   rx  c                          e Zd Z Zdd ZdS )zEInterfaceTests.test_classImplements_base_not_derived.<locals>.Currentc                 S   r   r   r   rn   r   r   r   r  R  r   zLInterfaceTests.test_classImplements_base_not_derived.<locals>.Current.methodNr   r   r   r  r  r   rw  r   r   r  O      r  r|   r  r   r{   r   r   r   r"  )r$   r  r   r{   rx  r  r  r   r  r   %test_classImplements_base_not_derivedC  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
}| }| || |  | | ||| | |||  |  || | ||| | |||  |  || d S )Nr   r  r   rz   c                   @   r   )zCInterfaceTests.test_classImplements_base_and_derived.<locals>.IBasec                   S   r   r  r   r   r   r   r   r  d  rW  zJInterfaceTests.test_classImplements_base_and_derived.<locals>.IBase.methodNr  r   r   r   r   rw  c  r   rw  c                   @   r   )zFInterfaceTests.test_classImplements_base_and_derived.<locals>.IDerivedNr   r   r   r   r   rx  g  r   rx  c                       r  )zEInterfaceTests.test_classImplements_base_and_derived.<locals>.Currentc                 S   r   r   r   rn   r   r   r   r  m  r   zLInterfaceTests.test_classImplements_base_and_derived.<locals>.Current.methodNr  r   rx  r   r   r  j  r  r  )r|   r  r   r{   r   r"  r   Z	flattened)r$   r  r   r{   rw  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
}G fddd}G dd d||}| }|  | | | |  || | || |  || | || d S )Nr   r  r   rz   c                   @   r   )z;InterfaceTests.test_classImplements_multiple.<locals>.ILeftc                   S   r   r  r   r   r   r   r   r    rW  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   rn   r   r   r   r    r   zAInterfaceTests.test_classImplements_multiple.<locals>.Left.methodNr  r   r  r   r   Left  r  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  Zambir   )r  r  r   test_classImplements_multiple{  s   z,InterfaceTests.test_classImplements_multiplec                    s<  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}G fdddG fddd|}| }|  | | | | | |  || | || | || |  || | || | || d S )Nr   r  r   rz   c                   @   r   )zPInterfaceTests.test_classImplements_multiple_w_explict_implements.<locals>.ILeftc                   S   r   r  r   r   r   r   r   r    rW  zWInterfaceTests.test_classImplements_multiple_w_explict_implements.<locals>.ILeft.methodNr  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   rC    r   rC  c                       r  )zOInterfaceTests.test_classImplements_multiple_w_explict_implements.<locals>.Leftc                 S   r   r   r   rn   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   )rC  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  r/   r  r  )r$   r  r   r{   r  r  mixedr   )r  rC  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   r2  r   )r$   r  newr  r  r  r  r   r   r   testInterfaceExtendsInterface  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}| || d S )	Nr   r9  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    rW  z8InterfaceTests.test_verifyClass.<locals>.ICheckMe.methodNr   r   r   r  r  r   r9  r   r   ICheckMe      r  c                          e Zd Z ZdZdd ZdS )z0InterfaceTests.test_verifyClass.<locals>.CheckMevaluec                 S   r   r   r   rn   r   r   r   r    r   z7InterfaceTests.test_verifyClass.<locals>.CheckMe.methodNr   r   r   r  r  r  r   r  r   r   CheckMe      r  )r|   r:  r  rh   r  r   )r$   r  r  r  r   r:  r  r   test_verifyClass  s   zInterfaceTests.test_verifyClassc                    sd   ddl m  ddl m} ddlm} G  fddd|G fddd}| }| || d S )	Nr   r9  r  rf   c                       r  )z2InterfaceTests.test_verifyObject.<locals>.ICheckMer  c                   S   r   r  r   r   r   r   r   r    rW  z9InterfaceTests.test_verifyObject.<locals>.ICheckMe.methodNr  r   r9  r   r   r    r  r  c                       r  )z1InterfaceTests.test_verifyObject.<locals>.CheckMer  c                 S   r   r   r   rn   r   r   r   r    r   z8InterfaceTests.test_verifyObject.<locals>.CheckMe.methodNr  r   r  r   r   r    r  r  )r|   r:  r  rh   rg   r   )r$   r  rg   r  Zcheck_mer   r  r   test_verifyObject  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   AnInterface  r   r  )r|   r  r   r{   )r$   r  r  r   r   r   (test_interface_object_provides_Interface     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   r9  r  c                       r  )z1InterfaceTests.test_names_simple.<locals>.ISimpler  c                   S   r   r  r   r   r   r   r   r    rW  z8InterfaceTests.test_names_simple.<locals>.ISimple.methodNr  r   r9  r   r   ISimple  r  r  r  r  r|   r:  r  r!   r}  rZ  r$   r  r  r   r9  r   test_names_simple
     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   r9  r  c                       r  )z0InterfaceTests.test_names_derived.<locals>.IBaser  c                   S   r   r  r   r   r   r   r   r    rW  z7InterfaceTests.test_names_derived.<locals>.IBase.methodNr  r   r9  r   r   rw    r  rw  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  #  rW  z:InterfaceTests.test_names_derived.<locals>.IDerived.methodc                   S   r   r  r   r   r   r   r   r  &  rW  z;InterfaceTests.test_names_derived.<locals>.IDerived.method2Nr   r   r   attr2r  r  r   r9  r   r   rx         rx  )r$  r  r  Trz  r  r$  r  r  r  r$   r  rw  rx  r   r9  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 | 	|d d	   | |d d	 j
d | |d d	 jd
 | |d	 d d | 	|d	 d	 | | |d	 d	 j
d | |d	 d	 jd d S )Nr   r9  r  Methodc                       r  )z@InterfaceTests.test_namesAndDescriptions_simple.<locals>.ISimpler  c                   S   r   	My methodNr   r   r   r   r   r  6  rW  zGInterfaceTests.test_namesAndDescriptions_simple.<locals>.ISimple.methodNr  r   r9  r   r   r  3  r  r  r  r  r  r  r  r,  r|   r:  r  r    r*  r}  r  r!   r  r  r   r@   )r$   r  r*  r  name_valuesr   r9  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
 | 	|d d   | |d d j
d
 | |d d jd | |d d d | 	|d d | | |d d j
d | |d d jd | |d d d | 	|d d | | |d d j
d | |d d jd t|jdd}| t|d | |d d d | 	|d d   | |d d j
d | |d d jd | |d d d
 | 	|d d   | |d d j
d
 | |d d jd | |d d d | 	|d d | | |d d j
d | |d d jd | |d	 d d | 	|d	 d | | |d	 d j
d | |d	 d jd d S )Nr   r9  r  r)  c                       r  )z?InterfaceTests.test_namesAndDescriptions_derived.<locals>.IBaser  c                   S   r   r+  r   r   r   r   r   r  M  rW  zFInterfaceTests.test_namesAndDescriptions_derived.<locals>.IBase.methodNr  r   r9  r   r   rw  J  r  rw  c                       r!  )zBInterfaceTests.test_namesAndDescriptions_derived.<locals>.IDerivedr"  c                   S   r   My method, overriddenNr   r   r   r   r   r  S  rW  zIInterfaceTests.test_namesAndDescriptions_derived.<locals>.IDerived.methodc                   S   r   
My method2Nr   r   r   r   r   r  V  rW  zJInterfaceTests.test_namesAndDescriptions_derived.<locals>.IDerived.method2Nr#  r   r9  r   r   rx  P  r%  rx     r$  r  r"  r  r1  r  r  r3  Trz     r  r  r-  )r$   r  r*  rw  rx  r.  r   r9  r   !test_namesAndDescriptions_derivedE  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   r8  rJ   )r|   r  rK   rL   r  r$   r  r8  r   r   r   *test_getDescriptionFor_nonesuch_no_default}  r  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}| |  | |jd | |j	d |d	}| || | |jd	 | |j	d
 d S )Nr   r9  r  r)  c                       r  )z=InterfaceTests.test_getDescriptionFor_simple.<locals>.ISimpler  c                   S   r   r+  r   r   r   r   r   r    rW  zDInterfaceTests.test_getDescriptionFor_simple.<locals>.ISimple.methodNr  r   r9  r   r   r    r  r  r  r  r  r,  
r|   r:  r  r    r*  r  r  r!   r   r@   r$   r  r*  r  a_descm_descr   r9  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	}| |  | |jd	 | |j	d
 |d}| || | |jd | |j	d |d}| |  | |jd | |j	d |d}| || | |jd | |j	d d S )Nr   r9  r  r)  c                       r  )z<InterfaceTests.test_getDescriptionFor_derived.<locals>.IBaser  c                   S   r   r+  r   r   r   r   r   r    rW  zCInterfaceTests.test_getDescriptionFor_derived.<locals>.IBase.methodNr  r   r9  r   r   rw    r  rw  c                       r!  )z?InterfaceTests.test_getDescriptionFor_derived.<locals>.IDerivedr"  c                   S   r   r0  r   r   r   r   r   r    rW  zFInterfaceTests.test_getDescriptionFor_derived.<locals>.IDerived.methodc                   S   r   r2  r   r   r   r   r   r    rW  zGInterfaceTests.test_getDescriptionFor_derived.<locals>.IDerived.method2Nr#  r   r9  r   r   rx    r%  rx  r  r  r  r1  r$  r"  r  r3  r;  	r$   r  r*  rw  rx  r=  r>  Za2_descZm2_descr   r9  r   test_getDescriptionFor_derived  s*   
	


z-InterfaceTests.test_getDescriptionFor_derivedc                 C   r7  )Nr   r  c                   @   r   )z7InterfaceTests.test___getitem__nonesuch.<locals>.IEmptyNr   r   r   r   r   r8    r   r8  rJ   )r|   r  rK   rL   __getitem__r9  r   r   r   test___getitem__nonesuch  r  z'InterfaceTests.test___getitem__nonesuchc                    s   ddl m  ddl m} ddlm} G  fddd|}|d }| |  | |jd | |jd |d	 }| || | |jd	 | |jd
 d S )Nr   r9  r  r)  c                       r  )z6InterfaceTests.test___getitem__simple.<locals>.ISimpler  c                   S   r   r+  r   r   r   r   r   r    rW  z=InterfaceTests.test___getitem__simple.<locals>.ISimple.methodNr  r   r9  r   r   r    r  r  r  r  r  r,  	r|   r:  r  r    r*  r  r!   r   r@   r<  r   r9  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	 }| |  | |jd	 | |jd
 |d }| || | |jd | |jd |d }| |  | |jd | |jd |d }| || | |jd | |jd d S )Nr   r9  r  r)  c                       r  )z6InterfaceTests.test___getitem___derived.<locals>.IBaser  c                   S   r   r+  r   r   r   r   r   r    rW  z=InterfaceTests.test___getitem___derived.<locals>.IBase.methodNr  r   r9  r   r   rw    r  rw  c                       r!  )z9InterfaceTests.test___getitem___derived.<locals>.IDerivedr"  c                   S   r   r0  r   r   r   r   r   r    rW  z@InterfaceTests.test___getitem___derived.<locals>.IDerived.methodc                   S   r   r2  r   r   r   r   r   r    rW  zAInterfaceTests.test___getitem___derived.<locals>.IDerived.method2Nr#  r   r9  r   r   rx    r%  rx  r  r  r  r1  r$  r"  r  r3  rD  r@  r   r9  r   test___getitem___derived  s*   	z'InterfaceTests.test___getitem___derivedc                 C   s,   ddl m} G dd d|}| d| d S )Nr   r  c                   @   r   )z8InterfaceTests.test___contains__nonesuch.<locals>.IEmptyNr   r   r   r   r   r8  
  r   r8  rJ   )r|   r  r"  r9  r   r   r   test___contains__nonesuch  s   z(InterfaceTests.test___contains__nonesuchc                    sH   ddl m  ddl m} G  fddd|}| d| | d| d S )Nr   r9  r  c                       r  )z7InterfaceTests.test___contains__simple.<locals>.ISimpler  c                   S   r   r+  r   r   r   r   r   r    rW  z>InterfaceTests.test___contains__simple.<locals>.ISimple.methodNr  r   r9  r   r   r    r  r  r  r  r|   r:  r  r   r  r   r9  r   test___contains__simple  s
   z&InterfaceTests.test___contains__simplec                    st   ddl m  ddl m} G  fddd|}G  fddd|}| d| | d	| | d
| | d| d S )Nr   r9  r  c                       r  )z6InterfaceTests.test___contains__derived.<locals>.IBaser  c                   S   r   r+  r   r   r   r   r   r  #  rW  z=InterfaceTests.test___contains__derived.<locals>.IBase.methodNr  r   r9  r   r   rw     r  rw  c                       r!  )z9InterfaceTests.test___contains__derived.<locals>.IDerivedr"  c                   S   r   r0  r   r   r   r   r   r  )  rW  z@InterfaceTests.test___contains__derived.<locals>.IDerived.methodc                   S   r   r2  r   r   r   r   r   r  ,  rW  zAInterfaceTests.test___contains__derived.<locals>.IDerived.method2Nr#  r   r9  r   r   rx  &  r%  rx  r  r  r$  r  rH  r'  r   r9  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   r8  7  r   r8  )r|   r  r!   rB   r9  r   r   r   test___iter__empty4  r  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   r9  r  c                       r  )z3InterfaceTests.test___iter__simple.<locals>.ISimpler  c                   S   r   r+  r   r   r   r   r   r  C  rW  z:InterfaceTests.test___iter__simple.<locals>.ISimple.methodNr  r   r9  r   r   r  @  r  r  r  r  r|   r:  r  r!   r}  rB   r  r   r9  r   test___iter__simple<  r   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   r9  r  c                       r  )z2InterfaceTests.test___iter__derived.<locals>.IBaser  c                   S   r   r+  r   r   r   r   r   r  O  rW  z9InterfaceTests.test___iter__derived.<locals>.IBase.methodNr  r   r9  r   r   rw  L  r  rw  c                       r!  )z5InterfaceTests.test___iter__derived.<locals>.IDerivedr"  c                   S   r   r0  r   r   r   r   r   r  U  rW  z<InterfaceTests.test___iter__derived.<locals>.IDerived.methodc                   S   r   r2  r   r   r   r   r   r  X  rW  z=InterfaceTests.test___iter__derived.<locals>.IDerived.method2Nr#  r   r9  r   r   rx  R  r%  rx  r&  rL  r'  r   r9  r   test___iter__derivedH  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  b  rW  zSInterfaceTests.test_function_attributes_become_tagged_values.<locals>.ITagMe.methodr  N)r   r   r   r  optionalr   r   r   r   ITagMea  s    
rP  r  rO  r  )r|   r  r!   rM   )r$   r  rP  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   r@   r   r   r   r   IHaveADocStringl  r  rU  rS  )r|   r  r!   r@   rB   r$   r  rU  r   r   r   test___doc___non_elementi  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   r9  r  c                          e Zd ZdZ dZdS )z?InterfaceTests.test___doc___as_element.<locals>.IHaveADocStringrS  the docNrT  r   r9  r   r   rU  v  s    rU  r>   r@   r|   r:  r  r!   r@   rB   rV  r   r9  r   test___doc___as_elementr  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>)
ri  r  rK   r  failr!   r   r  sortpop)
r$   has_invariantZ	error_len
error_msgsr   r  er^  Z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	}| }||| | |d
tg | ||d  d|_	| ||d  d|_
| ||d  |`	| |ddg| d S )Nr   r9  r  directlyProvidesr
   c                       $   e Zd Z dZ dZe dS )z8InterfaceTests.test_invariant_simple.<locals>.IInvariantrQ   *bar; must eval to Boolean True if foo doesNr   r   r   rQ   r-   _ifFooThenBarr   r:  r   r   r   
IInvariant      ro  c                   @   r   )z:InterfaceTests.test_invariant_simple.<locals>.HasInvariantNr   r   r   r   r   HasInvariant  r   rq  r      *   r  If Foo, then Bar!)r|   r:  r  ri  r   r!   rM   rm  r  r-   rQ   rg  )r$   r  ri  ro  rq  rc  r   rn  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}| |dtg | }||| d|_| 	|ddg| d|_d|_
| 	|ddg| d|_d|_
| 	|dddg| d|_d|_
| ||d  d S )Nr   r9  r  rh  r
   c                       rj  )z8InterfaceTests.test_invariant_nested.<locals>.IInvariantrQ   rk  Nrl  r   rn  r   r   ro    rp  ro  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   rw  c                   @   r   )z:InterfaceTests.test_invariant_nested.<locals>.HasInvariantNr   r   r   r   r   rq    r   rq  r   rs  r  rt  r  %Please, Boo MUST be greater than Foo!)r|   r:  r  ri  r   r!   rM   rv  rQ   rg  r-   r  )r$   r  ri  ro  rw  rq  rc  r   rn  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	}| }||| 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   r9  r  rh  r
   c                       rj  )z:InterfaceTests.test_invariant_mutandis.<locals>.IInvariantrQ   rk  Nrl  r   rn  r   r   ro    rp  ro  c                   @   r   )z<InterfaceTests.test_invariant_mutandis.<locals>.HasInvariantNr   r   r   r   r   rq    r   rq  rs  r   r  rt  r  rx  )r|   r:  r  ri  r   rQ   rM   r  rv  rS   rg  r-   r!   r  )r$   r  ri  ro  rq  rc  Zold_invariantsr   r   rn  r   test_invariant_mutandis  sH   


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   r9  r  c                   @   rR  )z7InterfaceTests.test___doc___element.<locals>.IDocstringrS  NrT  r   r   r   r   
IDocstring  r  r{  rS  c                       rX  )zCInterfaceTests.test___doc___element.<locals>.IDocstringAndAttributerS  rY  NrT  r   r9  r   r   IDocstringAndAttribute  r  r|  r>   r@   rZ  )r$   r  r{  r|  r   r9  r   test___doc___element  s   z#InterfaceTests.test___doc___elementc              
      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
}||dd ||dd z||dd W d S  yk } z| t	|d W Y d }~d S d }~ww )Nr   r9  r  r>  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_invariant0  s   zJInterfaceTests.test_invariant_as_decorator.<locals>.IRange.range_invariantN)r   r   r   r  r  r  r   r:  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   8  r  zBInterfaceTests.test_invariant_as_decorator.<locals>.Range.__init__Nr   r   r   r   r   Range5  s    r  r  r  r~  )
r|   r:  r  r?  r   ri  r  r  r!   r   )r$   r  r?  r  r  re  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
|	 ddh d S )Nr   r9  r  r+   c                       s&   e Zd Z dZ dZdd dS )z0InterfaceTests.test_taggedValue.<locals>.ITaggedrQ   rk  r1   SpamN)r   r   r   rQ   r-   r   r:  r,   r   r   ITaggedG  s    r  c                       s    e Zd Z dd  dd dS )z1InterfaceTests.test_taggedValue.<locals>.IDerivedr1   	Spam SpamrQ   r-   Nr   r   r+   r   r   rx  L  s    
rx  c                   @   r   )z2InterfaceTests.test_taggedValue.<locals>.IDerived2Nr   r   r   r   r   	IDerived2P  r   r  r1   r  rQ   r  r-   )r|   r:  r  r,   r!   rM   rK   rL   rB   rC   set)r$   r  r  rx  r  r   r  r   test_taggedValueB  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   r9  r+   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  c  r  r  c                       r  )z0InterfaceTests._make_taggedValue_tree.<locals>.Dr  DNr  r   r  r   r   r  g  r  r  c                       r  )z0InterfaceTests._make_taggedValue_tree.<locals>.Cr  CNr  r   r  r   r   r  k  r  r  c                   @   r   )z0InterfaceTests._make_taggedValue_tree.<locals>.BNr   r   r   r   r   Bo  r   r  c                   @   r   )z0InterfaceTests._make_taggedValue_tree.<locals>.ANr   r   r   r   r   Ar  r   r  )r|   r:  r,   )r$   r  r  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   rM   rW   r  rS   )r$   r  Zclass_AZiface_Ar   r   r   "test_getTaggedValue_follows__iro__w  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  r+  ra   r!   rB   rR   rK   rL   r^   rS   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
 |f|_| |d
 d S )Nr   r9  r  c                       r;  )z<InterfaceTests.test_description_cache_management.<locals>.I1r   N)r   r   r   r   r   r9  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:  r  r   r'  r  r+  )r$   r  r  r  r  r   r9  r   !test_description_cache_management  s   z0InterfaceTests.test_description_cache_managementc                 C   sT   ddl m} ddl m} G dd d|}||G dd d}| || d d S )Nr   r  r>  c                   @   r   )zAInterfaceTests.test___call___defers_to___conform___.<locals>.IFooNr   r   r   r   r   r$    r   r$  c                   @   r   )z>InterfaceTests.test___call___defers_to___conform___.<locals>.Cc                 S   r   )Nr   r   )r$   protor   r   r   r     ry   zJInterfaceTests.test___call___defers_to___conform___.<locals>.C.__conform__Nr   r   r   r   r   r    r   r  )r|   r  r?  r!   )r$   r  r?  r$  r  r   r   r   $test___call___defers_to___conform___  s   z3InterfaceTests.test___call___defers_to___conform___c                 C   sX   ddl m} ddl m} G dd d|}||G dd d}| }| ||| d S )Nr   r  r>  c                   @   r   )z<InterfaceTests.test___call___object_implements.<locals>.IFooNr   r   r   r   r   r$    r   r$  c                   @   r   )z9InterfaceTests.test___call___object_implements.<locals>.CNr   r   r   r   r   r    rE  r  )r|   r  r?  r   )r$   r  r?  r$  r  cr   r   r   test___call___object_implements  s   z.InterfaceTests.test___call___object_implementsc                 C   sB   ddl m} G dd d|}G dd d}| }| t|| d S )Nr   r  c                   @   r   )z<InterfaceTests.test___call___miss_wo_alternate.<locals>.IFooNr   r   r   r   r   r$    r   r$  c                   @   r   )z9InterfaceTests.test___call___miss_wo_alternate.<locals>.CNr   r   r   r   r   r    r   r  )r|   r  rK   r   r$   r  r$  r  r  r   r   r   test___call___miss_wo_alternate  s
   z.InterfaceTests.test___call___miss_wo_alternatec                 C   sF   ddl m} G dd d|}G dd d}| }| ||| |  d S )Nr   r  c                   @   r   )z;InterfaceTests.test___call___miss_w_alternate.<locals>.IFooNr   r   r   r   r   r$    r   r$  c                   @   r   )z8InterfaceTests.test___call___miss_w_alternate.<locals>.CNr   r   r   r   r   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}| }|d d  }||g|d d < z ||  W ||d d < d S ||d d < w )Nr   r  r  c                 S   r   r   r   r  r   r   r   _miss  ry   z:InterfaceTests.test___call___w_adapter_hook.<locals>._missc                    ru   r   r   r  rn   r   r   _hit  ry   z9InterfaceTests.test___call___w_adapter_hook.<locals>._hitc                   @   r   )z9InterfaceTests.test___call___w_adapter_hook.<locals>.IFooNr   r   r   r   r   r$    r   r$  c                   @   r   )z6InterfaceTests.test___call___w_adapter_hook.<locals>.CNr   r   r   r   r   r    r   r  )r|   r  r    r	  r   )	r$   r  r	  r  r  r$  r  r  Zold_adapter_hooksr   rn   r   test___call___w_adapter_hook  s   z+InterfaceTests.test___call___w_adapter_hookc                    sv   ddl m} ddl m} ddl m  G  fddd|}||G dd d}| d	|t  | d	||  d S )
Nr   r  r>  interfacemethodc                          e Zd Z dd ZdS )z=InterfaceTests.test___call___w_overridden_adapt.<locals>.IFooc                 S   r   Nrs  r   r   r   r   r   r   	  r   zGInterfaceTests.test___call___w_overridden_adapt.<locals>.IFoo.__adapt__Nr   r   r   r   r   r  r   r   r$  		  s    r$  c                   @   r   )z<InterfaceTests.test___call___w_overridden_adapt.<locals>.ObjNr   r   r   r   r   Obj	  rE  r  rs  )r|   r  r?  r  r!   r   )r$   r  r?  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
}||G dd d}| d|t  | d||  | d||  | t ||  W d    n1 sjw   Y  | d||  d S )Nr   r  r>  r  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                   @   rR  )zLInterfaceTests.test___call___w_overridden_adapt_and_conform.<locals>.ISimplezNothing special.NrT  r   r   r   r   r  $	  r  r  c                   @   r   )zNInterfaceTests.test___call___w_overridden_adapt_and_conform.<locals>.Conform24c                 S   r   N   r   r   r   r   r   r   )	  ry   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   .	  ry   z\InterfaceTests.test___call___w_overridden_adapt_and_conform.<locals>.ConformNone.__conform__Nr   r   r   r   r   ConformNone,	  r   r  rs  r  )r|   r  r?  r  r!   r   rK   r   )r$   r  r?  r  r  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}| d	|t  | }| ||| d S )
Nr   r  r>  r  c                       s    e Zd Z fddZ  ZS )zHInterfaceTests.test___call___w_overridden_adapt_call_super.<locals>.IFooc                    s   |  |sdS t |S r  )r{   superr   r   r  r   r   r   D	  s   
zRInterfaceTests.test___call___w_overridden_adapt_call_super.<locals>.IFoo.__adapt__)r   r   r   r   __classcell__r   r  r  r   r$  B	  s    r$  c                   @   r   )zGInterfaceTests.test___call___w_overridden_adapt_call_super.<locals>.ObjNr   r   r   r   r   r  J	  rE  r  rs  )sysr|   r  r?  r  r!   r   r   )r$   r  r  r?  r$  r  rw   r   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 )zHInterfaceTests.test___adapt___as_method_and_implementation.<locals>.IFooc                 S   r   r  r   r   r   r   r   r   W	  r   zRInterfaceTests.test___adapt___as_method_and_implementation.<locals>.IFoo.__adapt__c                 S   r   )zThis is a protocolNr   )Zto_adaptr   r   r   r   [	  rW  Nr  r   r  r   r   r$  V	  s    
r$  rs  r   z
(to_adapt))r|   r  r  r!   r   getSignatureStringr$   r  r$  r   r  r   +test___adapt___as_method_and_implementationR	  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                   @   rR  )z@InterfaceTests.test___adapt__inheritance_and_type.<locals>.IRootZRootNrT  r   r   r   r   IRoote	  r  r  c                       r  )zEInterfaceTests.test___adapt__inheritance_and_type.<locals>.IWithAdaptc                 S   r   r  r   r   r   r   r   r   i	  r   zOInterfaceTests.test___adapt__inheritance_and_type.<locals>.IWithAdapt.__adapt__Nr  r   r  r   r   
IWithAdapth	  r  r  c                   @   rR  )zAInterfaceTests.test___adapt__inheritance_and_type.<locals>.IOtherzSecond branchNrT  r   r   r   r   rC  m	  r  rC  c                   @   rR  )zEInterfaceTests.test___adapt__inheritance_and_type.<locals>.IUnrelatedZ	UnrelatedNrT  r   r   r   r   
IUnrelatedp	  r  r  c                   @   rR  )zHInterfaceTests.test___adapt__inheritance_and_type.<locals>.IDerivedAdaptzInherits an adaptNrT  r   r   r   r   IDerivedAdapts	  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   y	  r   zSInterfaceTests.test___adapt__inheritance_and_type.<locals>.IDerived2Adapt.__adapt__N)r   r   r   r@   r   r   r  r   r   IDerived2Adaptw	  s    r  rs  r  )
r|   r  r  r!   r   r   r   r  r  r  )	r$   r  r  r  rC  r  r  r  r   r   r  r   "test___adapt__inheritance_and_typea	  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 )z<InterfaceTests.test_interfacemethod_is_general.<locals>.IFooc                 S   r   )zReplace an existing methodrs  r   r   r   r   r   r  	  s   zEInterfaceTests.test_interfacemethod_is_general.<locals>.IFoo.__call__c                 S   r   r  r   rn   r   r   r   this_is_new	  r   zHInterfaceTests.test_interfacemethod_is_general.<locals>.IFoo.this_is_newN)r   r   r   r  r  r   r  r   r   r$  	  s
    
r$  rs  )r|   r  r  r!   r  r  r   r  r   test_interfacemethod_is_general	  s
   z.InterfaceTests.test_interfacemethod_is_generalN)7r   r   r   r  r  r  r  r  r  r  r
  r  r  r  r  r(  r/  r6  r:  r?  rA  rC  rE  rF  rG  rI  rJ  rK  rM  rN  rQ  rW  r[  rg  ru  ry  rz  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   r    sj    		"!+8((	/9#,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   r7   )Nr   r9  )r    r:  )r$   r:  r   r   r   r9   	  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  rr   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_interface	  s   
z'AttributeTests.test__repr__wo_interfacec                 C   s.   |   }t| |_t|}| |td  d S )Nz.AttributeTests.TestAttribute)r=   r  rr   r   r!   r   r  r   r   r   test__str__w_interface	  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;   r9   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 )MethodTestsZ
TestMethodc                 C   r7   )Nr   r)  )r    r*  )r$   r*  r   r   r   r9   	  r:   zMethodTests._getTargetClassc                 C   sH   |   }| |ji  ddi|_| |jddi |`| |ji  d S rP   )r=   r!   rO  r$   r  r   r   r   test_optional_as_property	  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)ri  r  r=   r!   rr   r<   r;   r`  )r$   r  r  re  r   r   r   )test___call___raises_BrokenImplementation	  s   
z5MethodTests.test___call___raises_BrokenImplementationc                 C   sl   |   }| }| t|d g  | t|d g  | |d i  | |d d  | |d d  d S )N
positionalrequiredrO  varargskwargs)r=   getSignatureInfor!   rB   )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_bare	  rO   z(MethodTests.test_getSignatureString_barec                 C   s*   |   }dg |_|_| | d d S )NrQ   z(foo))r=   r  r  r!   r  r  r   r   r   'test_getSignatureString_w_only_required	  s   z3MethodTests.test_getSignatureString_w_only_requiredc                 C   s4   |   }dg |_|_ddi|_| | d d S )NrQ   r-   z(foo='bar'))r=   r  r  rO  r!   r  r  r   r   r   "test_getSignatureString_w_optional	  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_varargs	  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  rr   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  rr   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;   r9   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	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   rR  )r    rS  )r$   r   r   rS  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   rT  r   r   r   r   r   _func/
  rW  z*Test_fromFunction.test_bare.<locals>._funcr  rU  r  r  rO  r  r  r  r!   r?   rA   rr   rB   rC   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   rI  c                   @   r   )z0Test_fromFunction.test_w_interface.<locals>.IFooNr   r   r   r   r   r$  A
  r   r$  c                   S   r   rT  r   r   r   r   r   r  D
  rW  z1Test_fromFunction.test_w_interface.<locals>._funcrq   )r    rJ  r  r!   rr   )r$   rJ  r$  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   rT  r   r   r   r   r   r  L
  rW  z,Test_fromFunction.test_w_name.<locals>._funcZanotherName)r<   )r  r!   r?   )r$   r  r  r   r   r   test_w_nameJ
  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   rT  r   rQ   r   r   r   r  T
  rW  z5Test_fromFunction.test_w_only_required.<locals>._funcr  rQ   r  rO  r  r  r  r  r!   rB   r  r   r   r   test_w_only_requiredR
  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   rT  r   r  r   r   r   r  a
  rW  z0Test_fromFunction.test_w_optional.<locals>._funcr  rQ   r  rO  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   rT  r   rn   r   r   r   r  u
  rW  z5Test_fromFunction.test_w_optional_self.<locals>._funcr  )Zimlevelr  r  rO  r  r  r  r  r  r   r   r   test_w_optional_selfl
  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   rT  r   r\  r   r   r   r  
  rW  z/Test_fromFunction.test_w_varargs.<locals>._funcr  r  rO  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   rT  r   )r   r   r   r   r  
  rW  z.Test_fromFunction.test_w_kwargs.<locals>._funcr  r  rO  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   rT  r   )rQ   r-   r   r   r   r   r   r  
  rW  z3Test_fromFunction.test_full_spectrum.<locals>._funcr  rQ   r-   r  rO  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}|  |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   rT  r   rn   r   r   r   r-   
  rW  z-Test_fromMethod.test_no_args.<locals>.Foo.barNr<  r   r   r   r   r   
  r   r   r-   rU  r  r  rO  r  r  )	r  r-   r!   r?   rA   rr   rB   rC   r  r$   r   r  r  r   r   r   test_no_args
  s   zTest_fromMethod.test_no_argsc                 C   s   G dd d}|  |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   rT  r   )r$   rQ   r-   r   r   r   r   r   r-   
  rW  z3Test_fromMethod.test_full_spectrum.<locals>.Foo.barNr  r<  r   r   r   r   r   
  s    r   r  rQ   r-   r  rO  r.   r  r   r  r   )r  r-   r  r!   rB   r  r   r   r   r  
  s   z"Test_fromMethod.test_full_spectrumc                 C   r  )
Nc                   S   r   rT  r   r   r   r   r   rQ   
  rW  z.Test_fromMethod.test_w_non_method.<locals>.foorQ   rU  r  r  rO  r  r  r  )r$   rQ   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   )r&  rn   r   r   r   r   
  ro   zDummyDependent.__init__c                 C   s   | j | d S r   )r&  r  )r$   Zoriginally_changedr   r   r   r*  
  s   zDummyDependent.changedN)r   r   r   r   r*  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  rQ   r-   rx  )ri  r  r"   
isinstancer  )rw   r  rQ   r-   r   r   r   rv  
  s   rv  c                 C   s4   ddl m} t| dd rt| dd s|dd S d S )Nr   r  rQ   r-   rt  )ri  r  r"   )rw   r  r   r   r   rm  
  s   rm  c                   @   r)   )r~   c                    s<    | _  fdd|D | _| D ]
\}}t || qd S )Nc                    s   i | ]}|t  |qS r   )r"   )r]  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     s
   z_Monkey.__init__c                 C   s   | S r   r   rn   r   r   r   	__enter__  ry   z_Monkey.__enter__c                 C   s&   | j  D ]\}}t| j|| qd S r   )r  r  r  r   )r$   exc_typeexc_valexc_tbr  r  r   r   r   __exit__  s   z_Monkey.__exit__N)r   r   r   r   r	  r  r   r   r   r   r~      s    r~   c                   @   s    e Zd ZdZdd Zdd ZdS )TestTypeAnnotationsz*Test using Interfaces in type annotations.c                    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
}| |j|  | f d d S )Nr   OptionalUnionr  c                   @   r   )z+TestTypeAnnotations.test___or__.<locals>.I1Nr   r   r   r   r   r    r   r  c                   @   r   )z+TestTypeAnnotations.test___or__.<locals>.I2Nr   r   r   r   r   r    r   r  c                       s&   e Zd ZU  dB ed<  B ed< dS )z*TestTypeAnnotations.test___or__.<locals>.BNr   r   r   r   r   rc  r   r  r  r   r   r       
 r  r  typingr  r  r|   r  r!   rc  r$   r  r  r  r  r   r  r   test___or__  s   zTestTypeAnnotations.test___or__c                    sz   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
}| |j| | f d d S )Nr   r  r  r  c                   @   r   )z,TestTypeAnnotations.test___ror__.<locals>.I1Nr   r   r   r   r   r  ,  r   r  c                   @   r   )z+TestTypeAnnotations.test___ror__.<locals>.ANr   r   r   r   r   r  /  r   r  c                       s&   e Zd ZU dB ed<  B ed< dS )z+TestTypeAnnotations.test___ror__.<locals>.BNr   r   r  r   r  r  r   r   r  2  r  r  r  r  r  r   r  r   test___ror__&  s   z TestTypeAnnotations.test___ror__N)r   r   r   r@   r  r  r   r   r   r   r    s    r  ) r@   ZunittestZzope.interface.testsr   r   r   r   r   r  ZTestCaser   r*   r6   rj   r   r   r   r   r   r   r  rH  r  r  r  r  r  r  rv  rm  r~   r  r   r   r   r   <module>   sj   !$J
"4k
4% *    |         '` :	