a
    _                    @   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߄ Zq  ZrS )ComponentsTestsc                 C   s   t S Nr   self r   D/usr/lib/python3/dist-packages/zope/interface/tests/test_registry.py_getTargetClass   s    zComponentsTests._getTargetClasstestc                 O   s   |   |g|R i |S r   r   )r
   nameargskwr   r   r   _makeOne   s    zComponentsTests._makeOnec                    s0   ddl m} g   fdd}t||d}| fS )Nr   )registryc                     s     | |f d S r   append)r   r   _eventsr   r   _notify"   s    z,ComponentsTests._wrapEvents.<locals>._notify)Znotify)zope.interfacer   _Monkey)r
   r   r   _monkeyr   r   r   _wrapEvents   s
    zComponentsTests._wrapEventsc                 C   s   ddl m} | d}| |jd | |jd | t|j| | t|j	| | |jjd | |j	jd | |j
i  | |ji  | |jg  | |jg  d S )Nr   )AdapterRegistrytestingr   )zope.interface.adapterr   r   assertEqual__name__	__bases__
assertTrue
isinstanceadapters	utilities_utility_registrations_adapter_registrations_subscription_registrations_handler_registrations)r
   r   compr   r   r   test_ctor_no_bases'   s    
z"ComponentsTests.test_ctor_no_basesc                 C   sb   |  d}|  d|f}| |jd | |j|f | |jj|jf | |jj|jf d S )Nbaser   )r   r!   r"   r#   r&   r'   )r
   r.   r,   r   r   r   test_ctor_w_base5   s    
z ComponentsTests.test_ctor_w_basec                 C   s   |  d}| t|d d S )Nr   z<Components testing>)r   r!   reprr
   r,   r   r   r   test___repr__=   s    
zComponentsTests.test___repr__c                 C   sl   |  d}|  d}|   }||f|_| |j||f | |jj|j|jf | |jj|j|jf d S )Nbase1base2)r   r#   r!   r&   r'   )r
   r3   r4   r,   r   r   r   test_assign_to___bases__C   s    






z(ComponentsTests.test_assign_to___bases__c           	      C   s   ddl m}m} G dd d|}|d}|dG dd dt}| }d}|  }|j|||d	 | |j|df ||d f d S )
Nr   namedInterfaceClassc                   @   s   e Zd ZdS )zFComponentsTests.test_registerUtility_with_component_name.<locals>.IFooNr"   
__module____qualname__r   r   r   r   IFooR   s   r<   fooc                   @   s   e Zd ZdS )zEComponentsTests.test_registerUtility_with_component_name.<locals>.FooNr9   r   r   r   r   FooV   s   r>   infor?   )zope.interface.declarationsr7   r8   objectr   registerUtilityr!   r(   )	r
   r7   r8   r<   ifoor>   r=   _infor,   r   r   r   (test_registerUtility_with_component_nameN   s    z8ComponentsTests.test_registerUtility_with_component_namec                 C   s.   dd }t  }|  }| jt|j||d d S )Nc                   S   s
   t  d S r   NotImplementedErrorr   r   r   r   _factoryc   s    zQComponentsTests.test_registerUtility_both_factory_and_component.<locals>._factory	componentfactoryrB   r   assertRaises	TypeErrorrC   r
   rI   _to_regr,   r   r   r   /test_registerUtility_both_factory_and_componentb   s    
z?ComponentsTests.test_registerUtility_both_factory_and_componentc                 C   s  ddl m} ddlm} ddlm} G dd d|}|d}d}d}t }|  }	|  \}
}|
  |		|||| W d    n1 s0    Y  | 
|	jjd | | |u  | |	j||f ||d f | |	jjd | d	 |f | t|d
 |d \}}|\}| |i  | 
t|| | 
t|j| | 
|jj|	u  | 
|jj|u  | 
|jj|u  | 
|jj|u  | 
|jj|u  | 
|jjd u  d S )Nr   r8   
RegisteredUtilityRegistrationc                   @   s   e Zd ZdS )z>ComponentsTests.test_registerUtility_w_component.<locals>.IFooNr9   r   r   r   r   r<   o   s   r<   r?   r       )rA   r8   zope.interface.interfacesrU   zope.interface.registryrW   rB   r   r   rC   r$   r'   	_adaptersr!   r(   _subscriberslenr%   r   providedr   rK   r?   rL   )r
   r8   rU   rW   r<   rD   rE   _namerQ   r,   r   r   r   r   eventr   r   r    test_registerUtility_w_componentj   s:    .z0ComponentsTests.test_registerUtility_w_componentc                    sb  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 d    n1 s0    Y  | 
t|d |d \}}|\}| 
|i  | t|| | t|j| | |jj|	u  | |jj|u  | |jj|u  | |jj u  | |jj|u  | |jj|u  d S )Nr   rS   rT   rV   c                   @   s   e Zd ZdS )z<ComponentsTests.test_registerUtility_w_factory.<locals>.IFooNr9   r   r   r   r   r<      s   r<   r?   r   c                      s    S r   r   r   rQ   r   r   rI      s    z@ComponentsTests.test_registerUtility_w_factory.<locals>._factoryrL   rY   )rA   r8   rZ   rU   r[   rW   rB   r   r   rC   r!   r^   r$   r%   r   r_   r   rK   r?   rL   )r
   r8   rU   rW   r<   rD   rE   r`   rI   r,   r   r   r   r   ra   r   rc   r   test_registerUtility_w_factory   s2    2z.ComponentsTests.test_registerUtility_w_factoryc                 C   s@   G dd dt }d}d}| }|  }| t|j|d || d S )Nc                   @   s   e Zd ZdS )zGComponentsTests.test_registerUtility_no_provided_available.<locals>.FooNr9   r   r   r   r   r>      s   r>   r?   r   rM   )r
   r>   rE   r`   rQ   r,   r   r   r   *test_registerUtility_no_provided_available   s    z:ComponentsTests.test_registerUtility_no_provided_availablec                 C   sx  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 d    n1 s0    Y  | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|u  | |jj|u  | |jj|	u  | |jj|
u  | |jj|u  | |jjd u  d S )Nr   directlyProvidesrS   rT   rV   c                   @   s   e Zd ZdS )z>ComponentsTests.test_registerUtility_wo_provided.<locals>.IFooNr9   r   r   r   r   r<      s   r<   c                   @   s   e Zd ZdS )z=ComponentsTests.test_registerUtility_wo_provided.<locals>.FooNr9   r   r   r   r   r>      s   r>   r?   r   rY   )rA   rh   r8   rZ   rU   r[   rW   rB   r   r   rC   r!   r^   r$   r%   r   r_   r   rK   r?   rL   )r
   rh   r8   rU   rW   r<   r>   rD   rE   r`   rQ   r,   r   r   r   r   ra   r   r   r    test_registerUtility_wo_provided   s6    
.z0ComponentsTests.test_registerUtility_wo_providedc           
      C   s   ddl m} G dd d|}|d}d}d}t }|  }||||| |  \}}	|  ||||| W d    n1 s0    Y  | t|	d d S )Nr   rS   c                   @   s   e Zd ZdS )zJComponentsTests.test_registerUtility_duplicates_existing_reg.<locals>.IFooNr9   r   r   r   r   r<      s   r<   r?   r   )rA   r8   rB   r   rC   r   r!   r^   
r
   r8   r<   rD   rE   r`   rQ   r,   r   r   r   r   r   ,test_registerUtility_duplicates_existing_reg   s    .z<ComponentsTests.test_registerUtility_duplicates_existing_regc                 C   s   ddl m} G dd d|}|d}d}d}d}t }|  }||||| |  \}	}
|	  ||||| W d    n1 s0    Y  | t|
d | |j||f ||d f | |j	j
d | d	 |f d S )
Nr   rS   c                   @   s   e Zd ZdS )zCComponentsTests.test_registerUtility_w_different_info.<locals>.IFooNr9   r   r   r   r   r<      s   r<   Zinfo1Zinfo2r      rX   rA   r8   rB   r   rC   r   r!   r^   r(   r'   r]   )r
   r8   r<   rD   Z_info1Z_info2r`   rQ   r,   r   r   r   r   r   %test_registerUtility_w_different_info   s&    .z5ComponentsTests.test_registerUtility_w_different_infoc                 C   s   ddl m} G dd d|}|d}d}d}d}t }t }|  }	|	|||| |  \}
}|
  |	|||| W d    n1 s0    Y  | t|d | |	j||f ||d f | |	j||f ||d f | |	j	j
d | d	 ||f d S )
Nr   rS   c                   @   s   e Zd ZdS )zSComponentsTests.test_registerUtility_w_different_names_same_component.<locals>.IFooNr9   r   r   r   r   r<      s   r<   r?   name1name2rY   rX   rm   r
   r8   r<   rD   rE   _name1_name2Z
_other_regrQ   r,   r   r   r   r   r   5test_registerUtility_w_different_names_same_component   s.    .zEComponentsTests.test_registerUtility_w_different_names_same_componentc                 C   s"  ddl m} ddlm} ddlm} ddlm} G dd d|}|d}d}d	}t t  }	}
|  }|	|	||| | 
 \}}|  |	|
||| W d    n1 s0    Y  | t|d
 |d \}}|\}| |i  | t|| | t|j| | |jj|u  | |jj|u  | |jj|u  | |jj|	u  | |jj|u  | |jjd u  |d \}}|\}| |i  | t|| | t|j| | |jj|u  | |jj|u  | |jj|u  | |jj|
u  | |jj|u  | |jjd u  d S )Nr   rS   UnregisteredrT   rV   c                   @   s   e Zd ZdS )zHComponentsTests.test_registerUtility_replaces_existing_reg.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   r   rl   rY   )rA   r8   rZ   rv   rU   r[   rW   rB   r   rC   r   r!   r^   r$   r%   r   r_   r   rK   r?   rL   )r
   r8   rv   rU   rW   r<   rD   rE   r`   Z_beforeZ_afterr,   r   r   r   r   ra   r   r   r   *test_registerUtility_replaces_existing_reg  sJ    .z:ComponentsTests.test_registerUtility_replaces_existing_regc                 C   s   ddl m} G dd d|}|d}d}d}d}t }|  }||||| |  \}	}
|	  ||||| W d    n1 s0    Y  | |jjd | d |f d S )	Nr   rS   c                   @   s   e Zd ZdS )zDComponentsTests.test_registerUtility_w_existing_subscr.<locals>.IFooNr9   r   r   r   r   r<   <  s   r<   r?   ro   rp   rX   )	rA   r8   rB   r   rC   r   r!   r'   r]   r
   r8   r<   rD   rE   rr   rs   rQ   r,   r   r   r   r   r   &test_registerUtility_w_existing_subscr9  s    .z6ComponentsTests.test_registerUtility_w_existing_subscrc           
      C   s   ddl m} G dd d|}|d}d}d}t }|  }|  \}}	|" |||||d W d    n1 sr0    Y  | t|	d d S )Nr   rS   c                   @   s   e Zd ZdS )z;ComponentsTests.test_registerUtility_wo_event.<locals>.IFooNr9   r   r   r   r   r<   M  s   r<   r?   r   F)rA   r8   rB   r   r   rC   r!   r^   rj   r   r   r   test_registerUtility_wo_eventJ  s    0z-ComponentsTests.test_registerUtility_wo_eventc                    s~   G  fddd|      }|t t | tt| d G dd dt}|t | | tt| d d S )Nc                       s"   e Zd ZdZ fddZ  ZS )zdComponentsTests.test_registerUtility_changes_object_identity_after.<locals>.CompThatChangesAfter1Regr   c                    s8   |  j d7  _ t | j|  | j dkr4t| j| _d S )NrY   )	reg_countsuperrC   dictr(   r
   r   )CompThatChangesAfter1Reg	__class__r   r   rC   ^  s    
