U
    [e                    @   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                       s  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 ZG fddZH fddZIdd ZJdd ZKdd ZLdd ZMdd ZNdd ZO fdd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ׄ Zmddل Znddۄ Zodd݄ Zpdd߄ ZqdddZrdd Zsdd Zt  ZuS )ComponentsTestsc                 C   s   t S Nr   self r   d/var/www/html/services/stratfitenv/lib/python3.8/site-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)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
   r4   r5   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>.FooNr:   r   r   r   r   FooV   s   r?   infor@   )zope.interface.declarationsr8   r9   objectr   registerUtilityr"   r)   )	r
   r8   r9   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rC   r   assertRaises	TypeErrorrD   r
   rJ   _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   r9   
RegisteredUtilityRegistrationc                   @   s   e Zd ZdS )z>ComponentsTests.test_registerUtility_w_component.<locals>.IFooNr:   r   r   r   r   r=   o   s   r=   r@   r       )rB   r9   zope.interface.interfacesrV   zope.interface.registryrX   rC   r   r   rD   r%   r(   	_adaptersr"   r)   _subscriberslenr&   r   providedr   rL   r@   rM   )r
   r9   rV   rX   r=   rE   rF   _namerR   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   rT   rU   rW   c                   @   s   e Zd ZdS )z<ComponentsTests.test_registerUtility_w_factory.<locals>.IFooNr:   r   r   r   r   r=      s   r=   r@   r   c                      s    S r   r   r   rR   r   r   rJ      s    z@ComponentsTests.test_registerUtility_w_factory.<locals>._factoryrM   rZ   )rB   r9   r[   rV   r\   rX   rC   r   r   rD   r"   r_   r%   r&   r   r`   r   rL   r@   rM   )r
   r9   rV   rX   r=   rE   rF   ra   rJ   r-   r   r   r   r   rb   r   rd   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>.FooNr:   r   r   r   r   r?      s   r?   r@   r   rN   )r
   r?   rF   ra   rR   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   directlyProvidesrT   rU   rW   c                   @   s   e Zd ZdS )z>ComponentsTests.test_registerUtility_wo_provided.<locals>.IFooNr:   r   r   r   r   r=      s   r=   c                   @   s   e Zd ZdS )z=ComponentsTests.test_registerUtility_wo_provided.<locals>.FooNr:   r   r   r   r   r?      s   r?   r@   r   rZ   )rB   ri   r9   r[   rV   r\   rX   rC   r   r   rD   r"   r_   r%   r&   r   r`   r   rL   r@   rM   )r
   ri   r9   rV   rX   r=   r?   rE   rF   ra   rR   r-   r   r   r   r   rb   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   rT   c                   @   s   e Zd ZdS )zJComponentsTests.test_registerUtility_duplicates_existing_reg.<locals>.IFooNr:   r   r   r   r   r=      s   r=   r@   r   )rB   r9   rC   r   rD   r   r"   r_   
r
   r9   r=   rE   rF   ra   rR   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   rT   c                   @   s   e Zd ZdS )zCComponentsTests.test_registerUtility_w_different_info.<locals>.IFooNr:   r   r   r   r   r=      s   r=   Zinfo1Zinfo2r      rY   rB   r9   rC   r   rD   r   r"   r_   r)   r(   r^   )r
   r9   r=   rE   Z_info1Z_info2ra   rR   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   rT   c                   @   s   e Zd ZdS )zSComponentsTests.test_registerUtility_w_different_names_same_component.<locals>.IFooNr:   r   r   r   r   r=      s   r=   r@   name1name2rZ   rY   rn   r
   r9   r=   rE   rF   _name1_name2Z
_other_regrR   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   rT   UnregisteredrU   rW   c                   @   s   e Zd ZdS )zHComponentsTests.test_registerUtility_replaces_existing_reg.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r@   r   rm   rZ   )rB   r9   r[   rw   rV   r\   rX   rC   r   rD   r   r"   r_   r%   r&   r   r`   r   rL   r@   rM   )r
   r9   rw   rV   rX   r=   rE   rF   ra   Z_beforeZ_afterr-   r   r   r   r   rb   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   rT   c                   @   s   e Zd ZdS )zDComponentsTests.test_registerUtility_w_existing_subscr.<locals>.IFooNr:   r   r   r   r   r=   <  s   r=   r@   rp   rq   rY   )	rB   r9   rC   r   rD   r   r"   r(   r^   r
   r9   r=   rE   rF   rs   rt   rR   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   rT   c                   @   s   e Zd ZdS )z;ComponentsTests.test_registerUtility_wo_event.<locals>.IFooNr:   r   r   r   r   r=   M  s   r=   r@   r   F)rB   r9   rC   r   r   rD   r"   r_   rk   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 )NrZ   )	reg_countsuperrD   dictr)   r
   r   )CompThatChangesAfter1Reg	__class__r   r   rD   ^  s    
