HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/test_tools/__pycache__/test_i18n.cpython-310.opt-1.pyc
o

�i�/�@spdZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
ddlmZm
Z
e	�Gdd�dej�ZdS)	z%Tests to cover the Tools/i18n package�N)�dedent)�assert_python_ok)�skip_if_missing�toolsdir)�temp_cwd�temp_dirc@sDeZdZdZej�edd�Zdd�Z	dd�Z
dd	�Zd
d�Ze
�ej�d�d
�dd��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Z d,d-�Z!d.d/�Z"d0d1�Z#d2d3�Z$d4d5�Z%d6d7�Z&d8d9�Z'd:d;�Z(d<d=�Z)d>d?�Z*d@dA�Z+dBdC�Z,dDdE�Z-dFdG�Z.dHdI�Z/dJS)K�Test_pygettextzTests for the pygettext.py toolZi18nzpygettext.pycCsNi}|�d�D]}|r|�d�rq|�d�}|�dd�\}}|��||<q|S)z: utility: return the header of a .po file as a dictionary �
)�#�msgidZmsgstr�"�:�)�split�
startswith�strip)�self�dataZheaders�line�key�val�r�6/usr/local/lib/python3.10/test/test_tools/test_i18n.py�
get_headers
zTest_pygettext.get_headercCs�g}d}g}|�d�D]6}|r*|�d�r|�|�d��n
|�d�|��g}d}q|�d�rA|td�d�}|�|�d��d}q|rL|�d�|��|S)z= utility: return all msgids in .po file as a list of strings Fr	rzmsgid NT)rr�appendr�join�len)rr�msgidsZ
reading_msgidZ	cur_msgidrrrr�
get_msgids s&

�zTest_pygettext.get_msgidsc	Cs�d}td��A}t|d��
}|�|�Wd�n1swYt|jd|�td��}|��}Wd�n1s;wYWd�n1sJwY|�|�S)z: utility: return all msgids extracted from module_content ztest_docstrings.pyN�wz-D�messages.pot)r�open�writer�script�readr)rZmodule_content�filename�cwd�fprrrr�extract_docstrings_from_str8s
�

���
z*Test_pygettext.extract_docstrings_from_strc	Cs�td��a}t|j�td��}|��}Wd�n1swY|�|�}|�d|�|�d|�|�d|�|�d|�|�d|�|�d|�|�d	|�|�d
|�|�d|�Wd�dS1shwYdS)z�Make sure the required fields are in the header, according to:
           http://www.gnu.org/software/gettext/manual/gettext.html#Header-Entry
        Nr zProject-Id-Version�POT-Creation-DatezPO-Revision-DatezLast-Translatorz
Language-TeamzMIME-VersionzContent-TypezContent-Transfer-EncodingzGenerated-By)rrr#r!r$r�assertIn)rr&r'r�headerrrr�test_headerCs 



�
"�zTest_pygettext.test_headerZaixzbpo-29972: broken test on AIXc	Cs�ddlm}td��C}t|j�td��}|��}Wd�n1s#wY|�|�}|d}|�d�r?|dtd��}|�	|d�Wd�dS1sPwYdS)z; Match the date format from xgettext for POT-Creation-Date r)�datetimeNr r)z\nz%Y-%m-%d %H:%M%z)
r-rrr#r!r$r�endswithr�strptime)rr-r&r'rr+ZcreationDaterrr�test_POT_Creation_Date]s



�

