U
    [e7                    @   s$  d Z ddlZddlmZ dd ZG dd deZG dd	 d	eZG d
d deZG dd deZ	G dd de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eZG dd dejZG dd dee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jZdS )$zAdapter registry tests
    N)OptimizationTestMixinc            
   	   C   s   ddl m}  G dd d| }G dd d|}G dd d|}G d	d
 d
||}G dd d||}G dd d| }G dd d|}G dd d| }G dd d|}	|||||||||	f	S )Nr   	Interfacec                   @   s   e Zd ZdS )z_makeInterfaces.<locals>.IB0N__name__
__module____qualname__ r	   r	   c/var/www/html/services/stratfitenv/lib/python3.8/site-packages/zope/interface/tests/test_adapter.pyIB0   s   r   c                   @   s   e Zd ZdS )z_makeInterfaces.<locals>.IB1Nr   r	   r	   r	   r
   IB1   s   r   c                   @   s   e Zd ZdS )z_makeInterfaces.<locals>.IB2Nr   r	   r	   r	   r
   IB2   s   r   c                   @   s   e Zd ZdS )z_makeInterfaces.<locals>.IB3Nr   r	   r	   r	   r
   IB3    s   r   c                   @   s   e Zd ZdS )z_makeInterfaces.<locals>.IB4Nr   r	   r	   r	   r
   IB4"   s   r   c                   @   s   e Zd ZdS )z_makeInterfaces.<locals>.IF0Nr   r	   r	   r	   r
   IF0%   s   r   c                   @   s   e Zd ZdS )z_makeInterfaces.<locals>.IF1Nr   r	   r	   r	   r
   IF1'   s   r   c                   @   s   e Zd ZdS )z_makeInterfaces.<locals>.IR0Nr   r	   r	   r	   r
   IR0*   s   r   c                   @   s   e Zd ZdS )z_makeInterfaces.<locals>.IR1Nr   r	   r	   r	   r
   IR1,   s   r   )zope.interfacer   )
r   r   r   r   r   r   r   r   r   r   r	   r	   r
   _makeInterfaces   s    r   c                   @   sH   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dS )CustomDataTypeBaseNc                 C   s
   | j | S N_dataselfnamer	   r	   r
   __getitem__7   s    zCustomDataTypeBase.__getitem__c                 C   s   || j |< d S r   r   )r   r   valuer	   r	   r
   __setitem__:   s    zCustomDataTypeBase.__setitem__c                 C   s   | j |= d S r   r   r   r	   r	   r
   __delitem__=   s    zCustomDataTypeBase.__delitem__c                 C   s
   t | jS r   )lenr   r   r	   r	   r
   __len__@   s    zCustomDataTypeBase.__len__c                 C   s
   || j kS r   r   r   r	   r	   r
   __contains__C   s    zCustomDataTypeBase.__contains__c                 C   s,   || krdS t |t | kr dS |j| jkS )NTF)typer   r   otherr	   r	   r
   __eq__F   s
    zCustomDataTypeBase.__eq__c                 C   s
   t | jS r   )reprr   r"   r	   r	   r
   __repr__N   s    zCustomDataTypeBase.__repr__)r   r   r   r   r   r   r    r#   r$   r(   r*   r	   r	   r	   r
   r   5   s   r   c                   @   s   e Zd ZdddZdS )CustomMappingNc                 C   s.   i | _ |r| j | | j j| _| j j| _d S r   )r   updategetitemsr&   r	   r	   r
   __init__R   s
    
zCustomMapping.__init__)Nr   r   r   r/   r	   r	   r	   r
   r+   Q   s   r+   c                   @   s   e Zd ZdddZdS )CustomSequenceNc                 C   s$   g | _ |r| j | | j j| _d S r   )r   extendappendr&   r	   r	   r
   r/   [   s    zCustomSequence.__init__)Nr0   r	   r	   r	   r
   r1   Z   s   r1   c                   @   s   e Zd ZdS )CustomLeafSequenceNr   r	   r	   r	   r
   r4   a   s   r4   c                   @   s   e Zd ZdS )CustomProvidedNr   r	   r	   r	   r
   r5   d   s   r5   c                   @   sd  e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd ZdWddZdXddZdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"dAdB Z#dCdD Z$dEdF Z%dGdH Z&dIdJ Z'dKdL Z(dMdN Z)dOdP Z*dQdR Z+dSdT Z,dUdV Z-dS )YBaseAdapterRegistryTestsNc                 C   s   ddl m} |S )Nr   BaseAdapterRegistryzope.interface.adapterr8   )r   r8   r	   r	   r
   _getBaseAdapterRegistryl   s    z0BaseAdapterRegistryTests._getBaseAdapterRegistryc                 C   s8   |   }G dd d|}|jD ]}t|j|t  q|S )Nc                   @   s   e Zd ZG dd deZdS )z6BaseAdapterRegistryTests._getTargetClass.<locals>._CUTc                   @   s4   e Zd Zd ZZdd Zdd Zdd Zdd	 Zd
S )zBBaseAdapterRegistryTests._getTargetClass.<locals>._CUT.LookupClassr	   c                 S   s   d S r   r	   )r   regr	   r	   r
   r/   u   s    zKBaseAdapterRegistryTests._getTargetClass.<locals>._CUT.LookupClass.__init__c                 S   s   |  j |f7  _ d S r   _changed)r   origr	   r	   r
   changedw   s    zJBaseAdapterRegistryTests._getTargetClass.<locals>._CUT.LookupClass.changedc                 S   s   |  j |f7  _ d S r   )
_extendorsr   providedr	   r	   r
   add_extendory   s    zOBaseAdapterRegistryTests._getTargetClass.<locals>._CUT.LookupClass.add_extendorc                    s   t  fdd| jD | _d S )Nc                    s   g | ]}| kr|qS r	   r	   ).0xrC   r	   r
   
<listcomp>|   s    zfBaseAdapterRegistryTests._getTargetClass.<locals>._CUT.LookupClass.remove_extendor.<locals>.<listcomp>)tuplerA   rB   r	   rG   r
   remove_extendor{   s    zRBaseAdapterRegistryTests._getTargetClass.<locals>._CUT.LookupClass.remove_extendorN)	r   r   r   r>   rA   r/   r@   rD   rJ   r	   r	   r	   r
   LookupClasss   s
   rK   N)r   r   r   objectrK   r	   r	   r	   r
   _CUTr   s   rM   )r;   
_delegatedsetattrrK   rL   )r   r8   rM   r   r	   r	   r
   _getTargetClassp   s
    
z(BaseAdapterRegistryTests._getTargetClassc                 C   s
   |    S r   rP   r"   r	   r	   r
   _makeOne   s    z!BaseAdapterRegistryTests._makeOnec                 C   s   t S r   dictr"   r	   r	   r
   _getMappingType   s    z(BaseAdapterRegistryTests._getMappingTypec                 C   s   t S r   rS   r"   r	   r	   r
   _getProvidedType   s    z)BaseAdapterRegistryTests._getProvidedTypec                 C   s   t S r   )listr"   r	   r	   r
   _getMutableListType   s    z,BaseAdapterRegistryTests._getMutableListTypec                 C   s   t S r   )rI   r"   r	   r	   r
   _getLeafSequenceType   s    z-BaseAdapterRegistryTests._getLeafSequenceTypec                 C   s8   |   }| }|jD ]}| t||t|j| qd S r   )rP   rN   assertIsgetattr	_v_lookup)r   ZCUTregistryr   r	   r	   r
   test_lookup_delegation   s    
z/BaseAdapterRegistryTests.test_lookup_delegationc                 C   s   |   }| |jd d S N   )rR   assertEqual_generationr   r]   r	   r	   r
   "test__generation_on_first_creation   s    z;BaseAdapterRegistryTests.test__generation_on_first_creationc                 C   s>   |   }t }|| | |jd | |jj||f d S N   )rR   rL   r@   ra   rb   r\   r>   )r   r]   r?   r	   r	   r
   &test__generation_after_calling_changed   s
    
z?BaseAdapterRegistryTests.test__generation_after_calling_changedc                 C   s2   G dd dt }|  }|f|_| |jd d S )Nc                   @   s   e Zd ZdS )zQBaseAdapterRegistryTests.test__generation_after_changing___bases__.<locals>._BaseNr   r	   r	   r	   r
   _Base   s   rh   rf   )rL   rR   	__bases__ra   rb   )r   rh   r]   r	   r	   r
   )test__generation_after_changing___bases__   s    zBBaseAdapterRegistryTests.test__generation_after_changing___bases__rf   c                 C   s   |  t|j| | |j|   |  }|jD ]}| || q2|  |jd |  | |jd | |  t|j|d  d d S Nr   r`   )ra   r!   	_adaptersassertIsInstancerX   rU   r   r]   expected_orderMTmappingr	   r	   r
   _check_basic_types_of_adapters   s    
z7BaseAdapterRegistryTests._check_basic_types_of_adaptersc                 C   s   |  t|j| | |j|   |  }|jD ]}| || q2|r|  |jd |  | |jd | |  t|j|d  d d S rk   )ra   r!   _subscribersrm   rX   rU   rn   r	   r	   r
   !_check_basic_types_of_subscribers   s    
z:BaseAdapterRegistryTests._check_basic_types_of_subscribersc              
   C   s   t  \	}}}}}}}}}	|  }
|
|g|dd | |
|g|dd | |
jd | |
 |  }| |
jd |||||ddiii | 	 }| |
j
||di t|
 }| ||f|ddfg d S )N A1rf   r`   )r   rR   registerra   
