B
    u9aV                 @   sN   d dl Z d dlZd dlZG dd de jZG dd deZG dd deZdS )    Nc               @   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d Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% ZdS )&BasicTestMappingProtocolNc             C   s   ddddS )N2Zvalue1)         )1Zkey1Zkey2 )selfr   r   #/usr/lib/python3.7/mapping_tests.py
_reference   s    z#BasicTestMappingProtocol._referencec             C   s   |   S )N)	type2test)r	   r   r   r
   _empty_mapping   s    z'BasicTestMappingProtocol._empty_mappingc             C   s*   |   }x| D ]\}}|||< qW |S )N)r   items)r	   dataxkeyvaluer   r   r
   _full_mapping   s    z&BasicTestMappingProtocol._full_mappingc             O   s`   t jj| f|| |   | _| j \}}||i| _| j \}}||i| _|| j|< d S )N)	unittestTestCase__init__r   copy	referencepopitemother	inmapping)r	   argskwr   r   r   r   r
   r      s    

z!BasicTestMappingProtocol.__init__c                s    }t|}j  |kr(|}x&j D ]\}} | | q4W tj d 	t
 fdd t|d t tj xjD ]}|  qW xjD ]}|  qW ||    |   | |rd  s&d fdd}|t  t  j  |t t  j  |t  t  j  |t  t  j  tt  \}}ttj \} |||  ||   d S )Nr   c                  s     S )Nr   r   )dknownkeyr   r
   <lambda>6       z4BasicTestMappingProtocol.test_read.<locals>.<lambda>z#Empty mapping must compare to Falsez!Full mapping must compare to Truec                sV     t| d   t| d t| }  t|t|  koJt|kn   d S )N__next____iter__)
assertTruehasattrlistset)iterZlstrefr   )r	   r   r
   check_iterandlistH   s    z=BasicTestMappingProtocol.test_read.<locals>.check_iterandlist)r   dictr   r   r   assertEqualr&   r   keysassertRaisesKeyErrorlenassertInassertNotInZassertNotEqualfailr(   valuesnextget)r	   pZp1r   r   kr*   
knownvaluer   )r   r   r	   r
   	test_read+   sH     
 
z"BasicTestMappingProtocol.test_readc                s  |   x.| j D ] \ }| < |   | qW x.| j D ]   = | t fdd qDW |   | j | t| j t	 }|   | | t| j | 
| j}tt| \ }tt| j \}}| | || | |  | | |||| | || | | ||| | || | t|j| d}|||< | |||| | || | |||| | \ }|  | | || j   |   | tj d S )Nc                  s     S )Nr   r   )r   r7   r   r
   r    d   r!   z5BasicTestMappingProtocol.test_write.<locals>.<lambda>i  )r   r   r   r,   r-   r.   r/   updater+   r&   r   r5   r(   r   
setdefaultpopr2   r   )r	   r   r   r   r   r9   defaultr   )r   r7   r
   
test_write[   sD    
z#BasicTestMappingProtocol.test_writec             C   s   |  |  |   d S )N)r,   r   )r	   r   r   r
   test_constructor   s    z)BasicTestMappingProtocol.test_constructorc             C   sJ   |  |    |  | j |  t|  dk |  t| jdk d S )NFT)r$   r   r   bool)r	   r   r   r
   	test_bool   s    z"BasicTestMappingProtocol.test_boolc             C   sr   |   }| t| g  | j}| t| j d |  | t| j d |  | 	t
|jd  d S )Nr   )r   r,   r&   r-   r   r1   r   r2   r   r.   	TypeError)r	   r   r   r   r
   	test_keys   s    z"BasicTestMappingProtocol.test_keysc             C   s0   |   }| t| g  | t|jd  d S )N)r   r,   r&   r4   r.   rC   )r	   r   r   r   r
   test_values   s    z$BasicTestMappingProtocol.test_valuesc             C   s0   |   }| t| g  | t|jd  d S )N)r   r,   r&   r   r.   rC   )r	   r   r   r   r
   
test_items   s    z#BasicTestMappingProtocol.test_itemsc             C   s   |   }| t|d d S )Nr   )r   r,   r0   )r	   r   r   r   r
   test_len   s    z!BasicTestMappingProtocol.test_lenc             C   sD   | j }| |t| j d  t| j d  | t|j d S )Nr   )	r   r,   r&   r   r-   r4   r.   rC   __getitem__)r	   r   r   r   r
   test_getitem   s    z%BasicTestMappingProtocol.test_getitemc                s  |   }|| j | t| t| j  |   }|  | ||    |   }|| j  | t| t| j  |   }|| j  | t| t| j  | ttf|jd | G fddd}|	  ||  t
| }t
| j }| || G dd dt |   }G  fddd}|  |j|  |	  G  fddd}|  |j|  G  fd	dd}|  |j|  |   }G  fd
ddt}|  |j|  | t|jdg d S )N*   c                   s(   e Zd Z fddZdd Zdd ZdS )z<BasicTestMappingProtocol.test_update.<locals>.SimpleUserDictc                s    j | _d S )N)r   r   )r	   )	outerselfr   r
   r      s    zEBasicTestMappingProtocol.test_update.<locals>.SimpleUserDict.__init__c             S   s
   | j  S )N)r   r-   )r	   r   r   r
   r-      s    zABasicTestMappingProtocol.test_update.<locals>.SimpleUserDict.keysc             S   s
   | j | S )N)r   )r	   ir   r   r
   rH      s    zHBasicTestMappingProtocol.test_update.<locals>.SimpleUserDict.__getitem__N)__name__
__module____qualname__r   r-   rH   r   )rK   r   r
   SimpleUserDict   s   rP   c               @   s   e Zd ZdS )z1BasicTestMappingProtocol.test_update.<locals>.ExcN)rM   rN   rO   r   r   r   r
   Exc   s    rQ   c                   s   e Zd Z fddZdS )z=BasicTestMappingProtocol.test_update.<locals>.FailingUserDictc                s    d S )Nr   )r	   )rQ   r   r
   r-      s    zBBasicTestMappingProtocol.test_update.<locals>.FailingUserDict.keysN)rM   rN   rO   r-   r   )rQ   r   r
   FailingUserDict   s   rR   c                   s    e Zd Z fddZdd ZdS )z=BasicTestMappingProtocol.test_update.<locals>.FailingUserDictc                s   G  fddd}| S )Nc                   s(   e Zd Zdd Zdd Z fddZdS )zUBasicTestMappingProtocol.test_update.<locals>.FailingUserDict.keys.<locals>.BogonIterc             S   s
   d| _ d S )Nr   )rL   )r	   r   r   r
   r      s    z^BasicTestMappingProtocol.test_update.<locals>.FailingUserDict.keys.<locals>.BogonIter.__init__c             S   s   | S )Nr   )r	   r   r   r
   r#      s    z^BasicTestMappingProtocol.test_update.<locals>.FailingUserDict.keys.<locals>.BogonIter.__iter__c                s   | j rd| _ dS  d S )Nr   a)rL   )r	   )rQ   r   r
   r"      s    z^BasicTestMappingProtocol.test_update.<locals>.FailingUserDict.keys.<locals>.BogonIter.__next__N)rM   rN   rO   r   r#   r"   r   )rQ   r   r
   	BogonIter   s   rT   r   )r	   rT   )rQ   r   r
   r-      s    
zBBasicTestMappingProtocol.test_update.<locals>.FailingUserDict.keysc             S   s   |S )Nr   )r	   r   r   r   r
   rH      s    zIBasicTestMappingProtocol.test_update.<locals>.FailingUserDict.__getitem__N)rM   rN   rO   r-   rH   r   )rQ   r   r
   rR      s   c                   s    e Zd Zdd Z fddZdS )z=BasicTestMappingProtocol.test_update.<locals>.FailingUserDictc             S   s   G dd d}| S )Nc               @   s$   e Zd Zdd Zdd Zdd ZdS )zUBasicTestMappingProtocol.test_update.<locals>.FailingUserDict.keys.<locals>.BogonIterc             S   s   t d| _d S )NrS   )ordrL   )r	   r   r   r
   r      s    z^BasicTestMappingProtocol.test_update.<locals>.FailingUserDict.keys.<locals>.BogonIter.__init__c             S   s   | S )Nr   )r	   r   r   r
   r#      s    z^BasicTestMappingProtocol.test_update.<locals>.FailingUserDict.keys.<locals>.BogonIter.__iter__c             S   s2   | j tdkr*t| j }|  j d7  _ |S td S )Nzr   )rL   rU   chrStopIteration)r	   Zrtnr   r   r
   r"      s
    
z^BasicTestMappingProtocol.test_update.<locals>.FailingUserDict.keys.<locals>.BogonIter.__next__N)rM   rN   rO   r   r#   r"   r   r   r   r
   rT      s   rT   r   )r	   rT   r   r   r
   r-      s    zBBasicTestMappingProtocol.test_update.<locals>.FailingUserDict.keysc                s    d S )Nr   )r	   r   )rQ   r   r
   rH      s    zIBasicTestMappingProtocol.test_update.<locals>.FailingUserDict.__getitem__N)rM   rN   rO   r-   rH   r   )rQ   r   r
   rR      s   c                   s    e Zd Zdd Z fddZdS )z4BasicTestMappingProtocol.test_update.<locals>.badseqc             S   s   | S )Nr   )r	   r   r   r
   r#     s    z=BasicTestMappingProtocol.test_update.<locals>.badseq.__iter__c                s
     d S )Nr   )r	   )rQ   r   r
   r"     s    z=BasicTestMappingProtocol.test_update.<locals>.badseq.__next__N)rM   rN   rO   r#   r"   r   )rQ   r   r
   badseq  s   rY   )r   r   r   )r   r;   r   r,   r&   r   r.   rC   AttributeErrorclearsortedr   	Exceptionobject
ValueError)r	   r   rP   Zi1Zi2rR   rY   r   )rQ   rK   r
   test_update   sB    z$BasicTestMappingProtocol.test_updatec             C   s  |   }| |t| j d d k | |t| j d dd | j}| |t| j d d k | |t| j d dd | |t| j d t| j	 d  | |t| j d dt| j	 d  | 
t|j | 
t|jd d d  d S )Nr   r   )r   r$   r6   r&   r   r-   r,   r   r   r4   r.   rC   )r	   r   r   r   r
   test_get  s    """"z!BasicTestMappingProtocol.test_getc             C   s   |   }| t|j d S )N)r   r.   rC   r<   )r	   r   r   r   r
   test_setdefault  s    z(BasicTestMappingProtocol.test_setdefaultc             C   s*   |   }| t|j | t|jd d S )NrJ   )r   r.   r/   r   rC   )r	   r   r   r   r
   test_popitem   s    z%BasicTestMappingProtocol.test_popitemc             C   sz   |   }t| j d \}}|||< | t|jt| j d  | 	||| | 	t
|d | t|j| d S )Nr   )r   r&   r   r   r.   r/   r=   r   r-   r,   r0   )r	   r   r8   vr   r   r
   test_pop%  s    z!BasicTestMappingProtocol.test_pop)rM   rN   rO   r   r   r   r   r   r:   r?   r@   rB   rD   rE   rF   rG   rI   r`   ra   rb   rc   re   r   r   r   r
   r      s&   0*ar   c               @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!S )"TestMappingProtocolc             C   s@   t |  | |  |  k	 | | jdddddd d S )Nr   r   )r   y)r   r@   r$   r   r,   r   )r	   r   r   r
   r@   2  s    