ztComponentsTests.test_registerUtility_changes_object_identity_after.<locals>.CompThatChangesAfter1Reg.registerUtilityr"   r:   r;   r{   rC   __classcell__r   r   r   r   r   \  s   r   rY   c                   @   s   e Zd ZdS )zPComponentsTests.test_registerUtility_changes_object_identity_after.<locals>.IFooNr9   r   r   r   r   r<   i  s   r<   rl   r   rC   rB   r   r!   r^   listregisteredUtilities)r
   r,   r<   r   r   r   2test_registerUtility_changes_object_identity_afterY  s    zBComponentsTests.test_registerUtility_changes_object_identity_afterc                    s   G  fddd|      }|t t | tt| d G dd dt}|t | | tt| d G dd dt}|t | | tt| d	 d S )
Nc                       s"   e Zd ZdZ fddZ  ZS )zeComponentsTests.test_registerUtility_changes_object_identity_before.<locals>.CompThatChangesAfter2Regr   c                    s8   |  j d7  _ | j dkr$t| j| _t | j|  d S )NrY   rl   )r{   r}   r(   r|   rC   r~   )CompThatChangesAfter2Regr   r   r   rC   t  s    
zuComponentsTests.test_registerUtility_changes_object_identity_before.<locals>.CompThatChangesAfter2Reg.registerUtilityr   r   r   r   r   r   r  s   r   rY   c                   @   s   e Zd ZdS )zQComponentsTests.test_registerUtility_changes_object_identity_before.<locals>.IFooNr9   r   r   r   r   r<     s   r<   rl   c                   @   s   e Zd ZdS )zQComponentsTests.test_registerUtility_changes_object_identity_before.<locals>.IBarNr9   r   r   r   r   IBar  s   r      r   )r
   r,   r<   r   r   r   r   3test_registerUtility_changes_object_identity_beforeo  s    	zCComponentsTests.test_registerUtility_changes_object_identity_beforec                 C   s"   |   }| jt|jd d d d d S )N)rK   r_   rL   )r   rN   rO   unregisterUtilityr1   r   r   r   Atest_unregisterUtility_neither_factory_nor_component_nor_provided  s    
zQComponentsTests.test_unregisterUtility_neither_factory_nor_component_nor_providedc                 C   s.   dd }t  }|  }| jt|j||d d S )Nc                   S   s
   t  d S r   rG   r   r   r   r   rI     s    zSComponentsTests.test_unregisterUtility_both_factory_and_component.<locals>._factoryrJ   )rB   r   rN   rO   r   rP   r   r   r   1test_unregisterUtility_both_factory_and_component  s    
zAComponentsTests.test_unregisterUtility_both_factory_and_componentc           
      C   s   ddl m} G dd d|}|d}d}t }|  }|  \}}| ||||}	W d    n1 sj0    Y  | |	 | | d S )Nr   rS   c                   @   s   e Zd ZdS )zEComponentsTests.test_unregisterUtility_w_component_miss.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   )rA   r8   rB   r   r   r   assertFalse)
r
   r8   r<   rD   r`   rQ   r,   r   r   unregr   r   r   'test_unregisterUtility_w_component_miss  s    ,
z7ComponentsTests.test_unregisterUtility_w_component_missc                 C   s  ddl m} ddlm} ddlm} G dd d|}|d}d}t }|  }|||| | 	 \}	}
|	 |
|||}W d    n1 s0    Y  | | | |jj | ||f|jv  | |jj | t|
d |
d \}}|\}| |i  | t|| | t|j| | |jj|u  | |jj|u  | |jj|u  | |jj|u  | |jjd u  d S )	Nr   rS   ru   rV   c                   @   s   e Zd ZdS )z@ComponentsTests.test_unregisterUtility_w_component.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   rY   )rA   r8   rZ   rv   r[   rW   rB   r   rC   r   r   r$   r   r'   r\   r(   r]   r!   r^   r%   r   r_   r   rK   rL   )r
   r8   rv   rW   r<   rD   r`   rQ   r,   r   r   r   r   r   ra   r   r   r   "test_unregisterUtility_w_component  s6    ,
z2ComponentsTests.test_unregisterUtility_w_componentc                    sl  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 d    n1 s0    Y  | | | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|	u  | |jj|u  | |jj|u  | |jj u  | |jj|u  d S )Nr   rS   ru   rV   c                   @   s   e Zd ZdS )z>ComponentsTests.test_unregisterUtility_w_factory.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   r   c                      s    S r   r   r   rc   r   r   rI     s    zBComponentsTests.test_unregisterUtility_w_factory.<locals>._factoryrd   rY   )rA   r8   rZ   rv   r[   rW   rB   r   rC   r   r   r$   r!   r^   r%   r   r_   r   rK   rL   )r
   r8   rv   rW   r<   rD   rE   r`   rI   r,   r   r   r   r   r   ra   r   rc   r    test_unregisterUtility_w_factory  s4    0
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 d    n1 s0    Y  | | | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|u  | |jj|u  | |jj|	u  | |jj|
u  | |jj|u  | |jjd u  d S )Nr   rg   rS   ru   rV   c                   @   s   e Zd ZdS )zIComponentsTests.test_unregisterUtility_wo_explicit_provided.<locals>.IFooNr9   r   r   r   r   r<     s   r<   c                   @   s   e Zd ZdS )zHComponentsTests.test_unregisterUtility_wo_explicit_provided.<locals>.FooNr9   r   r   r   r   r>     s   r>   r?   r   rY   rA   rh   r8   rZ   rv   r[   rW   rB   r   rC   r   r   r$   r!   r^   r%   r   r_   r   rK   r?   rL   r
   rh   r8   rv   rW   r<   r>   rD   rE   r`   rQ   r,   r   r   r   r   r   ra   r   r   r   +test_unregisterUtility_wo_explicit_provided  s:    
,
z;ComponentsTests.test_unregisterUtility_wo_explicit_providedc                 C   s  ddl m} ddl m} ddlm} ddlm} G dd d|}G dd	 d	t}|d}d
}d}	| }
||
| |  }|	|
||	| | 
 \}}| |j||	d}W d    n1 s0    Y  | | | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|u  | |jj|u  | |jj|	u  | |jj|
u  | |jj|u  | |jjd u  d S )Nr   rg   rS   ru   rV   c                   @   s   e Zd ZdS )zLComponentsTests.test_unregisterUtility_wo_component_or_factory.<locals>.IFooNr9   r   r   r   r   r<     s   r<   c                   @   s   e Zd ZdS )zKComponentsTests.test_unregisterUtility_wo_component_or_factory.<locals>.FooNr9   r   r   r   r   r>     s   r>   r?   r   )r_   r   rY   r   r   r   r   r   .test_unregisterUtility_wo_component_or_factory
  s:    
,
z>ComponentsTests.test_unregisterUtility_wo_component_or_factoryc                 C   s   ddl m} G dd d|}|d}d}d}d}t }|  }||||| ||||| |  \}	}
|	 |||| W d    n1 s0    Y  | |jj	d | d |f d S )	Nr   rS   c                   @   s   e Zd ZdS )zFComponentsTests.test_unregisterUtility_w_existing_subscr.<locals>.IFooNr9   r   r   r   r   r<   0  s   r<   r?   ro   rp   rX   
rA   r8   rB   r   rC   r   r   r!   r'   r]   rx   r   r   r   (test_unregisterUtility_w_existing_subscr-  s    ,z8ComponentsTests.test_unregisterUtility_w_existing_subscrc                 C   s   ddl m} G dd d|}|d}d}d}d}t }|  }||||| ||||| |  \}	}
|	 |||| W d    n1 s0    Y  | |jj	d | d |f d S )	Nr   rS   c                   @   s   e Zd ZdS )zSComponentsTests.test_unregisterUtility_w_existing_subscr_non_hashable.<locals>.IFooNr9   r   r   r   r   r<   B  s   r<   r?   ro   rp   rX   )
rA   r8   r}   r   rC   r   r   r!   r'   r]   rx   r   r   r   5test_unregisterUtility_w_existing_subscr_non_hashable?  s    ,zEComponentsTests.test_unregisterUtility_w_existing_subscr_non_hashablec                 C   s   ddl m} ddlm} G dd d|}|d}d}d}d}t }|  }	|	|||| |	|||| |  \}
}|
 |	||| W d    n1 s0    Y  | 	|	j
jd | d	 |f d S )
Nr   rS   )_UtilityRegistrationsc                   @   s   e Zd ZdS )z_ComponentsTests.test_unregisterUtility_w_existing_subscr_non_hashable_fresh_cache.<locals>.IFooNr9   r   r   r   r   r<   W  s   r<   r?   ro   rp   rX   )rA   r8   r[   r   r}   r   rC   r   r   r!   r'   r]   )r
   r8   r   r<   rD   rE   rr   rs   rQ   r,   r   r   r   r   r   Atest_unregisterUtility_w_existing_subscr_non_hashable_fresh_cacheQ  s    ,zQComponentsTests.test_unregisterUtility_w_existing_subscr_non_hashable_fresh_cachec                 C   s   ddl m} G dd d|}|d}d}d}d}t }|  }||||| ||||| |d ||||| |  \}	}
|	 |||| W d    n1 s0    Y  | dt	|j
j d S )	Nr   rS   c                   @   s   e Zd ZdS )z]ComponentsTests.test_unregisterUtility_w_existing_subscr_non_hashable_reinitted.<locals>.IFooNr9   r   r   r   r   r<   l  s   r<   r?   ro   rp   r.   )rA   r8   r}   r   rC   __init__r   r   r!   r^   r'   r]   rx   r   r   r   ?test_unregisterUtility_w_existing_subscr_non_hashable_reinittedg  s     
,zOComponentsTests.test_unregisterUtility_w_existing_subscr_non_hashable_reinittedc                 C   s   ddl m} G dd d|}|d}d}d}d}t }t }|  }	|	|||| |	|||| |  \}
}|
 |	||| W d    n1 s0    Y  | |	jj	d | d |f d S )	Nr   rS   c                   @   s   e Zd ZdS )zVComponentsTests.test_unregisterUtility_w_existing_subscr_other_component.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   ro   rp   rX   r   rq   r   r   r   8test_unregisterUtility_w_existing_subscr_other_component  s"    ,zHComponentsTests.test_unregisterUtility_w_existing_subscr_other_componentc                 C   s   ddl m} G dd d|}|d}d}d}d}t }t }|  }	|	|||| |	|||| |  \}
}|
 |	||| W d    n1 s0    Y  | |	j	j
d | d |f d S )	Nr   rS   c                   @   s   e Zd ZdS )zaComponentsTests.test_unregisterUtility_w_existing_subscr_other_component_mixed_hash.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   ro   rp   rX   )rA   r8   rB   r}   r   rC   r   r   r!   r'   r]   rq   r   r   r   Ctest_unregisterUtility_w_existing_subscr_other_component_mixed_hash  s"    ,zSComponentsTests.test_unregisterUtility_w_existing_subscr_other_component_mixed_hashc                 C   s    |   }| t| g  d S r   )r   r!   r   r   r1   r   r   r   test_registeredUtilities_empty  s    z.ComponentsTests.test_registeredUtilities_emptyc                 C   s  ddl m} ddlm} G dd d|}|d}d}d}d}t }|  }	|	|||| |	|||| t|	 d	d
 d}
| 	t
|
d | t|
d | | |
d j|	u  | |
d j|u  | |
d j|u  | |
d j|u  | |
d j|u  | |
d jd u  | t|
d | | |
d j|	u  | |
d j|u  | |
d j|u  | |
d j|u  | |
d j|u  | |
d jd u  d S )Nr   rS   rV   c                   @   s   e Zd ZdS )z?ComponentsTests.test_registeredUtilities_notempty.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   ro   rp   c                 S   s   | j S r   r   rr   r   r   <lambda>      zCComponentsTests.test_registeredUtilities_notempty.<locals>.<lambda>keyrl   rY   )rA   r8   r[   rW   rB   r   rC   sortedr   r!   r^   r$   r%   r   r_   r   rK   r?   rL   )r
   r8   rW   r<   rD   rE   rr   rs   rQ   r,   regr   r   r   !test_registeredUtilities_notempty  s6    z1ComponentsTests.test_registeredUtilities_notemptyc                 C   sD   ddl m} G dd d|}|d}|  }| ||d u  d S )Nr   rS   c                   @   s   e Zd ZdS )z?ComponentsTests.test_queryUtility_miss_no_default.<locals>.IFooNr9   r   r   r   r   r<     s   r<   )rA   r8   r   r$   queryUtilityr
   r8   r<   rD   r,   r   r   r   !test_queryUtility_miss_no_default  s
    z1ComponentsTests.test_queryUtility_miss_no_defaultc                 C   sN   ddl m} G dd d|}|d}|  }t }| |j||d|u  d S )Nr   rS   c                   @   s   e Zd ZdS )z>ComponentsTests.test_queryUtility_miss_w_default.<locals>.IFooNr9   r   r   r   r   r<     s   r<   default)rA   r8   r   rB   r$   r   )r
   r8   r<   rD   r,   _defaultr   r   r    test_queryUtility_miss_w_default  s    z0ComponentsTests.test_queryUtility_miss_w_defaultc                 C   sV   ddl m} G dd d|}|d}t }|  }||| | |||u  d S )Nr   rS   c                   @   s   e Zd ZdS )z3ComponentsTests.test_queryUtility_hit.<locals>.IFooNr9   r   r   r   r   r<     s   r<   )rA   r8   rB   r   rC   r$   r   r
   r8   r<   rD   rQ   r,   r   r   r   test_queryUtility_hit  s    z%ComponentsTests.test_queryUtility_hitc                 C   sL   ddl m} ddlm} G dd d|}|d}|  }| ||j| d S )Nr   rS   ComponentLookupErrorc                   @   s   e Zd ZdS )z2ComponentsTests.test_getUtility_miss.<locals>.IFooNr9   r   r   r   r   r<     s   r<   )rA   r8   rZ   r   r   rN   
getUtility)r
   r8   r   r<   rD   r,   r   r   r   test_getUtility_miss  s    z$ComponentsTests.test_getUtility_missc                 C   sV   ddl m} G dd d|}|d}t }|  }||| | |||u  d S )Nr   rS   c                   @   s   e Zd ZdS )z1ComponentsTests.test_getUtility_hit.<locals>.IFooNr9   r   r   r   r   r<     s   r<   )rA   r8   rB   r   rC   r$   r   r   r   r   r   test_getUtility_hit  s    z#ComponentsTests.test_getUtility_hitc                 C   sF   ddl m} G dd d|}|d}|  }| t||g  d S )Nr   rS   c                   @   s   e Zd ZdS )z7ComponentsTests.test_getUtilitiesFor_miss.<locals>.IFooNr9   r   r   r   r   r<     s   r<   )rA   r8   r   r!   r   getUtilitiesForr   r   r   r   test_getUtilitiesFor_miss  s
    z)ComponentsTests.test_getUtilitiesFor_missc                 C   s   ddl m} G dd d|}|d}d}d}t }|  }|j|||d |j|||d | t||||f||fg d S )Nr   rS   c                   @   s   e Zd ZdS )z6ComponentsTests.test_getUtilitiesFor_hit.<locals>.IFooNr9   r   r   r   r   r<     s   r<   ro   rp   r   )rA   r8   rB   r   rC   r!   r   r   r
   r8   r<   rD   rr   rs   rQ   r,   r   r   r   test_getUtilitiesFor_hit  s    z(ComponentsTests.test_getUtilitiesFor_hitc                 C   sF   ddl m} G dd d|}|d}|  }| t||g  d S )Nr   rS   c                   @   s   e Zd ZdS )zDComponentsTests.test_getAllUtilitiesRegisteredFor_miss.<locals>.IFooNr9   r   r   r   r   r<     s   r<   )rA   r8   r   r!   r   getAllUtilitiesRegisteredForr   r   r   r   &test_getAllUtilitiesRegisteredFor_miss  s
    z6ComponentsTests.test_getAllUtilitiesRegisteredFor_missc                 C   sv   ddl m} G dd d|}|d}d}d}t }|  }|j|||d |j|||d | t|||g d S )Nr   rS   c                   @   s   e Zd ZdS )zCComponentsTests.test_getAllUtilitiesRegisteredFor_hit.<locals>.IFooNr9   r   r   r   r   r<     s   r<   ro   rp   r   )rA   r8   rB   r   rC   r!   r   r   r   r   r   r   %test_getAllUtilitiesRegisteredFor_hit  s    z5ComponentsTests.test_getAllUtilitiesRegisteredFor_hitc           	      C   s   ddl m}m} G dd d|}|d}|d}|dG dd dt}d	}|  }|j||f||d
 | |j|f|df ||f d S )Nr   r6   c                   @   s   e Zd ZdS )zFComponentsTests.test_registerAdapter_with_component_name.<locals>.IFooNr9   r   r   r   r   r<   /  s   r<   r   r=   c                   @   s   e Zd ZdS )zEComponentsTests.test_registerAdapter_with_component_name.<locals>.FooNr9   r   r   r   r   r>   4  s   r>   r?   r@   )rA   r7   r8   rB   r   registerAdapterr!   r)   )	r
   r7   r8   r<   rD   ibarr>   rE   r,   r   r   r   (test_registerAdapter_with_component_name+  s    z8ComponentsTests.test_registerAdapter_with_component_namec                 C   s  ddl m} ddlm} ddlm} G dd d|}|d}|d}d}d	}d
d }	|  }
|  \}}|$ |
|	|f||| W d    n1 s0    Y  | 	|
j
jd | | | |	u  | |
j|f||f |	|f | t|d |d \}}|\}| |i  | 	t|| | 	t|j| | 	|jj|
u  | 	|jj|u  | |jj|f | 	|jj|u  | 	|jj|u  | 	|jj|	u  d S )Nr   rS   rT   AdapterRegistrationc                   @   s   e Zd ZdS )zSComponentsTests.test_registerAdapter_w_explicit_provided_and_required.<locals>.IFooNr9   r   r   r   r   r<   E  s   r<   r   r?   r   c                 S   s
   t  d S r   rG   contextr   r   r   rI   L  s    zWComponentsTests.test_registerAdapter_w_explicit_provided_and_required.<locals>._factoryrY   )rA   r8   rZ   rU   r[   r   r   r   r   r$   r&   r\   r!   r)   r^   r%   rB   r   r_   requiredr   r?   rL   )r
   r8   rU   r   r<   rD   r   rE   r`   rI   r,   r   r   r   r   ra   r   r   r   5test_registerAdapter_w_explicit_provided_and_required@  s>    2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   rS   c                   @   s   e Zd ZdS )zHComponentsTests.test_registerAdapter_no_provided_available.<locals>.IFooNr9   r   r   r   r   r<   f  s   r<   r   r?   r   c                   @   s   e Zd ZdS )zLComponentsTests.test_registerAdapter_no_provided_available.<locals>._FactoryNr9   r   r   r   r   _Factorym  s   r   r   r?   rA   r8   rB   r   rN   rO   r   )r
   r8   r<   r   rE   r`   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 d    n1 s0    Y  | |jjd | | |	 |u  | |j|f||	f ||f | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|u  | |jj|u  | |jj|f | |jj|	u  | |jj|u  | |jj|u  d S )Nr   rS   implementerrT   r   c                   @   s   e Zd ZdS )zGComponentsTests.test_registerAdapter_wo_explicit_provided.<locals>.IFooNr9   r   r   r   r   r<   z  s   r<   r   r?   r   c                   @   s   e Zd ZdS )zKComponentsTests.test_registerAdapter_wo_explicit_provided.<locals>._FactoryNr9   r   r   r   r   r     s   r   r   rY   )rA   r8   r   rZ   rU   r[   r   rB   r   r   r   r$   r&   r\   r!   r)   r^   r%   r   r_   r   r   r?   rL   )r
   r8   r   rU   r   r<   rD   r   rE   r`   rQ   r   r,   r   r   r   r   ra   r   r   r   )test_registerAdapter_wo_explicit_providedt  sD    2z9ComponentsTests.test_registerAdapter_wo_explicit_providedc                 C   s`   ddl m} G dd d|}|d}d}d}G dd dt}|  }| jt|j||||d	 d S )
Nr   rS   c                   @   s   e Zd ZdS )zHComponentsTests.test_registerAdapter_no_required_available.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   r   c                   @   s   e Zd ZdS )zLComponentsTests.test_registerAdapter_no_required_available.<locals>._FactoryNr9   r   r   r   r   r     s   r   r_   r   r?   r   r
   r8   r<   rD   rE   r`   r   r,   r   r   r   *test_registerAdapter_no_required_available  s    z:ComponentsTests.test_registerAdapter_no_required_availablec           	   	   C   sj   ddl m} G dd d|}|d}|d}d}d}G dd	 d	t}|  }| jt|j|||||d
 d S )Nr   rS   c                   @   s   e Zd ZdS )zEComponentsTests.test_registerAdapter_w_invalid_required.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r?   r   c                   @   s   e Zd ZdS )zIComponentsTests.test_registerAdapter_w_invalid_required.<locals>._FactoryNr9   r   r   r   r   r     s   r   r   r   )	r
   r8   r<   rD   r   rE   r`   r   r,   r   r   r   'test_registerAdapter_w_invalid_required  s    z7ComponentsTests.test_registerAdapter_w_invalid_requiredc                 C   s  ddl m} ddlm} ddlm} ddlm} G dd d|}|d}d}d	}G d
d dt}	| 	 }
| 
 \}}|& |
j|	d g|||d W d    n1 s0    Y  | |
jjd | | | |	u  | |
j|f||f |	|f | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|
u  | |jj|u  | |jj|f | |jj|u  | |jj|u  | |jj|	u  d S )Nr   rS   r   rT   r   c                   @   s   e Zd ZdS )zMComponentsTests.test_registerAdapter_w_required_containing_None.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   r   c                   @   s   e Zd ZdS )zQComponentsTests.test_registerAdapter_w_required_containing_None.<locals>._FactoryNr9   r   r   r   r   r     s   r   r   rY   )rA   r8   Zzope.interface.interfacer   rZ   rU   r[   r   rB   r   r   r   r$   r&   r\   r!   r)   r^   r%   r   r_   r   r   r?   rL   )r
   r8   r   rU   r   r<   rD   rE   r`   r   r,   r   r   r   r   ra   r   r   r   /test_registerAdapter_w_required_containing_None  sB    $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 d    n1 s0    Y  | |jjd | | |
 |u  | |j|f||
f ||	f | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|u  | |jj|u  | |jj|f | |jj|
u  | |jj|	u  | |jj|u  d S )Nr   rS   r   )implementedByrT   r   c                   @   s   e Zd ZdS )zNComponentsTests.test_registerAdapter_w_required_containing_class.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r?   r   c                   @   s   e Zd ZdS )zRComponentsTests.test_registerAdapter_w_required_containing_class.<locals>._FactoryNr9   r   r   r   r   r     s   r   c                   @   s   e Zd ZdS )zRComponentsTests.test_registerAdapter_w_required_containing_class.<locals>._ContextNr9   r   r   r   r   _Context  s   r   r   rY   )rA   r8   r   r   rZ   rU   r[   r   rB   r   r   r   r$   r&   r\   r!   r)   r^   r%   r   r_   r   r   r?   rL   )r
   r8   r   r   rU   r   r<   rD   r   rE   r`   r   r   Z	_ctx_implr,   r   r   r   r   ra   r   r   r   0test_registerAdapter_w_required_containing_class  sL    $z@ComponentsTests.test_registerAdapter_w_required_containing_classc              	   C   sf   ddl m} G dd d|}|d}d}d}G dd dt}|  }| jt|j|t g|||d	 d S )
Nr   rS   c                   @   s   e Zd ZdS )zMComponentsTests.test_registerAdapter_w_required_containing_junk.<locals>.IFooNr9   r   r   r   r   r<   
  s   r<   r?   r   c                   @   s   e Zd ZdS )zQComponentsTests.test_registerAdapter_w_required_containing_junk.<locals>._FactoryNr9   r   r   r   r   r     s   r   r   r   r   r   r   r   /test_registerAdapter_w_required_containing_junk  s    z?ComponentsTests.test_registerAdapter_w_required_containing_junkc                    s  ddl m} ddlm} ddlm} G dd d|}|d}|d d}d	}G  fd
ddt}|  }	|  \}
}|
" |	j	||||d W d    n1 s0    Y  | 
|	jjd   | | |u  | |	j f||f ||f | t|d |d \}}|\}| |i  | 
t|| | 
t|j| | 
|jj|	u  | 
|jj|u  | |jj f | 
|jj|u  | 
|jj|u  | 
|jj|u  d S )Nr   rS   rT   r   c                   @   s   e Zd ZdS )zGComponentsTests.test_registerAdapter_wo_explicit_required.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r?   r   c                       s   e Zd Z fZdS )zKComponentsTests.test_registerAdapter_wo_explicit_required.<locals>._FactoryNr"   r:   r;   __component_adapts__r   r   r   r   r   !  s   r   r   rY   )rA   r8   rZ   rU   r[   r   rB   r   r   r   r$   r&   r\   r!   r)   r^   r%   r   r_   r   r   r?   rL   )r
   r8   rU   r   r<   rD   rE   r`   r   r,   r   r   r   r   ra   r   r   r   )test_registerAdapter_wo_explicit_required  sB    
$z9ComponentsTests.test_registerAdapter_wo_explicit_requiredc              	   C   s   ddl m} G dd d|}|d}|d}d}d}dd	 }|  }|  \}	}
|	( |j||f|||d
d W d    n1 s0    Y  | t|
d d S )Nr   rS   c                   @   s   e Zd ZdS )z;ComponentsTests.test_registerAdapter_wo_event.<locals>.IFooNr9   r   r   r   r   r<   =  s   r<   r   r?   r   c                 S   s
   t  d S r   rG   r   r   r   r   rI   D  s    z?ComponentsTests.test_registerAdapter_wo_event.<locals>._factoryF)ra   )rA   r8   r   r   r   r!   r^   )r
   r8   r<   rD   r   rE   r`   rI   r,   r   r   r   r   r   test_registerAdapter_wo_event:  s    $z-ComponentsTests.test_registerAdapter_wo_eventc                 C   s    |   }| jt|jd d d d S N)rL   r_   )r   rN   rO   unregisterAdapterr1   r   r   r   3test_unregisterAdapter_neither_factory_nor_providedM  s    
zCComponentsTests.test_unregisterAdapter_neither_factory_nor_providedc                 C   sF   ddl m} G dd d|}|d}|  }| jt|jd |d d d S )Nr   rS   c                   @   s   e Zd ZdS )zQComponentsTests.test_unregisterAdapter_neither_factory_nor_required.<locals>.IFooNr9   r   r   r   r   r<   T  s   r<   rL   r_   r   )rA   r8   r   rN   rO   r   r   r   r   r   3test_unregisterAdapter_neither_factory_nor_requiredR  s    
zCComponentsTests.test_unregisterAdapter_neither_factory_nor_requiredc           
      C   s   ddl m} G dd d|}|d}|d}G dd dt}|  }|  \}}|  |||f|}	W d    n1 sz0    Y  | |	 d S )Nr   rS   c                   @   s   e Zd ZdS )z9ComponentsTests.test_unregisterAdapter_miss.<locals>.IFooNr9   r   r   r   r   r<   ]  s   r<   r   c                   @   s   e Zd ZdS )z=ComponentsTests.test_unregisterAdapter_miss.<locals>._FactoryNr9   r   r   r   r   r   a  s   r   )rA   r8   rB   r   r   r   r   
r
   r8   r<   rD   r   r   r,   r   r   r   r   r   r   test_unregisterAdapter_miss[  s    .z+ComponentsTests.test_unregisterAdapter_missc                 C   s  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 d    n1 s0    Y  | | | |jj | |j | t|
d
 |
d \}}|\}| |i  | t|| | t|j| | |jj|u  | |jj|u  | |jj|f | |jjd | |jjd | |jj|u  d S )Nr   rS   ru   r   c                   @   s   e Zd ZdS )zYComponentsTests.test_unregisterAdapter_hit_w_explicit_provided_and_required.<locals>.IFooNr9   r   r   r   r   r<   n  s   r<   r   c                   @   s   e Zd ZdS )z]ComponentsTests.test_unregisterAdapter_hit_w_explicit_provided_and_required.<locals>._FactoryNr9   r   r   r   r   r   r  s   r   rY   rX   )rA   r8   rZ   rv   r[   r   rB   r   r   r   r   r$   r   r&   r\   r)   r!   r^   r%   r   r_   r   r   r?   rL   )r
   r8   rv   r   r<   rD   r   r   r,   r   r   r   r   r   ra   r   r   r   ;test_unregisterAdapter_hit_w_explicit_provided_and_requiredj  s6    .
zKComponentsTests.test_unregisterAdapter_hit_w_explicit_provided_and_requiredc                 C   s  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 d    n1 s0    Y  | | | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|	u  | |jj|u  | |jj|f | |jjd | |jjd | |jj|u  d S )Nr   rS   r   ru   r   c                   @   s   e Zd ZdS )zIComponentsTests.test_unregisterAdapter_wo_explicit_provided.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   c                   @   s   e Zd ZdS )zMComponentsTests.test_unregisterAdapter_wo_explicit_provided.<locals>._FactoryNr9   r   r   r   r   r     s   r   rY   rX   )rA   r8   r   rZ   rv   r[   r   rB   r   r   r   r   r$   r!   r^   r%   r   r_   r   r   r?   rL   )r
   r8   r   rv   r   r<   rD   r   r   r,   r   r   r   r   r   ra   r   r   r   +test_unregisterAdapter_wo_explicit_provided  s6    ,
z;ComponentsTests.test_unregisterAdapter_wo_explicit_providedc                    st  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 d    n1 s0    Y  | |
 | t|	d |	d \}}|\}| |i  | t|| | t|j| | |jj|u  | |jj|u  | |jj f | |jjd | |jjd | |jj|u  d S )Nr   rS   ru   r   c                   @   s   e Zd ZdS )zIComponentsTests.test_unregisterAdapter_wo_explicit_required.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   c                       s   e Zd Z fZdS )zMComponentsTests.test_unregisterAdapter_wo_explicit_required.<locals>._FactoryNr   r   r   r   r   r     s   r   r_   rY   rX   )rA   r8   rZ   rv   r[   r   rB   r   r   r   r   r$   r!   r^   r%   r   r_   r   r   r?   rL   )r
   r8   rv   r   r<   rD   r   r,   r   r   r   r   r   ra   r   r   r   +test_unregisterAdapter_wo_explicit_required  s2    ,
z;ComponentsTests.test_unregisterAdapter_wo_explicit_requiredc                 C   s    |   }| t| g  d S r   )r   r!   r   registeredAdaptersr1   r   r   r   test_registeredAdapters_empty  s    z-ComponentsTests.test_registeredAdapters_emptyc                 C   s  ddl m} ddlm} G dd d|}|d}|d}d}d}d}G d	d
 d
t}	|  }
|
|	|f||| |
|	|f||| t|
 dd d}| 	t
|d | t|d | | |d j|
u  | |d j|u  | 	|d j|f | |d j|u  | |d j|u  | |d j|	u  | t|d | | |d j|
u  | |d j|u  | 	|d j|f | |d j|u  | |d j|u  | |d j|	u  d S )Nr   rS   r   c                   @   s   e Zd ZdS )z>ComponentsTests.test_registeredAdapters_notempty.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r?   ro   rp   c                   @   s   e Zd ZdS )zBComponentsTests.test_registeredAdapters_notempty.<locals>._FactoryNr9   r   r   r   r   r     s   r   c                 S   s   | j S r   r   r   r   r   r   r     r   zBComponentsTests.test_registeredAdapters_notempty.<locals>.<lambda>r   rl   rY   )rA   r8   r[   r   rB   r   r   r   r   r!   r^   r$   r%   r   r_   r   r   r?   rL   )r
   r8   r   r<   rD   r   rE   rr   rs   r   r,   r   r   r   r    test_registeredAdapters_notempty  s8    z0ComponentsTests.test_registeredAdapters_notemptyc                 C   sL   ddl m} G dd d|}|d}|  }t }| |||d u  d S )Nr   rS   c                   @   s   e Zd ZdS )z?ComponentsTests.test_queryAdapter_miss_no_default.<locals>.IFooNr9   r   r   r   r   r<     s   r<   rA   r8   r   rB   r$   queryAdapter)r
   r8   r<   rD   r,   _contextr   r   r   !test_queryAdapter_miss_no_default  s    z1ComponentsTests.test_queryAdapter_miss_no_defaultc                 C   sV   ddl m} G dd d|}|d}|  }t }t }| |j|||d|u  d S )Nr   rS   c                   @   s   e Zd ZdS )z>ComponentsTests.test_queryAdapter_miss_w_default.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r   )r
   r8   r<   rD   r,   r   r   r   r   r    test_queryAdapter_miss_w_default  s    z0ComponentsTests.test_queryAdapter_miss_w_defaultc                 C   s   ddl m} ddl m} G dd d|}|d}|d}G dd dt}||G d	d
 d
t}| }|  }	|	||f| |	||}
| t|
| | |
j	|u  d S )Nr   rS   r   c                   @   s   e Zd ZdS )z3ComponentsTests.test_queryAdapter_hit.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   c                   @   s   e Zd Zdd ZdS )z7ComponentsTests.test_queryAdapter_hit.<locals>._Factoryc                 S   s
   || _ d S r   r   r
   r   r   r   r   r   
  s    z@ComponentsTests.test_queryAdapter_hit.<locals>._Factory.__init__Nr"   r:   r;   r   r   r   r   r   r   	  s   r   c                   @   s   e Zd ZdS )z7ComponentsTests.test_queryAdapter_hit.<locals>._ContextNr9   r   r   r   r   r     s   r   )
rA   r8   r   rB   r   r   r   r$   r%   r   r
   r8   r   r<   rD   r   r   r   r   r,   adapterr   r   r   test_queryAdapter_hit  s    z%ComponentsTests.test_queryAdapter_hitc           
      C   s   ddl m} ddl m} ddlm} G dd d|}|d}|d}||G dd	 d	t}| }|  }	| ||	j|| d S )
Nr   rS   r   r   c                   @   s   e Zd ZdS )z2ComponentsTests.test_getAdapter_miss.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   c                   @   s   e Zd ZdS )z6ComponentsTests.test_getAdapter_miss.<locals>._ContextNr9   r   r   r   r   r     s   r   )	rA   r8   r   rZ   r   rB   r   rN   
getAdapter)
r
   r8   r   r   r<   rD   r   r   r   r,   r   r   r   test_getAdapter_miss  s    z$ComponentsTests.test_getAdapter_missc                 C   s   ddl m} ddl m} G dd d|}|d}|d}G dd dt}||G d	d
 d
t}| }|  }	|	||f| |	||}
| |
| | |
j	| d S )Nr   rS   r   c                   @   s   e Zd ZdS )z1ComponentsTests.test_getAdapter_hit.<locals>.IFooNr9   r   r   r   r   r<   )  s   r<   r   c                   @   s   e Zd Zdd ZdS )z5ComponentsTests.test_getAdapter_hit.<locals>._Factoryc                 S   s
   || _ d S r   r   r   r   r   r   r   .  s    z>ComponentsTests.test_getAdapter_hit.<locals>._Factory.__init__Nr   r   r   r   r   r   -  s   r   c                   @   s   e Zd ZdS )z5ComponentsTests.test_getAdapter_hit.<locals>._ContextNr9   r   r   r   r   r   0  s   r   )
