Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/test_tools/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/test_tools/__pycache__/test_i18n.cpython-312.pyc

�

*Μgj0���dZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
ddlmZm
Z
e	�Gd�dej�Zy)	z%Tests to cover the Tools/i18n package�N)�dedent)�assert_python_ok)�skip_if_missing�toolsdir)�temp_cwd�temp_dirc�t�eZdZdZej
j
edd�Zd�Z	d�Z
d�Zd�Ze
jej j#d�d	�d
��Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd �Z(d!�Z)d"�Z*d#�Z+d$�Z,d%�Z-d&�Z.d'�Z/y())�Test_pygettextzTests for the pygettext.py tool�i18nzpygettext.pyc���i}|jd�D]O}|r|jd�r�|jd�}|jdd�\}}|j�||<�Q|S)z: utility: return the header of a .po file as a dictionary �
)�#�msgid�msgstr�"�:�)�split�
startswith�strip)�self�data�headers�line�key�vals      �6/usr/local/lib/python3.12/test/test_tools/test_i18n.py�
get_headerzTest_pygettext.get_headersc�����J�J�t�$�D��4�?�?�+B�C���:�:�c�?�D��z�z�#�a�(�H�C���9�9�;�G�C�L�%���c��g}d}g}|jd�D]�}|rW|jd�r!|j|jd��n%|jdj	|��g}d}�\|jd�s�n|td�d}|j|jd��d}��|r |jdj	|��|S)z= utility: return all msgids in .po file as a list of strings Fr
rzmsgid NT)rr�appendr�join�len)rr�msgids�
reading_msgid�	cur_msgidrs      r�
get_msgidszTest_pygettext.get_msgids s������
��	��J�J�t�$�D���?�?�3�'��$�$�T�Z�Z��_�5��M�M�$�)�)�I�"6�7� "�I�$)�M�����x�(��C��M�N�+��� � ����C��1� $�
�%���
�
�d�i�i�	�2�3��
rc�b�d}td�5}t|dd��5}|j|�ddd�t|jd|�tdd��5}|j�}ddd�ddd�|j
�S#1swY�_xYw#1swY�.xYw#1swY�2xYw)z: utility: return all msgids extracted from module_content ztest_docstrings.pyN�w�utf-8��encodingz-D�messages.pot)r�open�writer�script�readr')r�module_content�filename�cwd�fprs      r�extract_docstrings_from_strz*Test_pygettext.extract_docstrings_from_str8s���'��
�d�^�s��h��g�6�"�����(�7��T�[�[�$��9��n�w�7�2��w�w�y��8�	����t�$�$�7�6��8�7��	�^�s9�B%�B
�,B%�B�,B%�
B	�B%�B"	�B%�%B.c�8�td�5}t|j�tdd��5}|j	�}ddd�|j�}|j
d|�|j
d|�|j
d|�|j
d|�|j
d	|�|j
d
|�|j
d|�|j
d|�|j
d
|�ddd�y#1swY��xYw#1swYyxYw)z�Make sure the required fields are in the header, according to:
           http://www.gnu.org/software/gettext/manual/gettext.html#Header-Entry
        Nr-r*r+zProject-Id-Version�POT-Creation-DatezPO-Revision-DatezLast-Translatorz
Language-TeamzMIME-VersionzContent-TypezContent-Transfer-EncodingzGenerated-By)rrr0r.r1r�assertIn)rr4r5r�headers     r�test_headerzTest_pygettext.test_headerCs����d�^�s��T�[�[�)��n�w�7�2��w�w�y��8��_�_�T�*�F��M�M�.��7��M�M�-�v�6��M�M�,�f�5��M�M�+�V�4��M�M�/�6�2��M�M�.�&�1��M�M�.�&�1��M�M�5�v�>��M�M�.�&�1��^�7�7���^�s#�#D�D�B;D�D
	�	D�D�aixzbpo-29972: broken test on AIXc�n�ddlm}td�5}t|j�t	dd��5}|j�}ddd�|j
