B
    u9ay                 @   sr  d dl Z d dlZd dlZd dlZd dlZd dlmZ dZdZdZ	dZ
dZe jdd	Ze jed
Ze jedZe jedZe jedZe jedZG dd dejZdZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG d d! d!ejZG d"d# d#eZ G d$d% d%ejZ!d&d' Z"e#d(krne"  dS ))    N)supports  3hIElQAAAAAGAAAAHAAAAEwAAAALAAAAfAAAAAAAAACoAAAAFQAAAKkAAAAjAAAAvwAAAKEAAADj
AAAABwAAAIUBAAALAAAAjQEAAEUBAACZAQAAFgAAAN8CAAAeAAAA9gIAAKEAAAAVAwAABQAAALcD
AAAJAAAAvQMAAAEAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABQAAAAYAAAACAAAAAFJh
eW1vbmQgTHV4dXJ5IFlhY2gtdABUaGVyZSBpcyAlcyBmaWxlAFRoZXJlIGFyZSAlcyBmaWxlcwBU
aGlzIG1vZHVsZSBwcm92aWRlcyBpbnRlcm5hdGlvbmFsaXphdGlvbiBhbmQgbG9jYWxpemF0aW9u
CnN1cHBvcnQgZm9yIHlvdXIgUHl0aG9uIHByb2dyYW1zIGJ5IHByb3ZpZGluZyBhbiBpbnRlcmZh
Y2UgdG8gdGhlIEdOVQpnZXR0ZXh0IG1lc3NhZ2UgY2F0YWxvZyBsaWJyYXJ5LgBtdWxsdXNrAG51
ZGdlIG51ZGdlAFByb2plY3QtSWQtVmVyc2lvbjogMi4wClBPLVJldmlzaW9uLURhdGU6IDIwMDAt
MDgtMjkgMTI6MTktMDQ6MDAKTGFzdC1UcmFuc2xhdG9yOiBKLiBEYXZpZCBJYsOhw7FleiA8ai1k
YXZpZEBub29zLmZyPgpMYW5ndWFnZS1UZWFtOiBYWCA8cHl0aG9uLWRldkBweXRob24ub3JnPgpN
SU1FLVZlcnNpb246IDEuMApDb250ZW50LVR5cGU6IHRleHQvcGxhaW47IGNoYXJzZXQ9aXNvLTg4
NTktMQpDb250ZW50LVRyYW5zZmVy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UlkLVZlcnNpb246IDIuMApQTy1S
ZXZpc2lvbi1EYXRlOiAyMDAzLTA0LTExIDEyOjQyLTA0MDAKTGFzdC1UcmFuc2xhdG9yOiBCYXJy
eSBBLiBXQXJzYXcgPGJhcnJ5QHB5dGhvbi5vcmc+Ckxhbmd1YWdlLVRlYW06IFhYIDxweXRob24t
ZGV2QHB5dGhvbi5vcmc+Ck1JTUUtVmVyc2lvbjogMS4wCkNvbnRlbnQtVHlwZTogdGV4dC9wbGFp
bjsgY2hhcnNldD11dGYtOApDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiA3Yml0CkdlbmVyYXRl
ZC1CeTogbWFudWFsbHkKAMKkeXoA
sL  3hIElQAAAAABAAAAHAAAACQAAAADAAAALAAAAAAAAAA4AAAAeAEAADkAAAABAAAAAAAAAAAAAAAA
UHJvamVjdC1JZC1WZXJzaW9uOiBObyBQcm9qZWN0IDAuMApQT1QtQ3JlYXRpb24tRGF0ZTogV2Vk
IERlYyAxMSAwNzo0NDoxNSAyMDAyClBPLVJldmlzaW9uLURhdGU6IDIwMDItMDgtMTQgMDE6MTg6
NTgrMDA6MDAKTGFzdC1UcmFuc2xhdG9yOiBKb2huIERvZSA8amRvZUBleGFtcGxlLmNvbT4KSmFu
ZSBGb29iYXIgPGpmb29iYXJAZXhhbXBsZS5jb20+Ckxhbmd1YWdlLVRlYW06IHh4IDx4eEBleGFt
cGxlLmNvbT4KTUlNRS1WZXJzaW9uOiAxLjAKQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFy
c2V0PWlzby04ODU5LTE1CkNvbnRlbnQtVHJhbnNmZXItRW5jb2Rpbmc6IHF1b3RlZC1wcmludGFi
bGUKR2VuZXJhdGVkLUJ5OiBweWdldHRleHQucHkgMS4zCgA=
xxLC_MESSAGESz
gettext.mozgettext_bad_major_version.mozgettext_bad_minor_version.mozugettext.mozmetadata.moc               @   s   e Zd Zdd Zdd ZdS )GettextBaseTestc          	   C   s   t jtst t ttd}|t	t
 W d Q R X ttd}|t	t W d Q R X ttd}|t	t W d Q R X ttd}|t	t W d Q R X ttd}|t	t W d Q R X t | _d| jd< tj  d S )Nwbr   LANGUAGE)ospathisdir	LOCALEDIRmakedirsopenMOFILEwritebase64decodebytesGNU_MO_DATAMOFILE_BAD_MAJOR_VERSIONGNU_MO_DATA_BAD_MAJOR_VERSIONMOFILE_BAD_MINOR_VERSIONGNU_MO_DATA_BAD_MINOR_VERSIONUMOFILEUMO_DATAMMOFILEMMO_DATAr   ZEnvironmentVarGuardenvgettext_translationsclear)selffp r!   "/usr/lib/python3.7/test_gettext.pysetUps   s    