rA   r8   r   rB   r   r   r   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>.IBaseNr9   r   r   r   r   IBase>  s   r   c                   @   s   e Zd ZdS )z;ComponentsTests.test_getAdapter_hit_super.<locals>.IDerivedNr9   r   r   r   r   IDerivedA  s   r   c                   @   s   e Zd ZdS )z7ComponentsTests.test_getAdapter_hit_super.<locals>.IFooNr9   r   r   r   r   r<   D  s   r<   c                   @   s   e Zd ZdS )z7ComponentsTests.test_getAdapter_hit_super.<locals>.BaseNr9   r   r   r   r   BaseG  s   r   c                   @   s   e Zd ZdS )z:ComponentsTests.test_getAdapter_hit_super.<locals>.DerivedNr9   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   rA   r   rB   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>.IBaseNr9   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>.IDerivedNr9   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>.IFooNr9   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>.BaseNr9   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>.Child1Nr9   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>.Child2Nr9   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>.DerivedNr9   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   rS   r   c                   @   s   e Zd ZdS )z9ComponentsTests.test_queryMultiAdapter_miss.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   IBazc                   @   s   e Zd ZdS )z>ComponentsTests.test_queryMultiAdapter_miss.<locals>._Context1Nr9   r   r   r   r   	_Context1  s   r  c                   @   s   e Zd ZdS )z>ComponentsTests.test_queryMultiAdapter_miss.<locals>._Context2Nr9   r   r   r   r   	_Context2  s   r  )rA   r8   r   rB   r   r!   queryMultiAdapterr
   r8   r   r<   rD   r   ibazr  r  	_context1	_context2r,   r   r   r   test_queryMultiAdapter_miss  s     z+ComponentsTests.test_queryMultiAdapter_missc                 C   s   ddl m} ddl m} G dd d|}|d}|d}|d}||G dd	 d	t}||G d
d dt}| }	| }
t }|  }| |j|	|
f||d|u  d S )Nr   rS   r   c                   @   s   e Zd ZdS )zCComponentsTests.test_queryMultiAdapter_miss_w_default.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r  c                   @   s   e Zd ZdS )zHComponentsTests.test_queryMultiAdapter_miss_w_default.<locals>._Context1Nr9   r   r   r   r   r    s   r  c                   @   s   e Zd ZdS )zHComponentsTests.test_queryMultiAdapter_miss_w_default.<locals>._Context2Nr9   r   r   r   r   r    s   r  r   )rA   r8   r   rB   r   r$   r  )r
   r8   r   r<   rD   r   r  r  r  r  r  r   r,   r   r   r   %test_queryMultiAdapter_miss_w_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   rS   r   c                   @   s   e Zd ZdS )z8ComponentsTests.test_queryMultiAdapter_hit.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r  c                   @   s   e Zd ZdS )z=ComponentsTests.test_queryMultiAdapter_hit.<locals>._Context1Nr9   r   r   r   r   r    s   r  c                   @   s   e Zd ZdS )z=ComponentsTests.test_queryMultiAdapter_hit.<locals>._Context2Nr9   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   )rA   r8   r   rB   r   r   r  r$   r%   r!   r   r
   r8   r   r<   rD   r   r  r  r  r  r  r   r,   r   r   r   r   test_queryMultiAdapter_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   rS   r   r   c                   @   s   e Zd ZdS )z7ComponentsTests.test_getMultiAdapter_miss.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r  c                   @   s   e Zd ZdS )z<ComponentsTests.test_getMultiAdapter_miss.<locals>._Context1Nr9   r   r   r   r   r    s   r  c                   @   s   e Zd ZdS )z<ComponentsTests.test_getMultiAdapter_miss.<locals>._Context2Nr9   r   r   r   r   r    s   r  )	rA   r8   r   rZ   r   rB   r   rN   getMultiAdapter)r
   r8   r   r   r<   rD   r   r  r  r  r  r  r,   r   r   r   test_getMultiAdapter_miss  s"    z)ComponentsTests.test_getMultiAdapter_missc                 C   s   ddl m} ddl m} G dd d|}|d}|d}|d}||G dd	 d	t}||G d
d dt}| }	| }
G dd dt}|  }||||f| ||	|
f|}| t|| | 	|j
|	|
f d S )Nr   rS   r   c                   @   s   e Zd ZdS )z6ComponentsTests.test_getMultiAdapter_hit.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r  c                   @   s   e Zd ZdS )z;ComponentsTests.test_getMultiAdapter_hit.<locals>._Context1Nr9   r   r   r   r   r    s   r  c                   @   s   e Zd ZdS )z;ComponentsTests.test_getMultiAdapter_hit.<locals>._Context2Nr9   r   r   r   r   r    s   r  c                   @   s   e Zd Zdd ZdS )z:ComponentsTests.test_getMultiAdapter_hit.<locals>._Factoryc                 S   s   ||f| _ d S r   r   r  r   r   r   r     s    zCComponentsTests.test_getMultiAdapter_hit.<locals>._Factory.__init__Nr   r   r   r   r   r      s   r   )rA   r8   r   rB   r   r   r  r$   r%   r!   r   r  r   r   r   test_getMultiAdapter_hit  s$    z(ComponentsTests.test_getMultiAdapter_hitc                    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>.IBaseNr9   r   r   r   r   r     s   r   c                   @   s   e Zd ZdS )z@ComponentsTests.test_getMultiAdapter_hit_super.<locals>.IDerivedNr9   r   r   r   r   r     s   r   c                   @   s   e Zd ZdS )z<ComponentsTests.test_getMultiAdapter_hit_super.<locals>.IFooNr9   r   r   r   r   r<     s   r<   c                   @   s   e Zd ZdS )z<ComponentsTests.test_getMultiAdapter_hit_super.<locals>.BaseNr9   r   r   r   r   r      s   r   c                   @   s   e Zd ZdS )z?ComponentsTests.test_getMultiAdapter_hit_super.<locals>.DerivedNr9   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>.AdapterDerivedNr9   r   r   r   r   r  -  s   r  )r   r   rA   r   rB   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   rS   r   c                   @   s   e Zd ZdS )z4ComponentsTests.test_getAdapters_empty.<locals>.IFooNr9   r   r   r   r   r<   E  s   r<   r   r  c                   @   s   e Zd ZdS )z9ComponentsTests.test_getAdapters_empty.<locals>._Context1Nr9   r   r   r   r   r  J  s   r  c                   @   s   e Zd ZdS )z9ComponentsTests.test_getAdapters_empty.<locals>._Context2Nr9   r   r   r   r   r  M  s   r  )rA   r8   r   rB   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   rS   r   c                   @   s   e Zd ZdS )zCComponentsTests.test_getAdapters_factory_returns_None.<locals>.IFooNr9   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>._Context1Nr9   r   r   r   r   r  ^  s   r  c                   @   s   e Zd ZdS )zHComponentsTests.test_getAdapters_factory_returns_None.<locals>._Context2Nr9   r   r   r   r   r  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)	rA   r8   r   rB   r   r   r!   r   r$  )r
   r8   r   r<   rD   r   r  r  r  r  r  r,   r'  r   r&  r   %test_getAdapters_factory_returns_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   rS   r   c                   @   s   e Zd ZdS )z8ComponentsTests.test_getAdapters_non_empty.<locals>.IFooNr9   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>._Context1Nr9   r   r   r   r   r  y  s   r  c                   @   s   e Zd ZdS )z=ComponentsTests.test_getAdapters_non_empty.<locals>._Context2Nr9   r   r   r   r   r  |  s   r  c                   @   s   e Zd Zdd ZdS )z=ComponentsTests.test_getAdapters_non_empty.<locals>._Factory1c                 S   s   ||f| _ d S r   r   r  r   r   r   r     s    zFComponentsTests.test_getAdapters_non_empty.<locals>._Factory1.__init__Nr   r   r   r   r   	_Factory1  s   r)  c                   @   s   e Zd Zdd ZdS )z=ComponentsTests.test_getAdapters_non_empty.<locals>._Factory2c                 S   s   ||f| _ d S r   r   r  r   r   r   r     s    zFComponentsTests.test_getAdapters_non_empty.<locals>._Factory2.__init__Nr   r   r   r   r   	_Factory2  s   r*  ro   rp   r   rl   rY   )rA   r8   r   rB   r   r   r   r$  r!   r^   r$   r%   )r
   r8   r   r<   rD   r   r  r  r  r  r  r)  r*  rr   rs   r,   foundr   r   r   test_getAdapters_non_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   rS   c                   @   s   e Zd ZdS )zNComponentsTests.test_registerSubscriptionAdapter_w_nonblank_name.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r   r?   c                 S   s
   t  d S r   rG   r   r   r   r   rI     s    zRComponentsTests.test_registerSubscriptionAdapter_w_nonblank_name.<locals>._factory)rA   r8   r   rN   rO   registerSubscriptionAdapter)	r
   r8   r<   rD   r   r`   rE   rI   r,   r   r   r   0test_registerSubscriptionAdapter_w_nonblank_name  s    
z@ComponentsTests.test_registerSubscriptionAdapter_w_nonblank_namec                 C   s  ddl m} ddlm} ddlm} G dd d|}|d}|d}d}d	}d
d }	|  }
|  \}}|$ |
j|	|f||d W d    n1 s0    Y  |
j	j
d | | | }| t|d | |d |	u  | |
j|f|||	|fg | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|
u  | |jj|u  | |jj|f | |jj| | |jj|u  | |jj|	u  d S )Nr   rS   rT   SubscriptionRegistrationc                   @   s   e Zd ZdS )z_ComponentsTests.test_registerSubscriptionAdapter_w_explicit_provided_and_required.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   rX   r?   c                 S   s
   t  d S r   rG   r   r   r   r   rI     s    zcComponentsTests.test_registerSubscriptionAdapter_w_explicit_provided_and_required.<locals>._factoryr@   rY   )rA   r8   rZ   rU   r[   r0  r   r   r-  r&   r]   r!   r^   r$   r*   r%   rB   r   r_   r   r   r?   rL   )r
   r8   rU   r0  r<   rD   r   _blankrE   rI   r,   r   r   r   r   r   ra   r   r   r   Atest_registerSubscriptionAdapter_w_explicit_provided_and_required  sB    $zQComponentsTests.test_registerSubscriptionAdapter_w_explicit_provided_and_requiredc                 C   s  ddl m} ddl m} ddlm} ddlm} G dd d|}|d}|d}d	}d
}	||G dd dt}
|  }| 	 \}}|" |j
|
|f|d W d    n1 s0    Y  |jjd | | |	 }| t|d | |d |
u  | |j|f||	|
|fg | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|u  | |jj|u  | |jj|f | |jj|	 | |jj|u  | |jj|
u  d S )Nr   rS   r   rT   r/  c                   @   s   e Zd ZdS )zSComponentsTests.test_registerSubscriptionAdapter_wo_explicit_provided.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r?   rX   c                   @   s   e Zd ZdS )zWComponentsTests.test_registerSubscriptionAdapter_wo_explicit_provided.<locals>._FactoryNr9   r   r   r   r   r     s   r   r@   rY   )rA   r8   r   rZ   rU   r[   r0  rB   r   r   r-  r&   r]   r!   r^   r$   r*   r%   r   r_   r   r   r?   rL   )r
   r8   r   rU   r0  r<   rD   r   rE   r1  r   r,   r   r   r   r   r   ra   r   r   r   5test_registerSubscriptionAdapter_wo_explicit_provided  sB    0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 d    n1 s0    Y  |	j
jd   | | }| t|d | |d |u  | |	j f||||fg | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|	u  | |jj|u  | |jj f | |jj| | |jj|u  | |jj|u  d S )Nr   rS   rT   r/  c                   @   s   e Zd ZdS )zSComponentsTests.test_registerSubscriptionAdapter_wo_explicit_required.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   r?   rX   c                       s   e Zd Z fZdS )zWComponentsTests.test_registerSubscriptionAdapter_wo_explicit_required.<locals>._FactoryNr   r   r   r   r   r     s   r   )r_   r?   rY   )rA   r8   rZ   rU   r[   r0  rB   r   r   r-  r&   r]   r!   r^   r$   r*   r%   r   r_   r   r   r?   rL   )r
   r8   rU   r0  r<   rD   rE   r1  r   r,   r   r   r   r   r   ra   r   r   r   5test_registerSubscriptionAdapter_wo_explicit_required  sB    $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 d    n1 s0    Y  | t|
d d S )Nr   rS   c                   @   s   e Zd ZdS )zGComponentsTests.test_registerSubscriptionAdapter_wo_event.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   rX   r?   c                 S   s
   t  d S r   rG   r   r   r   r   rI     s    zKComponentsTests.test_registerSubscriptionAdapter_wo_event.<locals>._factoryFr?   ra   )rA   r8   r   r   r-  r!   r^   )r
   r8   r<   rD   r   r1  rE   rI   r,   r   r   r   r   r   )test_registerSubscriptionAdapter_wo_event  s    $z9ComponentsTests.test_registerSubscriptionAdapter_wo_eventc                 C   s    |   }| t| g  d S r   )r   r!   r   registeredSubscriptionAdaptersr1   r   r   r   )test_registeredSubscriptionAdapters_empty'  s    z9ComponentsTests.test_registeredSubscriptionAdapters_emptyc                 C   s  ddl m} ddlm} G dd d|}|d}|d}d}d}G dd	 d	t}|  }	|	j||f||d
 |	j||f||d
 t|	 }
| 	t
|
d | t|
d | | |
d j|	u  | |
d j|u  | 	|
d j|f | 	|
d j| | |
d j|u  | |
d j|u  | t|
d | | |
d j|	u  | |
d j|u  | 	|
d j|f | 	|
d j| | |
d j|u  | |
d j|u  d S )Nr   rS   r/  c                   @   s   e Zd ZdS )zJComponentsTests.test_registeredSubscriptionAdapters_notempty.<locals>.IFooNr9   r   r   r   r   r<   /  s   r<   r?   rX   c                   @   s   e Zd ZdS )zNComponentsTests.test_registeredSubscriptionAdapters_notempty.<locals>._FactoryNr9   r   r   r   r   r   5  s   r   r@   rl   rY   )rA   r8   r[   r0  rB   r   r-  r   r7  r!   r^   r$   r%   r   r_   r   r   r?   rL   )r
   r8   r0  r<   rD   r   rE   r1  r   r,   r   r   r   r   ,test_registeredSubscriptionAdapters_notempty+  s6    z<ComponentsTests.test_registeredSubscriptionAdapters_notemptyc                 C   sR   ddl m} G dd d|}|d}|d}d}|  }| jt|j|||d d S )Nr   rS   c                   @   s   e Zd ZdS )zPComponentsTests.test_unregisterSubscriptionAdapter_w_nonblank_name.<locals>.IFooNr9   r   r   r   r   r<   O  s   r<   r   nonblank)r   r_   r   rA   r8   r   rN   rO   unregisterSubscriptionAdapter)r
   r8   r<   rD   r   	_nonblankr,   r   r   r   2test_unregisterSubscriptionAdapter_w_nonblank_nameL  s    
zBComponentsTests.test_unregisterSubscriptionAdapter_w_nonblank_namec                 C   s    |   }| jt|jd d d d S r   )r   rN   rO   r<  r1   r   r   r   ?test_unregisterSubscriptionAdapter_neither_factory_nor_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   rS   c                   @   s   e Zd ZdS )z]ComponentsTests.test_unregisterSubscriptionAdapter_neither_factory_nor_required.<locals>.IFooNr9   r   r   r   r   r<   _  s   r<   r   r;  r   r   r   r   ?test_unregisterSubscriptionAdapter_neither_factory_nor_required]  s    
zOComponentsTests.test_unregisterSubscriptionAdapter_neither_factory_nor_requiredc           
      C   s   ddl m} G dd d|}|d}|d}G dd dt}|  }|  \}}|  |||f|}	W d    n1 sz0    Y  | |	 | | d S )Nr   rS   c                   @   s   e Zd ZdS )zEComponentsTests.test_unregisterSubscriptionAdapter_miss.<locals>.IFooNr9   r   r   r   r   r<   h  s   r<   r   c                   @   s   e Zd ZdS )zIComponentsTests.test_unregisterSubscriptionAdapter_miss.<locals>._FactoryNr9   r   r   r   r   r   l  s   r   )rA   r8   rB   r   r   r<  r   r   r   r   r   'test_unregisterSubscriptionAdapter_missf  s    .
z7ComponentsTests.test_unregisterSubscriptionAdapter_missc                 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}|  }|||f| | 	 \}	}
|	  |
d |f|}W d    n1 s0    Y  | | | |jj | |j | t|
d
 |
d \}}|\}| |i  | t|| | t|j| | |jj|u  | |jj|u  | |jj|f | |jjd | |jjd | |jjd u  d S )Nr   rS   ru   r/  c                   @   s   e Zd ZdS )zOComponentsTests.test_unregisterSubscriptionAdapter_hit_wo_factory.<locals>.IFooNr9   r   r   r   r   r<   z  s   r<   r   c                   @   s   e Zd ZdS )zSComponentsTests.test_unregisterSubscriptionAdapter_hit_wo_factory.<locals>._FactoryNr9   r   r   r   r   r   ~  s   r   rY   rX   rA   r8   rZ   rv   r[   r0  rB   r   r-  r   r<  r$   r   r&   r]   r*   r!   r^   r%   r   r_   r   r   r?   rL   r
   r8   rv   r0  r<   rD   r   r   r,   r   r   r   r   r   ra   r   r   r   1test_unregisterSubscriptionAdapter_hit_wo_factoryv  s6    .
zAComponentsTests.test_unregisterSubscriptionAdapter_hit_wo_factoryc                 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}|  }|||f| | 	 \}	}
|	  |
||f|}W d    n1 s0    Y  | | | |jj | |j | t|
d
 |
d \}}|\}| |i  | t|| | t|j| | |jj|u  | |jj|u  | |jj|f | |jjd | |jjd | |jj|u  d S )Nr   rS   ru   r/  c                   @   s   e Zd ZdS )zNComponentsTests.test_unregisterSubscriptionAdapter_hit_w_factory.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   c                   @   s   e Zd ZdS )zRComponentsTests.test_unregisterSubscriptionAdapter_hit_w_factory.<locals>._FactoryNr9   r   r   r   r   r     s   r   rY   rX   rB  rC  r   r   r   0test_unregisterSubscriptionAdapter_hit_w_factory  s6    .
z@ComponentsTests.test_unregisterSubscriptionAdapter_hit_w_factoryc                 C   s  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 d    n1 s0    Y  | | | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|	u  | |jj|u  | |jj|f | |jjd | |jjd | |jj|u  d S )Nr   rS   r   ru   r/  c                   @   s   e Zd ZdS )zUComponentsTests.test_unregisterSubscriptionAdapter_wo_explicit_provided.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   c                   @   s   e Zd ZdS )zYComponentsTests.test_unregisterSubscriptionAdapter_wo_explicit_provided.<locals>._FactoryNr9   r   r   r   r   r     s   r   rY   rX   )rA   r8   r   rZ   rv   r[   r0  rB   r   r-  r   r<  r$   r!   r^   r%   r   r_   r   r   r?   rL   )r
   r8   r   rv   r0  r<   rD   r   r   r,   r   r   r   r   r   ra   r   r   r   7test_unregisterSubscriptionAdapter_wo_explicit_provided  s6    ,
zGComponentsTests.test_unregisterSubscriptionAdapter_wo_explicit_providedc                    st  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 d    n1 s0    Y  | |
 | t|	d |	d \}}|\}| |i  | t|| | t|j| | |jj|u  | |jj|u  | |jj f | |jjd | |jjd | |jj|u  d S )Nr   rS   ru   r/  c                   @   s   e Zd ZdS )zUComponentsTests.test_unregisterSubscriptionAdapter_wo_explicit_required.<locals>.IFooNr9   r   r   r   r   r<     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   rY   rX   )rA   r8   rZ   rv   r[   r0  rB   r   r-  r   r<  r$   r!   r^   r%   r   r_   r   r   r?   rL   )r
   r8   rv   r0  r<   rD   r   r,   r   r   r   r   r   ra   r   r   r   7test_unregisterSubscriptionAdapter_wo_explicit_required  s2    ,
zGComponentsTests.test_unregisterSubscriptionAdapter_wo_explicit_requiredc           	      C   s|   ddl m} ddl m} G dd d|}|d}|d}|  }||G dd dt}| }| t||f|g  d S )	Nr   rS   r   c                   @   s   e Zd ZdS )z4ComponentsTests.test_subscribers_empty.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   c                   @   s   e Zd ZdS )z3ComponentsTests.test_subscribers_empty.<locals>.BarNr9   r   r   r   r   Bar  s   rH  )rA   r8   r   r   rB   r!   r   subscribers)	r
   r8   r   r<   rD   r   r,   rH  barr   r   r   test_subscribers_empty  s    z&ComponentsTests.test_subscribers_emptyc                    s   ddl m} ddl m} G dd d|}|d}|d G  fdddt}G d	d
 d
|}|  }|| f| || f| | G dd dt}| }	||	f|}
dd }t|
|d}
| t	|
d | 
t|
d | | 
t|
d | d S )Nr   rS   r   c                   @   s   e Zd ZdS )z8ComponentsTests.test_subscribers_non_empty.<locals>.IFooNr9   r   r   r   r   r<     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>._DerivedNr9   r   r   r   r   _Derived  s   rL  c                   @   s   e Zd ZdS )z7ComponentsTests.test_subscribers_non_empty.<locals>.BarNr9   r   r   r   r   rH    s   rH  c                 S   s   | j jS r   )r   r"   xr   r   r   
_klassname  s    z>ComponentsTests.test_subscribers_non_empty.<locals>._klassnamer   rl   rY   )rA   r8   r   rB   r   r-  rI  r   r!   r^   r$   r%   )r
   r8   r   r<   rD   r   rL  r,   rH  rJ  rI  rO  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   rS   c                   @   s   e Zd ZdS )zBComponentsTests.test_registerHandler_w_nonblank_name.<locals>.IFooNr9   r   r   r   r   r<   !  s   r<   r:  c                 S   s
   t  d S r   rG   r   r   r   r   rI   &  s    zFComponentsTests.test_registerHandler_w_nonblank_name.<locals>._factoryr   r   )rA   r8   r   rN   rO   registerHandler)r
   r8   r<   rD   r=  r,   rI   r   r   r   $test_registerHandler_w_nonblank_name  s    z4ComponentsTests.test_registerHandler_w_nonblank_namec                 C   s  ddl m} ddlm} ddlm} G dd d|}|d}d}d}d	d
 }|  }	|  \}
}|
" |	j||f|d W d    n1 s0    Y  |	j	j
d | d  | }| t|d | |d |u  | |	j|f|||fg | t|d |d \}}|\}| |i  | t|| | t|j| | |jj|	u  | |jj|f | |jj| | |jj|u  | |jj|u  d S )Nr   rS   rT   HandlerRegistrationc                   @   s   e Zd ZdS )zFComponentsTests.test_registerHandler_w_explicit_required.<locals>.IFooNr9   r   r   r   r   r<   1  s   r<   rX   r?   c                 S   s
   t  d S r   rG   r   r   r   r   rI   6  s    zJComponentsTests.test_registerHandler_w_explicit_required.<locals>._factoryr@   rY   )rA   r8   rZ   rU   r[   rU  r   r   rR  r&   r]   r!   r^   r$   r+   r%   rB   r   r   r   r?   rL   )r
   r8   rU   rU  r<   rD   r1  rE   rI   r,   r   r   r   r   r   ra   r   r   r   (test_registerHandler_w_explicit_required,  s:    0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 d    n1 s~0    Y  |jjd   d  | }	| t	|	d | 
|	d |u  | |j f|||fg | t	|d d S )Nr   rS   c                   @   s   e Zd ZdS )zPComponentsTests.test_registerHandler_wo_explicit_required_no_event.<locals>.IFooNr9   r   r   r   r   r<   Q  s   r<   r?   rX   c                       s   e Zd Z fZdS )zTComponentsTests.test_registerHandler_wo_explicit_required_no_event.<locals>._FactoryNr   r   rD   r   r   r   V  s   r   Fr5  rY   )rA   r8   rB   r   r   rR  r&   r]   r!   r^   r$   r+   )
r
   r8   r<   rE   r1  r   r,   r   r   r   r   rW  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   registeredHandlersr1   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   rS   rT  c                   @   s   e Zd ZdS )z?ComponentsTests.test_registeredHandlers_non_empty.<locals>.IFooNr9   r   r   r   r   r<   l  s   r<   c                 S   s
   t  d S r   rG   r   r   r   r   	_factory1o  s    zDComponentsTests.test_registeredHandlers_non_empty.<locals>._factory1c                 S   s
   t  d S r   rG   r   r   r   r   	_factory2q  s    zDComponentsTests.test_registeredHandlers_non_empty.<locals>._factory2c                 S   s
   | j jjS r   )rL   __code__co_namerM  r   r   r   _factory_namev  s    zHComponentsTests.test_registeredHandlers_non_empty.<locals>._factory_namer   rl   rX   rY   )rA   r8   r[   rU  r   rR  r   rY  r!   r^   r$   r%   r   r   rL   r?   )
r
   r8   rU  r<   rD   r[  r\  r,   r_  rI  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   rS   c                   @   s   e Zd ZdS )zDComponentsTests.test_unregisterHandler_w_nonblank_name.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r:  rQ  )rA   r8   r   rN   rO   unregisterHandler)r
   r8   r<   rD   r=  r,   r   r   r   &test_unregisterHandler_w_nonblank_name  s    
z6ComponentsTests.test_unregisterHandler_w_nonblank_namec                 C   s   |   }| t|j d S r   )r   rN   rO   ra  r1   r   r   r   3test_unregisterHandler_neither_factory_nor_required  s    zCComponentsTests.test_unregisterHandler_neither_factory_nor_requiredc                 C   sH   ddl m} G dd d|}|d}|  }|j|fd}| | d S )Nr   rS   c                   @   s   e Zd ZdS )z9ComponentsTests.test_unregisterHandler_miss.<locals>.IFooNr9   r   r   r   r   r<     s   r<   r   )rA   r8   r   ra  r   )r
   r8   r<   rD   r,   r   r   r   r   test_unregisterHandler_miss  s    z+ComponentsTests.test_unregisterHandler_missc                 C   sD  ddl m} ddlm} ddlm} G dd d|}|d}|  }dd }|  }|||f |  \}}	| |	||f}
W d    n1 s0    Y  | 
|
 | t|	d	 |	d \}}|\}| |i  | 
t|| | 
t|j| | 
|jj|u  | |jj|f | |jjd
 | 
|jj|u  d S )Nr   rS   ru   rT  c                   @   s   e Zd ZdS )zXComponentsTests.test_unregisterHandler_hit_w_factory_and_explicit_provided.<locals>.IFooNr9   r   r   r   r   r<     s   r<   c                 S   s
   t  d S r   rG   r   r   r   r   rI     s    z\ComponentsTests.test_unregisterHandler_hit_w_factory_and_explicit_provided.<locals>._factoryrY   rX   rA   r8   rZ   rv   r[   rU  r   rR  r   ra  r$   r!   r^   r%   rB   r   r   r   rL   r
   r8   rv   rU  r<   rD   r,   rI   r   r   r   r   r   ra   r   r   r   :test_unregisterHandler_hit_w_factory_and_explicit_provided  s.    ,
zJComponentsTests.test_unregisterHandler_hit_w_factory_and_explicit_providedc                 C   sD  ddl m} ddlm} ddlm} G dd d|}|d}|  }dd }|  }|||f |  \}}	| |j	|fd	}
W d    n1 s0    Y  | 
|
 | t|	d
 |	d \}}|\}| |i  | 
t|| | 
t|j| | 
|jj|u  | |jj|f | |jjd | 
|jjd u  d S )Nr   rS   ru   rT  c                   @   s   e Zd ZdS )zQComponentsTests.test_unregisterHandler_hit_w_only_explicit_provided.<locals>.IFooNr9   r   r   r   r   r<     s   r<   c                 S   s
   t  d S r   rG   r   r   r   r   rI     s    zUComponentsTests.test_unregisterHandler_hit_w_only_explicit_provided.<locals>._factoryrd  rY   rX   rf  rg  r   r   r   3test_unregisterHandler_hit_w_only_explicit_provided  s.    ,
zCComponentsTests.test_unregisterHandler_hit_w_only_explicit_providedc                    sP  ddl m} ddlm} ddlm} G dd d|}|d G  fdddt}|  }|| | 	 \}}| |
|}	W d    n1 s0    Y  | |	 | t|d	 |d \}
}|
\}| |i  | t|| | t|j| | |jj|u  | |jj f | |jjd
 | |jjd
 | |jj|u  d S )Nr   rS   ru   rT  c                   @   s   e Zd ZdS )zIComponentsTests.test_unregisterHandler_wo_explicit_required.<locals>.IFooNr9   r   r   r   r   r<     s   r<   c                       s   e Zd Z fZdS )zMComponentsTests.test_unregisterHandler_wo_explicit_required.<locals>._FactoryNr   r   rW  r   r   r     s   r   rY   rX   )rA   r8   rZ   rv   r[   rU  rB   r   rR  r   ra  r$   r!   r^   r%   r   r   r   r?   rL   )r
   r8   rv   rU  r<   r   r,   r   r   r   r   r   ra   r   rW  r   +test_unregisterHandler_wo_explicit_required  s.    
(
z;ComponentsTests.test_unregisterHandler_wo_explicit_requiredc                 C   sf   ddl m} ddl m} G dd d|}|d}|  }||G dd dt}| }||f d S )Nr   rS   r   c                   @   s   e Zd ZdS )z/ComponentsTests.test_handle_empty.<locals>.IFooNr9   r   r   r   r   r<     s   r<   c                   @   s   e Zd ZdS )z.ComponentsTests.test_handle_empty.<locals>.BarNr9   r   r   r   r   rH    s   rH  )rA   r8   r   r   rB   handle)r
   r8   r   r<   rD   r,   rH  rJ  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   rS   r   c                   @   s   e Zd ZdS )z3ComponentsTests.test_handle_non_empty.<locals>.IFooNr9   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>.BarNr9   r   r   r   r   rH  	  s   rH  )rA   r8   r   r   rR  rB   rk  r!   )
r
   r8   r   r<   rD   rn  rp  r,   rH  rJ  r   )rm  ro  r   test_handle_non_empty  s"    
z%ComponentsTests.test_handle_non_empty)r   )sr"   r:   r;   r   r   r   r-   r/   r2   r5   rF   rR   rb   re   rf   ri   rk   rn   rt   rw   ry   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r	  r  r  r  r  r  r  r  r#  r%  r(  r,  r.  r2  r3  r4  r6  r8  r9  r>  r?  r@  rA  rD  rE  rF  rG  rK  rP  rS  rV  rX  rZ  r`  rb  rc  re  rh  ri  rj  rl  rq  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>.ComponentsNr9   r   r   r   r   r   	  s   r   )r|   rr  r   r}   )r
   r   r   r   r   r   	  s    z)UnhashableComponentsTests._getTargetClass)r"   r:   r;   r   r   r   r   r   r   rr  	  s   rr  c                   @   s   e Zd Zdd Zd6ddZdd Zdd	 Zd
d Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Zd*d+ Zd,d- Zd.d/ Zd0d1 Zd2d3 Zd4d5 ZdS )7UtilityRegistrationTestsc                 C   s   ddl m} |S )Nr   rV   )r[   rW   )r
   rW   r   r   r   r   #	  s    z(UtilityRegistrationTests._getTargetClassNc                 C   sb   ddl m} G dd d|}|d}G dd dt}| }d}d	}	|  }
|
|||||	|||fS )
Nr   rS   c                   @   s   e Zd ZdS )zAUtilityRegistrationTests._makeOne.<locals>.InterfaceClassSubclassNr9   r   r   r   r   InterfaceClassSubclass*	  s   rt  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;   rv  r   r   r   r   	_Registry.	  s   rx  r   	DOCSTRINGrA   r8   rB   r   )r
   rK   rL   r8   rt  rD   rx  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~  rZ   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  rZ   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TESTNr9   r   r   r   r   
_ComponentF	  s   r  zAUtilityRegistration(_REGISTRY, IFoo, %r, TEST, None, 'DOCSTRING')rB   r   r!   r0   r
   r  
_componentr  	_registryr`   r   r   r   r2   E	  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   rv  P	  s    zTUtilityRegistrationTests.test___repr___provided_wo_name.<locals>._Component.__repr__Nrw  r   r   r   r   r  O	  s   r  AUtilityRegistration(_REGISTRY, None, %r, TEST, None, 'DOCSTRING')rB   r   r_   r!   r0   r  r   r   r   test___repr___provided_wo_nameN	  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   rv  [	  s    zUUtilityRegistrationTests.test___repr___component_wo_name.<locals>._Component.__repr__Nrw  r   r   r   r   r  Z	  s   r  r  r  r  r   r   r   test___repr___component_wo_nameY	  s    
z8UtilityRegistrationTests.test___repr___component_wo_namec                 C   s.   t  }| |\}}}| | t| d S r   rB   r   r!   __hash__idr
   r  r  r  r`   r   r   r   test___hash__d	  s    z&UtilityRegistrationTests.test___hash__c                 C   s(   t  }| |\}}}| ||k d S r   rB   r   r$   r  r   r   r   test___eq___identityi	  s    z-UtilityRegistrationTests.test___eq___identityc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r
   r  r  r  r`   ur2r  r   r   r   test___eq___hitn	  s    z(UtilityRegistrationTests.test___eq___hitc                 C   s>   t  }t  }| |\}}}| |\}}}| ||k d S r   rB   r   r   r
   r  _component2r  r  r`   r  r  r   r   r   test___eq___misst	  s
    z)UtilityRegistrationTests.test___eq___missc                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   test___ne___identity{	  s    z-UtilityRegistrationTests.test___ne___identityc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r  r   r   r   test___ne___hit	  s    z(UtilityRegistrationTests.test___ne___hitc                 C   s>   t  }t  }| |\}}}| |\}}}| ||k d S r   r  r  r   r   r   test___ne___miss	  s
    z)UtilityRegistrationTests.test___ne___missc                 C   s(   t  }| |\}}}| ||k  d S r   r  r  r   r   r   test___lt___identity	  s    z-UtilityRegistrationTests.test___lt___identityc                 C   s8   t  }| |\}}}| |\}}}| ||k  d S r   r  r  r   r   r   test___lt___hit	  s    z(UtilityRegistrationTests.test___lt___hitc                 C   sH   t  }t  }| |\}}}| |\}}}|d |_| ||k  d S N2rB   r   r   r$   r  r   r   r   test___lt___miss	  s    
z)UtilityRegistrationTests.test___lt___missc                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   test___le___identity	  s    z-UtilityRegistrationTests.test___le___identityc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r  r   r   r   test___le___hit	  s    z(UtilityRegistrationTests.test___le___hitc                 C   sH   t  }t  }| |\}}}| |\}}}|d |_| ||k d S r  r  r  r   r   r   test___le___miss	  s    
z)UtilityRegistrationTests.test___le___missc                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   test___gt___identity	  s    z-UtilityRegistrationTests.test___gt___identityc                 C   sH   t  }t  }| |\}}}| |\}}}|d |_| ||k d S r  r  r  r   r   r   test___gt___hit	  s    
z(UtilityRegistrationTests.test___gt___hitc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r  r   r   r   test___gt___miss	  s    z)UtilityRegistrationTests.test___gt___missc                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   test___ge___identity	  s    z-UtilityRegistrationTests.test___ge___identityc                 C   sH   t  }t  }| |\}}}| |\}}}|d |_| ||k d S r  rB   r   r   r   r  r   r   r   test___ge___miss	  s    
z)UtilityRegistrationTests.test___ge___missc                 C   sB   t  }| |\}}}| |\}}}|d |_| ||k d S r  r  r  r   r   r   test___ge___hit	  s
    