�}|d}|jd�r|dtd�}|j|d	�ddd�y#1swY�ZxYw#1swYyxYw)
z; Match the date format from xgettext for POT-Creation-Date r)�datetimeNr-r*r+r8z\nz%Y-%m-%d %H:%M%z)
r>rrr0r.r1r�endswithr#�strptime)rr>r4r5rr:�creationDates       r�test_POT_Creation_Datez%Test_pygettext.test_POT_Creation_Date]s���	&�
�d�^�s��T�[�[�)��n�w�7�2��w�w�y��8��_�_�T�*�F�!�"5�6�L��$�$�U�+�+�L�c�%�j�[�9��
���l�,>�?��^�7�7���^�s#�#B+�B�AB+�B(	�$B+�+B4c��dD]K}|j|�5|jtd|z��}|jd|�ddd��My#1swY�XxYw)N�z	"""doc"""z
r'''doc'''zR'doc'zu"doc"zE                def foo(bar):
                    %s
                �doc��subTestr6rr9�rrEr$s   r�test_funcdocstringz!Test_pygettext.test_funcdocstringp�`��B�C����c�"��9�9�&�B��B�;����
�
�e�V�,�#�"�C�"�"���0A�A	c��|jtd��}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz5        def foo(bar):
            b"""doc"""
        rE�r6r�assertFalse�rr$rs   r�test_funcdocstring_bytesz'Test_pygettext.test_funcdocstring_bytesy�F���1�1�&�:�3
���	
���V�F�V�E�u��~�%�V�F�G��F�
�	A�Ac��|jtd��}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz5        def foo(bar):
            f"""doc"""
        rErMrOs   r�test_funcdocstring_fstringz)Test_pygettext.test_funcdocstring_fstring�rQrRc��dD]K}|j|�5|jtd|z��}|jd|�ddd��My#1swY�XxYw)NrDz@                class C:
                    %s
                rErFrHs   r�test_classdocstringz"Test_pygettext.test_classdocstring�rJrKc��|jtd��}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz0        class C:
            b"""doc"""
        rErMrOs   r�test_classdocstring_bytesz(Test_pygettext.test_classdocstring_bytes�rQrRc��|jtd��}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz0        class C:
            f"""doc"""
        rErMrOs   r�test_classdocstring_fstringz*Test_pygettext.test_classdocstring_fstring�rQrRc��dD]K}|j|�5|jtd|z��}|jd|�ddd��My#1swY�XxYw)NrDz#                %s
                rErFrHs   r�test_moduledocstringz#Test_pygettext.test_moduledocstring�s^��B�C����c�"��9�9�&�B��B�;����
�
�e�V�,�	#�"�C�"�"�rKc��|jtd��}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz        b"""doc"""
        rErMrOs   r�test_moduledocstring_bytesz)Test_pygettext.test_moduledocstring_bytes��F���1�1�&�:�3
���	
���V�F�V�E�u��~�%�V�F�G��FrRc��|jtd��}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz        f"""doc"""
        rErMrOs   r�test_moduledocstring_fstringz+Test_pygettext.test_moduledocstring_fstring�r_rRc�J�|jd�}|jd|�y)Nz_("""doc""" r'str' u"ing")�	docstring)r6r9�rr$s  r�
test_msgidzTest_pygettext.test_msgid�s#���1�1�0�2���
�
�k�6�*rc�x�|jd�}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz
_(b"""doc""")rE�r6rNrOs   r�test_msgid_byteszTest_pygettext.test_msgid_bytes��8���1�1�/�B�����V�F�V�E�u��~�%�V�F�G��F��	7�7c�x�|jd�}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz
_(f"""doc""")rErgrOs   r�test_msgid_fstringz!Test_pygettext.test_msgid_fstring�rirjc�\�|jtd��}|jd|�y)z3 Test docstrings for functions with annotated args z9        def foo(bar: str):
            """doc"""
        rEN�r6rr9rds  r�!test_funcdocstring_annotated_argsz0Test_pygettext.test_funcdocstring_annotated_args��.���1�1�&�:�3
���	
�
�
�e�V�$rc�\�|jtd��}|jd|�y)z: Test docstrings for functions with annotated return type z;        def foo(bar) -> str:
            """doc"""
        rENrnrds  r�#test_funcdocstring_annotated_returnz2Test_pygettext.test_funcdocstring_annotated_return�rprc�\�|jtd��}|jd|�y)z6 Test docstring for functions with default arg values z7        def foo(bar=()):
            """doc"""
        rENrnrds  r� test_funcdocstring_defvalue_argsz/Test_pygettext.test_funcdocstring_defvalue_args�rprc��|jtd��}|jd|�|jd|�|jd|�y)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"""
        �doc1�doc2�doc3Nrnrds  r�!test_funcdocstring_multiple_funcsz0Test_pygettext.test_funcdocstring_multiple_funcs�sL���1�1�&�	:�	3
�	��	
�
�
�f�f�%��
�
�f�f�%��
�
�f�f�%rc�\�|jtd��}|jd|�y)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"""
        rENrnrds  r�test_classdocstring_early_colonz.Test_pygettext.test_classdocstring_early_colon�s0���1�1�&�:�3
���	
�
�
�e�V�$rc�\�|jtd��}|jd|�y)Nz"        f"{_('foo bar')}"
        �foo barrnrds  r�test_calls_in_fstringsz%Test_pygettext.test_calls_in_fstrings��.���1�1�&�:�3
���	
�
�
�i��(rc�\�|jtd��}|jd|�y)Nz#        rf"{_('foo bar')}"
        r}rnrds  r�test_calls_in_fstrings_rawz)Test_pygettext.test_calls_in_fstrings_raw�rrc�\�|jtd��}|jd|�y)Nz+        f"""{f'{_("foo bar")}'}"""
        r}rnrds  r�test_calls_in_fstrings_nestedz,Test_pygettext.test_calls_in_fstrings_nested�rrc�\�|jtd��}|jd|�y)Nz&        f"{obj._('foo bar')}"
        r}rnrds  r� test_calls_in_fstrings_attributez/Test_pygettext.test_calls_in_fstrings_attributerrc�\�|jtd��}|jd|�y)Nz*        f"{type(str)('foo bar')}"
        r}�r6r�assertNotInrds  r�(test_calls_in_fstrings_with_call_on_callz7Test_pygettext.test_calls_in_fstrings_with_call_on_calls0���1�1�&�:�3
���	
����F�+rc�\�|jtd��}|jd|�y)Nz6        f"{_('foo {bar}').format(bar='baz')}"
        �	foo {bar}rnrds  r�"test_calls_in_fstrings_with_formatz1Test_pygettext.test_calls_in_fstrings_with_formats.���1�1�&�:�3
���	
�
�
�k�6�*rc��|jtd��}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz%        f"{_(f'foo {bar}')}"
        r�rMrOs   r�)test_calls_in_fstrings_with_wrong_input_1z8Test_pygettext.test_calls_in_fstrings_with_wrong_input_1sG���1�1�&�:�3
���	
���V�L�V�E�{�e�7K�%�V�L�M��LrRc�\�|jtd��}|jd|�y)Nz        f"{_(1)}"
        rr�rds  r�)test_calls_in_fstrings_with_wrong_input_2z8Test_pygettext.test_calls_in_fstrings_with_wrong_input_2s0���1�1�&�:�3
���	
����F�#rc��|jtd��}|jd|�|jd|�y)Nz%        f"{_('foo', 'bar')}"
        �foo�barr�rds  r�(test_calls_in_fstring_with_multiple_argsz7Test_pygettext.test_calls_in_fstring_with_multiple_args#s@���1�1�&�:�3
���	
�����'������'rc��|jtd��}|jd|�|jd|�|jd|�y)Nz)        f"{_('foo', bar='baz')}"
        r�r��bazr�rds  r�'test_calls_in_fstring_with_keyword_argsz6Test_pygettext.test_calls_in_fstring_with_keyword_args*sP���1�1�&�:�3
���	
�����'������'������'rc��|jtd��}|jd|�|jd|�y)Nz*        f"{_(f'foo') + _('bar')}"
        r�r�)r6rr�r9rds  r�5test_calls_in_fstring_with_partially_wrong_expressionzDTest_pygettext.test_calls_in_fstring_with_partially_wrong_expression2s>���1�1�&�:�3
���	
�����'��
�
�e�V�$rc	���d}d}d}td�5td�5}tjtjj|d��t
tjj|dd�dd�	�5}|jd
|�d��ddd�tjtjj|d��t
tjj|dd
�dd�	�5}|jd
|�d��ddd�tjtjj|d��t
tjj|dd�dd�	�5}|jd
|�d��ddd�t|j|�t
dd�	�5}|j�}ddd�|jd|�d��|jd|�d�|�|j||�ddd�ddd�y#1swY���xYw#1swY�� xYw#1swY��xYw#1swY�~xYw#1swY�DxYw#1swYyxYw)zVMake sure the directories are inspected for source files
           bpo-31920
        zText to translate1zText to translate2zText to ignoreN�pypkgzpymod.pyr)r*r+z_(�)zpkg.pyz	pymod2.py�CVSz	pymod3.pyr-zmsgid "r)
rr�os�mkdir�pathr"r.r/rr0r1r9r�)r�text1�text2�text3�sdir�sfiler5rs        r�test_files_listzTest_pygettext.test_files_list9s���%��$�� ��
�d�^�X�d�^�t��H�H�R�W�W�\�\�$��0�1��b�g�g�l�l�4��*�=�s�&�(�+0����b��	��O�,�(�
�H�H�R�W�W�\�\�$��1�2��b�g�g�l�l�4��;�?��&�(�+0����b��	��O�,�(�
�H�H�R�W�W�\�\�$��.�/��b�g�g�l�l�4���<�c�&�(�+0����b��	��O�,�(�
�T�[�[�$�/��n�w�7�2��w�w�y��8��M�M�G�E�7�!�,�d�3��M�M�G�E�7�!�,�d�3����U�D�)�%,�^�^�(�(��(�(��(�(��8�7��,�^��^�^�s��I"�A!I�?H$�A(I�=H1�A(I�;H>�+I�<I
�
AI�I"�$H.�)I�1H;�6I�>I�I�
I�I�I	�I"�"I+N)0�__name__�
__module__�__qualname__�__doc__r�r�r"rr0rr'r6r;�unittest�skipIf�sys�platformrrBrIrPrTrVrXrZr\r^rarerhrlrorrrtryr{r~r�r�r�r�r�r�r�r�r�r�r��rrr
r
s���)�
�W�W�\�\�(�6�>�
:�F�	��0	%�2�4�X�_�_�S�\�\�,�,�U�3�4�6�@�6�@�"-�H�H�-�H�H�-�H�H�+�
H�H�%�%�%�&�$%�)�)�)�)�,�+�N�$�(�(�%�*rr
)r�r�r�r��textwrapr�test.support.script_helperr�test.test_toolsrr�test.support.os_helperrr�TestCaser
r�rr�<module>r�s9��+�	�
���7�5�5���B*�X�&�&�B*r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists