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.7/test/test_tools/__pycache__/test_i18n.cpython-37.opt-1.pyc
B

"��gV#�@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@s�eZdZdZej�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.S)/�Test_pygettextzTests for the pygettext.py toolZi18nzpygettext.pycCsRi}xH|�d�D]:}|r|�d�r$q|�d�}|�dd�\}}|��||<qW|S)z: utility: return the header of a .po file as a dictionary �
)�#�msgidZmsgstr�"�:�)�split�
startswith�strip)�self�dataZheaders�line�key�val�r�5/usr/local/lib/python3.7/test/test_tools/test_i18n.py�
get_headers
zTest_pygettext.get_headercCs�g}d}g}x�|�d�D]l}|rV|�d�r<|�|�d��n|�d�|��g}d}q|�d�r|td�d�}|�|�d��d}qW|r�|�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
Csld}td��P}t|d��}|�|�WdQRXt|jd|�td��}|��}WdQRXWdQRX|�|�S)z: utility: return all msgids extracted from module_content ztest_docstrings.pyN�wz-Dz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���}t|j�td��}|��}WdQRX|�|�}|�d|�|�d|�|�d|�|�d|�|�d|�|�d|�|�d	|�|�d
|�|�d|�WdQRXdS)z�Make sure the required fields are in the header, according to:
           http://www.gnu.org/software/gettext/manual/gettext.html#Header-Entry
        Nzmessages.potzProject-Id-VersionzPOT-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��f}t|j�td��}|��}WdQRX|�|�}|d}|�d�rj|dtd��}|�	|d�WdQRXdS)z; Match the date format from xgettext for POT-Creation-Date r)�datetimeNzmessages.potzPOT-Creation-Datez\nz%Y-%m-%d %H:%M%z)
r+rrr"r r#r�endswithrZstrptime)rr+r%r&rr)ZcreationDaterrr�test_POT_Creation_Date]s




z%Test_pygettext.test_POT_Creation_Datec
CsFx@dD]8}|�|��$|�td|��}|�d|�WdQRXqWdS)N)z	"""doc"""z
r'''doc'''zR'doc'zu"doc"zE                def foo(bar):
                    %s
                �doc)�subTestr'rr()rr.rrrr�test_funcdocstringps

z!Test_pygettext.test_funcdocstringcCs&|�td��}|�dd�|D��dS)Nz5        def foo(bar):
            b"""doc"""
        cSsg|]}d|kr|�qS)r.r)�.0rrrr�
<listcomp>~sz;Test_pygettext.test_funcdocstring_bytes.<locals>.<listcomp>)r'r�assertFalse)rrrrr�test_funcdocstring_bytesysz'Test_pygettext.test_funcdocstring_bytescCs&|�td��}|�dd�|D��dS)Nz5        def foo(bar):
            f"""doc"""
        cSsg|]}d|kr|�qS)r.r)r1rrrrr2�sz=Test_pygettext.test_funcdocstring_fstring.<locals>.<listcomp>)r'rr3)rrrrr�test_funcdocstring_fstring�sz)Test_pygettext.test_funcdocstring_fstringc
CsFx@dD]8}|�|��$|�td|��}|�d|�WdQRXqWdS)N)z	"""doc"""z
r'''doc'''zR'doc'zu"doc"z@                class C:
                    %s
                r.)r/r'rr()rr.rrrr�test_classdocstring�s

z"Test_pygettext.test_classdocstringcCs&|�td��}|�dd�|D��dS)Nz0        class C:
            b"""doc"""
        cSsg|]}d|kr|�qS)r.r)r1rrrrr2�sz<Test_pygettext.test_classdocstring_bytes.<locals>.<listcomp>)r'rr3)rrrrr�test_classdocstring_bytes�sz(Test_pygettext.test_classdocstring_bytescCs&|�td��}|�dd�|D��dS)Nz0        class C:
            f"""doc"""
        cSsg|]}d|kr|�qS)r.r)r1rrrrr2�sz>Test_pygettext.test_classdocstring_fstring.<locals>.<listcomp>)r'rr3)rrrrr�test_classdocstring_fstring�sz*Test_pygettext.test_classdocstring_fstringcCs|�d�}|�d|�dS)Nz_("""doc""" r'str' u"ing")Z	docstring)r'r()rrrrr�
test_msgid�szTest_pygettext.test_msgidcCs"|�d�}|�dd�|D��dS)Nz
_(b"""doc""")cSsg|]}d|kr|�qS)r.r)r1rrrrr2�sz3Test_pygettext.test_msgid_bytes.<locals>.<listcomp>)r'r3)rrrrr�test_msgid_bytes�s
zTest_pygettext.test_msgid_bytescCs"|�d�}|�dd�|D��dS)Nz
_(f"""doc""")cSsg|]}d|kr|�qS)r.r)r1rrrrr2�sz5Test_pygettext.test_msgid_fstring.<locals>.<listcomp>)r'r3)rrrrr�test_msgid_fstring�s
z!Test_pygettext.test_msgid_fstringcCs|�td��}|�d|�dS)z3 Test docstrings for functions with annotated args z9        def foo(bar: str):
            """doc"""
        r.N)r'rr()rrrrr�!test_funcdocstring_annotated_args�sz0Test_pygettext.test_funcdocstring_annotated_argscCs|�td��}|�d|�dS)z: Test docstrings for functions with annotated return type z;        def foo(bar) -> str:
            """doc"""
        r.N)r'rr()rrrrr�#test_funcdocstring_annotated_return�sz2Test_pygettext.test_funcdocstring_annotated_returncCs|�td��}|�d|�dS)z6 Test docstring for functions with default arg values z7        def foo(bar=()):
            """doc"""
        r.N)r'rr()rrrrr� test_funcdocstring_defvalue_args�sz/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"""
        Zdoc1Zdoc2Zdoc3N)r'rr()rrrrr�!test_funcdocstring_multiple_funcs�s
	z0Test_pygettext.test_funcdocstring_multiple_funcscCs|�td��}|�d|�dS)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"""
        r.N)r'rr()rrrrr�test_classdocstring_early_colon�sz.Test_pygettext.test_classdocstring_early_coloncCspd}d}d}td���Ptd���:}t�tj�|d��ttj�|dd�d��}|�d|�d	��WdQRXt�tj�|d
��ttj�|d
d�d��}|�d|�d	��WdQRXt�tj�|d��ttj�|dd
�d��}|�d|�d	��WdQRXt|j	|�td��}|�
�}WdQRX|�d|�d�|�|�d|�d�|�|�||�WdQRXWdQRXdS)zVMake sure the directories are inspected for source files
           bpo-31920
        zText to translate1zText to translate2zText to ignoreNZpypkgzpymod.pyrz_(�)zpkg.pyz	pymod2.pyZCVSz	pymod3.pyzmessages.potzmsgid "r)
rr�os�mkdir�pathrr r!rr"r#r(ZassertNotIn)rZtext1Ztext2Ztext3ZsdirZsfiler&rrrr�test_files_list�s&
zTest_pygettext.test_files_listN)"�__name__�
__module__�__qualname__�__doc__rBrDrrr"rrr'r*�unittestZskipIf�sys�platformrr-r0r4r5r6r7r8r9r:r;r<r=r>r?r@rErrrrrs.		
r)rIrBrKrJ�textwraprZtest.support.script_helperrZtest.test_toolsrrZtest.supportrrZTestCaserrrrr�<module>s