ztComponentsTests.test_registerUtility_changes_object_identity_after.<locals>.CompThatChangesAfter1Reg.registerUtilityr#   r;   r<   r|   rD   __classcell__r   r   r   r   r   \  s   r   rZ   c                   @   s   e Zd ZdS )zPComponentsTests.test_registerUtility_changes_object_identity_after.<locals>.IFooNr:   r   r   r   r   r=   i  s   r=   rm   r   rD   rC   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 )NrZ   rm   )r|   r~   r)   r}   rD   r   )CompThatChangesAfter2Regr   r   r   rD   t  s    
zuComponentsTests.test_registerUtility_changes_object_identity_before.<locals>.CompThatChangesAfter2Reg.registerUtilityr   r   r   r   r   r   r  s   r   rZ   c                   @   s   e Zd ZdS )zQComponentsTests.test_registerUtility_changes_object_identity_before.<locals>.IFooNr:   r   r   r   r   r=     s   r=   rm   c                   @   s   e Zd ZdS )zQComponentsTests.test_registerUtility_changes_object_identity_before.<locals>.IBarNr:   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)rL   r`   rM   )r   rO   rP   unregisterUtilityr2   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   rH   r   r   r   r   rJ     s    zSComponentsTests.test_unregisterUtility_both_factory_and_component.<locals>._factoryrK   )rC   r   rO   rP   r   rQ   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   rT   c                   @   s   e Zd ZdS )zEComponentsTests.test_unregisterUtility_w_component_miss.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   )rB   r9   rC   r   r   r   assertFalse)
r
   r9   r=   rE   ra   rR   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   rT   rv   rW   c                   @   s   e Zd ZdS )z@ComponentsTests.test_unregisterUtility_w_component.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   rZ   )rB   r9   r[   rw   r\   rX   rC   r   rD   r   r   r%   r   r(   r]   r)   r^   r"   r_   r&   r   r`   r   rL   rM   )r
   r9   rw   rX   r=   rE   ra   rR   r-   r   r   r   r   r   rb   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   rT   rv   rW   c                   @   s   e Zd ZdS )z>ComponentsTests.test_unregisterUtility_w_factory.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r@   r   c                      s    S r   r   r   rd   r   r   rJ     s    zBComponentsTests.test_unregisterUtility_w_factory.<locals>._factoryre   rZ   )rB   r9   r[   rw   r\   rX   rC   r   rD   r   r   r%   r"   r_   r&   r   r`   r   rL   rM   )r
   r9   rw   rX   r=   rE   rF   ra   rJ   r-   r   r   r   r   r   rb   r   rd   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   rh   rT   rv   rW   c                   @   s   e Zd ZdS )zIComponentsTests.test_unregisterUtility_wo_explicit_provided.<locals>.IFooNr:   r   r   r   r   r=     s   r=   c                   @   s   e Zd ZdS )zHComponentsTests.test_unregisterUtility_wo_explicit_provided.<locals>.FooNr:   r   r   r   r   r?     s   r?   r@   r   rZ   rB   ri   r9   r[   rw   r\   rX   rC   r   rD   r   r   r%   r"   r_   r&   r   r`   r   rL   r@   rM   r
   ri   r9   rw   rX   r=   r?   rE   rF   ra   rR   r-   r   r   r   r   r   rb   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   rh   rT   rv   rW   c                   @   s   e Zd ZdS )zLComponentsTests.test_unregisterUtility_wo_component_or_factory.<locals>.IFooNr:   r   r   r   r   r=     s   r=   c                   @   s   e Zd ZdS )zKComponentsTests.test_unregisterUtility_wo_component_or_factory.<locals>.FooNr:   r   r   r   r   r?     s   r?   r@   r   r`   r   rZ   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   rT   c                   @   s   e Zd ZdS )zFComponentsTests.test_unregisterUtility_w_existing_subscr.<locals>.IFooNr:   r   r   r   r   r=   0  s   r=   r@   rp   rq   rY   
rB   r9   rC   r   rD   r   r   r"   r(   r^   ry   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   rT   c                   @   s   e Zd ZdS )zSComponentsTests.test_unregisterUtility_w_existing_subscr_non_hashable.<locals>.IFooNr:   r   r   r   r   r=   B  s   r=   r@   rp   rq   rY   )
rB   r9   r~   r   rD   r   r   r"   r(   r^   ry   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   rT   )_UtilityRegistrationsc                   @   s   e Zd ZdS )z_ComponentsTests.test_unregisterUtility_w_existing_subscr_non_hashable_fresh_cache.<locals>.IFooNr:   r   r   r   r   r=   W  s   r=   r@   rp   rq   rY   )rB   r9   r\   r   r~   r   rD   r   r   r"   r(   r^   )r
   r9   r   r=   rE   rF   rs   rt   rR   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   rT   c                   @   s   e Zd ZdS )z]ComponentsTests.test_unregisterUtility_w_existing_subscr_non_hashable_reinitted.<locals>.IFooNr:   r   r   r   r   r=   l  s   r=   r@   rp   rq   r/   )rB   r9   r~   r   rD   __init__r   r   r"   r_   r(   r^   ry   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   rT   c                   @   s   e Zd ZdS )zVComponentsTests.test_unregisterUtility_w_existing_subscr_other_component.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r@   rp   rq   rY   r   rr   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   rT   c                   @   s   e Zd ZdS )zaComponentsTests.test_unregisterUtility_w_existing_subscr_other_component_mixed_hash.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r@   rp   rq   rY   )rB   r9   rC   r~   r   rD   r   r   r"   r(   r^   rr   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   r2   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   rT   rW   c                   @   s   e Zd ZdS )z?ComponentsTests.test_registeredUtilities_notempty.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r@   rp   rq   c                 S   s   | j S r   r   rr   r   r   <lambda>      zCComponentsTests.test_registeredUtilities_notempty.<locals>.<lambda>keyrm   rZ   )rB   r9   r\   rX   rC   r   rD   sortedr   r"   r_   r%   r&   r   r`   r   rL   r@   rM   )r
   r9   rX   r=   rE   rF   rs   rt   rR   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   rT   c                   @   s   e Zd ZdS )z?ComponentsTests.test_queryUtility_miss_no_default.<locals>.IFooNr:   r   r   r   r   r=     s   r=   )rB   r9   r   r%   queryUtilityr
   r9   r=   rE   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   rT   c                   @   s   e Zd ZdS )z>ComponentsTests.test_queryUtility_miss_w_default.<locals>.IFooNr:   r   r   r   r   r=     s   r=   default)rB   r9   r   rC   r%   r   )r
   r9   r=   rE   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   rT   c                   @   s   e Zd ZdS )z3ComponentsTests.test_queryUtility_hit.<locals>.IFooNr:   r   r   r   r   r=     s   r=   )rB   r9   rC   r   rD   r%   r   r
   r9   r=   rE   rR   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   rT   ComponentLookupErrorc                   @   s   e Zd ZdS )z2ComponentsTests.test_getUtility_miss.<locals>.IFooNr:   r   r   r   r   r=     s   r=   )rB   r9   r[   r   r   rO   
getUtility)r
   r9   r   r=   rE   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   rT   c                   @   s   e Zd ZdS )z1ComponentsTests.test_getUtility_hit.<locals>.IFooNr:   r   r   r   r   r=     s   r=   )rB   r9   rC   r   rD   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   rT   c                   @   s   e Zd ZdS )z7ComponentsTests.test_getUtilitiesFor_miss.<locals>.IFooNr:   r   r   r   r   r=     s   r=   )rB   r9   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   rT   c                   @   s   e Zd ZdS )z6ComponentsTests.test_getUtilitiesFor_hit.<locals>.IFooNr:   r   r   r   r   r=     s   r=   rp   rq   r   )rB   r9   rC   r   rD   r"   r   r   r
   r9   r=   rE   rs   rt   rR   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   rT   c                   @   s   e Zd ZdS )zDComponentsTests.test_getAllUtilitiesRegisteredFor_miss.<locals>.IFooNr:   r   r   r   r   r=     s   r=   )rB   r9   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   rT   c                   @   s   e Zd ZdS )zCComponentsTests.test_getAllUtilitiesRegisteredFor_hit.<locals>.IFooNr:   r   r   r   r   r=     s   r=   rp   rq   r   )rB   r9   rC   r   rD   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   r7   c                   @   s   e Zd ZdS )zFComponentsTests.test_registerAdapter_with_component_name.<locals>.IFooNr:   r   r   r   r   r=   /  s   r=   r   r>   c                   @   s   e Zd ZdS )zEComponentsTests.test_registerAdapter_with_component_name.<locals>.FooNr:   r   r   r   r   r?   4  s   r?   r@   rA   )rB   r8   r9   rC   r   registerAdapterr"   r*   )	r
   r8   r9   r=   rE   ibarr?   rF   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   rT   rU   AdapterRegistrationc                   @   s   e Zd ZdS )zSComponentsTests.test_registerAdapter_w_explicit_provided_and_required.<locals>.IFooNr:   r   r   r   r   r=   E  s   r=   r   r@   r   c                 S   s
   t  d S r   rH   contextr   r   r   rJ   L  s    zWComponentsTests.test_registerAdapter_w_explicit_provided_and_required.<locals>._factoryrZ   )rB   r9   r[   rV   r\   r   r   r   r   r%   r'   r]   r"   r*   r_   r&   rC   r   r`   requiredr   r@   rM   )r
   r9   rV   r   r=   rE   r   rF   ra   rJ   r-   r   r   r   r   rb   r   r   r   5test_registerAdapter_w_explicit_provided_and_required@  s>    zEComponentsTests.test_registerAdapter_w_explicit_provided_and_requiredc                 C   sb   ddl m} G dd d|}|d}d}d}G dd	 d	t}|  }| jt|j||f||d
 d S )Nr   rT   c                   @   s   e Zd ZdS )zHComponentsTests.test_registerAdapter_no_provided_available.<locals>.IFooNr:   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>._FactoryNr:   r   r   r   r   _Factorym  s   r   r   r@   rB   r9   rC   r   rO   rP   r   )r
   r9   r=   r   rF   ra   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   rT   implementerrU   r   c                   @   s   e Zd ZdS )zGComponentsTests.test_registerAdapter_wo_explicit_provided.<locals>.IFooNr:   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>._FactoryNr:   r   r   r   r   r     s   r   r   rZ   )rB   r9   r   r[   rV   r\   r   rC   r   r   r   r%   r'   r]   r"   r*   r_   r&   r   r`   r   r   r@   rM   )r
   r9   r   rV   r   r=   rE   r   rF   ra   rR   r   r-   r   r   r   r   rb   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   rT   c                   @   s   e Zd ZdS )zHComponentsTests.test_registerAdapter_no_required_available.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r@   r   c                   @   s   e Zd ZdS )zLComponentsTests.test_registerAdapter_no_required_available.<locals>._FactoryNr:   r   r   r   r   r     s   r   r`   r   r@   r   r
   r9   r=   rE   rF   ra   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   rT   c                   @   s   e Zd ZdS )zEComponentsTests.test_registerAdapter_w_invalid_required.<locals>.IFooNr:   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>._FactoryNr:   r   r   r   r   r     s   r   r   r   )	r
   r9   r=   rE   r   rF   ra   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   rT   r   rU   r   c                   @   s   e Zd ZdS )zMComponentsTests.test_registerAdapter_w_required_containing_None.<locals>.IFooNr:   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>._FactoryNr:   r   r   r   r   r     s   r   r   rZ   )rB   r9   Zzope.interface.interfacer   r[   rV   r\   r   rC   r   r   r   r%   r'   r]   r"   r*   r_   r&   r   r`   r   r   r@   rM   )r
   r9   r   rV   r   r=   rE   rF   ra   r   r-   r   r   r   r   rb   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   rT   r   )implementedByrU   r   c                   @   s   e Zd ZdS )zNComponentsTests.test_registerAdapter_w_required_containing_class.<locals>.IFooNr:   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>._FactoryNr:   r   r   r   r   r     s   r   c                   @   s   e Zd ZdS )zRComponentsTests.test_registerAdapter_w_required_containing_class.<locals>._ContextNr:   r   r   r   r   _Context  s   r   r   rZ   )rB   r9   r   r   r[   rV   r\   r   rC   r   r   r   r%   r'   r]   r"   r*   r_   r&   r   r`   r   r   r@   rM   )r
   r9   r   r   rV   r   r=   rE   r   rF   ra   r   r   Z	_ctx_implr-   r   r   r   r   rb   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   rT   c                   @   s   e Zd ZdS )zMComponentsTests.test_registerAdapter_w_required_containing_junk.<locals>.IFooNr:   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>._FactoryNr:   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   rT   rU   r   c                   @   s   e Zd ZdS )zGComponentsTests.test_registerAdapter_wo_explicit_required.<locals>.IFooNr:   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   rZ   )rB   r9   r[   rV   r\   r   rC   r   r   r   r%   r'   r]   r"   r*   r_   r&   r   r`   r   r   r@   rM   )r
   r9   rV   r   r=   rE   rF   ra   r   r-   r   r   r   r   rb   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   rT   c                   @   s   e Zd ZdS )z;ComponentsTests.test_registerAdapter_wo_event.<locals>.IFooNr:   r   r   r   r   r=   =  s   r=   r   r@   r   c                 S   s
   t  d S r   rH   r   r   r   r   rJ   D  s    z?ComponentsTests.test_registerAdapter_wo_event.<locals>._factoryF)rb   )rB   r9   r   r   r   r"   r_   )r
   r9   r=   rE   r   rF   ra   rJ   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)rM   r`   )r   rO   rP   unregisterAdapterr2   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   rT   c                   @   s   e Zd ZdS )zQComponentsTests.test_unregisterAdapter_neither_factory_nor_required.<locals>.IFooNr:   r   r   r   r   r=   T  s   r=   rM   r`   r   )rB   r9   r   rO   rP   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   rT   c                   @   s   e Zd ZdS )z9ComponentsTests.test_unregisterAdapter_miss.<locals>.IFooNr:   r   r   r   r   r=   ]  s   r=   r   c                   @   s   e Zd ZdS )z=ComponentsTests.test_unregisterAdapter_miss.<locals>._FactoryNr:   r   r   r   r   r   a  s   r   )rB   r9   rC   r   r   r   r   
r
   r9   r=   rE   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   rT   rv   r   c                   @   s   e Zd ZdS )zYComponentsTests.test_unregisterAdapter_hit_w_explicit_provided_and_required.<locals>.IFooNr:   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>._FactoryNr:   r   r   r   r   r   r  s   r   rZ   rY   )rB   r9   r[   rw   r\   r   rC   r   r   r   r   r%   r   r'   r]   r*   r"   r_   r&   r   r`   r   r   r@   rM   )r
   r9   rw   r   r=   rE   r   r   r-   r   r   r   r   r   rb   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   rT   r   rv   r   c                   @   s   e Zd ZdS )zIComponentsTests.test_unregisterAdapter_wo_explicit_provided.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   c                   @   s   e Zd ZdS )zMComponentsTests.test_unregisterAdapter_wo_explicit_provided.<locals>._FactoryNr:   r   r   r   r   r     s   r   rZ   rY   )rB   r9   r   r[   rw   r\   r   rC   r   r   r   r   r%   r"   r_   r&   r   r`   r   r   r@   rM   )r
   r9   r   rw   r   r=   rE   r   r   r-   r   r   r   r   r   rb   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   rT   rv   r   c                   @   s   e Zd ZdS )zIComponentsTests.test_unregisterAdapter_wo_explicit_required.<locals>.IFooNr:   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`   rZ   rY   )rB   r9   r[   rw   r\   r   rC   r   r   r   r   r%   r"   r_   r&   r   r`   r   r   r@   rM   )r
   r9   rw   r   r=   rE   r   r-   r   r   r   r   r   rb   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   registeredAdaptersr2   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   rT   r   c                   @   s   e Zd ZdS )z>ComponentsTests.test_registeredAdapters_notempty.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r@   rp   rq   c                   @   s   e Zd ZdS )zBComponentsTests.test_registeredAdapters_notempty.<locals>._FactoryNr:   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   rm   rZ   )rB   r9   r\   r   rC   r   r   r   r   r"   r_   r%   r&   r   r`   r   r   r@   rM   )r
   r9   r   r=   rE   r   rF   rs   rt   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   rT   c                   @   s   e Zd ZdS )z?ComponentsTests.test_queryAdapter_miss_no_default.<locals>.IFooNr:   r   r   r   r   r=     s   r=   rB   r9   r   rC   r%   queryAdapter)r
   r9   r=   rE   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   rT   c                   @   s   e Zd ZdS )z>ComponentsTests.test_queryAdapter_miss_w_default.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   r   )r
   r9   r=   rE   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   rT   r   c                   @   s   e Zd ZdS )z3ComponentsTests.test_queryAdapter_hit.<locals>.IFooNr:   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>._ContextNr:   r   r   r   r   r     s   r   )
rB   r9   r   rC   r   r   r   r%   r&   r   r
   r9   r   r=   rE   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   rT   r   r   c                   @   s   e Zd ZdS )z2ComponentsTests.test_getAdapter_miss.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   c                   @   s   e Zd ZdS )z6ComponentsTests.test_getAdapter_miss.<locals>._ContextNr:   r   r   r   r   r     s   r   )	rB   r9   r   r[   r   rC   r   rO   
getAdapter)
r
   r9   r   r   r=   rE   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| |	||}
| |
| | |
j	| d S )Nr   rT   r   c                   @   s   e Zd ZdS )z1ComponentsTests.test_getAdapter_hit.<locals>.IFooNr:   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>._ContextNr:   r   r   r   r   r   0  s   r   )
rB   r9   r   rC   r   r   r   assertIsInstanceassertIsr   r   r   r   r   test_getAdapter_hit&  s    z#ComponentsTests.test_getAdapter_hitc                    s*  ddl m} ddlm} G dd d|}G dd d|}G dd	 d	|}||G d
d dt}||G dd d|}G dd dt}G dd dt}	|  }
|
|	|f| |
||f| | |
 | }|
||}| 	||	 | 
|j| t||}|
||}| 	|| | 
|j| d S )Nr   r   r   c                   @   s   e Zd ZdS )z8ComponentsTests.test_getAdapter_hit_super.<locals>.IBaseNr:   r   r   r   r   IBase>  s   r   c                   @   s   e Zd ZdS )z;ComponentsTests.test_getAdapter_hit_super.<locals>.IDerivedNr:   r   r   r   r   IDerivedA  s   r  c                   @   s   e Zd ZdS )z7ComponentsTests.test_getAdapter_hit_super.<locals>.IFooNr:   r   r   r   r   r=   D  s   r=   c                   @   s   e Zd ZdS )z7ComponentsTests.test_getAdapter_hit_super.<locals>.BaseNr:   r   r   r   r   BaseG  s   r  c                   @   s   e Zd ZdS )z:ComponentsTests.test_getAdapter_hit_super.<locals>.DerivedNr:   r   r   r   r   DerivedK  s   r  c                   @   s   e Zd Zdd ZdS )z>ComponentsTests.test_getAdapter_hit_super.<locals>.AdapterBasec                 S   s
   || _ d S r   r   r   r   r   r   r   P  s    zGComponentsTests.test_getAdapter_hit_super.<locals>.AdapterBase.__init__Nr   r   r   r   r   AdapterBaseO  s   r  c                   @   s   e Zd Zdd ZdS )zAComponentsTests.test_getAdapter_hit_super.<locals>.AdapterDerivedc                 S   s
   || _ d S r   r   r   r   r   r   r   T  s    zJComponentsTests.test_getAdapter_hit_super.<locals>.AdapterDerived.__init__Nr   r   r   r   r   AdapterDerivedS  s   r  r   r   rB   r   rC   r   r   _should_not_changer   r   r   r   r}   r
   r   r   r   r  r=   r  r  r  r  r-   derivedr   super   r   r   test_getAdapter_hit_super:  s.    

z)ComponentsTests.test_getAdapter_hit_superc                    sL  ddl m} ddlm} G dd d|}G dd d|}G dd	 d	|}G d
d dt}G dd d|}||G dd d|}||G dd d||}	G dd dt}
G dd dt}|  }|||f| ||
|f| | | |	 }|||}| 	|| | 
|j| t|	|}|||}| 	||
 | 
|j| d S )Nr   r   r   c                   @   s   e Zd ZdS )zaComponentsTests.test_getAdapter_hit_super_when_parent_implements_interface_diamond.<locals>.IBaseNr:   r   r   r   r   r   j  s   r   c                   @   s   e Zd ZdS )zdComponentsTests.test_getAdapter_hit_super_when_parent_implements_interface_diamond.<locals>.IDerivedNr:   r   r   r   r   r  m  s   r  c                   @   s   e Zd ZdS )z`ComponentsTests.test_getAdapter_hit_super_when_parent_implements_interface_diamond.<locals>.IFooNr:   r   r   r   r   r=   p  s   r=   c                   @   s   e Zd ZdS )z`ComponentsTests.test_getAdapter_hit_super_when_parent_implements_interface_diamond.<locals>.BaseNr:   r   r   r   r   r  s  s   r  c                   @   s   e Zd ZdS )zbComponentsTests.test_getAdapter_hit_super_when_parent_implements_interface_diamond.<locals>.Child1Nr:   r   r   r   r   Child1v  s   r  c                   @   s   e Zd ZdS )zbComponentsTests.test_getAdapter_hit_super_when_parent_implements_interface_diamond.<locals>.Child2Nr:   r   r   r   r   Child2y  s   r  c                   @   s   e Zd ZdS )zcComponentsTests.test_getAdapter_hit_super_when_parent_implements_interface_diamond.<locals>.DerivedNr:   r   r   r   r   r  }  s   r  c                   @   s   e Zd Zdd ZdS )zgComponentsTests.test_getAdapter_hit_super_when_parent_implements_interface_diamond.<locals>.AdapterBasec                 S   s
   || _ d S r   r   r   r   r   r   r     s    zpComponentsTests.test_getAdapter_hit_super_when_parent_implements_interface_diamond.<locals>.AdapterBase.__init__Nr   r   r   r   r   r    s   r  c                   @   s   e Zd Zdd ZdS )zjComponentsTests.test_getAdapter_hit_super_when_parent_implements_interface_diamond.<locals>.AdapterDerivedc                 S   s
   || _ d S r   r   r   r   r   r   r     s    zsComponentsTests.test_getAdapter_hit_super_when_parent_implements_interface_diamond.<locals>.AdapterDerived.__init__Nr   r   r   r   r   r    s   r  r  )r
   r   r   r   r  r=   r  r  r  r  r  r  r-   r	  r   r
  r   r   r   Btest_getAdapter_hit_super_when_parent_implements_interface_diamondf  s2    

zRComponentsTests.test_getAdapter_hit_super_when_parent_implements_interface_diamondc                 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   rT   r   c                   @   s   e Zd ZdS )z9ComponentsTests.test_queryMultiAdapter_miss.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   IBazc                   @   s   e Zd ZdS )z>ComponentsTests.test_queryMultiAdapter_miss.<locals>._Context1Nr:   r   r   r   r   	_Context1  s   r  c                   @   s   e Zd ZdS )z>ComponentsTests.test_queryMultiAdapter_miss.<locals>._Context2Nr:   r   r   r   r   	_Context2  s   r  )rB   r9   r   rC   r   r"   queryMultiAdapterr
   r9   r   r=   rE   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   rT   r   c                   @   s   e Zd ZdS )zCComponentsTests.test_queryMultiAdapter_miss_w_default.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   r  c                   @   s   e Zd ZdS )zHComponentsTests.test_queryMultiAdapter_miss_w_default.<locals>._Context1Nr:   r   r   r   r   r    s   r  c                   @   s   e Zd ZdS )zHComponentsTests.test_queryMultiAdapter_miss_w_default.<locals>._Context2Nr:   r   r   r   r   r    s   r  r   )rB   r9   r   rC   r   r%   r  )r
   r9   r   r=   rE   r   r  r  r  r  r  r   r-   r   r   r   %test_queryMultiAdapter_miss_w_default  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   rT   r   c                   @   s   e Zd ZdS )z8ComponentsTests.test_queryMultiAdapter_hit.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   r  c                   @   s   e Zd ZdS )z=ComponentsTests.test_queryMultiAdapter_hit.<locals>._Context1Nr:   r   r   r   r   r    s   r  c                   @   s   e Zd ZdS )z=ComponentsTests.test_queryMultiAdapter_hit.<locals>._Context2Nr:   r   r   r   r   r    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     s    zEComponentsTests.test_queryMultiAdapter_hit.<locals>._Factory.__init__Nr   r   r   r   r   r     s   r   )rB   r9   r   rC   r   r   r  r%   r&   r"   r   r
   r9   r   r=   rE   r   r  r  r  r  r  r   r-   r   r   r   r   test_queryMultiAdapter_hit  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   rT   r   r   c                   @   s   e Zd ZdS )z7ComponentsTests.test_getMultiAdapter_miss.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   r  c                   @   s   e Zd ZdS )z<ComponentsTests.test_getMultiAdapter_miss.<locals>._Context1Nr:   r   r   r   r   r    s   r  c                   @   s   e Zd ZdS )z<ComponentsTests.test_getMultiAdapter_miss.<locals>._Context2Nr:   r   r   r   r   r    s   r  )	rB   r9   r   r[   r   rC   r   rO   getMultiAdapter)r
   r9   r   r   r=   rE   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   rT   r   c                   @   s   e Zd ZdS )z6ComponentsTests.test_getMultiAdapter_hit.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   r  c                   @   s   e Zd ZdS )z;ComponentsTests.test_getMultiAdapter_hit.<locals>._Context1Nr:   r   r   r   r   r    s   r  c                   @   s   e Zd ZdS )z;ComponentsTests.test_getMultiAdapter_hit.<locals>._Context2Nr:   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   )rB   r9   r   rC   r   r   r  r%   r&   r"   r   r  r   r   r   test_getMultiAdapter_hit  s$    z(ComponentsTests.test_getMultiAdapter_hitc                    s(    fdd}||_ ||j_ ||jj_ d S )Nc                     s     d d S )NzNothing should get changed)Zfail)r   r	   r   r   
no_changes  s    z6ComponentsTests._should_not_change.<locals>.no_changes)changedr'   	_v_lookup)r
   r-   r!  r   r	   r   r  	  s    z"ComponentsTests._should_not_changec                    s^  ddl m} ddlm} G dd d|}G dd d|}G dd	 d	|}||G d
d dt}||G dd d|}G dd dt}G dd d|}	|  }
|
|	||f| |
|||f| | |
 | }|
