U
    ؒ]%                    @   s$  d Z ddlZddlmZ ddlmZ ddlmZ G dd dejZ	G dd	 d	e	Z
G d
d dejZG dd dejZG dd de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eZG dd dee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ZdS )"zComponent Registry Tests    N	Interface)VerifyingAdapterRegistry
Componentsc                   @   sf  e Zd Zdd Zdd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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] Z0d^d_ Z1d`da Z2dbdc Z3ddde Z4dfdg Z5dhdi Z6djdk Z7dldm Z8dndo Z9dpdq Z:drds Z;dtdu Z<dvdw Z=dxdy Z>dzd{ Z?d|d} Z@d~d ZAdd ZBdd ZCdd ZDdd ZEdd ZFdd ZGdd ZHdd ZIdd ZJdd ZKdd ZLdd ZMdd ZNdd ZOdd ZPdd ZQdd ZRdd ZSdd ZTdd ZUdd ZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z`dd Zadd ZbddÄ Zcddń ZdddǄ ZeddɄ Zfdd˄ Zgdd̈́ Zhddτ Ziddф Zjddӄ ZkddՄ Zlddׄ ZmdS )ComponentsTestsc                 C   s   t S Nr   self r   D/usr/lib/python3/dist-packages/zope/interface/tests/test_registry.py_getTargetClass   s    zComponentsTests._getTargetClasstestc                 O   s   |   |f||S r   r   )r
   nameargskwr   r   r   _makeOne   s    zComponentsTests._makeOnec                    s0   ddl m} g   fdd}t||d}| fS )Nr   )registryc                     s     | |f d S r   append)r   r   _eventsr   r   _notify"   s    z,ComponentsTests._wrapEvents.<locals>._notify)Znotify)zope.interfacer   _Monkey)r
   r   r   _monkeyr   r   r   _wrapEvents   s
    zComponentsTests._wrapEventsc                 C   s   ddl m} | d}| |jd | |jd | t|j| | t|j	| | |jjd | |j	jd | |j
i  | |ji  | |jg  | |jg  d S )Nr   )AdapterRegistrytestingr   )zope.interface.adapterr   r   assertEqual__name__	__bases__
assertTrue
isinstanceadapters	utilities_utility_registrations_adapter_registrations_subscription_registrations_handler_registrations)r
   r   compr   r   r   test_ctor_no_bases'   s    
z"ComponentsTests.test_ctor_no_basesc                 C   sb   |  d}|  d|f}| |jd | |j|f | |jj|jf | |jj|jf d S )Nbaser   )r   r!   r"   r#   r&   r'   )r
   r.   r,   r   r   r   test_ctor_w_base5   s    
z ComponentsTests.test_ctor_w_basec                 C   s   |  d}| t|d d S )Nr   z<Components testing>)r   r!   reprr
   r,   r   r   r   test___repr__=   s    
zComponentsTests.test___repr__c                 C   sl   |  d}|  d}|   }||f|_| |j||f | |jj|j|jf | |jj|j|jf d S )Nbase1base2)r   r#   r!   r&   r'   )r
   r3   r4   r,   r   r   r   test_assign_to___bases__C   s    






z(ComponentsTests.test_assign_to___bases__c           	      C   s   ddl m}m} G dd d|}|d}|dG dd dt}| }d}|  }|j|||d	 | |j|df ||d f d S )
Nr   namedInterfaceClassc                   @   s   e Zd ZdS )zFComponentsTests.test_registerUtility_with_component_name.<locals>.IFooNr"   
__module____qualname__r   r   r   r   IFooR   s   r<   fooc                   @   s   e Zd ZdS )zEComponentsTests.test_registerUtility_with_component_name.<locals>.FooNr9   r   r   r   r   FooV   s   r>   infor?   )zope.interface.declarationsr7   r8   objectr   registerUtilityr!   r(   )	r
   r7   r8   r<   ifoor>   r=   _infor,   r   r   r   (test_registerUtility_with_component_nameN   s    z8ComponentsTests.test_registerUtility_with_component_namec                 C   s.   dd }t  }|  }| jt|j||d d S )Nc                   S   s
   t  d S r   NotImplementedErrorr   r   r   r   _factoryc   s    zQComponentsTests.test_registerUtility_both_factory_and_component.<locals>._factory	componentfactoryrB   r   assertRaises	TypeErrorrC   r
   rI   _to_regr,   r   r   r   /test_registerUtility_both_factory_and_componentb   s    
 z?ComponentsTests.test_registerUtility_both_factory_and_componentc              	   C   s  ddl m} ddlm} ddlm} G dd d|}|d}d}d}t }|  }	|  \}
}|
 |		|||| W 5 Q R X | 
|	jjd | | |k | |	j||f ||d f | |	jjd | d	 |f | t|d
 |d \}}|\}| |i  | 
t|| | 
t|j| | 
|jj|	k | 
|jj|k | 
|jj|k | 
|jj|k | 
|jj|k | 
|jjd k d S )Nr   r8   
RegisteredUtilityRegistrationc                   @   s   e Zd ZdS )z>ComponentsTests.test_registerUtility_w_component.<locals>.IFooNr9   r   r   r   r   r<   o   s   r<   r?   r       )rA   r8   zope.interface.interfacesrU   zope.interface.registryrW   rB   r   r   rC   r$   r'   	_adaptersr!   r(   _subscriberslenr%   r   providedr   rK   r?   rL   )r
   r8   rU   rW   r<   rD   rE   _namerQ   r,   r   r   r   r   eventr   r   r    test_registerUtility_w_componentj   s:    z0ComponentsTests.test_registerUtility_w_componentc              	      sN  ddl m} ddlm} ddlm} G dd d|}|d}d}d}t   fd	d
}|  }	|  \}
}|
 |	j	d ||||d W 5 Q R X | 
t|d |d \}}|\}| 
|i  | t|| | t|j| | |jj|	k | |jj|k | |jj|k | |jj k | |jj|k | |jj|k d S )Nr   rS   rT   rV   c                   @   s   e Zd ZdS )z<ComponentsTests.test_registerUtility_w_factory.<locals>.IFooNr9   r   r   r   r   r<      s   r<   r?   r   c                      s    S r   r   r   rQ   r   r   rI      s    z@ComponentsTests.test_registerUtility_w_factory.<locals>._factoryrL   rY   )rA   r8   rZ   rU   r[   rW   rB   r   r   rC   r!   r^   r$   r%   r   r_   r   rK   r?   rL   )r
   r8   rU   rW   r<   rD   rE   r`   rI   r,   r   r   r   r   ra   r   rc   r   test_registerUtility_w_factory   s2    z.ComponentsTests.test_registerUtility_w_factoryc                 C   s@   G dd dt }d}d}| }|  }| t|j|d || d S )Nc                   @   s   e Zd ZdS )zGComponentsTests.test_registerUtility_no_provided_available.<locals>.FooNr9   r   r   r   r   r>      s   r>   r?   r   rM   )r
   r>   rE   r`   rQ   r,   r   r   r   *test_registerUtility_no_provided_available   s        z:ComponentsTests.test_registerUtility_no_provided_availablec              	   C   sd  ddl m} ddl m} ddlm} ddlm} G dd d|}G dd	 d	t}|d}d
}d}	| }
||
| |  }| 	 \}}| |
|
d |	| W 5 Q R X | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|k | |jj|k | |jj|	k | |jj|
k | |jj|k | |jjd k d S )Nr   directlyProvidesrS   rT   rV   c                   @   s   e Zd ZdS )z>ComponentsTests.test_registerUtility_wo_provided.<locals>.IFooNr9   r   r   r   r   r<      s   r<   c                   @   s   e Zd ZdS )z=ComponentsTests.test_registerUtility_wo_provided.<locals>.FooNr9   r   r   r   r   r>      s   r>   r?   r   rY   )rA   rh   r8   rZ   rU   r[   rW   rB   r   r   rC   r!   r^   r$   r%   r   r_   r   rK   r?   rL   )r
   rh   r8   rU   rW   r<   r>   rD   rE   r`   rQ   r,   r   r   r   r   ra   r   r   r    test_registerUtility_wo_provided   s6    
z0ComponentsTests.test_registerUtility_wo_providedc           
   	   C   s   ddl m} G dd d|}|d}d}d}t }|  }||||| |  \}}	| ||||| W 5 Q R X | t|	d d S )Nr   rS   c                   @   s   e Zd ZdS )zJComponentsTests.test_registerUtility_duplicates_existing_reg.<locals>.IFooNr9   r   r   r   r   r<      s   r<   r?   r   )rA   r8   rB   r   rC   r   r!   r^   
r
   r8   r<   rD   rE   r`   rQ   r,   r   r   r   r   r   ,test_registerUtility_duplicates_existing_reg   s    z<ComponentsTests.test_registerUtility_duplicates_existing_regc              	   C   s   ddl m} G dd d|}|d}d}d}d}t }|  }||||| |  \}	}
|	 ||||| W 5 Q R X | t|
d | |j||f ||d f | |j	j
d | d	 |f d S )
Nr   rS   c                   @   s   e Zd ZdS )zCComponentsTests.test_registerUtility_w_different_info.<locals>.IFooNr9   r   r   r   r   r<      s   r<   Zinfo1Zinfo2r      rX   rA   r8   rB   r   rC   r   r!   r^   r(   r'   r]   )r
   r8   r<   rD   Z_info1Z_info2r`   rQ   r,   r   r   r   r   r   %test_registerUtility_w_different_info   s&    z5ComponentsTests.test_registerUtility_w_different_infoc              	   C   s   ddl m} G dd d|}|d}d}d}d}t }t }|  }	|	|||| |  \}
}|
 |	|||| W 5 Q R X | t|d | |	j||f ||d f | |	j||f ||d f | |	j	j
d | d	 ||f d S )
Nr   rS   c                   @   s   e Zd ZdS )zSComponentsTests.test_registerUtility_w_different_names_same_component.<locals>.IFooNr9   r   r   r   r   r<      s   r<   r?   name1name2rY   rX   rm   r
   r8   r<   rD   rE   _name1_name2Z
_other_regrQ   r,   r   r   r   r   r   5test_registerUtility_w_different_names_same_component   s.    zEComponentsTests.test_registerUtility_w_different_names_same_componentc              	   C   s  ddl m} ddlm} ddlm} ddlm} G dd d|}|d}d}d	}t t  }	}
|  }|	|	||| | 
 \}}| |	|
||| W 5 Q R X | t|d
 |d \}}|\}| |i  | t|| | t|j| | |jj|k | |jj|k | |jj|k | |jj|	k | |jj|k | |jjd k |d \}}|\}| |i  | t|| | t|j| | |jj|k | |jj|k | |jj|k | |jj|
k | |jj|k | |jjd k d S )Nr   rS   UnregisteredrT   rV   c                   @   s   e Zd ZdS )zHComponentsTests.test_registerUtility_replaces_existing_reg.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   r   rl   rY   )rA   r8   rZ   rv   rU   r[   rW   rB   r   rC   r   r!   r^   r$   r%   r   r_   r   rK   r?   rL   )r
   r8   rv   rU   rW   r<   rD   rE   r`   Z_beforeZ_afterr,   r   r   r   r   ra   r   r   r   *test_registerUtility_replaces_existing_reg  sJ    z:ComponentsTests.test_registerUtility_replaces_existing_regc              	   C   s   ddl m} G dd d|}|d}d}d}d}t }|  }||||| |  \}	}
|	 ||||| W 5 Q R X | |jjd | d |f d S )	Nr   rS   c                   @   s   e Zd ZdS )zDComponentsTests.test_registerUtility_w_existing_subscr.<locals>.IFooNr9   r   r   r   r   r<   <  s   r<   r?   ro   rp   rX   )	rA   r8   rB   r   rC   r   r!   r'   r]   r
   r8   r<   rD   rE   rr   rs   rQ   r,   r   r   r   r   r   &test_registerUtility_w_existing_subscr9  s    z6ComponentsTests.test_registerUtility_w_existing_subscrc           
   	   C   s|   ddl m} G dd d|}|d}d}d}t }|  }|  \}}	| |||||d W 5 Q R X | t|	d d S )Nr   rS   c                   @   s   e Zd ZdS )z;ComponentsTests.test_registerUtility_wo_event.<locals>.IFooNr9   r   r   r   r   r<   M  s   r<   r?   r   F)rA   r8   rB   r   r   rC   r!   r^   rj   r   r   r   test_registerUtility_wo_eventJ  s    z-ComponentsTests.test_registerUtility_wo_eventc                    s~   G  fddd|      }|t t | tt| d G dd dt}|t | | tt| d d S )Nc                       s"   e Zd ZdZ fddZ  ZS )zdComponentsTests.test_registerUtility_changes_object_identity_after.<locals>.CompThatChangesAfter1Regr   c                    s8   |  j d7  _ t | j|  | j dkr4t| j| _d S )NrY   )	reg_countsuperrC   dictr(   r
   r   )CompThatChangesAfter1Reg	__class__r   r   rC   ^  s    
ztComponentsTests.test_registerUtility_changes_object_identity_after.<locals>.CompThatChangesAfter1Reg.registerUtilityr"   r:   r;   r{   rC   __classcell__r   r   r   r   r   \  s   r   rY   c                   @   s   e Zd ZdS )zPComponentsTests.test_registerUtility_changes_object_identity_after.<locals>.IFooNr9   r   r   r   r   r<   i  s   r<   rl   r   rC   rB   r   r!   r^   listregisteredUtilities)r
   r,   r<   r   r   r   2test_registerUtility_changes_object_identity_afterY  s    zBComponentsTests.test_registerUtility_changes_object_identity_afterc                    s   G  fddd|      }|t t | tt| d G dd dt}|t | | tt| d G dd dt}|t | | tt| d	 d S )