zGettextBaseTest.setUpc             C   s(   | j   | ` ttjtd  d S )Nr   )r   __exit__r   Zrmtreer   r	   splitr   )r   r!   r!   r"   tearDown   s    
zGettextBaseTest.tearDownN)__name__
__module____qualname__r#   r&   r!   r!   r!   r"   r   r   s   r   s   3hIElQAAAAABAAAAHAAAACQAAAAAAAAAAAAAAAAAAAAsAAAAggAAAC0AAAAAUGx1cmFsLUZvcm1z
OiBucGx1cmFscz0yOyBwbHVyYWw9KG4gIT0gMSk7CiMtIy0jLSMtIyAgbWVzc2FnZXMucG8gKEVk
WCBTdHVkaW8pICAjLSMtIy0jLSMKQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFyc2V0PVVU
Ri04CgA=
c               @   sD   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dS )GettextTestCase1c             C   s*   t |  tj| _t| _td| j d S )Nr   )	r   r#   r   curdir	localedirr   mofiler   install)r   r!   r!   r"   r#      s    
zGettextTestCase1.setUpc             C   sB   | j }|tdd |tdd |tdd |tdd d S )N	albatrossmulluskbaconzRaymond Luxury Yach-tzThroatwobbler Mangroveznudge nudgez	wink wink)assertEqual_)r   eqr!   r!   r"   test_some_translations   s
    z'GettextTestCase1.test_some_translationsc             C   sB   | j }|tdd |tdd |tdd |tdd d S )Nr/   r0   r1   zRaymond Luxury Yach-tzThroatwobbler Mangroveznudge nudgez	wink wink)r2   r3   )r   r4   r!   r!   r"   test_double_quotes   s
    z#GettextTestCase1.test_double_quotesc             C   sB   | j }|tdd |tdd |tdd |tdd d S )Nr/   r0   r1   zRaymond Luxury Yach-tzThroatwobbler Mangroveznudge nudgez	wink wink)r2   r3   )r   r4   r!   r!   r"   test_triple_single_quotes   s
    z*GettextTestCase1.test_triple_single_quotesc             C   sB   | j }|tdd |tdd |tdd |tdd d S )Nr/   r0   r1   zRaymond Luxury Yach-tzThroatwobbler Mangroveznudge nudgez	wink wink)r2   r3   )r   r4   r!   r!   r"   test_triple_double_quotes   s
    z*GettextTestCase1.test_triple_double_quotesc             C   s   | j }|tdd d S )NzThis module provides internationalization and localization
support for your Python programs by providing an interface to the GNU
gettext message catalog library.zGuvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba
fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH
trggrkg zrffntr pngnybt yvoenel.)r2   r3   )r   r4   r!   r!   r"   test_multiline_strings   s    z'GettextTestCase1.test_multiline_stringsc          	   C   s   | j }t| jd}t|}W d Q R X |  |tdd |  |tdd dd l}|jddgd	 |t|j ||j|j |t|j |`|`d S )
Nrbznudge nudgez	wink winkr0   r1   r   r   lgettext)names)	r2   r   r-   r   GNUTranslationsr.   r3   builtinsr;   )r   r4   r    tr>   r!   r!   r"   test_the_alternative_interface   s    z/GettextTestCase1.test_the_alternative_interfaceN)
r'   r(   r)   r#   r5   r6   r7   r8   r9   r@   r!   r!   r!   r"   r*      s   
r*   c               @   s\   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd ZdS )GettextTestCase2c             C   s6   t |  tj| _td| j td tj| _d S )Nr   )	r   r#   r   r+   r,   r   bindtextdomain
textdomainr3   )r   r!   r!   r"   r#      s
    

zGettextTestCase2.setUpc             C   s   |  td| j d S )Nr   )r2   r   rB   r,   )r   r!   r!   r"   test_bindtextdomain   s    z$GettextTestCase2.test_bindtextdomainc             C   s   |  t d d S )Nr   )r2   r   rC   )r   r!   r!   r"   test_textdomain   s    z GettextTestCase2.test_textdomainc          
   C   sj   t tdV}| t}t| W d Q R X |j}| |jd | |j	d | |j
t W d Q R X d S )Nr:   r   zBad version number 5)r   r   assertRaisesOSErrorr   r=   	exceptionr2   errnostrerrorfilename)r   r    cmrH   r!   r!   r"   test_bad_major_version   s    z'GettextTestCase2.test_bad_major_versionc          	   C   s$   t td}t| W d Q R X d S )Nr:   )r   r   r   r=   )r   r    r!   r!   r"   test_bad_minor_version   s    z'GettextTestCase2.test_bad_minor_versionc             C   sJ   | j }|| dd || dd || dd || dd d S )Nr/   r0   r1   zRaymond Luxury Yach-tzThroatwobbler Mangroveznudge nudgez	wink wink)r2   r3   )r   r4   r!   r!   r"   r5      s
    z'GettextTestCase2.test_some_translationsc             C   sJ   | j }|| dd || dd || dd || dd d S )Nr/   r0   r1   zRaymond Luxury Yach-tzThroatwobbler Mangroveznudge nudgez	wink wink)r2   r3   )r   r4   r!   r!   r"   r6      s
    z#GettextTestCase2.test_double_quotesc             C   sJ   | j }|| dd || dd || dd || dd d S )Nr/   r0   r1   zRaymond Luxury Yach-tzThroatwobbler Mangroveznudge nudgez	wink wink)r2   r3   )r   r4   r!   r!   r"   r7     s
    z*GettextTestCase2.test_triple_single_quotesc             C   sJ   | j }|| dd || dd || dd || dd d S )Nr/   r0   r1   zRaymond Luxury Yach-tzThroatwobbler Mangroveznudge nudgez	wink wink)r2   r3   )r   r4   r!   r!   r"   r8     s
    z*GettextTestCase2.test_triple_double_quotesc             C   s   | j }|| dd d S )NzThis module provides internationalization and localization
support for your Python programs by providing an interface to the GNU
gettext message catalog library.zGuvf zbqhyr cebivqrf vagreangvbanyvmngvba naq ybpnyvmngvba
fhccbeg sbe lbhe Clguba cebtenzf ol cebivqvat na vagresnpr gb gur TAH
trggrkg zrffntr pngnybt yvoenel.)r2   r3   )r   r4   r!   r!   r"   r9     s    z'GettextTestCase2.test_multiline_stringsN)r'   r(   r)   r#   rD   rE   rM   rN   r5   r6   r7   r8   r9   r!   r!   r!   r"   rA      s   	
rA   c               @   s   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/S )0PluralFormsTestCasec             C   s   t |  t| _d S )N)r   r#   r   r-   )r   r!   r!   r"   r#   !  s    
zPluralFormsTestCase.setUpc             C   s:   | j }tddd}||d tddd}||d d S )NzThere is %s filezThere are %s files   zHay %s fichero   zHay %s ficheros)r2   r   ngettext)r   r4   xr!   r!   r"   test_plural_forms1%  s
    
z&PluralFormsTestCase.test_plural_forms1c          	   C   s\   | j }t| jd}t|}W d Q R X |ddd}||d |ddd}||d d S )Nr:   zThere is %s filezThere are %s filesrP   zHay %s ficherorQ   zHay %s ficheros)r2   r   r-   r   r=   rR   )r   r4   r    r?   rS   r!   r!   r"   test_plural_forms2,  s    
z&PluralFormsTestCase.test_plural_forms2c                s:   | j }td d fddtdD }||d d S )N0 c                s   g | ]}t  |qS r!   )str).0rS   )fr!   r"   
<listcomp>:  s    z/PluralFormsTestCase.test_ja.<locals>.<listcomp>   Z00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)r2   r   c2pyjoinrange)r   r4   sr!   )rZ   r"   test_ja7  s    
zPluralFormsTestCase.test_jac                s:   | j }td d fddtdD }||d d S )Nzn != 1rW   c                s   g | ]}t  |qS r!   )rX   )rY   rS   )rZ   r!   r"   r[   @  s    z/PluralFormsTestCase.test_de.<locals>.<listcomp>r\   Z10111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111)r2   r   r]   r^   r_   )r   r4   r`   r!   )rZ   r"   test_de=  s    
zPluralFormsTestCase.test_dec                s:   | j }td d fddtdD }||d d S )Nzn>1rW   c                s   g | ]}t  |qS r!   )rX   )rY   rS   )rZ   r!   r"   r[   F  s    z/PluralFormsTestCase.test_fr.<locals>.<listcomp>r\   Z00111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111)r2   r   r]   r^   r_   )r   r4   r`   r!   )rZ   r"   test_frC  s    
zPluralFormsTestCase.test_frc                s:   | j }td d fddtdD }||d d S )Nz)n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2rW   c                s   g | ]}t  |qS r!   )rX   )rY   rS   )rZ   r!   r"   r[   L  s    z/PluralFormsTestCase.test_lv.<locals>.<listcomp>r\   Z20111111111111111111101111111110111111111011111111101111111110111111111011111111101111111110111111111011111111111111111110111111111011111111101111111110111111111011111111101111111110111111111011111111)r2   r   r]   r^   r_   )r   r4   r`   r!   )rZ   r"   test_lvI  s    
zPluralFormsTestCase.test_lvc                s:   | j }td d fddtdD }||d d S )Nzn==1 ? 0 : n==2 ? 1 : 2rW   c                s   g | ]}t  |qS r!   )rX   )rY   rS   )rZ   r!   r"   r[   R  s    z/PluralFormsTestCase.test_gd.<locals>.<listcomp>r\   20122222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222)r2   r   r]   r^   r_   )r   r4   r`   r!   )rZ   r"   test_gdO  s    
zPluralFormsTestCase.test_gdc                s:   | j }td d fddtdD }||d d S )Nzn==1 ? 0 : (n==2 ? 1 : 2)rW   c                s   g | ]}t  |qS r!   )rX   )rY   rS   )rZ   r!   r"   r[   Y  s    z0PluralFormsTestCase.test_gd2.<locals>.<listcomp>r\   re   )r2   r   r]   r^   r_   )r   r4   r`   r!   )rZ   r"   test_gd2U  s    
zPluralFormsTestCase.test_gd2c                s:   | j }td d fddtdD }||d d S )Nz6n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < 20)) ? 1 : 2rW   c                s   g | ]}t  |qS r!   )rX   )rY   rS   )rZ   r!   r"   r[   _  s    z/PluralFormsTestCase.test_ro.<locals>.<listcomp>r\   Z10111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222111111111111111111122222222222222222222222222222222222222222222222222222222222222222222222222222222)r2   r   r]   r^   r_   )r   r4   r`   r!   )rZ   r"   test_ro\  s    
zPluralFormsTestCase.test_roc                s:   | j }td d fddtdD }||d d S )NzEn%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2rW   c                s   g | ]}t  |qS r!   )rX   )rY   rS   )rZ   r!   r"   r[   e  s    z/PluralFormsTestCase.test_lt.<locals>.<listcomp>r\   Z20111111112222222222201111111120111111112011111111201111111120111111112011111111201111111120111111112011111111222222222220111111112011111111201111111120111111112011111111201111111120111111112011111111)r2   r   r]   r^   r_   )r   r4   r`   r!   )rZ   r"   test_ltb  s    
zPluralFormsTestCase.test_ltc                s:   | j }td d fddtdD }||d d S )NzPn%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2rW   c                s   g | ]}t  |qS r!   )rX   )rY   rS   )rZ   r!   r"   r[   k  s    z/PluralFormsTestCase.test_ru.<locals>.<listcomp>r\   Z20111222222222222222201112222220111222222011122222201112222220111222222011122222201112222220111222222011122222222222222220111222222011122222201112222220111222222011122222201112222220111222222011122222)r2   r   r]   r^   r_   )r   r4   r`   r!   )rZ   r"   test_ruh  s    
zPluralFormsTestCase.test_ruc                s:   | j }td d fddtdD }||d d S )Nz#(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2rW   c                s   g | ]}t  |qS r!   )rX   )rY   rS   )rZ   r!   r"   r[   q  s    z/PluralFormsTestCase.test_cs.<locals>.<listcomp>r\   Z20111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222)r2   r   r]   r^   r_   )r   r4   r`   r!   )rZ   r"   test_csn  s    
zPluralFormsTestCase.test_csc                s:   | j }td d fddtdD }||d d S )Nz@n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2rW   c                s   g | ]}t  |qS r!   )rX   )rY   rS   )rZ   r!   r"   r[   w  s    z/PluralFormsTestCase.test_pl.<locals>.<listcomp>r\   Z20111222222222222222221112222222111222222211122222221112222222111222222211122222221112222222111222222211122222222222222222111222222211122222221112222222111222222211122222221112222222111222222211122222)r2   r   r]   r^   r_   )r   r4   r`   r!   )rZ   r"   test_plt  s    
zPluralFormsTestCase.test_plc                s:   | j }td d fddtdD }||d d S )Nz:n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3rW   c                s   g | ]}t  |qS r!   )rX   )rY   rS   )rZ   r!   r"   r[   }  s    z/PluralFormsTestCase.test_sl.<locals>.<listcomp>r\   Z30122333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333012233333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333)r2   r   r]   r^   r_   )r   r4   r`   r!   )rZ   r"   test_slz  s    
zPluralFormsTestCase.test_slc                s:   | j }td d fddtdD }||d d S )NzNn==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5rW   c                s   g | ]}t  |qS r!   )rX   )rY   rS   )rZ   r!   r"   r[     s    z/PluralFormsTestCase.test_ar.<locals>.<listcomp>r\   Z01233333333444444444444444444444444444444444444444444444444444444444444444444444444444444444444444445553333333344444444444444444444444444444444444444444444444444444444444444444444444444444444444444444)r2   r   r]   r^   r_   )r   r4   r`   r!   )rZ   r"   test_ar  s    
zPluralFormsTestCase.test_arc             C   s   | j }|ttjd |ttjd |ttjd |ttjdd d  | tddd	 |ttjd
 |ttjdd d dd   | tddd d S )Nzos.chmod('/etc/passwd',0777)z"(eval(foo) && ""zf"{os.system('sh')}"zn+i'  nzn+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+n+nrP   e   z((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((n))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))()z)((((((((((((((((((((n)))))))))))))))))))))rF   
