a ze>@sdZddlZddlmZddlZddlZddlZddlmZm Z m Z Gdddej Z Gdddej Z Gd d d e ZGd d d e ZGd ddej ZedkredS)z Tests for the unicodedata module. Written by Marc-Andre Lemburg (mal@lemburg.com). (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. N) HTTPException)open_urlresourcerequires_resource script_helperc@s eZdZdZedddZdS)UnicodeMethodsTestZ(fbdf8106a3c7c242086b0a9efa03ad4d30d5b85dcpucCsnt}ttjdD]:}t|}d|d|d|d| d| d| d| d| d|d|dd|dd|dd|d d|d d|d d|d d|d d|d||||d|d|d|dg}|d|dd q|}|||jdS) NZ01abcZ123z ABCutf-8 surrogatepass)hashlibsha1rangesys maxunicodechrisalnumisalpha isdecimalisdigitislower isnumericisspaceistitleisupperloweruppertitleupdatejoinencode hexdigest assertEqualexpectedchecksum)selfhichardataresultr,I/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_unicodedata.pytest_method_checksums@             #z'UnicodeMethodsTest.test_method_checksumN)__name__ __module__ __qualname__r%rr.r,r,r,r-rsrc@seZdZeZdS)UnicodeDatabaseTestN)r/r0r1 unicodedatadbr,r,r,r-r2Bsr2c@seZdZdZedddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZddZddZddZddZdS) UnicodeFunctionsTestZ(d1e37a2854df60ac607b47b51189b9bf1b54bfdbrc Csg}t}ttjdD]}t|}t|j|ddt|j |ddt|j |dd|j ||j ||j |t|j|t|j|g}|d|dq|}|||jdS)Nrz.12gr ascii)rrrrrrformatr4digitnumericdecimalcategory bidirectional decompositionstrmirrored combiningr r!r"r#r$r%)r&r*r'r(r)r+r,r,r-test_function_checksumKs     z+UnicodeFunctionsTest.test_function_checksumcCs||jddd||jdd||jddd||jdd||jddd||jdd|t|jj|t|jjd |t|jjd dS NA9 ⅛⑨𠀀u𝟽xxx)r$r4r9 assertRaises TypeError ValueErrorr&r,r,r- test_digitaszUnicodeFunctionsTest.test_digitcCs||jddd||jdd||jdd||jdd||jdd ||jd dd||jd d |t|jj|t|jjd |t|jjddS)NrDrErFrGg?rHg"@u꘧g@rI𐄪i(#rKrL)r$r4r:rMrNrOrPr,r,r- test_numericmsz!UnicodeFunctionsTest.test_numericcCs||jddd||jdd||jddd||jddd||jddd||jdd|t|jj|t|jjd |t|jjd dSrC)r$r4r;rMrNrOrPr,r,r- test_decimalzsz!UnicodeFunctionsTest.test_decimalcCs||jdd||jdd||jdd||jdd||jd d |t|jj|t|jjd dS) N￾ZCnaZLlrDZLurIZLorRZNorK)r$r4r<rMrNrPr,r,r- test_categorysz"UnicodeFunctionsTest.test_categorycCsv||jdd||jdd||jdd||jdd|t|jj|t|jjddS) NrUr  ZWSrDLrIrK)r$r4r=rMrNrPr,r,r-test_bidirectionals z'UnicodeFunctionsTest.test_bidirectionalcCsN||jdd||jdd|t|jj|t|jjddS)NrUr ¼z 0031 2044 0034rK)r$r4r>rMrNrPr,r,r-test_decompositionsz'UnicodeFunctionsTest.test_decompositioncCsv||jdd||jdd||jdd||jdd|t|jj|t|jjddS)NrUrrVu∁rrIrK)r$r4r@rMrNrPr,r,r- test_mirroreds z"UnicodeFunctionsTest.test_mirroredcCsv||jdd||jdd||jdd||jdd|t|jj|t|jjddS)NrUrrVu⃡rIrK)r$r4rArMrNrPr,r,r-test_combinings z#UnicodeFunctionsTest.test_combiningcCs(d}|D]}||jd||qdS)N)uେ̀ାuᄀ̀ᅡu Li̍t-sṳ́u.मार्क ज़ुकेरबर्गu'किर्गिज़स्तानNFCr$r4 normalize)r&Zcomposedtextr,r,r- test_pr29szUnicodeFunctionsTest.test_pr29cCs"d}d}||jd||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&rVbr,r,r-test_issue10254sz$UnicodeFunctionsTest.test_issue10254cCs^d}d}d}d}d}d}||jd||||jd||||jd||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_issue29456sz$UnicodeFunctionsTest.test_issue29456cCs|jj}|t|d|t|t|t|d|t|d||dd||dd||dd ||d d ||d d ||dd||dd dS)Nar ZraNrXZNau좔WuヲHu?Fu‐rDrI)r4east_asian_widthrMrN bytearrayr$)r&Zeawr,r,r-test_east_asian_widthsz*UnicodeFunctionsTest.test_east_asian_widthcCs.||jjdd||jdddS)Nu⌚rjrk)r$r4 ucd_3_2_0rnrPr,r,r-!test_east_asian_width_9_0_changessz6UnicodeFunctionsTest.test_east_asian_width_9_0_changesN)r/r0r1r%rrBrQrSrTrWrZr\r]r_rdrfrgrprrr,r,r,r-r5Es           r5c@sLeZdZddZddZddZddZd d Zd d Zd dZ ddZ dS)UnicodeMiscTestcCs,d}td|}d}|||jddS)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_failureZassertInerrdecode)r&coder+errorr,r,r-#test_failed_import_during_compilings z3UnicodeMiscTest.test_failed_import_during_compilingcCs^d}tdD]>}t|}|j|d}|dkr |||j||d7}q ||dkdSNrr6r )rrr4r;r$r: assertTruer&countr(cZdecr,r,r-test_decimal_numeric_consistents  z/UnicodeMiscTest.test_decimal_numeric_consistentcCs^d}tdD]>}t|}|j|d}|dkr |||j||d7}q ||dkdSry)rrr4r9r$r:r|r}r,r,r-test_digit_numeric_consistents  z-UnicodeMiscTest.test_digit_numeric_consistentcCs||jdddS)NzGOTHIC LETTER FAIHUu𐍆)r$r4lookuprPr,r,r-test_bug_1704793sz UnicodeMiscTest.test_bug_1704793cCsfddl}||d||jd |ddk|ddk|ddkdS)Nru༺rVrDᵹuꝽ.)r3r|r@rqr)r&r3r,r,r- test_ucd_510s zUnicodeMiscTest.test_ucd_510cCs6|dd|ddttjdDdgdS)NrcSs8g|]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|dd|dd|dddS)NuDŽuDžudž)r$rrPr,r,r- test_bug_4971'szUnicodeMiscTest.test_bug_4971cCsXtdD]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/r0r1rxrrrrrrrr,r,r,r-rss    rsc@sLeZdZeddZeddZedddZdd Zd d Z d d Z dS)NormalizationTestcCs|}tj|vS)N)readliner3unidata_version)ZtestfileZhdrr,r,r- check_version9szNormalizationTest.check_versioncCs(dd|dD}ddd|DS)NcSsg|]}t|dqS))intrrLr,r,r-r@z,NormalizationTest.unistr..rXr cSsg|] }t|qSr,)rrr,r,r-rAr)splitr!)r*r,r,r-unistr>szNormalizationTest.unistrZnetworkc Csd}dtjd|}zt|d|jd}WnHtyN|d|dYn&ttfyr|d|Yn0|| |Wdn1s0YdS) NzNormalizationTest.txtz"http://www.pythontest.net/unicode//r )encodingcheckz"Permission error when downloading z into the test data directoryzCould not retrieve ) r3rrrPermissionErrorZskipTestOSErrorrZfailrun_normalization_tests)r&Z TESTDATAFILEZ TESTDATAURLtestdatar,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 |dddD\} } } } } | || ko|| ko|| kn|| || ko|| kn|| || ko&|| ko&|| kn|| || koP|| kn|| || ko|| ko|| ko|| ko|| kn|| || ko|| ko|| ko|| ko|| kn|td| td| td| td| td| td| |dkr,d|| <q,ttjdD]f}t |}||vrq|||ko||ko||ko||kn|qdS)NcSs td|S)Nr`r3rbr?r,r,r-r`Ysz6NormalizationTest.run_normalization_tests..NFCcSs td|S)NNFKCrrr,r,r-r\sz7NormalizationTest.run_normalization_tests..NFKCcSs td|S)NNFDrrr,r,r-r_sz6NormalizationTest.run_normalization_tests..NFDcSs td|S)NNFKDrrr,r,r-rbsz7NormalizationTest.run_normalization_tests..NFKD#rz@Partcsg|]}|qSr,)rrrPr,r-rnrz=NormalizationTest.run_normalization_tests..;r6r`rrrz@Part1r) rstrip startswithr|r3Z is_normalizedrrrr)r&rpartZ part1_datar`rrrlinec1c2Zc3Zc4Zc5rXr,rPr-rUsf   *6(:*&  &    z)NormalizationTest.run_normalization_testscCs8|ttj|ttjdd|tddddS)NunknownrKrr )rMrNr3rbrOr$rPr,r,r-test_edge_casessz!NormalizationTest.test_edge_casescCstdddS)Nr`u한글rrPr,r,r-test_bug_834676sz!NormalizationTest.test_bug_834676N) r/r0r1 staticmethodrrrrrrrr,r,r,r-r8s   ;r__main__)__doc__rZ http.clientrrr3ZunittestZ test.supportrrrZTestCaserr2r5rsrr/mainr,r,r,r-s 1Vb