registeredrb   rr   rU   rl   rV   	_providedrW   allRegistrations)r   r   r   r   r   r   r   r   r   r   r]   rp   PTrx   r	   r	   r
   test_register   s4    
  

 z&BaseAdapterRegistryTests.test_registerc           
         s&  t  \	 }}}|  }|g dd |g dd | gdd | gdd | gdd | gdd | gdd | gdd | gd	d | gdd  fd
d}| |j||  |  d t| }| |dddfdddf fddf fddf fddf fddf fddf fddf fd	df fddfg
 |  }|D ]}|j|  q| |j|j | |j	|j	 t
|_t|_t|_t|_dd }	|	|_|  | |j|tt
d d S )Nru   rv   name1A2name2A3name3A4name4c                    s   | ||dddi| ||ddd|dddii| |||ddii||d	di|d
dii||ddiiiigS )Nrv   r~   )ru   r}   )ru   r   r   r   )ru   r   ru   r   r   r	   Lrp   r   r   r   r   r   r   r	   r
   build_adapters   s\           
  
 
  
zXBaseAdapterRegistryTests.test_register_multiple_allRegistrations.<locals>.build_adaptersr   r	   c                 S   s    | d k	r| nt  } | | | S r   r4   r3   existingnewr	   r	   r
   addValue1  s    
zRBaseAdapterRegistryTests.test_register_multiple_allRegistrations.<locals>.addValue)r   rR   rw   ra   rl   rX   rU   sortedrz   ry   r+   _mappingTyper4   _leafSequenceTyper1   _sequenceTyper5   _providedType_addValueToLeafrebuild)
r   r   r   r   r]   r   rx   	registry2argsr   r	   r   r
   'test_register_multiple_allRegistrations   sb    '

z@BaseAdapterRegistryTests.test_register_multiple_allRegistrationsc              	   C   sN   t  \	}}}}}}}}}	|  }
| t |
|g|t d W 5 Q R X d S Nrv   )r   rR   assertRaises
ValueErrorrw   rL   r   r   r   r   r   r   r   r   r   r   r]   r	   r	   r
   test_register_with_invalid_name?  s    z8BaseAdapterRegistryTests.test_register_with_invalid_namec              	   C   s   t  \	}}}}}}}}}	|  }
|
d g|dd |
d g|dd  | t|
jd | |
j|   t|
	 }| |g  d S )Nru   rv   r   )
r   rR   rw   ra   r!   rl   rm   rX   rW   rz   )r   r   r   r   r   r   r   r   r   r   r]   rx   r	   r	   r
   )test_register_with_value_None_unregistersE  s    zBBaseAdapterRegistryTests.test_register_with_value_None_unregistersc              
   C   s   ddl m} t \	}}}}}}}}	}
|  }t }|d g|	d| |j}|d g|	d| | |j| | | | 	 }| |j
d ||||	|d|iii t| }| ||f|	d|fg d S )Nr   r   ru   r`   )r   r   r   rR   rL   rw   rb   ra   rr   rU   rl   rW   rz   )r   r   r   r   r   r   r   r   r   r   r   r]   _valueZ_beforerp   rx   r	   r	   r
   test_register_with_same_valueO  s4    
  
	z6BaseAdapterRegistryTests.test_register_with_same_valuec                 C   s<   |   }| |d gd dd  t| }| |g  d S Nru   )rR   ra   rx   rW   rz   )r   r]   rx   r	   r	   r
   test_registered_emptyl  s    z.BaseAdapterRegistryTests.test_registered_emptyc              	   C   sN   t  \	}}}}}}}}}	|  }
|
|gd dd | |
|gd dd  d S Nru   rv   )r   rR   rw   ra   rx   r   r	   r	   r
   test_registered_non_empty_missr  s    z7BaseAdapterRegistryTests.test_registered_non_empty_missc                 C   s6   |   }|d gd dd | |d gd dd d S r   )rR   rw   ra   rx   rc   r	   r	   r
   test_registered_non_empty_hitx  s    z6BaseAdapterRegistryTests.test_registered_non_empty_hitc                 C   sF   |   }|d gd d | |d gd dd  | t|jd d S )Nru   r   )rR   
unregisterra   rx   r!   ry   rc   r	   r	   r
   test_unregister_empty}  s    z.BaseAdapterRegistryTests.test_unregister_emptyc              
   C   s   t  \	}}}}}}}}}	|  }
|
|gd dd |
|gd d | |
|gd dd | |
 |  }| |
jd |||d |ddiii | 	 }| |
j
|d di d S )Nru   rv   r`   r   rR   rw   r   ra   rx   rr   rU   rl   rV   ry   r   r   r   r   r   r   r   r   r   r   r]   rp   r{   r	   r	   r
   *test_unregister_non_empty_miss_on_required  s*    
  
	
 zCBaseAdapterRegistryTests.test_unregister_non_empty_miss_on_requiredc              
   C   s   t  \	}}}}}}}}}	|  }
|
|gd dd |
|gd d | |
|gd dd | |
 |  }| |
jd |||d |ddiii | 	 }| |
j
|d di d S )Nru   rv   Znonesuchr`   r   r   r	   r	   r
   &test_unregister_non_empty_miss_on_name  s*    
  
	
 z?BaseAdapterRegistryTests.test_unregister_non_empty_miss_on_namec              	   C   sl   t  \	}}}}}}}}}	|  }
t }t }|
|gd d| |
|gd d| | |
|gd d| d S r   )r   rR   rL   rw   r   rZ   rx   r   r   r   r   r   r   r   r   r   r   r]   r?   Znomatchr	   r	   r
   (test_unregister_with_value_not_None_miss  s    zABaseAdapterRegistryTests.test_unregister_with_value_not_None_missc                 C   s  t  \	}}}}}}}}}	|  }
t }t }|
||gd d| |
||gd d| | j|
dd | ||
jd |  | ||
jd |  |  }| |
jd |||||d |d|ii||d |d|iiii | 	 }| |
j
|d di |
||gd d| | ||
jd |  | ||
jd |  | |
jd |||||d |d|iiii | |
j
|d di d S )Nru      ro   rf   r`   )r   rR   rL   rw   rr   assertInrl   rU   ra   rV   ry   r   ZassertNotIn)r   r   r   r   r   r   r   r   r   r   r]   oneZanotherrp   r{   r	   r	   r
   .test_unregister_hit_clears_empty_subcomponents  sT       

   	
 zGBaseAdapterRegistryTests.test_unregister_hit_clears_empty_subcomponentsc                 C   sB   |   }|d gd d | |d gd dd  | j|dd d S )Nru   r   r   )rR   unsubscribera   rx   rt   rc   r	   r	   r
   test_unsubscribe_empty  s    z/BaseAdapterRegistryTests.test_unsubscribe_emptyc                 C   s   t  \	}}}}}}}}}	|  }
t }|
|gd | |  }|  }|  }| |
 | |
j	d |||d |d||fiii | |
j
|i  |
|gd | | t|
j	d | |
j
|i  d S )Nr`   ru   r   )r   rR   rL   	subscriberU   rY   rV   rt   ra   rs   ry   r   r!   )r   r   r   r   r   r   r   r   r   r   r]   r?   rp   r   r{   r	   r	   r
   test_unsubscribe_hit  s,    
   z-BaseAdapterRegistryTests.test_unsubscribe_hitc                 C   s   |  || dS )a  
        Implementations may choose to use new, immutable objects
        instead of mutating existing subscriber leaf objects, or vice versa.

        The default implementation uses immutable tuples, so they are never
        the same. Other implementations may use persistent lists so they should be
        the same and mutated in place. Subclasses testing this behaviour need to
        override this method.
        N)ZassertIsNotr   Zleaf1Zleaf2r	   r	   r
   assertLeafIdentity  s    
z+BaseAdapterRegistryTests.assertLeafIdentityc                 C   s*  t  \	}}}}}}}}}	|  }
t }t }t }t }|
|gd | |
|gd | |
|g|| |
|g|| | j|
dd |  }|  }|  }| |
j	d |||d |d|||fi||d|||fiii | |
j
||di |
j	d | | d }|
j	d | d  d }|
|gd | |
|g|| | |
j	d |||d |d||fi||d||fiii | |
j
||di |
j	d | | d }|
j	d | d  d }| || | || |
|gd | |
|g|| | t|
j	d | t|
j
d d S )Nrf   r   r`   ru   r   )r   rR   rL   r   rt   rU   rY   rV   ra   rs   ry   r   r   r!   )r   r   r   r   r   r   r   r   r   r   r]   firstsecondthirdZfourthrp   r   r{   ZIR0_leaf_origZNon_leaf_origZIR0_leaf_newZNon_leaf_newr	   r	   r
   test_unsubscribe_after_multiple	  sh       
    
 z8BaseAdapterRegistryTests.test_unsubscribe_after_multiplec                 C   s   t  \	}}}}}}}}}	|  }
t }|
|g|| |
|g|| |  }|  }|  }| |
jd |||||d|||fiii | |
j	||di |

|g|| |

