a
    ze                    @   s  d dl Z d dlmZ d dlZd dlZd dlZd dlZd dlZd dlm	Z	m
Z
 d dlZd dlZd dlZd dlZG dd deZdd ZG dd	 d	ZG d
d dZG dd deZG dd dZG dd dee j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e jZG dd deZ G dd deZ!e Z"G d d! d!Z#G d"d# d#e#e jZ$G d$d% d%e#e jZ%G d&d' d'e#e jZ&G d(d) d)e#e jZ'G d*d+ d+e#e jZ(G d,d- d-e#e jZ)G d.d/ d/e#e jZ*d0d1 Z+d2d3 Z,G d4d5 d5e jZ-G d6d7 d7e jZ.G d8d9 d9e jZ/G d:d; d;e jZ0G d<d= d=e jZ1G d>d? d?Z2G d@dA dAe2e jZ3G dBdC dCe2e jZ4G dDdE dEe2e jZ5G dFdG dGe2e jZ6G dHdI dIe2e jZ7G dJdK dKZ8G dLdM dMe8e jZ9G dNdO dOe8e jZ:G dPdQ dQe8e jZ;G dRdS dSe8e jZ<G dTdU dUe8e jZ=G dVdW dWe8e jZ>G dXdY dYZ?G dZd[ d[e?e jZ@G d\d] d]e?e jZAG d^d_ d_e?e jZBG d`da dae?e jZCG dbdc dce?e jZDG ddde dee jZEdfdg ZFG dhdi diZGG djdk dkZHG dldm dmZIG dndo doZJG dpdq dqZKG drds dsZLG dtdu duZMd dvlmNZN dwdx ZOG dydz dze jZPG d{d| d|ZQG d}d~ d~ZRG dd de jZSG dd dZTG dd deTZUG dd deUe jZVG dd deUe jZWG dd deUe jZXG dd deUe jZYG dd deTZZG dd deZe jZ[G dd deZe jZ\G dd deZe jZ]G dd deZe jZ^G dd deZe jZ_G dd deZe jZ`dd Zadd Zbdd Zcdd ZdG dd de jZeefdkre g  dS )    N)support)	randrangeshufflec                   @   s   e Zd ZdS )PassThruN__name__
__module____qualname__ r
   r
   #/usr/lib/python3.9/test/test_set.pyr      s   r   c                   c   s   t dV  d S N   )r   r
   r
   r
   r   check_pass_thru   s    r   c                   @   s   e Zd Zdd Zdd ZdS )BadCmpc                 C   s   dS r   r
   selfr
   r
   r   __hash__   s    zBadCmp.__hash__c                 C   s   t d S N)RuntimeErrorr   otherr
   r
   r   __eq__   s    zBadCmp.__eq__Nr   r   r	   r   r   r
   r
   r
   r   r      s   r   c                   @   s   e Zd ZdZdd ZdS )ReprWrapperz*Used to test self-referential repr() callsc                 C   s
   t | jS r   )reprvaluer   r
   r
   r   __repr__   s    zReprWrapper.__repr__N)r   r   r	   __doc__r   r
   r
   r
   r   r      s   r   c                   @   s    e Zd ZdZdd Zdd ZdS )HashCountingIntzBint-like object that counts the number of times __hash__ is calledc                 G   s
   d| _ d S Nr   
hash_count)r   argsr
   r
   r   __init__"   s    zHashCountingInt.__init__c                 C   s   |  j d7  _ t| S r   )r!   intr   r   r
   r
   r   r   $   s    zHashCountingInt.__hash__N)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	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/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9S ):TestJointOpsc                 C   s2   d | _ }d| _d| _| || _t|| _d S )NZ
simsalabimZ
madagascarZ4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ)word	otherwordlettersthetypesdictfromkeysd)r   r&   r
   r
   r   setUp+   s
    
zTestJointOps.setUpc                 C   s*   |  t| jg d | j tt jdd d S )N   r   a)assertRaises	TypeErrorr)   setr#   r   r
   r
   r   test_new_or_init2   s    zTestJointOps.test_new_or_initc                 C   sH   t | j}t | j}| || | t| jt  | t| jg g d S r   )	sortedr*   r-   assertEqualr2   r   r)   r   r3   )r   actualexpectedr
   r
   r   test_uniquification6   s
    

z TestJointOps.test_uniquificationc                 C   s   |  t| jt| j d S r   )r7   lenr*   r-   r   r
   r
   r   test_len=   s    zTestJointOps.test_lenc                 C   sb   | j D ]}| || jv || jv  q| t| jjg g | t| j g}| 	| | j | d S r   )
r(   r7   r*   r-   r2   r3   __contains__r)   	frozensetassertIn)r   cr*   r
   r
   r   test_contains@   s
    
zTestJointOps.test_containsc                 C   s  | j | j}| jD ]$}| ||v || jv p4|| jv  q| | j | | j | t|| j	 | 
t| j jt  | 
t| j jg g tttjtttfD ]}| | d|dtd | | d|dtd | | d|dtd | | d|dtd	 | | d|d|d
td q|  }| |tdg|tdg| ddg d S )NabcbacdcabcdefgfeabcefgccbabcefabcefZfgr   r/   )r*   unionr'   r(   r7   r-   r)   r&   typebasetyper2   r   r   r3   r4   r>   r+   r,   strlisttuple)r   ur@   Cxr
   r
   r   
test_unionG   s    
"    (zTestJointOps.test_unionc                 C   sp   | j | j}| | j t| jB | | | j t| jB | z| j | jB  W n ty`   Y n0 | d d S )Nz(s|t did not screen-out general iterables)r*   rK   r'   r7   r4   r>   r3   failr   ir
   r
   r   test_orZ   s    zTestJointOps.test_orc                 C   s  | j | j}| jD ]$}| ||v || jv o4|| jv  q| | j | | j | t|| j	 | 
t| j jt  tttjtttfD ]}| | d|dtd | | d|dtd | | d|dtd | | d|dtd | | d|d	|d
td q| d}| }| jt krj| t|t| n| t|t| d S )NrB   rC   ccrE    rG   bcrI   ZcbcfZbagb)r*   intersectionr'   r(   r7   r-   r)   r&   rL   rM   r2   r   r   r4   r>   r+   r,   rN   rO   rP   idassertNotEqual)r   rW   r@   rR   r*   zr
   r
   r   test_intersectione   s"    
"    (
zTestJointOps.test_intersectionc           	      C   s   dd }dD ]n}|  |}dD ]Z}tttjtttfD ]B}||}||}|||}| 	|| | 
|du pr|du  q4qqd S )Nc                 S   s   t | | S )z&Pure python equivalent of isdisjoint())r4   r]   )s1s2r
   r
   r   fz   s    z'TestJointOps.test_isdisjoint.<locals>.f)
rZ   r1   abrH   ZababacrC   rY   rE   rG   rI   TF)r)   r4   r>   r+   r,   rN   rO   rP   
isdisjointr7   
assertTrue)	r   rd   Zlargrb   ZrargrR   rc   r8   r9   r
   r
   r   test_isdisjointy   s    


zTestJointOps.test_isdisjointc                 C   sp   | j | j}| | j t| j@ | | | j t| j@ | z| j | j@  W n ty`   Y n0 | d d S )Nz(s&t did not screen-out general iterables)r*   r]   r'   r7   r4   r>   r3   rU   rV   r
   r
   r   test_and   s    zTestJointOps.test_andc                 C   sf  | j | j}| jD ]$}| ||v || jv o4|| jv q| | j | | j | t|| j	 | 
t| j jt  | 
t| j jg g tttjtttfD ]}| | d|dtd | | d|dtd | | d|dtd | | d|dtd | | d td | | d|d|d	td
 qd S )NrB   rC   re   rE   rH   rG   r1   rI   r\   r@   )r*   
differencer'   r(   r7   r-   r)   r&   rL   rM   r2   r   r   r3   r4   r>   r+   r,   rN   rO   rP   r   rW   r@   rR   r
   r
   r   test_difference   s    
"    zTestJointOps.test_differencec                 C   sp   | j | j}| | j t| j | | | j t| j | z| j | j  W n ty`   Y n0 | d d S )Nz(s-t did not screen-out general iterables)r*   rj   r'   r7   r4   r>   r3   rU   rV   r
   r
   r   test_sub   s    zTestJointOps.test_subc                 C   s&  | j | j}| jD ]$}| ||v || jv || jv A  q| | j | | j | t|| j	 | 
t| j jt  | 
t| j jg g tttjtttfD ]}| | d|dtd | | d|dtd | | d|dtd | | d|dtd	 qd S )
NrB   rC   abdrE   rF   rG   r1   rI   rJ   )r*   symmetric_differencer'   r(   r7   r-   r)   r&   rL   rM   r2   r   r   r3   r4   r>   r+   r,   rN   rO   rP   rk   r
   r
   r   test_symmetric_difference   s    
"   z&TestJointOps.test_symmetric_differencec                 C   sp   | j | j}| | j t| jA | | | j t| jA | z| j | jA  W n ty`   Y n0 | d d S )Nz(s^t did not screen-out general iterables)r*   ro   r'   r7   r4   r>   r3   rU   rV   r
   r
   r   test_xor   s    zTestJointOps.test_xorc                 C   s|   |  | jt| j |  | jt| j |  | j| jkd | | jt| j | | jt| j |  | j| jkd d S NFT)r7   r*   r4   r&   r>   r_   r'   r   r
   r
   r   test_equality   s    zTestJointOps.test_equalityc                 C   s,   t tg d}| |}| t|d d S )N)ZabcdefZbcdZbdcbZfedZfedccba   )mapr>   r)   r7   r;   )r   tr*   r
   r
   r   test_setOfFrozensets   s    
z!TestJointOps.test_setOfFrozensetsc                 C   s   t | jg d\}}}| ||k  | ||k | ||k | ||k | ||k | ||k  | ||k | ||k | ||k | tdd | tdd | tdd | tdd d S )N)re   Zabcdedefr1   rH   Zcbs)ru   r)   rg   ZassertFalser4   issubset
issuperset)r   pqrr
   r
   r   test_sub_and_super   s    zTestJointOps.test_sub_and_superc                 C   s   t tjd D ]z}t| j|}t|}| | j|d| j|f  t| jtt	fvrd| j_
t| j|}t|}| | jj
|j
 qd S )Nr   %s != %s
   )rangepickleHIGHEST_PROTOCOLdumpsr*   loadsr7   rL   r4   r>   rS   )r   rW   r{   dupr
   r
   r   test_pickling   s    

zTestJointOps.test_picklingc              	   C   s   t tjd D ]}t| j}| | j}t||}t|}| |t	j
j | | || t|}zt|}W n ty   Y qY n0 t||}t|}| | ||| |f  qd S r   )r   r   r   iterr*   r)   r   r   ZassertIsInstancecollectionsrH   Iteratorr7   nextStopIteration)r   protoZitorgdatar-   itZdropr
   r
   r   test_iterator_pickling   s    




