B
    u9a                 @   s   d dl Z d dlmZ ed d dlmZmZmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZ eddddd	d
dddddddZG dd de jZG dd de jZedkre   dS )    N)support	_testcapi)_test_structmembersTypeCHAR_MAXCHAR_MIN	UCHAR_MAXSHRT_MAXSHRT_MIN	USHRT_MAXINT_MAXINT_MINUINT_MAXLONG_MAXLONG_MIN	ULONG_MAX	LLONG_MAX	LLONG_MIN
ULLONG_MAXPY_SSIZE_T_MAXPY_SSIZE_T_MINF                           grt#@g3$@hic               @   sf   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Ze	
eedddd Zdd Zdd ZdS )ReadWriteTestsc             C   s>   dt _| t jd dt _| t jd | ttt dd d S )NTFT_BOOLr   )tsr!   assertEqualassertRaises	TypeErrorsetattr)self r(   (/usr/lib/python3.7/test_structmembers.py	test_bool   s
    zReadWriteTests.test_boolc             C   s@   t t_| tjt  tt_| tjt tt_| tjt d S )N)r   r"   T_BYTEr#   r   r   T_UBYTE)r'   r(   r(   r)   	test_byte&   s    zReadWriteTests.test_bytec             C   s@   t t_| tjt  tt_| tjt tt_| tjt d S )N)r   r"   T_SHORTr#   r	   r
   T_USHORT)r'   r(   r(   r)   
test_short.   s    zReadWriteTests.test_shortc             C   s@   t t_| tjt  tt_| tjt tt_| tjt d S )N)r   r"   T_INTr#   r   r   T_UINT)r'   r(   r(   r)   test_int6   s    zReadWriteTests.test_intc             C   s@   t t_| tjt  tt_| tjt tt_| tjt d S )N)r   r"   T_LONGr#   r   r   T_ULONG)r'   r(   r(   r)   	test_long>   s    zReadWriteTests.test_longc             C   s,   t t_| tjt  tt_| tjt d S )N)r   r"   
T_PYSSIZETr#   r   )r'   r(   r(   r)   test_py_ssize_tF   s    zReadWriteTests.test_py_ssize_t
T_LONGLONGzlong long not presentc             C   sh   t t_| tjt  tt_| tjt tt_| tjt dt_| tjd dt_| tjd d S )Nr   r   )r   r"   r9   r#   r   r   T_ULONGLONG)r'   r(   r(   r)   test_longlongL   s    zReadWriteTests.test_longlongc          
   C   sl   ddddddddd	d
g
}t tdr0|ddg x6d ddi g fD ]$}x|D ]}| ttt|| qJW q@W d S )Nr!   r+   r,   r.   r/   r1   r2   r4   r5   r7   r9   r:   y        	@zfull of eels)hasattrr"   extendr$   r%   r&   )r'   Zinteger_attributesZnonintattrr(   r(   r)   test_bad_assignments\   s    

z#ReadWriteTests.test_bad_assignmentsc             C   s4   |  tjd | tttdd | tttd d S )Nr   T_STRING_INPLACEs)r#   r"   r@   r$   r%   r&   delattr)r'   r(   r(   r)   test_inplace_stringn   s    z"ReadWriteTests.test_inplace_stringN)__name__
__module____qualname__r*   r-   r0   r3   r6   r8   unittestZ
skipUnlessr<   r"   r;   r?   rC   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S )TestWarningsc          	   C   s(   t dtf td t_W d Q R X d S )N r   )r   check_warningsRuntimeWarningr   r"   r+   )r'   r(   r(   r)   test_byte_maxv   s    zTestWarnings.test_byte_maxc          	   C   s(   t dtf td t_W d Q R X d S )NrI   r   )r   rJ   rK   r   r"   r+   )r'   r(   r(   r)   test_byte_minz   s    zTestWarnings.test_byte_minc          	   C   s(   t dtf td t_W d Q R X d S )NrI   r   )r   rJ   rK   r   r"   r,   )r'   r(   r(   r)   test_ubyte_max~   s    zTestWarnings.test_ubyte_maxc          	   C   s(   t dtf td t_W d Q R X d S )NrI   r   )r   rJ   rK   r   r"   r.   )r'   r(   r(   r)   test_short_max   s    zTestWarnings.test_short_maxc          	   C   s(   t dtf td t_W d Q R X d S )NrI   r   )r   rJ   rK   r	   r"   r.   )r'   r(   r(   r)   test_short_min   s    zTestWarnings.test_short_minc          	   C   s(   t dtf td t_W d Q R X d S )NrI   r   )r   rJ   rK   r
   r"   r/   )r'   r(   r(   r)   test_ushort_max   s    zTestWarnings.test_ushort_maxN)	rD   rE   rF   rL   rM   rN   rO   rP   rQ   r(   r(   r(   r)   rH   t   s   rH   __main__)rG   Ztestr   import_moduler   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r"   ZTestCaser    rH   rD   mainr(   r(   r(   r)   <module>   s(   
PW