|g|| | t|
jd | |
j	|  d S Nr`   ru   rf   r   r   rR   rL   r   rU   rY   rV   ra   rs   ry   r   r!   )r   r   r   r   r   r   r   r   r   r   r]   r   rp   r   r{   r	   r	   r
   5test_subscribe_unsubscribe_identical_objects_provided=  s.      
 zNBaseAdapterRegistryTests.test_subscribe_unsubscribe_identical_objects_providedc                 C   s   t  \	}}}}}}}}}	|  }
t }t }|
|g|| |
|g|| |  }|  }|  }| |
jd |||||d|||fiii | |
j	||di |

|g|| |

|g|| | t|
jd | |
j	|  d S r   r   )r   r   r   r   r   r   r   r   r   r   r]   r   r   rp   r   r{   r	   r	   r
   4test_subscribe_unsubscribe_nonequal_objects_providedV  s0      
 zMBaseAdapterRegistryTests.test_subscribe_unsubscribe_nonequal_objects_providedc                 C   s:   |   }| |d gd d t| }| |g  d S r   )rR   assertIsNone
subscribedrW   allSubscriptionsra   )r   r]   r   r	   r	   r
   test_subscribed_emptyp  s    z.BaseAdapterRegistryTests.test_subscribed_emptyc              	   C   sv   t  \	}}}}}}}}}	|  }
|
|g|d | |
|g|d | |
|g|d | |
|g|d d S )Nrv   ru   )r   rR   r   r   r   r   r	   r	   r
   test_subscribed_non_empty_missv  s    z7BaseAdapterRegistryTests.test_subscribed_non_empty_missc              	   C   sL   t  \	}}}}}}}}}	|  }
|
|g|d | |
|g|dd d S r   )r   rR   r   ra   r   r   r	   r	   r
   test_subscribed_non_empty_hit  s    z6BaseAdapterRegistryTests.test_subscribed_non_empty_hitc              	   C   s~   t  \	}}}}}}}}}	|  }
t }t }|
|gd | |
|gd | | j|
dd |
|gd  | t|
jd d S )Nrf   r   r   )	r   rR   rL   r   rt   r   ra   r!   rs   )r   r   r   r   r   r   r   r   r   r   r]   r   r   r	   r	   r
   &test_unsubscribe_w_None_after_multiple  s    z?BaseAdapterRegistryTests.test_unsubscribe_w_None_after_multiplec                 C   s   t  \	}}}}}}}}}	|  }
|
|gd d | j|
dd |
|gd d | t|
jd |  }| 	 }| |
jd |||d |d|diii d S )Nrv   rf   r   ru   r`   rv   
r   rR   r   rt   r   ra   r!   rs   rU   rY   r   r   r   r   r   r   r   r   r   r   r]   rp   r   r	   r	   r
   +test_unsubscribe_non_empty_miss_on_required  s      zDBaseAdapterRegistryTests.test_unsubscribe_non_empty_miss_on_requiredc                 C   s   t  \	}}}}}}}}}	|  }