z#TestJointOps.test_iterator_picklingc                    s~   G  fddd  d}|  |g}t|}| t|t| |D ]}|}qH| t|t| | |jd |j d S )Nc                       s*   e Zd Zdd Zdd Zd fdd	ZdS )	z*TestJointOps.test_deepcopy.<locals>.Tracerc                 S   s
   || _ d S r   r   )r   r   r
   r
   r   r#     s    z3TestJointOps.test_deepcopy.<locals>.Tracer.__init__c                 S   s   | j S r   r   r   r
   r
   r   r     s    z3TestJointOps.test_deepcopy.<locals>.Tracer.__hash__Nc                    s    | j d S r   r   )r   memoTracerr
   r   __deepcopy__	  s    z7TestJointOps.test_deepcopy.<locals>.Tracer.__deepcopy__)N)r   r   r	   r#   r   r   r
   r   r
   r   r     s   r   r   r   )r)   copydeepcopyr_   r^   r7   r   )r   rv   r*   r   elemZnewtr
   r   r   test_deepcopy  s    
zTestJointOps.test_deepcopyc                    sN   G dd d t  fddtdD }|D ]}||_||_t |g|_ q,d S )Nc                   @   s   e Zd ZdS )zTestJointOps.test_gc.<locals>.ANr   r
   r
   r
   r   A  s   r   c                 3   s   | ]}  V  qd S r   r
   .0rW   r   r
   r   	<genexpr>      z'TestJointOps.test_gc.<locals>.<genexpr>  )r4   r   cyclesub)r   r*   r   r
   r   r   test_gc  s    zTestJointOps.test_gcc                 C   sV   G dd d| j }| }t }|| | || || || || d S )Nc                   @   s   e Zd Zdd ZdS )z6TestJointOps.test_subclass_with_custom_hash.<locals>.Hc                 S   s   t t| d@ S )Ni)r$   r^   r   r
   r
   r   r   !  s    z?TestJointOps.test_subclass_with_custom_hash.<locals>.H.__hash__N)r   r   r	   r   r
   r
   r
   r   H   s   r   )r)   r4   addr?   removediscard)r   r   r*   rd   r
   r
   r   test_subclass_with_custom_hash  s    


z+TestJointOps.test_subclass_with_custom_hashc                 C   s|   |  t g}| t| j t t g | t|jt  t|drx| t|jt  | t|jt  | t|jt  d S )Nr   )	r)   r   r2   r   r=   hasattrr   r   r   r   r*   r
   r
   r   test_badcmp+  s    
zTestJointOps.test_badcmpc                 C   sb   t  }| |g}||_| jtkr4| t|d n*t|dd }| t|d||f  d S )Nz
{set(...)}(r   z%s({%s(...)}))r   r)   r   r4   r7   r   	partition)r   wr*   namer
   r
   r   test_cyclical_repr6  s    
zTestJointOps.test_cyclical_reprc              	   C   s   t  }| |g}||_ttjd}zN|t| |  ttjd}| 	|
 t| W |  ttj n|  ttj 0 d S Nr   r}   )r   r)   r   openr   TESTFNwriterN   closer7   readr   unlink)r   r   r*   for
   r
   r   test_cyclical_print@  s    z TestJointOps.test_cyclical_printc                 C   s:  d}t ttt|}| tdd |D | | |}| tdd |D | || | tdd |D | t	|dr|
| | tdd |D | t t|}| tdd |D | t t|}| td	d |D | t t|d
}| tdd |D | | |t |d
 d S )Nr   c                 s   s   | ]}|j V  qd S r   r    r   r   r
   r
   r   r   Q  r   z<TestJointOps.test_do_not_rehash_dict_keys.<locals>.<genexpr>c                 s   s   | ]}|j V  qd S r   r    r   r
   r
   r   r   S  r   c                 s   s   | ]}|j V  qd S r   r    r   r
   r
   r   r   U  r   symmetric_difference_updatec                 s   s   | ]}|j V  qd S r   r    r   r
   r
   r   r   X  r   c                 s   s   | ]}|j V  qd S r   r    r   r
   r
   r   r   Z  r   c                 s   s   | ]}|j V  qd S r   r    r   r
   r
   r   r   \  r   {   c                 s   s   | ]}|j V  qd S r   r    r   r
   r
   r   r   ^  r   )r+   r,   ru   r   r   r7   sumr)   rj   r   r   r4   r>   )r   nr-   r*   Zd2Zd3r
   r
   r   test_do_not_rehash_dict_keysN  s"    



z)TestJointOps.test_do_not_rehash_dict_keysc                 C   sX   G dd dt }| }t|}t|dg}t||_~~t  | | d u d d S )Nc                   @   s   e Zd ZdS )z/TestJointOps.test_container_iterator.<locals>.CNr   r
   r
   r
   r   rR   c  s   rR   r   zCycle was not collected)	objectweakrefrefr4   r   rS   gcZcollectrg   )r   rR   objr   	containerr
   r
   r   test_container_iteratora  s    

z$TestJointOps.test_container_iteratorc                 C   s   t | t| j d S r   )r   Zcheck_free_after_iteratingr   r)   r   r
   r
   r   test_free_after_iteratingm  s    z&TestJointOps.test_free_after_iteratingN)r   r   r	   r.   r5   r:   r<   rA   rT   rX   ra   rh   ri   rl   rm   rp   rq   rs   rw   r~   r   r   r   r   r   r   r   r   r   r   r   r
   r
   r
   r   r%   (   s8   

r%   c                   @   s   e Zd ZeZe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d-d. Zd/d0 Zd1d2 Ze e!ed3d4d5d6 Z"d7S )8TestSetc                 C   sj   |   }|| j | |t| j || j | |t| j | t|j|d | t|jd d S )Nr/   r   )r)   r#   r&   r7   r4   r'   r2   r3   r   r
   r
   r   	test_initt  s    zTestSet.test_initc                 C   s0   |  td}|  |}| t|t| d S Nrt   r)   r   r_   r^   r   r*   rv   r
   r
   r   test_constructor_identity}  s    
z!TestSet.test_constructor_identityc                 C   s$   t g d}h d}| || d S )Nr   r/   rt      r   r/   rt   r4   r7   r   r
   r
   r   test_set_literal  s    zTestSet.test_set_literalc                 C   s4   h d}|  t|d | }|  t|t d S )N>   r   r   )r7   r;   poprL   r$   )r   r*   Zstored_valuer
   r
   r    test_set_literal_insertion_order  s    z(TestSet.test_set_literal_insertion_orderc                    s:   g   fdd}|d|d|dh}|   g d d S )Nc                    s     |  d S r   )append)r   eventsr
   r   record  s    z9TestSet.test_set_literal_evaluation_order.<locals>.recordr   r/   rt   r   )r7   )r   r   r*   r
   r   r   !test_set_literal_evaluation_order  s    z)TestSet.test_set_literal_evaluation_orderc                 C   s   |  tt| j d S r   )r2   r3   hashr*   r   r
   r
   r   	test_hash  s    zTestSet.test_hashc                 C   s0   | j   | | j t  | t| j d d S r   )r*   clearr7   r4   r;   r   r
   r
   r   
test_clear  s    
zTestSet.test_clearc                 C   sD   | j  }| | j | | t| j t| | t|| j d S r   )r*   r   r7   r_   r^   rL   rM   r   r   r
   r
   r   	test_copy  s    
zTestSet.test_copyc                 C   sT   | j d | d| j  | j  }| j d | | j | | t| j jg  d S )NQ)r*   r   r?   r   r7   r2   r3   r   r
   r
   r   test_add  s    
zTestSet.test_addc                 C   s   | j d | d| j  | t| j jd | t| j jg  | t| jg}| 	| | j| || | j | | | j| | t| j j| | j d S Nr1   r   )
r*   r   assertNotInr2   KeyErrorr3   r)   r>   r&   r?   r   r
   r
   r   test_remove  s    zTestSet.test_removec                 C   sb   dD ]X}z| j | W n: tyR } z"|jd }| || W Y d }~qd }~0 0 |   qd S )N)r   r   r   )r*   r   r   r"   r7   rU   )r   v1ev2r
   r
   r   test_remove_keyerror_unpacking  s    
"z&TestSet.test_remove_keyerror_unpackingc                 C   st   |  ddg}z| j| W nH tyf } z0| |jd |u d||jd  W Y d }~nd }~0 0 |   d S )Nrt      r   zKeyError should be {0}, not {1})r)   r*   r   r   rg   r"   formatrU   )r   keyr   r
   r
   r   test_remove_keyerror_set  s    z TestSet.test_remove_keyerror_setc                 C   s   | j d | d| j  | j d | t| j jg  | t| jg}| | | j| || | j | | | j| || | j d S r   )	r*   r   r   r2   r3   r)   r>   r&   r?   r   r
   r
   r   test_discard  s    zTestSet.test_discardc                 C   s@   t t| jD ]}| j }| || j q| t| jj d S r   )r   r;   r*   r   r   r2   r   )r   rW   r   r
   r
   r   test_pop  s    
zTestSet.test_popc              	   C   s(  | j | j}| |d  | j| j D ]}| || j  q&| t| j jt  | t	| j jg g dD ]P\}}t
ttjtttfD ]4}| d}| |||d  | |t
| qqfdD ]f}d}t
ttjtttfD ]J}| d}| |||||d  | |t
|t
|B t
|B  qqd S )N))rC   rD   rE   rF   )rG   rH   rI   rJ   rB   )rC   rE   rG   rI   ZabcdaZahi)r*   updater'   r7   r&   r?   r2   r   r   r3   r4   r>   r+   r,   rN   rO   rP   r)   r   retvalr@   r{   r|   rR   r*   r
   r
   r   test_update  s"    

zTestSet.test_updatec                 C   s8   |  j t| jO  _ | j| j D ]}| || j  q d S r   )r*   r4   r'   r&   r?   r   r@   r
   r
   r   test_ior  s    zTestSet.test_iorc           	   	   C   s.  | j | j}| |d  | j| j D ]6}|| jv rN|| jv rN| || j  q&| || j  q&| t| j jt	  | t
| j jg g dD ]\}}tttjtttfD ]}| d}| |||d  | |t| d}| |}d}| |||||d  | |tdt|@ t|@  qqd S )N))rC   r@   )rE   rZ   )rG   r[   )rI   rZ   rB   Zcbc)r*   intersection_updater'   r7   r&   r?   r   r2   r   r   r3   r4   r>   r+   r,   rN   rO   rP   r)   )	r   r   r@   r{   r|   rR   r*   ssrv   r
   r
   r   test_intersection_update  s$    

z TestSet.test_intersection_updatec                 C   s\   |  j t| jM  _ | j| j D ]6}|| jv rH|| jv rH| || j  q | || j  q d S r   r*   r4   r'   r&   r?   r   r   r
   r
   r   	test_iand  s
    zTestSet.test_iandc                 C   sr  | j | j}| |d  | j| j D ]6}|| jv rN|| jvrN| || j  q&| || j  q&| t| j jt	  | t
| j jg g | t
| j jg g dD ]\}}tttjtttfD ]}| d}| |||d  | |t| | d}|  | || d | d}||d | || d | d}||d|d | || d qqd S )N))rC   re   )rE   rH   rG   r1   )rI   rH   rB   Z
abcdefghihZabaZcdefghihrC   Zefghih)r*   difference_updater'   r7   r&   r?   r   r2   r   r   r3   r   r4   r>   r+   r,   rN   rO   rP   r)   r   r
   r
   r   test_difference_update  s.    



zTestSet.test_difference_updatec                 C   s\   |  j t| j8  _ | j| j D ]6}|| jv rH|| jvrH| || j  q | || j  q d S r   r   r   r
   r
   r   	test_isub0  s
    zTestSet.test_isubc                 C   s   | j | j}| |d  | j| j D ]6}|| jv || jv A rN| || j  q&| || j  q&| t| j jt	  | t
| j jg g dD ]P\}}tttjtttfD ]4}| d}| |||d  | |t| qqd S )N))rC   rn   r   r   r   rB   )r*   r   r'   r7   r&   r?   r   r2   r   r   r3   r4   r>   r+   r,   rN   rO   rP   r)   r   r
   r
   r    test_symmetric_difference_update8  s    
z(TestSet.test_symmetric_difference_updatec                 C   s\   |  j t| jN  _ | j| j D ]6}|| jv || jv A rH| || j  q | || j  q d S r   r   r   r
   r
   r   	test_ixorH  s
    zTestSet.test_ixorc                 C   st   | j  }||O }| || j  ||M }| || j  ||8 }| ||   | j  }||N }| ||   d S r   )r*   r   r7   r)   )r   rv   r
   r
   r   test_inplace_on_selfP  s    

zTestSet.test_inplace_on_selfc                 C   sF   |  d}t|}| t|t| d }t  | tt| d S )NZgallahad)	r)   r   proxyr7   rN   r   
gc_collectr2   ReferenceError)r   r*   r{   r
   r
   r   test_weakref\  s    

zTestSet.test_weakrefc                 C   s   G dd d}h d}| }||k  |  |j | }||k |  |j | }||k |  |j | }||k |  |j d S )Nc                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
z5TestSet.test_rich_compare.<locals>.TestRichSetComparec                 S   s
   d| _ dS NTF)	gt_calledr   Zsome_setr
   r
   r   __gt__f  s    z<TestSet.test_rich_compare.<locals>.TestRichSetCompare.__gt__c                 S   s
   d| _ dS r  )	lt_calledr
  r
   r
   r   __lt__i  s    z<TestSet.test_rich_compare.<locals>.TestRichSetCompare.__lt__c                 S   s
   d| _ dS r  )	ge_calledr
  r
   r
   r   __ge__l  s    z<TestSet.test_rich_compare.<locals>.TestRichSetCompare.__ge__c                 S   s
   d| _ dS r  )	le_calledr
  r
   r
   r   __le__o  s    z<TestSet.test_rich_compare.<locals>.TestRichSetCompare.__le__N)r   r   r	   r  r  r  r  r
   r
   r
   r   TestRichSetComparee  s   r  r   )rg   r	  r  r  r  )r   r  ZmysetZmyobjr
   r
   r   test_rich_compared  s    zTestSet.test_rich_compare
test_c_apiz*C API test only available in a debug buildc                 C   s   |  t  d d S NT)r7   r4   r  r   r
   r
   r   r    s    zTestSet.test_c_apiN)#r   r   r	   r4   r)   rM   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  unittestZ
skipUnlessr   r  r
   r
   r
   r   r   p  s>   	$r   c                   @   s   e Zd ZdS )SetSubclassNr   r
   r
   r
   r   r    s   r  c                   @   s   e Zd ZeZeZdS )TestSetSubclassN)r   r   r	   r  r)   r4   rM   r
   r
   r
   r   r    s   r  c                   @   s   e Zd Zg dfddZdS )SetSubclassWithKeywordArgsNc                 C   s   t | | d S r   )r4   r#   )r   iterablenewargr
   r
   r   r#     s    z#SetSubclassWithKeywordArgs.__init__)r   r   r	   r#   r
   r
   r
   r   r    s   r  c                   @   s   e Zd Zdd ZdS )TestSetSubclassWithKeywordArgsc                 C   s   t dd dS )z=SF bug #1486663 -- this used to erroneously raise a TypeErrorr   )r  N)r  r   r
   r
   r   test_keywords_in_subclass  s    z8TestSetSubclassWithKeywordArgs.test_keywords_in_subclassN)r   r   r	   r  r
   r
   r
   r   r    s   r  c                   @   sT   e Zd ZeZe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 )TestFrozenSetc                 C   s.   |  | j}|| j | |t| j d S r   )r)   r&   r#   r'   r7   r4   r   r
   r
   r   r     s    zTestFrozenSet.test_initc                 C   sn   t  }t  t g t dt dt  t g t dt dt tdt t  t ||g}| tttt|d d S )Nr
   rZ   r   r   )r>   r   r7   r;   r4   ru   r^   )r   rd   efsr
   r
   r   test_singleton_empty_frozenset  s    z,TestFrozenSet.test_singleton_empty_frozensetc                 C   s0   |  td}|  |}| t|t| d S r   )r)   r   r7   r^   r   r
   r
   r   r     s    
z'TestFrozenSet.test_constructor_identityc                    s~   |  t| dt| d d  fddt D }t }tdD ] }t| |t| | qH|  t|d d S )NZabcdebZebecdad   c                    s   g | ]}t  qS r
   r   r   r   r
   r   
<listcomp>  r   z+TestFrozenSet.test_hash.<locals>.<listcomp>   r   )r7   r   r)   r   r4   r   r   r;   )r   seqresultsrW   r
   r#  r   r     s    zTestFrozenSet.test_hashc                 C   s$   | j  }| t| j t| d S r   )r*   r   r7   r^   r   r
   r
   r   r     s    
zTestFrozenSet.test_copyc                 C   sr   t tdt d dg }| |}| t|}| || | t|t| i }d||< | || d d S )Nr   ZabcdefgZapple*   )rO   r   r)   reversedr7   r_   r^   )r   r&  Zkey1Zkey2r-   r
   r
   r   test_frozen_as_dictkey  s    
z$TestFrozenSet.test_frozen_as_dictkeyc                 C   s"   |  d}| t|t| d S )NZabcdcda)r)   r7   r   r   rd   r
   r
   r   test_hash_caching  s    
zTestFrozenSet.test_hash_cachingc           
   	      s   d}t  }|j}dd t|D }td| D ]" |tt fdd|D  q.| t|d|  dd }dd	 }td
D ]V}d| }|d t|fD ]8}tfddtt|||D }	| d|	 | qq~d S )N   c                 S   s   g | ]}|d  d |> fqS r   r
   r   r
   r
   r   r$    r   z9TestFrozenSet.test_hash_effectiveness.<locals>.<listcomp>r/   c                    s   g | ]\}}| @ r|qS r
   r
   )r   r   mrW   r
   r   r$    r   c                 S   s8   t  g}t| d D ]}t |}|| q|d |  S r   )r>   r   r   )r   numsrW   numr
   r
   r   zf_range  s
    z7TestFrozenSet.test_hash_effectiveness.<locals>.zf_rangec                 s   s2   t t| d D ]}ttt| |E d H  qd S r   )r   r;   ru   r>   	itertoolscombinations)r*   rW   r
   r
   r   powerset  s    z7TestFrozenSet.test_hash_effectiveness.<locals>.powerset   r   c                    s   h | ]}| @ qS r
   r
   )r   h)maskr
   r   	<setcomp>  r   z8TestFrozenSet.test_hash_effectiveness.<locals>.<setcomp>r   )	r4   r   r   r   r>   r7   r;   ru   ZassertGreater)
r   r   Z
hashvaluesZaddhashvalueZ	elemmasksr2  r5  rv   r0  rQ   r
   )rW   r8  r   test_hash_effectiveness  s     $z%TestFrozenSet.test_hash_effectivenessN)r   r   r	   r>   r)   rM   r   r   r   r   r   r*  r,  r:  r
   r
   r
   r   r    s   	
r  c                   @   s   e Zd ZdS )FrozenSetSubclassNr   r
   r
   r
   r   r;    s   r;  c                   @   s4   e Zd ZeZeZdd Zdd Zdd Z	dd Z
d	S )
TestFrozenSetSubclassc                 C   s0   |  td}|  |}| t|t| d S r   r   r   r
   r
   r   r     s    
z/TestFrozenSetSubclass.test_constructor_identityc                 C   s$   | j  }| t| j t| d S r   )r*   r   r_   r^   r   r
   r
   r   r     s    
zTestFrozenSetSubclass.test_copyc                 C   s"   |   }|  |}| || d S r   )r)   r7   r   r
   r
   r   test_nested_empty_constructor   s    
z3TestFrozenSetSubclass.test_nested_empty_constructorc                 C   s   | j }t }| }| |g |d|d| |g |d|d|td|| |t ||||||g}| tttt|t| d S )Nr
   rZ   r   )r)   r>   r   r7   r;   r4   ru   r^   )r   Z	Frozensetrd   Fr  r
   r
   r   r     s    z4TestFrozenSetSubclass.test_singleton_empty_frozensetN)r   r   r	   r;  r)   r>   rM   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	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/d0 Zd1S )2TestBasicOpsc                 C   s"   | j d ur| t | j| j  d S r   )r   r7   r4   r   r
   r
   r   	test_repr  s    
zTestBasicOps.test_reprc                 C   sl   t | j}| |d | |d |dd d}|  dd | jD }|  | || d S )N{}r   z, c                 S   s   g | ]}t |qS r
   )r   )r   r   r
   r
   r   r$  #  r   z:TestBasicOps.check_repr_against_values.<locals>.<listcomp>)	r   r4   rg   
startswithendswithsplitsortvaluesr7   )r   textresultZsorted_repr_valuesr
   r
   r   check_repr_against_values  s    
z&TestBasicOps.check_repr_against_valuesc              	   C   sz   z^t tjd}|t| j |  t tjd}| | t	| j W |  t
tj n|  t
tj 0 d S r   )r   r   r   r   rN   r4   r   r7   r   r   r   )r   r   r
   r
   r   