Nc                       s"   e Zd ZdZ fddZ  ZS )zeComponentsTests.test_registerUtility_changes_object_identity_before.<locals>.CompThatChangesAfter2Regr   c                    s8   |  j d7  _ | j dkr$t| j| _t | j|  d S )NrY   rl   )r{   r}   r(   r|   rC   r~   )CompThatChangesAfter2Regr   r   r   rC   t  s    
zuComponentsTests.test_registerUtility_changes_object_identity_before.<locals>.CompThatChangesAfter2Reg.registerUtilityr   r   r   r   r   r   r  s   r   rY   c                   @   s   e Zd ZdS )zQComponentsTests.test_registerUtility_changes_object_identity_before.<locals>.IFooNr9   r   r   r   r   r<     s   r<   rl   c                   @   s   e Zd ZdS )zQComponentsTests.test_registerUtility_changes_object_identity_before.<locals>.IBarNr9   r   r   r   r   IBar  s   r      r   )r
   r,   r<   r   r   r   r   3test_registerUtility_changes_object_identity_beforeo  s    	zCComponentsTests.test_registerUtility_changes_object_identity_beforec                 C   s"   |   }| jt|jd d d d d S )N)rK   r_   rL   )r   rN   rO   unregisterUtilityr1   r   r   r   Atest_unregisterUtility_neither_factory_nor_component_nor_provided  s    
  zQComponentsTests.test_unregisterUtility_neither_factory_nor_component_nor_providedc                 C   s.   dd }t  }|  }| jt|j||d d S )Nc                   S   s
   t  d S r   rG   r   r   r   r   rI     s    zSComponentsTests.test_unregisterUtility_both_factory_and_component.<locals>._factoryrJ   )rB   r   rN   rO   r   rP   r   r   r   1test_unregisterUtility_both_factory_and_component  s    
 zAComponentsTests.test_unregisterUtility_both_factory_and_componentc           
   	   C   sx   ddl m} G dd d|}|d}d}t }|  }|  \}}| ||||}	W 5 Q R X | |	 | | d S )Nr   rS   c                   @   s   e Zd ZdS )zEComponentsTests.test_unregisterUtility_w_component_miss.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   )rA   r8   rB   r   r   r   assertFalse)
r
   r8   r<   rD   r`   rQ   r,   r   r   unregr   r   r   'test_unregisterUtility_w_component_miss  s    
z7ComponentsTests.test_unregisterUtility_w_component_missc              	   C   sn  ddl m} ddlm} ddlm} G dd d|}|d}d}t }|  }|||| | 	 \}	}
|	 |
|||}W 5 Q R X | | | |jj | ||f|jk | |jj | t|
d |
d \}}|\}| |i  | t|| | t|j| | |jj|k | |jj|k | |jj|k | |jj|k | |jjd k d S )	Nr   rS   ru   rV   c                   @   s   e Zd ZdS )z@ComponentsTests.test_unregisterUtility_w_component.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   rY   )rA   r8   rZ   rv   r[   rW   rB   r   rC   r   r   r$   r   r'   r\   r(   r]   r!   r^   r%   r   r_   r   rK   rL   )r
   r8   rv   rW   r<   rD   r`   rQ   r,   r   r   r   r   r   ra   r   r   r   "test_unregisterUtility_w_component  s6    
z2ComponentsTests.test_unregisterUtility_w_componentc              	      sX  ddl m} ddlm} ddlm} G dd d|}|d}d}d}t   fd	d
}|  }	|	jd ||||d | 	 \}
}|
 |	j
d |||d}W 5 Q R X | | | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|	k | |jj|k | |jj|k | |jj k | |jj|k d S )Nr   rS   ru   rV   c                   @   s   e Zd ZdS )z>ComponentsTests.test_unregisterUtility_w_factory.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   r   c                      s    S r   r   r   rc   r   r   rI     s    zBComponentsTests.test_unregisterUtility_w_factory.<locals>._factoryrd   rY   )rA   r8   rZ   rv   r[   rW   rB   r   rC   r   r   r$   r!   r^   r%   r   r_   r   rK   rL   )r
   r8   rv   rW   r<   rD   rE   r`   rI   r,   r   r   r   r   r   ra   r   rc   r    test_unregisterUtility_w_factory  s4    
z0ComponentsTests.test_unregisterUtility_w_factoryc              	   C   s|  ddl m} ddl m} ddlm} ddlm} G dd d|}G dd	 d	t}|d}d
}d}	| }
||
| |  }|	|
||	| | 
 \}}| ||
d |	}W 5 Q R X | | | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|k | |jj|k | |jj|	k | |jj|
k | |jj|k | |jjd k d S )Nr   rg   rS   ru   rV   c                   @   s   e Zd ZdS )zIComponentsTests.test_unregisterUtility_wo_explicit_provided.<locals>.IFooNr9   r   r   r   r   r<     s   r<   c                   @   s   e Zd ZdS )zHComponentsTests.test_unregisterUtility_wo_explicit_provided.<locals>.FooNr9   r   r   r   r   r>     s   r>   r?   r   rY   rA   rh   r8   rZ   rv   r[   rW   rB   r   rC   r   r   r$   r!   r^   r%   r   r_   r   rK   r?   rL   r
   rh   r8   rv   rW   r<   r>   rD   rE   r`   rQ   r,   r   r   r   r   r   ra   r   r   r   +test_unregisterUtility_wo_explicit_provided  s:    

z;ComponentsTests.test_unregisterUtility_wo_explicit_providedc              	   C   s|  ddl m} ddl m} ddlm} ddlm} G dd d|}G dd	 d	t}|d}d
}d}	| }
||
| |  }|	|
||	| | 
 \}}| |j||	d}W 5 Q R X | | | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|k | |jj|k | |jj|	k | |jj|
k | |jj|k | |jjd k d S )Nr   rg   rS   ru   rV   c                   @   s   e Zd ZdS )zLComponentsTests.test_unregisterUtility_wo_component_or_factory.<locals>.IFooNr9   r   r   r   r   r<     s   r<   c                   @   s   e Zd ZdS )zKComponentsTests.test_unregisterUtility_wo_component_or_factory.<locals>.FooNr9   r   r   r   r   r>     s   r>   r?   r   )r_   r   rY   r   r   r   r   r   .test_unregisterUtility_wo_component_or_factory
  s:    

z>ComponentsTests.test_unregisterUtility_wo_component_or_factoryc              	   C   s   ddl m} G dd d|}|d}d}d}d}t }|  }||||| ||||| |  \}	}
|	 |||| W 5 Q R X | |jj	d | d |f d S )	Nr   rS   c                   @   s   e Zd ZdS )zFComponentsTests.test_unregisterUtility_w_existing_subscr.<locals>.IFooNr9   r   r   r   r   r<   0  s   r<   r?   ro   rp   rX   
rA   r8   rB   r   rC   r   r   r!   r'   r]   rx   r   r   r   (test_unregisterUtility_w_existing_subscr-  s    z8ComponentsTests.test_unregisterUtility_w_existing_subscrc              	   C   s   ddl m} G dd d|}|d}d}d}d}t }|  }||||| ||||| |  \}	}
|	 |||| W 5 Q R X | |jj	d | d |f d S )	Nr   rS   c                   @   s   e Zd ZdS )zSComponentsTests.test_unregisterUtility_w_existing_subscr_non_hashable.<locals>.IFooNr9   r   r   r   r   r<   B  s   r<   r?   ro   rp   rX   )
rA   r8   r}   r   rC   r   r   r!   r'   r]   rx   r   r   r   5test_unregisterUtility_w_existing_subscr_non_hashable?  s    zEComponentsTests.test_unregisterUtility_w_existing_subscr_non_hashablec              	   C   s   ddl m} ddlm} G dd d|}|d}d}d}d}t }|  }	|	|||| |	|||| |  \}
}|
 |	||| W 5 Q R X | 	|	j
jd | d	 |f d S )
Nr   rS   )_UtilityRegistrationsc                   @   s   e Zd ZdS )z_ComponentsTests.test_unregisterUtility_w_existing_subscr_non_hashable_fresh_cache.<locals>.IFooNr9   r   r   r   r   r<   W  s   r<   r?   ro   rp   rX   )rA   r8   r[   r   r}   r   rC   r   r   r!   r'   r]   )r
   r8   r   r<   rD   rE   rr   rs   rQ   r,   r   r   r   r   r   Atest_unregisterUtility_w_existing_subscr_non_hashable_fresh_cacheQ  s    zQComponentsTests.test_unregisterUtility_w_existing_subscr_non_hashable_fresh_cachec              	   C   s   ddl m} G dd d|}|d}d}d}d}t }|  }||||| ||||| |d ||||| |  \}	}
|	 |||| W 5 Q R X | dt	|j
j d S )	Nr   rS   c                   @   s   e Zd ZdS )z]ComponentsTests.test_unregisterUtility_w_existing_subscr_non_hashable_reinitted.<locals>.IFooNr9   r   r   r   r   r<   l  s   r<   r?   ro   rp   r.   )rA   r8   r}   r   rC   __init__r   r   r!   r^   r'   r]   rx   r   r   r   ?test_unregisterUtility_w_existing_subscr_non_hashable_reinittedg  s     
zOComponentsTests.test_unregisterUtility_w_existing_subscr_non_hashable_reinittedc              	   C   s   ddl m} G dd d|}|d}d}d}d}t }t }|  }	|	|||| |	|||| |  \}
}|
 |	||| W 5 Q R X | |	jj	d | d |f d S )	Nr   rS   c                   @   s   e Zd ZdS )zVComponentsTests.test_unregisterUtility_w_existing_subscr_other_component.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   ro   rp   rX   r   rq   r   r   r   8test_unregisterUtility_w_existing_subscr_other_component  s"    zHComponentsTests.test_unregisterUtility_w_existing_subscr_other_componentc              	   C   s   ddl m} G dd d|}|d}d}d}d}t }t }|  }	|	|||| |	|||| |  \}
}|
 |	||| W 5 Q R X | |	j	j
d | d |f d S )	Nr   rS   c                   @   s   e Zd ZdS )zaComponentsTests.test_unregisterUtility_w_existing_subscr_other_component_mixed_hash.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   ro   rp   rX   )rA   r8   rB   r}   r   rC   r   r   r!   r'   r]   rq   r   r   r   Ctest_unregisterUtility_w_existing_subscr_other_component_mixed_hash  s"    zSComponentsTests.test_unregisterUtility_w_existing_subscr_other_component_mixed_hashc                 C   s    |   }| t| g  d S r   )r   r!   r   r   r1   r   r   r   test_registeredUtilities_empty  s    z.ComponentsTests.test_registeredUtilities_emptyc                 C   s  ddl m} ddlm} G dd d|}|d}d}d}d}t }|  }	|	|||| |	|||| t|	 d	d
 d}
| 	t
|
d | t|
d | | |
d j|	k | |
d j|k | |
d j|k | |
d j|k | |
d j|k | |
d jd k | t|
d | | |
d j|	k | |
d j|k | |
d j|k | |
d j|k | |
d j|k | |
d jd k d S )Nr   rS   rV   c                   @   s   e Zd ZdS )z?ComponentsTests.test_registeredUtilities_notempty.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   ro   rp   c                 S   s   | j S r   r   rr   r   r   <lambda>      zCComponentsTests.test_registeredUtilities_notempty.<locals>.<lambda>keyrl   rY   )rA   r8   r[   rW   rB   r   rC   sortedr   r!   r^   r$   r%   r   r_   r   rK   r?   rL   )r
   r8   rW   r<   rD   rE   rr   rs   rQ   r,   regr   r   r   !test_registeredUtilities_notempty  s6    z1ComponentsTests.test_registeredUtilities_notemptyc                 C   sD   ddl m} G dd d|}|d}|  }| ||d k d S )Nr   rS   c                   @   s   e Zd ZdS )z?ComponentsTests.test_queryUtility_miss_no_default.<locals>.IFooNr9   r   r   r   r   r<     s   r<   )rA   r8   r   r$   queryUtilityr
   r8   r<   rD   r,   r   r   r   !test_queryUtility_miss_no_default  s
    z1ComponentsTests.test_queryUtility_miss_no_defaultc                 C   sN   ddl m} G dd d|}|d}|  }t }| |j||d|k d S )Nr   rS   c                   @   s   e Zd ZdS )z>ComponentsTests.test_queryUtility_miss_w_default.<locals>.IFooNr9   r   r   r   r   r<     s   r<   default)rA   r8   r   rB   r$   r   )r
   r8   r<   rD   r,   _defaultr   r   r    test_queryUtility_miss_w_default  s    z0ComponentsTests.test_queryUtility_miss_w_defaultc                 C   sV   ddl m} G dd d|}|d}t }|  }||| | |||k d S )Nr   rS   c                   @   s   e Zd ZdS )z3ComponentsTests.test_queryUtility_hit.<locals>.IFooNr9   r   r   r   r   r<     s   r<   )rA   r8   rB   r   rC   r$   r   r
   r8   r<   rD   rQ   r,   r   r   r   test_queryUtility_hit  s    z%ComponentsTests.test_queryUtility_hitc                 C   sL   ddl m} ddlm} G dd d|}|d}|  }| ||j| d S )Nr   rS   ComponentLookupErrorc                   @   s   e Zd ZdS )z2ComponentsTests.test_getUtility_miss.<locals>.IFooNr9   r   r   r   r   r<     s   r<   )rA   r8   rZ   r   r   rN   
