a  zeV#@slddlZddlZddlZddlmZddlmZddlmZm Z ddl m Z m Z eGdddej ZdS)N)dedent)assert_python_ok)skip_if_missingtoolsdir)temp_cwdtemp_dirc@seZdZejeddZddZddZ ddZ d d Z e ejd d d dZddZddZddZddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Z d-S).Test_pygettextZi18nz pygettext.pycCsNi}|dD]:}|r|dr"q|d}|dd\}}|||<q|S)N )#msgidZmsgstr":)split startswithstrip)selfdataZheaderslinekeyvalrM/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_tools/test_i18n.py get_headers zTest_pygettext.get_headercCsg}d}g}|dD]l}|rT|dr:||dn|d|g}d}q|dr|tdd}||dd}q|r|d||S)NFr r zmsgid T)rrappendrjoinlen)rrmsgidsZ reading_msgidZ cur_msgidrrrr get_msgids s$  zTest_pygettext.get_msgidsc Csd}td}t|d}||Wdn1s80Yt|jd|td}|}Wdn1sv0YWdn1s0Y||S)Nztest_docstrings.pywz-D messages.pot)ropenwriterscriptreadr)rZmodule_contentfilenamecwdfprrrrextract_docstrings_from_str8s  ( Dz*Test_pygettext.extract_docstrings_from_strc Cstd}t|jtd}|}Wdn1s:0Y||}|d||d||d||d||d||d||d||d ||d |Wdn1s0YdS) Nr zProject-Id-VersionPOT-Creation-DatezPO-Revision-DatezLast-Translatorz Language-Teamz MIME-Versionz Content-TypezContent-Transfer-Encodingz Generated-By)rrr#r!r$rassertIn)rr&r'rheaderrrr test_headerCs   &         zTest_pygettext.test_headerZaixzbpo-29972: broken test on AIXc Csddlm}td}t|jtd}|}Wdn1sF0Y||}|d}|dr~|dtd }| |dWdn1s0YdS)Nr)datetimer r)z\nz%Y-%m-%d %H:%M%z) r-rrr#r!r$rendswithrstrptime)rr-r&r'rr+Z creationDaterrrtest_POT_Creation_Date]s    &  z%Test_pygettext.test_POT_Creation_Datec CsVdD]L}||.|td|}|d|Wdq1sF0YqdS)Nz """doc"""z r'''doc'''zR'doc'zu"doc"zE def foo(bar): %s docZsubTestr(rr*rr2rrrrtest_funcdocstringps  z!Test_pygettext.test_funcdocstringcCs&|td}|dd|DdS)Nz5 def foo(bar): b"""doc""" cSsg|]}d|vr|qSr2r.0r rrr ~z;Test_pygettext.test_funcdocstring_bytes..r(r assertFalserrrrrtest_funcdocstring_bytesysz'Test_pygettext.test_funcdocstring_bytescCs&|td}|dd|DdS)Nz5 def foo(bar): f"""doc""" cSsg|]}d|vr|qSr6rr7rrrr9r:z=Test_pygettext.test_funcdocstring_fstring..r;r=rrrtest_funcdocstring_fstringsz)Test_pygettext.test_funcdocstring_fstringc CsVdD]L}||.|td|}|d|Wdq1sF0YqdS)Nr1z@ class C: %s r2r3r4rrrtest_classdocstrings  z"Test_pygettext.test_classdocstringcCs&|td}|dd|DdS)Nz0 class C: b"""doc""" cSsg|]}d|vr|qSr6rr7rrrr9r:z.r;r=rrrtest_classdocstring_bytessz(Test_pygettext.test_classdocstring_bytescCs&|td}|dd|DdS)Nz0 class C: f"""doc""" cSsg|]}d|vr|qSr6rr7rrrr9r:z>Test_pygettext.test_classdocstring_fstring..r;r=rrrtest_classdocstring_fstringsz*Test_pygettext.test_classdocstring_fstringcCs|d}|d|dS)Nz_("""doc""" r'str' u"ing")Z docstring)r(r*r=rrr test_msgidszTest_pygettext.test_msgidcCs"|d}|dd|DdS)Nz _(b"""doc""")cSsg|]}d|vr|qSr6rr7rrrr9r:z3Test_pygettext.test_msgid_bytes..r(r<r=rrrtest_msgid_bytess zTest_pygettext.test_msgid_bytescCs"|d}|dd|DdS)Nz _(f"""doc""")cSsg|]}d|vr|qSr6rr7rrrr9r:z5Test_pygettext.test_msgid_fstring..rDr=rrrtest_msgid_fstrings z!Test_pygettext.test_msgid_fstringcCs|td}|d|dS)Nz9 def foo(bar: str): """doc""" r2r(rr*r=rrr!test_funcdocstring_annotated_argssz0Test_pygettext.test_funcdocstring_annotated_argscCs|td}|d|dS)Nz; def foo(bar) -> str: """doc""" r2rGr=rrr#test_funcdocstring_annotated_returnsz2Test_pygettext.test_funcdocstring_annotated_returncCs|td}|d|dS)Nz7 def foo(bar=()): """doc""" r2rGr=rrr test_funcdocstring_defvalue_argssz/Test_pygettext.test_funcdocstring_defvalue_argscCs6|td}|d||d||d|dS)Nz def foo1(bar: tuple=()) -> str: """doc1""" def foo2(bar: List[1:2]) -> (lambda x: x): """doc2""" def foo3(bar: 'func'=lambda x: x) -> {1: 2}: """doc3""" Zdoc1Zdoc2Zdoc3rGr=rrr!test_funcdocstring_multiple_funcss  z0Test_pygettext.test_funcdocstring_multiple_funcscCs|td}|d|dS)Nz\ class D(L[1:2], F({1: 2}), metaclass=M(lambda x: x)): """doc""" r2rGr=rrrtest_classdocstring_early_colonsz.Test_pygettext.test_classdocstring_early_colonc Csd}d}d}tdtd}ttj|dttj|ddd"}|d|dWdn1sv0Yttj|d ttj|d d d"}|d|dWdn1s0Yttj|d ttj|d d d"}|d|dWdn1s00Yt|j |td }| }Wdn1sn0Y| d|d|| d|d|| ||Wdn1s0YWdn1s0YdS)NzText to translate1zText to translate2zText to ignoreZpypkgzpymod.pyrz_()zpkg.pyz pymod2.pyCVSz pymod3.pyr zmsgid "r ) rrosmkdirpathrr!r"rr#r$r*Z assertNotIn)rZtext1Ztext2Ztext3ZsdirZsfiler'rrrrtest_files_lists&002  (zTest_pygettext.test_files_listN)!__name__ __module__ __qualname__rOrQrrr#rrr(r,unittestZskipIfsysplatformrr0r5r>r?r@rArBrCrErFrHrIrJrKrLrRrrrrrs0      r)rOrWrVtextwraprZtest.support.script_helperrZtest.test_toolsrrZ test.supportrrZTestCaserrrrrs