|
|gd d | j|
dd |
|gd d | t|
jd |  }| 	 }| |
jd |||d |d|diii d S )Nrv   rf   r   r~   r`   ru   r   r   r   r	   r	   r
   (test_unsubscribe_non_empty_miss_on_value  s      zABaseAdapterRegistryTests.test_unsubscribe_non_empty_miss_on_valuec              	   C   sb   t  \	}}}}}}}}}	|  }
t }t }|
|gd | |
|gd | | t|
jd d S re   )r   rR   rL   r   r   ra   r!   rs   r   r	   r	   r
   )test_unsubscribe_with_value_not_None_miss  s    zBBaseAdapterRegistryTests.test_unsubscribe_with_value_not_None_missc                 C   s   |  d d S )Nz*Example method, not intended to be called.Zfailr"   r	   r	   r
   _instance_method_notify_target  s    z7BaseAdapterRegistryTests._instance_method_notify_targetc              	   C   sl   t  \	}}}}}}}}}	|  }
| t|
jd |
|gd | j |
|gd | j | t|
jd d S Nr   )r   rR   ra   r!   rs   r   r   r   r   r	   r	   r
    test_unsubscribe_instance_method  s    z9BaseAdapterRegistryTests.test_unsubscribe_instance_methodc                    s,  t  \	 }}}|  }|g d |g d | gd | gd | gd | gd | gd | gd | gd | gd  fdd}| |j||  |  |  d fdd	}| |j|| 	 d
 t
| }| |ddfddf fdf fdf fdf fdf fdf fdf fdf fdfg
 |  }|D ]}	|j|	  q| |j|j | |j|j t|_t|_t|_t|_dd }
|
|_|  | |j|tttd d S )Nrv   r~   r   r   c                    s   | ||d|ddgii| ||d|ddgi|d|ddgiii| |||d|dgii||d|dgi|d|dgii||d|dgiiiigS )Nru   rv   r~   r   r   r	   r   Frp   r   r	   r
   build_subscribers  s\      
   
  
        z\BaseAdapterRegistryTests.test_subscribe_multiple_allRegistrations.<locals>.build_subscribersr   c                    s   |  ddiS )N      r	   P)r   r   r	   r
   build_provided  s      zYBaseAdapterRegistryTests.test_subscribe_multiple_allRegistrations.<locals>.build_providedr   r	   c                 S   s    | d k	r| nt  } | | | S r   r   r   r	   r	   r
   r   (  s    
zSBaseAdapterRegistryTests.test_subscribe_multiple_allRegistrations.<locals>.addValue)r   rR   r   ra   rs   rX   rY   rU   ry   rV   r   r   r+   r   r4   r   r1   r   r5   r   r   r   )r   r   r   r   r]   r   r   rx   r   r   r   r	   r   r
   (test_subscribe_multiple_allRegistrations  sp    $



zABaseAdapterRegistryTests.test_subscribe_multiple_allRegistrations)rf   )rf   ).r   r   r   ZmaxDiffr;   rP   rR   rU   rV   rX   rY   r^   rd   rg   rj   rr   rt   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
   r6   h   sV   


e
	*4		r6   c                   @   s@   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dS )#CustomTypesBaseAdapterRegistryTestsz
    This class may be extended by other packages to test their own
    adapter registries that use custom types. (So be cautious about
    breaking changes.)

    One known user is ``zope.component.persistentregistry``.
    c                 C   s   t S r   )r+   r"   r	   r	   r
   rU   A  s    z3CustomTypesBaseAdapterRegistryTests._getMappingTypec                 C   s   t S r   )r5   r"   r	   r	   r
   rV   D  s    z4CustomTypesBaseAdapterRegistryTests._getProvidedTypec                 C   s   t S r   )r1   r"   r	   r	   r
   rX   G  s    z7CustomTypesBaseAdapterRegistryTests._getMutableListTypec                 C   s   t S r   )r4   r"   r	   r	   r
   rY   J  s    z8CustomTypesBaseAdapterRegistryTests._getLeafSequenceTypec                    s&   ddl m  G  fddd }|S )Nr   r7   c                       s@   e Zd Z Z Z Z	 Z
dd Z fddZdS )zZCustomTypesBaseAdapterRegistryTests._getBaseAdapterRegistry.<locals>.CustomAdapterRegistryc                 S   s   |s|   }|| |S r   )r   r3   )r   existing_leaf_sequenceZnew_itemr	   r	   r
   r   U  s    
zjCustomTypesBaseAdapterRegistryTests._getBaseAdapterRegistry.<locals>.CustomAdapterRegistry._addValueToLeafc                    s*     | ||}||d d < ||ks&t|S r   )_removeValueFromLeafAssertionError)r   r   Z	to_removeZwithout_removedr7   r	   r
   r   [  s    zoCustomTypesBaseAdapterRegistryTests._getBaseAdapterRegistry.<locals>.CustomAdapterRegistry._removeValueFromLeafN)r   r   r   rU   r   rX   r   rY   r   rV   r   r   r   r	   r8   r   r	   r
   CustomAdapterRegistryO  s   r   r9   )r   r   r	   r   r
   r;   M  s    z;CustomTypesBaseAdapterRegistryTests._getBaseAdapterRegistryc                 C   s   |  || d S r   )rZ   r   r	   r	   r
   r   f  s    z6CustomTypesBaseAdapterRegistryTests.assertLeafIdentityN)
r   r   r   __doc__rU   rV   rX   rY   r;   r   r	   r	   r	   r
   r   8  s   r   c                       s   e Zd Zdd Ze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 fd.d/Zd0d1 Zd2d3 Zd4d5 Zd6d7 Zd8d9 Z  Z S );LookupBaseFallbackTestsc                 C   s   ddl m} |S )Nr   )LookupBaseFallback)r:   r   )r   r   r	   r	   r
   _getFallbackClassl  s    z)LookupBaseFallbackTests._getFallbackClassNc                    sR    d krdd  d kr dd d kr0dd G  fddd|   }| S )	Nc                 S   s   d S r   r	   r   requiredrC   r   r	   r	   r
   	uc_lookupv  s    z3LookupBaseFallbackTests._makeOne.<locals>.uc_lookupc                 S   s
   t  d S r   NotImplementedErrorr   r   rC   r	   r	   r
   uc_lookupAlly  s    z6LookupBaseFallbackTests._makeOne.<locals>.uc_lookupAllc                 S   s
   t  d S r   r   r   r	   r	   r
   uc_subscriptions|  s    z:LookupBaseFallbackTests._makeOne.<locals>.uc_subscriptionsc                       s   e Zd Z ZZZdS )z1LookupBaseFallbackTests._makeOne.<locals>.DerivedN)r   r   r   _uncached_lookup_uncached_lookupAll_uncached_subscriptionsr	   r   r   r   r	   r
   Derived~  s   r   rQ   )r   r   r   r   r   r	   r   r
   rR   r  s    z LookupBaseFallbackTests._makeOnec              	   C   s>   dd }| j |d}| t |ddt  W 5 Q R X d S )Nc                 S   s   |  d d S NzThis should never be calledr   r   r	   r	   r
   _lookup  s    zCLookupBaseFallbackTests.test_lookup_w_invalid_name.<locals>._lookupr   AB)rR   r   r   lookuprL   r   r   lbr	   r	   r
   test_lookup_w_invalid_name  s    z2LookupBaseFallbackTests.test_lookup_w_invalid_namec                    sF   g   fdd}| j |d}|ddd}| | |  dg d S )Nc                    s     |||f d S r   r3   r   _called_withr	   r
   r     s    zDLookupBaseFallbackTests.test_lookup_miss_no_default.<locals>._lookupr   r   r   Cr   r   r   )rR   r   r   ra   r   r   r   foundr	   r   r
   test_lookup_miss_no_default  s    
z3LookupBaseFallbackTests.test_lookup_miss_no_defaultc                    sP   g  t  } fdd}| j|d}|ddd|}| || |  dg d S )Nc                    s     |||f d S r   r   r   r   r	   r
   r     s    zCLookupBaseFallbackTests.test_lookup_miss_w_default.<locals>._lookupr   r   r   r   r   rL   rR   r   rZ   ra   r   _defaultr   r   r   r	   r   r
   test_lookup_miss_w_default  s    z2LookupBaseFallbackTests.test_lookup_miss_w_defaultc                    sz   g  t  t  t    }}}|||g fdd}| j|d}|ddd}| || |  dg | ||g d S )Nc                    s     |||f dS r   r3   popr   r   _resultsr	   r
   r     s    z?LookupBaseFallbackTests.test_lookup_not_cached.<locals>._lookupr   r   r   r   r   r  r   abcr   r   r   r	   r  r
   test_lookup_not_cached  s    
z.LookupBaseFallbackTests.test_lookup_not_cachedc                    s   g  t  t  t    }}}|||g fdd}| j|d}|ddd}|ddd}| || |  dg | ||g d S )Nc                    s     |||f dS r   r  r   r  r	   r
   r     s    z;LookupBaseFallbackTests.test_lookup_cached.<locals>._lookupr   r   r   r   r   r  r
  r	   r  r
   test_lookup_cached  s    
z*LookupBaseFallbackTests.test_lookup_cachedc                    sz   g  t  t  t    }}}|||g fdd}| j|d}|ddd}| || |  dg | ||g d S )Nc                    s     |||f dS r   r  r   r  r	   r
   r     s    zNLookupBaseFallbackTests.test_lookup_not_cached_multi_required.<locals>._lookupr   r   Dr   r   r  r   r   r  r
  r	   r  r
   %test_lookup_not_cached_multi_required  s    
z=LookupBaseFallbackTests.test_lookup_not_cached_multi_requiredc                    s   g  t  t  t    }}}|||g fdd}| j|d}|ddd}|ddd}| || |  dg | ||g d S )Nc                    s     |||f dS r   r  r   r  r	   r
   r     s    zJLookupBaseFallbackTests.test_lookup_cached_multi_required.<locals>._lookupr   r  r   r   r  r  r
  r	   r  r
   !test_lookup_cached_multi_required  s    
z9LookupBaseFallbackTests.test_lookup_cached_multi_requiredc                    s   g  t  t  t    }}}|||g fdd}| j|d}|ddd}|| |ddd}| || |  ddg | |g d S )Nc                    s     |||f dS r   r  r   r  r	   r
   r     s    zMLookupBaseFallbackTests.test_lookup_not_cached_after_changed.<locals>._lookupr   r   r   r   r   )rL   rR   r   r@   rZ   ra   r
  r	   r  r
   $test_lookup_not_cached_after_changed  s    

z<LookupBaseFallbackTests.test_lookup_not_cached_after_changedc              	   C   s>   dd }| j |d}| t |ddt  W 5 Q R X d S )Nc                 S   s   |  d d S r   r   r   r	   r	   r
   r     s    zDLookupBaseFallbackTests.test_lookup1_w_invalid_name.<locals>._lookupr   r   r   )rR   r   r   lookup1rL   r   r	   r	   r
   test_lookup1_w_invalid_name  s    z3LookupBaseFallbackTests.test_lookup1_w_invalid_namec                    sF   g   fdd}| j |d}|ddd}| | |  dg d S )Nc                    s     |||f d S r   r   r   r   r	   r
   r     s    zELookupBaseFallbackTests.test_lookup1_miss_no_default.<locals>._lookupr   r   r   r   r   )rR   r  r   ra   r   r	   r   r
   test_lookup1_miss_no_default  s    
z4LookupBaseFallbackTests.test_lookup1_miss_no_defaultc                    sP   g  t  } fdd}| j|d}|ddd|}| || |  dg d S )Nc                    s     |||f d S r   r   r   r   r	   r
   r     s    zDLookupBaseFallbackTests.test_lookup1_miss_w_default.<locals>._lookupr   r   r   r   r   rL   rR   r  rZ   ra   r  r	   r   r
   test_lookup1_miss_w_default  s    z3LookupBaseFallbackTests.test_lookup1_miss_w_defaultc                    sl   g  t  } fdd}| j|d}|ddd|}| || |ddd|}| || |  dg d S )Nc                    s     |||f d S r   r   r   r   r	   r
   r     s    zSLookupBaseFallbackTests.test_lookup1_miss_w_default_negative_cache.<locals>._lookupr   r   r   r   r   r  r  r	   r   r
   *test_lookup1_miss_w_default_negative_cache  s    zBLookupBaseFallbackTests.test_lookup1_miss_w_default_negative_cachec                    sz   g  t  t  t    }}}|||g fdd}| j|d}|ddd}| || |  dg | ||g d S )Nc                    s     |||f dS r   r  r   r  r	   r
   r     s    z@LookupBaseFallbackTests.test_lookup1_not_cached.<locals>._lookupr   r   r   r   r   r  r
  r	   r  r
   test_lookup1_not_cached  s    
z/LookupBaseFallbackTests.test_lookup1_not_cachedc                    s   g  t  t  t    }}}|||g fdd}| j|d}|ddd}|ddd}| || |  dg | ||g d S )Nc                    s     |||f dS r   r  r   r  r	   r
   r   !  s    z<LookupBaseFallbackTests.test_lookup1_cached.<locals>._lookupr   r   r   r   r   r  r
  r	   r  r
   test_lookup1_cached  s    
z+LookupBaseFallbackTests.test_lookup1_cachedc                    s   g  t  t  t    }}}|||g fdd}| j|d}|ddd}|| |ddd}| || |  ddg | |g d S )Nc                    s     |||f dS r   r  r   r  r	   r
   r   /  s    zNLookupBaseFallbackTests.test_lookup1_not_cached_after_changed.<locals>._lookupr   r   r   r   r   )rL   rR   r  r@   rZ   ra   r
  r	   r  r
   %test_lookup1_not_cached_after_changed+  s    

z=LookupBaseFallbackTests.test_lookup1_not_cached_after_changedc              	   C   s@   t  t   }}|  }| t |||t   W 5 Q R X d S r   )rL   rR   r   r   adapter_hook)r   reqprvr   r	   r	   r
    test_adapter_hook_w_invalid_name;  s    z8LookupBaseFallbackTests.test_adapter_hook_w_invalid_namec                 C   s2   t  t   }}|  }|||d}| | d S r   )rL   rR   r  r   )r   r   r!  r   r   r	   r	   r
   !test_adapter_hook_miss_no_defaultA  s    z9LookupBaseFallbackTests.test_adapter_hook_miss_no_defaultc                 C   s>   t  t  t    }}}|  }|||d|}| || d S r   )rL   rR   r  rZ   )r   r   r!  r  r   r   r	   r	   r
    test_adapter_hook_miss_w_defaultG  s    z8LookupBaseFallbackTests.test_adapter_hook_miss_w_defaultc                    sl   g   fddfdd}t  t  t    }}}| j|d}|||d|}| || |  |g d S )Nc                    s     |  d S r   r   context_f_called_withr	   r
   _factoryO  s    zTLookupBaseFallbackTests.test_adapter_hook_hit_factory_returns_None.<locals>._factoryc                    s    S r   r	   r   r)  r	   r
   r   R  s    zSLookupBaseFallbackTests.test_adapter_hook_hit_factory_returns_None.<locals>._lookupr   r   rL   rR   r  rZ   ra   r   r   r   r!  r  r   adaptedr	   r(  r)  r
   *test_adapter_hook_hit_factory_returns_NoneM  s    zBLookupBaseFallbackTests.test_adapter_hook_hit_factory_returns_Nonec                    st   g t    fddfdd}t  t  t    }}}| j|d}|||d|}| |  | |g d S )Nc                    s    |   S r   r   r%  _adapterr(  r	   r
   r)  ]  s    
zWLookupBaseFallbackTests.test_adapter_hook_hit_factory_returns_adapter.<locals>._factoryc                    s    S r   r	   r   r*  r	   r
   r   `  s    zVLookupBaseFallbackTests.test_adapter_hook_hit_factory_returns_adapter.<locals>._lookupr   r   r+  r,  r	   r1  r(  r)  r
   -test_adapter_hook_hit_factory_returns_adapterZ  s    zELookupBaseFallbackTests.test_adapter_hook_hit_factory_returns_adapterc                    sd   g   fdddfdd	}t t| }t }| j|d}|||}| ||  |  | g d S )Nc                    s     |  | S r   r   r%  r'  r	   r
   r)  j  s    
