a 5êdg‰>ã@sªddlZddlmZddlZddlZddlZddlmZmZm Z Gdd„dej ƒZ Gdd„dej ƒZ Gdd „d e ƒZ Gd d „d e ƒZGd d „d ej ƒZedkr¦e ¡dS)éN)Ú HTTPException)Úopen_urlresourceÚrequires_resourceÚ script_helperc@s eZdZdZedƒdd„ƒZdS)ÚUnicodeMethodsTestZ(fbdf8106a3c7c242086b0a9efa03ad4d30d5b85dÚcpucCsnt ¡}ttjdƒD]:}t|ƒ}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 ¡g}| d |¡ dd ¡¡q| ¡}| ||j¡dS) NéZ01ÚabcZ123z ÚABCÚúutf-8Ú surrogatepass)ÚhashlibÚsha1ÚrangeÚsysÚ maxunicodeÚchrÚisalnumÚisalphaÚ isdecimalÚisdigitÚislowerÚ isnumericÚisspaceÚistitleÚisupperÚlowerÚupperÚtitleÚupdateÚjoinÚencodeÚ hexdigestÚ assertEqualÚexpectedchecksum)ÚselfÚhÚiÚcharÚdataÚresult©r,ú1/usr/local/lib/python3.9/test/test_unicodedata.pyÚtest_method_checksums@             à#z'UnicodeMethodsTest.test_method_checksumN)Ú__name__Ú __module__Ú __qualname__r%rr.r,r,r,r-rsrc@seZdZeZdS)ÚUnicodeDatabaseTestN)r/r0r1Ú unicodedataÚdbr,r,r,r-r2Bsr2c@sˆeZdZdZedƒdd„ƒZdd„Zdd„Zd d „Zd d „Z d d„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„ZdS) ÚUnicodeFunctionsTestZ(d1e37a2854df60ac607b47b51189b9bf1b54bfdbrc CsÌg}t ¡}ttjdƒD]–}t|ƒ}t|j |d¡dƒt|j  |d¡dƒt|j  |d¡dƒ|j  |¡|j  |¡|j  |¡t|j |¡ƒt|j |¡ƒg}| d |¡ d¡¡q| ¡}| ||j¡dS)Nréÿÿÿÿz.12gr Úascii)rrrrrrÚformatr4ÚdigitÚnumericÚdecimalÚcategoryÚ bidirectionalÚ decompositionÚstrÚmirroredÚ combiningr r!r"r#r$r%)r&r*r'r(r)r+r,r,r-Útest_function_checksumKs    ÷ z+UnicodeFunctionsTest.test_function_checksumcCs¶| |j dd¡d¡| |j d¡d¡| |j dd¡d¡| |j d¡d¡| |j dd¡d¡| |j d¡d¡| t|jj¡| t|jjd ¡| t|jjd ¡dS© NÚAÚ9é õâ…›õ⑨õð €€uðŸ½éÚxxÚx)r$r4r9Ú assertRaisesÚ TypeErrorÚ ValueError©r&r,r,r-Ú test_digitaszUnicodeFunctionsTest.test_digitcCsÈ| |j dd¡d¡| |j d¡d¡| |j d¡d¡| |j d¡d¡| |j d¡d ¡| |j d d¡d¡| |j d ¡d ¡| t|jj¡| t|jjd ¡| t|jjd¡dS)NrDrErFrGgÀ?rHg"@u꘧g@rIõð„ªi(#rKrL)r$r4r:rMrNrOrPr,r,r-Ú test_numericmsz!UnicodeFunctionsTest.test_numericcCs¸| |j dd¡d¡| |j d¡d¡| |j dd¡d¡| |j dd¡d¡| |j dd¡d¡| |j d¡d¡| t|jj¡| t|jjd ¡| t|jjd ¡dSrC)r$r4r;rMrNrOrPr,r,r-Ú test_decimalzsz!UnicodeFunctionsTest.test_decimalcCsŠ| |j d¡d¡| |j d¡d¡| |j d¡d¡| |j d¡d¡| |j d ¡d ¡| t|jj¡| t|jjd ¡dS) Nõ￾ZCnÚaZLlrDZLurIZLorRZNorK)r$r4r<rMrNrPr,r,r-Ú test_category†sz"UnicodeFunctionsTest.test_categorycCsv| |j d¡d¡| |j d¡d¡| |j d¡d¡| |j d¡d¡| t|jj¡| t|jjd¡dS) NrUr ú ZWSrDÚLrIrK)r$r4r=rMrNrPr,r,r-Útest_bidirectionals z'UnicodeFunctionsTest.test_bidirectionalcCsN| |j d¡d¡| |j d¡d¡| t|jj¡| t|jjd¡dS)NrUr õ¼z 0031 2044 0034rK)r$r4r>rMrNrPr,r,r-Útest_decomposition™sz'UnicodeFunctionsTest.test_decompositioncCsv| |j d¡d¡| |j d¡d¡| |j d¡d¡| |j d¡d¡| t|jj¡| t|jjd¡dS)NrUrrVuâˆrrIrK)r$r4r@rMrNrPr,r,r-Ú test_mirrored s z"UnicodeFunctionsTest.test_mirroredcCsv| |j d¡d¡| |j d¡d¡| |j d¡d¡| |j d¡d¡| t|jj¡| t|jjd¡dS)NrUrrVu⃡éærIrK)r$r4rArMrNrPr,r,r-Útest_combining©s z#UnicodeFunctionsTest.test_combiningcCs(d}|D]}| |j d|¡|¡qdS)N)uେ̀ାuᄀ̀ᅡu LiÌt-sá¹³Ìu.मारà¥à¤• ज़à¥à¤•ेरबरà¥à¤—u'किरà¥à¤—िज़सà¥à¤¤à¤¾à¤¨ÚNFC©r$r4Ú normalize)r&ZcomposedÚtextr,r,r-Ú test_pr29²szUnicodeFunctionsTest.test_pr29cCs"d}d}| |j d|¡|¡dS)Nu?C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸Çu>C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸C̸Çr`ra)r&rVÚbr,r,r-Útest_issue10254¾sz$UnicodeFunctionsTest.test_issue10254cCs^d}d}d}d}d}d}| |j d|¡|¡| |j d|¡|¡| |j d|¡|¡dS)Nu ᄀᅶᆨu 기ᆧu기ᆧu 기ᇃu기ᇃr`ra)r&Z u1176_str_aZ u1176_str_bZ u11a7_str_aZ u11a7_str_bZ u11c3_str_aZ u11c3_str_br,r,r-Útest_issue29456Äsz$UnicodeFunctionsTest.test_issue29456cCs¶|jj}| t|d¡| t|tƒ¡| t|d¡| t|d¡| |dƒd¡| |dƒd¡| |dƒd ¡| |d ƒd ¡| |d ƒd ¡| |dƒd¡| |dƒd ¡dS)Nóar ZraúÚNrXZNau좔ÚWuヲÚHu?ÚFuâ€rDrI)r4Úeast_asian_widthrMrNÚ bytearrayr$)r&Zeawr,r,r-Útest_east_asian_widthÐsz*UnicodeFunctionsTest.test_east_asian_widthcCs.| |jj d¡d¡| |j d¡d¡dS)Nu⌚rjrk)r$r4Ú ucd_3_2_0rnrPr,r,r-Ú!test_east_asian_width_9_0_changesÞsz6UnicodeFunctionsTest.test_east_asian_width_9_0_changesN)r/r0r1r%rrBrQrSrTrWrZr\r]r_rdrfrgrprrr,r,r,r-r5Es           r5c@sLeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dS)ÚUnicodeMiscTestcCs,d}t d|¡}d}| ||j d¡¡dS)NzGimport sys;sys.modules['unicodedata'] = None;eval("'\\N{SOFT HYPHEN}'")z-czUSyntaxError: (unicode error) \N escapes not supported (can't load unicodedata module)r7)rZassert_python_failureZassertInÚerrÚdecode)r&Úcoder+Úerrorr,r,r-Ú#test_failed_import_during_compilingäs z3UnicodeMiscTest.test_failed_import_during_compilingcCs^d}tdƒD]>}t|ƒ}|j |d¡}|dkr | ||j |¡¡|d7}q | |dk¡dS©Nrér6ré )rrr4r;r$r:Ú assertTrue©r&Úcountr(ÚcZdecr,r,r-Útest_decimal_numeric_consistentôs  z/UnicodeMiscTest.test_decimal_numeric_consistentcCs^d}tdƒD]>}t|ƒ}|j |d¡}|dkr | ||j |¡¡|d7}q | |dk¡dSry)rrr4r9r$r:r|r}r,r,r-Útest_digit_numeric_consistents  z-UnicodeMiscTest.test_digit_numeric_consistentcCs| |j d¡d¡dS)NzGOTHIC LETTER FAIHUuð†)r$r4ÚlookuprPr,r,r-Útest_bug_1704793sz UnicodeMiscTest.test_bug_1704793cCsfddl}| | d¡¡| |j d¡ ¡| d ¡dk¡| d ¡dk¡| d ¡dk¡dS)Nru༺rVrDõáµ¹uê½Ú.)r3r|r@rqr)r&r3r,r,r-Ú test_ucd_510s zUnicodeMiscTest.test_ucd_510cCs6| d ¡d¡| dd„ttjdƒDƒdg¡dS)Nr„cSs8g|]0}dt|ƒ ¡t|ƒ ¡t|ƒ ¡vr|‘qS)ú)rrrr)Ú.0rr,r,r-Ú s(ÿz1UnicodeMiscTest.test_bug_5828..rr)r$rrrrrPr,r,r-Ú test_bug_5828s ÿûzUnicodeMiscTest.test_bug_5828cCs4| d ¡d¡| d ¡d¡| d ¡d¡dS)NuÇ„uÇ…udž)r$rrPr,r,r-Ú test_bug_4971'szUnicodeMiscTest.test_bug_4971cCsXtdƒD]J}t|ƒd ¡}|dvr<| t|ƒdd|¡q| t|ƒdd|¡qdS)NrzrD) r{é é é é…éééi( i) éz\u%.4x should be a linebreakrz \u%.4x should not be a linebreak)rrÚ splitlinesr$Úlen)r&r(Úlinesr,r,r-Útest_linebreak_7643-s  ÿ ÿz#UnicodeMiscTest.test_linebreak_7643N) r/r0r1rxr€rrƒr†rŠr‹r—r,r,r,r-rsâs    rsc@sLeZdZedd„ƒZedd„ƒZedƒdd„ƒZdd „Zd d „Z d d „Z dS)ÚNormalizationTestcCs| ¡}tj|vS)N)Úreadliner3Úunidata_version)ZtestfileZhdrr,r,r-Ú check_version9szNormalizationTest.check_versioncCs(dd„| d¡Dƒ}d dd„|Dƒ¡S)NcSsg|]}t|dƒ‘qS)é)Úint©rˆrLr,r,r-r‰@óz,NormalizationTest.unistr..rXr cSsg|] }t|ƒ‘qSr,)rržr,r,r-r‰ArŸ)Úsplitr!)r*r,r,r-Úunistr>szNormalizationTest.unistrZnetworkc Cs¦d}dtj›d|›}zt|d|jd}WnHtyN| d|›d¡Yn&ttfyr| d|›¡Yn0||  |¡Wdƒn1s˜0YdS) NzNormalizationTest.txtz"http://www.pythontest.net/unicode/ú/r )ÚencodingÚcheckz"Permission error when downloading z into the test data directoryzCould not retrieve ) r3ršrr›ÚPermissionErrorZskipTestÚOSErrorrZfailÚrun_normalization_tests)r&Z TESTDATAFILEZ TESTDATAURLÚtestdatar,r,r-Útest_normalizationCsÿ  z$NormalizationTest.test_normalizationcsd}i}dd„}dd„}dd„}dd„}|D]\}d |vrH| d ¡d }| ¡}|sVq,| d ¡rn| ¡d }q,‡fd d „| d¡dd…Dƒ\} } } } } ˆ | || ƒkoÄ|| ƒkoÄ|| ƒkn|¡ˆ | || ƒkoì|| ƒkn|¡ˆ | || ƒko&|| ƒko&|| ƒkn|¡ˆ | || ƒkoP|| ƒkn|¡ˆ | || ƒkoª|| ƒkoª|| ƒkoª|| ƒkoª|| ƒkn|¡ˆ | || ƒko|| ƒko|| ƒko|| ƒko|| ƒkn|¡ˆ t d| ¡¡ˆ t d| ¡¡ˆ t d| ¡¡ˆ t d| ¡¡ˆ t d| ¡¡ˆ t d| ¡¡|dkr,d|| <q,ttjdƒD]f}t |ƒ}||vr´qšˆ |||ƒkoô||ƒkoô||ƒkoô||ƒkn|¡qšdS)NcSs t d|¡S)Nr`©r3rb©r?r,r,r-r`Ysz6NormalizationTest.run_normalization_tests..NFCcSs t d|¡S)NÚNFKCrªr«r,r,r-r¬\sz7NormalizationTest.run_normalization_tests..NFKCcSs t d|¡S)NÚNFDrªr«r,r,r-r­_sz6NormalizationTest.run_normalization_tests..NFDcSs t d|¡S)NÚNFKDrªr«r,r,r-r®bsz7NormalizationTest.run_normalization_tests..NFKDú#rz@Partcsg|]}ˆ |¡‘qSr,)r¡ržrPr,r-r‰nrŸz=NormalizationTest.run_normalization_tests..ú;r6r`r­r¬r®z@Part1r) r ÚstripÚ startswithr|r3Ú is_normalizedrrrr)r&r¨ÚpartZ part1_datar`r¬r­r®ÚlineÚc1Úc2Zc3Zc4Zc5rÚXr,rPr-r§Usf   *6(:*&ÿ ÿ ÿþ&ÿ ÿ ÿþ  z)NormalizationTest.run_normalization_testscCs8| ttj¡| ttjdd¡| t dd¡d¡dS)NÚunknownrKr¬r )rMrNr3rbrOr$rPr,r,r-Útest_edge_casessz!NormalizationTest.test_edge_casescCst dd¡dS)Nr`u한글rªrPr,r,r-Útest_bug_834676•sz!NormalizationTest.test_bug_834676N) r/r0r1Ú staticmethodr›r¡rr©r§rºr»r,r,r,r-r˜8s   ;r˜Ú__main__)rZ http.clientrrr3ZunittestZ test.supportrrrZTestCaserr2r5rsr˜r/Úmainr,r,r,r-Ú s 1Vb