z$TestMappingProtocol.test_constructorc             C   sd   t |  | |    | | ddi | t|  dk | t| ddidk d S )Nr   rg   FT)r   rB   r$   r   r   rA   )r	   r   r   r
   rB   7  s
    
zTestMappingProtocol.test_boolc             C   sf   t |  |  }| t| g  | ddd}| }| d| | d| | d| d S )Nr   r   )rS   brS   rh   c)	r   rD   r   r,   r&   r-   r   r1   r2   )r	   r   r8   r   r   r
   rD   >  s    
zTestMappingProtocol.test_keysc             C   s2   t |  | ddi}| t| dg d S )Nr   r   )r   rE   r   r,   r&   r4   )r	   r   r   r   r
   rE   H  s    
zTestMappingProtocol.test_valuesc             C   s2   t |  | ddi}| t| dg d S )Nr   r   )r   r   )r   rF   r   r,   r&   r   )r	   r   r   r   r
   rF   M  s    
zTestMappingProtocol.test_itemsc             C   sv   |   }| d| | d|k | d|k | ddd}| d| | d| | d| | t|j d S )NrS   r   r   )rS   rh   rh   ri   )r   r2   r$   r   r1   r.   rC   __contains__)r	   r   r   r   r
   test_containsS  s    z!TestMappingProtocol.test_containsc             C   s.   t |  | ddd}| t|d d S )Nr   r   )rS   rh   )r   rG   r   r,   r0   )r	   r   r   r   r
   rG   _  s    
