B
    u9a¼.  ã               @   sN   d dl Zd dlZd dlZd dlZd dlZG dd„ dejƒZedkrJe 	¡  dS )é    Nc               @   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S )ÚDictSetTestc             C   sv   t i  ¡ ƒ}|  t|i ¡ |  t|¡ t i  ¡ ƒ}|  t|i ¡ |  t|¡ t i  ¡ ƒ}|  t|i ¡ |  t|¡ d S )N)ÚtypeÚkeysÚassertRaisesÚ	TypeErrorÚitemsÚvalues)ÚselfZktÚitZvt© r   ú$/usr/lib/python3.7/test_dictviews.pyÚtest_constructors_not_callable	   s    z*DictSetTest.test_constructors_not_callablec             C   s  dddœ}|  ¡ }|  t|ƒd¡ |  t|ƒddh¡ |  |ddh¡ |  |dddh¡ |  |ddh¡ |  |dh¡ |  |d¡ |  d|¡ |  d|¡ |  d|¡ |  d	|¡ |  |  ¡ |  ¡ ¡ d
ddœ}|  |  ¡ |  ¡ ¡ |d= |  |  ¡ |  ¡ ¡ d S )Né
   ÚABC)é   Úaé   r   r   Úbé*   ÚZé   Údef)r   ÚassertEqualÚlenÚsetÚassertNotEqualÚassertInÚassertNotIn)r	   Údr   Úer   r   r   Útest_dict_keys   s$    

zDictSetTest.test_dict_keysc             C   s&  dddœ}|  ¡ }|  t|ƒd¡ |  t|ƒddh¡ |  |ddh¡ |  |dddh¡ |  |ddh¡ |  |dh¡ |  |d	¡ |  d|¡ |  d|¡ |  d
|¡ |  d|¡ |  d|¡ |  d|¡ |  d|¡ |  |  ¡ |  ¡ ¡ | ¡ }|  |  ¡ |  ¡ ¡ d|d< |  |  ¡ |  ¡ ¡ d S )Nr   r   )r   r   r   )r   r   )r   r   Zjunk)r   r   r   )r   r   r   r   )r   )r   r   é   r   r   )r   r   r   r   r   r   r   Úcopy)r	   r   r   r   r   r   r   Útest_dict_items(   s*    
zDictSetTest.test_dict_itemsc             C   s@   dddœ}dddœ}|   | ¡ | ¡ ¡ |  | ¡ | ¡ ¡ d S )Nr   é   ))r   r   )r   r   r   r   )r   r   )r   r   r   r   )r	   r   r   r   r   r   Útest_dict_mixed_keys_items?   s    

z&DictSetTest.test_dict_mixed_keys_itemsc             C   s:   dddœ}|  ¡ }|  t|ƒddh¡ |  t|ƒd¡ d S )Nr   r   )r   r   r   )r   r   r   r   )r	   r   r   r   r   r   Útest_dict_valuesE   s    
zDictSetTest.test_dict_valuesc             C   s¨   dddœ}|   t|ƒt¡ t| ¡ ƒ}|   |t¡ |  |dkpD|dk¡ t| ¡ ƒ}|   |t¡ |  |dkpr|dk¡ t| ¡ ƒ}|   |t¡ |  |dkp |d	k¡ d S )
Nr   r   )r   r   z#dict_items([('a', 'ABC'), (1, 10)])z#dict_items([(1, 10), ('a', 'ABC')])zdict_keys(['a', 1])zdict_keys([1, 'a'])zdict_values(['ABC', 10])zdict_values([10, 'ABC']))ÚassertIsInstanceÚreprÚstrr   Ú
assertTruer   r   )r	   r   Úrr   r   r   Útest_dict_reprK   s    


