B
    v9a%                 @   sb   d dl mZ d dlmZmZ d dlmZmZ G dd dZG dd deeZ	G dd	 d	eeZ
d
S )    )StringIO)PyTestCTest)
bigmemtest_1Gc               @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )TestDumpc             C   s(   t  }| ji | | | d d S )Nz{})r   ZjsondumpassertEqualgetvalue)selfZsio r   /usr/lib/python3.7/test_dump.py	test_dump   s    zTestDump.test_dumpc             C   s   |  | i d d S )Nz{})r	   dumps)r   r   r   r   
test_dumps   s    zTestDump.test_dumpsc             C   s@   |  | jdddddd |  | jddddd	ddd
 d S )NFT)TF)	sort_keysz{"false": true, "true": false}g      @      )   g      @F   z+{"false": 1, "2": 3.0, "4.0": 5, "6": true})r	   r   )r   r   r   r   test_encode_truefalse   s    zTestDump.test_encode_truefalsec                s2   t  gd   fdd}| | j |dd d S )N
   c                s
    d= d S )Nr   )obj)ar   r   crasher   s    z-TestDump.test_encode_mutated.<locals>.crasher)defaultz[null, null, null, null, null])objectr	   r   )r   r   r   )r   r   test_encode_mutated   s    zTestDump.test_encode_mutatedc                sd   G  fdddt }G  fdddfddtdD  | }d|d	< | | j|d
dd d S )Nc                   s   e Zd Z fddZdS )z)TestDump.test_encode_evil_dict.<locals>.Dc                s    S )Nr   )r   )Lr   r   keys"   s    z.TestDump.test_encode_evil_dict.<locals>.D.keysN)__name__
__module____qualname__r    r   )r   r   r   D!   s   r$   c                   s    e Zd Z fddZdd ZdS )z)TestDump.test_encode_evil_dict.<locals>.Xc                s
    d= dS )Nr   i9  r   )r   )r   r   r   __hash__&   s    z2TestDump.test_encode_evil_dict.<locals>.X.__hash__c             S   s   dS )Nr   r   )r   or   r   r   __lt__*   s    z0TestDump.test_encode_evil_dict.<locals>.X.__lt__N)r!   r"   r#   r%   r'   r   )r   r   r   X%   s   r(   c                s   g | ]
}  qS r   r   ).0i)r(   r   r   
<listcomp>-   s    z2TestDump.test_encode_evil_dict.<locals>.<listcomp>ib  ztrue.dati9  T)r   z{"1337": "true.dat"})dictranger	   r   )r   r$   dr   )r   r(   r   test_encode_evil_dict    s    zTestDump.test_encode_evil_dictN)r!   r"   r#   r   r   r   r   r/   r   r   r   r   r      s
   	r   c               @   s   e Zd ZdS )
TestPyDumpN)r!   r"   r#   r   r   r   r   r0   3   s    r0   c               @   s    e Zd Zeedddd ZdS )	TestCDumpr   )sizeZmemusec             C   s   t d|t  }dg| }| |}| t||d  | |d d d | |dd  d | |dd d|d   d S )Ni  r      [z1]z1, )intr   r   r	   len)r   r2   NlZencodedr   r   r   test_large_list<   s    

zTestCDump.test_large_listN)r!   r"   r#   r   r   r:   r   r   r   r   r1   5   s   r1   N)ior   Ztest.test_jsonr   r   Ztest.supportr   r   r   r0   r1   r   r   r   r   <module>   s
   -