||f|}| 	||	 | 
|j| | 
|j| t||}|
||f|}| 	|| | ||	 | 
|j| | 
|j| d S )Nr   r   r   c                   @   s   e Zd ZdS )z=ComponentsTests.test_getMultiAdapter_hit_super.<locals>.IBaseNr:   r   r   r   r   r     s   r   c                   @   s   e Zd ZdS )z@ComponentsTests.test_getMultiAdapter_hit_super.<locals>.IDerivedNr:   r   r   r   r   r    s   r  c                   @   s   e Zd ZdS )z<ComponentsTests.test_getMultiAdapter_hit_super.<locals>.IFooNr:   r   r   r   r   r=     s   r=   c                   @   s   e Zd ZdS )z<ComponentsTests.test_getMultiAdapter_hit_super.<locals>.BaseNr:   r   r   r   r   r     s   r  c                   @   s   e Zd ZdS )z?ComponentsTests.test_getMultiAdapter_hit_super.<locals>.DerivedNr:   r   r   r   r   r  $  s   r  c                   @   s   e Zd Zdd ZdS )zCComponentsTests.test_getMultiAdapter_hit_super.<locals>.AdapterBasec                 S   s   || _ || _d S r   r  r  r  r   r   r   r   )  s    zLComponentsTests.test_getMultiAdapter_hit_super.<locals>.AdapterBase.__init__Nr   r   r   r   r   r  (  s   r  c                   @   s   e Zd ZdS )zFComponentsTests.test_getMultiAdapter_hit_super.<locals>.AdapterDerivedNr:   r   r   r   r   r  -  s   r  )r   r   rB   r   rC   r   r   r  r  r   r   r  r  r}   ZassertNotIsInstancer  r   r   r   test_getMultiAdapter_hit_super  s4    

z.ComponentsTests.test_getMultiAdapter_hit_superc                 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   rT   r   c                   @   s   e Zd ZdS )z4ComponentsTests.test_getAdapters_empty.<locals>.IFooNr:   r   r   r   r   r=   E  s   r=   r   r  c                   @   s   e Zd ZdS )z9ComponentsTests.test_getAdapters_empty.<locals>._Context1Nr:   r   r   r   r   r  J  s   r  c                   @   s   e Zd ZdS )z9ComponentsTests.test_getAdapters_empty.<locals>._Context2Nr:   r   r   r   r   r  M  s   r  )rB   r9   r   rC   r   r"   r   getAdaptersr  r   r   r   test_getAdapters_emptyB  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   rT   r   c                   @   s   e Zd ZdS )zCComponentsTests.test_getAdapters_factory_returns_None.<locals>.IFooNr:   r   r   r   r   r=   Y  s   r=   r   r  c                   @   s   e Zd ZdS )zHComponentsTests.test_getAdapters_factory_returns_None.<locals>._Context1Nr:   r   r   r   r   r  ^  s   r  c                   @   s   e Zd ZdS )zHComponentsTests.test_getAdapters_factory_returns_None.<locals>._Context2Nr:   r   r   r   r   r  a  s   r  c                    s     | |f d S r   r   r$  Z_called_withr   r   _side_effect_onlyh  s    zPComponentsTests.test_getAdapters_factory_returns_None.<locals>._side_effect_only)	rB   r9   r   rC   r   r   r"   r   r&  )r
   r9   r   r=   rE   r   r  r  r  r  r  r-   r)  r   r(  r   %test_getAdapters_factory_returns_NoneV  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   rT   r   c                   @   s   e Zd ZdS )z8ComponentsTests.test_getAdapters_non_empty.<locals>.IFooNr:   r   r   r   r   r=   t  s   r=   r   r  c                   @   s   e Zd ZdS )z=ComponentsTests.test_getAdapters_non_empty.<locals>._Context1Nr:   r   r   r   r   r  y  s   r  c                   @   s   e Zd ZdS )z=ComponentsTests.test_getAdapters_non_empty.<locals>._Context2Nr:   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,  rp   rq   r   rm   rZ   )rB   r9   r   rC   r   r   r   r&  r"   r_   r%   r&   )r
   r9   r   r=   rE   r   r  r  r  r  r  r+  r,  rs   rt   r-   foundr   r   r   test_getAdapters_non_emptyp  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   rT   c                   @   s   e Zd ZdS )zNComponentsTests.test_registerSubscriptionAdapter_w_nonblank_name.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   r   r@   c                 S   s
   t  d S r   rH   r   r   r   r   rJ     s    zRComponentsTests.test_registerSubscriptionAdapter_w_nonblank_name.<locals>._factory)rB   r9   r   rO   rP   registerSubscriptionAdapter)	r
   r9   r=   rE   r   ra   rF   rJ   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   rT   rU   SubscriptionRegistrationc                   @   s   e Zd ZdS )z_ComponentsTests.test_registerSubscriptionAdapter_w_explicit_provided_and_required.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   rY   r@   c                 S   s
   t  d S r   rH   r   r   r   r   rJ     s    zcComponentsTests.test_registerSubscriptionAdapter_w_explicit_provided_and_required.<locals>._factoryrA   rZ   )rB   r9   r[   rV   r\   r2  r   r   r/  r'   r^   r"   r_   r%   r+   r&   rC   r   r`   r   r   r@   rM   )r
   r9   rV   r2  r=   rE   r   _blankrF   rJ   r-   r   r   r   r   r   rb   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   rT   r   rU   r1  c                   @   s   e Zd ZdS )zSComponentsTests.test_registerSubscriptionAdapter_wo_explicit_provided.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   r@   rY   c                   @   s   e Zd ZdS )zWComponentsTests.test_registerSubscriptionAdapter_wo_explicit_provided.<locals>._FactoryNr:   r   r   r   r   r     s   r   rA   rZ   )rB   r9   r   r[   rV   r\   r2  rC   r   r   r/  r'   r^   r"   r_   r%   r+   r&   r   r`   r   r   r@   rM   )r
   r9   r   rV   r2  r=   rE   r   rF   r3  r   r-   r   r   r   r   r   rb   r   r   r   5test_registerSubscriptionAdapter_wo_explicit_provided  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   rT   rU   r1  c                   @   s   e Zd ZdS )zSComponentsTests.test_registerSubscriptionAdapter_wo_explicit_required.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   r@   rY   c                       s   e Zd Z fZdS )zWComponentsTests.test_registerSubscriptionAdapter_wo_explicit_required.<locals>._FactoryNr   r   r   r   r   r     s   r   )r`   r@   rZ   )rB   r9   r[   rV   r\   r2  rC   r   r   r/  r'   r^   r"   r_   r%   r+   r&   r   r`   r   r   r@   rM   )r
   r9   rV   r2  r=   rE   rF   r3  r   r-   r   r   r   r   r   rb   r   r   r   5test_registerSubscriptionAdapter_wo_explicit_required  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   rT   c                   @   s   e Zd ZdS )zGComponentsTests.test_registerSubscriptionAdapter_wo_event.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   rY   r@   c                 S   s
   t  d S r   rH   r   r   r   r   rJ     s    zKComponentsTests.test_registerSubscriptionAdapter_wo_event.<locals>._factoryFr@   rb   )rB   r9   r   r   r/  r"   r_   )r
   r9   r=   rE   r   r3  rF   rJ   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   registeredSubscriptionAdaptersr2   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   rT   r1  c                   @   s   e Zd ZdS )zJComponentsTests.test_registeredSubscriptionAdapters_notempty.<locals>.IFooNr:   r   r   r   r   r=   /  s   r=   r@   rY   c                   @   s   e Zd ZdS )zNComponentsTests.test_registeredSubscriptionAdapters_notempty.<locals>._FactoryNr:   r   r   r   r   r   5  s   r   rA   rm   rZ   )rB   r9   r\   r2  rC   r   r/  r   r9  r"   r_   r%   r&   r   r`   r   r   r@   rM   )r
   r9   r2  r=   rE   r   rF   r3  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   rT   c                   @   s   e Zd ZdS )zPComponentsTests.test_unregisterSubscriptionAdapter_w_nonblank_name.<locals>.IFooNr:   r   r   r   r   r=   O  s   r=   r   nonblank)r   r`   r   rB   r9   r   rO   rP   unregisterSubscriptionAdapter)r
   r9   r=   rE   r   	_nonblankr-   r   r   r   2test_unregisterSubscriptionAdapter_w_nonblank_nameL  s    
  zBComponentsTests.test_unregisterSubscriptionAdapter_w_nonblank_namec                 C   s    |   }| jt|jd d d d S r   )r   rO   rP   r>  r2   r   r   r   ?test_unregisterSubscriptionAdapter_neither_factory_nor_providedX  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   rT   c                   @   s   e Zd ZdS )z]ComponentsTests.test_unregisterSubscriptionAdapter_neither_factory_nor_required.<locals>.IFooNr:   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   rT   c                   @   s   e Zd ZdS )zEComponentsTests.test_unregisterSubscriptionAdapter_miss.<locals>.IFooNr:   r   r   r   r   r=   h  s   r=   r   c                   @   s   e Zd ZdS )zIComponentsTests.test_unregisterSubscriptionAdapter_miss.<locals>._FactoryNr:   r   r   r   r   r   l  s   r   )rB   r9   rC   r   r   r>  r   r   r   r   r   'test_unregisterSubscriptionAdapter_missf  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   rT   rv   r1  c                   @   s   e Zd ZdS )zOComponentsTests.test_unregisterSubscriptionAdapter_hit_wo_factory.<locals>.IFooNr:   r   r   r   r   r=   z  s   r=   r   c                   @   s   e Zd ZdS )zSComponentsTests.test_unregisterSubscriptionAdapter_hit_wo_factory.<locals>._FactoryNr:   r   r   r   r   r   ~  s   r   rZ   rY   rB   r9   r[   rw   r\   r2  rC   r   r/  r   r>  r%   r   r'   r^   r+   r"   r_   r&   r   r`   r   r   r@   rM   r
   r9   rw   r2  r=   rE   r   r   r-   r   r   r   r   r   rb   r   r   r   1test_unregisterSubscriptionAdapter_hit_wo_factoryv  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   rT   rv   r1  c                   @   s   e Zd ZdS )zNComponentsTests.test_unregisterSubscriptionAdapter_hit_w_factory.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   c                   @   s   e Zd ZdS )zRComponentsTests.test_unregisterSubscriptionAdapter_hit_w_factory.<locals>._FactoryNr:   r   r   r   r   r     s   r   rZ   rY   rD  rE  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   rT   r   rv   r1  c                   @   s   e Zd ZdS )zUComponentsTests.test_unregisterSubscriptionAdapter_wo_explicit_provided.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   c                   @   s   e Zd ZdS )zYComponentsTests.test_unregisterSubscriptionAdapter_wo_explicit_provided.<locals>._FactoryNr:   r   r   r   r   r     s   r   rZ   rY   )rB   r9   r   r[   rw   r\   r2  rC   r   r/  r   r>  r%   r"   r_   r&   r   r`   r   r   r@   rM   )r
   r9   r   rw   r2  r=   rE   r   r   r-   r   r   r   r   r   rb   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   rT   rv   r1  c                   @   s   e Zd ZdS )zUComponentsTests.test_unregisterSubscriptionAdapter_wo_explicit_required.<locals>.IFooNr:   r   r   r   r   r=     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     s   r   r   rZ   rY   )rB   r9   r[   rw   r\   r2  rC   r   r/  r   r>  r%   r"   r_   r&   r   r`   r   r   r@   rM   )r
   r9   rw   r2  r=   rE   r   r-   r   r   r   r   r   rb   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   rT   r   c                   @   s   e Zd ZdS )z4ComponentsTests.test_subscribers_empty.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   c                   @   s   e Zd ZdS )z3ComponentsTests.test_subscribers_empty.<locals>.BarNr:   r   r   r   r   Bar  s   rJ  )rB   r9   r   r   rC   r"   r   subscribers)	r
   r9   r   r=   rE   r   r-   rJ  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   rT   r   c                   @   s   e Zd ZdS )z8ComponentsTests.test_subscribers_non_empty.<locals>.IFooNr:   r   r   r   r   r=     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     s    zEComponentsTests.test_subscribers_non_empty.<locals>._Factory.__init__N)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>._DerivedNr:   r   r   r   r   _Derived  s   rN  c                   @   s   e Zd ZdS )z7ComponentsTests.test_subscribers_non_empty.<locals>.BarNr:   r   r   r   r   rJ    s   rJ  c                 S   s   | j jS r   )r   r#   xr   r   r   
