HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/Python311/Lib/test/test_tools/__pycache__/test_i18n.cpython-311.opt-1.pyc
�

��Vc�.���dZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
ddlmZm
Z
e	��Gd�dej��ZdS)	z%Tests to cover the Tools/i18n package�N)�dedent)�assert_python_ok)�skip_if_missing�toolsdir)�temp_cwd�temp_dirc�b�eZdZdZej�edd��Zd�Z	d�Z
d�Zd�Ze
jej�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%S)&�Test_pygettextzTests for the pygettext.py tool�i18nzpygettext.pyc���i}|�d��D]_}|r|�d��r�|�d��}|�dd��\}}|���||<�`|S)z: utility: return the header of a .po file as a dictionary �
)�#�msgid�msgstr�"�:�)�split�
startswith�strip)�self�data�headers�line�key�vals      �-D:\Python311\Lib\test\test_tools\test_i18n.py�
get_headerzTest_pygettext.get_headers�����J�J�t�$�$�	'�	'�D��
�4�?�?�+B�C�C�
���:�:�c�?�?�D��z�z�#�a�(�(�H�C���9�9�;�;�G�C�L�L���c��g}d}g}|�d��D]�}|rk|�d��r)|�|�d����n-|�d�|����g}d}�o|�d��rA|td��d�}|�|�d����d}��|r(|�d�|����|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�$�$�	4�	4�D��
��?�?�3�'�'���$�$�T�Z�Z��_�_�5�5�5�5��M�M�$�)�)�I�"6�"6�7�7�7� "�I�$)�M�����x�(�(�
%��C��M�M�N�N�+��� � ����C���1�1�1� $�
���
4��
�
�d�i�i�	�2�2�3�3�3��
rc��d}td��5}t|dd���5}|�|��ddd��n#1swxYwYt|jd|��tdd���5}|���}ddd��n#1swxYwYddd��n#1swxYwY|�|��S)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_str8sx��'��
�d�^�^�	!�s��h��g�6�6�6�
)�"�����(�(�(�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)�
)����
)�
)�
)�
)��T�[�$��9�9�9��n�w�7�7�7�
!�2��w�w�y�y��
!�
!�
!�
!�
!�
!�
!�
!�
!�
!�
!����
!�
!�
!�
!�		!�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!����	!�	!�	!�	!����t�$�$�$sW�B1�A�B1�A	�B1�A	�*B1�9B�B1�B	�B1�!B	�"B1�1B5�8B5c��td��5}t|j��tdd���5}|���}ddd��n#1swxYwY|�|��}|�d|��|�d|��|�d|��|�d|��|�d	|��|�d
|��|�d|��|�d|��|�d
|��ddd��dS#1swxYwYdS)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�^�^�	2�s��T�[�)�)�)��n�w�7�7�7�
!�2��w�w�y�y��
!�
!�
!�
!�
!�
!�
!�
!�
!�
!�
!����
!�
!�
!�
!��_�_�T�*�*�F��M�M�.��7�7�7��M�M�-�v�6�6�6��M�M�,�f�5�5�5��M�M�+�V�4�4�4��M�M�/�6�2�2�2��M�M�.�&�1�1�1��M�M�.�&�1�1�1��M�M�5�v�>�>�>��M�M�.�&�1�1�1�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2�	2�	2s5�&E
�A�E
�A	�E
�A	�CE
�
E�E�aixzbpo-29972: broken test on AIXc���ddlm}td��5}t|j��t	dd���5}|���}ddd��n#1swxYwY|�|��}|d}|�d��r|dtd���}|�	|d	��ddd��dS#1swxYwYdS)
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�7�7�
!�2��w�w�y�y��
!�
!�
!�
!�
!�
!�
!�
!�
!�
!�
!����
!�
!�
!�
!��_�_�T�*�*�F�!�"5�6�L��$�$�U�+�+�
:�+�L�c�%�j�j�[�L�9��
���l�,>�?�?�?�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@�	@����	@�	@�	@�	@�	@�	@s5�&C�A�C�A!	�!C�$A!	�%A#C�C�Cc���dD]j}|�|��5|�td|z����}|�d|��ddd��n#1swxYwY�kdS)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�,�,�,�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-��	-�	-��<A"�"A&	�)A&	c��|�td����}|�d�|D����dS)Nz5        def foo(bar):
            b"""doc"""
        c��g|]}d|v�|��	S�rE���.0rs  r�
<listcomp>z;Test_pygettext.test_funcdocstring_bytes.<locals>.<listcomp>~�!��F�F�F�E�u��~�F�%�F�F�Fr�r6r�assertFalse�rr$s  r�test_funcdocstring_bytesz'Test_pygettext.test_funcdocstring_bytesy�S���1�1�&�:�3
�3
����	
���F�F�V�F�F�F�G�G�G�G�Grc��|�td����}|�d�|D����dS)Nz5        def foo(bar):
            f"""doc"""
        c��g|]}d|v�|��	SrNrOrPs  rrRz=Test_pygettext.test_funcdocstring_fstring.<locals>.<listcomp>�rSrrTrVs  r�test_funcdocstring_fstringz)Test_pygettext.test_funcdocstring_fstring�rXrc���dD]j}|�|��5|�td|z����}|�d|��ddd��n#1swxYwY�kdS)NrDz@                class C:
                    %s
                rErFrHs   r�test_classdocstringz"Test_pygettext.test_classdocstring�rJrKc��|�td����}|�d�|D����dS)Nz0        class C:
            b"""doc"""
        c��g|]}d|v�|��	SrNrOrPs  rrRz<Test_pygettext.test_classdocstring_bytes.<locals>.<listcomp>�rSrrTrVs  r�test_classdocstring_bytesz(Test_pygettext.test_classdocstring_bytes�rXrc��|�td����}|�d�|D����dS)Nz0        class C:
            f"""doc"""
        c��g|]}d|v�|��	SrNrOrPs  rrRz>Test_pygettext.test_classdocstring_fstring.<locals>.<listcomp>�rSrrTrVs  r�test_classdocstring_fstringz*Test_pygettext.test_classdocstring_fstring�rXrc�\�|�d��}|�d|��dS)Nz_("""doc""" r'str' u"ing")�	docstring)r6r9rVs  r�
test_msgidzTest_pygettext.test_msgid�s4���1�1�0�2�2���
�
�k�6�*�*�*�*�*rc�n�|�d��}|�d�|D����dS)Nz
_(b"""doc""")c��g|]}d|v�|��	SrNrOrPs  rrRz3Test_pygettext.test_msgid_bytes.<locals>.<listcomp>�rSr�r6rUrVs  r�test_msgid_byteszTest_pygettext.test_msgid_bytes��>���1�1�/�B�B�����F�F�V�F�F�F�G�G�G�G�Grc�n�|�d��}|�d�|D����dS)Nz
_(f"""doc""")c��g|]}d|v�|��	SrNrOrPs  rrRz5Test_pygettext.test_msgid_fstring.<locals>.<listcomp>�rSrrirVs  r�test_msgid_fstringz!Test_pygettext.test_msgid_fstring�rkrc�v�|�td����}|�d|��dS)z3 Test docstrings for functions with annotated args z9        def foo(bar: str):
            """doc"""
        rEN�r6rr9rVs  r�!test_funcdocstring_annotated_argsz0Test_pygettext.test_funcdocstring_annotated_args��D���1�1�&�:�3
�3
����	
�
�
�e�V�$�$�$�$�$rc�v�|�td����}|�d|��dS)z: Test docstrings for functions with annotated return type z;        def foo(bar) -> str:
            """doc"""
        rENrprVs  r�#test_funcdocstring_annotated_returnz2Test_pygettext.test_funcdocstring_annotated_return�rrrc�v�|�td����}|�d|��dS)z6 Test docstring for functions with default arg values z7        def foo(bar=()):
            """doc"""
        rENrprVs  r� test_funcdocstring_defvalue_argsz/Test_pygettext.test_funcdocstring_defvalue_args�rrrc���|�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"""
        �doc1�doc2�doc3NrprVs  r�!test_funcdocstring_multiple_funcsz0Test_pygettext.test_funcdocstring_multiple_funcs�sn���1�1�&�	:�	3
�	3
�	�	��	
�
�
�f�f�%�%�%��
�
�f�f�%�%�%��
�
�f�f�%�%�%�%�%rc�v�|�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"""
        rENrprVs  r�test_classdocstring_early_colonz.Test_pygettext.test_classdocstring_early_colon�sF���1�1�&�:�3
�3
����	
�
�
�e�V�$�$�$�$�$rc�v�|�td����}|�d|��dS)Nz"        f"{_('foo bar')}"
        �foo barrprVs  r�test_calls_in_fstringsz%Test_pygettext.test_calls_in_fstrings��D���1�1�&�:�3
�3
����	
�
�
�i��(�(�(�(�(rc�v�|�td����}|�d|��dS)Nz#        rf"{_('foo bar')}"
        rrprVs  r�test_calls_in_fstrings_rawz)Test_pygettext.test_calls_in_fstrings_raw�r�rc�v�|�td����}|�d|��dS)Nz+        f"""{f'{_("foo bar")}'}"""
        rrprVs  r�test_calls_in_fstrings_nestedz,Test_pygettext.test_calls_in_fstrings_nested�r�rc�v�|�td����}|�d|��dS)Nz&        f"{obj._('foo bar')}"
        rrprVs  r� test_calls_in_fstrings_attributez/Test_pygettext.test_calls_in_fstrings_attribute�r�rc�v�|�td����}|�d|��dS)Nz*        f"{type(str)('foo bar')}"
        r�r6r�assertNotInrVs  r�(test_calls_in_fstrings_with_call_on_callz7Test_pygettext.test_calls_in_fstrings_with_call_on_call�sF���1�1�&�:�3
�3
����	
����F�+�+�+�+�+rc�v�|�td����}|�d|��dS)Nz6        f"{_('foo {bar}').format(bar='baz')}"
        �	foo {bar}rprVs  r�"test_calls_in_fstrings_with_formatz1Test_pygettext.test_calls_in_fstrings_with_format�sD���1�1�&�:�3
�3
����	
�
�
�k�6�*�*�*�*�*rc��|�td����}|�d�|D����dS)Nz%        f"{_(f'foo {bar}')}"
        c��g|]}d|v�|��	S)r�rOrPs  rrRzLTest_pygettext.test_calls_in_fstrings_with_wrong_input_1.<locals>.<listcomp>s"��L�L�L�E�{�e�7K�L�%�L�L�LrrTrVs  r�)test_calls_in_fstrings_with_wrong_input_1z8Test_pygettext.test_calls_in_fstrings_with_wrong_input_1sS���1�1�&�:�3
�3
����	
���L�L�V�L�L�L�M�M�M�M�Mrc�v�|�td����}|�d|��dS)Nz        f"{_(1)}"
        rr�rVs  r�)test_calls_in_fstrings_with_wrong_input_2z8Test_pygettext.test_calls_in_fstrings_with_wrong_input_2	sF���1�1�&�:�3
�3
����	
����F�#�#�#�#�#rc��|�td����}|�d|��|�d|��dS)Nz%        f"{_('foo', 'bar')}"
        �foo�barr�rVs  r�(test_calls_in_fstring_with_multiple_argsz7Test_pygettext.test_calls_in_fstring_with_multiple_argss\���1�1�&�:�3
�3
����	
�����'�'�'������'�'�'�'�'rc���|�td����}|�d|��|�d|��|�d|��dS)Nz)        f"{_('foo', bar='baz')}"
        r�r��bazr�rVs  r�'test_calls_in_fstring_with_keyword_argsz6Test_pygettext.test_calls_in_fstring_with_keyword_argssr���1�1�&�:�3
�3
����	
�����'�'�'������'�'�'������'�'�'�'�'rc��|�td����}|�d|��|�d|��dS)Nz*        f"{_(f'foo') + _('bar')}"
        r�r�)r6rr�r9rVs  r�5test_calls_in_fstring_with_partially_wrong_expressionzDTest_pygettext.test_calls_in_fstring_with_partially_wrong_expressionsZ���1�1�&�:�3
�3
����	
�����'�'�'��
�
�e�V�$�$�$�$�$rc	�`�d}d}d}td��5td��5}tjtj�|d����t
tj�|dd��dd�	��5}|�d
|�d���ddd��n#1swxYwYtjtj�|d����t
tj�|dd
��dd�	��5}|�d
|�d���ddd��n#1swxYwYtjtj�|d����t
tj�|dd��dd�	��5}|�d
|�d���ddd��n#1swxYwYt|j	|��t
dd�	��5}|�
��}ddd��n#1swxYwY|�d|�d�|��|�d|�d�|��|�||��ddd��n#1swxYwYddd��dS#1swxYwYdS)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_list%s���%��$�� ��
�d�^�^�	*�	*�X�d�^�^�	*�t��H�R�W�\�\�$��0�0�1�1�1��b�g�l�l�4��*�=�=�s�&�(�(�(�
-�+0����O��O�O�O�,�,�,�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-�
�H�R�W�\�\�$��1�1�2�2�2��b�g�l�l�4��;�?�?��&�(�(�(�
-�+0����O��O�O�O�,�,�,�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-�
�H�R�W�\�\�$��.�.�/�/�/��b�g�l�l�4���<�<�c�&�(�(�(�
-�+0����O��O�O�O�,�,�,�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-�
-����
-�
-�
-�
-�
�T�[�$�/�/�/��n�w�7�7�7�
!�2��w�w�y�y��
!�
!�
!�
!�
!�
!�
!�
!�
!�
!�
!����
!�
!�
!�
!��M�M�,�E�,�,�,�d�3�3�3��M�M�,�E�,�,�,�d�3�3�3����U�D�)�)�)�%	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�	*�	*s��J#�A$J�
B0�$J�0B4�4J�7B4�8A&J�E�8J�E�J�E�A&J�2G�J�G�J�G� )J�	H*�J�*H.�.J�1H.�2A
J�?J#�J	�J#�J	�J#�#J'�*J'N)-�__name__�
__module__�__qualname__�__doc__r�r�r"rr0rr'r6r;�unittest�skipIf�sys�platformrrBrIrWr[r]r`rcrfrjrnrqrtrvr{r}r�r�r�r�r�r�r�r�r�r�r�r�rOrrr
r
sL������)�)�
�W�\�\�(�6�>�
:�
:�F�	�	�	����0	%�	%�	%�2�2�2�4�X�_�S�\�,�,�U�3�3�4�6�6�@�@�6�6�@�"-�-�-�H�H�H�H�H�H�-�-�-�H�H�H�H�H�H�+�+�+�
H�H�H�H�H�H�%�%�%�%�%�%�%�%�%�&�&�&�$%�%�%�)�)�)�)�)�)�)�)�)�)�)�)�,�,�,�+�+�+�N�N�N�$�$�$�(�(�(�(�(�(�%�%�%�*�*�*�*�*rr
)r�r�r�r��textwrapr�test.support.script_helperr�test.test_toolsrr�test.support.os_helperrr�TestCaser
rOrr�<module>r�s���+�+�	�	�	�	�
�
�
�
�����������7�7�7�7�7�7�5�5�5�5�5�5�5�5�5�5�5�5�5�5�5�5������n*�n*�n*�n*�n*�X�&�n*�n*�n*�n*�n*r