zDictSetTest.test_dict_reprc             C   sÜ  dddœ}dddœ}dddœ}|   | ¡ | ¡ @ d	d
h¡ |   | ¡ | ¡ @ d
h¡ |   | ¡ | ¡ @ tƒ ¡ |   | ¡ t| ¡ ƒ@ d	d
h¡ |   | ¡ t| ¡ ƒ@ d
h¡ |   | ¡ t| ¡ ƒ@ tƒ ¡ |   | ¡ t| ¡ ƒ@ d	d
h¡ |   | ¡ | ¡ B d	d
h¡ |   | ¡ | ¡ B d	d
dh¡ |   | ¡ | ¡ B d	d
ddh¡ |   | ¡ t| ¡ ƒB d	d
h¡ |   | ¡ t| ¡ ƒB d	d
dh¡ |   | ¡ t| ¡ ƒB d	d
ddh¡ |   | ¡ dB d	d
ddh¡ |   | ¡ | ¡ A tƒ ¡ |   | ¡ | ¡ A d	dh¡ |   | ¡ | ¡ A d	d
ddh¡ |   | ¡ t| ¡ ƒA tƒ ¡ |   | ¡ t| ¡ ƒA d	dh¡ |   | ¡ t| ¡ ƒA d	d
ddh¡ |   | ¡ t| ¡ ƒA d	dh¡ |   | ¡ | ¡  tƒ ¡ |   | ¡ | ¡  d	h¡ |   | ¡ | ¡  d	d
h¡ |   | ¡ t| ¡ ƒ tƒ ¡ |   | ¡ t| ¡ ƒ d	h¡ |   | ¡ t| ¡ ƒ d	d
h¡ |   | ¡ d d	d
h¡ |  | ¡  | ¡ ¡¡ |  | ¡  | ¡ ¡¡ |  | ¡  t| ¡ ƒ¡¡ |  | ¡  t| ¡ ƒ¡¡ |  | ¡  dddh¡¡ |  | ¡  dddg¡¡ |  | ¡  tdddgƒ¡¡ |  | ¡  tddgƒ¡¡ |  | ¡  ddg¡¡ |  | ¡  i ¡¡ |  | ¡  | ¡ ¡¡ i }|  | ¡  tƒ ¡¡ |  | ¡  g ¡¡ |  | ¡  | ¡ ¡¡ |  | ¡  dg¡¡ d S )Nr   r   )r   r   r!   )r   Úcé   é   )r   r   r   r   r-   r   r   )r   r   )r   r   ÚxÚyÚz)r   r   r   ÚtupleÚassertFalseÚ
isdisjointÚlistr*   )r	   Úd1Úd2Úd3Úder   r   r   Útest_keys_set_operations[   sb    


    "    z$DictSetTest.test_keys_set_operationsc             C   sî  dddœ}dddœ}dddœ}|   | ¡ | ¡ @ ddh¡ |   | ¡ | ¡ @ dh¡ |   | ¡ | ¡ @ tƒ ¡ |   | ¡ t| ¡ ƒ@ ddh¡ |   | ¡ t| ¡ ƒ@ dh¡ |   | ¡ t| ¡ ƒ@ tƒ ¡ |   | ¡ | ¡ B ddh¡ |   | ¡ | ¡ B dd	dh¡ |   | ¡ | ¡ B ddd
dh¡ |   | ¡ t| ¡ ƒB ddh¡ |   | ¡ t| ¡ ƒB dd	dh¡ |   | ¡ t| ¡ ƒB ddd
dh¡ |   | ¡ | ¡ A tƒ ¡ |   | ¡ | ¡ A dd	h¡ |   | ¡ | ¡ A ddd
dh¡ |   | ¡ | ¡  tƒ ¡ |   | ¡ | ¡  dh¡ |   | ¡ | ¡  ddh¡ |   | ¡ t| ¡ ƒ tƒ ¡ |   | ¡ t| ¡ ƒ dh¡ |   | ¡ t| ¡ ƒ ddh¡ |  | ¡  | ¡ ¡¡ |  | ¡  | ¡ ¡¡ |  | ¡  t| ¡ ƒ¡¡ |  | ¡  t| ¡ ƒ¡¡ |  | ¡  dddh¡¡ |  | ¡  dddg¡¡ |  | ¡  tdddgƒ¡¡ |  | ¡  tddgƒ¡¡ |  | ¡  i ¡¡ |  | ¡  | ¡ ¡¡ i }|  | ¡  tƒ ¡¡ |  | ¡  g ¡¡ |  | ¡  | ¡ ¡¡ |  | ¡  dg¡¡ d S )Nr   r   )r   r   r.   r/   )r   r   )r   r   )r   r   )r   r   )r   r.   )r   r/   r0   r1   r2   )r   r   r   r4   r5   r6   r*   )r	   r7   r8   r9   r:   r   r   r   Útest_items_set_operations“   sb    






 z%DictSetTest.test_items_set_operationsc             C   sH   i }|  ¡ |d< t|ƒ}|  |t¡ | ¡ |d< t|ƒ}|  |t¡ d S )Nr   )r   r(   r'   r)   r   )r	   r   r+   r   r   r   Útest_recursive_reprË   s    zDictSetTest.test_recursive_reprc             C   s<   i }x$t t ¡ d ƒD ]}d| ¡ i}qW |  tt|¡ d S )Néd   r   )ÚrangeÚsysÚgetrecursionlimitr   r   ÚRecursionErrorr(   )r	   r   Úir   r   r   Útest_deeply_nested_reprØ   s    z#DictSetTest.test_deeply_nested_reprc             C   sJ   dddœ}|   ttj| ¡ ¡ |   ttj| ¡ ¡ |   ttj| ¡ ¡ d S )Nr   r   )r   r   )r   r   r"   r   r   r   )r	   r   r   r   r   Ú	test_copyÞ   s    
zDictSetTest.test_copyc          	      s   G dd„ dt ƒ‰ G ‡ fdd„dƒ}|ƒ |ƒ  }}|ƒ |ƒ  }}||i}|  ||¡ |  || ¡ ¡ |  || ¡ ¡ |  ||f| ¡ ¡ |  ˆ |j|¡ |  ˆ | ¡ j|¡ |  ˆ | ¡ j||f¡ |  ˆ | ¡ j||f¡ |  ˆ ¡ || ¡ k W d Q R X d S )Nc               @   s   e Zd ZdS )z+DictSetTest.test_compare_error.<locals>.ExcN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   ÚExcå   s   rI   c                   s    e Zd Zdd„ Z‡ fdd„ZdS )z-DictSetTest.test_compare_error.<locals>.BadEqc             S   s   dS )Né   r   )r	   r   r   r   Ú__hash__é   s    z6DictSetTest.test_compare_error.<locals>.BadEq.__hash__c                s   ˆ ‚d S )Nr   )r	   Úother)rI   r   r   Ú__eq__ë   s    z4DictSetTest.test_compare_error.<locals>.BadEq.__eq__N)rF   rG   rH   rK   rM   r   )rI   r   r   ÚBadEqè   s   rN   )Ú	Exceptionr   r   r   r   r   Ú__contains__)r	   rN   Zk1Zk2Zv1Zv2r   r   )rI   r   Útest_compare_errorä   s    zDictSetTest.test_compare_errorc             C   sz   dddœ}xjt tjd ƒD ]X}|  ttjftj| ¡ |¡ |  ttjftj| ¡ |¡ |  ttjftj| 	¡ |¡ qW d S )Nr   r   )r   r   r   )
r?   ÚpickleZHIGHEST_PROTOCOLr   r   ZPicklingErrorÚdumpsr   r   r   )r	   r   Úprotor   r   r   Útest_pickleþ   s    
zDictSetTest.test_picklec             C   s:  t dd}|  | ¡ tjj¡ |  | ¡ tjj¡ |  | ¡ tjj¡ |  | ¡ tjj¡ |  | ¡ tjj	¡ |  | ¡ tjj
¡ |  | ¡ tjj¡ |  | ¡ tjj¡ |  | ¡ tjj¡ |  | ¡ tjj¡ |  | ¡ tjj¡ |  | ¡ tjj¡ |  | ¡ tjj¡ |  | ¡ tjj	¡ |  | ¡ tjj
¡ d S )Nr   )r   )Údictr'   r   ÚcollectionsÚabcÚKeysViewÚMappingViewÚSetÚSizedÚIterableÚ	Containerr   Ú
ValuesViewr   Ú	ItemsView)r	   r   r   r   r   Útest_abc_registry  s     
zDictSetTest.test_abc_registryN)rF   rG   rH   r   r    r#   r%   r&   r,   r;   r<   r=   rD   rE   rQ   rU   ra   r   r   r   r   r      s   88
r   Ú__main__)
Zcollections.abcrW   r"   rR   r@   ZunittestZTestCaser   rF   Úmainr   r   r   r   Ú<module>   s     