zILookupBaseFallbackTests.test_adapter_hook_super_unwraps.<locals>._factoryru   c                    s    S r   r	   r   r*  r	   r
   r   m  s    zHLookupBaseFallbackTests.test_adapter_hook_super_unwraps.<locals>._lookupr   )ru   )superr   rL   rR   r  rZ   ra   )r   r   r   rC   r   r-  	__class__r.  r
   test_adapter_hook_super_unwrapsh  s    
z7LookupBaseFallbackTests.test_adapter_hook_super_unwrapsc                    st   g t    fddfdd}t  t  t    }}}| j|d}|||d|}| |  | |g d S )Nc                    s    |   S r   r   r%  r0  r	   r
   r)  y  s    
z;LookupBaseFallbackTests.test_queryAdapter.<locals>._factoryc                    s    S r   r	   r   r*  r	   r
   r   |  s    z:LookupBaseFallbackTests.test_queryAdapter.<locals>._lookupr   r   )rL   rR   queryAdapterrZ   ra   r,  r	   r2  r
   test_queryAdapterv  s    z)LookupBaseFallbackTests.test_queryAdapterc                    s\   g  t  t  t  g fdd}| j|d}|dd}| |t |  dg d S )Nc                    s     ||f tS r   r3   rI   r   r  r	   r
   
_lookupAll  s    zCLookupBaseFallbackTests.test_lookupAll_uncached.<locals>._lookupAllr   r   r   r   r   rL   rR   	lookupAllra   rI   r   r;  r   r   r	   r  r
   test_lookupAll_uncached  s    z/LookupBaseFallbackTests.test_lookupAll_uncachedc                    sh   g  t  t  t  g fdd}| j|d}|dd}|dd}| |t |  dg d S )Nc                    s     ||f tS r   r:  r   r  r	   r
   r;    s    zALookupBaseFallbackTests.test_lookupAll_cached.<locals>._lookupAllr<  r   r   r=  r>  r@  r	   r  r
   test_lookupAll_cached  s    z-LookupBaseFallbackTests.test_lookupAll_cachedc                    s\   g  t  t  t  g fdd}| j|d}|dd}| |t |  dg d S )Nc                    s     ||f tS r   r:  r   r  r	   r
   _subscriptions  s    zKLookupBaseFallbackTests.test_subscriptions_uncached.<locals>._subscriptionsr   r   r   r=  rL   rR   subscriptionsra   rI   r   rC  r   r   r	   r  r
   test_subscriptions_uncached  s    z3LookupBaseFallbackTests.test_subscriptions_uncachedc                    sh   g  t  t  t  g fdd}| j|d}|dd}|dd}| |t |  dg d S )Nc                    s     ||f tS r   r:  r   r  r	   r
   rC    s    zILookupBaseFallbackTests.test_subscriptions_cached.<locals>._subscriptionsrD  r   r   r=  rE  rG  r	   r  r
   test_subscriptions_cached  s    z1LookupBaseFallbackTests.test_subscriptions_cached)NNN)!r   r   r   r   rP   rR   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r"  r#  r$  r/  r3  r7  r9  rA  rB  rH  rI  __classcell__r	   r	   r5  r
   r   j  s>     


r   c                   @   s   e Zd Zdd ZdS )LookupBaseTestsc                 C   s   ddl m} |S )Nr   )
LookupBase)r:   rL  )r   rL  r	   r	   r
   rP     s    zLookupBaseTests._getTargetClassNr   r   r   rP   r	   r	   r	   r
   rK    s   rK  c                   @   sZ   e Zd Zdd Ze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S )VerifyingBaseFallbackTestsc                 C   s   ddl m} |S )Nr   )VerifyingBaseFallback)r:   rO  )r   rO  r	   r	   r
   r     s    z,VerifyingBaseFallbackTests._getFallbackClassNc                    sd   d krdd d kr dd d kr0dd G  fddd|     |}|| |S )	Nc                 S   s
   t  d S r   r   r   r	   r	   r
   r     s    z6VerifyingBaseFallbackTests._makeOne.<locals>.uc_lookupc                 S   s
   t  d S r   r   r   r	   r	   r
   r     s    z9VerifyingBaseFallbackTests._makeOne.<locals>.uc_lookupAllc                 S   s
   t  d S r   r   r   r	   r	   r
   r     s    z=VerifyingBaseFallbackTests._makeOne.<locals>.uc_subscriptionsc                       s*   e Zd ZZZZ fddZ  ZS )z4VerifyingBaseFallbackTests._makeOne.<locals>.Derivedc                    s   t  |   || _d S r   )r4  r/   	_registryrc   )r   r6  r	   r
   r/     s    z=VerifyingBaseFallbackTests._makeOne.<locals>.Derived.__init__)r   r   r   r   r   r   r/   rJ  r	   r   r   r   r   r5  r
   r     s   r   )rP   r@   )r   r]   r   r   r   Zderivedr	   rQ  r
   rR     s    
z#VerifyingBaseFallbackTests._makeOnec                    s*   G dd dt  G  fddd}||S )Nc                   @   s   e Zd ZdZdS )z@VerifyingBaseFallbackTests._makeRegistry.<locals>.WithGenerationr`   N)r   r   r   rb   r	   r	   r	   r
   WithGeneration  s   rR  c                       s   e Zd Z fddZdS )z:VerifyingBaseFallbackTests._makeRegistry.<locals>.Registryc                    s    fddt |D | _d S )Nc                    s   g | ]
}  qS r	   r	   )rE   irR  r	   r
   rH     s     zWVerifyingBaseFallbackTests._makeRegistry.<locals>.Registry.__init__.<locals>.<listcomp>)rangero)r   depthrT  r	   r
   r/     s    zCVerifyingBaseFallbackTests._makeRegistry.<locals>.Registry.__init__Nr0   r	   rT  r	   r
   Registry  s   rX  )rL   )r   rW  rX  r	   rT  r
   _makeRegistry  s    z(VerifyingBaseFallbackTests._makeRegistryc                    s   g  t  t  t    }}}|||g fdd}| d}| j||d}|ddd}|ddd}| || |  dg | ||g |jd	  jd	7  _|ddd}| || |  ddg | |g d S )
Nc                    s     |||f dS r   r  r   r  r	   r
   r     s    z7VerifyingBaseFallbackTests.test_lookup.<locals>._lookupr   r   r   r   r   r   r`   )rL   rY  rR   r   rZ   ra   rV  rb   r   r  r  r  r   r<   r   r   r	   r  r
   test_lookup  s$    

z&VerifyingBaseFallbackTests.test_lookupc                    s   g  t  t  t    }}}|||g fdd}| d}| j||d}|ddd}|ddd}| || |  dg | ||g |jd	  jd	7  _|ddd}| || |  ddg | |g d S )
Nc                    s     |||f dS r   r  r   r  r	   r
   r     s    z8VerifyingBaseFallbackTests.test_lookup1.<locals>._lookupr   r   r   r   r   r   r`   )rL   rY  rR   r  rZ   ra   rV  rb   rZ  r	   r  r
   test_lookup1  s$    

z'VerifyingBaseFallbackTests.test_lookup1c                    s   t  t  t  g\}fdd}fdd}fdd}|||g  fdd}t  t  t    }}}d	}	j|	|d
}
|
||d|}| |
||d|}| |	jd  jd7  _|
||d|}| d S )Nc                    s    S r   r	   r%  r  r	   r
   	_factory1  s    z?VerifyingBaseFallbackTests.test_adapter_hook.<locals>._factory1c                    s    S r   r	   r%  r  r	   r
   	_factory2  s    z?VerifyingBaseFallbackTests.test_adapter_hook.<locals>._factory2c                    s     d d S r   r   r%  r"   r	   r
   	_factory3  s    z?VerifyingBaseFallbackTests.test_adapter_hook.<locals>._factory3c                    s
     dS r   r  r   
_factoriesr	   r
   r     s    z=VerifyingBaseFallbackTests.test_adapter_hook.<locals>._lookupr   r   r   r`   )rL   rY  rR   r  rZ   rV  rb   r   Z_cr^  r`  ra  r   r   r!  r  r<   r   r-  r	   rd  r  r  r   r
   test_adapter_hook  s     

z,VerifyingBaseFallbackTests.test_adapter_hookc                    s   t  t  t  g\}fdd}fdd}fdd}|||g  fdd}t  t  t    }}}d	}	j|	|d
}
|
||d|}| |
||d|}| |	jd  jd7  _|
||d|}| d S )Nc                    s    S r   r	   r%  r]  r	   r
   r^  $  s    z?VerifyingBaseFallbackTests.test_queryAdapter.<locals>._factory1c                    s    S r   r	   r%  r_  r	   r
   r`  &  s    z?VerifyingBaseFallbackTests.test_queryAdapter.<locals>._factory2c                    s     d d S r   r   r%  r"   r	   r
   ra  (  s    z?VerifyingBaseFallbackTests.test_queryAdapter.<locals>._factory3c                    s
     dS r   rb  r   rc  r	   r
   r   +  s    z=VerifyingBaseFallbackTests.test_queryAdapter.<locals>._lookupr   r   r   r`   )rL   rY  rR   r8  rZ   rV  rb   r  re  r	   rf  r
   r9  "  s     

z,VerifyingBaseFallbackTests.test_queryAdapterc                    s   t  t  t  g}t  t  t  g}||g  fdd}| d}| j||d}|dd}| |t| |dd}| |t| |jd  jd7  _|dd}| |t| d S )Nc                    s   t  dS r   rI   r  r   r	  r	   r
   r;  <  s    z=VerifyingBaseFallbackTests.test_lookupAll.<locals>._lookupAllr   r<  r   r   r`   )rL   rY  rR   r?  ra   rI   rV  rb   )r   
_results_1
_results_2r;  r<   r   r   r	   ri  r
   test_lookupAll8  s    
z)VerifyingBaseFallbackTests.test_lookupAllc                    s   t  t  t  g}t  t  t  g}||g  fdd}| d}| j||d}|dd}| |t| |dd}| |t| |jd  jd7  _|dd}| |t| d S )Nc                    s   t  dS r   rh  r   ri  r	   r
   rC  L  s    zEVerifyingBaseFallbackTests.test_subscriptions.<locals>._subscriptionsr   rD  r   r   r`   )rL   rY  rR   rF  ra   rI   rV  rb   )r   rj  rk  rC  r<   r   r   r	   ri  r
   test_subscriptionsH  s    
z-VerifyingBaseFallbackTests.test_subscriptions)NNN)r   r   r   r   rP   rR   rY  r[  r\  rg  r9  rl  rm  r	   r	   r	   r
   rN    s     
rN  c                   @   s   e Zd Zdd ZdS )VerifyingBaseTestsc                 C   s   ddl m} |S )Nr   )VerifyingBase)r:   ro  )r   ro  r	   r	   r
   rP   \  s    z"VerifyingBaseTests._getTargetClassNrM  r	   r	   r	   r
   rn  Y  s   rn  c                       s<  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Z fd-d.Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"dAdB Z#dCdD Z$dEdF Z%dGdH Z&dIdJ Z'  Z(S )KAdapterLookupBaseTestsc                 C   s   ddl m} |S )Nr   )AdapterLookupBase)r:   rq  )r   rq  r	   r	   r
   rP   c  s    z&AdapterLookupBaseTests._getTargetClassc                 C   s   |   |S r   rQ   rc   r	   r	   r
   rR   g  s    zAdapterLookupBaseTests._makeOnec                 G   s   G dd d}| S )Nc                   @   s   e Zd Zdd ZdS )z<AdapterLookupBaseTests._makeSubregistry.<locals>.Subregistryc                 S   s   g | _ g | _d S r   )rl   rs   r"   r	   r	   r
   r/   l  s    zEAdapterLookupBaseTests._makeSubregistry.<locals>.Subregistry.__init__Nr0   r	   r	   r	   r
   Subregistryk  s   rr  r	   )r   rC   rr  r	   r	   r
   _makeSubregistryj  s    z'AdapterLookupBaseTests._makeSubregistryc                 G   s   G dd d}||S )Nc                   @   s   e Zd Zdd ZdS )z6AdapterLookupBaseTests._makeRegistry.<locals>.Registryc                 S   s   || _ g | _d S r   )ry   rV  rB   r	   r	   r
   r/   s  s    z?AdapterLookupBaseTests._makeRegistry.<locals>.Registry.__init__Nr0   r	   r	   r	   r
   rX  r  s   rX  r	   )r   rC   rX  r	   r	   r
   rY  q  s    z$AdapterLookupBaseTests._makeRegistryc                 C   s$   |   }| |}| |ji  d S r   )rY  rR   ra   rA   )r   r]   albr	   r	   r
   test_ctor_empty_registryx  s    
z/AdapterLookupBaseTests.test_ctor_empty_registryc                 C   s   ddl m} ddlm} |d}|d|f}| ||}| |}| t|j	 t|||g | |j| ||g | |j| |g | t|j| t||g d S Nr   r   InterfaceClassIFooIBar)
r   r   zope.interface.interfacerx  rY  rR   ra   r   rA   keysr   r   rx  ry  rz  r]   rt  r	   r	   r
   test_ctor_w_registry_provided}  s    

z4AdapterLookupBaseTests.test_ctor_w_registry_providedc                 C   sD   G dd dt }G dd d|  |}|  }||}|| d S )Nc                   @   s   e Zd Zdd ZdS )zAAdapterLookupBaseTests.test_changed_empty_required.<locals>.Mixinc                 W   s   d S r   r	   r&   r	   r	   r
   r@     s    zIAdapterLookupBaseTests.test_changed_empty_required.<locals>.Mixin.changedNr   r   r   r@   r	   r	   r	   r
   Mixin  s   r  c                   @   s   e Zd ZdS )zCAdapterLookupBaseTests.test_changed_empty_required.<locals>.DerivedNr   r	   r	   r	   r
   r     s   r   )rL   rP   rY  r@   )r   r  r   r]   rt  r	   r	   r
   test_changed_empty_required  s
    z2AdapterLookupBaseTests.test_changed_empty_requiredc                 C   s   G dd dt }G dd d|  |}G dd dt }|d}|d}|  }||}d	|j|< d	|j|< || | t|jd
 | |jd  | |j| d S )Nc                   @   s   e Zd Zdd ZdS )z=AdapterLookupBaseTests.test_changed_w_required.<locals>.Mixinc                 W   s   d S r   r	   r&   r	   r	   r
   r@     s    zEAdapterLookupBaseTests.test_changed_w_required.<locals>.Mixin.changedNr  r	   r	   r	   r
   r    s   r  c                   @   s   e Zd ZdS )z?AdapterLookupBaseTests.test_changed_w_required.<locals>.DerivedNr   r	   r	   r	   r
   r     s   r   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )zCAdapterLookupBaseTests.test_changed_w_required.<locals>.FauxWeakrefNc                 S   s
   || _ d S r   Z_here)r   herer	   r	   r
   r/     s    zLAdapterLookupBaseTests.test_changed_w_required.<locals>.FauxWeakref.__init__c                 S   s   | j r
| S d S r   r  r"   r	   r	   r
   __call__  s    zLAdapterLookupBaseTests.test_changed_w_required.<locals>.FauxWeakref.__call__c                 S   s
   || _ d S r   )_unsub)r   targetr	   r	   r
   r     s    zOAdapterLookupBaseTests.test_changed_w_required.<locals>.FauxWeakref.unsubscribe)r   r   r   r  r/   r  r   r	   r	   r	   r
   FauxWeakref  s   r  FTr`   r   )rL   rP   rY  	_requiredr@   ra   r!   r  )r   r  r   r  goner  r]   rt  r	   r	   r
   test_changed_w_required  s    


z.AdapterLookupBaseTests.test_changed_w_requiredc                 C   s   ddl m} ddlm} |d}|d|f}|  }| |}||g|_|  | t	|j
 t	|||g | |j
| ||g | |j
| |g | t	|j
| t	||g d S rv  )r   r   r{  rx  rY  rR   ry   Zinit_extendorsra   r   rA   r|  r}  r	   r	   r
   )test_init_extendors_after_registry_update  s     


z@AdapterLookupBaseTests.test_init_extendors_after_registry_updatec                 C   s   ddl m} ddlm} |d}|d|f}|  }| |}|| || | t|j	
 t|||g | |j	| ||g | |j	| |g | t|j	| t||g d S rv  )r   r   r{  rx  rY  rR   rD   ra   r   rA   r|  r}  r	   r	   r
   test_add_extendor  s     



z(AdapterLookupBaseTests.test_add_extendorc                 C   s   ddl m} ddlm} |d}|d|f}| ||}| |}|| | t|j	
 t|||g | |j	| |g | |j	| |g | t|j	| t|g d S rv  )r   r   r{  rx  rY  rR   rJ   ra   r   rA   r|  r}  r	   r	   r
   test_remove_extendor  s    

z+AdapterLookupBaseTests.test_remove_extendorc                 C   st   ddl m} |d}|d|f}|  }| |}||f|}| |d  | t|jd | |	 |j d S Nr   rw  ry  rz  r`   )
r{  rx  rY  rR   r   ra   r!   r  r   weakrefr   rx  ry  rz  r]   rt  resultr	   r	   r
   test__uncached_lookup_empty_ro  s    
z5AdapterLookupBaseTests.test__uncached_lookup_empty_roc                 C   sh   ddl m} |d}|d|f}| ||}|  }|j| | |}||f|}| |d  d S Nr   rw  ry  rz  )	r{  rx  rY  rs  rV  r3   rR   r   ra   r   rx  ry  rz  r]   subrrt  r  r	   r	   r
    test__uncached_lookup_order_miss  s    
z7AdapterLookupBaseTests.test__uncached_lookup_order_missc                 C   st   ddl m} |d}|d|f}|  }|  }i i g|_|j| | |}||_|	|f|}| 
|d  d S r  )r{  rx  rY  rs  rl   rV  r3   rR   r\   r   ra   r  r	   r	   r
   $test__uncached_lookup_extendors_miss  s    

z;AdapterLookupBaseTests.test__uncached_lookup_extendors_missc           
      C   s   ddl m} |d}|d|f}|d}| ||}|  }t }i ||d|iiig|_|j| | |}||_	|
|f|}	| |	d  d S Nr   rw  ry  rz  IQuxru   r{  rx  rY  rs  rL   rl   rV  r3   rR   r\   r   ra   
r   rx  ry  rz  r  r]   r  Z
irrelevantrt  r  r	   r	   r
   1test__uncached_lookup_components_miss_wrong_iface  s    
