3
8฿L]  ใ               @   s^   d dl Z d dlZd dlZddlmZmZ G dd deZG dd deZG dd	 d	ej	Z
dS )
้    N้   )ฺ
WeakIDDictฺWeakIDKeyDictc               @   s$   e Zd Zdd Zdd Zdd ZdS )ฺ
AllTheSamec             C   s   dS )N้*   ฉ )ฺselfr   r   ๚F/tmp/pip-install-5sebvq2j/traits/traits/util/tests/test_weakidddict.pyฺ__hash__
   s    zAllTheSame.__hash__c             C   s   t |t| S )N)ฺ
isinstanceฺtype)r   ฺotherr   r   r	   ฺ__eq__   s    zAllTheSame.__eq__c             C   s   | j | S )N)r   )r   r   r   r   r	   ฺ__ne__   s    zAllTheSame.__ne__N)ฺ__name__ฺ
__module__ฺ__qualname__r
   r   r   r   r   r   r	   r   	   s   r   c               @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
ฺWeakreffableIntc             C   s
   || _ d S )N)ฺvalue)r   r   r   r   r	   ฺ__init__   s    zWeakreffableInt.__init__c             C   s
   t | jS )N)ฺhashr   )r   r   r   r	   r
      s    zWeakreffableInt.__hash__c             C   s$   t |tr| j|kS | j|jkS d S )N)r   ฺintr   )r   r   r   r   r	   r      s    

zWeakreffableInt.__eq__c             C   s   | j | S )N)r   )r   r   r   r   r	   r   !   s    zWeakreffableInt.__ne__N)r   r   r   r   r
   r   r   r   r   r   r	   r      s   r   c               @   s*   e Zd ZejrejjZdd Z	dd Z
dS )ฺTestWeakIDDictc                s$  t   g }g }ttd}xTt|dD ]F\}}t }|d sH|j| n
|j| | |< ~| jt | q&W | jt d ~| jt d | jt j	 ttddd | j fdd|D ttddd | jdd  j
 D dd  D  | jd	d  j
 D d	d |D  d S )
N้
   ้   r   ้   r   c                s   g | ]} | qS r   r   )ฺ.0ฺk)ฺwdr   r	   ๚
<listcomp>A   s    z1TestWeakIDDict.test_weak_keys.<locals>.<listcomp>c             S   s   g | ]}t |qS r   )ฺid)r   r   r   r   r	   r   D   s    c             S   s   g | ]}t |qS r   )r    )r   r   r   r   r	   r   F   s    )r   ฺlistฺrangeฺ	enumerater   ฺappendฺassertEqualฺlenฺassertCountEqualฺvaluesฺkeys)r   ฺkeepฺ	dont_keepr(   ฺnฺiฺkeyr   )r   r	   ฺtest_weak_keys)   s(    
 &$zTestWeakIDDict.test_weak_keysc          
      sพ  t   g }g }ttttd}xVt|dD ]H\}}t }|jd sP|j| n
|j| | |< ~| j	t
 | q,W | j	t
 d ~| j	t
 d | jt j tttdddddg | j	 fd	d
|D tttdddddg | jdd
  j D dd
  D  | jdd
  j D dd
 |D  |dd= | j	t
 d |dd= | j	t
 d |dd= | j	t
 d |dd= | j	t
 d |dd= | j	t
 d d S )Nr   r   r   r   r   ้   ้   ้   c                s   g | ]} | qS r   r   )r   r   )r   r   r	   r   d   s    z8TestWeakIDDict.test_weak_keys_values.<locals>.<listcomp>c             S   s   g | ]}t |qS r   )r    )r   r   r   r   r	   r   h   s    c             S   s   g | ]}t |qS r   )r    )r   r   r   r   r	   r   j   s    ้   )r   r!   ฺmapr   r"   r#   r   r   r$   r%   r&   r'   r(   r)   )r   r*   r+   r(   r,   r-   r.   r   )r   r	   ฺtest_weak_keys_valuesI   s@    

$*$ 




z$TestWeakIDDict.test_weak_keys_valuesN)r   r   r   ฺsixฺPY2ฺunittestฺTestCaseZassertItemsEqualr'   r/   r5   r   r   r   r	   r   %   s    r   )ฺgcr8   r6   Z
weakiddictr   r   ฺobjectr   r   r9   r   r   r   r   r	   ฺ<module>   s   