B VXYT@sTddlZddlZddlmZddlZddlmZmZm Z m Z m Z GdddeZ dS)N)TestCase)unichr text_typebuBytesIOc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%S)& TestUnicodecCs>tjdd}d}|d}||}||}|||dS)Nzutf-8)encodinguαΩ)json JSONEncoderencode assertEqual)selfencoderrsjujsrP/opt/alt/python37/lib64/python3.7/site-packages/simplejson/tests/test_unicode.pytest_encoding1 s     zTestUnicode.test_encoding1cCs:d}|d}tj|dd}tj|dd}|||dS)NuαΩzutf-8)r )r r dumpsr )rrrrrrrrtest_encoding2s  zTestUnicode.test_encoding2cCsd}t|}||ddS)NuαΩz"\u03b1\u03a9")r rr )rrjrrrtest_encoding3s zTestUnicode.test_encoding3cCs d}t|g}||ddS)NuαΩz["\u03b1\u03a9"])r rr )rrrrrrtest_encoding4s zTestUnicode.test_encoding4cCs*d}tj|dd}||d|ddS)NuαΩF) ensure_ascii")r rr )rrrrrrtest_encoding5"szTestUnicode.test_encoding5cCs,d}tj|gdd}||d|ddS)NuαΩF)rz["z"])r rr )rrrrrrtest_encoding6'szTestUnicode.test_encoding6cCs0d}|t|d|tj|ddddS)Nu𝄠z"\ud834\udd20"F)ru"𝄠")r r r)rrrrrtest_big_unicode_encode,sz#TestUnicode.test_big_unicode_encodecCs4d}|td|d||td|dS)Nuz𝄠xrz"z\ud834\udd20x")r r loads)rrrrrtest_big_unicode_decode1sz#TestUnicode.test_big_unicode_decodecCs<x6tddD](}t|}d|f}|t||q WdS)Nriz"\u%04x")rangerr r r )rirrrrrtest_unicode_decode6s zTestUnicode.test_unicode_decodecCsd}dddddddg}|t|t||tj|d d d |tj|tjd }||t||t|tj|tj|tjd d d t|dS)Nz?{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7})Zxkd)Zkcw)Zart)Zhxm)Zqrt)pad)ZhoycSs|S)Nr)xrrrBzATestUnicode.test_object_pairs_hook_with_unicode..)object_pairs_hookcSsdS)Nr)r-rrrr.Ir/)r0 object_hook)r r r eval OrderedDicttype)rrpZodrrr#test_object_pairs_hook_with_unicode=s   z/TestUnicode.test_object_pairs_hook_with_unicodecCs |tddddidS)Nu {"a": "é"}zutf-8aé)r r r r )rrrrtest_default_encodingMsz!TestUnicode.test_default_encodingcCsJ|ttdt|ttdt|ttddtdS)Nz""z"a"z["a"]r)r r4r r r)rrrrtest_unicode_preservationQsz%TestUnicode.test_unicode_preservationcCsl|ttjgddt|ttjdddt|ttjiddt|ttjdddtdS)NF)rr)r r4r rr)rrrr'test_ensure_ascii_false_returns_unicodeVsz3TestUnicode.test_ensure_ascii_false_returns_unicodecCstdtdi}dtdi}d}d}|t|||t|||tj|dd||tj|dd|dS)NZquuxuArrêt sur imagesuArrêt sur imagesz!{"quux": "Arr\u00eat sur images"}u{"quux": "Arrêt sur images"}F)r)rrr r r)rZdoc1Zdoc2Z doc_asciiZ doc_unicoderrr+test_ensure_ascii_false_bytestring_encoding]s  z7TestUnicode.test_ensure_ascii_false_bytestring_encodingcCsfd}|d}d}|t|||t|||tj|dd||tj|dd|dS)Nu

utf8z"\u2029\u2028"F)r)r r r r)rs1s2Zexpectrrr$test_ensure_ascii_linebreak_encodinghs z0TestUnicode.test_ensure_ascii_linebreak_encodingcCsB|tjtjd|tjtjd|tjtjd|tjtjd|tjtjd|tjtjd|tjtjd|tjtjd|tjtjd tjd kr>|tjtjd |tjtjd |tjtjd |tjtjd|tjtjd|tjtjd|tjtjd|tjtjddS)Nz"\uz"\u1z"\u12z"\u123z"\u1234z"\u123x"z"\u12x4"z"\u1x34"z"\ux234"iz "\ud800\u"z "\ud800\u0"z "\ud800\u00"z "\ud800\u000"z"\ud800\u000x"z"\ud800\u00x0"z"\ud800\u0x00"z"\ud800\ux000")Z assertRaisesr JSONDecodeErrorr sys maxunicode)rrrrtest_invalid_escape_sequencesrs$ z)TestUnicode.test_invalid_escape_sequencescCs\x4tttddD] }|tj|ddt|qWd}|tj|ddd|ddS)NrF)ru☃r)maprr"r r r)rcZsnowmanrrrtest_ensure_ascii_still_workss  z)TestUnicode.test_ensure_ascii_still_workscCs\d}tjtt|}|tt||x(||dfD]}|t ||q>WdS)Nuこんにちわr>) codecsBOM_UTF8rr rr loadrdecoder )rcontentZjson_docdocrrrtest_strip_boms zTestUnicode.test_strip_bomN)__name__ __module__ __qualname__rrrrrrrr!r$r6r9r:r<r=rArErIrPrrrrrs$   r) rCrJZunittestr simplejsonr Zsimplejson.compatrrrrrrrrrrs