getUtility)r
   r8   r   r<   rD   r,   r   r   r   test_getUtility_miss  s    z$ComponentsTests.test_getUtility_missc                 C   sV   ddl m} G dd d|}|d}t }|  }||| | |||k d S )Nr   rS   c                   @   s   e Zd ZdS )z1ComponentsTests.test_getUtility_hit.<locals>.IFooNr9   r   r   r   r   r<     s   r<   )rA   r8   rB   r   rC   r$   r   r   r   r   r   test_getUtility_hit  s    z#ComponentsTests.test_getUtility_hitc                 C   sF   ddl m} G dd d|}|d}|  }| t||g  d S )Nr   rS   c                   @   s   e Zd ZdS )z7ComponentsTests.test_getUtilitiesFor_miss.<locals>.IFooNr9   r   r   r   r   r<     s   r<   )rA   r8   r   r!   r   getUtilitiesForr   r   r   r   test_getUtilitiesFor_miss  s
    z)ComponentsTests.test_getUtilitiesFor_missc                 C   s   ddl m} G dd d|}|d}d}d}t }|  }|j|||d |j|||d | t||||f||fg d S )Nr   rS   c                   @   s   e Zd ZdS )z6ComponentsTests.test_getUtilitiesFor_hit.<locals>.IFooNr9   r   r   r   r   r<     s   r<   ro   rp   r   )rA   r8   rB   r   rC   r!   r   r   r
   r8   r<   rD   rr   rs   rQ   r,   r   r   r   test_getUtilitiesFor_hit  s    z(ComponentsTests.test_getUtilitiesFor_hitc                 C   sF   ddl m} G dd d|}|d}|  }| t||g  d S )Nr   rS   c                   @   s   e Zd ZdS )zDComponentsTests.test_getAllUtilitiesRegisteredFor_miss.<locals>.IFooNr9   r   r   r   r   r<     s   r<   )rA   r8   r   r!   r   getAllUtilitiesRegisteredForr   r   r   r   &test_getAllUtilitiesRegisteredFor_miss  s
    z6ComponentsTests.test_getAllUtilitiesRegisteredFor_missc                 C   sv   ddl m} G dd d|}|d}d}d}t }|  }|j|||d |j|||d | t|||g d S )Nr   rS   c                   @   s   e Zd ZdS )zCComponentsTests.test_getAllUtilitiesRegisteredFor_hit.<locals>.IFooNr9   r   r   r   r   r<     s   r<   ro   rp   r   )rA   r8   rB   r   rC   r!   r   r   r   r   r   r   %test_getAllUtilitiesRegisteredFor_hit  s    z5ComponentsTests.test_getAllUtilitiesRegisteredFor_hitc           	      C   s   ddl m}m} G dd d|}|d}|d}|dG dd dt}d	}|  }|j||f||d
 | |j|f|df ||f d S )Nr   r6   c                   @   s   e Zd ZdS )zFComponentsTests.test_registerAdapter_with_component_name.<locals>.IFooNr9   r   r   r   r   r<   /  s   r<   r   r=   c                   @   s   e Zd ZdS )zEComponentsTests.test_registerAdapter_with_component_name.<locals>.FooNr9   r   r   r   r   r>   4  s   r>   r?   r@   )rA   r7   r8   rB   r   registerAdapterr!   r)   )	r
   r7   r8   r<   rD   ibarr>   rE   r,   r   r   r   (test_registerAdapter_with_component_name+  s    z8ComponentsTests.test_registerAdapter_with_component_namec              	   C   s  ddl m} ddlm} ddlm} G dd d|}|d}|d}d}d	}d
d }	|  }
|  \}}| |
|	|f||| W 5 Q R X | 	|
j
jd | | | |	k | |
j|f||f |	|f | t|d |d \}}|\}| |i  | 	t|| | 	t|j| | 	|jj|
k | 	|jj|k | |jj|f | 	|jj|k | 	|jj|k | 	|jj|	k d S )Nr   rS   rT   AdapterRegistrationc                   @   s   e Zd ZdS )zSComponentsTests.test_registerAdapter_w_explicit_provided_and_required.<locals>.IFooNr9   r   r   r   r   r<   E  s   r<   r   r?   r   c                 S   s
   t  d S r   rG   contextr   r   r   rI   L  s    zWComponentsTests.test_registerAdapter_w_explicit_provided_and_required.<locals>._factoryrY   )rA   r8   rZ   rU   r[   r   r   r   r   r$   r&   r\   r!   r)   r^   r%   rB   r   r_   requiredr   r?   rL   )r
   r8   rU   r   r<   rD   r   rE   r`   rI   r,   r   r   r   r   ra   r   r   r   5test_registerAdapter_w_explicit_provided_and_required@  s>    zEComponentsTests.test_registerAdapter_w_explicit_provided_and_requiredc           	      C   sh   ddl m} G dd d|}|d}d}d}t }G dd	 d	t}|  }| jt|j||f||d
 d S )Nr   rS   c                   @   s   e Zd ZdS )zHComponentsTests.test_registerAdapter_no_provided_available.<locals>.IFooNr9   r   r   r   r   r<   f  s   r<   r   r?   r   c                   @   s   e Zd ZdS )zLComponentsTests.test_registerAdapter_no_provided_available.<locals>._FactoryNr9   r   r   r   r   _Factorym  s   r   r   r?   rA   r8   rB   r   rN   rO   r   )	r
   r8   r<   r   rE   r`   rQ   r   r,   r   r   r   *test_registerAdapter_no_provided_availablec  s     z:ComponentsTests.test_registerAdapter_no_provided_availablec              	   C   s  ddl m} ddl m} ddlm} ddlm} G dd d|}|d}|d}d	}d
}	t }
||G dd dt}|  }| 	 \}}| |j
||f|	|d W 5 Q R X | |jjd | | |	 |k | |j|f||	f ||f | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|k | |jj|k | |jj|f | |jj|	k | |jj|k | |jj|k d S )Nr   rS   implementerrT   r   c                   @   s   e Zd ZdS )zGComponentsTests.test_registerAdapter_wo_explicit_provided.<locals>.IFooNr9   r   r   r   r   r<   z  s   r<   r   r?   r   c                   @   s   e Zd ZdS )zKComponentsTests.test_registerAdapter_wo_explicit_provided.<locals>._FactoryNr9   r   r   r   r   r     s   r   r   rY   )rA   r8   r   rZ   rU   r[   r   rB   r   r   r   r$   r&   r\   r!   r)   r^   r%   r   r_   r   r   r?   rL   )r
   r8   r   rU   r   r<   rD   r   rE   r`   rQ   r   r,   r   r   r   r   ra   r   r   r   )test_registerAdapter_wo_explicit_providedt  sD    z9ComponentsTests.test_registerAdapter_wo_explicit_providedc                 C   s`   ddl m} G dd d|}|d}d}d}G dd dt}|  }| jt|j||||d	 d S )
Nr   rS   c                   @   s   e Zd ZdS )zHComponentsTests.test_registerAdapter_no_required_available.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   r   c                   @   s   e Zd ZdS )zLComponentsTests.test_registerAdapter_no_required_available.<locals>._FactoryNr9   r   r   r   r   r     s   r   r_   r   r?   r   r
   r8   r<   rD   rE   r`   r   r,   r   r   r   *test_registerAdapter_no_required_available  s      z:ComponentsTests.test_registerAdapter_no_required_availablec           	   	   C   sj   ddl m} G dd d|}|d}|d}d}d}G dd	 d	t}|  }| jt|j|||||d
 d S )Nr   rS   c                   @   s   e Zd ZdS )zEComponentsTests.test_registerAdapter_w_invalid_required.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r?   r   c                   @   s   e Zd ZdS )zIComponentsTests.test_registerAdapter_w_invalid_required.<locals>._FactoryNr9   r   r   r   r   r     s   r   r   r   )	r
   r8   r<   rD   r   rE   r`   r   r,   r   r   r   'test_registerAdapter_w_invalid_required  s       z7ComponentsTests.test_registerAdapter_w_invalid_requiredc              	   C   s  ddl m} ddlm} ddlm} ddlm} G dd d|}|d}d}d	}G d
d dt}	| 	 }
| 
 \}}| |
j|	d g|||d W 5 Q R X | |
jjd | | | |	k | |
j|f||f |	|f | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|
k | |jj|k | |jj|f | |jj|k | |jj|k | |jj|	k d S )Nr   rS   r   rT   r   c                   @   s   e Zd ZdS )zMComponentsTests.test_registerAdapter_w_required_containing_None.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   r   c                   @   s   e Zd ZdS )zQComponentsTests.test_registerAdapter_w_required_containing_None.<locals>._FactoryNr9   r   r   r   r   r     s   r   r   rY   )rA   r8   Zzope.interface.interfacer   rZ   rU   r[   r   rB   r   r   r   r$   r&   r\   r!   r)   r^   r%   r   r_   r   r   r?   rL   )r
   r8   r   rU   r   r<   rD   rE   r`   r   r,   r   r   r   r   ra   r   r   r   /test_registerAdapter_w_required_containing_None  sD     z?ComponentsTests.test_registerAdapter_w_required_containing_Nonec              	   C   s  ddl m} ddl m} ddl m} ddlm} ddlm} G dd d|}|d}|d	}d
}	d}
G dd dt}||G dd dt}||}| 	 }| 
 \}}| |j||g||
|	d W 5 Q R X | |jjd | | |
 |k | |j|f||
f ||	f | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|k | |jj|k | |jj|f | |jj|
k | |jj|	k | |jj|k d S )Nr   rS   r   )implementedByrT   r   c                   @   s   e Zd ZdS )zNComponentsTests.test_registerAdapter_w_required_containing_class.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r?   r   c                   @   s   e Zd ZdS )zRComponentsTests.test_registerAdapter_w_required_containing_class.<locals>._FactoryNr9   r   r   r   r   r     s   r   c                   @   s   e Zd ZdS )zRComponentsTests.test_registerAdapter_w_required_containing_class.<locals>._ContextNr9   r   r   r   r   _Context  s   r   r   rY   )rA   r8   r   r   rZ   rU   r[   r   rB   r   r   r   r$   r&   r\   r!   r)   r^   r%   r   r_   r   r   r?   rL   )r
   r8   r   r   rU   r   r<   rD   r   rE   r`   r   r   Z	_ctx_implr,   r   r   r   r   ra   r   r   r   0test_registerAdapter_w_required_containing_class  sN     z@ComponentsTests.test_registerAdapter_w_required_containing_classc              	   C   sf   ddl m} G dd d|}|d}d}d}G dd dt}|  }| jt|j|t g|||d	 d S )
Nr   rS   c                   @   s   e Zd ZdS )zMComponentsTests.test_registerAdapter_w_required_containing_junk.<locals>.IFooNr9   r   r   r   r   r<   
  s   r<   r?   r   c                   @   s   e Zd ZdS )zQComponentsTests.test_registerAdapter_w_required_containing_junk.<locals>._FactoryNr9   r   r   r   r   r     s   r   r   r   r   r   r   r   /test_registerAdapter_w_required_containing_junk  s      z?ComponentsTests.test_registerAdapter_w_required_containing_junkc              	      s  ddl m} ddlm} ddlm} G dd d|}|d}|d d}d	}G  fd
ddt}|  }	|  \}
}|
 |	j	||||d W 5 Q R X | 
|	jjd   | | |k | |	j f||f ||f | t|d |d \}}|\}| |i  | 
t|| | 
t|j| | 
|jj|	k | 
|jj|k | |jj f | 
|jj|k | 
|jj|k | 
|jj|k d S )Nr   rS   rT   r   c                   @   s   e Zd ZdS )zGComponentsTests.test_registerAdapter_wo_explicit_required.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r?   r   c                       s   e Zd Z fZdS )zKComponentsTests.test_registerAdapter_wo_explicit_required.<locals>._FactoryNr"   r:   r;   __component_adapts__r   r   r   r   r   !  s   r   r   rY   )rA   r8   rZ   rU   r[   r   rB   r   r   r   r$   r&   r\   r!   r)   r^   r%   r   r_   r   r   r?   rL   )r
   r8   rU   r   r<   rD   rE   r`   r   r,   r   r   r   r   ra   r   r   r   )test_registerAdapter_wo_explicit_required  sB    
z9ComponentsTests.test_registerAdapter_wo_explicit_requiredc              	   C   s   ddl m} G dd d|}|d}|d}d}d}dd	 }|  }|  \}	}
|	 |j||f|||d
d W 5 Q R X | t|
d d S )Nr   rS   c                   @   s   e Zd ZdS )z;ComponentsTests.test_registerAdapter_wo_event.<locals>.IFooNr9   r   r   r   r   r<   =  s   r<   r   r?   r   c                 S   s
   t  d S r   rG   r   r   r   r   rI   D  s    z?ComponentsTests.test_registerAdapter_wo_event.<locals>._factoryF)ra   )rA   r8   r   r   r   r!   r^   )r
   r8   r<   rD   r   rE   r`   rI   r,   r   r   r   r   r   test_registerAdapter_wo_event:  s    z-ComponentsTests.test_registerAdapter_wo_eventc                 C   s    |   }| jt|jd d d d S N)rL   r_   )r   rN   rO   unregisterAdapterr1   r   r   r   3test_unregisterAdapter_neither_factory_nor_providedM  s
    
 zCComponentsTests.test_unregisterAdapter_neither_factory_nor_providedc                 C   sF   ddl m} G dd d|}|d}|  }| jt|jd |d d d S )Nr   rS   c                   @   s   e Zd ZdS )zQComponentsTests.test_unregisterAdapter_neither_factory_nor_required.<locals>.IFooNr9   r   r   r   r   r<   T  s   r<   rL   r_   r   )rA   r8   r   rN   rO   r   r   r   r   r   3test_unregisterAdapter_neither_factory_nor_requiredR  s    
  zCComponentsTests.test_unregisterAdapter_neither_factory_nor_requiredc           
   	   C   s~   ddl m} G dd d|}|d}|d}G dd dt}|  }|  \}}| |||f|}	W 5 Q R X | |	 d S )Nr   rS   c                   @   s   e Zd ZdS )z9ComponentsTests.test_unregisterAdapter_miss.<locals>.IFooNr9   r   r   r   r   r<   ]  s   r<   r   c                   @   s   e Zd ZdS )z=ComponentsTests.test_unregisterAdapter_miss.<locals>._FactoryNr9   r   r   r   r   r   a  s   r   )rA   r8   rB   r   r   r   r   
