Your IP : 216.73.216.213


Current Path : /opt/alt/python36/lib64/python3.6/test/test_tools/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/test/test_tools/__pycache__/test_i18n.cpython-36.opt-2.pyc

3

��2a�"�@sdddlZddlZddlmZddlmZddlmZmZddl	m
Z
mZe�Gdd�dej�Z
dS)�N)�dedent)�assert_python_ok)�skip_if_missing�toolsdir)�temp_cwd�temp_dirc@s�eZdZejjedd�Zdd�Zdd�Z	dd�Z
d	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+S),�Test_pygettextZi18nzpygettext.pycCsTi}xJ|jd�D]<}|s|jd�r&q|jd�}|jdd�\}}|j�||<qW|S)	N�
�#�msgid�msgstr�"�:�)r
rr)�split�
startswith�strip)�self�dataZheaders�line�key�val�r�./opt/alt/python36/lib64/python3.6/test_i18n.py�
get_headers
zTest_pygettext.get_headercCs�g}d}g}x�|jd�D]l}|rV|jd�r<|j|jd��n|jdj|��g}d}q|jd�r|td�d�}|j|jd��d}qW|r�|jdj|��|S)NFr	r
zmsgid T)rr�appendr�join�len)rr�msgidsZ
reading_msgidZ	cur_msgidrrrr�
get_msgidss$

zTest_pygettext.get_msgidscCsld}td��P}t|d��}|j|�WdQRXt|jd|�td��}|j�}WdQRXWdQRX|j|�S)Nztest_docstrings.py�wz-Dzmessages.pot)r�open�writer�script�readr)rZmodule_content�filename�cwd�fprrrr�extract_docstrings_from_str7s

z*Test_pygettext.extract_docstrings_from_strcCs�td���}t|j�td��}|j�}WdQRX|j|�}|jd|�|jd|�|jd|�|jd|�|jd|�|jd|�|jd|�|jd	|�|jd
|�WdQRXdS)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_headerBs



zTest_pygettext.test_headercCs�ddlm}td��f}t|j�td��}|j�}WdQRX|j|�}|d}|jd�rj|dtd��}|j	|d�WdQRXdS)Nr)�datetimez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}|j|��$|jtd|��}|jd|�WdQRXqWdS)N�	"""doc"""�
r'''doc'''�R'doc'�u"doc"zE                def foo(bar):
                    %s
                �doc)r/r0r1r2)�subTestr(rr))rr3rrrr�test_funcdocstringns

z!Test_pygettext.test_funcdocstringcCs&|jtd��}|jdd�|D��dS)Nz5        def foo(bar):
            b"""doc"""
        cSsg|]}d|kr|�qS)r3r)�.0rrrr�
<listcomp>|sz;Test_pygettext.test_funcdocstring_bytes.<locals>.<listcomp>)r(r�assertFalse)rrrrr�test_funcdocstring_byteswsz'Test_pygettext.test_funcdocstring_bytescCs&|jtd��}|jdd�|D��dS)Nz5        def foo(bar):
            f"""doc"""
        cSsg|]}d|kr|�qS)r3r)r6rrrrr7�sz=Test_pygettext.test_funcdocstring_fstring.<locals>.<listcomp>)r(rr8)rrrrr�test_funcdocstring_fstring~sz)Test_pygettext.test_funcdocstring_fstringcCsFx@dD]8}|j|��$|jtd|��}|jd|�WdQRXqWdS)N�	"""doc"""�
r'''doc'''�R'doc'�u"doc"z@                class C:
                    %s
                r3)r;r<r=r>)r4r(rr))rr3rrrr�test_classdocstring�s

z"Test_pygettext.test_classdocstringcCs&|jtd��}|jdd�|D��dS)Nz0        class C:
            b"""doc"""
        cSsg|]}d|kr|�qS)r3r)r6rrrrr7�sz<Test_pygettext.test_classdocstring_bytes.<locals>.<listcomp>)r(rr8)rrrrr�test_classdocstring_bytes�sz(Test_pygettext.test_classdocstring_bytescCs&|jtd��}|jdd�|D��dS)Nz0        class C:
            f"""doc"""
        cSsg|]}d|kr|�qS)r3r)r6rrrrr7�sz>Test_pygettext.test_classdocstring_fstring.<locals>.<listcomp>)r(rr8)rrrrr�test_classdocstring_fstring�sz*Test_pygettext.test_classdocstring_fstringcCs|jd�}|jd|�dS)Nz_("""doc""" r'str' u"ing")Z	docstring)r(r))rrrrr�
test_msgid�szTest_pygettext.test_msgidcCs"|jd�}|jdd�|D��dS)Nz
_(b"""doc""")cSsg|]}d|kr|�qS)r3r)r6rrrrr7�sz3Test_pygettext.test_msgid_bytes.<locals>.<listcomp>)r(r8)rrrrr�test_msgid_bytes�s
zTest_pygettext.test_msgid_bytescCs"|jd�}|jdd�|D��dS)Nz
_(f"""doc""")cSsg|]}d|kr|�qS)r3r)r6rrrrr7�sz5Test_pygettext.test_msgid_fstring.<locals>.<listcomp>)r(r8)rrrrr�test_msgid_fstring�s
z!Test_pygettext.test_msgid_fstringcCs|jtd��}|jd|�dS)Nz9        def foo(bar: str):
            """doc"""
        r3)r(rr))rrrrr�!test_funcdocstring_annotated_args�sz0Test_pygettext.test_funcdocstring_annotated_argscCs|jtd��}|jd|�dS)Nz;        def foo(bar) -> str:
            """doc"""
        r3)r(rr))rrrrr�#test_funcdocstring_annotated_return�sz2Test_pygettext.test_funcdocstring_annotated_returncCs|jtd��}|jd|�dS)Nz7        def foo(bar=()):
            """doc"""
        r3)r(rr))rrrrr� test_funcdocstring_defvalue_args�sz/Test_pygettext.test_funcdocstring_defvalue_argscCs6|jtd��}|jd|�|jd|�|jd|�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"""
        Zdoc1Zdoc2Zdoc3)r(rr))rrrrr�!test_funcdocstring_multiple_funcs�s
	z0Test_pygettext.test_funcdocstring_multiple_funcscCs|jtd��}|jd|�dS)Nz\        class D(L[1:2], F({1: 2}), metaclass=M(lambda x: x)):
            """doc"""
        r3)r(rr))rrrrr�test_classdocstring_early_colon�sz.Test_pygettext.test_classdocstring_early_colonc.Cspd}d}d}td���Ptd���:}tjtjj|d��ttjj|dd�d��}|jd|�d��WdQRXtjtjj|d	��ttjj|d	d
�d��}|jd|�d��WdQRXtjtjj|d��ttjj|dd�d��}|jd|�d��WdQRXt|j	|�td
��}|j
�}WdQRX|jd|�d�|�|jd|�d�|�|j||�WdQRXWdQRXdS)NzText to translate1zText to translate2zText to ignoreZpypkgzpymod.pyr z_(�)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__rKrMrrr#rrr(r+r.r5r9r:r?r@rArBrCrDrErFrGrHrIrNrrrrrs*		
r)rKZunittest�textwraprZtest.support.script_helperrZtest.test_toolsrrZtest.supportrrZTestCaserrrrr�<module>s