test_print'  s    zTestBasicOps.test_printc                 C   s   |  t| j| j d S r   )r7   r;   r4   lengthr   r
   r
   r   test_length2  s    zTestBasicOps.test_lengthc                 C   s   |  | j| j d S r   r7   r4   r   r
   r
   r   test_self_equality5  s    zTestBasicOps.test_self_equalityc                 C   s   |  | j| j d S r   )r7   r4   r   r   r
   r
   r   test_equivalent_equality8  s    z%TestBasicOps.test_equivalent_equalityc                 C   s   |  | j | j d S r   )r7   r4   r   r   r   r
   r
   r   r   ;  s    zTestBasicOps.test_copyc                 C   s   | j | j B }| || j d S r   r4   r7   r   r   rJ  r
   r
   r   test_self_union>  s    zTestBasicOps.test_self_unionc                 C   s   | j tB }| || j d S r   r4   	empty_setr7   r   rS  r
   r
   r   test_empty_unionB  s    
zTestBasicOps.test_empty_unionc                 C   s   t | jB }| || j d S r   )rV  r4   r7   r   rS  r
   r
   r   test_union_emptyF  s    
zTestBasicOps.test_union_emptyc                 C   s   | j | j @ }| || j d S r   rR  rS  r
   r
   r   test_self_intersectionJ  s    z#TestBasicOps.test_self_intersectionc                 C   s   | j t@ }| |t d S r   r4   rV  r7   rS  r
   r
   r   test_empty_intersectionN  s    
z$TestBasicOps.test_empty_intersectionc                 C   s   t | j@ }| |t  d S r   rV  r4   r7   rS  r
   r
   r   test_intersection_emptyR  s    
z$TestBasicOps.test_intersection_emptyc                 C   s"   | j | j }| || j   d S r   r4   rf   r7   rS  r
   r
   r   test_self_isdisjointV  s    z!TestBasicOps.test_self_isdisjointc                 C   s   | j t}| |d d S r  )r4   rf   rV  r7   rS  r
   r
   r   test_empty_isdisjointZ  s    z"TestBasicOps.test_empty_isdisjointc                 C   s   t | j}| |d d S r  )rV  rf   r4   r7   rS  r
   r
   r   test_isdisjoint_empty^  s    z"TestBasicOps.test_isdisjoint_emptyc                 C   s   | j | j A }| |t d S r   r4   r7   rV  rS  r
   r
   r   test_self_symmetric_differenceb  s    z+TestBasicOps.test_self_symmetric_differencec                 C   s   | j tA }| || j  d S r   rZ  rS  r
   r
   r   test_empty_symmetric_differencef  s    
z,TestBasicOps.test_empty_symmetric_differencec                 C   s   | j | j  }| |t d S r   rb  rS  r
   r
   r   test_self_differencej  s    z!TestBasicOps.test_self_differencec                 C   s   | j t }| || j d S r   rU  rS  r
   r
   r   test_empty_differencen  s    
z"TestBasicOps.test_empty_differencec                 C   s   t | j }| |t  d S r   r\  rS  r
   r
   r   test_empty_difference_revr  s    
z&TestBasicOps.test_empty_difference_revc                 C   s>   | j D ]}| || j qt| j }| | t| j  d S r   )r4   r?   rH  r   r7   __length_hint__r;   )r   vZsetiterr
   r
   r   test_iterationv  s    