_klassname  s    z>ComponentsTests.test_subscribers_non_empty.<locals>._klassnamer   rm   rZ   )rB   r9   r   rC   r   r/  rK  r   r"   r_   r%   r&   )r
   r9   r   r=   rE   r   rN  r-   rJ  rL  rK  rQ  r   r   r   test_subscribers_non_empty  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   rT   c                   @   s   e Zd ZdS )zBComponentsTests.test_registerHandler_w_nonblank_name.<locals>.IFooNr:   r   r   r   r   r=   !  s   r=   r<  c                 S   s
   t  d S r   rH   r   r   r   r   rJ   &  s    zFComponentsTests.test_registerHandler_w_nonblank_name.<locals>._factoryr   r   )rB   r9   r   rO   rP   registerHandler)r
   r9   r=   rE   r?  r-   rJ   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   rT   rU   HandlerRegistrationc                   @   s   e Zd ZdS )zFComponentsTests.test_registerHandler_w_explicit_required.<locals>.IFooNr:   r   r   r   r   r=   1  s   r=   rY   r@   c                 S   s
   t  d S r   rH   r   r   r   r   rJ   6  s    zJComponentsTests.test_registerHandler_w_explicit_required.<locals>._factoryrA   rZ   )rB   r9   r[   rV   r\   rW  r   r   rT  r'   r^   r"   r_   r%   r,   r&   rC   r   r   r   r@   rM   )r
   r9   rV   rW  r=   rE   r3  rF   rJ   r-   r   r   r   r   r   rb   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   rT   c                   @   s   e Zd ZdS )zPComponentsTests.test_registerHandler_wo_explicit_required_no_event.<locals>.IFooNr:   r   r   r   r   r=   Q  s   r=   r@   rY   c                       s   e Zd Z fZdS )zTComponentsTests.test_registerHandler_wo_explicit_required_no_event.<locals>._FactoryNr   r   rE   r   r   r   V  s   r   Fr7  rZ   )rB   r9   rC   r   r   rT  r'   r^   r"   r_   r%   r,   )