zHAdapterLookupBaseTests.test__uncached_lookup_components_miss_wrong_ifacec           	      C   s   ddl m} |d}|d|f}| ||}|  }t }i ||d|iiig|_|j| | |}||_	|
|f|}| |d  d S Nr   rw  ry  rz  	wrongnamer  	r   rx  ry  rz  r]   r  r  rt  r  r	   r	   r
   0test__uncached_lookup_components_miss_wrong_name  s    
zGAdapterLookupBaseTests.test__uncached_lookup_components_miss_wrong_namec           	      C   s   ddl m} |d}|d|f}| ||}|  }t }i ||d|iiig|_|j| | |}||_	|
|f|}| || d S Nr   rw  ry  rz  ru   r{  rx  rY  rs  rL   rl   rV  r3   rR   r\   r   rZ   )	r   rx  ry  rz  r]   r  	_expectedrt  r  r	   r	   r
    test__uncached_lookup_simple_hit*  s    
z7AdapterLookupBaseTests.test__uncached_lookup_simple_hitc           
      C   s   ddl m} |d}|d|f}| ||}|  }t }i ||d|iiig|_|j| | |}||_	|
|f|}|
|f|}	| || | |	| d S r  r  )
r   rx  ry  rz  r]   r  r  rt  r  Zresult2r	   r	   r
   "test__uncached_lookup_repeated_hit;  s     
z9AdapterLookupBaseTests.test__uncached_lookup_repeated_hitc                 C   s   ddl m} ddlm} |d}|d|f}||G dd dt}| }|  }|  }i i g|_|j	| | 
|}	|	j|	_|	|_t }
|	j|f||
d}| ||
 d S )	Nr   implementerrw  ry  rz  c                   @   s   e Zd ZdS )zFAdapterLookupBaseTests.test_queryMultiAdaptor_lookup_miss.<locals>.FooNr   r	   r	   r	   r
   FooS  s   r  default)zope.interface.declarationsr  r{  rx  rL   rY  rs  rl   rV  r3   rR   r   r   r\   queryMultiAdapterrZ   )r   r  rx  ry  rz  r  foor]   r  rt  r  r  r	   r	   r
   "test_queryMultiAdaptor_lookup_missN  s&    
z9AdapterLookupBaseTests.test_queryMultiAdaptor_lookup_missc                    sl   ddl m} ddlm} |d |  }| |j_ fdd}tt	k	}|j
| ||r`dndd	 d S )
Nr   rw  )MissingSomeAttrsry  c                    s    | f S r   )r  )obry  rt  r	   r
   testr  s    zVAdapterLookupBaseTests.test_queryMultiAdapter_errors_on_attribute_access.<locals>.testr6  Z__providedBy__)Zexpected_missing)r{  rx  zope.interface.testsr  rY  rR   r   r   strbytesZtest_raises)r   rx  r  r]   r  PY3r	   r  r
   1test_queryMultiAdapter_errors_on_attribute_accesse  s    

zHAdapterLookupBaseTests.test_queryMultiAdapter_errors_on_attribute_accessc                    s   ddl m} ddlm} |d}|d|f}||G dd dt}| }| ||}|  }t }	g   fdd	}
i ||d
|
iiig|_|j	| | 
|}|j|_||_t }|j|f||d}| || |  |g d S )Nr   r  rw  ry  rz  c                   @   s   e Zd ZdS )zGAdapterLookupBaseTests.test_queryMultiAdaptor_factory_miss.<locals>.FooNr   r	   r	   r	   r
   r    s   r  c                    s     |  d S r   r   r%  r   r	   r
   r)    s    zLAdapterLookupBaseTests.test_queryMultiAdaptor_factory_miss.<locals>._factoryru   r  r  r  r{  rx  rL   rY  rs  rl   rV  r3   rR   r   r   r\   r  rZ   ra   )r   r  rx  ry  rz  r  r  r]   r  r  r)  rt  r  r  r	   r   r
   #test_queryMultiAdaptor_factory_miss|  s.    
z:AdapterLookupBaseTests.test_queryMultiAdaptor_factory_missc                    s   ddl m} ddlm} |d}|d|f}||G dd dt}| }| ||}|  }t g   fdd	}	i ||d
|	iiig|_|j	| | 
|}
|
j|
_|
|_t }|
j|f||d}| | |  |g d S )Nr   r  rw  ry  rz  c                   @   s   e Zd ZdS )zFAdapterLookupBaseTests.test_queryMultiAdaptor_factory_hit.<locals>.FooNr   r	   r	   r	   r
   r    s   r  c                    s     |  S r   r   r%  r   r  r	   r
   r)    s    
zKAdapterLookupBaseTests.test_queryMultiAdaptor_factory_hit.<locals>._factoryru   r  r  )r   r  rx  ry  rz  r  r  r]   r  r)  rt  r  r  r	   r  r
   "test_queryMultiAdaptor_factory_hit  s.    
z9AdapterLookupBaseTests.test_queryMultiAdaptor_factory_hitc                    sd   |  |  } fdd}dd  ||_tt| ddtt| g}||d }| || dd| f d S )Nc                     s    S r   r	   r   factoryr	   r
   r     s    zKAdapterLookupBaseTests.test_queryMultiAdapter_super_unwraps.<locals>.lookupc                  W   s   | S r   r	   r  r	   r	   r
   r    s    zLAdapterLookupBaseTests.test_queryMultiAdapter_super_unwraps.<locals>.factory*   abc)rR   rY  r   r4  rp  r  ra   )r   rt  r   objectsr  r5  r  r
   $test_queryMultiAdapter_super_unwraps  s     z;AdapterLookupBaseTests.test_queryMultiAdapter_super_unwrapsc                 C   st   ddl m} |d}|d|f}|  }| |}||f|}| |d | t|jd | |	 |j d S )Nr   rw  ry  rz  r	   r`   )
r{  rx  rY  rR   r   ra   r!   r  r   r  r  r	   r	   r
   !test__uncached_lookupAll_empty_ro  s    
z8AdapterLookupBaseTests.test__uncached_lookupAll_empty_roc                 C   sn   ddl m} |d}|d|f}| ||}|  }|j| | |}||_||f|}| 	|d d S Nr   rw  ry  rz  r	   )
r{  rx  rY  rs  rV  r3   rR   r\   r   ra   r  r	   r	   r
   #test__uncached_lookupAll_order_miss  s    
z:AdapterLookupBaseTests.test__uncached_lookupAll_order_missc                 C   st   ddl m} |d}|d|f}|  }|  }i i g|_|j| | |}||_|	|f|}| 
|d d S r  )r{  rx  rY  rs  rl   rV  r3   rR   r\   r   ra   r  r	   r	   r
   'test__uncached_lookupAll_extendors_miss  s    

z>AdapterLookupBaseTests.test__uncached_lookupAll_extendors_missc           
      C   s   ddl m} |d}|d|f}|d}| ||}|  }t }i ||d|iiig|_|j| | |}||_	|
|f|}	| |	d d S )Nr   rw  ry  rz  r  ru   r	   )r{  rx  rY  rs  rL   rl   rV  r3   rR   r\   r   ra   r  r	   r	   r
   (test__uncached_lookupAll_components_miss  s    
z?AdapterLookupBaseTests.test__uncached_lookupAll_components_missc           
      C   s   ddl m} |d}|d|f}| ||}|  }t }t }i ||||diig|_|j| | |}||_	|
|f|}	| t|	d|fd|fg d S Nr   rw  ry  rz  )ru   namedru   r  )r{  rx  rY  rs  rL   rl   rV  r3   rR   r\   r   ra   r   
r   rx  ry  rz  r]   r  r  Z_namedrt  r  r	   r	   r
   #test__uncached_lookupAll_simple_hit  s    
z:AdapterLookupBaseTests.test__uncached_lookupAll_simple_hitc           
      C   s   ddl m} |d}|d|f}| ||}|  }t }t }i ||||diig|_|j| | |}|j	|_
||_||f|}	| t|	ddg d S r  )r{  rx  rY  rs  rL   rl   rV  r3   rR   r   r?  r\   namesra   r   r  r	   r	   r
   
test_names  s     
z!AdapterLookupBaseTests.test_namesc                 C   st   ddl m} |d}|d|f}|  }| |}||f|}| |g  | t|jd | |	 |j d S r  )
r{  rx  rY  rR   r   ra   r!   r  r   r  r  r	   r	   r
   %test__uncached_subscriptions_empty_ro(  s    
z<AdapterLookupBaseTests.test__uncached_subscriptions_empty_roc                 C   sn   ddl m} |d}|d|f}| ||}|  }|j| | |}||_||f|}| 	|g  d S r  )
r{  rx  rY  rs  rV  r3   rR   r\   r   ra   r  r	   r	   r
   'test__uncached_subscriptions_order_miss3  s    
z>AdapterLookupBaseTests.test__uncached_subscriptions_order_missc                 C   st   ddl m} |d}|d|f}|  }|  }i i g|_|j| | |}||_|	|f|}| 
|g  d S r  )r{  rx  rY  rs  rs   rV  r3   rR   r\   r   ra   r  r	   r	   r
   +test__uncached_subscriptions_extendors_miss?  s    

zBAdapterLookupBaseTests.test__uncached_subscriptions_extendors_missc           
      C   s   ddl m} |d}|d|f}|d}| ||}|  }t }i ||d|iiig|_|j| | |}||_	|
