B
    u9aP                 @   sN   d dl mZm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 )    )support	seq_testsNc                   s   e Zd ZeZdd Z fddZdd Z fddZ fd	d
Z	 fddZ
 fddZdd Zdd Zdd Zdd Zdd Zejdd Zdd Zejdd Zejdd  Zejd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Z  ZS )-	TupleTestc          	   C   s(   d}|  t| dd  W d Q R X d S )Nz(tuple indices must be integers or slices a)assertRaisesRegex	TypeError)selfmsgr   r    /usr/lib/python3.7/test_tuple.pytest_getitem_error
   s    zTupleTest.test_getitem_errorc                s   t    | t d d}t|}| ||k | tg d | tddddgd | tdd | tdd	 | td
d tdD d d S )Nr   )r            r   r   r   r    Zspam)spr   mc             s   s   | ]}|d  r|V  qdS )r   Nr   ).0xr   r   r   	<genexpr>   s    z.TupleTest.test_constructors.<locals>.<genexpr>
   )r   r         	   )supertest_constructorsassertEqualtuple
assertTruerange)r	   Zt0_3Zt0_3_bis)	__class__r   r   r      s    
zTupleTest.test_constructorsc          	   C   s&   |  td tdd W d Q R X d S )Nzkeyword argumentr   )Zsequence)r   r   r   )r	   r   r   r   test_keyword_args   s    zTupleTest.test_keyword_argsc                s"   t    | d | d d S )NT)*   )r   
test_truthr   )r	   )r!   r   r   r$   !   s    

zTupleTest.test_truthc                s>   t    | tdd | tdd | tdd d S )Nr   r   )r   r   )r   r   r   r   )r   test_lenr   len)r	   )r!   r   r   r%   &   s    
zTupleTest.test_lenc                s,   t    d}|}|d7 }| ||k	 d S )N)r   r   )r   r   )r   	test_iaddr   )r	   uu2)r!   r   r   r'   ,   s
    
zTupleTest.test_iaddc                s,   t    d}|}|d9 }| ||k	 d S )N)r   r   r   )r   	test_imulr   )r	   r(   r)   )r!   r   r   r*   3   s
    
zTupleTest.test_imulc             C   s*   dd }|  tt| ttd d S )Nc              s   s   xt dD ]
} | V  q
W d S )Ni  )r    )ir   r   r   f<   s    z(TupleTest.test_tupleresizebug.<locals>.fi  )r   listr   r    )r	   r,   r   r   r   test_tupleresizebug:   s    zTupleTest.test_tupleresizebugc                s   d}t t|  fdd D  fdd D   fddD   t t  }t|tttt| }| |dk d S )N2   c                s   g | ]} D ]}||fqqS r   r   )r   r+   j)baser   r   
<listcomp>S   s    z'TupleTest.test_hash.<locals>.<listcomp>c                s   g | ]} D ]}||fqqS r   r   )r   r+   r0   )xpr   r   r2   T   s    c                s   g | ]} D ]}||fqqS r   r   )r   r+   r0   )r1   r   r   r2   U   s       )r-   r    zipr&   setmaphashr   )r	   NZinpsZ
collisionsr   )r1   r3   r   	test_hashA   s    8zTupleTest.test_hashc             C   sj   t  }d}| |}| |}| t|t| | t|t| | t|d | t|d d S )N)r   r   r   z()z	(0, 1, 2))r   	type2testr   strrepr)r	   Zl0l2Za0Za2r   r   r   	test_reprY   s    

zTupleTest.test_reprc             C   s&   t   t   | t || d S )N)gccollectZassertFalse
is_tracked)r	   tr   r   r   _not_trackedd   s    zTupleTest._not_trackedc             C   s8   |  t|| t  t  |  t|| d S )N)r   r@   rB   rA   )r	   rC   r   r   r   _trackedj   s    zTupleTest._trackedc             C   s   ddg   }}}|  d |  d |  d |  d |  ddd	tf |  t f |  d|f|d
f | g f | dgf | i f | t f | |||f d S )Ng      ?r   r   )r   )r   r   )r   r   r   r   r   )NTFr   )r   r   )rD   intobjectrE   r6   )r	   r   yzr   r   r   test_track_literalsp   s    



zTupleTest.test_track_literalsc                s^  ddg   }}}|r| j n| j}|   | g  | t  | d||g | dd d||gD  | td||g | dd d||gD  |t fddd||gD  |   |g |   ||gg |   ||ig |   dd |||gD  |   d	d |||gD  |  t fd
d|||gD  d S )Ng      ?r   r   c             s   s   | ]
}|V  qd S )Nr   )r   objr   r   r   r      s    z0TupleTest.check_track_dynamic.<locals>.<genexpr>c             s   s   | ]}t |gV  qd S )N)r   )r   rK   r   r   r   r      s    c             3   s   | ]} |gV  qd S )Nr   )r   rK   )tpr   r   r      s    c             s   s   | ]
}|V  qd S )Nr   )r   rK   r   r   r   r      s    c             s   s   | ]}t |gV  qd S )N)r   )r   rK   r   r   r   r      s    c             3   s   | ]} |gV  qd S )Nr   )r   rK   )rL   r   r   r      s    )rE   rD   r6   r   )r	   rL   Zalways_trackr   rH   rI   checkr   )rL   r   check_track_dynamic   s     
 zTupleTest.check_track_dynamicc             C   s   |  td d S )NF)rN   r   )r	   r   r   r   test_track_dynamic   s    zTupleTest.test_track_dynamicc             C   s    G dd dt }| |d d S )Nc               @   s   e Zd ZdS )z.TupleTest.test_track_subtypes.<locals>.MyTupleN)__name__
__module____qualname__r   r   r   r   MyTuple   s   rS   T)r   rN   )r	   rS   r   r   r   test_track_subtypes   s    zTupleTest.test_track_subtypesc             C   s    |  tdd tdD  d S )Nc             s   s   | ]}t  V  qd S )N)r@   rA   )r   r+   r   r   r   r      s    z)TupleTest.test_bug7466.<locals>.<genexpr>e   )rD   r   r    )r	   r   r   r   test_bug7466   s    zTupleTest.test_bug7466c                s     fdd}|d |d d S )Nc                s4   d|  }t |} |dddg|   d  d S )N)r   (z, 0))r=   r   join)nlr   )r	   r   r   rM      s    z(TupleTest.test_repr_large.<locals>.checkr   i@B r   )r	   rM   r   )r	   r   test_repr_large   s    zTupleTest.test_repr_largec             C   s   |  ddddg}xttjd D ]}t|}t||}t|}| t|t| | |  ||  | t|}t	| t||}| |  ||  |dd   q"W d S )N   r      r   r   )
r;   r    pickleHIGHEST_PROTOCOLiterdumpsloadsr   typenext)r	   dataprotoitorgditr   r   r   test_iterator_pickle   s    

zTupleTest.test_iterator_picklec             C   s   |  ddddg}xttjd D ]}t|}t||}t|}| t|t| | |  ||  t| t|}t	| t||}| |  ||  t|dd   q"W d S )Nr^   r   r_   r   r   )
r;   r    r`   ra   reversedrc   rd   r   re   rf   )r	   rg   rh   ri   rj   rk   r   r   r   test_reversed_pickle   s    

zTupleTest.test_reversed_picklec          	   C   s8   G dd dt }| t dg|d  W d Q R X d S )Nc               @   s   e Zd ZdS )z+TupleTest.test_no_comdat_folding.<locals>.TN)rP   rQ   rR   r   r   r   r   T   s    ro   r   )r   r   )r   ZassertRaisesr   )r	   ro   r   r   r   test_no_comdat_folding   s    z TupleTest.test_no_comdat_foldingc             C   sH   |  ddg}|  dddg}|  ddg}| || | || d S )Nr   r   r   r   )r;   Z
assertLess)r	   r   bcr   r   r   test_lexicographic_ordering   s
    z%TupleTest.test_lexicographic_ordering)rP   rQ   rR   r   r;   r   r   r"   r$   r%   r'   r*   r.   r:   r?   rD   rE   r   Zcpython_onlyrJ   rN   rO   rT   rV   r]   rl   rn   rp   rs   __classcell__r   r   )r!   r   r      s.   
r   __main__)
Ztestr   r   Zunittestr@   r`   Z
CommonTestr   rP   mainr   r   r   r   <module>   s    \