HEX
Server: LiteSpeed
System: Linux altar40.supremepanel40.com 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
User: sescorpcl (4477)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: //lib64/python3.6/site-packages/simplejson/tests/__pycache__/test_dump.cpython-36.pyc
3

�8�]t(�@sxddlmZddlmZmZmZmZmZmZddl	Z
Gdd�de�ZGdd�de�Zdd	�Z
d
d�ZGdd
�d
e�ZdS)�)�TestCase)�StringIO�	long_type�b�binary_type�	text_type�PY3Nc@seZdZdd�ZdS)�MisbehavingTextSubtypecCsdS)NzFAIL!�)�selfr
r
�!/usr/lib64/python3.6/test_dump.py�__str__szMisbehavingTextSubtype.__str__N)�__name__�
__module__�__qualname__r
r
r
r
rr	sr	c@s&eZdZddd�Zdd�Zdd�ZdS)	�MisbehavingBytesSubtypeNcCsdS)Nz
bad decoder
)r�encodingr
r
r�decode
szMisbehavingBytesSubtype.decodecCsdS)Nzbad __str__r
)rr
r
rr
szMisbehavingBytesSubtype.__str__cCstd�S)Nz
bad __bytes__)r)rr
r
r�	__bytes__sz!MisbehavingBytesSubtype.__bytes__)N)rrrrr
rr
r
r
rr	s
rcCstrt|t�r|jd�S|S)N�ascii)r�
isinstance�bytesr)�sr
r
r�as_text_types
rcCs
|jd�S)Nziso-8859-15)r)rr
r
r�decode_iso_8859_15src@s|eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�TestDumpcCs&t�}tji|�|j|j�d�dS)Nz{})r�json�dump�assertEqual�getvalue)r�sior
r
r�	test_dumpszTestDump.test_dumpcCsnxhdD]`}|jtjtj|��|k�|jtjtj|g��d|k�|jtjtjd|i��d|k�qWdS)NTFr�a)NTF)Z
assertTruer�loads�dumps)r�cr
r
r�test_constantss
 zTestDump.test_constantsc	CsNtd�dfdddddtd�dfg}xT|D]L\}}|jtjtj||i��||i�|jtjtj||idd
��||i�q(W|jttjtdi�x�idditd�dddigD]�}x�dD]�}t|�}d|t<tdd�|j	�D��}|jtjtj|d|d��|�|jtjtjd|id|d��d|i�|jtjtj|gd|d��|g�q�Wq�WdS)Nr��?�1.0�
�10T�trueF�false�null�dZ100)�	sort_keys��otherZderpZherp�css|]\}}t|�|fVqdS)N)r)�.0�key�valr
r
r�	<genexpr>9sz.TestDump.test_stringify_key.<locals>.<genexpr>)�skipkeysr/�)r'r()r)r*)Tr+)Fr,)Nr-)FT)
rrrrr#r$�assertRaises�	TypeError�dict�items)rr<�k�expect�vr/Zv0Zv1r
r
r�test_stringify_key%s:

 

zTestDump.test_stringify_keycCs|jtji�d�dS)Nz{})rrr$)rr
r
r�
test_dumpsDszTestDump.test_dumpscCsR|jtjddd�dd�d�|jtjdddtd	�dd
td�ddd
idd�d�dS)NFT)TF)r/z{"false": true, "true": false}r2g@g@�r0��7rz3{"2": 3.0, "4.0": 5, "6": true, "7": 0, "false": 1})rrr$r)rr
r
r�test_encode_truefalseGszTestDump.test_encode_truefalsecCs.dd
dddg}tjtj|��}|j|d�dS)N�oner0�twor2�three��four��fiverBz6{"one": 1, "two": 2, "three": 3, "four": 4, "five": 5})rFr0)rGr2)rHrI)rJrK)rLrB)rr$�OrderedDictr)rr<rr
r
r�test_ordered_dictUs
zTestDump.test_ordered_dictcCs8Gdd�dt�}tjdddg|d�d�}|j|d�d	S)
a�
        A test against the regression mentioned at `github issue 29`_.

        The indent parameter should accept any type which pretends to be
        an instance of int or long when it comes to being multiplied by
        strings, even if it is not actually an int or long, for
        backwards compatibility.

        .. _github issue 29:
           http://github.com/simplejson/simplejson/issue/29
        c@s eZdZdZdd�Zdd�ZdS)z@TestDump.test_indent_unknown_type_acceptance.<locals>.AwesomeIntz'An awesome reimplementation of integersc_s(t|�dkr$t|dt�r$|d|_dS)Nr)�lenr�int�_int)r�args�kwargsr
r
r�__init__mszITestDump.test_indent_unknown_type_acceptance.<locals>.AwesomeInt.__init__cSs t|d�r|j|Std��dS)NrQzOTo do non-awesome things with this object, please construct it from an integer!)�hasattrrQ�NotImplementedError)rr1r
r
r�__mul__xs

zHTestDump.test_indent_unknown_type_acceptance.<locals>.AwesomeInt.__mul__N)rrr�__doc__rTrWr
r
r
r�
AwesomeIntjsrYrr0r2rI)�indentz[
   0,
   1,
   2
]N)�objectrr$r)rrYrr
r
r�#test_indent_unknown_type_acceptance]s
z,TestDump.test_indent_unknown_type_acceptancecCs&dgd}|jtjtj|��|�dS)Nri��)rrr#r$)rZlstr
r
r�test_accumulator�s
zTestDump.test_accumulatorcCstxntdd�D]`}tdd�t|�D��}t�}tj||dd�|j|j�tj|dd��|jtj|j��|�qWdS)Nr2� css|]}t|�|fVqdS)N)�str)r3�xr
r
rr6�sz*TestDump.test_sort_keys.<locals>.<genexpr>T)r/)	�ranger;rrrrrr$r#)rZnum_keys�pr r
r
r�test_sort_keys�szTestDump.test_sort_keyscCshd}|jtjt|��tj|��|jtjt|�g�tj|g��|jtjt|�di�tj|di��dS)Nzthis is some text�*)rrr$r	)r�textr
r
r�test_misbehaving_text_subtype�sz&TestDump.test_misbehaving_text_subtypecCsltd�}|jtjt|��tj|��|jtjt|�g�tj|g��|jtjt|�di�tj|di��dS)Nuthis is some data €rd)rrrr$r)r�datar
r
r�test_misbehaving_bytes_subtype�sz'TestDump.test_misbehaving_bytes_subtypecCs|jtjtd��d�|jttjtd��|jtjtd�dd�d�|jtjtd�dd�d�tr�|jttjtd�dd�|jttjtd�dd�|jtjtd�dtd�d�nL|jtjtd�dd�d�|jttjtd�dd�|jttjtd�dtd�dS)	Nu€z"\u20ac"�¤z
iso-8859-1)rz"\u00a4"ziso-8859-15)r�default)	rrr$rr9�UnicodeDecodeErrorrr:r)rr
r
r�test_bytes_toplevel�s(zTestDump.test_bytes_toplevelcCs|jtjtd�g�d�|jttjtd�g�|jtjtd�gdd�d�|jtjtd�gdd�d�tr�|jttjtd�gdd�|jttjtd�gdd�|jtjtd�gdtd�d�nR|jtjtd�gdd�d�|jttjtd�gdd�|jttjtd�gdtd�dS)	Nu€z
["\u20ac"]riz
iso-8859-1)rz
["\u00a4"]ziso-8859-15)rrj)	rrr$rr9rkrr:r)rr
r
r�test_bytes_nested�s(zTestDump.test_bytes_nestedcCsd|jtjtd�di�d�|jttjtd�di�|jtjtd�didd�d�|jtjtd�didd�d�tr�|jttjtd�didd�|jttjtd�didd�|jttjtd�didtd	�|jtjtd�didd
d�d�nv|jtjtd�didd�d�|jttjtd�didd�|jttjtd�didtd	�|jttjtd�didd
d�dS)
Nu€rdz{"\u20ac": 42}riz
iso-8859-1)rz{"\u00a4": 42}ziso-8859-15)rrjT)rr7z{})	rrr$rr9rkrr:r)rr
r
r�test_bytes_key�s0

zTestDump.test_bytes_keyN)rrrr!r&r@rArErNr\r]rcrfrhrlrmrnr
r
r
rrs(	r)ZunittestrZsimplejson.compatrrrrrrZ
simplejsonrr	rrrrr
r
r
r�<module>s