r
   r8   r<   rD   r   r   r,   r   r   r   r   r   r   test_unregisterAdapter_miss[  s    z+ComponentsTests.test_unregisterAdapter_missc              	   C   sx  ddl m} ddlm} ddlm} G dd d|}|d}|d}G dd	 d	t}|  }|||f| | 	 \}	}
|	 |
||f|}W 5 Q R X | | | |jj | |j | t|
d
 |
d \}}|\}| |i  | t|| | t|j| | |jj|k | |jj|k | |jj|f | |jjd | |jjd | |jj|k d S )Nr   rS   ru   r   c                   @   s   e Zd ZdS )zYComponentsTests.test_unregisterAdapter_hit_w_explicit_provided_and_required.<locals>.IFooNr9   r   r   r   r   r<   n  s   r<   r   c                   @   s   e Zd ZdS )z]ComponentsTests.test_unregisterAdapter_hit_w_explicit_provided_and_required.<locals>._FactoryNr9   r   r   r   r   r   r  s   r   rY   rX   )rA   r8   rZ   rv   r[   r   rB   r   r   r   r   r$   r   r&   r\   r)   r!   r^   r%   r   r_   r   r   r?   rL   )r
   r8   rv   r   r<   rD   r   r   r,   r   r   r   r   r   ra   r   r   r   ;test_unregisterAdapter_hit_w_explicit_provided_and_requiredj  s6    
zKComponentsTests.test_unregisterAdapter_hit_w_explicit_provided_and_requiredc              	   C   sp  ddl m} ddl m} ddlm} ddlm} G dd d|}|d}|d}||G d	d
 d
t}|  }	|		||f| | 
 \}
}|
 |	||f}W 5 Q R X | | | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|	k | |jj|k | |jj|f | |jjd | |jjd | |jj|k d S )Nr   rS   r   ru   r   c                   @   s   e Zd ZdS )zIComponentsTests.test_unregisterAdapter_wo_explicit_provided.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   c                   @   s   e Zd ZdS )zMComponentsTests.test_unregisterAdapter_wo_explicit_provided.<locals>._FactoryNr9   r   r   r   r   r     s   r   rY   rX   )rA   r8   r   rZ   rv   r[   r   rB   r   r   r   r   r$   r!   r^   r%   r   r_   r   r   r?   rL   )r
   r8   r   rv   r   r<   rD   r   r   r,   r   r   r   r   r   ra   r   r   r   +test_unregisterAdapter_wo_explicit_provided  s6    
z;ComponentsTests.test_unregisterAdapter_wo_explicit_providedc              	      s`  ddl m} ddlm} ddlm} G dd d|}|d}|d G  fdd	d	t}|  }|| f| | 	 \}}	| |j
||d
}
W 5 Q R X | |
 | t|	d |	d \}}|\}| |i  | t|| | t|j| | |jj|k | |jj|k | |jj f | |jjd | |jjd | |jj|k d S )Nr   rS   ru   r   c                   @   s   e Zd ZdS )zIComponentsTests.test_unregisterAdapter_wo_explicit_required.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   c                       s   e Zd Z fZdS )zMComponentsTests.test_unregisterAdapter_wo_explicit_required.<locals>._FactoryNr   r   r   r   r   r     s   r   r_   rY   rX   )rA   r8   rZ   rv   r[   r   rB   r   r   r   r   r$   r!   r^   r%   r   r_   r   r   r?   rL   )r
   r8   rv   r   r<   rD   r   r,   r   r   r   r   r   ra   r   r   r   +test_unregisterAdapter_wo_explicit_required  s2    
z;ComponentsTests.test_unregisterAdapter_wo_explicit_requiredc                 C   s    |   }| t| g  d S r   )r   r!   r   registeredAdaptersr1   r   r   r   test_registeredAdapters_empty  s    z-ComponentsTests.test_registeredAdapters_emptyc                 C   s  ddl m} ddlm} G dd d|}|d}|d}d}d}d}G d	d
 d
t}	|  }
|
|	|f||| |
|	|f||| t|
 dd d}| 	t
|d | t|d | | |d j|
k | |d j|k | 	|d j|f | |d j|k | |d j|k | |d j|	k | t|d | | |d j|
k | |d j|k | 	|d j|f | |d j|k | |d j|k | |d j|	k d S )Nr   rS   r   c                   @   s   e Zd ZdS )z>ComponentsTests.test_registeredAdapters_notempty.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   ro   rp   c                   @   s   e Zd ZdS )zBComponentsTests.test_registeredAdapters_notempty.<locals>._FactoryNr9   r   r   r   r   r     s   r   c                 S   s   | j S r   r   r   r   r   r   r     r   zBComponentsTests.test_registeredAdapters_notempty.<locals>.<lambda>r   rl   rY   )rA   r8   r[   r   rB   r   r   r   r   r!   r^   r$   r%   r   r_   r   r   r?   rL   )r
   r8   r   r<   rD   r   rE   rr   rs   r   r,   r   r   r   r    test_registeredAdapters_notempty  s8    z0ComponentsTests.test_registeredAdapters_notemptyc                 C   sL   ddl m} G dd d|}|d}|  }t }| |||d k d S )Nr   rS   c                   @   s   e Zd ZdS )z?ComponentsTests.test_queryAdapter_miss_no_default.<locals>.IFooNr9   r   r   r   r   r<     s   r<   rA   r8   r   rB   r$   queryAdapter)r
   r8   r<   rD   r,   _contextr   r   r   !test_queryAdapter_miss_no_default  s    z1ComponentsTests.test_queryAdapter_miss_no_defaultc                 C   sV   ddl m} G dd d|}|d}|  }t }t }| |j|||d|k d S )Nr   rS   c                   @   s   e Zd ZdS )z>ComponentsTests.test_queryAdapter_miss_w_default.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r   )r
   r8   r<   rD   r,   r   r   r   r   r    test_queryAdapter_miss_w_default  s    z0ComponentsTests.test_queryAdapter_miss_w_defaultc                 C   s   ddl m} ddl m} G dd d|}|d}|d}G dd dt}||G d	d
 d
t}| }|  }	|	||f| |	||}
| t|
| | |
j	|k d S )Nr   rS   r   c                   @   s   e Zd ZdS )z3ComponentsTests.test_queryAdapter_hit.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   c                   @   s   e Zd Zdd ZdS )z7ComponentsTests.test_queryAdapter_hit.<locals>._Factoryc                 S   s
   || _ d S r   r   r
   r   r   r   r   r   
  s    z@ComponentsTests.test_queryAdapter_hit.<locals>._Factory.__init__Nr"   r:   r;   r   r   r   r   r   r   	  s   r   c                   @   s   e Zd ZdS )z7ComponentsTests.test_queryAdapter_hit.<locals>._ContextNr9   r   r   r   r   r     s   r   )
rA   r8   r   rB   r   r   r   r$   r%   r   r
   r8   r   r<   rD   r   r   r   r   r,   adapterr   r   r   test_queryAdapter_hit  s    z%ComponentsTests.test_queryAdapter_hitc           
      C   s   ddl m} ddl m} ddlm} G dd d|}|d}|d}||G dd	 d	t}| }|  }	| ||	j|| d S )
Nr   rS   r   r   c                   @   s   e Zd ZdS )z2ComponentsTests.test_getAdapter_miss.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   c                   @   s   e Zd ZdS )z6ComponentsTests.test_getAdapter_miss.<locals>._ContextNr9   r   r   r   r   r     s   r   )	rA   r8   r   rZ   r   rB   r   rN   
getAdapter)
r
   r8   r   r   r<   rD   r   r   r   r,   r   r   r   test_getAdapter_miss  s      z$ComponentsTests.test_getAdapter_missc                 C   s   ddl m} ddl m} G dd d|}|d}|d}G dd dt}||G d	d
 d
t}| }|  }	|	||f| |	||}
| t|
| | |
j	|k d S )Nr   rS   r   c                   @   s   e Zd ZdS )z1ComponentsTests.test_getAdapter_hit.<locals>.IFooNr9   r   r   r   r   r<   )  s   r<   r   c                   @   s   e Zd Zdd ZdS )z5ComponentsTests.test_getAdapter_hit.<locals>._Factoryc                 S   s
   || _ d S r   r   r   r   r   r   r   .  s    z>ComponentsTests.test_getAdapter_hit.<locals>._Factory.__init__Nr   r   r   r   r   r   -  s   r   c                   @   s   e Zd ZdS )z5ComponentsTests.test_getAdapter_hit.<locals>._ContextNr9   r   r   r   r   r   0  s   r   )
rA   r8   r   rB   r   r   r   r$   r%   r   r   r   r   r   test_getAdapter_hit&  s    z#ComponentsTests.test_getAdapter_hitc                 C   s   ddl m} ddl m} G dd d|}|d}|d}|d}||G dd	 d	t}||G d
d dt}| }	| }
|  }| ||	|
f|d  d S )Nr   rS   r   c                   @   s   e Zd ZdS )z9ComponentsTests.test_queryMultiAdapter_miss.<locals>.IFooNr9   r   r   r   r   r<   =  s   r<   r   IBazc                   @   s   e Zd ZdS )z>ComponentsTests.test_queryMultiAdapter_miss.<locals>._Context1Nr9   r   r   r   r   	_Context1B  s   r   c                   @   s   e Zd ZdS )z>ComponentsTests.test_queryMultiAdapter_miss.<locals>._Context2Nr9   r   r   r   r   	_Context2E  s   r   )rA   r8   r   rB   r   r!   queryMultiAdapterr
   r8   r   r<   rD   r   ibazr   r   	_context1	_context2r,   r   r   r   test_queryMultiAdapter_miss:  s     z+ComponentsTests.test_queryMultiAdapter_missc                 C   s   ddl m} ddl m} G dd d|}|d}|d}|d}||G dd	 d	t}||G d
d dt}| }	| }
t }|  }| |j|	|
f||d|k d S )Nr   rS   r   c                   @   s   e Zd ZdS )zCComponentsTests.test_queryMultiAdapter_miss_w_default.<locals>.IFooNr9   r   r   r   r   r<   Q  s   r<   r   r   c                   @   s   e Zd ZdS )zHComponentsTests.test_queryMultiAdapter_miss_w_default.<locals>._Context1Nr9   r   r   r   r   r   V  s   r   c                   @   s   e Zd ZdS )zHComponentsTests.test_queryMultiAdapter_miss_w_default.<locals>._Context2Nr9   r   r   r   r   r   Y  s   r   r   )rA   r8   r   rB   r   r$   r   )r
   r8   r   r<   rD   r   r  r   r   r  r  r   r,   r   r   r   %test_queryMultiAdapter_miss_w_defaultN  s*    z5ComponentsTests.test_queryMultiAdapter_miss_w_defaultc                 C   s   ddl m} ddl m} G dd d|}|d}|d}|d}||G dd	 d	t}||G d
d dt}| }	| }
G dd dt}|  }||||f| ||	|
f|}| t|| | 	|j
|	|
f d S )Nr   rS   r   c                   @   s   e Zd ZdS )z8ComponentsTests.test_queryMultiAdapter_hit.<locals>.IFooNr9   r   r   r   r   r<   g  s   r<   r   r   c                   @   s   e Zd ZdS )z=ComponentsTests.test_queryMultiAdapter_hit.<locals>._Context1Nr9   r   r   r   r   r   l  s   r   c                   @   s   e Zd ZdS )z=ComponentsTests.test_queryMultiAdapter_hit.<locals>._Context2Nr9   r   r   r   r   r   o  s   r   c                   @   s   e Zd Zdd ZdS )z<ComponentsTests.test_queryMultiAdapter_hit.<locals>._Factoryc                 S   s   ||f| _ d S r   r   r
   context1context2r   r   r   r   u  s    zEComponentsTests.test_queryMultiAdapter_hit.<locals>._Factory.__init__Nr   r   r   r   r   r   t  s   r   )rA   r8   r   rB   r   r   r   r$   r%   r!   r   r
   r8   r   r<   rD   r   r  r   r   r  r  r   r,   r   r   r   r   test_queryMultiAdapter_hitd  s$    z*ComponentsTests.test_queryMultiAdapter_hitc                 C   s   ddl m} ddl m} ddlm} G dd d|}|d}|d}|d}||G d	d
 d
t}||G dd dt}	| }
|	 }|  }| ||j|
|f| d S )Nr   rS   r   r   c                   @   s   e Zd ZdS )z7ComponentsTests.test_getMultiAdapter_miss.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r   c                   @   s   e Zd ZdS )z<ComponentsTests.test_getMultiAdapter_miss.<locals>._Context1Nr9   r   r   r   r   r     s   r   c                   @   s   e Zd ZdS )z<ComponentsTests.test_getMultiAdapter_miss.<locals>._Context2Nr9   r   r   r   r   r     s   r   )	rA   r8   r   rZ   r   rB   r   rN   getMultiAdapter)r
   r8   r   r   r<   rD   r   r  r   r   r  r  r,   r   r   r   test_getMultiAdapter_miss}  s&      z)ComponentsTests.test_getMultiAdapter_missc                 C   s   ddl m} ddl m} G dd d|}|d}|d}|d}||G dd	 d	t}||G d
d dt}| }	| }
G dd dt}|  }||||f| ||	|
f|}| t|| | 	|j
|	|
f d S )Nr   rS   r   c                   @   s   e Zd ZdS )z6ComponentsTests.test_getMultiAdapter_hit.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r   c                   @   s   e Zd ZdS )z;ComponentsTests.test_getMultiAdapter_hit.<locals>._Context1Nr9   r   r   r   r   r     s   r   c                   @   s   e Zd ZdS )z;ComponentsTests.test_getMultiAdapter_hit.<locals>._Context2Nr9   r   r   r   r   r     s   r   c                   @   s   e Zd Zdd ZdS )z:ComponentsTests.test_getMultiAdapter_hit.<locals>._Factoryc                 S   s   ||f| _ d S r   r   r  r   r   r   r     s    zCComponentsTests.test_getMultiAdapter_hit.<locals>._Factory.__init__Nr   r   r   r   r   r     s   r   )rA   r8   r   rB   r   r   r  r$   r%   r!   r   r	  r   r   r   test_getMultiAdapter_hit  s$    z(ComponentsTests.test_getMultiAdapter_hitc                 C   s   ddl m} ddl m} G dd d|}|d}|d}|d}||G dd	 d	t}||G d
d dt}| }	| }
|  }| t||	|
f|g  d S )Nr   rS   r   c                   @   s   e Zd ZdS )z4ComponentsTests.test_getAdapters_empty.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r   c                   @   s   e Zd ZdS )z9ComponentsTests.test_getAdapters_empty.<locals>._Context1Nr9   r   r   r   r   r     s   r   c                   @   s   e Zd ZdS )z9ComponentsTests.test_getAdapters_empty.<locals>._Context2Nr9   r   r   r   r   r     s   r   )rA   r8   r   rB   r   r!   r   getAdaptersr   r   r   r   test_getAdapters_empty  s"     z&ComponentsTests.test_getAdapters_emptyc                    s   ddl m} ddl m} G dd d|}|d}|d}|d}||G dd	 d	t}||G d
d dt}| }	| }
|  }g   fdd}||||f| | t||	|
f|g  |  |	|
fg d S )Nr   rS   r   c                   @   s   e Zd ZdS )zCComponentsTests.test_getAdapters_factory_returns_None.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r   c                   @   s   e Zd ZdS )zHComponentsTests.test_getAdapters_factory_returns_None.<locals>._Context1Nr9   r   r   r   r   r     s   r   c                   @   s   e Zd ZdS )zHComponentsTests.test_getAdapters_factory_returns_None.<locals>._Context2Nr9   r   r   r   r   r     s   r   c                    s     | |f d S r   r   )r  r  Z_called_withr   r   _side_effect_only  s    zPComponentsTests.test_getAdapters_factory_returns_None.<locals>._side_effect_only)	rA   r8   r   rB   r   r   r!   r   r  )r
   r8   r   r<   rD   r   r  r   r   r  r  r,   r  r   r  r   %test_getAdapters_factory_returns_None  s*     z5ComponentsTests.test_getAdapters_factory_returns_Nonec                 C   sX  ddl m} ddl m} G dd d|}|d}|d}|d}||G dd	 d	t}||G d
d dt}| }	| }
G dd dt}G dd dt}d}d}|  }|j|||f||d |j|||f||d t||	|
f|}| t	|d | |d d | | 
t|d d | | |d d | | 
t|d d | d S )Nr   rS   r   c                   @   s   e Zd ZdS )z8ComponentsTests.test_getAdapters_non_empty.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r   c                   @   s   e Zd ZdS )z=ComponentsTests.test_getAdapters_non_empty.<locals>._Context1Nr9   r   r   r   r   r     s   r   c                   @   s   e Zd ZdS )z=ComponentsTests.test_getAdapters_non_empty.<locals>._Context2Nr9   r   r   r   r   r     s   r   c                   @   s   e Zd Zdd ZdS )z=ComponentsTests.test_getAdapters_non_empty.<locals>._Factory1c                 S   s   ||f| _ d S r   r   r  r   r   r   r     s    zFComponentsTests.test_getAdapters_non_empty.<locals>._Factory1.__init__Nr   r   r   r   r   	_Factory1  s   r  c                   @   s   e Zd Zdd ZdS )z=ComponentsTests.test_getAdapters_non_empty.<locals>._Factory2c                 S   s   ||f| _ d S r   r   r  r   r   r   r     s    zFComponentsTests.test_getAdapters_non_empty.<locals>._Factory2.__init__Nr   r   r   r   r   	_Factory2  s   r  ro   rp   r   rl   rY   )rA   r8   r   rB   r   r   r   r  r!   r^   r$   r%   )r
   r8   r   r<   rD   r   r  r   r   r  r  r  r  rr   rs   r,   foundr   r   r   test_getAdapters_non_empty  s2    z*ComponentsTests.test_getAdapters_non_emptyc           	   	   C   sb   ddl m} G dd d|}|d}|d}d}d}dd	 }|  }| t|j||f||| d S )
Nr   rS   c                   @   s   e Zd ZdS )zNComponentsTests.test_registerSubscriptionAdapter_w_nonblank_name.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r   r?   c                 S   s
   t  d S r   rG   r   r   r   r   rI     s    zRComponentsTests.test_registerSubscriptionAdapter_w_nonblank_name.<locals>._factory)rA   r8   r   rN   rO   registerSubscriptionAdapter)	r
   r8   r<   rD   r   r`   rE   rI   r,   r   r   r   0test_registerSubscriptionAdapter_w_nonblank_name  s    
    z@ComponentsTests.test_registerSubscriptionAdapter_w_nonblank_namec              	   C   s  ddl m} ddlm} ddlm} G dd d|}|d}|d}d}d	}d