r
   r9   r=   rF   r3  r   r-   r   r   r   r   rY  r   2test_registerHandler_wo_explicit_required_no_eventN  s"    zBComponentsTests.test_registerHandler_wo_explicit_required_no_eventc                 C   s   |   }| t|  d S r   )r   r   r   registeredHandlersr2   r   r   r   test_registeredHandlers_emptye  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   rT   rV  c                   @   s   e Zd ZdS )z?ComponentsTests.test_registeredHandlers_non_empty.<locals>.IFooNr:   r   r   r   r   r=   l  s   r=   c                 S   s
   t  d S r   rH   r   r   r   r   	_factory1o  s    zDComponentsTests.test_registeredHandlers_non_empty.<locals>._factory1c                 S   s
   t  d S r   rH   r   r   r   r   	_factory2q  s    zDComponentsTests.test_registeredHandlers_non_empty.<locals>._factory2c                 S   s
   | j jjS r   )rM   __code__co_namerO  r   r   r   _factory_namev  s    zHComponentsTests.test_registeredHandlers_non_empty.<locals>._factory_namer   rm   rY   rZ   )rB   r9   r\   rW  r   rT  r   r[  r"   r_   r%   r&   r   r   rM   r@   )
r
   r9   rW  r=   rE   r]  r^  r-   ra  rK  r   r   r   !test_registeredHandlers_non_emptyi  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   rT   c                   @   s   e Zd ZdS )zDComponentsTests.test_unregisterHandler_w_nonblank_name.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r<  rS  )rB   r9   r   rO   rP   unregisterHandler)r
   r9   r=   rE   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   rO   rP   rc  r2   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   rT   c                   @   s   e Zd ZdS )z9ComponentsTests.test_unregisterHandler_miss.<locals>.IFooNr:   r   r   r   r   r=     s   r=   r   )rB   r9   r   rc  r   )r
   r9   r=   rE   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   rT   rv   rV  c                   @   s   e Zd ZdS )zXComponentsTests.test_unregisterHandler_hit_w_factory_and_explicit_provided.<locals>.IFooNr:   r   r   r   r   r=     s   r=   c                 S   s
   t  d S r   rH   r   r   r   r   rJ     s    z\ComponentsTests.test_unregisterHandler_hit_w_factory_and_explicit_provided.<locals>._factoryrZ   rY   rB   r9   r[   rw   r\   rW  r   rT  r   rc  r%   r"   r_   r&   rC   r   r   r   rM   r
   r9   rw   rW  r=   rE   r-   rJ   r   r   r   r   r   rb   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   rT   rv   rV  c                   @   s   e Zd ZdS )zQComponentsTests.test_unregisterHandler_hit_w_only_explicit_provided.<locals>.IFooNr:   r   r   r   r   r=     s   r=   c                 S   s
   t  d S r   rH   r   r   r   r   rJ     s    zUComponentsTests.test_unregisterHandler_hit_w_only_explicit_provided.<locals>._factoryrf  rZ   rY   rh  ri  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   rT   rv   rV  c                   @   s   e Zd ZdS )zIComponentsTests.test_unregisterHandler_wo_explicit_required.<locals>.IFooNr:   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   rY  r   r   r     s   r   rZ   rY   )rB   r9   r[   rw   r\   rW  rC   r   rT  r   rc  r%   r"   r_   r&   r   r   r   r@   rM   )r
   r9   rw   rW  r=   r   r-   r   r   r   r   r   rb   r   rY  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   rT   r   c                   @   s   e Zd ZdS )z/ComponentsTests.test_handle_empty.<locals>.IFooNr:   r   r   r   r   r=     s   r=   c                   @   s   e Zd ZdS )z.ComponentsTests.test_handle_empty.<locals>.BarNr:   r   r   r   r   rJ    s   rJ  )rB   r9   r   r   rC   handle)r
   r9   r   r=   rE   r-   rJ  rL  r   r   r   test_handle_empty  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   rT   r   c                   @   s   e Zd ZdS )z3ComponentsTests.test_handle_non_empty.<locals>.IFooNr:   r   r   r   r   r=     s   r=   c                    s     |  d S r   r   r   )	_called_1r   r   
_factory_1	  s    z9ComponentsTests.test_handle_non_empty.<locals>._factory_1c                    s     |  d S r   r   r   )	_called_2r   r   
_factory_2	  s    z9ComponentsTests.test_handle_non_empty.<locals>._factory_2c                   @   s   e Zd ZdS )z2ComponentsTests.test_handle_non_empty.<locals>.BarNr:   r   r   r   r   rJ  	  s   rJ  )rB   r9   r   r   rT  rC   rm  r"   )
r
   r9   r   r=   rE   rp  rr  r-   rJ  rL  r   )ro  rq  r   test_handle_non_empty  s"    
z%ComponentsTests.test_handle_non_emptyTc                 C   s   G dd dt }|  }t }|r&|nt }|j||d |j||dd | t|jjd | |jj|d|rv|fn||fiig | |jj||rdnd	i |j	||d}| 
| |j	||dd}| 
| | |jji  | t|jjd
 d S )Nc                   @   s   e Zd ZdS )zQComponentsTests.test_register_unregister_identical_objects_provided.<locals>.IFooNr:   r   r   r   r   r=   	  s   r=   r   rL  r   rZ   rY   r      r   )r   r   rC   rD   r"   r_   r(   r^   Z	_providedr   r%   )r
   	identicalr=   r-   firstsecondresr   r   r   3test_register_unregister_identical_objects_provided	  s*    
 
 


zCComponentsTests.test_register_unregister_identical_objects_providedc                 C   s   | j dd d S )NF)ru  )ry  r	   r   r   r   2test_register_unregister_nonequal_objects_provided/	  s    zBComponentsTests.test_register_unregister_nonequal_objects_providedc                 C   s  G dd dt }G dd dt}|  }tdD ]}|j| |d|f d q0|jj}|jj}| t	|d | t	|d	 d | t	|d	 | d |jj
}| t	|d | t	|d	 d | t	|d	 | d | t	|d	 | d
 d t|  }|j_|i  i  }	|d	 |< tdD ]*}
td
t|
}
|d	 | |
 |	|
< q.| || t|  }|j_
|i  i  }	|d	 |< d|	d
< tddD ]8}
td
t|
}
|d	 | |
 }|	d
  |f7  < q| }| |jj| | |ddddd |jdd}| |jj|d  | || | || | t	|d	 | d
 t	|d	 | d
  |d	 | d
 D ]}| ||d	 | d
  q| }| |dd	dd	d |jdd}| || | |jj|d  d S )Nc                   @   s   e Zd ZdZdS )zGComponentsTests.test_rebuildUtilityRegistryFromLocalCache.<locals>.IFooDoes nothingNr#   r;   r<   __doc__r   r   r   r   r=   3	  s   r=   c                   @   s   e Zd ZdZdS )zYComponentsTests.test_rebuildUtilityRegistryFromLocalCache.<locals>.UtilityImplementingFoor{  Nr|  r   r   r   r   UtilityImplementingFoo6	  s   r~     z%sr   rZ   r   rY   
   r                  )Zdid_not_registerZneeded_registeredZdid_not_subscribeZneeded_subscribedT)Zrebuild)r   rC   r   rangerD   r(   Z_generationr]   r"   r_   r^   typer   strZassertNotEqualZ$rebuildUtilityRegistryFromLocalCacheassertIn)r
   r=   r~  compsiZorig_generationZorig_adaptersZorig_subscribersZnew_adaptersdr   Znew_subscribersr-   Zrebuild_results_preflightZrebuild_resultsZorig_subscriberZpreflight_afterZrebuild_afterr   r   r   )test_rebuildUtilityRegistryFromLocalCache2	  st    

	z9ComponentsTests.test_rebuildUtilityRegistryFromLocalCache)r   )T)vr#   r;   r<   r   r   r   r.   r0   r3   r6   rG   rS   rc   rf   rg   rj   rl   ro   ru   rx   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.  r0  r4  r5  r6  r8  r:  r;  r@  rA  rB  rC  rF  rG  rH  rI  rM  rR  rU  rX  rZ  r\  rb  rd  re  rg  rj  rk  rl  rn  rs  ry  rz  r  r   r   r   r   r   r      s   
  )"#	
	
#'#*$	  "	,2
/#$'%!	   "	
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>.ComponentsNr:   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   rW   )r\   rX   )r
   rX   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   rT   c                   @   s   e Zd ZdS )zAUtilityRegistrationTests._makeOne.<locals>.InterfaceClassSubclassNr:   r   r   r   r   InterfaceClassSubclass	  s   r  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   r  r   	DOCSTRINGrB   r9   rC   r   )r
   rL   rM   r9   r  rE   r  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.verifyr  r[   r  r   )r
   r  r  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   verifyObjectr  )r  r  r[   r  r   )r
   r  r  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TESTNr:   r   r   r   r   
_Component	  s   r  zAUtilityRegistration(_REGISTRY, IFoo, %r, TEST, None, 'DOCSTRING')rC   r   r"   r1   r
   r  
