3
N้d  ใ               @   sN   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   ๚V/var/www/html/virt/lib64/python3.6/site-packages/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dd Zdd 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   c                s   g | ]} | qS r   r   )ฺ.0ฺk)ฺwdr   r   ๚
<listcomp>F   s    z1TestWeakIDDict.test_weak_keys.<locals>.<listcomp>c             S   s   g | ]}t |qS r   )ฺid)r   r   r   r   r   r   I   s    c             S   s   g | ]}t |qS r   )r    )r   r   r   r   r   r   K   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   i   s    z8TestWeakIDDict.test_weak_keys_values.<locals>.<listcomp>c             S   s   g | ]}t |qS r   )r    )r   r   r   r   r   r   m   s    c             S   s   g | ]}t |qS r   )r    )r   r   r   r   r   r   o   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_valuesN   s@    

$*$ 




z$TestWeakIDDict.test_weak_keys_valuesc             C   s8   t  }djt|}| j|t| | j|t| dS )z5 test string representation of the WeakIDDict class. z<WeakIDDict at 0x{0:x}>N)r   ฺformatr    r%   ฺstrฺrepr)r   Zweak_id_dictฺdesired_reprr   r   r   ฺ$test_weak_id_dict_str_representation   s    z3TestWeakIDDict.test_weak_id_dict_str_representationc             C   s<   t  }dt|dd}| j|t| | j|t| dS )z8 test string representation of the WeakIDKeyDict class. z<WeakIDKeyDict at 0xฺx๚>N)r   r    r%   r7   r8   )r   Zweak_id_key_dictr9   r   r   r   ฺ(test_weak_id_key_dict_str_representation   s    z7TestWeakIDDict.test_weak_id_key_dict_str_representationN)r   r   r   r/   r5   r:   r=   r   r   r   r   r   ,   s    1r   )	ZunittestZtraits.util.weakiddictr   r   ฺobjectr   r   ZTestCaser   r   r   r   r   ฺ<module>   s   