ValueErrorr   r]   r2   )r   Zraisesr!   r!   r"   test_security  s    z!PluralFormsTestCase.test_securityc                s   t d | d fddtdD d t d | d fddtdD d	 t d
 | d fddtdD d t d | d fddtdD d d S )Nzn == n == nrW   c             3   s   | ]}t  |V  qd S )N)rX   )rY   rS   )rZ   r!   r"   	<genexpr>  s    z>PluralFormsTestCase.test_chained_comparison.<locals>.<genexpr>   Z010z
1 < n == nc             3   s   | ]}t  |V  qd S )N)rX   )rY   rS   )rZ   r!   r"   ru     s    Z100z
n == n < 2c             3   s   | ]}t  |V  qd S )N)rX   )rY   rS   )rZ   r!   r"   ru     s    z	0 < n < 2c             3   s   | ]}t  |V  qd S )N)rX   )rY   rS   )rZ   r!   r"   ru     s    Z111)r   r]   r2   r^   r_   )r   r!   )rZ   r"   test_chained_comparison  s    
$
$
$
z+PluralFormsTestCase.test_chained_comparisonc             C   s   |  tddd d S )NZ0123rP   {   )r2   r   r]   )r   r!   r!   r"   test_decimal_number  s    z'PluralFormsTestCase.test_decimal_numberc             C   sT   ddddddddd	d
dddddg}x,|D ]$}|  t t| W d Q R X q(W d S )Nzx>1z(n>1zn>1)z
42**42**42Z0xaz1.0Z1e2zn>0x1z+nz-nzn()zn(1)z1+nnzn n)rF   rs   r   r]   )r   Zinvalid_expressionsexprr!   r!   r"   test_invalid_syntax  s
    