d }	|  }
|  \}}| |
j|	|f||d W 5 Q R X |
j	j
d | | | }| t|d | |d |	k | |
j|f|||	|fg | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|
k | |jj|k | |jj|f | |jj| | |jj|k | |jj|	k d S )Nr   rS   rT   SubscriptionRegistrationc                   @   s   e Zd ZdS )z_ComponentsTests.test_registerSubscriptionAdapter_w_explicit_provided_and_required.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   rX   r?   c                 S   s
   t  d S r   rG   r   r   r   r   rI     s    zcComponentsTests.test_registerSubscriptionAdapter_w_explicit_provided_and_required.<locals>._factoryr@   rY   )rA   r8   rZ   rU   r[   r  r   r   r  r&   r]   r!   r^   r$   r*   r%   rB   r   r_   r   r   r?   rL   )r
   r8   rU   r  r<   rD   r   _blankrE   rI   r,   r   r   r   r   r   ra   r   r   r   Atest_registerSubscriptionAdapter_w_explicit_provided_and_required  sB    zQComponentsTests.test_registerSubscriptionAdapter_w_explicit_provided_and_requiredc              	   C   s  ddl m} ddl m} ddlm} ddlm} G dd d|}|d}|d}d	}d
}	||G dd dt}
|  }| 	 \}}| |j
|
|f|d W 5 Q R X |jjd | | |	 }| t|d | |d |
k | |j|f||	|
|fg | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|k | |jj|k | |jj|f | |jj|	 | |jj|k | |jj|
k d S )Nr   rS   r   rT   r  c                   @   s   e Zd ZdS )zSComponentsTests.test_registerSubscriptionAdapter_wo_explicit_provided.<locals>.IFooNr9   r   r   r   r   r<   6  s   r<   r   r?   rX   c                   @   s   e Zd ZdS )zWComponentsTests.test_registerSubscriptionAdapter_wo_explicit_provided.<locals>._FactoryNr9   r   r   r   r   r   =  s   r   r@   rY   )rA   r8   r   rZ   rU   r[   r  rB   r   r   r  r&   r]   r!   r^   r$   r*   r%   r   r_   r   r   r?   rL   )r
   r8   r   rU   r  r<   rD   r   rE   r  r   r,   r   r   r   r   r   ra   r   r   r   5test_registerSubscriptionAdapter_wo_explicit_provided0  sB    zEComponentsTests.test_registerSubscriptionAdapter_wo_explicit_providedc              	      s  ddl m} ddlm} ddlm} G dd d|}|d}|d d}d	}G  fd
ddt}|  }	|  \}
}|
 |	j	|||d W 5 Q R X |	j
jd   | | }| t|d | |d |k | |	j f||||fg | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|	k | |jj|k | |jj f | |jj| | |jj|k | |jj|k d S )Nr   rS   rT   r  c                   @   s   e Zd ZdS )zSComponentsTests.test_registerSubscriptionAdapter_wo_explicit_required.<locals>.IFooNr9   r   r   r   r   r<   \  s   r<   r   r?   rX   c                       s   e Zd Z fZdS )zWComponentsTests.test_registerSubscriptionAdapter_wo_explicit_required.<locals>._FactoryNr   r   r   r   r   r   b  s   r   )r_   r?   rY   )rA   r8   rZ   rU   r[   r  rB   r   r   r  r&   r]   r!   r^   r$   r*   r%   r   r_   r   r   r?   rL   )r
   r8   rU   r  r<   rD   rE   r  r   r,   r   r   r   r   r   ra   r   r   r   5test_registerSubscriptionAdapter_wo_explicit_requiredW  sF      zEComponentsTests.test_registerSubscriptionAdapter_wo_explicit_requiredc              	   C   s   ddl m} G dd d|}|d}|d}d}d}dd	 }|  }|  \}	}
|	 |j||f||d
d W 5 Q R X | t|
d d S )Nr   rS   c                   @   s   e Zd ZdS )zGComponentsTests.test_registerSubscriptionAdapter_wo_event.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   rX   r?   c                 S   s
   t  d S r   rG   r   r   r   r   rI     s    zKComponentsTests.test_registerSubscriptionAdapter_wo_event.<locals>._factoryFr?   ra   )rA   r8   r   r   r  r!   r^   )r
   r8   r<   rD   r   r  rE   rI   r,   r   r   r   r   r   )test_registerSubscriptionAdapter_wo_event|  s     z9ComponentsTests.test_registerSubscriptionAdapter_wo_eventc                 C   s    |   }| t| g  d S r   )r   r!   r   registeredSubscriptionAdaptersr1   r   r   r   )test_registeredSubscriptionAdapters_empty  s    z9ComponentsTests.test_registeredSubscriptionAdapters_emptyc                 C   s  ddl m} ddlm} G dd d|}|d}|d}d}d}G dd	 d	t}|  }	|	j||f||d
 |	j||f||d
 t|	 }
| 	t
|
d | t|
d | | |
d j|	k | |
d j|k | 	|
d j|f | 	|
d j| | |
d j|k | |
d j|k | t|
d | | |
d j|	k | |
d j|k | 	|
d j|f | 	|
d j| | |
d j|k | |
d j|k d S )Nr   rS   r  c                   @   s   e Zd ZdS )zJComponentsTests.test_registeredSubscriptionAdapters_notempty.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   rX   c                   @   s   e Zd ZdS )zNComponentsTests.test_registeredSubscriptionAdapters_notempty.<locals>._FactoryNr9   r   r   r   r   r     s   r   r@   rl   rY   )rA   r8   r[   r  rB   r   r  r   r!  r!   r^   r$   r%   r   r_   r   r   r?   rL   )r
   r8   r  r<   rD   r   rE   r  r   r,   r   r   r   r   ,test_registeredSubscriptionAdapters_notempty  s6    z<ComponentsTests.test_registeredSubscriptionAdapters_notemptyc                 C   sR   ddl m} G dd d|}|d}|d}d}|  }| jt|j|||d d S )Nr   rS   c                   @   s   e Zd ZdS )zPComponentsTests.test_unregisterSubscriptionAdapter_w_nonblank_name.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   nonblank)r   r_   r   rA   r8   r   rN   rO   unregisterSubscriptionAdapter)r
   r8   r<   rD   r   	_nonblankr,   r   r   r   2test_unregisterSubscriptionAdapter_w_nonblank_name  s    
  zBComponentsTests.test_unregisterSubscriptionAdapter_w_nonblank_namec                 C   s    |   }| jt|jd d d d S r   )r   rN   rO   r&  r1   r   r   r   ?test_unregisterSubscriptionAdapter_neither_factory_nor_provided  s
    
 zOComponentsTests.test_unregisterSubscriptionAdapter_neither_factory_nor_providedc                 C   sF   ddl m} G dd d|}|d}|  }| jt|jd |d d d S )Nr   rS   c                   @   s   e Zd ZdS )z]ComponentsTests.test_unregisterSubscriptionAdapter_neither_factory_nor_required.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r%  r   r   r   r   ?test_unregisterSubscriptionAdapter_neither_factory_nor_required  s    
  zOComponentsTests.test_unregisterSubscriptionAdapter_neither_factory_nor_requiredc           
   	   C   s   ddl m} G dd d|}|d}|d}G dd dt}|  }|  \}}| |||f|}	W 5 Q R X | |	 | | d S )Nr   rS   c                   @   s   e Zd ZdS )zEComponentsTests.test_unregisterSubscriptionAdapter_miss.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   c                   @   s   e Zd ZdS )zIComponentsTests.test_unregisterSubscriptionAdapter_miss.<locals>._FactoryNr9   r   r   r   r   r     s   r   )rA   r8   rB   r   r   r&  r   r   r   r   r   'test_unregisterSubscriptionAdapter_miss  s    