"�z%Test_pygettext.test_POT_Creation_Datec	C�VdD]&}|�|��|�td|��}|�d|�Wd�n1s#wYqdS)N�z	"""doc"""z
r'''doc'''zR'doc'zu"doc"zE                def foo(bar):
                    %s
                �doc�ZsubTestr(rr*�rr3rrrr�test_funcdocstringp�����z!Test_pygettext.test_funcdocstringcC�&|�td��}|�dd�|D��dS)Nz5        def foo(bar):
            b"""doc"""
        cS�g|]}d|vr|�qS�r3r��.0rrrr�
<listcomp>~�z;Test_pygettext.test_funcdocstring_bytes.<locals>.<listcomp>�r(r�assertFalse�rrrrr�test_funcdocstring_bytesy�z'Test_pygettext.test_funcdocstring_bytescCr8)Nz5        def foo(bar):
            f"""doc"""
        cSr9r:rr;rrrr=�r>z=Test_pygettext.test_funcdocstring_fstring.<locals>.<listcomp>r?rArrr�test_funcdocstring_fstring�rCz)Test_pygettext.test_funcdocstring_fstringc	Cr1)Nr2z@                class C:
                    %s
                r3r4r5rrr�test_classdocstring�r7z"Test_pygettext.test_classdocstringcCr8)Nz0        class C:
            b"""doc"""
        cSr9r:rr;rrrr=�r>z<Test_pygettext.test_classdocstring_bytes.<locals>.<listcomp>r?rArrr�test_classdocstring_bytes�rCz(Test_pygettext.test_classdocstring_bytescCr8)Nz0        class C:
            f"""doc"""
        cSr9r:rr;rrrr=�r>z>Test_pygettext.test_classdocstring_fstring.<locals>.<listcomp>r?rArrr�test_classdocstring_fstring�rCz*Test_pygettext.test_classdocstring_fstringc	Cr1)Nr2z#                %s
                r3r4r5rrr�test_moduledocstring�s����z#Test_pygettext.test_moduledocstringcCr8)Nz        b"""doc"""
        cSr9r:rr;rrrr=�r>z=Test_pygettext.test_moduledocstring_bytes.<locals>.<listcomp>r?rArrr�test_moduledocstring_bytes��z)Test_pygettext.test_moduledocstring_bytescCr8)Nz        f"""doc"""
        cSr9r:rr;rrrr=�r>z?Test_pygettext.test_moduledocstring_fstring.<locals>.<listcomp>r?rArrr�test_moduledocstring_fstring�rJz+Test_pygettext.test_moduledocstring_fstringcCs|�d�}|�d|�dS)Nz_("""doc""" r'str' u"ing")Z	docstring)r(r*rArrr�
test_msgid�s�zTest_pygettext.test_msgidcC�"|�d�}|�dd�|D��dS)Nz
_(b"""doc""")cSr9r:rr;rrrr=�r>z3Test_pygettext.test_msgid_bytes.<locals>.<listcomp>�r(r@rArrr�test_msgid_bytes��
zTest_pygettext.test_msgid_bytescCrM)Nz
_(f"""doc""")cSr9r:rr;rrrr=�r>z5Test_pygettext.test_msgid_fstring.<locals>.<listcomp>rNrArrr�test_msgid_fstring�rPz!Test_pygettext.test_msgid_fstringcC�|�td��}|�d|�dS)z3 Test docstrings for functions with annotated args z9        def foo(bar: str):
            """doc"""
        r3N�r(rr*rArrr�!test_funcdocstring_annotated_args��z0Test_pygettext.test_funcdocstring_annotated_argscCrR)z: Test docstrings for functions with annotated return type z;        def foo(bar) -> str:
            """doc"""
        r3NrSrArrr�#test_funcdocstring_annotated_return�rUz2Test_pygettext.test_funcdocstring_annotated_returncCrR)z6 Test docstring for functions with default arg values z7        def foo(bar=()):
            """doc"""
        r3NrSrArrr� test_funcdocstring_defvalue_args�rUz/Test_pygettext.test_funcdocstring_defvalue_argscCs6|�td��}|�d|�|�d|�|�d|�dS)z� Test docstring extraction for multiple functions combining
        annotated args, annotated return types and default arg values
        z�        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"""
        Zdoc1Zdoc2Zdoc3NrSrArrr�!test_funcdocstring_multiple_funcs�s