z'PluralFormsTestCase.test_invalid_syntaxc             C   s\   |  tddd |  tddd |  tddd |  tddd d S )Nz	n?1?2:3:4r      rP   rQ   z	n?1:3?4:5)r2   r   r]   )r   r!   r!   r"   test_nested_condition_operator  s    z2PluralFormsTestCase.test_nested_condition_operatorc             C   s\   t d}| |dd | |dd | |dd | |dd | t|d d S )	Nz2/n*3rP      rQ   rv   r   i)r   r]   r2   rF   ZeroDivisionError)r   rZ   r!   r!   r"   test_division  s    
z!PluralFormsTestCase.test_divisionc          	   C   s   t d}| |dd | |dd | t | |dd W d Q R X | t | |dd W d Q R X | t | |dd W d Q R X | t|d | t|d	 | t|g  | t|t  d S )
Nzn != 1rP   r   rQ   g      ?g       @g?2   2)r   r]   r2   ZassertWarnsDeprecationWarningrF   	TypeErrorobject)r   rZ   r!   r!   r"   test_plural_number  s    
z&PluralFormsTestCase.test_plural_numberN)r'   r(   r)   r#   rT   rU   ra   rb   rc   rd   rf   rg   rh   ri   rj   rk   rl   rm   rn   rt   rw   ry   r|   r~   r   r   r!   r!   r!   r"   rO      s.   	rO   c               @   sT   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd ZdS )LGettextTestCasec             C   s   t |  t| _d S )N)r   r#   r   r-   )r   r!   r!   r"   r#     s    
zLGettextTestCase.setUpc             C   sT   t j}t j}| |dd | |dd | |ddd | |ddd d S )Nr0   s   baconspams   spamr   )r   r;   	ldgettextr2   )r   r;   r   r!   r!   r"   test_lgettext  s    zLGettextTestCase.test_lgettextc          	   C   sL   t | jd}t|}W d Q R X |j}| |dd | |dd d S )Nr:   r0   s   baconr   s   spam)r   r-   r   r=   r;   r2   )r   r    r?   r;   r!   r!   r"   test_lgettext_2  s
    z LGettextTestCase.test_lgettext_2c          
   C   s   t j}t j}t d}zlt dd | |ddd | |ddd | |dddd | |dddd W d t jd= t d| X d S )Nr   zutf-16r0   r1   r   )r   r;   r   bind_textdomain_codesetr2   encode_localecodesets)r   r;   r   saved_codesetr!   r!   r"   %test_lgettext_bind_textdomain_codeset  s    