z7ComponentsTests.test_unregisterSubscriptionAdapter_missc              	   C   sx  ddl m} ddlm} ddlm} G dd d|}|d}|d}G dd	 d	t}|  }|||f| | 	 \}	}
|	 |
d |f|}W 5 Q R X | | | |jj | |j | t|
d
 |
d \}}|\}| |i  | t|| | t|j| | |jj|k | |jj|k | |jj|f | |jjd | |jjd | |jjd k d S )Nr   rS   ru   r  c                   @   s   e Zd ZdS )zOComponentsTests.test_unregisterSubscriptionAdapter_hit_wo_factory.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   c                   @   s   e Zd ZdS )zSComponentsTests.test_unregisterSubscriptionAdapter_hit_wo_factory.<locals>._FactoryNr9   r   r   r   r   r     s   r   rY   rX   rA   r8   rZ   rv   r[   r  rB   r   r  r   r&  r$   r   r&   r]   r*   r!   r^   r%   r   r_   r   r   r?   rL   r
   r8   rv   r  r<   rD   r   r   r,   r   r   r   r   r   ra   r   r   r   1test_unregisterSubscriptionAdapter_hit_wo_factory  s6    
zAComponentsTests.test_unregisterSubscriptionAdapter_hit_wo_factoryc              	   C   sx  ddl m} ddlm} ddlm} G dd d|}|d}|d}G dd	 d	t}|  }|||f| | 	 \}	}
|	 |
||f|}W 5 Q R X | | | |jj | |j | t|
d
 |
d \}}|\}| |i  | t|| | t|j| | |jj|k | |jj|k | |jj|f | |jjd | |jjd | |jj|k d S )Nr   rS   ru   r  c                   @   s   e Zd ZdS )zNComponentsTests.test_unregisterSubscriptionAdapter_hit_w_factory.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   c                   @   s   e Zd ZdS )zRComponentsTests.test_unregisterSubscriptionAdapter_hit_w_factory.<locals>._FactoryNr9   r   r   r   r   r     s   r   rY   rX   r,  r-  r   r   r   0test_unregisterSubscriptionAdapter_hit_w_factory  s6    
z@ComponentsTests.test_unregisterSubscriptionAdapter_hit_w_factoryc              	   C   sp  ddl m} ddl m} ddlm} ddlm} G dd d|}|d}|d}||G d	d
 d
t}|  }	|		||f| | 
 \}
}|
 |	||f}W 5 Q R X | | | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|	k | |jj|k | |jj|f | |jjd | |jjd | |jj|k d S )Nr   rS   r   ru   r  c                   @   s   e Zd ZdS )zUComponentsTests.test_unregisterSubscriptionAdapter_wo_explicit_provided.<locals>.IFooNr9   r   r   r   r   r<   $  s   r<   r   c                   @   s   e Zd ZdS )zYComponentsTests.test_unregisterSubscriptionAdapter_wo_explicit_provided.<locals>._FactoryNr9   r   r   r   r   r   (  s   r   rY   rX   )rA   r8   r   rZ   rv   r[   r  rB   r   r  r   r&  r$   r!   r^   r%   r   r_   r   r   r?   rL   )r
   r8   r   rv   r  r<   rD   r   r   r,   r   r   r   r   r   ra   r   r   r   7test_unregisterSubscriptionAdapter_wo_explicit_provided  s6    
zGComponentsTests.test_unregisterSubscriptionAdapter_wo_explicit_providedc              	      s`  ddl m} ddlm} ddlm} G dd d|}|d}|d G  fdd	d	t}|  }|| f| | 	 \}}	| |j
||d
}
W 5 Q R X | |
 | t|	d |	d \}}|\}| |i  | t|| | t|j| | |jj|k | |jj|k | |jj f | |jjd | |jjd | |jj|k d S )Nr   rS   ru   r  c                   @   s   e Zd ZdS )zUComponentsTests.test_unregisterSubscriptionAdapter_wo_explicit_required.<locals>.IFooNr9   r   r   r   r   r<   C  s   r<   r   c                       s   e Zd Z fZdS )zYComponentsTests.test_unregisterSubscriptionAdapter_wo_explicit_required.<locals>._FactoryNr   r   r   r   r   r   G  s   r   r   rY   rX   )rA   r8   rZ   rv   r[   r  rB   r   r  r   r&  r$   r!   r^   r%   r   r_   r   r   r?   rL   )r
   r8   rv   r  r<   rD   r   r,   r   r   r   r   r   ra   r   r   r   7test_unregisterSubscriptionAdapter_wo_explicit_required?  s2    
zGComponentsTests.test_unregisterSubscriptionAdapter_wo_explicit_requiredc           	      C   s|   ddl m} ddl m} G dd d|}|d}|d}|  }||G dd dt}| }| t||f|g  d S )	Nr   rS   r   c                   @   s   e Zd ZdS )z4ComponentsTests.test_subscribers_empty.<locals>.IFooNr9   r   r   r   r   r<   `  s   r<   r   c                   @   s   e Zd ZdS )z3ComponentsTests.test_subscribers_empty.<locals>.BarNr9   r   r   r   r   Bare  s   r2  )rA   r8   r   r   rB   r!   r   subscribers)	r
   r8   r   r<   rD   r   r,   r2  barr   r   r   test_subscribers_empty]  s    z&ComponentsTests.test_subscribers_emptyc                    s   ddl m} ddl m} G dd d|}|d}|d G  fdddt}G d	d
 d
|}|  }|| f| || f| | G dd dt}| }	||	f|}
dd }t|
|d}
| t	|
d | 
t|
d | | 
t|
d | d S )Nr   rS   r   c                   @   s   e Zd ZdS )z8ComponentsTests.test_subscribers_non_empty.<locals>.IFooNr9   r   r   r   r   r<   n  s   r<   r   c                       s   e Zd Z fZdd ZdS )z<ComponentsTests.test_subscribers_non_empty.<locals>._Factoryc                 S   s
   || _ d S r   )r   r   r   r   r   r   t  s    zEComponentsTests.test_subscribers_non_empty.<locals>._Factory.__init__N)r"   r:   r;   r   r   r   r   r   r   r   r  s   r   c                   @   s   e Zd ZdS )z<ComponentsTests.test_subscribers_non_empty.<locals>._DerivedNr9   r   r   r   r   _Derivedv  s   r6  c                   @   s   e Zd ZdS )z7ComponentsTests.test_subscribers_non_empty.<locals>.BarNr9   r   r   r   r   r2  {  s   r2  c                 S   s   | j jS r   )r   r"   xr   r   r   
_klassname  s    z>ComponentsTests.test_subscribers_non_empty.<locals>._klassnamer   rl   rY   )rA   r8   r   rB   r   r  r3  r   r!   r^   r$   r%   )r
   r8   r   r<   rD   r   r6  r,   r2  r4  r3  r9  r   r   r   test_subscribers_non_emptyk  s&    z*ComponentsTests.test_subscribers_non_emptyc                 C   sR   ddl m} G dd d|}|d}d}|  }dd }| jt|j|||d d S )	Nr   rS   c                   @   s   e Zd ZdS )zBComponentsTests.test_registerHandler_w_nonblank_name.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r$  c                 S   s
   t  d S r   rG   r   r   r   r   rI     s    zFComponentsTests.test_registerHandler_w_nonblank_name.<locals>._factoryr   r   )rA   r8   r   rN   rO   registerHandler)r
   r8   r<   rD   r'  r,   rI   r   r   r   $test_registerHandler_w_nonblank_name  s     z4ComponentsTests.test_registerHandler_w_nonblank_namec              	   C   s  ddl m} ddlm} ddlm} G dd d|}|d}d}d}d	d
 }|  }	|  \}
}|
 |	j||f|d W 5 Q R X |	j	j
d | d  | }| t|d | |d |k | |	j|f|||fg | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|	k | |jj|f | |jj| | |jj|k | |jj|k d S )Nr   rS   rT   HandlerRegistrationc                   @   s   e Zd ZdS )zFComponentsTests.test_registerHandler_w_explicit_required.<locals>.IFooNr9   r   r   r   r   r<     s   r<   rX   r?   c                 S   s
   t  d S r   rG   r   r   r   r   rI     s    zJComponentsTests.test_registerHandler_w_explicit_required.<locals>._factoryr@   rY   )rA   r8   rZ   rU   r[   r?  r   r   r<  r&   r]   r!   r^   r$   r+   r%   rB   r   r   r   r?   rL   )r
   r8   rU   r?  r<   rD   r  rE   rI   r,   r   r   r   r   r   ra   r   r   r   (test_registerHandler_w_explicit_required  s:    z8ComponentsTests.test_registerHandler_w_explicit_requiredc           
   	      s   ddl m} G dd d|}|d d}d}G  fdddt}|  }|  \}}| |j||d	d
 W 5 Q R X |jjd   d  | }	| t	|	d | 
|	d |k | |j f|||fg | t	|d d S )Nr   rS   c                   @   s   e Zd ZdS )zPComponentsTests.test_registerHandler_wo_explicit_required_no_event.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   rX   c                       s   e Zd Z fZdS )zTComponentsTests.test_registerHandler_wo_explicit_required_no_event.<locals>._FactoryNr   r   rD   r   r   r     s   r   Fr  rY   )rA   r8   rB   r   r   r<  r&   r]   r!   r^   r$   r+   )
r
   r8   r<   rE   r  r   r,   r   r   r   r   rA  r   2test_registerHandler_wo_explicit_required_no_event  s"    zBComponentsTests.test_registerHandler_wo_explicit_required_no_eventc                 C   s   |   }| t|  d S r   )r   r   r   registeredHandlersr1   r   r   r   test_registeredHandlers_empty  s    z-ComponentsTests.test_registeredHandlers_emptyc           
      C   sL  ddl m} ddlm} G dd d|}|d}dd }dd	 }|  }|||f |||f d
d }t| |d}	| t	|	d | 
t|	d | | |	d j|f | |	d jd | |	d j| | |	d jd | 
t|	d | | |	d j|f | |	d jd | |	d j| | |	d jd d S )Nr   rS   r>  c                   @   s   e Zd ZdS )z?ComponentsTests.test_registeredHandlers_non_empty.<locals>.IFooNr9   r   r   r   r   r<     s   r<   c                 S   s
   t  d S r   rG   r   r   r   r   	_factory1  s    zDComponentsTests.test_registeredHandlers_non_empty.<locals>._factory1c                 S   s
   t  d S r   rG   r   r   r   r   	_factory2  s    zDComponentsTests.test_registeredHandlers_non_empty.<locals>._factory2c                 S   s
   | j jjS r   )rL   __code__co_namer7  r   r   r   _factory_name  s    zHComponentsTests.test_registeredHandlers_non_empty.<locals>._factory_namer   rl   rX   rY   )rA   r8   r[   r?  r   r<  r   rC  r!   r^   r$   r%   r   r   rL   r?   )
r
   r8   r?  r<   rD   rE  rF  r,   rI  r3  r   r   r   !test_registeredHandlers_non_empty  s,    z1ComponentsTests.test_registeredHandlers_non_emptyc                 C   sJ   ddl m} G dd d|}|d}d}|  }| jt|j|f|d d S )Nr   rS   c                   @   s   e Zd ZdS )zDComponentsTests.test_unregisterHandler_w_nonblank_name.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r$  r;  )rA   r8   r   rN   rO   unregisterHandler)r
   r8   r<   rD   r'  r,   r   r   r   &test_unregisterHandler_w_nonblank_name  s    
 z6ComponentsTests.test_unregisterHandler_w_nonblank_namec                 C   s   |   }| t|j d S r   )r   rN   rO   rK  r1   r   r   r   3test_unregisterHandler_neither_factory_nor_required  s    zCComponentsTests.test_unregisterHandler_neither_factory_nor_requiredc                 C   sH   ddl m} G dd d|}|d}|  }|j|fd}| | d S )Nr   rS   c                   @   s   e Zd ZdS )z9ComponentsTests.test_unregisterHandler_miss.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   )rA   r8   r   rK  r   )r
   r8   r<   rD   r,   r   r   r   r   test_unregisterHandler_miss  s    z+ComponentsTests.test_unregisterHandler_missc              	   C   s0  ddl m} ddlm} ddlm} G dd d|}|d}|  }dd }|  }|||f |  \}}	| |	||f}
W 5 Q R X | 
|
 | t|	d	 |	d \}}|\}| |i  | 
t|| | 
t|j| | 
|jj|k | |jj|f | |jjd
 | 
|jj|k d S )Nr   rS   ru   r>  c                   @   s   e Zd ZdS )zXComponentsTests.test_unregisterHandler_hit_w_factory_and_explicit_provided.<locals>.IFooNr9   r   r   r   r   r<   
  s   r<   c                 S   s
   t  d S r   rG   r   r   r   r   rI     s    z\ComponentsTests.test_unregisterHandler_hit_w_factory_and_explicit_provided.<locals>._factoryrY   rX   rA   r8   rZ   rv   r[   r?  r   r<  r   rK  r$   r!   r^   r%   rB   r   r   r   rL   r
   r8   rv   r?  r<   rD   r,   rI   r   r   r   r   r   ra   r   r   r   :test_unregisterHandler_hit_w_factory_and_explicit_provided  s.    
zJComponentsTests.test_unregisterHandler_hit_w_factory_and_explicit_providedc              	   C   s0  ddl m} ddlm} ddlm} G dd d|}|d}|  }dd }|  }|||f |  \}}	| |j	|fd	}
W 5 Q R X | 
|
 | t|	d
 |	d \}}|\}| |i  | 
