B
    v9a$                 @   sZ   d dl Z d dl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 )
    N)OrderedDict)PyTestCTestc               @   sd   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S )TestUnicodec             C   s   d}|  |}| |d d S )Nu   αΩz"\u03b1\u03a9")dumpsassertEqual)selfuj r   "/usr/lib/python3.7/test_unicode.pytest_encoding3
   s    
zTestUnicode.test_encoding3c             C   s    d}|  |g}| |d d S )Nu   αΩz["\u03b1\u03a9"])r   r   )r   r	   r
   r   r   r   test_encoding4   s    zTestUnicode.test_encoding4c             C   s(   d}| j |dd}| |d| d S )Nu   αΩF)ensure_asciiz"{0}")r   r   format)r   r	   r
   r   r   r   test_encoding5   s    zTestUnicode.test_encoding5c             C   s*   d}| j |gdd}| |d| d S )Nu   αΩF)r   z["{0}"])r   r   r   )r   r	   r
   r   r   r   test_encoding6   s    zTestUnicode.test_encoding6c             C   s0   d}|  | |d |  | j|ddd d S )Nu   𝄠z"\ud834\udd20"F)r   u   "𝄠")r   r   )r   r	   r   r   r   test_big_unicode_encode   s    z#TestUnicode.test_big_unicode_encodec             C   s4   d}|  | d| d | |  | d| d S )Nu   z𝄠x"z"z\ud834\udd20x")r   loads)r   r	   r   r   r   test_big_unicode_decode#   s    z#TestUnicode.test_big_unicode_decodec             C   s<   x6t ddD ](}t|}d|}| | || qW d S )Nr   i  z"\u{0:04x}")rangechrr   r   r   )r   ir	   sr   r   r   test_unicode_decode(   s    
zTestUnicode.test_unicode_decodec             C   sJ   |  t| dt |  t| dt |  t| dd t d S )Nz""z"a"z["a"]r   )r   typer   str)r   r   r   r   test_unicode_preservation.   s    z%TestUnicode.test_unicode_preservationc             C   s&   |  t| jd |  t| jdg d S )Ns   hi)assertRaises	TypeErrorr   )r   r   r   r   test_bytes_encode3   s    zTestUnicode.test_bytes_encodec             C   s   xvdt jfdt jfdt jfdt jfdt jfgD ]F\}}dg}| ||}| | 	|| | | | 	|| q.W | 
t| j	d | | 	dd	d
 | | 	dd | | 	dd | | 	dd d S )Nzutf-8zutf-16bezutf-16lezutf-32bezutf-32leu
   aµ€𝄠s   [""]u   "☀"z	utf-16-leu   ☀s   5    s    7   s   579   )codecsBOM_UTF8BOM_UTF16_BEBOM_UTF16_LEBOM_UTF32_BEBOM_UTF32_LEr   encoder   r   r   UnicodeDecodeError)r   encodingZbomdataZencodedr   r   r   test_bytes_decode7   s     zTestUnicode.test_bytes_decodec             C   s   d}dddddddg}|  | |t| |  | j|d	d
 d| | j|td}|  |t| |  t|t |  | j|tdd
 dt| d S )Nz?{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7})Zxkd   )Zkcw   )Zart   )Zhxm   )Zqrtr"   )Zpad   )Zhoyr#   c             S   s   | S )Nr   )xr   r   r   <lambda>W       zATestUnicode.test_object_pairs_hook_with_unicode.<locals>.<lambda>)object_pairs_hookc             S   s   d S )Nr   )r5   r   r   r   r6   ]   r7   )r8   Zobject_hook)r   r   evalr   r   )r   r   pZodr   r   r   #test_object_pairs_hook_with_unicodeR   s    

z/TestUnicode.test_object_pairs_hook_with_unicodeN)__name__
__module____qualname__r   r   r   r   r   r   r   r   r!   r/   r;   r   r   r   r   r      s   r   c               @   s   e Zd ZdS )TestPyUnicodeN)r<   r=   r>   r   r   r   r   r?   a   s    r?   c               @   s   e Zd ZdS )TestCUnicodeN)r<   r=   r>   r   r   r   r   r@   b   s    r@   )	r%   collectionsr   Ztest.test_jsonr   r   r   r?   r@   r   r   r   r   <module>   s
   [