z6LGettextTestCase.test_lgettext_bind_textdomain_codesetc          	   C   sb   t | jd}t|}W d Q R X |j}|d | |ddd | |ddd d S )Nr:   zutf-16r0   r1   r   )r   r-   r   r=   r;   set_output_charsetr2   r   )r   r    r?   r;   r!   r!   r"   test_lgettext_output_encoding  s    
z.LGettextTestCase.test_lgettext_output_encodingc             C   s   t j}t j}|ddd}| |d |ddd}| |d |ddd}| |d	 |ddd}| |d
 |dddd}| |d |dddd}| |d |dddd}| |d	 |dddd}| |d
 d S )NzThere is %s filezThere are %s filesrP   s   Hay %s ficherorQ   s   Hay %s ficheroszThere is %s directoryzThere are %s directoriess   There is %s directorys   There are %s directoriesr   )r   	lngettext
ldngettextr2   )r   r   r   rS   r!   r!   r"   test_lngettext  s$    zLGettextTestCase.test_lngettextc          	   C   s   t | jd}t|}W d Q R X |j}|ddd}| |d |ddd}| |d |dd	d}| |d
 |dd	d}| |d d S )Nr:   zThere is %s filezThere are %s filesrP   s   Hay %s ficherorQ   s   Hay %s ficheroszThere is %s directoryzThere are %s directoriess   There is %s directorys   There are %s directories)r   r-   r   r=   r   r2   )r   r    r?   r   rS   r!   r!   r"   test_lngettext_2	  s    z!LGettextTestCase.test_lngettext_2c          
   C   s<  t j}t j}t d}zt dd |ddd}| |dd |ddd}| |dd |d	d
d}| |d	d |d	d
d}| |d
d |dddd}| |dd |dddd}| |dd |dd	d
d}| |d	d |dd	d
d}| |d
d W d t jd= t d| X d S )Nr   zutf-16zThere is %s filezThere are %s filesrP   zHay %s ficherorQ   zHay %s ficheroszThere is %s directoryzThere are %s directories)r   r   r   r   r2   r   r   )r   r   r   r   rS   r!   r!   r"   &test_lngettext_bind_textdomain_codeset  s.    
z7LGettextTestCase.test_lngettext_bind_textdomain_codesetc          	   C   s   t | jd}t|}W d Q R X |j}|d |ddd}| |dd |ddd}| |dd |d	d
d}| |d	d |d	d
d}| |d
d d S )Nr:   zutf-16zThere is %s filezThere are %s filesrP   zHay %s ficherorQ   zHay %s ficheroszThere is %s directoryzThere are %s directories)r   r-   r   r=   r   r   r2   r   )r   r    r?   r   rS   r!   r!   r"   test_lngettext_output_encoding0  s    
z/LGettextTestCase.test_lngettext_output_encodingN)r'   r(   r)   r#   r   r   r   r   r   r   r   r   r!   r!   r!   r"   r     s   r   c               @   s   e Zd Zdd ZdS )GNUTranslationParsingTestc          	   C   sJ   t td}|tt W d Q R X t td}t|}W d Q R X d S )Nr   r:   )r   r   r   r   r   GNU_MO_DATA_ISSUE_17898r   r=   )r   r    r?   r!   r!   r"   !test_plural_form_error_issue17898@  s    z;GNUTranslationParsingTest.test_plural_form_error_issue17898N)r'   r(   r)   r   r!   r!   r!   r"   r   ?  s   r   c               @   s$   e Zd Zdd Zdd Zdd ZdS )UnicodeTranslationsTestc          	   C   s:   t |  ttd}t|| _W d Q R X | jj| _d S )Nr:   )r   r#   r   r   r   r=   r?   r3   )r   r    r!   r!   r"   r#   I  s    
zUnicodeTranslationsTest.setUpc             C   s   |  | dt d S )NrW   )ZassertIsInstancer3   rX   )r   r!   r!   r"   test_unicode_msgidO  s    z*UnicodeTranslationsTest.test_unicode_msgidc             C   s   |  | dd d S )Nu   abÞu   ¤yz)r2   r3   )r   r!   r!   r"   test_unicode_msgstrR  s    z+UnicodeTranslationsTest.test_unicode_msgstrN)r'   r(   r)   r#   r   r   r!   r!   r!   r"   r   H  s   r   c               @   s   e Zd Zdd Zdd ZdS )WeirdMetadataTestc          	   C   sL   t |  ttd.}yt|| _W n   |    Y nX W d Q R X d S )Nr:   )r   r#   r   r   r   r=   r?   r&   )r   r    r!   r!   r"   r#   W  s    
zWeirdMetadataTest.setUpc             C   s.   | j  }| t|d | |d d d S )N	   zlast-translatorz=John Doe <jdoe@example.com>
Jane Foobar <jfoobar@example.com>)r?   infor2   len)r   r   r!   r!   r"   test_weird_metadata`  s    