zTestBasicOps.test_iterationc                 C   sJ   t tjd D ]6}t| j|}t|}| | j|d| j|f  qd S )Nr   r   )r   r   r   r   r4   r   r7   )r   r   r{   r   r
   r
   r   r   |  s    

zTestBasicOps.test_picklingc                 C   sp   |  t t d W d    n1 s,0    Y  |  t t d W d    n1 sb0    Y  d S )Nr   )r2   r3   r4   rj   r   r   r
   r
   r   test_issue_37219  s    *zTestBasicOps.test_issue_37219N)r   r   r	   r@  rK  rL  rN  rP  rQ  r   rT  rW  rX  rY  r[  r]  r_  r`  ra  rc  rd  re  rf  rg  rj  r   rk  r
   r
   r
   r   r?    s0   r?  c                   @   s   e Zd Zdd ZdS )TestBasicOpsEmptyc                 C   s4   d| _ g | _t| j| _t| j| _d| _d| _d S )Nz	empty setr   zset()caserH  r4   r   rM  r   r   r
   r
   r   r.     s    zTestBasicOpsEmpty.setUpNr   r   r	   r.   r
   r
   r
   r   rl    s   rl  c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestBasicOpsSingletonc                 C   s6   d| _ dg| _t| j| _t| j| _d| _d| _d S )Nzunit set (number)rt   r   z{3}rm  r   r
   r
   r   r.     s    zTestBasicOpsSingleton.setUpc                 C   s   |  d| j d S r   r?   r4   r   r
   r
   r   test_in  s    zTestBasicOpsSingleton.test_inc                 C   s   |  d| j d S Nr/   r   r4   r   r
   r
   r   test_not_in  s    z!TestBasicOpsSingleton.test_not_inNr   r   r	   r.   rr  ru  r
   r
   r
   r   rp    s   rp  c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestBasicOpsTuplec                 C   s6   d| _ dg| _t| j| _t| j| _d| _d| _d S )Nzunit set (tuple)r   zeror   z{(0, 'zero')}rm  r   r
   r
   r   r.     s    zTestBasicOpsTuple.setUpc                 C   s   |  d| j d S )Nrx  rq  r   r
   r
   r   rr    s    zTestBasicOpsTuple.test_inc                 C   s   |  d| j d S )N	   rt  r   r
   r
   r   ru    s    zTestBasicOpsTuple.test_not_inNrv  r
   r
   r
   r   rw    s   rw  c                   @   s   e Zd Zdd ZdS )TestBasicOpsTriplec                 C   s<   d| _ ddtjg| _t| j| _t| j| _d| _d | _d S )Nz
triple setr   ry  rt   )rn  operatorr   rH  r4   r   rM  r   r   r
   r
   r   r.     s    zTestBasicOpsTriple.setUpNro  r
   r
   r
   r   r{    s   r{  c                   @   s   e Zd Zdd Zdd ZdS )TestBasicOpsStringc                 C   s2   d| _ g d| _t| j| _t| j| _d| _d S )Nz
string setr1   r\   r@   rt   rn  rH  r4   r   rM  r   r
   r
   r   r.     s
    
zTestBasicOpsString.setUpc                 C   s   |    d S r   rK  r   r
   r
   r   r@    s    zTestBasicOpsString.test_reprN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S )TestBasicOpsBytesc                 C   s2   d| _ g d| _t| j| _t| j| _d| _d S )Nz	bytes set)   a   b   crt   r  r   r
   r
   r   r.     s
    
zTestBasicOpsBytes.setUpc                 C   s   |    d S r   r  r   r
   r
   r   r@    s    zTestBasicOpsBytes.test_reprNr  r
   r
   r
   r   r    s   r  c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestBasicOpsMixedStringBytesc                 C   sR   t  | _| j  tdt d| _g d| _t	| j| _	t	| j| _
d| _d S )Nignorezstring and bytes set)r1   r\   r  r  r   )r   Zcheck_warnings_warning_filters	__enter__warningssimplefilterBytesWarningrn  rH  r4   r   rM  r   r
   r
   r   r.     s    


z"TestBasicOpsMixedStringBytes.setUpc                 C   s   | j d d d  d S r   )r  __exit__r   r
   r
   r   tearDown  s    z%TestBasicOpsMixedStringBytes.tearDownc                 C   s   |    d S r   r  r   r
   r
   r   r@    s    z&TestBasicOpsMixedStringBytes.test_reprN)r   r   r	   r.   r  r@  r
   r
   r
   r   r    s   
r  c                   c   s   t dV  d S r  )r3   r
   r
   r
   r   baditer  s    r  c                   c   s
   dV  d S r  r
   r
   r
   r
   r   gooditer  s    r  c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	TestExceptionPropagationz?SF 628246:  Set constructor should not trap iterator TypeErrorsc                 C   s   |  ttt  d S r   )r2   r3   r4   r  r   r
   r
   r   test_instanceWithException  s    z3TestExceptionPropagation.test_instanceWithExceptionc                 C   sF   t g d t d t dddd t td t d t t  d S )Nr   r   r/   rt   )ZoneZtwoZthreerH   )r4   r   r  r   r
   r
   r   test_instancesWithoutException  s    z7TestExceptionPropagation.test_instancesWithoutExceptionc                 C   sH   t g d}z|D ]}|dg qW n ty8   Y n0 | d d S )Nr   r   z0no exception when changing size during iteration)r4   r   r   rU   )r   r*   rW   r
   r
   r   test_changingSizeWhileIterating  s    z8TestExceptionPropagation.test_changingSizeWhileIteratingN)r   r   r	   r   r  r  r  r
   r
   r
   r   r    s   	r  c                   @   s   e Zd Zdd ZdS )TestSetOfSetsc                 C   s\   t dg}t|g}| }| t|t  || || | |t  || d S r   )r>   r4   r   r7   rL   r   r   r   )r   innerZouterelementr
   r
   r   test_constructor  s    



zTestSetOfSets.test_constructorN)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	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 )&TestBinaryOpsc                 C   s   t d| _ d S Nr/   r      r4   r   r
   r
   r   r.      s    zTestBinaryOps.setUpc                 C   s   |  | jtdddd d S )Nr   rt      r  rO  r   r
   r
   r   test_eq#  s    zTestBinaryOps.test_eqc                 C   s$   | j t dgB }| |t d d S Nr/   r  r   rS  r
   r
   r   test_union_subset&  s    zTestBinaryOps.test_union_subsetc                 C   s*   | j t g dB }| |t g d d S Nr/   r   r     r   rS  r
   r
   r   test_union_superset*  s    z!TestBinaryOps.test_union_supersetc                 C   s*   | j t g dB }| |t g d d S Nrt   r   r  )r/   rt   r   r  r  r   rS  r
   r
   r   test_union_overlap.  s    z TestBinaryOps.test_union_overlapc                 C   s(   | j t dgB }| |t g d d S Nr  r  r   rS  r
   r
   r   test_union_non_overlap2  s    z$TestBinaryOps.test_union_non_overlapc                 C   s"   | j t d@ }| |t d d S Nr/   r   r   rS  r
   r
   r   test_intersection_subset6  s    z&TestBinaryOps.test_intersection_subsetc                 C   s*   | j t g d@ }| |t g d d S Nr  r  r   rS  r
   r
   r   test_intersection_superset:  s    z(TestBinaryOps.test_intersection_supersetc                 C   s(   | j t g d@ }| |t dg d S Nr  r   r   rS  r
   r
   r   test_intersection_overlap>  s    z'TestBinaryOps.test_intersection_overlapc                 C   s    | j t dg@ }| |t d S Nr  rb  rS  r
   r
   r   test_intersection_non_overlapB  s    z+TestBinaryOps.test_intersection_non_overlapc                 C   s    | j t d}| |d d S )Nr  Fr^  rS  r
   r
   r   test_isdisjoint_subsetF  s    z$TestBinaryOps.test_isdisjoint_subsetc                 C   s$   | j t g d}| |d d S )Nr  Fr^  rS  r
   r
   r   test_isdisjoint_supersetJ  s    z&TestBinaryOps.test_isdisjoint_supersetc                 C   s$   | j t g d}| |d d S )Nr  Fr^  rS  r
   r
   r   test_isdisjoint_overlapN  s    z%TestBinaryOps.test_isdisjoint_overlapc                 C   s"   | j t dg}| |d d S )Nr  Tr^  rS  r
   r
   r   test_isdisjoint_non_overlapR  s    z)TestBinaryOps.test_isdisjoint_non_overlapc                 C   s$   | j t dA }| |t dg d S Nr  r  r   rS  r
   r
   r   test_sym_difference_subsetV  s    z(TestBinaryOps.test_sym_difference_subsetc                 C   s$   | j t dA }| |t dg d S Nr  r  r   rS  r
   r
   r   test_sym_difference_supersetZ  s    z*TestBinaryOps.test_sym_difference_supersetc                 C   s&   | j t dA }| |t g d d S Nr  )r/   rt   r  r  r   rS  r
   r
   r   test_sym_difference_overlap^  s    z)TestBinaryOps.test_sym_difference_overlapc                 C   s(   | j t dgA }| |t g d d S r  r   rS  r
   r
   r   test_sym_difference_non_overlapb  s    z-TestBinaryOps.test_sym_difference_non_overlapN)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    s$   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!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+S ),TestUpdateOpsc                 C   s   t d| _ d S r  r  r   r
   r
   r   r.   i  s    zTestUpdateOps.setUpc                 C   s*   |  j t dgO  _ | | j t d d S r  r   r   r
   r
   r   r  l  s    zTestUpdateOps.test_union_subsetc                 C   s0   |  j t g dO  _ | | j t g d d S r  r   r   r
   r
   r   r  p  s    z!TestUpdateOps.test_union_supersetc                 C   s0   |  j t g dO  _ | | j t g d d S r  r   r   r
   r
   r   r  t  s    z TestUpdateOps.test_union_overlapc                 C   s.   |  j t dgO  _ | | j t g d d S r  r   r   r
   r
   r   r  x  s    z$TestUpdateOps.test_union_non_overlapc                 C   s.   | j t g d | | j t g d d S r  )r4   r   r7   r   r
   r
   r   test_union_method_call|  s    z$TestUpdateOps.test_union_method_callc                 C   s(   |  j t dM  _ | | j t d d S r  r   r   r
   r
   r   r    s    z&TestUpdateOps.test_intersection_subsetc                 C   s0   |  j t g dM  _ | | j t g d d S r  r   r   r
   r
   r   r    s    z(TestUpdateOps.test_intersection_supersetc                 C   s.   |  j t g dM  _ | | j t dg d S r  r   r   r
   r
   r   r    s    z'TestUpdateOps.test_intersection_overlapc                 C   s&   |  j t dgM  _ | | j t d S r  rb  r   r
   r
   r   r    s    z+TestUpdateOps.test_intersection_non_overlapc                 C   s,   | j t g d | | j t dg d S r  )r4   r   r7   r   r
   r
   r   test_intersection_method_call  s    z+TestUpdateOps.test_intersection_method_callc                 C   s*   |  j t dN  _ | | j t dg d S r  r   r   r
   r
   r   r    s    z(TestUpdateOps.test_sym_difference_subsetc                 C   s*   |  j t dN  _ | | j t dg d S r  r   r   r
   r
   r   r    s    z*TestUpdateOps.test_sym_difference_supersetc                 C   s,   |  j t dN  _ | | j t g d d S r  r   r   r
   r
   r   r    s    z)TestUpdateOps.test_sym_difference_overlapc                 C   s.   |  j t dgN  _ | | j t g d d S r  r   r   r
   r
   r   r    s    z-TestUpdateOps.test_sym_difference_non_overlapc                 C   s.   | j t g d | | j t g d d S r  )r4   r   r7   r   r
   r
   r   test_sym_difference_method_call  s    z-TestUpdateOps.test_sym_difference_method_callc                 C   s*   |  j t d8  _ | | j t dg d S r  r   r   r
   r
   r   test_difference_subset  s    z$TestUpdateOps.test_difference_subsetc                 C   s(   |  j t d8  _ | | j t g  d S r  r   r   r
   r
   r   test_difference_superset  s    z&TestUpdateOps.test_difference_supersetc                 C   s,   |  j t d8  _ | | j t ddg d S Nr  r/   r  r   r   r
   r
   r   test_difference_overlap  s    z%TestUpdateOps.test_difference_overlapc                 C   s.   |  j t dg8  _ | | j t g d d S )Nr  r  r   r   r
   r
   r   test_difference_non_overlap  s    z)TestUpdateOps.test_difference_non_overlapc                 C   s.   | j t g d | | j t ddg d S r  )r4   r   r7   r   r
   r
   r   test_difference_method_call  s    z)TestUpdateOps.test_difference_method_callN)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  h  s*   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S )
TestMutatec                 C   s   g d| _ t| j | _d S )Nr~  )rH  r4   r   r
   r
   r   r.     s    
zTestMutate.setUpc                 C   s"   | j d | | j t d d S )Nr@   rH   r4   r   r7   r   r
   r
   r   test_add_present  s    zTestMutate.test_add_presentc                 C   s"   | j d | | j t d d S )Nr-   rD   r  r   r
   r
   r   test_add_absent  s    zTestMutate.test_add_absentc                 C   sJ   t  }d}| jD ]&}|| |d7 }| t|| q| || j  d S )Nr   r   )r4   rH  r   r7   r;   )r   tmpexpected_lenri  r
   r
   r   test_add_until_full  s    

zTestMutate.test_add_until_fullc                 C   s"   | j d | | j t d d S )Nr\   Zac)r4   r   r7   r   r
   r
   r   test_remove_present  s    zTestMutate.test_remove_presentc                 C   s2   z| j d | d W n ty,   Y n0 d S )Nr-   z7Removing missing element should have raised LookupError)r4   r   rU   LookupErrorr   r
   r
   r   test_remove_absent  s
    zTestMutate.test_remove_absentc                 C   s@   t | j}| jD ]*}| j| |d8 }| t | j| qd S r   )r;   r4   rH  r   r7   )r   r  ri  r
   r
   r   test_remove_until_empty  s
    

z"TestMutate.test_remove_until_emptyc                 C   s"   | j d | | j t d d S )Nr@   re   r4   r   r7   r   r
   r
   r   test_discard_present  s    zTestMutate.test_discard_presentc                 C   s"   | j d | | j t d d S )Nr-   rH   r  r   r
   r
   r   test_discard_absent  s    zTestMutate.test_discard_absentc                 C   s    | j   | t| j d d S r   )r4   r   r7   r;   r   r
   r
   r   r     s    
zTestMutate.test_clearc                 C   sL   i }| j rd || j  < q| t|t| j | jD ]}| || q6d S r   )r4   r   r7   r;   rH  r?   )r   Zpoppedri  r
   r
   r   r     s    
zTestMutate.test_popc                 C   s$   | j d | | j t | j d S )Nr
   r4   r   r7   rH  r   r
   r
   r   test_update_empty_tuple  s    z"TestMutate.test_update_empty_tuplec                 C   s$   | j d | | j t | j d S )Nr0   r  r   r
   r
   r   test_update_unit_tuple_overlap  s    z)TestMutate.test_update_unit_tuple_overlapc                 C   s*   | j d | | j t | jdg  d S )N)r1   r`   r`   r  r   r
   r
   r   "test_update_unit_tuple_non_overlap  s    z-TestMutate.test_update_unit_tuple_non_overlapN)r   r   r	   r.   r  r  r  r  r  r  r  r  r   r   r  r  r  r
   r
   r
   r   r    s   	r  c                   @   s0   e Zd ZdddZdddddd	d
Zdd ZdS )TestSubsetsry   rz   )<=>===!=><r  r  )r  r  r  r  r  r  c                 C   s   | j }| j}dD ]}|| jv }td| d t }| || |tjv rlt|tj| }||}| || tj	| }td| d t }| || |tjv rt|tj| }||}| || qd S )N)r  r  r  r  r  r  rS   y)
leftrightcasesevallocalsr7   r  case2methodgetattrreverse)r   rS   r  rn  r9   rJ  methodZrcaser
   r
   r   test_issubset  s"    



zTestSubsets.test_issubsetN)r   r   r	   r  r  r  r
   r
   r
   r   r    s   r  c                   @   s    e Zd Ze Ze ZdZdZdS )TestSubsetEqualEmptyz
both emptyr  r  r  Nr   r   r	   r4   r  r  r   r  r
   r
   r
   r   r  .  s   r  c                   @   s,   e Zd ZeddgZeddgZdZdZdS )TestSubsetEqualNonEmptyr   r/   z
equal pairr  Nr  r
   r
   r
   r   r  6  s   r  c                   @   s&   e Zd Ze ZeddgZdZdZdS )TestSubsetEmptyNonEmptyr   r/   zone empty, one non-emptyr  r  r  Nr  r
   r
   r
   r   r  >  s   r  c                   @   s*   e Zd ZedgZeddgZdZdZdS )TestSubsetPartialr   r/   z&one a non-empty proper subset of otherr  Nr  r
   r
   r
   r   r  F  s   
r  c                   @   s(   e Zd ZedgZedgZdZdZdS )TestSubsetNonOverlapr   r/   zneither empty, neither containsr  Nr  r
   r
   r
   r   r  N  s   

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S )TestOnlySetsInBinaryOpsc                 C   sT   |  | j| jkd |  | j| jkd |  | j| jkd |  | j| jkd d S rr   )r7   r   r4   r   r
   r
   r   
test_eq_neX  s    z"TestOnlySetsInBinaryOps.test_eq_nec                    s     t fdd   t fdd   t fdd   t fdd   t fdd   t fdd   t fdd   t fd	d d S )
Nc                      s    j  jk S r   r4   r   r
   r   r
   r   <lambda>`  r   z:TestOnlySetsInBinaryOps.test_ge_gt_le_lt.<locals>.<lambda>c                      s    j  jkS r   r  r
   r   r
   r   r  a  r   c                      s    j  jkS r   r  r
   r   r
   r   r  b  r   c                      s    j  jkS r   r  r
   r   r
   r   r  c  r   c                      s    j  jk S r   r   r4   r
   r   r
   r   r  e  r   c                      s    j  jkS r   r  r
   r   r
   r   r  f  r   c                      s    j  jkS r   r  r
   r   r
   r   r  g  r   c                      s    j  jkS r   r  r
   r   r
   r   r  h  r   )r2   r3   r   r
   r   r   test_ge_gt_le_lt_  s    z(TestOnlySetsInBinaryOps.test_ge_gt_le_ltc                 C   s6   z|  j | jO  _ W n ty&   Y n0 | d d S Nzexpected TypeErrorr4   r   r3   rU   r   r
   r
   r   test_update_operatorj  s
    z,TestOnlySetsInBinaryOps.test_update_operatorc                 C   s.   | j r| j| j n| t| jj| j d S r   )otherIsIterabler4   r   r   r2   r3   r   r
   r
   r   r   r  s    z#TestOnlySetsInBinaryOps.test_updatec                    sV     t fdd   t fdd  jr> j j n  t jj j d S )Nc                      s    j  jB S r   r  r
   r   r
   r   r  y  r   z4TestOnlySetsInBinaryOps.test_union.<locals>.<lambda>c                      s    j  jB S r   r  r
   r   r
   r   r  z  r   )r2   r3   r  r4   rK   r   r   r
   r   r   rT   x  s
    z"TestOnlySetsInBinaryOps.test_unionc                 C   s6   z|  j | jM  _ W n ty&   Y n0 | d d S r  r  r   r
   r
   r   !test_intersection_update_operator  s
    z9TestOnlySetsInBinaryOps.test_intersection_update_operatorc                 C   s.   | j r| j| j n| t| jj| j d S r   )r  r4   r   r   r2   r3   r   r
   r
   r   r     s    z0TestOnlySetsInBinaryOps.test_intersection_updatec                    sV     t fdd   t fdd  jr> j j n  t jj j d S )Nc                      s    j  j@ S r   r  r
   r   r
   r   r    r   z;TestOnlySetsInBinaryOps.test_intersection.<locals>.<lambda>c                      s    j  j@ S r   r  r
   r   r
   r   r    r   )r2   r3   r  r4   r]   r   r   r
   r   r   ra     s
    z)TestOnlySetsInBinaryOps.test_intersectionc                 C   s6   z|  j | jN  _ W n ty&   Y n0 | d d S r  r  r   r
   r
   r   #test_sym_difference_update_operator  s
    z;TestOnlySetsInBinaryOps.test_sym_difference_update_operatorc                 C   s.   | j r| j| j n| t| jj| j d S r   )r  r4   r   r   r2   r3   r   r
   r
   r   test_sym_difference_update  s    z2TestOnlySetsInBinaryOps.test_sym_difference_updatec                    sV     t fdd   t fdd  jr> j j n  t jj j d S )Nc                      s    j  jA S r   r  r
   r   r
   r   r    r   z=TestOnlySetsInBinaryOps.test_sym_difference.<locals>.<lambda>c                      s    j  jA S r   r  r
   r   r
   r   r    r   )r2   r3   r  r4   ro   r   r   r
   r   r   test_sym_difference  s
    z+TestOnlySetsInBinaryOps.test_sym_differencec                 C   s6   z|  j | j8  _ W n ty&   Y n0 | d d S r  r  r   r
   r
   r   test_difference_update_operator  s
    z7TestOnlySetsInBinaryOps.test_difference_update_operatorc                 C   s.   | j r| j| j n| t| jj| j d S r   )r  r4   r   r   r2   r3   r   r
   r
   r   r     s    z.TestOnlySetsInBinaryOps.test_difference_updatec                    sV     t fdd   t fdd  jr> j j n  t jj j d S )Nc                      s    j  j S r   r  r
   r   r
   r   r    r   z9TestOnlySetsInBinaryOps.test_difference.<locals>.<lambda>c                      s    j  j S r   r  r
   r   r
   r   r    r   )r2   r3   r  r4   rj   r   r   r
   r   r   rl     s
    z'TestOnlySetsInBinaryOps.test_differenceN)r   r   r	   r  r  r  r   rT   r  r   ra   r   r  r  r  r   rl   r
   r
   r
   r   r  V  s   r  c                   @   s   e Zd Zdd ZdS )TestOnlySetsNumericc                 C   s   t d| _ d| _d| _d S )Nr      Fr4   r   r  r   r
   r
   r   r.     s    