z(UtilityRegistrationTests.test___ge___hit)NN)r"   r:   r;   r   r   r  r  r2   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   rs  !	  s4   
	rs  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   	  s    z(AdapterRegistrationTests._getTargetClassNc                 C   sl   ddl m} G dd d|}|d}|d}G dd dt}| }d}d	}	|  }
|
||f||||	||fS )
Nr   rS   c                   @   s   e Zd ZdS )z/AdapterRegistrationTests._makeOne.<locals>.IFooNr9   r   r   r   r   r<   	  s   r<   r   c                   @   s   e Zd Zdd ZdS )z4AdapterRegistrationTests._makeOne.<locals>._Registryc                 S   s   dS ru  r   r	   r   r   r   rv  	  s    z=AdapterRegistrationTests._makeOne.<locals>._Registry.__repr__Nrw  r   r   r   r   rx  	  s   rx  r   ry  rz  r
   rK   r8   r<   rD   r   rx  r   r   r{  r|  r   r   r   r   	  s    z!AdapterRegistrationTests._makeOnec                 C   s*   ddl m} ddlm} |||   d S )Nr   r}  IAdapterRegistration)r  r~  rZ   r  r   )r
   r~  r  r   r   r   +test_class_conforms_to_IAdapterRegistration	  s    zDAdapterRegistrationTests.test_class_conforms_to_IAdapterRegistrationc                 C   s4   ddl m} ddlm} |  \}}}||| d S )Nr   r  r  )r  r  rZ   r  r   )r
   r  r  arr  r   r   r   .test_instance_conforms_to_IAdapterRegistration	  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  Nr9   r   r   r   r   r   
  s   r  zCAdapterRegistration(_REGISTRY, [IBar], IFoo, %r, TEST, 'DOCSTRING')r  r
   r  r  r  r  r`   r   r   r   r2   	  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   rv  

  s    zTAdapterRegistrationTests.test___repr___provided_wo_name.<locals>._Component.__repr__Nrw  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   rv  
  s    zUAdapterRegistrationTests.test___repr___component_wo_name.<locals>._Component.__repr__Nrw  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  r`   r   r   r   r  
  s    z&AdapterRegistrationTests.test___hash__c                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   r  #
  s    z-AdapterRegistrationTests.test___eq___identityc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r
   r  r  r  r`   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  r`   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  5
  s    z-AdapterRegistrationTests.test___ne___identityc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r  r   r   r   r  :
  s    z)AdapterRegistrationTests.test___ne___missc                 C   s>   t  }t  }| |\}}}| |\}}}| ||k d S r   r  r  r   r   r   test___ne___hit_component@
  s
    z2AdapterRegistrationTests.test___ne___hit_componentc           
      C   sb   ddl m} G dd d|}|d}t }| |\}}}| |\}}	}	||_| ||k d S )Nr   rS   c                   @   s   e Zd ZdS )z?AdapterRegistrationTests.test___ne___hit_provided.<locals>.IFooNr9   r   r   r   r   r<   I
  s   r<   r  )rA   r8   rB   r   r_   r$   )
r
   r8   r<   r  r  r  r  r`   r  r  r   r   r   test___ne___hit_providedG
  s    z1AdapterRegistrationTests.test___ne___hit_providedc                 C   sj   ddl m} G dd d|}|d}t }t }| |\}}}| |\}	}
}
|f|	_| ||	k d S )Nr   rS   c                   @   s   e Zd ZdS )z?AdapterRegistrationTests.test___ne___hit_required.<locals>.IFooNr9   r   r   r   r   r<   T
  s   r<   r  )rA   r8   rB   r   r   r$   )r
   r8   r<   r  r  r  r  r  r`   r  r  r   r   r   test___ne___hit_requiredR
  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  c
  s    z(AdapterRegistrationTests.test___lt___hitc                 C   sH   t  }t  }| |\}}}| |\}}}|d |_| ||k  d S r  r  r  r   r   r   r  i
  s    
z)AdapterRegistrationTests.test___lt___missc                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   r  q
  s    z-AdapterRegistrationTests.test___le___identityc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r  r   r   r   r  v
  s    z(AdapterRegistrationTests.test___le___hitc                 C   sH   t  }t  }| |\}}}| |\}}}|d |_| ||k d S r  r  r  r   r   r   r  |
  s    
z)AdapterRegistrationTests.test___le___missc                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   r  
  s    z-AdapterRegistrationTests.test___gt___identityc                 C   sH   t  }t  }| |\}}}| |\}}}|d |_| ||k d S r  r  r  r   r   r   r  
  s    
z(AdapterRegistrationTests.test___gt___hitc                 C   s8   t  }| |\}}}| |\}}}| ||k d S r   r  r  r   r   r   r  
  s    z)AdapterRegistrationTests.test___gt___missc                 C   s(   t  }| |\}}}| ||k d S r   r  r  r   r   r   r  
  s    z-AdapterRegistrationTests.test___ge___identityc                 C   sH   t  }t  }| |\}}}| |\}}}|d |_| ||k d S r  r  r  r   r   r   r  
  s    
z)AdapterRegistrationTests.test___ge___missc                 C   sB   t  }| |\}}}| |\}}}|d |_| ||k d S r  r  r  r   r   r   r  
  s
    
z(AdapterRegistrationTests.test___ge___hit)N)r"   r:   r;   r   r   r  r  r2   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  	  s8   
	r  c                   @   s.   e Zd Zdd Zd
ddZdd Zdd	 ZdS )SubscriptionRegistrationTestsc                 C   s   ddl m} |S )Nr   r/  )r[   r0  )r
   r0  r   r   r   r   
  s    z-SubscriptionRegistrationTests._getTargetClassNc                 C   sl   ddl m} G dd d|}|d}|d}G dd dt}| }d}d	}	|  }
|
||f||||	||fS )
Nr   rS   c                   @   s   e Zd ZdS )z4SubscriptionRegistrationTests._makeOne.<locals>.IFooNr9   r   r   r   r   r<   
  s   r<   r   c                   @   s   e Zd Zdd ZdS )z9SubscriptionRegistrationTests._makeOne.<locals>._Registryc                 S   s   dS ru  r   r	   r   r   r   rv  
  s    zBSubscriptionRegistrationTests._makeOne.<locals>._Registry.__repr__Nrw  r   r   r   r   rx  
  s   rx  r   ry  rz  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~  rZ   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  rZ   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   rT  )r[   rU  )r
   rU  r   r   r   r   
  s    z(HandlerRegistrationTests._getTargetClassNc           
      C   sb   ddl m} G dd d|}|d}G dd dt}| }d}d}|  }	|	||f|||||fS )	Nr   rS   c                   @   s   e Zd ZdS )z/HandlerRegistrationTests._makeOne.<locals>.IFooNr9   r   r   r   r   r<   
  s   r<   c                   @   s   e Zd Zdd ZdS )z4HandlerRegistrationTests._makeOne.<locals>._Registryc                 S   s   dS ru  r   r	   r   r   r   rv  
  s    z=HandlerRegistrationTests._makeOne.<locals>._Registry.__repr__Nrw  r   r   r   r   rx  
  s   rx  r   ry  rz  )
r
   rK   r8   r<   rD   rx  r   r   r{  r|  r   r   r   r   
  s    z!HandlerRegistrationTests._makeOnec                 C   s*   ddl m} ddlm} |||   d S )Nr   r}  IHandlerRegistration)r  r~  rZ   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  rZ   r  r   )r
   r  r  hrr  r   r   r   .test_instance_conforms_to_IHandlerRegistration
  s    zGHandlerRegistrationTests.test_instance_conforms_to_IHandlerRegistrationc                 C   sN   dd }|  |\}}}| |j|u  | |j|ju  | |jd u  d S )Nc                 S   s
   t  d S r   rG   r   r   r   r   rI   
  s    z:HandlerRegistrationTests.test_properties.<locals>._factory)r   r$   ZhandlerrL   r_   )r
   rI   r  r  r   r   r   test_properties
  s
    z(HandlerRegistrationTests.test_propertiesc                 C   s:   G dd dt }| | \}}}| t|d|  d S )Nc                   @   s   e Zd ZdZ dS )zGHandlerRegistrationTests.test___repr___factory_w_name.<locals>._Factoryr  Nr9   r   r   r   r   r   
  s   r   =HandlerRegistration(_REGISTRY, [IFoo], %r, TEST, 'DOCSTRING')r  r
   r   r  r  r`   r   r   r   test___repr___factory_w_name
  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   rv    s    zQHandlerRegistrationTests.test___repr___factory_wo_name.<locals>._Factory.__repr__Nrw  r   r   r   r   r     s   r   r  r  r  r   r   r   test___repr___factory_wo_name  s    
z6HandlerRegistrationTests.test___repr___factory_wo_name)N)
r"   r:   r;   r   r   r  r  r  r  r  r   r   r   r   r  
  s   
r  c                   @   s   e Zd Zdd Zdd ZdS )PersistentAdapterRegistryc                 C   sF   | j  }t|D ]"}|| jv s*|dr|| q|dd  |S )NZ_vZ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 )PersistentDictComponentsNr9   r   r   r   r   r  &  s   r  c                   @   s   e Zd Zdd ZdS )PersistentComponentsDictc                 C   s   t |  t| | d S r   )r}   r   r  )r
   r   r   r   r   r   -  s    
z!PersistentComponentsDict.__init__Nr   r   r   r   r   r  +  s   r  c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestPersistentComponentsc                 C   s   t dS )Nr   )r  r	   r   r   r   r   3  s    z!TestPersistentComponents._makeOnec                 C   s   d S r   r   r
   Zmader   r   r   _check_equality_after_pickle6  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_empty9  s
    
z+TestPersistentComponents.test_pickles_emptyc                 C   s   dd l }|  }t }||t | ||t |||}| 	|j
d | |t ||t | ||t | | d S r  )r  r   rB   rC   r   r   r   r  r  r!   r"   ZassertIsNotNoner  )r
   r  r,   Zutilityr  r   r   r   &test_pickles_with_utility_registrationA  s*    z?TestPersistentComponents.test_pickles_with_utility_registrationN)r"   r:   r;   r   r  r  r  r   r   r   r   r  1  s   r  c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestPersistentDictComponentsc                 C   s   t S r   )r  r	   r   r   r   r   ^  s    z,TestPersistentDictComponents._getTargetClassc                 C   s   |   dd}d|d< |S )Nr   r   *   r   r   r1   r   r   r   r   a  s    z%TestPersistentDictComponents._makeOnec                 C   s    |  d| | |d d d S )Nr   r  )ZassertInr!   r  r   r   r   r  f  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   l  s    z,TestPersistentComponentsDict._getTargetClassN)r"   r:   r;   r   r   r   r   r   r  j  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  r   z$_Monkey.__init__.<locals>.<listcomp>)r  r}   
to_restoreitemssetattr)r
   r  r   r   valuer   r  r   r   q  s    z_Monkey.__init__c                 C   s   | S r   r   r	   r   r   r   	__enter__w  s    z_Monkey.__enter__c                 C   s&   | j  D ]\}}t| j|| q
d S r   )r  r  r  r  )r
   exc_typeZexc_valZexc_tbr   r  r   r   r   __exit__z  s    z_Monkey.__exit__N)r"   r:   r;   r   r  r  r   r   r   r   r   o  s   r   )__doc__Zunittestr   r   r    r   r[   r   ZTestCaser   rr  rs  r  r  r  r  r  r}   r  r  r  r  r  rB   r   r   r   r   r   <module>   sL                      ; R%<+