B
    u9a|                 @   s>   d dl Z d dlZd dlZG dd dejZedkr:e  dS )    Nc               @   sl   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S )StructSeqTestc             C   sT  t  }| |t t|}| t|t| | || xrtt| t|D ]Z}| ||d  ||d   x8tt| t|D ] }| ||| |||  qW qRW x8tt| t|D ] }| |d | |d |  qW | t|j	t| d  | t|j	t| x6tt| t|d D ]}| || ||  q2W d S )N   )
timegmtimeZassertIsInstancetupleassertEquallenrangeassertRaises
IndexError__getitem__)selftZastupleij r   $/usr/lib/python3.7/test_structseq.py
test_tuple   s    $ zStructSeqTest.test_tuplec             C   sz   t  }| t| t d}| t|d tt}t|}| |d | 	d| | 	d| | 	d| d S )Nr   zttime.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)zos.stat_resultzst_mode=zst_ino=zst_dev=)
r   r   
assertTruereprr   osstat__file__
startswithassertIn)r   r   stZrepr   r   r   	test_repr   s    


zStructSeqTest.test_reprc             C   sJ   t  }|t| }x0tt|D ] }| || ||t|   q"W d S )N)r   r   r   r	   r   r   )r   t1t2r   r   r   r   test_concat-   s    zStructSeqTest.test_concatc          	   C   sf   t  }d| }xPtt|D ]@}| || ||t|   | || ||dt|    qW d S )N      )r   r   r	   r   r   )r   r   r   r   r   r   r   test_repeat3   s
    zStructSeqTest.test_repeatc             C   s2   t  }x|D ]}| || qW | d| d S )Ni)r   r   r   ZassertNotIn)r   r   itemr   r   r   test_contains:   s    
zStructSeqTest.test_containsc             C   s$   t  }| t|tt| d S )N)r   r   r   hashr   )r   r   r   r   r   	test_hash@   s    zStructSeqTest.test_hashc             C   sp   t  }t||}| || | ||k   | ||k | ||k  | ||k | ||k  d S )N)r   r   typer   r   )r   r   r   r   r   r   test_cmpD   s    zStructSeqTest.test_cmpc             C   s<   t  }| t||j | |jd | |jt j d S )Nr   )r   r   r   r   n_sequence_fieldsn_unnamed_fieldsn_fieldsZ_STRUCT_TM_ITEMS)r   r   r   r   r   test_fieldsN   s    zStructSeqTest.test_fieldsc             C   sp   t j}| t| | t|d  | t|d | jt|di d | jt|dd d d}| d||| d S )NZ123)dictZ	123456789 )r   struct_timer
   	TypeErrorr   join)r   r   sr   r   r   test_constructorT   s    zStructSeqTest.test_constructorc                s8   G dd dt  G  fddd}|  tj|  d S )Nc               @   s   e Zd ZdS )z)StructSeqTest.test_eviltuple.<locals>.ExcN)__name__
__module____qualname__r   r   r   r   Exca   s   r7   c                   s    e Zd Z fddZdd ZdS )z'StructSeqTest.test_eviltuple.<locals>.Cc                s    d S )Nr   )r   r   )r7   r   r   r   f   s    z3StructSeqTest.test_eviltuple.<locals>.C.__getitem__c             S   s   dS )N	   r   )r   r   r   r   __len__h   s    z/StructSeqTest.test_eviltuple.<locals>.C.__len__N)r4   r5   r6   r   r9   r   )r7   r   r   Ce   s   r:   )	Exceptionr
   r   r/   )r   r:   r   )r7   r   test_eviltuple`   s    zStructSeqTest.test_eviltuplec             C   s   t  }| }d S )N)r   r   
__reduce__)r   r   xr   r   r   test_reducem   s    zStructSeqTest.test_reducec          
   C   sn   t  }t|}d}xT|D ]L}xF|D ]>}x8|dd  D ](}| t|||| ||||  q6W q$W qW d S )N)
r   Nr   r       i,  iir   )r   r   listr   )r   r   Lindicesstartstopstepr   r   r   test_extended_getsliceq   s    

z$StructSeqTest.test_extended_getsliceN)r4   r5   r6   r   r   r   r"   r$   r&   r(   r,   r3   r<   r?   rI   r   r   r   r   r      s   
r   __main__)r   r   ZunittestZTestCaser   r4   mainr   r   r   r   <module>   s
   w