zTestOnlySetsNumeric.setUpNro  r
   r
   r
   r   r    s   r  c                   @   s   e Zd Zdd ZdS )TestOnlySetsDictc                 C   s    t d| _ ddd| _d| _d S )Nr   r/   r   )r   rt   Tr  r   r
   r
   r   r.     s    
zTestOnlySetsDict.setUpNro  r
   r
   r
   r   r    s   r  c                   @   s   e Zd Zdd ZdS )TestOnlySetsOperatorc                 C   s   t d| _ tj| _d| _d S )Nr   F)r4   r|  r   r   r  r   r
   r
   r   r.     s    
zTestOnlySetsOperator.setUpNro  r
   r
   r
   r   r    s   r  c                   @   s   e Zd Zdd ZdS )TestOnlySetsTuplec                 C   s   t d| _ d| _d| _d S )Nr   r  Tr  r   r
   r
   r   r.     s    
zTestOnlySetsTuple.setUpNro  r
   r
   r
   r   r	    s   r	  c                   @   s   e Zd Zdd ZdS )TestOnlySetsStringc                 C   s   t d| _ d| _d| _d S )Nr   rH   Tr  r   r
   r
   r   r.     s    
zTestOnlySetsString.setUpNro  r
   r
   r
   r   r
    s   r
  c                   @   s   e Zd Zdd ZdS )TestOnlySetsGeneratorc                 C   s$   dd }t d| _ | | _d| _d S )Nc                  s   s   t dddD ]
} | V  qd S )Nr   r   r/   )r   r/  r
   r
   r   gen  s    z(TestOnlySetsGenerator.setUp.<locals>.genr   Tr  )r   r  r
   r
   r   r.     s    
zTestOnlySetsGenerator.setUpNro  r
   r
   r
   r   r    s   r  c                   @   s   e Zd Zdd Zdd ZdS )TestCopyingc                 C   sd   | j  }t|td}t| j td}| t|t| tt|D ]}| || || u  qDd S Nr   )r4   r   r6   r   r7   r;   r   rg   r   r   Zdup_listZset_listrW   r
   r
   r   r     s    
zTestCopying.test_copyc                 C   sd   t | j}t|td}t| jtd}| t|t| tt|D ]}| || ||  qFd S r  )r   r   r4   r6   r   r7   r;   r   r  r
   r
   r   test_deep_copy  s    zTestCopying.test_deep_copyN)r   r   r	   r   r  r
   r
   r
   r   r    s   r  c                   @   s   e Zd Zdd ZdS )TestCopyingEmptyc                 C   s   t  | _ d S r   r  r   r
   r
   r   r.     s    zTestCopyingEmpty.setUpNro  r
   r
   r
   r   r    s   r  c                   @   s   e Zd Zdd ZdS )TestCopyingSingletonc                 C   s   t dg| _ d S )NZhellor  r   r
   r
   r   r.     s    zTestCopyingSingleton.setUpNro  r
   r
   r
   r   r    s   r  c                   @   s   e Zd Zdd ZdS )TestCopyingTriplec                 C   s   t g d| _ d S )N)ry  r   Nr  r   r
   r
   r   r.     s    zTestCopyingTriple.setUpNro  r
   r
   r
   r   r    s   r  c                   @   s   e Zd Zdd ZdS )TestCopyingTuplec                 C   s   t dg| _ d S )Nr   r/   r  r   r
   r
   r   r.   %  s    zTestCopyingTuple.setUpNro  r
   r
   r
   r   r  $  s   r  c                   @   s   e Zd Zdd ZdS )TestCopyingNestedc                 C   s   t dg| _ d S )N)r  )rt   r   r  r   r
   r
   r   r.   +  s    zTestCopyingNested.setUpNro  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 )TestIdentitiesc                 C   s   t d| _t d| _d S )NZabracadabraZalacazam)r4   r1   r\   r   r
   r
   r   r.   1  s    
zTestIdentities.setUpc                 C   s   | j | j }}| || |k  | || |k  | ||@ |k  | ||@ |k  | ||B |k | ||B |k | ||A ||B k  d S r   )r1   r\   rg   r   r1   r\   r
   r
   r   test_binopsVsSubsets5  s    z#TestIdentities.test_binopsVsSubsetsc                 C   sj   | j | j }}| ||@ ||@  | ||B ||B  | ||A ||A  ||krf| || ||  d S r   )r1   r\   r7   r_   r  r
   r
   r   test_commutativity?  s    z!TestIdentities.test_commutativityc                 C   s   | j | j }}| || ||@ B || B ||B  | ||@ ||A B ||B  | ||| B ||B  | || |B ||B  | || ||@ B | | || ||@ B | | || || B ||A  d S r   )r1   r\   r7   r  r
   r
   r   test_summationsG  s    $zTestIdentities.test_summationsc                 C   sZ   | j | jt   }}}| || |@ | | || |@ | | ||@ ||A @ | d S r   )r1   r\   r4   r7   )r   r1   r\   ry  r
   r
   r   test_exclusionR  s    zTestIdentities.test_exclusionN)r   r   r	   r.   r  r  r  r  r
   r
   r
   r   r  0  s
   
r  c                 c   s   | D ]
}|V  qdS )zRegular generatorNr
   seqnrW   r
   r
   r   R[  s    r   c                   @   s    e Zd ZdZdd Zdd ZdS )GzSequence using __getitem__c                 C   s
   || _ d S r   r  r   r  r
   r
   r   r#   b  s    z
G.__init__c                 C   s
   | j | S r   r"  rV   r
   r
   r   __getitem__d  s    zG.__getitem__N)r   r   r	   r   r#   r$  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 )	Iz Sequence using iterator protocolc                 C   s   || _ d| _d S r   r  r#  r
   r
   r   r#   i  s    z
I.__init__c                 C   s   | S r   r
   r   r
   r
   r   __iter__l  s    z
I.__iter__c                 C   s2   | j t| jkrt| j| j  }|  j d7  _ |S r   rW   r;   r  r   r   ri  r
   r
   r   __next__n  s    z
I.__next__Nr   r   r	   r   r#   r&  r)  r
   r
   r
   r   r%  g  s   r%  c                   @   s    e Zd ZdZdd Zdd ZdS )Igz9Sequence using iterator protocol defined with a generatorc                 C   s   || _ d| _d S r   r  r#  r
   r
   r   r#   v  s    zIg.__init__c                 c   s   | j D ]
}|V  qd S r   r"  )r   valr
   r
   r   r&  y  s    