z0Test_pygettext.test_funcdocstring_multiple_funcscCrR)ze Test docstring extraction for a class with colons occurring within
        the parentheses.
        z\        class D(L[1:2], F({1: 2}), metaclass=M(lambda x: x)):
            """doc"""
        r3NrSrArrr�test_classdocstring_early_colon�sz.Test_pygettext.test_classdocstring_early_coloncC�|�td��}|�d|�dS)Nz"        f"{_('foo bar')}"
        �foo barrSrArrr�test_calls_in_fstrings��z%Test_pygettext.test_calls_in_fstringscCrZ)Nz#        rf"{_('foo bar')}"
        r[rSrArrr�test_calls_in_fstrings_raw�r]z)Test_pygettext.test_calls_in_fstrings_rawcCrZ)Nz+        f"""{f'{_("foo bar")}'}"""
        r[rSrArrr�test_calls_in_fstrings_nested�r]z,Test_pygettext.test_calls_in_fstrings_nestedcCrZ)Nz&        f"{obj._('foo bar')}"
        r[rSrArrr� test_calls_in_fstrings_attributer]z/Test_pygettext.test_calls_in_fstrings_attributecCrZ)Nz*        f"{type(str)('foo bar')}"
        r[�r(r�assertNotInrArrr�(test_calls_in_fstrings_with_call_on_callr]z7Test_pygettext.test_calls_in_fstrings_with_call_on_callcCrZ)Nz6        f"{_('foo {bar}').format(bar='baz')}"
        �	foo {bar}rSrArrr�"test_calls_in_fstrings_with_formatr]z1Test_pygettext.test_calls_in_fstrings_with_formatcCr8)Nz%        f"{_(f'foo {bar}')}"
        cSr9)rdrr;rrrr=r>zLTest_pygettext.test_calls_in_fstrings_with_wrong_input_1.<locals>.<listcomp>r?rArrr�)test_calls_in_fstrings_with_wrong_input_1rJz8Test_pygettext.test_calls_in_fstrings_with_wrong_input_1cCrZ)Nz        f"{_(1)}"
        rrarArrr�)test_calls_in_fstrings_with_wrong_input_2r]z8Test_pygettext.test_calls_in_fstrings_with_wrong_input_2cCs*|�td��}|�d|�|�d|�dS)Nz%        f"{_('foo', 'bar')}"
        �foo�barrarArrr�(test_calls_in_fstring_with_multiple_args#�z7Test_pygettext.test_calls_in_fstring_with_multiple_argscCs6|�td��}|�d|�|�d|�|�d|�dS)Nz)        f"{_('foo', bar='baz')}"
        rhriZbazrarArrr�'test_calls_in_fstring_with_keyword_args*sz6Test_pygettext.test_calls_in_fstring_with_keyword_argscCs*|�td��}|�d|�|�d|�dS)Nz*        f"{_(f'foo') + _('bar')}"
        rhri)r(rrbr*rArrr�5test_calls_in_fstring_with_partially_wrong_expression2rkzDTest_pygettext.test_calls_in_fstring_with_partially_wrong_expressionc
Cs�d}d}d}td���td���}t�tj�|d��ttj�|dd�d��}|�d|�d	��Wd�n1s9wYt�tj�|d
��ttj�|d
d�d��}|�d|�d	��Wd�n1sgwYt�tj�|d��ttj�|dd
�d��}|�d|�d	��Wd�n1s�wYt|j	|�td��}|�
�}Wd�n1s�wY|�d|�d�|�|�d|�d�|�|�||�Wd�n1s�wYWd�dSWd�dS1s�wYdS)zVMake sure the directories are inspected for source files
           bpo-31920
        zText to translate1zText to translate2zText to ignoreNZpypkgzpymod.pyrz_(�)zpkg.pyz	pymod2.py�CVSz	pymod3.pyr zmsgid "r)
rr�os�mkdir�pathrr!r"rr#r$r*rb)rZtext1Ztext2Ztext3ZsdirZsfiler'rrrr�test_files_list9s0���

�P�zTest_pygettext.test_files_listN)0�__name__�
__module__�__qualname__�__doc__rprrrrr#rrr(r,�unittestZskipIf�sys�platformrr0r6rBrDrErFrGrHrIrKrLrOrQrTrVrWrXrYr\r^r_r`rcrerfrgrjrlrmrsrrrrrsP�
		
r)rwrpryrx�textwraprZtest.support.script_helperrZtest.test_toolsrrZtest.support.os_helperrrZTestCaserrrrr�<module>s