zTestMappingProtocol.test_lenc             C   s   t |  | ddd}| |d d | |d d d|d< d|d< | |d d | |d d |d= | |ddd	 | t|j d S )
Nr   r   )rS   rh   rS   rh   r   ri      )rS   ri   )r   rI   r   r,   r.   rC   rH   )r	   r   r   r   r
   rI   d  s    
z TestMappingProtocol.test_getitemc             C   s:   |  dddd}|  | |i  | t|jd  d S )Nr   r   r   )r   r   r   )r   r[   r,   r.   rC   )r	   r   r   r   r
   
test_clearr  s    zTestMappingProtocol.test_clearc             C   s  t |  |  }|ddi |ddi |dddd | |dddd |  | |dddd |  }|jdd |jdd |jdddd	 | |dddd	 |  }|d
dg | |ddd |  }|jd
dgddd | |ddd | ddd}|| dddd  | |ddddd G dd d}|  ||  | |dddd d S )Nr   d   r      r   )r   r   r   )r   )rg   )r   rg   rV   )r   rn   )rg   ro   )r   rg   rl   )r   r      )r   r      )r   r   r   rq   c               @   s$   e Zd Zdd Zdd Zdd ZdS )z7TestMappingProtocol.test_update.<locals>.SimpleUserDictc             S   s   dddd| _ d S )Nr   r   r   )r   r   r   )r   )r	   r   r   r
   r     s    z@TestMappingProtocol.test_update.<locals>.SimpleUserDict.__init__c             S   s
   | j  S )N)r   r-   )r	   r   r   r
   r-     s    z<TestMappingProtocol.test_update.<locals>.SimpleUserDict.keysc             S   s
   | j | S )N)r   )r	   rL   r   r   r
   rH     s    zCTestMappingProtocol.test_update.<locals>.SimpleUserDict.__getitem__N)rM   rN   rO   r   r-   rH   r   r   r   r
   rP     s   rP   )r   r`   r   r;   r,   r   r   r[   )r	   r   rP   r   r   r
   r`   y  s4    