t|| | 
t|j| | 
|jj|k | |jj|f | |jjd | 
|jjd k d S )Nr   rS   ru   r>  c                   @   s   e Zd ZdS )zQComponentsTests.test_unregisterHandler_hit_w_only_explicit_provided.<locals>.IFooNr9   r   r   r   r   r<   %  s   r<   c                 S   s
   t  d S r   rG   r   r   r   r   rI   )  s    zUComponentsTests.test_unregisterHandler_hit_w_only_explicit_provided.<locals>._factoryrN  rY   rX   rP  rQ  r   r   r   3test_unregisterHandler_hit_w_only_explicit_provided!  s.    
zCComponentsTests.test_unregisterHandler_hit_w_only_explicit_providedc              	      s<  ddl m} ddlm} ddlm} G dd d|}|d G  fdddt}|  }|| | 	 \}}| |
|}	W 5 Q R X | |	 | t|d	 |d \}
}|
\}| |i  | t|| | t|j| | |jj|k | |jj f | |jjd
 | |jjd
 | |jj|k d S )Nr   rS   ru   r>  c                   @   s   e Zd ZdS )zIComponentsTests.test_unregisterHandler_wo_explicit_required.<locals>.IFooNr9   r   r   r   r   r<   @  s   r<   c                       s   e Zd Z fZdS )zMComponentsTests.test_unregisterHandler_wo_explicit_required.<locals>._FactoryNr   r   rA  r   r   r   C  s   r   rY   rX   )rA   r8   rZ   rv   r[   r?  rB   r   r<  r   rK  r$   r!   r^   r%   r   r   r   r?   rL   )r
   r8   rv   r?  r<   r   r,   r   r   r   r   r   ra   r   rA  r   +test_unregisterHandler_wo_explicit_required<  s.    

z;ComponentsTests.test_unregisterHandler_wo_explicit_requiredc                 C   sf   ddl m} ddl m} G dd d|}|d}|  }||G dd dt}| }||f d S )Nr   rS   r   c                   @   s   e Zd ZdS )z/ComponentsTests.test_handle_empty.<locals>.IFooNr9   r   r   r   r   r<   [  s   r<   c                   @   s   e Zd ZdS )z.ComponentsTests.test_handle_empty.<locals>.BarNr9   r   r   r   r   r2  _  s   r2  )rA   r8   r   r   rB   handle)r
   r8   r   r<   rD   r,   r2  r4  r   r   r   test_handle_emptyX  s    z!ComponentsTests.test_handle_emptyc           
         s   ddl m} ddl m} G dd d|}|d}g   fdd}g fdd	}|  }|||f |||f ||G d
d dt}| }	||	 |  |	g | |	g d S )Nr   rS   r   c                   @   s   e Zd ZdS )z3ComponentsTests.test_handle_non_empty.<locals>.IFooNr9   r   r   r   r   r<   h  s   r<   c                    s     |  d S r   r   r   )	_called_1r   r   
_factory_1l  s    z9ComponentsTests.test_handle_non_empty.<locals>._factory_1c                    s     |  d S r   r   r   )	_called_2r   r   
_factory_2o  s    z9ComponentsTests.test_handle_non_empty.<locals>._factory_2c                   @   s   e Zd ZdS )z2ComponentsTests.test_handle_non_empty.<locals>.BarNr9   r   r   r   r   r2  t  s   r2  )rA   r8   r   r   r<  rB   rU  r!   )
r
   r8   r   r<   rD   rX  rZ  r,   r2  r4  r   )rW  rY  r   test_handle_non_emptye  s"    
z%ComponentsTests.test_handle_non_emptyN)r   )nr"   r:   r;   r   r   r   r-   r/   r2   r5   rF   rR   rb   re   rf   ri   rk   rn   rt   rw   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   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r
  r  r  r  r  r  r  r  r  r  r   r"  r#  r(  r)  r*  r+  r.  r/  r0  r1  r5  r:  r=  r@  rB  rD  rJ  rL  rM  rO  rR  rS  rT  rV  r[  r   r   r   r   r      s   
  )"#	
	
#'#*$	  "	#$'%!	   "	r   c                       s   e Zd Z fddZ  ZS )UnhashableComponentsTestsc                    s    G dd dt t|  t}|S )Nc                   @   s   e Zd ZdS )z=UnhashableComponentsTests._getTargetClass.<locals>.ComponentsNr9   r   r   r   r   r     s   r   )r|   r\  r   r}   )r
   r   r   r   r   r     s    z)UnhashableComponentsTests._getTargetClass)r"   r:   r;   r   r   r   r   r   r   r\  }  s   r\  c                   @   s   e Zd Zdd Zd6d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d0d1 Zd2d3 Zd4d5 ZdS )7UtilityRegistrationTestsc                 C   s   ddl m} |S )Nr   rV   )r[   rW   )r
   rW   r   r   r   r     s    z(UtilityRegistrationTests._getTargetClassNc                 C   sb   ddl m} G dd d|}|d}G dd dt}| }d}d}	|  }
|
|||||	|||fS )	Nr   rS   c                   @   s   e Zd ZdS )z/UtilityRegistrationTests._makeOne.<locals>.IFooNr9   r   r   r   r   r<     s   r<   c                   @   s   e Zd Zdd ZdS )z4UtilityRegistrationTests._makeOne.<locals>._Registryc                 S   s   dS NZ	_REGISTRYr   r	   r   r   r   __repr__  s    z=UtilityRegistrationTests._makeOne.<locals>._Registry.__repr__Nr"   r:   r;   r_  r   r   r   r   	_Registry  s   ra  r   	DOCSTRINGrA   r8   rB   r   )r
   rK   rL   r8   r<   rD   ra  r   r   docklassr   r   r   r     s    z!UtilityRegistrationTests._makeOnec                 C   s*   ddl m} ddlm} |||   d S )Nr   verifyClassIUtilityRegistration)zope.interface.verifyrg  rZ   ri  r   )r
   rg  ri  r   r   r   +test_class_conforms_to_IUtilityRegistration  s    zDUtilityRegistrationTests.test_class_conforms_to_IUtilityRegistrationc                 C   s4   ddl m} ddlm} |  \}}}||| d S )Nr   verifyObjectrh  )rj  rm  rZ   ri  r   )r
   rm  ri  ur_r   r   r   .test_instance_conforms_to_IUtilityRegistration  s    zGUtilityRegistrationTests.test_instance_conforms_to_IUtilityRegistrationc                 C   s>   G dd dt }| }| |\}}}| t|d|  d S )Nc                   @   s   e Zd ZdZ dS )z:UtilityRegistrationTests.test___repr__.<locals>._ComponentTESTNr9   r   r   r   r   
_Component  s   rr  zAUtilityRegistration(_REGISTRY, IFoo, %r, TEST, None, 'DOCSTRING')rB   r   r!   r0   r
   rr  
_componentrn  	_registryr`   r   r   r   r2     s    
z&UtilityRegistrationTests.test___repr__c                 C   sF   G dd dt }| }| |\}}}t  |_| t|d|  d S )Nc                   @   s   e Zd Zdd ZdS )zKUtilityRegistrationTests.test___repr___provided_wo_name.<locals>._Componentc                 S   s   dS Nrq  r   r	   r   r   r   r_    s    zTUtilityRegistrationTests.test___repr___provided_wo_name.<locals>._Component.__repr__Nr`  r   r   r   r   rr    s   rr  AUtilityRegistration(_REGISTRY, None, %r, TEST, None, 'DOCSTRING')rB   r   r_   r!   r0   rt  r   r   r   test___repr___provided_wo_name  s    
z7UtilityRegistrationTests.test___repr___provided_wo_namec                 C   sF   G dd dt }| }| |\}}}t  |_| t|d|  d S )Nc                   @   s   e Zd Zdd ZdS )zLUtilityRegistrationTests.test___repr___component_wo_name.<locals>._Componentc                 S   s   dS rw  r   r	   r   r   r   r_    s    zUUtilityRegistrationTests.test___repr___component_wo_name.<locals>._Component.__repr__Nr`  r   r   r   r   rr    s   rr  rx  ry  rt  r   r   r   test___repr___component_wo_name  s    
z8UtilityRegistrationTests.test___repr___component_wo_namec                 C   s.   t  }| |\}}}| | t| d S r   rB   r   r!   __hash__idr
   ru  rn  rv  r`   r   r   r   test___hash__  s    z&UtilityRegistrationTests.test___hash__c                 C   s(   t  }| |\}}}| ||k d S r   rB   r   r$   r  r   r   r   test___eq___identity  s    z-UtilityRegistrationTests.test___eq___identityc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r
   ru  rn  rv  r`   ur2ro  r   r   r   test___eq___hit  s    z(UtilityRegistrationTests.test___eq___hitc                 C   s>   t  }t  }| |\}}}| |\}}}| ||k d S r   rB   r   r   r
   ru  _component2rn  rv  r`   r  ro  r   r   r   test___eq___miss  s
    z)UtilityRegistrationTests.test___eq___missc                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   test___ne___identity  s    z-UtilityRegistrationTests.test___ne___identityc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r  r   r   r   test___ne___hit  s    z(UtilityRegistrationTests.test___ne___hitc                 C   s>   t  }t  }| |\}}}| |\}}}| ||k d S r   r  r  r   r   r   test___ne___miss  s
    z)UtilityRegistrationTests.test___ne___missc                 C   s(   t  }| |\}}}| ||k  d S r   r  r  r   r   r   test___lt___identity  s    z-UtilityRegistrationTests.test___lt___identityc                 C   s8   t  }| |\}}}| |\}}}| ||k  d S r   r  r  r   r   r   test___lt___hit  s    z(UtilityRegistrationTests.test___lt___hitc                 C   sH   t  }t  }| |\}}}| |\}}}|d |_| ||k  d S N2rB   r   r   r$   r  r   r   r   test___lt___miss 	  s    
z)UtilityRegistrationTests.test___lt___missc                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   test___le___identity	  s    z-UtilityRegistrationTests.test___le___identityc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r  r   r   r   test___le___hit	  s    z(UtilityRegistrationTests.test___le___hitc                 C   sH   t  }t  }| |\}}}| |\}}}|d |_| ||k d S r  r  r  r   r   r   test___le___miss	  s    
z)UtilityRegistrationTests.test___le___missc                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   test___gt___identity	  s    z-UtilityRegistrationTests.test___gt___identityc                 C   sH   t  }t  }| |\}}}| |\}}}|d |_| ||k d S r  r  r  r   r   r   test___gt___hit 	  s    
z(UtilityRegistrationTests.test___gt___hitc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r  r   r   r   test___gt___miss(	  s    z)UtilityRegistrationTests.test___gt___missc                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   test___ge___identity.	  s    z-UtilityRegistrationTests.test___ge___identityc                 C   sH   t  }t  }| |\}}}| |\}}}|d |_| ||k d S r  rB   r   r   r   r  r   r   r   test___ge___miss3	  s    
z)UtilityRegistrationTests.test___ge___missc                 C   sB   t  }| |\}}}| |\}}}|d |_| ||k d S r  r  r  r   r   r   test___ge___hit;	  s
    
z(UtilityRegistrationTests.test___ge___hit)NN)r"   r:   r;   r   r   rk  rp  r2   rz  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   r]    s4   
	r]  c                   @   s   e 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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S );AdapterRegistrationTestsc                 C   s   ddl m} |S )Nr   r   )r[   r   )r
   r   r   r   r   r   E	  s    z(AdapterRegistrationTests._getTargetClassNc                 C   sl   ddl m} G dd d|}|d}|d}G dd dt}| }d}d	}	|  }
|
||f||||	||fS )
Nr   rS   c                   @   s   e Zd ZdS )z/AdapterRegistrationTests._makeOne.<locals>.IFooNr9   r   r   r   r   r<   L	  s   r<   r   c                   @   s   e Zd Zdd ZdS )z4AdapterRegistrationTests._makeOne.<locals>._Registryc                 S   s   dS r^  r   r	   r   r   r   r_  Q	  s    z=AdapterRegistrationTests._makeOne.<locals>._Registry.__repr__Nr`  r   r   r   r   ra  P	  s   ra  r   rb  rc  r
   rK   r8   r<   rD   r   ra  r   r   rd  re  r   r   r   r   I	  s    z!AdapterRegistrationTests._makeOnec                 C   s*   ddl m} ddlm} |||   d S )Nr   rf  IAdapterRegistration)rj  rg  rZ   r  r   )r
   rg  r  r   r   r   +test_class_conforms_to_IAdapterRegistration\	  s    zDAdapterRegistrationTests.test_class_conforms_to_IAdapterRegistrationc                 C   s4   ddl m} ddlm} |  \}}}||| d S )Nr   rl  r  )rj  rm  rZ   r  r   )r
   rm  r  arro  r   r   r   .test_instance_conforms_to_IAdapterRegistrationa	  s    zGAdapterRegistrationTests.test_instance_conforms_to_IAdapterRegistrationc                 C   s>   G dd dt }| }| |\}}}| t|d|  d S )Nc                   @   s   e Zd ZdZ dS )z:AdapterRegistrationTests.test___repr__.<locals>._Componentrq  Nr9   r   r   r   r   rr  h	  s   rr  zCAdapterRegistration(_REGISTRY, [IBar], IFoo, %r, TEST, 'DOCSTRING')rs  r
   rr  ru  r  rv  r`   r   r   r   r2   g	  s    
z&AdapterRegistrationTests.test___repr__c                 C   sF   G dd dt }| }| |\}}}t  |_| t|d|  d S )Nc                   @   s   e Zd Zdd ZdS )zKAdapterRegistrationTests.test___repr___provided_wo_name.<locals>._Componentc                 S   s   dS rw  r   r	   r   r   r   r_  r	  s    zTAdapterRegistrationTests.test___repr___provided_wo_name.<locals>._Component.__repr__Nr`  r   r   r   r   rr  q	  s   rr  CAdapterRegistration(_REGISTRY, [IBar], None, %r, TEST, 'DOCSTRING')ry  r  r   r   r   rz  p	  s    
z7AdapterRegistrationTests.test___repr___provided_wo_namec                 C   sF   G dd dt }| }| |\}}}t  |_| t|d|  d S )Nc                   @   s   e Zd Zdd ZdS )zLAdapterRegistrationTests.test___repr___component_wo_name.<locals>._Componentc                 S   s   dS rw  r   r	   r   r   r   r_  }	  s    zUAdapterRegistrationTests.test___repr___component_wo_name.<locals>._Component.__repr__Nr`  r   r   r   r   rr  |	  s   rr  r  ry  r  r   r   r   r{  {	  s    
z8AdapterRegistrationTests.test___repr___component_wo_namec                 C   s.   t  }| |\}}}| | t| d S r   r|  r
   ru  r  rv  r`   r   r   r   r  	  s    z&AdapterRegistrationTests.test___hash__c                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   r  	  s    z-AdapterRegistrationTests.test___eq___identityc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r
   ru  r  rv  r`   ar2ro  r   r   r   r  	  s    z(AdapterRegistrationTests.test___eq___hitc                 C   s>   t  }t  }| |\}}}| |\}}}| ||k d S r   r  r
   ru  r  r  rv  r`   r  ro  r   r   r   r  	  s
    z)AdapterRegistrationTests.test___eq___missc                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   r  	  s    z-AdapterRegistrationTests.test___ne___identityc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r  r   r   r   r  	  s    z)AdapterRegistrationTests.test___ne___missc                 C   s>   t  }t  }| |\}}}| |\}}}| ||k d S r   r  r  r   r   r   test___ne___hit_component	  s
    z2AdapterRegistrationTests.test___ne___hit_componentc           
      C   sb   ddl m} G dd d|}|d}t }| |\}}}| |\}}	}	||_| ||k d S )Nr   rS   c                   @   s   e Zd ZdS )z?AdapterRegistrationTests.test___ne___hit_provided.<locals>.IFooNr9   r   r   r   r   r<   	  s   r<   r   )rA   r8   rB   r   r_   r$   )
r
   r8   r<   r  ru  r  rv  r`   r  ro  r   r   r   test___ne___hit_provided	  s    z1AdapterRegistrationTests.test___ne___hit_providedc                 C   sj   ddl m} G dd d|}|d}t }t }| |\}}}| |\}	}
}
|f|	_| ||	k d S )Nr   rS   c                   @   s   e Zd ZdS )z?AdapterRegistrationTests.test___ne___hit_required.<locals>.IFooNr9   r   r   r   r   r<   	  s   r<   r   )rA   r8   rB   r   r   r$   )r
   r8   r<   r  ru  r  r  rv  r`   r  ro  r   r   r   test___ne___hit_required	  s    z1AdapterRegistrationTests.test___ne___hit_requiredc                 C   s(   t  }| |\}}}| ||k  d S r   r  r  r   r   r   r  	  s    z-AdapterRegistrationTests.test___lt___identityc                 C   s8   t  }| |\}}}| |\}}}| ||k  d S r   r  r  r   r   r   r  	  s    z(AdapterRegistrationTests.test___lt___hitc                 C   sH   t  }t  }| |\}}}| |\}}}|d |_| ||k  d S r  r  r  r   r   r   r  	  s    
z)AdapterRegistrationTests.test___lt___missc                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   r  	  s    z-AdapterRegistrationTests.test___le___identityc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r  r   r   r   r  	  s    z(AdapterRegistrationTests.test___le___hitc                 C   sH   t  }t  }| |\}}}| |\}}}|d |_| ||k d S r  r  r  r   r   r   r  	  s    
z)AdapterRegistrationTests.test___le___missc                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   r  	  s    z-AdapterRegistrationTests.test___gt___identityc                 C   sH   t  }t  }| |\}}}| |\}}}|d |_| ||k d S r  r  r  r   r   r   r  	  s    
z(AdapterRegistrationTests.test___gt___hitc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r  r   r   r   r  	  s    z)AdapterRegistrationTests.test___gt___missc                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   r  	  s    z-AdapterRegistrationTests.test___ge___identityc                 C   sH   t  }t  }| |\}}}| |\}}}|d |_| ||k d S r  r  r  r   r   r   r  
  s    
z)AdapterRegistrationTests.test___ge___missc                 C   sB   t  }| |\}}}| |\}}}|d |_| ||k d S r  r  r  r   r   r   r  
  s
    
z(AdapterRegistrationTests.test___ge___hit)N)r"   r:   r;   r   r   r  r  r2   rz  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   r  C	  s8   
	r  c                   @   s.   e Zd Zdd Zd
ddZdd Zdd	 ZdS )SubscriptionRegistrationTestsc                 C   s   ddl m} |S )Nr   r  )r[   r  )r
   r  r   r   r   r   
  s    z-SubscriptionRegistrationTests._getTargetClassNc                 C   sl   ddl m} G dd d|}|d}|d}G dd dt}| }d}d	}	|  }
|
||f||||	||fS )
Nr   rS   c                   @   s   e Zd ZdS )z4SubscriptionRegistrationTests._makeOne.<locals>.IFooNr9   r   r   r   r   r<   
  s   r<   r   c                   @   s   e Zd Zdd ZdS )z9SubscriptionRegistrationTests._makeOne.<locals>._Registryc                 S   s   dS r^  r   r	   r   r   r   r_  "
  s    zBSubscriptionRegistrationTests._makeOne.<locals>._Registry.__repr__Nr`  r   r   r   r   ra  !
  s   ra  r   rb  rc  r  r   r   r   r   
  s    z&SubscriptionRegistrationTests._makeOnec                 C   s*   ddl m} ddlm} |||   d S )Nr   rf   ISubscriptionAdapterRegistration)rj  rg  rZ   r  r   )r
   rg  r  r   r   r   7test_class_conforms_to_ISubscriptionAdapterRegistration-
  s    zUSubscriptionRegistrationTests.test_class_conforms_to_ISubscriptionAdapterRegistrationc                 C   s4   ddl m} ddlm} |  \}}}||| d S )Nr   rl  r  )rj  rm  rZ   r  r   )r
   rm  r  Zsarro  r   r   r   :test_instance_conforms_to_ISubscriptionAdapterRegistration2
  s    zXSubscriptionRegistrationTests.test_instance_conforms_to_ISubscriptionAdapterRegistration)N)r"   r:   r;   r   r   r  r  r   r   r   r   r  
  s   
r  c                   @   sF   e 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S )HandlerRegistrationTestsc                 C   s   ddl m} |S )Nr   r>  )r[   r?  )r
   r?  r   r   r   r   ;
  s    z(HandlerRegistrationTests._getTargetClassNc           
      C   sb   ddl m} G dd d|}|d}G dd dt}| }d}d}|  }	|	||f|||||fS )	Nr   rS   c                   @   s   e Zd ZdS )z/HandlerRegistrationTests._makeOne.<locals>.IFooNr9   r   r   r   r   r<   B
  s   r<   c                   @   s   e Zd Zdd ZdS )z4HandlerRegistrationTests._makeOne.<locals>._Registryc                 S   s   dS r^  r   r	   r   r   r   r_  F
  s    z=HandlerRegistrationTests._makeOne.<locals>._Registry.__repr__Nr`  r   r   r   r   ra  E
  s   ra  r   rb  rc  )
r
   rK   r8   r<   rD   ra  r   r   rd  re  r   r   r   r   ?
  s    z!HandlerRegistrationTests._makeOnec                 C   s*   ddl m} ddlm} |||   d S )Nr   rf  IHandlerRegistration)rj  rg  rZ   r  r   )r
   rg  r  r   r   r   +test_class_conforms_to_IHandlerRegistrationQ
  s    zDHandlerRegistrationTests.test_class_conforms_to_IHandlerRegistrationc                 C   s4   ddl m} ddlm} |  \}}}||| d S )Nr   rl  r  )rj  rm  rZ   r  r   )r
   rm  r  hrro  r   r   r   .test_instance_conforms_to_IHandlerRegistrationV
  s    zGHandlerRegistrationTests.test_instance_conforms_to_IHandlerRegistrationc                 C   sN   dd }|  |\}}}| |j|k | |j|jk | |jd k d S )Nc                 S   s
   t  d S r   rG   r   r   r   r   rI   ]
  s    z:HandlerRegistrationTests.test_properties.<locals>._factory)r   r$   ZhandlerrL   r_   )r
   rI   r  ro  r   r   r   test_properties\
  s
    z(HandlerRegistrationTests.test_propertiesc                 C   s:   G dd dt }| | \}}}| t|d|  d S )Nc                   @   s   e Zd ZdZ dS )zGHandlerRegistrationTests.test___repr___factory_w_name.<locals>._Factoryrq  Nr9   r   r   r   r   r   e
  s   r   =HandlerRegistration(_REGISTRY, [IFoo], %r, TEST, 'DOCSTRING')rs  r
   r   r  rv  r`   r   r   r   test___repr___factory_w_named
  s    
z5HandlerRegistrationTests.test___repr___factory_w_namec                 C   s:   G dd dt }| | \}}}| t|d|  d S )Nc                   @   s   e Zd Zdd ZdS )zHHandlerRegistrationTests.test___repr___factory_wo_name.<locals>._Factoryc                 S   s   dS rw  r   r	   r   r   r   r_  n
  s    zQHandlerRegistrationTests.test___repr___factory_wo_name.<locals>._Factory.__repr__Nr`  r   r   r   r   r   m
  s   r   r  rs  r  r   r   r   test___repr___factory_wo_namel
  s    
z6HandlerRegistrationTests.test___repr___factory_wo_name)N)
r"   r:   r;   r   r   r  r  r  r  r  r   r   r   r   r  9
  s   
r  c                   @   s   e Zd Zdd Zdd ZdS )PersistentAdapterRegistryc                 C   sF   | j  }t|D ]"}|| jks*|dr|| q|dd  |S )NZ_vZro)__dict__copyr   Z
_delegated
startswithpop)r
   statekr   r   r   __getstate__w
  s    
z&PersistentAdapterRegistry.__getstate__c                 C   s6   | dd}| j| |   || _| j|  d S )Nr#   r   )r  r  updateZ_createLookupr#   Z	_v_lookupZchanged)r
   r  basesr   r   r   __setstate__
  s
    z&PersistentAdapterRegistry.__setstate__N)r"   r:   r;   r  r  r   r   r   r   r  u
  s   r  c                   @   s   e Zd Zdd ZdS )PersistentComponentsc                 C   s   t  | _t  | _d S r   )r  r&   r'   r	   r   r   r   _init_registries
  s    z%PersistentComponents._init_registriesN)r"   r:   r;   r  r   r   r   r   r  
  s   r  c                   @   s   e Zd ZdS )PersistentDictComponentsNr9   r   r   r   r   r  
  s   r  c                   @   s   e Zd Zdd ZdS )PersistentComponentsDictc                 C   s   t |  t| | d S r   )r}   r   r  )r
   r   r   r   r   r   
  s    
z!PersistentComponentsDict.__init__Nr   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 )
TestPersistentComponentsc                 C   s   t dS )Nr   )r  r	   r   r   r   r   
  s    z!TestPersistentComponents._makeOnec                 C   s   d S r   r   r
   Zmader   r   r   _check_equality_after_pickle
  s    z5TestPersistentComponents._check_equality_after_picklec                 C   s<   dd l }|  }|| |||}| |jd d S Nr   r   )pickler   dumpsloadsr!   r"   )r
   r  r,   comp2r   r   r   test_pickles_empty
  s
    
z+TestPersistentComponents.test_pickles_emptyc                 C   s   dd l }|  }t }||t | ||t |||}| 	|j
d | |t ||t | ||t | | d S r  )r  r   rB   rC   r   ZassertIsr   r  r  r!   r"   ZassertIsNotNoner  )r
   r  r,   Zutilityr  r   r   r   &test_pickles_with_utility_registration
  s*    z?TestPersistentComponents.test_pickles_with_utility_registrationN)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S )TestPersistentDictComponentsc                 C   s   t S r   )r  r	   r   r   r   r   
  s    z,TestPersistentDictComponents._getTargetClassc                 C   s   |   dd}d|d< |S )Nr   r   *   r   r   r1   r   r   r   r   
  s    z%TestPersistentDictComponents._makeOnec                 C   s    |  d| | |d d d S )Nr   r  )ZassertInr!   r  r   r   r   r  
  s    z9TestPersistentDictComponents._check_equality_after_pickleN)r"   r:   r;   r   r   r  r   r   r   r   r  
  s   r  c                   @   s   e Zd Zdd ZdS )TestPersistentComponentsDictc                 C   s   t S r   )r  r	   r   r   r   r   
  s    z,TestPersistentComponentsDict._getTargetClassN)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S )r   c                    s@    | _ t fdd|D | _| D ]\}}t || q&d S )Nc                    s   g | ]}|t  |fqS r   )getattr).0r   moduler   r   
<listcomp>
  s     z$_Monkey.__init__.<locals>.<listcomp>)r  r}   
to_restoreitemssetattr)r
   r  r   r   valuer   r  r   r   
  s    z_Monkey.__init__c                 C   s   | S r   r   r	   r   r   r   	__enter__
  s    z_Monkey.__enter__c                 C   s&   | j  D ]\}}t| j|| q
d S r   )r  r  r  r  )r
   exc_typeZ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   )__doc__Zunittestr   r   r    r   r[   r   ZTestCaser   r\  r]  r  r  r  r  r  r}   r  r  r  r  r  rB   r   r   r   r   r   <module>   sH                   v : R%<+