B
    u9a                 @   sl   d dl Z d dlZd dlmZ d dlmZ d dlZG dd deZG dd dejZ	dd	 Z
ed
krhe
  dS )    N)support)AbstractPickleTestsc               @   s6   e Zd Zd
ddZdd ZdZdZdd Zdd	 ZdS )OptimizedPickleTestsNc             C   s   t t||S )N)pickletoolsoptimizepickledumps)selfargproto r   &/usr/lib/python3.7/test_pickletools.pyr   	   s    zOptimizedPickleTests.dumpsc             K   s   t j|f|S )N)r   loads)r	   bufkwdsr   r   r   r      s    zOptimizedPickleTests.loadsc             C   s   dd t dD }||d  xt tjd D ]}t||}t|}| || | |d |d  t	|}t|}| || | |d |d  | 
tj| | 
tj| q0W d S )Nc             S   s   g | ]}t |qS r   )str).0ir   r   r   
<listcomp>   s    zBOptimizedPickleTests.test_optimize_long_binget.<locals>.<listcomp>i     )rangeappendr   ZHIGHEST_PROTOCOLr   r   assertEqualassertIsr   r   assertNotInZLONG_BINGETZLONG_BINPUT)r	   datar   pickled	unpickledpickled2
unpickled2r   r   r   test_optimize_long_binget   s    


z.OptimizedPickleTests.test_optimize_long_bingetc             C   s   d}|  tj| t|}| |dddg | |d |d  t|}t|}| |dddg | |d |d  | tj| d S )Ns           ](spamqhamhe.ZspamZhamr      )	ZassertInr   ZBINPUTr   r   r   r   r   r   )r	   r   r   r    r!   r   r   r    test_optimize_binput_and_memoize%   s    


z5OptimizedPickleTests.test_optimize_binput_and_memoize)N)	__name__
__module____qualname__r   r   Ztest_pickle_to_2xZ+test_framed_write_sizes_with_delayed_writerr"   r$   r   r   r   r   r      s   
r   c               @   s   e Zd Zdd ZdS )MiscTestCasec          K   C   s   ddddddddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKhK}t j| t|dL d S )MNZbytes_typesZUP_TO_NEWLINEZTAKEN_FROM_ARGUMENT1ZTAKEN_FROM_ARGUMENT4ZTAKEN_FROM_ARGUMENT4UZTAKEN_FROM_ARGUMENT8UZArgumentDescriptorZ
read_uint1Z
read_uint2Z	read_int4Z
read_uint4Z
read_uint8Zread_stringnlZread_stringnl_noescapeZread_stringnl_noescape_pairZread_string1Zread_string4Zread_bytes1Zread_bytes4Zread_bytes8Zread_unicodestringnlZread_unicodestring1Zread_unicodestring4Zread_unicodestring8Zread_decimalnl_shortZread_decimalnl_longZread_floatnlZread_float8Z
read_long1Z
read_long4Zuint1Zuint2Zint4Zuint4Zuint8ZstringnlZstringnl_noescapeZstringnl_noescape_pairZstring1Zstring4Zbytes1Zbytes4Zbytes8ZunicodestringnlZunicodestring1Zunicodestring4Zunicodestring8Zdecimalnl_shortZdecimalnl_longZfloatnlZfloat8Zlong1Zlong4ZStackObjectZpyintZpylongZpyinteger_or_boolZpyboolZpyfloatZpybytes_or_strZpystringZpybytesZ	pyunicodeZpynoneZpytupleZpylistZpydictZpysetZpyfrozensetZ	anyobjectZ
markobjectZ
stacksliceZ
OpcodeInfoZopcodesZcode2op)	blacklist)r   Zcheck__all__r   )r	   r)   r   r   r   test__all__A   s4    


zMiscTestCase.test__all__N)r%   r&   r'   r*   r   r   r   r   r(   @   s   r(   c               C   s"   t t t t t t d S )N)r   Zrun_unittestr   r(   Zrun_doctestr   r   r   r   r   	test_main_   s    

r+   __main__)r   r   Ztestr   Ztest.pickletesterr   Zunittestr   ZTestCaser(   r+   r%   r   r   r   r   <module>   s   9