z%WeirdMetadataTest.test_weird_metadataN)r'   r(   r)   r#   r   r!   r!   r!   r"   r   V  s   	r   c               @   s   e Zd Zdd ZdS )DummyGNUTranslationsc             C   s   dS )Nfoor!   )r   r!   r!   r"   r   h  s    zDummyGNUTranslations.fooN)r'   r(   r)   r   r!   r!   r!   r"   r   g  s   r   c               @   s   e Zd Zdd ZdS )GettextCacheTestCasec             C   s   t j| _t| _| ttjd t	d| j}| ttjd tj	d| jt
d}| ttjd | |jt
 tj	d| jt
d}| ttjd | |jt
 d S )Nr   r   rP   )class_rQ   )r   r+   r,   r   r-   r2   r   r   r   translationr   	__class__)r   r?   r!   r!   r"   
test_cachem  s    

zGettextCacheTestCase.test_cacheN)r'   r(   r)   r   r!   r!   r!   r"   r   l  s   r   c               @   s   e Zd Zdd ZdS )MiscTestCasec             C   s   ddh}t j| t|d d S )Nr]   ENOENT)	blacklist)r   Zcheck__all__r   )r   r   r!   r!   r"   test__all__  s    zMiscTestCase.test__all__N)r'   r(   r)   r   r!   r!   r!   r"   r     s   r   c               C   s   t t d S )N)r   Zrun_unittestr'   r!   r!   r!   r"   	test_main  s    r   __main__)$r   r   r   localeZunittestZtestr   r   r   r   r   r   r	   r^   r   r   r   r   r   r   ZTestCaser   r   r*   rA   rO   r   r   r   r   r=   r   r   r   r   r'   r!   r!   r!   r"   <module>   sB   FJ ,t	
u