zTestMappingProtocol.test_updatec       	         s
  |  | jdd d d d |  }| |d|k	 |  |dd d d d |  |ddddd |  |g i  dd }|  || dd i | ti jd G d	d
 d
| j}|  |ddd i |  | ddd i | |dj|k | | dj|k | t|d|k G dd d| j}|d}|  |d d d | 	|t
j | ttj G dd dt G  fddd| j}|  |jdg G  fdddt}|  | jj|  G  fddd| j}|  |jdg d S )Nabc)rS   rh   ri   )rl   rq   r   c               s   s
   dV  d S )Nr   r   r   r   r   r
   g  s    z,TestMappingProtocol.test_fromkeys.<locals>.gr   r   c               @   s   e Zd ZdS )z3TestMappingProtocol.test_fromkeys.<locals>.dictlikeN)rM   rN   rO   r   r   r   r
   dictlike  s    rt   rS   c               @   s   e Zd Zdd ZdS )z1TestMappingProtocol.test_fromkeys.<locals>.mydictc             S   s   t  S )N)collectionsUserDict)clsr   r   r
   __new__  s    z9TestMappingProtocol.test_fromkeys.<locals>.mydict.__new__N)rM   rN   rO   rx   r   r   r   r
   mydict  s   ry   ab)rS   rh   c               @   s   e Zd ZdS )z.TestMappingProtocol.test_fromkeys.<locals>.ExcN)rM   rN   rO   r   r   r   r
   rQ     s    rQ   c                   s   e Zd Z fddZdS )z3TestMappingProtocol.test_fromkeys.<locals>.baddict1c                s
     d S )Nr   )r	   )rQ   r   r
   r     s    z<TestMappingProtocol.test_fromkeys.<locals>.baddict1.__init__N)rM   rN   rO   r   r   )rQ   r   r
   baddict1  s   r{   c                   s    e Zd Zdd Z fddZdS )z1TestMappingProtocol.test_fromkeys.<locals>.BadSeqc             S   s   | S )Nr   )r	   r   r   r
   r#     s    z:TestMappingProtocol.test_fromkeys.<locals>.BadSeq.__iter__c                s
     d S )Nr   )r	   )rQ   r   r
   r"     s    z:TestMappingProtocol.test_fromkeys.<locals>.BadSeq.__next__N)rM   rN   rO   r#   r"   r   )rQ   r   r
   BadSeq  s   r|   c                   s   e Zd Z fddZdS )z3TestMappingProtocol.test_fromkeys.<locals>.baddict2c                s
     d S )Nr   )r	   r   r   )rQ   r   r
   __setitem__  s    z?TestMappingProtocol.test_fromkeys.<locals>.baddict2.__setitem__N)rM   rN   rO   r}   r   )rQ   r   r
   baddict2  s   r~   )r,   r   fromkeysr   r$   r.   rC   	__class__typeassertIsInstanceru   rv   r+   r]   r^   )	r	   r   rs   rt   ry   udr{   r|   r~   r   )rQ   r
   test_fromkeys  s6    