_componentr  	_registryra   r   r   r   r3   	  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 Nr  r   r	   r   r   r   r  	  s    zTUtilityRegistrationTests.test___repr___provided_wo_name.<locals>._Component.__repr__Nr  r   r   r   r   r  	  s   r  AUtilityRegistration(_REGISTRY, None, %r, TEST, None, 'DOCSTRING')rC   r   r`   r"   r1   r  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 r  r   r	   r   r   r   r  	  s    zUUtilityRegistrationTests.test___repr___component_wo_name.<locals>._Component.__repr__Nr  r   r   r   r   r  	  s   r  r  r  r  r   r   r   test___repr___component_wo_name	  s    
z8UtilityRegistrationTests.test___repr___component_wo_namec                 C   s.   t  }| |\}}}| | t| d S r   rC   r   r"   __hash__idr
   r  r  r  ra   r   r   r   test___hash__	  s    z&UtilityRegistrationTests.test___hash__c                 C   s(   t  }| |\}}}| ||k d S r   rC   r   r%   r  r   r   r   test___eq___identity	  s    z-UtilityRegistrationTests.test___eq___identityc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r
   r  r  r  ra   ur2r  r   r   r   test___eq___hit	  s    z(UtilityRegistrationTests.test___eq___hitc                 C   s>   t  }t  }| |\}}}| |\}}}| ||k d S r   rC   r   r   r
   r  _component2r  r  ra   r  r  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rC   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___miss5
  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  rC   r   r   r   r  r   r   r   test___ge___miss@
  s    
z)UtilityRegistrationTests.test___ge___missc                 C   sB   t  }| |\}}}| |\}}}|d |_| ||k d S r  r  r  r   r   r   test___ge___hitH
  s
    
z(UtilityRegistrationTests.test___ge___hit)NN)r#   r;   r<   r   r   r  r  r3   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  	  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   R
  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   rT   c                   @   s   e Zd ZdS )z/AdapterRegistrationTests._makeOne.<locals>.IFooNr:   r   r   r   r   r=   Y
  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  ^
  s    z=AdapterRegistrationTests._makeOne.<locals>._Registry.__repr__Nr  r   r   r   r   r  ]
  s   r  r   r  r  r
   rL   r9   r=   rE   r   r  r   r   r  r  r   r   r   r   V
  s    z!AdapterRegistrationTests._makeOnec                 C   s*   ddl m} ddlm} |||   d S )Nr   r  IAdapterRegistration)r  r  r[   r  r   )r
   r  r  r   r   r   +test_class_conforms_to_IAdapterRegistrationi
  s    zDAdapterRegistrationTests.test_class_conforms_to_IAdapterRegistrationc                 C   s4   ddl m} ddlm} |  \}}}||| d S )Nr   r  r  )r  r  r[   r  r   )r
   r  r  arr  r   r   r   .test_instance_conforms_to_IAdapterRegistrationn
  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>._Componentr  Nr:   r   r   r   r   r  u
  s   r  zCAdapterRegistration(_REGISTRY, [IBar], IFoo, %r, TEST, 'DOCSTRING')r  r
   r  r  r  r  ra   r   r   r   r3   t
  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 r  r   r	   r   r   r   r  
  s    zTAdapterRegistrationTests.test___repr___provided_wo_name.<locals>._Component.__repr__Nr  r   r   r   r   r  ~
  s   r  CAdapterRegistration(_REGISTRY, [IBar], None, %r, TEST, 'DOCSTRING')r  r  r   r   r   r  }
  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 r  r   r	   r   r   r   r  
  s    zUAdapterRegistrationTests.test___repr___component_wo_name.<locals>._Component.__repr__Nr  r   r   r   r   r  
  s   r  r  r  r  r   r   r   r  
  s    
z8AdapterRegistrationTests.test___repr___component_wo_namec                 C   s.   t  }| |\}}}| | t| d S r   r  r
   r  r  r  ra   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
   r  r  r  ra   ar2r  r   r   r   r  
  s    z(AdapterRegistrationTests.test___eq___hitc                 C   s>   t  }t  }| |\}}}| |\}}}| ||k d S r   r  r
   r  r  r  r  ra   r  r  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   rT   c                   @   s   e Zd ZdS )z?AdapterRegistrationTests.test___ne___hit_provided.<locals>.IFooNr:   r   r   r   r   r=   
  s   r=   r  )rB   r9   rC   r   r`   r%   )
r
   r9   r=   r  r  r  r  ra   r  r  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   rT   c                   @   s   e Zd ZdS )z?AdapterRegistrationTests.test___ne___hit_required.<locals>.IFooNr:   r   r   r   r   r=   
  s   r=   r  )rB   r9   rC   r   r   r%   )r
   r9   r=   r  r  r  r  r  ra   r  r  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  r3   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  P
  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   r1  )r\   r2  )r
   r2  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   rT   c                   @   s   e Zd ZdS )z4SubscriptionRegistrationTests._makeOne.<locals>.IFooNr:   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   r  .  s   r  r   r  r  r  r   r   r   r   '  s    z&SubscriptionRegistrationTests._makeOnec                 C   s*   ddl m} ddlm} |||   d S )Nr   r   ISubscriptionAdapterRegistration)r  r  r[   r  r   )r
   r  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   r  r  )r  r  r[   r  r   )r
   r  r  Zsarr  r   r   r   :test_instance_conforms_to_ISubscriptionAdapterRegistration?  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   rV  )r\   rW  )r
   rW  r   r   r   r   H  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   rT   c                   @   s   e Zd ZdS )z/HandlerRegistrationTests._makeOne.<locals>.IFooNr:   r   r   r   r   r=   O  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  S  s    z=HandlerRegistrationTests._makeOne.<locals>._Registry.__repr__Nr  r   r   r   r   r  R  s   r  r   r  r  )
r
   rL   r9   r=   rE   r  r   r   r  r  r   r   r   r   L  s    z!HandlerRegistrationTests._makeOnec                 C   s*   ddl m} ddlm} |||   d S )Nr   r  IHandlerRegistration)r  r  r[   r  r   )r
   r  r  r   r   r   +test_class_conforms_to_IHandlerRegistration^  s    zDHandlerRegistrationTests.test_class_conforms_to_IHandlerRegistrationc                 C   s4   ddl m} ddlm} |  \}}}||| d S )Nr   r  r  )r  r  r[   r  r   )r
   r  r  hrr  r   r   r   .test_instance_conforms_to_IHandlerRegistrationc  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   rH   r   r   r   r   rJ   j  s    z:HandlerRegistrationTests.test_properties.<locals>._factory)r   r%   handlerrM   r`   )r
   rJ   r  r  r   r   r   test_propertiesi  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>._Factoryr  Nr:   r   r   r   r   r   r  s   r   =HandlerRegistration(_REGISTRY, [IFoo], %r, TEST, 'DOCSTRING')r  r
   r   r  r  ra   r   r   r   test___repr___factory_w_nameq  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 r  r   r	   r   r   r   r  {  s    zQHandlerRegistrationTests.test___repr___factory_wo_name.<locals>._Factory.__repr__Nr  r   r   r   r   r   z  s   r   r  r  r  r   r   r   test___repr___factory_wo_namey  s    
z6HandlerRegistrationTests.test___repr___factory_wo_name)N)
r#   r;   r<   r   r   r  r  r  r  r  r   r   r   r   r  F  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 )N_vro)__dict__copyr   Z
_delegated
startswithpop)r
   statekr   r   r   __getstate__  s    
z&PersistentAdapterRegistry.__getstate__c                 C   s6   | dd}| j| |   || _| j|  d S )Nr$   r   )r  r  updateZ_createLookupr$   r#  r"  )r
   r  basesr   r   r   __setstate__  s
    z&PersistentAdapterRegistry.__setstate__N)r#   r;   r<   r  r  r   r   r   r   r    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 )PersistentDictComponentsNr:   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   rC   rD   r   r   r   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   r2   r   r   r   r     s    z%TestPersistentDictComponents._makeOnec                 C   s    |  d| | |d d d S )Nr   r  )r  r"   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_typeexc_valexc_tbr   r  r   r   r   __exit__  s    z_Monkey.__exit__N)r#   r;   r<   r   r  r  r   r   r   r   r     s   r   )r}  Zunittestr   r   r!   r   r\   r   ZTestCaser   r  r  r  r  r  r  r  r~   r   r  r  r  r  rC   r   r   r   r   r   <module>   sN                       ; R%<+