|f|}	| |	g  d S r  r{  rx  rY  rs  rL   rs   rV  r3   rR   r\   r   ra   r  r	   r	   r
   8test__uncached_subscriptions_components_miss_wrong_ifaceL  s    
zOAdapterLookupBaseTests.test__uncached_subscriptions_components_miss_wrong_ifacec           	      C   s   ddl m} |d}|d|f}| ||}|  }t }i ||d|iiig|_|j| | |}||_	|
|f|}| |g  d S r  r  r  r	   r	   r
   7test__uncached_subscriptions_components_miss_wrong_name^  s    
zNAdapterLookupBaseTests.test__uncached_subscriptions_components_miss_wrong_namec                 C   s   ddl m} |d}|d|f}| ||}|  }G dd dt}| |  }}i ||d||fiiig|_|j| | |}	|	|_	|	
|f|}
| t|
t||g d S )Nr   rw  ry  rz  c                   @   s   e Zd Zdd ZdS )zKAdapterLookupBaseTests.test__uncached_subscriptions_simple_hit.<locals>.Fooc                 S   s   dS )NTr	   r&   r	   r	   r
   __lt__v  s    zRAdapterLookupBaseTests.test__uncached_subscriptions_simple_hit.<locals>.Foo.__lt__N)r   r   r   r  r	   r	   r	   r
   r  u  s   r  ru   )r{  rx  rY  rs  rL   rs   rV  r3   rR   r\   r   ra   r   )r   rx  ry  rz  r]   r  r  _exp1_exp2rt  r  r	   r	   r
   'test__uncached_subscriptions_simple_hito  s    
z>AdapterLookupBaseTests.test__uncached_subscriptions_simple_hitc                    s   ddl m} ddlm} |d}|d|f}||G dd dt}| }| ||}| ||}|  }i   fdd	}	 fd
d}
i |d d|	|
fiiig|_|j	| | 
|}|j|_||_||fd }| |d |  |g|gd d S )Nr   r  rw  ry  rz  c                   @   s   e Zd ZdS )z@AdapterLookupBaseTests.test_subscribers_wo_provided.<locals>.FooNr   r	   r	   r	   r
   r    s   r  c                    s     dg |  d S Nr^  
setdefaultr3   r%  _calledr	   r
   r^    s    zFAdapterLookupBaseTests.test_subscribers_wo_provided.<locals>._factory1c                    s     dg |  d S Nr`  r  r%  r  r	   r
   r`    s    zFAdapterLookupBaseTests.test_subscribers_wo_provided.<locals>._factory2ru   r	   )r^  r`  r  r  r{  rx  rL   rY  rs  rs   rV  r3   rR   r   rF  r\   Zsubscribersra   )r   r  rx  ry  rz  r  r  r]   r  r^  r`  rt  r  r	   r  r
   test_subscribers_wo_provided  s.    
z3AdapterLookupBaseTests.test_subscribers_wo_providedc                    s   ddl m} ddlm} |d}|d|f}||G dd dt}| }| ||}| ||}|  }i  t t   fdd	}	 fd
d}
 fdd}i ||d|	|
|fiiig|_|j	| | 
|}|j|_||_||f|}| |g |  |g|g|gd d S )Nr   r  rw  ry  rz  c                   @   s   e Zd ZdS )z?AdapterLookupBaseTests.test_subscribers_w_provided.<locals>.FooNr   r	   r	   r	   r
   r    s   r  c                    s     dg |  S r  r  r%  )r  r  r	   r
   r^    s    zEAdapterLookupBaseTests.test_subscribers_w_provided.<locals>._factory1c                    s     dg |  S r  r  r%  )r  r  r	   r
   r`    s    zEAdapterLookupBaseTests.test_subscribers_w_provided.<locals>._factory2c                    s     dg |  d S )N_side_effect_onlyr  r%  r  r	   r
   r    s    zMAdapterLookupBaseTests.test_subscribers_w_provided.<locals>._side_effect_onlyru   )r^  r`  r  r  )r   r  rx  ry  rz  r  r  r]   r  r^  r`  r  rt  r  r	   )r  r  r  r
   test_subscribers_w_provided  s<    
z2AdapterLookupBaseTests.test_subscribers_w_provided))r   r   r   rP   rR   rs  rY  ru  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rJ  r	   r	   r5  r
   rp  a  sJ   rp  c                   @   s$   e Zd Zdd Zdd Zdd ZdS )VerifyingAdapterRegistryTestsc                 C   s   ddl m} |S )Nr   )VerifyingAdapterRegistry)r:   r  )r   r  r	   r	   r
   rP     s    z-VerifyingAdapterRegistryTests._getTargetClassc                 O   s   |   ||S r   rQ   )r   r   kwr	   r	   r
   rR     s    z&VerifyingAdapterRegistryTests._makeOnec                 C   s.   ddl m} ddlm} |  }||| d S )Nr   )verifyObject)IAdapterRegistry)Zzope.interface.verifyr  Zzope.interface.interfacesr  rR   )r   r  r  r]   r	   r	   r
   ,test_verify_object_provides_IAdapterRegistry  s    zJVerifyingAdapterRegistryTests.test_verify_object_provides_IAdapterRegistryN)r   r   r   rP   rR   r  r	   r	   r	   r
   r    s   r  c                   @   sD   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dS )AdapterRegistryTestsc                 C   s   ddl m} |S )Nr   )AdapterRegistry)r:   r  )r   r  r	   r	   r
   rP     s    z$AdapterRegistryTests._getTargetClassc                 C   s   |   }| t|jd d S r   )rR   ra   r!   _v_subregistries)r   arr	   r	   r
   test_ctor_no_bases  s    z'AdapterRegistryTests.test_ctor_no_basesc                 C   sJ   |   }|  |g}| t|jd | t|jd | ||j d S rk   )rR   ra   r!   r  r   )r   basesubr	   r	   r
   test_ctor_w_bases  s
    z&AdapterRegistryTests.test_ctor_w_basesc                 C   sZ   |   }|   }|  |g}|g|_| t|jd | t|jd | ||j d S rk   rR   ri   ra   r!   r  r   r   beforeafterr  r	   r	   r
   ,test__setBases_removing_existing_subregistry  s    zAAdapterRegistryTests.test__setBases_removing_existing_subregistryc                 C   sr   |   }|   }|   }|  |g}|jd | |g|_| t|jd | t|jd | ||j d S )Nri   r   r`   )rR   __dict__r3   ri   ra   r!   r  r   )r   r  Zstrayr  r  r	   r	   r
   test__setBases_wo_stray_entry  s    z2AdapterRegistryTests.test__setBases_wo_stray_entryc                 C   sj   |   }|   }|  |g}||g|_| t|jd | t|jd | ||j | ||j d S r_   r  r  r	   r	   r
   *test__setBases_w_existing_entry_continuing  s    
z?AdapterRegistryTests.test__setBases_w_existing_entry_continuingc                 C   sj   |   }G dd dt}| |  }}|| || t }|| | |j| | |j| d S )Nc                   @   s   e Zd ZdZdd ZdS )zBAdapterRegistryTests.test_changed_w_subregistries.<locals>.DerivedNc                 S   s
   || _ d S r   r=   )r   Zoriginally_changedr	   r	   r
   r@     s    zJAdapterRegistryTests.test_changed_w_subregistries.<locals>.Derived.changed)r   r   r   r>   r@   r	   r	   r	   r
   r     s   r   )rR   rL   Z_addSubregistryr@   rZ   r>   )r   r  r   Zderived1Zderived2r?   r	   r	   r
   test_changed_w_subregistries  s    


z1AdapterRegistryTests.test_changed_w_subregistriesN)
r   r   r   rP   r  r  r  r  r  r  r	   r	   r	   r
   r    s   		
r  c                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )
Test_utilsc                 C   s,   ddl m} ddlm} | |d | d S )Nr   _convert_None_to_Interfacer   )r:   r  r{  r   rZ   )r   r  r   r	   r	   r
   &test__convert_None_to_Interface_w_None  s    z1Test_utils.test__convert_None_to_Interface_w_Nonec                 C   s&   ddl m} t }| ||| d S )Nr   r  )r:   r  rL   rZ   )r   r  r'   r	   r	   r
   'test__convert_None_to_Interface_w_other$  s    z2Test_utils.test__convert_None_to_Interface_w_otherc                 C   s<   ddl m} d}d}||}| || | |t| d S )Nr   _normalize_names   strr  )r:   r  ra   rm   r%   )r   r  ZSTRUNICODEZnormr	   r	   r
   test__normalize_name_str)  s    z#Test_utils.test__normalize_name_strc                 C   s$   ddl m} d}| ||| d S )Nr   r  Zustr)r:   r  ra   )r   r  ZUSTRr	   r	   r
   test__normalize_name_unicode1  s    z'Test_utils.test__normalize_name_unicodec                 C   s6   ddl m} dddg i t fD ]}| t|| qd S )Nr   r  r`   g      ?r	   )r:   r  rL   r   	TypeError)r   r  r'   r	   r	   r
   test__normalize_name_other7  s    z%Test_utils.test__normalize_name_otherN)r   r   r   r  r  r  r  r  r	   r	   r	   r
   r    s
   r  )r   Zunittestr  r   r   rL   r   r+   r1   r4   r5   ZTestCaser6   r   r   rK  rN  rn  rp  r  r  r  r	   r	   r	   r
   <module>   sD   	     U2  K     k@