zIg.__iter__Nr   r   r	   r   r#   r&  r
   r
   r
   r   r+  t  s   r+  c                   @   s    e Zd ZdZdd Zdd ZdS )Xz Missing __getitem__ and __iter__c                 C   s   || _ d| _d S r   r  r#  r
   r
   r   r#     s    z
X.__init__c                 C   s2   | j t| jkrt| j| j  }|  j d7  _ |S r   r'  r(  r
   r
   r   r)    s    z
X.__next__N)r   r   r	   r   r#   r)  r
   r
   r
   r   r.  }  s   r.  c                   @   s    e Zd ZdZdd Zdd ZdS )NzIterator missing __next__()c                 C   s   || _ d| _d S r   r  r#  r
   r
   r   r#     s    z
N.__init__c                 C   s   | S r   r
   r   r
   r
   r   r&    s    z
N.__iter__Nr-  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 )	EzTest propagation of exceptionsc                 C   s   || _ d| _d S r   r  r#  r
   r
   r   r#     s    z
E.__init__c                 C   s   | S r   r
   r   r
   r
   r   r&    s    z
E.__iter__c                 C   s   dd  d S )Nrt   r   r
   r   r
   r
   r   r)    s    z
E.__next__Nr*  r
   r
   r
   r   r0    s   r0  c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	SzTest immediate stopc                 C   s   d S r   r
   r#  r
   r
   r   r#     s    z
S.__init__c                 C   s   | S r   r
   r   r
   r
   r   r&    s    z
S.__iter__c                 C   s   t d S r   )r   r   r
   r
   r   r)    s    z
S.__next__Nr*  r
   r
   r
   r   r1    s   r1  )chainc                 C   s   t tdd ttt| S )z Test multiple tiers of iteratorsc                 S   s   | S r   r
   rS   r
   r
   r   r    r   zL.<locals>.<lambda>)r2  ru   r   r+  r!  r"  r
   r
   r   L  s    r4  c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestVariousIteratorArgsc              
   C   s   t tfD ]}ddtddtdddfD ]x}ttttttfD ],}| 	t
|||tdt
||td q:| t|t| | t|t| | t|t| q&qd S )	N123rZ   r   Zdog333333?    r  r  )r4   r>   r   r!  r%  r+  r1  r4  r   r7   r6   r   r2   r3   r.  r/  ZeroDivisionErrorr0  )r   Zconsr*   gr
   r
   r   r    s    *z(TestVariousIteratorArgs.test_constructorc              
   C   s   t d}ddtddtdddd	fD ]}|j|j|j|j|jfD ]}ttt	t
tfD ]L}||}|||}t|tr| || qR| t|td
t|td
 qR| t|t| | t|t| | t|t| q@q$d S )NZnovemberr6  rZ   r   r7  r8  r9  r  decemberr  )r4   r   rK   r]   rj   ro   rf   r!  r%  r+  r4  r   
isinstanceboolr7   r6   r   r2   r3   r.  r/  r:  r0  )r   r*   r   methr;  r9   r8   r
   r
   r   test_inline_methods  s     
z+TestVariousIteratorArgs.test_inline_methodsc              
   C   s   ddt ddt ddddfD ]}d	D ]}ttttttfD ]X}td
}| }t	||t
|| t	|||| | t|tdt|td q8| tt	td
|t| | tt	td
|t| | tt	td
|t| q$qd S )Nr6  rZ   r   r7  r8  r9  r  r<  )r   r   r   r   Zjanuaryr  )r   r!  r%  r+  r1  r4  r   r4   r   r  rO   r7   r6   r   r2   r3   r.  r/  r:  r0  )r   r   Zmethnamer;  r*   rv   r
   r
   r   test_inplace_methods  s     z,TestVariousIteratorArgs.test_inplace_methodsN)r   r   r	   r  r@  rA  r
   r
   r
   r   r5    s   	r5  c                   @   s   e Zd Zdd Zdd ZdS )bad_eqc                 C   s   t rt  t| |u S r   )be_badset2r   r:  r   r
   r
   r   r     s    zbad_eq.__eq__c                 C   s   dS r   r
   r   r
   r
   r   r     s    zbad_eq.__hash__Nr   r   r	   r   r   r
   r
   r
   r   rB    s   rB  c                   @   s   e Zd Zdd Zdd ZdS )bad_dict_clearc                 C   s   t rt  | |u S r   )rC  dict2r   r   r
   r
   r   r     s    zbad_dict_clear.__eq__c                 C   s   dS r   r
   r   r
   r
   r   r     s    zbad_dict_clear.__hash__NrE  r
   r
   r
   r   rF    s   rF  c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestWeirdBugsc                 C   sZ   da t h}dd tdD ada | t|jt da t h}t d iada |	t d S )NFc                 S   s   h | ]
}t  qS r
   )rB  r   r
   r
   r   r9    r   z4TestWeirdBugs.test_8420_set_merge.<locals>.<setcomp>K   T)
rC  rB  r   rD  r2   r:  r   rF  rG  r   )r   set1r
   r
   r   test_8420_set_merge  s    
z!TestWeirdBugs.test_8420_set_mergec                 C   sX   t td}|  |td t|}|  ttd}|td t| d S )Nr!  )r4   r   r   r   r   rO   )r   r*   sir1   r
   r
   r   test_iter_and_mutate  s    z"TestWeirdBugs.test_iter_and_mutatec                    sB   G fddd t   fddtdD dh}| d S )Nc                       s    e Zd Zdd Z fddZdS )z.TestWeirdBugs.test_merge_and_mutate.<locals>.Xc                 S   s   t dS r   )r   r   r
   r
   r   r     s    z7TestWeirdBugs.test_merge_and_mutate.<locals>.X.__hash__c                    s       dS )NF)r   )r   or   r
   r   r     s    z5TestWeirdBugs.test_merge_and_mutate.<locals>.X.__eq__Nr   r
   rO  r
   r   r.    s   r.  c                    s   h | ]
}  qS r
   r
   r   )r.  r
   r   r9    r   z6TestWeirdBugs.test_merge_and_mutate.<locals>.<setcomp>r   r   )r4   r   r   r   r
   )r.  r   r   test_merge_and_mutate  s
    z#TestWeirdBugs.test_merge_and_mutateN)r   r   r	   rK  rM  rP  r
   r
   r
   r   rH    s   rH  c                   @   s(   e Zd ZdZdZdZdd Zdd ZdS )TestOperationsMutatingzRegression test for bpo-46615Nc                    sf   G fddd d|   fddttdD |  fddttdD dfS )	Nc                       s$   e Zd Z fddZdd ZdS )z<TestOperationsMutating.make_sets_of_bad_objects.<locals>.Badc                    s<    sdS t ddkr  t ddkr0  tt dS )NF   r   r/   )r   r   r>  r   enabledrJ  rD  r
   r   r     s    zCTestOperationsMutating.make_sets_of_bad_objects.<locals>.Bad.__eq__c                 S   s   t dS rs  r"  r   r
   r
   r   r     s    zETestOperationsMutating.make_sets_of_bad_objects.<locals>.Bad.__hash__NrE  r
   rS  r
   r   Bad  s   rU  Fc                 3   s   | ]}  V  qd S r   r
   r   _rU  r
   r   r     r   zBTestOperationsMutating.make_sets_of_bad_objects.<locals>.<genexpr>2   c                 3   s   | ]}  V  qd S r   r
   rV  rX  r
   r   r      r   T)constructor1r   r   constructor2r   r
   )rU  rT  rJ  rD  r   make_sets_of_bad_objects  s      z/TestOperationsMutating.make_sets_of_bad_objectsc                 C   sb   t dD ]T}|  \}}z||| W q tyZ } z| dt| W Y d }~qd }~0 0 qd S )Nr!  zchanged size during iteration)r   r\  r   r?   rN   )r   functionrW  rJ  rD  r   r
   r
   r   check_set_op_does_not_crash%  s    z2TestOperationsMutating.check_set_op_does_not_crash)r   r   r	   r   rZ  r[  r\  r^  r
   r
   r
   r   rQ    s
   rQ  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S ) TestBinaryOpsMutatingc                 C   s   |  dd  d S )Nc                 S   s   | |kS r   r
   r1   r\   r
   r
   r   r  2  r   z=TestBinaryOpsMutating.test_eq_with_mutation.<locals>.<lambda>r^  r   r
   r
   r   test_eq_with_mutation1  s    z+TestBinaryOpsMutating.test_eq_with_mutationc                 C   s   |  dd  d S )Nc                 S   s   | |kS r   r
   r`  r
   r
   r   r  5  r   z=TestBinaryOpsMutating.test_ne_with_mutation.<locals>.<lambda>ra  r   r
   r
   r   test_ne_with_mutation4  s    z+TestBinaryOpsMutating.test_ne_with_mutationc                 C   s   |  dd  d S )Nc                 S   s   | |k S r   r
   r`  r
   r
   r   r  8  r   z=TestBinaryOpsMutating.test_lt_with_mutation.<locals>.<lambda>ra  r   r
   r
   r   test_lt_with_mutation7  s    z+TestBinaryOpsMutating.test_lt_with_mutationc                 C   s   |  dd  d S )Nc                 S   s   | |kS r   r
   r`  r
   r
   r   r  ;  r   z=TestBinaryOpsMutating.test_le_with_mutation.<locals>.<lambda>ra  r   r
   r
   r   test_le_with_mutation:  s    z+TestBinaryOpsMutating.test_le_with_mutationc                 C   s   |  dd  d S )Nc                 S   s   | |kS r   r
   r`  r
   r
   r   r  >  r   z=TestBinaryOpsMutating.test_gt_with_mutation.<locals>.<lambda>ra  r   r
   r
   r   test_gt_with_mutation=  s    z+TestBinaryOpsMutating.test_gt_with_mutationc                 C   s   |  dd  d S )Nc                 S   s   | |kS r   r
   r`  r
   r
   r   r  A  r   z=TestBinaryOpsMutating.test_ge_with_mutation.<locals>.<lambda>ra  r   r
   r
   r   test_ge_with_mutation@  s    z+TestBinaryOpsMutating.test_ge_with_mutationc                 C   s   |  dd  d S )Nc                 S   s   | |@ S r   r
   r`  r
   r
   r   r  D  r   z>TestBinaryOpsMutating.test_and_with_mutation.<locals>.<lambda>ra  r   r
   r
   r   test_and_with_mutationC  s    z,TestBinaryOpsMutating.test_and_with_mutationc                 C   s   |  dd  d S )Nc                 S   s   | |B S r   r
   r`  r
   r
   r   r  G  r   z=TestBinaryOpsMutating.test_or_with_mutation.<locals>.<lambda>ra  r   r
   r
   r   test_or_with_mutationF  s    z+TestBinaryOpsMutating.test_or_with_mutationc                 C   s   |  dd  d S )Nc                 S   s   | | S r   r
   r`  r
   r
   r   r  J  r   z>TestBinaryOpsMutating.test_sub_with_mutation.<locals>.<lambda>ra  r   r
   r
   r   test_sub_with_mutationI  s    z,TestBinaryOpsMutating.test_sub_with_mutationc                 C   s   |  dd  d S )Nc                 S   s   | |A S r   r
   r`  r
   r
   r   r  M  r   z>TestBinaryOpsMutating.test_xor_with_mutation.<locals>.<lambda>ra  r   r
   r
   r   test_xor_with_mutationL  s    z,TestBinaryOpsMutating.test_xor_with_mutationc                 C   s   dd }|  | d S )Nc                 S   s   | |M } d S r   r
   r`  r
   r
   r   rd   P  s    z8TestBinaryOpsMutating.test_iadd_with_mutation.<locals>.fra  r+  r
   r
   r   test_iadd_with_mutationO  s    z-TestBinaryOpsMutating.test_iadd_with_mutationc                 C   s   dd }|  | d S )Nc                 S   s   | |O } d S r   r
   r`  r
   r
   r   rd   U  s    z7TestBinaryOpsMutating.test_ior_with_mutation.<locals>.fra  r+  r
   r
   r   test_ior_with_mutationT  s    z,TestBinaryOpsMutating.test_ior_with_mutationc                 C   s   dd }|  | d S )Nc                 S   s   | |8 } d S r   r
   r`  r
   r
   r   rd   Z  s    z8TestBinaryOpsMutating.test_isub_with_mutation.<locals>.fra  r+  r
   r
   r   test_isub_with_mutationY  s    z-TestBinaryOpsMutating.test_isub_with_mutationc                 C   s   dd }|  | d S )Nc                 S   s   | |N } d S r   r
   r`  r
   r
   r   rd   _  s    z8TestBinaryOpsMutating.test_ixor_with_mutation.<locals>.fra  r+  r
   r
   r   test_ixor_with_mutation^  s    z-TestBinaryOpsMutating.test_ixor_with_mutationc                 C   s:   dd }dd }dd }|  | |  | |  | d S )Nc                 S   s   | D ]}q|D ]}qd S r   r
   r1   r\   rS   r  r
   r
   r   f1d  s    z>TestBinaryOpsMutating.test_iteration_with_mutation.<locals>.f1c                 S   s   |D ]}q| D ]}qd S r   r
   )r1   r\   r  rS   r
   r
   r   f2i  s    z>TestBinaryOpsMutating.test_iteration_with_mutation.<locals>.f2c                 S   s   t | |D ]\}}q
d S r   )ziprp  r
   r
   r   f3n  s    z>TestBinaryOpsMutating.test_iteration_with_mutation.<locals>.f3ra  )r   rq  rr  rt  r
   r
   r   test_iteration_with_mutationc  s    

z2TestBinaryOpsMutating.test_iteration_with_mutationN)r   r   r	   rb  rc  rd  re  rf  rg  rh  ri  rj  rk  rl  rm  rn  ro  ru  r
   r
   r
   r   r_  /  s   r_  c                   @   s   e Zd ZeZeZdS )TestBinaryOpsMutating_Set_SetNr   r   r	   r4   rZ  r[  r
   r
   r
   r   rv  v  s   rv  c                   @   s   e Zd ZeZeZdS )'TestBinaryOpsMutating_Subclass_SubclassNr   r   r	   r  rZ  r[  r
   r
   r
   r   rx  z  s   rx  c                   @   s   e Zd ZeZeZdS )"TestBinaryOpsMutating_Set_SubclassNr   r   r	   r4   rZ  r  r[  r
   r
   r
   r   rz  ~  s   rz  c                   @   s   e Zd ZeZeZdS )"TestBinaryOpsMutating_Subclass_SetNr   r   r	   r  rZ  r4   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d Z
dd Zdd Zdd ZdS )TestMethodsMutatingc                 C   s   |  tj d S r   )r^  r4   ry   r   r
   r
   r   test_issubset_with_mutation  s    z/TestMethodsMutating.test_issubset_with_mutationc                 C   s   |  tj d S r   )r^  r4   rz   r   r
   r
   r   test_issuperset_with_mutation  s    z1TestMethodsMutating.test_issuperset_with_mutationc                 C   s   |  tj d S r   )r^  r4   r]   r   r
   r
   r   test_intersection_with_mutation  s    z3TestMethodsMutating.test_intersection_with_mutationc                 C   s   |  tj d S r   )r^  r4   rK   r   r
   r
   r   test_union_with_mutation  s    z,TestMethodsMutating.test_union_with_mutationc                 C   s   |  tj d S r   )r^  r4   rj   r   r
   r
   r   test_difference_with_mutation  s    z1TestMethodsMutating.test_difference_with_mutationc                 C   s   |  tj d S r   )r^  r4   ro   r   r
   r
   r   'test_symmetric_difference_with_mutation  s    z;TestMethodsMutating.test_symmetric_difference_with_mutationc                 C   s   |  tj d S r   )r^  r4   rf   r   r
   r
   r   test_isdisjoint_with_mutation  s    z1TestMethodsMutating.test_isdisjoint_with_mutationc                 C   s   |  tj d S r   )r^  r4   r   r   r
   r
   r   $test_difference_update_with_mutation  s    z8TestMethodsMutating.test_difference_update_with_mutationc                 C   s   |  tj d S r   )r^  r4   r   r   r
   r
   r   &test_intersection_update_with_mutation  s    z:TestMethodsMutating.test_intersection_update_with_mutationc                 C   s   |  tj d S r   )r^  r4   r   r   r
   r
   r   .test_symmetric_difference_update_with_mutation  s    zBTestMethodsMutating.test_symmetric_difference_update_with_mutationc                 C   s   |  tj d S r   )r^  r4   r   r   r
   r
   r   test_update_with_mutation  s    z-TestMethodsMutating.test_update_with_mutationN)r   r   r	   r  r  r  r  r  r  r  r  r  r  r  r
   r
   r
   r   r~    s   r~  c                   @   s   e Zd ZeZeZdS )TestMethodsMutating_Set_SetNrw  r
   r
   r
   r   r    s   r  c                   @   s   e Zd ZeZeZdS )%TestMethodsMutating_Subclass_SubclassNry  r
   r
   r
   r   r    s   r  c                   @   s   e Zd ZeZeZdS ) TestMethodsMutating_Set_SubclassNr{  r
   r
   r
   r   r    s   r  c                   @   s   e Zd ZeZeZdS ) TestMethodsMutating_Subclass_SetNr}  r
   r
   r
   r   r    s   r  c                   @   s   e Zd ZeZejZdS )TestMethodsMutating_Set_DictN)r   r   r	   r4   rZ  r+   r,   r[  r
   r
   r
   r   r    s   r  c                   @   s   e Zd ZeZeZdS )TestMethodsMutating_Set_ListN)r   r   r	   r4   rZ  rO   r[  r
   r
   r
   r   r    s   r  c                 c   sX   t | } z0tt| g}t| D ]}|V  ||B V  q W n tyR   t V  Y n0 dS )z-Generates all subsets of a set or sequence U.N)r   r>   r   r5  r   )UrS   r1  r
   r
   r   r5    s    r5  c                    s0   dd t | D  t fddtt | D S )z!Graph of n-dimensional hypercube.c                 S   s   g | ]}t |gqS r
   r>   )r   rS   r
   r
   r   r$    r   zcube.<locals>.<listcomp>c                    s&   g | ]  t  fd dD fqS )c                    s   g | ]} |A qS r
   r
   )r   r*   r3  r
   r   r$    r   z#cube.<locals>.<listcomp>.<listcomp>r  )r   Z
singletonsr3  r   r$    s   )r   r+   r5  r#  r
   r  r   cube  s    
r  c                    sh   i }| D ]Z |   D ]L fdd|   D } fdd|  D }t || |t  g< qq|S )zGraph, the vertices of which are edges of G,
    with two vertices being adjacent iff the corresponding
    edges share a vertex.c                    s    g | ]}|krt  |gqS r
   r  r   r`   rS   r  r
   r   r$    r   zlinegraph.<locals>.<listcomp>c                    s    g | ]}| krt |gqS r
   r  r  r  r
   r   r$    r   r  )r!  r4  Znxnyr
   r  r   	linegraph  s    r  c                 C   s   t  }|  D ]\}}|D ]}| | D ]}||kr4q&|| | v rV|t|||g q&| | D ]v}||krlq^|| | v r|t||||g q^| | D ]:}||ks||krq|| | v r|t|||||g qq^q&qq|S )zKReturn a set of faces in G.  Where a face is a set of vertices on that face)r4   itemsr   r>   )r!  rd   r   edgesr   Zv3Zv4Zv5r
   r
   r   faces  s&    "r  c                   @   s   e Zd Zdd Zdd ZdS )
TestGraphsc                 C   s   t d}t|}| t|d | D ]}| t|d q(tdd | D }| || t|}| t|d |D ]}| t|d q|d S )Nrt   r  c                 s   s   | ]}|D ]
}|V  q
qd S r   r
   )r   r  ri  r
   r
   r   r     r   z'TestGraphs.test_cube.<locals>.<genexpr>r  r   )r  r4   r7   r;   rH  r  )r   r;  Z	vertices1edgeZ	vertices2Z	cubefacesfacer
   r
   r   	test_cube  s    zTestGraphs.test_cubec                 C   s   t d}t|}| t|d t|}| D ]}| t|d q0tdd | D }| || t|}tt	}|D ]}|t|  d7  < q~| |d d | |d d |D ].}	|	}
| t|
d	 |
D ]}| 
|| qqd S )
Nrt      r   c                 s   s   | ]}|D ]
}|V  q
qd S r   r
   )r   r  r  r
   r
   r   r     r   z0TestGraphs.test_cuboctahedron.<locals>.<genexpr>r   r  r  r/   )r  r  r7   r;   r4   rH  r  r   defaultdictr$   r?   )r   r;  ZcuboctahedronZverticesr  ZotherverticesZ	cubofacesZ	facesizesr  Zvertexr  Zcubevertr
   r
   r   test_cuboctahedron  s&    
zTestGraphs.test_cuboctahedronN)r   r   r	   r  r  r
   r
   r
   r   r    s   r  __main__)hr  testr   r   r   r|  r   r   randomr   r   r  r   collections.abcr3  	Exceptionr   r   r   r   r$   r   r%   ZTestCaser   r4   r  r  r  r  r  r>   r;  r<  rV  r?  rl  rp  rw  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!  r%  r+  r.  r/  r0  r1  r2  r4  r5  rB  rF  rH  rQ  r_  rv  rx  rz  r|  r~  r  r  r  r  r  r  r5  r  r  r  r  r   mainr
   r
   r
   r   <module>   s     J  RuIVJ&t+	
	)	)$G$1