z!TestMappingProtocol.test_fromkeysc             C   sh   |  dddd}| | dddd |  }| | | | | |j | t|jd  d S )Nr   r   r   )r   r   r   )r   r,   r   r   r   r   r.   rC   )r	   r   r   r   r
   	test_copy  s    zTestMappingProtocol.test_copyc             C   s   t |  |  }| |dd k | |ddd | ddd}| |dd k | |ddd | |dd | |ddd d S )Nri   r   r   r   )rS   rh   rS   )r   ra   r   r$   r6   r,   r   )r	   r   r   r   r
   ra     s    
zTestMappingProtocol.test_getc             C   s   t |  |  }| |dd k |dg  | |dd k |dg d | |d d d |dg d | t|d d d S )NZkey0r   r   r   rl   r   )r   rb   r   r$   r<   appendr,   r0   )r	   r   r   r   r
   rb     s    
z#TestMappingProtocol.test_setdefaultc             C   s
  t |  xdD ]}xtdD ]}d| }|  }|  }x0t|D ]$}||t|< |dk rD||t|< qDW |dkr|| }xht|D ]\}|  \}}}	| |t| |  \}
}}| |t|
 | 	|dk o|	|k  qW | 	|  | 	|  qW qW d S )N)r      r   r   )
r   rc   ranger   reprr   r   r,   intr$   )r	   ZcopymodeZlog2sizesizerS   rh   rL   kaZvataZkbZvbtbr   r   r
   rc     s(    

z TestMappingProtocol.test_popitemc             C   sN   t |  |  }d\}}| |||| |||< | ||d| d S )N)rr   defr   )r   re   r   r,   r=   )r	   r   r8   rd   r   r   r
   re     s    
zTestMappingProtocol.test_popN)rM   rN   rO   r@   rB   rD   rE   rF   rk   rG   rI   rm   r`   r   r   ra   rb   rc   re   r   r   r   r
   rf   1  s    
./rf   c               @   sL   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S )TestHashMappingProtocolc                s   t |  G dd dt G  fdddt}|  }d|| < | t|jd G  fdddt}|  }| }d||< d	|_|  |j| d S )
Nc               @   s   e Zd ZdS )z1TestHashMappingProtocol.test_getitem.<locals>.ExcN)rM   rN   rO   r   r   r   r
   rQ     s    rQ   c                   s    e Zd Z fddZdd ZdS )z3TestHashMappingProtocol.test_getitem.<locals>.BadEqc                s
     d S )Nr   )r	   r   )rQ   r   r
   __eq__  s    z:TestHashMappingProtocol.test_getitem.<locals>.BadEq.__eq__c             S   s   dS )N   r   )r	   r   r   r
   __hash__!  s    z<TestHashMappingProtocol.test_getitem.<locals>.BadEq.__hash__N)rM   rN   rO   r   r   r   )rQ   r   r
   BadEq  s   r   rJ      c                   s   e Zd ZdZ fddZdS )z5TestHashMappingProtocol.test_getitem.<locals>.BadHashFc                s   | j r  ndS d S )NrJ   )r3   )r	   )rQ   r   r
   r   *  s    z>TestHashMappingProtocol.test_getitem.<locals>.BadHash.__hash__N)rM   rN   rO   r3   r   r   )rQ   r   r
   BadHash(  s   r   T)	rf   rI   r]   r^   r   r.   r/   rH   r3   )r	   r   r   r   r   r   )rQ   r
   rI     s    

z$TestHashMappingProtocol.test_getitemc             C   sJ   t |  G dd d| j}|d}| |d d d | |tj d S )Nc               @   s   e Zd Zdd ZdS )z5TestHashMappingProtocol.test_fromkeys.<locals>.mydictc             S   s   t  S )N)ru   rv   )rw   r   r   r
   rx   9  s    z=TestHashMappingProtocol.test_fromkeys.<locals>.mydict.__new__N)rM   rN   rO   rx   r   r   r   r
   ry   8  s   ry   rz   )rS   rh   )rf   r   r   r   r,   r   ru   rv   )r	   ry   r   r   r   r
   r   6  s
    

z%TestHashMappingProtocol.test_fromkeysc                s^   t |  G dd dt G  fdddt}|  }| }d||< d|_|  |j| d S )Nc               @   s   e Zd ZdS )z-TestHashMappingProtocol.test_pop.<locals>.ExcN)rM   rN   rO   r   r   r   r
   rQ   B  s    rQ   c                   s   e Zd ZdZ fddZdS )z1TestHashMappingProtocol.test_pop.<locals>.BadHashFc                s   | j r  ndS d S )NrJ   )r3   )r	   )rQ   r   r
   r   F  s    z:TestHashMappingProtocol.test_pop.<locals>.BadHash.__hash__N)rM   rN   rO   r3   r   r   )rQ   r   r
   r   D  s   r   rJ   T)rf   re   r]   r^   r   r3   r.   r=   )r	   r   r   r   r   )rQ   r
   re   ?  s    
z TestHashMappingProtocol.test_popc             C   sR   |   }d|d< yx|D ]}d||d < qW W n tk
rB   Y nX | d d S )Nr   z7changing dict size during iteration doesn't raise Error)r   RuntimeErrorr3   )r	   r   rL   r   r   r
   test_mutatingiterationR  s    
z.TestHashMappingProtocol.test_mutatingiterationc                s   |   }| t|d d|d< | t|d |   }||d< | t|d G dd dt G  fdd	d	t}| d| i}|  t| d S )
Nz{}r   r   z{1: 2}z
{1: {...}}c               @   s   e Zd ZdS )z.TestHashMappingProtocol.test_repr.<locals>.ExcN)rM   rN   rO   r   r   r   r
   rQ   f  s    rQ   c                   s   e Zd Z fddZdS )z2TestHashMappingProtocol.test_repr.<locals>.BadReprc                s
     d S )Nr   )r	   )rQ   r   r
   __repr__i  s    z;TestHashMappingProtocol.test_repr.<locals>.BadRepr.__repr__N)rM   rN   rO   r   r   )rQ   r   r
   BadReprh  s   r   )r   r,   r   r]   r^   r   r.   )r	   r   r   r   )rQ   r
   	test_repr]  s    z!TestHashMappingProtocol.test_reprc             C   sH   |   }x,tt d D ]}|}|   }||d< qW | tt| d S )Nrn   r   )r   r   sysgetrecursionlimitr.   RecursionErrorr   )r	   r   rL   Zd0r   r   r
   test_repr_deepo  s    z&TestHashMappingProtocol.test_repr_deepc                s   |  |  |   |  | ddi| ddi G dd dtG fdddt |   di| ddi|  fdd | fd	d d S )
Nr   r   c               @   s   e Zd ZdS )z,TestHashMappingProtocol.test_eq.<locals>.ExcN)rM   rN   rO   r   r   r   r
   rQ   |  s    rQ   c                   s    e Zd Z fddZdd ZdS )z/TestHashMappingProtocol.test_eq.<locals>.BadCmpc                s
     d S )Nr   )r	   r   )rQ   r   r
   r     s    z6TestHashMappingProtocol.test_eq.<locals>.BadCmp.__eq__c             S   s   dS )Nr   r   )r	   r   r   r
   r     s    z8TestHashMappingProtocol.test_eq.<locals>.BadCmp.__hash__N)rM   rN   rO   r   r   r   )rQ   r   r
   BadCmp~  s   r   c                  s
     dkS )Nr   r   r   )r   r   r
   r      r!   z1TestHashMappingProtocol.test_eq.<locals>.<lambda>c                  s    kS )Nr   r   )d1d2r   r
   r      r!   )r,   r   r   r]   r^   r.   )r	   r   )r   rQ   r   r   r
   test_eqw  s    zTestHashMappingProtocol.test_eqc                s`   t |  G dd dt G  fdddt}|  }| }d||< d|_|  |j|g  d S )Nc               @   s   e Zd ZdS )z4TestHashMappingProtocol.test_setdefault.<locals>.ExcN)rM   rN   rO   r   r   r   r
   rQ     s    rQ   c                   s   e Zd ZdZ fddZdS )z8TestHashMappingProtocol.test_setdefault.<locals>.BadHashFc                s   | j r  ndS d S )NrJ   )r3   )r	   )rQ   r   r
   r     s    zATestHashMappingProtocol.test_setdefault.<locals>.BadHash.__hash__N)rM   rN   rO   r3   r   r   )rQ   r   r
   r     s   r   rJ   T)rf   rb   r]   r^   r   r3   r.   r<   )r	   r   r   r   r   )rQ   r
   rb     s    
z'TestHashMappingProtocol.test_setdefaultN)rM   rN   rO   rI   r   re   r   r   r   r   rb   r   r   r   r
   r     s   	r   )r   ru   r   r   r   rf   r   r   r   r   r
   <module>   s     , h